fix: 适配新的appmanager接口
This commit is contained in:
parent
e4fb123f61
commit
7d4779be04
|
@ -27,9 +27,9 @@
|
|||
#include <QDBusMessage>
|
||||
#include <QProcess>
|
||||
|
||||
#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<bool> 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<bool> 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<bool> status(QDBusConnection::sessionBus().call(message));
|
||||
return status.value();
|
||||
}
|
||||
|
||||
QString AppManager::parseDesktopFile(const QString &desktopFilePath)
|
||||
{
|
||||
// TODO: try QSettings?
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
|
||||
private:
|
||||
explicit AppManager(QObject *parent = nullptr);
|
||||
bool launchAppWithDBus(const QString &app);
|
||||
static QString parseDesktopFile(const QString &desktopFilePath);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
Loading…
Reference in New Issue