From 519f6d03c3784eb10b75c5dee69a4ee59eeaad0b Mon Sep 17 00:00:00 2001 From: Robert Lv Date: Thu, 28 Nov 2024 14:44:58 +0800 Subject: [PATCH] fix: Switching unresponsive in technical preview Remove input method support and related code Remove package installation operation Log: pms: BUG-282157 --- dcc-insider/operation/dccinsider.cpp | 11 +- dcc-insider/operation/insiderworker.cpp | 99 ------------------ dcc-insider/operation/insiderworker.h | 10 -- dcc-insider/operation/pkpackagesproxy.cpp | 117 ---------------------- dcc-insider/operation/pkpackagesproxy.h | 44 -------- dcc-insider/qml/main.qml | 4 +- debian/changelog | 6 ++ 7 files changed, 9 insertions(+), 282 deletions(-) delete mode 100644 dcc-insider/operation/pkpackagesproxy.cpp delete mode 100644 dcc-insider/operation/pkpackagesproxy.h diff --git a/dcc-insider/operation/dccinsider.cpp b/dcc-insider/operation/dccinsider.cpp index 7f1e1db..c54107f 100644 --- a/dcc-insider/operation/dccinsider.cpp +++ b/dcc-insider/operation/dccinsider.cpp @@ -13,9 +13,8 @@ DccInsider::DccInsider(QObject *parent) : QObject(parent) , m_insider(new InsiderWorker(this)) { - m_currentItems.append({ m_insider->displayManager(), m_insider->inputMethod() }); + m_currentItems.append({ m_insider->displayManager() }); connect(m_insider, &InsiderWorker::displayManagerChanged, this, &DccInsider::updateCurrentItem); - connect(m_insider, &InsiderWorker::inputMethodChanged, this, &DccInsider::updateCurrentItem); } DccInsider::~DccInsider() { } @@ -29,8 +28,6 @@ void DccInsider::setCurrentItem(const QString &item) { if (item == "lightdm" || item == "treeland") { m_insider->setDisplayManager(item); - } else if (item == "fcitx5" || item == "deepin-im") { - m_insider->setInputMethod(item); } } @@ -42,12 +39,6 @@ void DccInsider::updateCurrentItem(const QString &item) } else if (item == "treeland") { m_currentItems.removeOne("lightdm"); m_currentItems.append("treeland"); - } else if (item == "fcitx5") { - m_currentItems.removeOne("deepin-im"); - m_currentItems.append("fcitx5"); - } else if (item == "deepin-im") { - m_currentItems.removeOne("fcitx5"); - m_currentItems.append("deepin-im"); } Q_EMIT currentItemsChanged(m_currentItems); } diff --git a/dcc-insider/operation/insiderworker.cpp b/dcc-insider/operation/insiderworker.cpp index d6820a1..e3fd24a 100644 --- a/dcc-insider/operation/insiderworker.cpp +++ b/dcc-insider/operation/insiderworker.cpp @@ -3,8 +3,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "insiderworker.h" -#include "pkpackagesproxy.h" - #include #include @@ -13,11 +11,8 @@ namespace insider { InsiderWorker::InsiderWorker(QObject *parent) : QObject(parent) , m_displayManager("lightdm") - , m_inputMethod("fcitx5") - , m_pkProxy(new PkPackagesProxy(this)) { QMetaObject::invokeMethod(this, &InsiderWorker::checkEnabledDisplayManager, Qt::QueuedConnection); - QMetaObject::invokeMethod(this, &InsiderWorker::checkEnabledInputMethod, Qt::QueuedConnection); } InsiderWorker::~InsiderWorker() { } @@ -27,44 +22,16 @@ QString InsiderWorker::displayManager() const return m_displayManager; } -QString InsiderWorker::inputMethod() const -{ - return m_inputMethod; -} - void InsiderWorker::setDisplayManager(const QString &id) { if (m_displayManager == id) { return; } bool isNew = id == "treeland"; - if (isNew && !installPackage("ddm")) { - return; - } - if (!installPackage(id)) { - return; - } switchDisplayManager(isNew); - if (isNew) { - setInputMethod("deepin-im"); - installDDEShell(); - } checkEnabledDisplayManager(); } -void InsiderWorker::setInputMethod(const QString &id) -{ - if (m_inputMethod == id) { - return; - } - bool isNew = id == "deepin-im"; - if (!installPackage(id)) { - return; - } - switchInputMethod(isNew); - checkEnabledInputMethod(); -} - void InsiderWorker::checkEnabledDisplayManager() { QProcess *process = new QProcess(this); @@ -75,35 +42,6 @@ void InsiderWorker::checkEnabledDisplayManager() process->start(); } -static bool imConfigIsDim() -{ - auto home = QDir::home(); - QFile file(home.filePath(".xinputrc")); - - if (file.exists() && file.open(QFile::ReadOnly)) { - QTextStream in(&file); - QString line; - do { - line = in.readLine(); - if (line.contains("run_im dim")) { - return true; - } - } while (!line.isNull()); - } - - return false; -} - -void InsiderWorker::checkEnabledInputMethod() -{ - bool isDim = imConfigIsDim(); - QString inputMethod = isDim ? "deepin-im" : "fcitx5"; - if (m_inputMethod != inputMethod) { - m_inputMethod = inputMethod; - Q_EMIT inputMethodChanged(m_inputMethod); - } -} - void InsiderWorker::onDisplayManagerFinished() { QProcess *process = qobject_cast(sender()); @@ -118,8 +56,6 @@ void InsiderWorker::onDisplayManagerFinished() } } -void InsiderWorker::onInputMethodFinished() { } - void InsiderWorker::switchDisplayManager(bool isNew) { QProcess process; @@ -142,40 +78,5 @@ void InsiderWorker::switchDisplayManager(bool isNew) qDebug() << "switchDisplayManager: " << process.readAll(); } -void InsiderWorker::installDDEShell() -{ - if (installPackage("dde-shell")) { - checkEnabledDisplayManager(); - } -} - -bool InsiderWorker::installPackage(const QString &package) -{ - m_pkProxy->resolve(package); - if (m_pkProxy->packageID().isEmpty()) { - return false; - } - m_pkProxy->installPackage(m_pkProxy->packageID()); - if (m_pkProxy->error() != 0) { - return false; - } - return true; -} - -void InsiderWorker::switchInputMethod(bool isNew) -{ - if (isNew) { - QProcess process; - process.setProgram("im-config"); - process.setArguments({ "-n", "dim" }); - process.start(); - process.waitForFinished(); - } else { - if (imConfigIsDim()) { - QDir home = QDir::home(); - home.remove(".xinputrc"); - } - } -} } // namespace insider } // namespace dde diff --git a/dcc-insider/operation/insiderworker.h b/dcc-insider/operation/insiderworker.h index a3248b7..7cb8a10 100644 --- a/dcc-insider/operation/insiderworker.h +++ b/dcc-insider/operation/insiderworker.h @@ -18,32 +18,22 @@ class InsiderWorker : public QObject ~InsiderWorker() override; QString displayManager() const; - QString inputMethod() const; public Q_SLOTS: void setDisplayManager(const QString &id); - void setInputMethod(const QString &id); Q_SIGNALS: void displayManagerChanged(const QString &displayManager); - void inputMethodChanged(const QString &inputMethod); protected Q_SLOTS: void checkEnabledDisplayManager(); - void checkEnabledInputMethod(); void onDisplayManagerFinished(); - void onInputMethodFinished(); void switchDisplayManager(bool isNew); - void switchInputMethod(bool isNew); - void installDDEShell(); - bool installPackage(const QString &package); private: QString m_displayManager; - QString m_inputMethod; - PkPackagesProxy *m_pkProxy; }; } // namespace insider } // namespace dde diff --git a/dcc-insider/operation/pkpackagesproxy.cpp b/dcc-insider/operation/pkpackagesproxy.cpp deleted file mode 100644 index 8808054..0000000 --- a/dcc-insider/operation/pkpackagesproxy.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later -#include "pkpackagesproxy.h" - -#include -#include -#include -#include - -namespace dde { -namespace insider { -static QString PK_NAME = QStringLiteral("org.freedesktop.PackageKit"); -static QString PK_OFFLINE_INTERFACE = QStringLiteral("org.freedesktop.PackageKit.Offline"); -static QString PK_PATH = QStringLiteral("/org/freedesktop/PackageKit"); -static QString PK_TRANSACTION_INTERFACE = QStringLiteral("org.freedesktop.PackageKit.Transaction"); - -static QString DBUS_PROPERTIES = QStringLiteral("org.freedesktop.DBus.Properties"); - -PkPackagesProxy::PkPackagesProxy(QObject *parent) - : QObject(parent) - , m_error(0) -{ -} - -PkPackagesProxy::~PkPackagesProxy() { } - -uint PkPackagesProxy::error() const -{ - return m_error; -} - -QString PkPackagesProxy::packageID() const -{ - return m_packageID; -} - -void PkPackagesProxy::searchNames(const QString &search) -{ - init(); - QDBusMessage msg = QDBusMessage::createMethodCall(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, "SearchNames"); - msg << (quint64)2 << QStringList{ search }; - QDBusPendingReply reply = QDBusConnection::systemBus().call(msg); - waitForFinished(); -} - -void PkPackagesProxy::resolve(const QString &search) -{ - init(); - QDBusMessage msg = QDBusMessage::createMethodCall(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, "Resolve"); - msg << (quint64)2 << QStringList{ search }; - QDBusPendingReply reply = QDBusConnection::systemBus().call(msg); - qDebug() << "resolve Package:" << m_path << reply.error() << search; - waitForFinished(); -} - -void PkPackagesProxy::installPackage(const QString &packageId) -{ - init(); - QDBusMessage msg = QDBusMessage::createMethodCall(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, "InstallPackages"); - msg << (quint64)2 << QStringList{ packageId }; - QDBusPendingReply reply = QDBusConnection::systemBus().call(msg); - qDebug() << "install Package:" << m_path << reply.error() << packageId; - waitForFinished(); -} - -void PkPackagesProxy::init() -{ - m_error = 0; - m_packageID.clear(); - - QDBusMessage msg = QDBusMessage::createMethodCall(PK_NAME, PK_PATH, PK_NAME, "CreateTransaction"); - QDBusPendingReply reply = QDBusConnection::systemBus().call(msg); - if (reply.isError()) { } - m_path = reply.value().path(); - qDebug() << "Create Transaction:" << m_path; - QDBusConnection::systemBus().connect(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, QLatin1String("Destroy"), this, SLOT(onDestroy())); - QDBusConnection::systemBus().connect(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, QLatin1String("Package"), this, SLOT(Package(uint, QString, QString))); - QDBusConnection::systemBus().connect(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, QLatin1String("ErrorCode"), this, SLOT(ErrorCode(uint, QString))); - QDBusConnection::systemBus().connect(PK_NAME, m_path, PK_TRANSACTION_INTERFACE, QLatin1String("Finished"), this, SLOT(Finished(uint, uint))); -} - -void PkPackagesProxy::waitForFinished() -{ - QEventLoop loop; - connect(this, &PkPackagesProxy::dbusFinished, &loop, &QEventLoop::quit); - loop.exec(); -} - -void PkPackagesProxy::onDestroy() -{ - Q_EMIT dbusFinished(); - m_path.clear(); -} - -void PkPackagesProxy::Package(uint info, const QString &packageID, const QString &summary) -{ - qDebug() << "Package" << m_path << info << packageID << summary; - if (info == 1 || m_packageID.isEmpty()) { - m_packageID = packageID; - } -} - -void PkPackagesProxy::ErrorCode(uint error, const QString &details) -{ - qDebug() << "ErrorCode" << m_path << error << details; - m_error = error; -} - -void PkPackagesProxy::Finished(uint status, uint runtime) -{ - qDebug() << "Finished" << m_path << status << runtime; - Q_EMIT dbusFinished(); - m_path.clear(); -} -} // namespace insider -} // namespace dde diff --git a/dcc-insider/operation/pkpackagesproxy.h b/dcc-insider/operation/pkpackagesproxy.h deleted file mode 100644 index 78a5a0e..0000000 --- a/dcc-insider/operation/pkpackagesproxy.h +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later -#ifndef PKPACKAGESPROXY_H -#define PKPACKAGESPROXY_H - -#include - -namespace dde { -namespace insider { -class PkPackagesProxy : public QObject -{ - Q_OBJECT -public: - explicit PkPackagesProxy(QObject *parent = nullptr); - ~PkPackagesProxy() override; - - uint error() const; - QString packageID() const; - -public Q_SLOTS: - void searchNames(const QString &search); - void resolve(const QString &search); - void installPackage(const QString &packageId); - -protected Q_SLOTS: - void init(); - void waitForFinished(); - - void onDestroy(); - void Package(uint info, const QString &packageID, const QString &summary); - void ErrorCode(uint, const QString &); - void Finished(uint, uint); -Q_SIGNALS: - void dbusFinished(); - -protected: - QString m_path; - uint m_error; - QString m_packageID; -}; -} // namespace insider -} // namespace dde -#endif // PKPACKAGESPROXY_H diff --git a/dcc-insider/qml/main.qml b/dcc-insider/qml/main.qml index b445c8e..0f459d3 100644 --- a/dcc-insider/qml/main.qml +++ b/dcc-insider/qml/main.qml @@ -63,14 +63,14 @@ DccTitleObject { name: "imTitle" parentName: "insider" weight: 30 - visible: dccData.currentItems.includes("treeland") + visible: false displayName: qsTr("New Input Method") } DccObject { name: "selectInputMethod" parentName: "insider" weight: 40 - visible: dccData.currentItems.includes("treeland") + visible: false pageType: DccObject.Item page: DccGroupView {} DccObject { diff --git a/debian/changelog b/debian/changelog index b560226..2346bfc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dcc-insider-plugin (0.1.6) unstable; urgency=medium + + * release 0.1.6 + + -- Robertkill Thu, 28 Nov 2024 15:06:20 +0800 + dcc-insider-plugin (0.1.5) unstable; urgency=medium * release 0.1.5