From eb7712190d00a376a2729da73a82a44ab5efde54 Mon Sep 17 00:00:00 2001 From: yangjianhao Date: Fri, 12 Jan 2024 11:49:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:#I8EQUH=E3=80=90=E7=BB=88=E7=AB=AF=E3=80=91?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=B8=B8=E8=BF=90=E8=A1=8C=E4=B8=80?= =?UTF-8?q?=E6=AE=B5=E6=97=B6=E9=97=B4=E5=90=8E=EF=BC=8C=E5=9C=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=AE=A1=E7=90=86=E5=99=A8=E5=8F=B3=E9=94=AE=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=9A=84=E7=BB=88=E7=AB=AF=E7=AA=97=E5=8F=A3=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=BD=AE=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mate-terminal-menu-plugin.cpp | 41 ++++++++----------- .../peony-menu-plugin-mate-terminal.pro | 2 +- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/peony-menu-plugin-mate-terminal/mate-terminal-menu-plugin.cpp b/peony-menu-plugin-mate-terminal/mate-terminal-menu-plugin.cpp index 75f4264..6437f58 100644 --- a/peony-menu-plugin-mate-terminal/mate-terminal-menu-plugin.cpp +++ b/peony-menu-plugin-mate-terminal/mate-terminal-menu-plugin.cpp @@ -34,7 +34,9 @@ #include #include #include - +#include +#include +#include #include #ifdef KYLIN_COMMON @@ -82,30 +84,23 @@ MateTerminalMenuPlugin::MateTerminalMenuPlugin(QObject *parent) : QObject (paren } void MateTerminalMenuPlugin::openTerminal(){ - - //qDebug()<<"triggered"<message; - g_error_free(err); - err = nullptr; - //try again to open terminal - //maybe this method is better,but still need more test to confirm - tryOpenAgain(); + auto dir = url.path(); + + QStringList args; + args << "--working-directory" << dir; + QString terminal_path = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "mate-terminal.desktop"); + if (terminal_path.isEmpty()) { + terminal_path = QFile(terminal_cmd).fileName() + ".desktop"; + terminal_path = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, terminal_path); + if (!QFile(terminal_path).exists()) { + return; + } } - g_strfreev (argv); + + QDBusMessage msg = QDBusMessage::createMethodCall("com.kylin.AppManager", "/com/kylin/AppManager", "com.kylin.AppManager", "LaunchAppWithArguments"); + msg << terminal_path << args; + QDBusConnection::sessionBus().asyncCall(msg); } void MateTerminalMenuPlugin::tryOpenAgain() diff --git a/peony-menu-plugin-mate-terminal/peony-menu-plugin-mate-terminal.pro b/peony-menu-plugin-mate-terminal/peony-menu-plugin-mate-terminal.pro index 953246b..b36f6c2 100644 --- a/peony-menu-plugin-mate-terminal/peony-menu-plugin-mate-terminal.pro +++ b/peony-menu-plugin-mate-terminal/peony-menu-plugin-mate-terminal.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += widgets concurrent +QT += widgets concurrent dbus TARGET = peony-menu-plugin-mate-terminal TEMPLATE = lib