fix(appmanager): 使用gio接口作为后备应用程序打开接口

This commit is contained in:
hewenfei 2023-09-11 10:48:21 +08:00 committed by He Sir
parent 0cc72ae13a
commit 7a9c3bf699
1 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@
*
*/
#include <gio/gio.h>
#include <gio-unix-2.0/gio/gdesktopappinfo.h>
#include "app-manager.h"
#include "app-data-manager.h"
@ -58,10 +59,17 @@ void AppManager::launchApp(const QString &desktopFilePath)
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [desktopFilePath] (QDBusPendingCallWatcher *self) {
QDBusPendingReply<bool> reply = *self;
if (!reply.isValid() || !reply.value()) {
QString cmd = parseDesktopFile(desktopFilePath);
if (!cmd.isEmpty()) {
QProcess::startDetached(cmd, QStringList());
// QString cmd = parseDesktopFile(desktopFilePath);
// if (!cmd.isEmpty()) {
// QProcess::startDetached(cmd, QStringList());
// }
GDesktopAppInfo *desktopAppInfo = g_desktop_app_info_new_from_filename(desktopFilePath.toLocal8Bit().data());
if (desktopAppInfo == nullptr) {
return;
}
bool launched = g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr);
g_object_unref(desktopAppInfo);
qDebug() << "launch with GDesktopAppInfo:" << launched;
}
self->deleteLater();
});