fix: 适配新的appmanager接口
This commit is contained in:
parent
e4fb123f61
commit
7d4779be04
|
@ -27,9 +27,9 @@
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
|
#define KYLIN_APP_MANAGER_NAME "com.kylin.ProcessManager"
|
||||||
#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
|
#define KYLIN_APP_MANAGER_PATH "/com/kylin/ProcessManager/AppLauncher"
|
||||||
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
|
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.ProcessManager.AppLauncher"
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
AppManager *AppManager::instance()
|
AppManager *AppManager::instance()
|
||||||
|
@ -57,8 +57,7 @@ void AppManager::launchApp(const QString &desktopFilePath)
|
||||||
|
|
||||||
auto watcher = new QDBusPendingCallWatcher(QDBusPendingCall(QDBusConnection::sessionBus().asyncCall(message)), this);
|
auto watcher = new QDBusPendingCallWatcher(QDBusPendingCall(QDBusConnection::sessionBus().asyncCall(message)), this);
|
||||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [desktopFilePath] (QDBusPendingCallWatcher *self) {
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [desktopFilePath] (QDBusPendingCallWatcher *self) {
|
||||||
QDBusPendingReply<bool> reply = *self;
|
if (self->isError()) {
|
||||||
if (!reply.isValid() || !reply.value()) {
|
|
||||||
// QString cmd = parseDesktopFile(desktopFilePath);
|
// QString cmd = parseDesktopFile(desktopFilePath);
|
||||||
// if (!cmd.isEmpty()) {
|
// if (!cmd.isEmpty()) {
|
||||||
// QProcess::startDetached(cmd, QStringList());
|
// 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);
|
auto watcher = new QDBusPendingCallWatcher(QDBusPendingCall(QDBusConnection::sessionBus().asyncCall(message)), this);
|
||||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [app, args] (QDBusPendingCallWatcher *self) {
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [app, args] (QDBusPendingCallWatcher *self) {
|
||||||
QDBusPendingReply<bool> reply = *self;
|
if (self->isError()) {
|
||||||
if (!reply.isValid() || !reply.value()) {
|
QProcess::startDetached(app, {args}, "");
|
||||||
QProcess::startDetached(app, {args});
|
|
||||||
}
|
}
|
||||||
self->deleteLater();
|
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)
|
QString AppManager::parseDesktopFile(const QString &desktopFilePath)
|
||||||
{
|
{
|
||||||
// TODO: try QSettings?
|
// TODO: try QSettings?
|
||||||
|
|
|
@ -38,7 +38,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AppManager(QObject *parent = nullptr);
|
explicit AppManager(QObject *parent = nullptr);
|
||||||
bool launchAppWithDBus(const QString &app);
|
|
||||||
static QString parseDesktopFile(const QString &desktopFilePath);
|
static QString parseDesktopFile(const QString &desktopFilePath);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
Loading…
Reference in New Issue