fix(appmanager): 使用gio接口作为后备应用程序打开接口
This commit is contained in:
parent
0cc72ae13a
commit
7a9c3bf699
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue