From 7d4779be042d9b07545b2d47f42062ec93930a59 Mon Sep 17 00:00:00 2001 From: hewenfei Date: Wed, 8 Nov 2023 15:03:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8D=E6=96=B0=E7=9A=84appm?= =?UTF-8?q?anager=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/app-manager.cpp | 23 ++++++----------------- src/utils/app-manager.h | 1 - 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/utils/app-manager.cpp b/src/utils/app-manager.cpp index bed1b35..915838a 100644 --- a/src/utils/app-manager.cpp +++ b/src/utils/app-manager.cpp @@ -27,9 +27,9 @@ #include #include -#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" -#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" -#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" +#define KYLIN_APP_MANAGER_NAME "com.kylin.ProcessManager" +#define KYLIN_APP_MANAGER_PATH "/com/kylin/ProcessManager/AppLauncher" +#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.ProcessManager.AppLauncher" namespace UkuiMenu { AppManager *AppManager::instance() @@ -57,8 +57,7 @@ void AppManager::launchApp(const QString &desktopFilePath) auto watcher = new QDBusPendingCallWatcher(QDBusPendingCall(QDBusConnection::sessionBus().asyncCall(message)), this); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [desktopFilePath] (QDBusPendingCallWatcher *self) { - QDBusPendingReply reply = *self; - if (!reply.isValid() || !reply.value()) { + if (self->isError()) { // QString cmd = parseDesktopFile(desktopFilePath); // if (!cmd.isEmpty()) { // QProcess::startDetached(cmd, QStringList()); @@ -86,23 +85,13 @@ void AppManager::launchBinaryApp(const QString &app, const QString &args) auto watcher = new QDBusPendingCallWatcher(QDBusPendingCall(QDBusConnection::sessionBus().asyncCall(message)), this); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [app, args] (QDBusPendingCallWatcher *self) { - QDBusPendingReply reply = *self; - if (!reply.isValid() || !reply.value()) { - QProcess::startDetached(app, {args}); + if (self->isError()) { + QProcess::startDetached(app, {args}, ""); } self->deleteLater(); }); } -bool AppManager::launchAppWithDBus(const QString &app) -{ - QDBusMessage message = QDBusMessage::createMethodCall(KYLIN_APP_MANAGER_NAME, KYLIN_APP_MANAGER_PATH, KYLIN_APP_MANAGER_INTERFACE, "LaunchApp"); - message << app; - - QDBusReply status(QDBusConnection::sessionBus().call(message)); - return status.value(); -} - QString AppManager::parseDesktopFile(const QString &desktopFilePath) { // TODO: try QSettings? diff --git a/src/utils/app-manager.h b/src/utils/app-manager.h index c6b93ad..b8b0778 100644 --- a/src/utils/app-manager.h +++ b/src/utils/app-manager.h @@ -38,7 +38,6 @@ public: private: explicit AppManager(QObject *parent = nullptr); - bool launchAppWithDBus(const QString &app); static QString parseDesktopFile(const QString &desktopFilePath); Q_SIGNALS: