From f6ee9aad87b6f14570200819ec183f166df0b187 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Tue, 1 Nov 2022 17:29:21 +0800 Subject: [PATCH] fix bug 145707 --- plugins/netconnect/netconnect.cpp | 26 +++++++++++++++++++++++--- plugins/netconnect/netconnect.h | 1 + plugins/wlanconnect/wlanconnect.cpp | 26 +++++++++++++++++++++++--- plugins/wlanconnect/wlanconnect.h | 1 + 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 6df6b99c..21fbe697 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -32,6 +32,9 @@ #define ITEMHEIGH 50 #define LAN_TYPE 0 #define CONTROL_CENTER_WIFI "org.ukui.control-center.wifi.switch" +#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" +#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" +#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" const QString KLanSymbolic = "network-wired-connected-symbolic"; const QString NoNetSymbolic = "network-wired-disconnected-symbolic"; @@ -350,9 +353,10 @@ void NetConnect::initNet() } void NetConnect::runExternalApp() { - QString cmd = "nm-connection-editor"; - QProcess process(this); - process.startDetached(cmd); +// QString cmd = "nm-connection-editor"; +// QProcess process(this); +// process.startDetached(cmd); + LaunchApp("nm-connection-editor.desktop"); } //刪除 @@ -928,3 +932,19 @@ int NetConnect::getInsertPos(QString connName, QString deviceName) } return index; } + +bool NetConnect::LaunchApp(QString desktopFile) +{ + QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME, + KYLIN_APP_MANAGER_PATH, + KYLIN_APP_MANAGER_INTERFACE, + QDBusConnection::sessionBus());//局部变量 + + if (!m_appManagerDbusInterface.isValid()) { + qWarning()<<"m_appManagerDbusInterface init error"; + return false; + } else { + QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile); + return reply; + } +} diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h index 644f39f3..99ce6855 100644 --- a/plugins/netconnect/netconnect.h +++ b/plugins/netconnect/netconnect.h @@ -123,6 +123,7 @@ private: //单个lan连接状态变化 void itemActiveConnectionStatusChanged(LanItem *item, int status); + bool LaunchApp(QString desktopFile); protected: bool eventFilter(QObject *w,QEvent *e); diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 24004b1f..bfbc6dd0 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -99,6 +99,9 @@ const QString KApSymbolic = "network-wireless-hotspot-symbolic"; const QString IsApConnection = "1"; +#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 ACTIVATING 1 #define ACTIVATED 2 @@ -713,6 +716,22 @@ void WlanConnect::initSwtichState() setSwitchBtnState(state); } +bool WlanConnect::LaunchApp(QString desktopFile) +{ + QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME, + KYLIN_APP_MANAGER_PATH, + KYLIN_APP_MANAGER_INTERFACE, + QDBusConnection::sessionBus());//局部变量 + + if (!m_appManagerDbusInterface.isValid()) { + qWarning()<<"m_appManagerDbusInterface init error"; + return false; + } else { + QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile); + return reply; + } +} + //初始化整体列表和单设备列表 void WlanConnect::initNet() { // int count = 1; @@ -776,9 +795,10 @@ void WlanConnect::initNetListFromDevice(QString deviceName) //高级设置 void WlanConnect::runExternalApp() { - QString cmd = "nm-connection-editor"; - QProcess process(this); - process.startDetached(cmd); +// QString cmd = "nm-connection-editor"; +// QProcess process(this); +// process.startDetached(cmd); + LaunchApp("nm-connection-editor.desktop"); } //根据信号强度分级+安全性分图标 diff --git a/plugins/wlanconnect/wlanconnect.h b/plugins/wlanconnect/wlanconnect.h index 8754219f..45983aeb 100644 --- a/plugins/wlanconnect/wlanconnect.h +++ b/plugins/wlanconnect/wlanconnect.h @@ -149,6 +149,7 @@ private: } } + bool LaunchApp(QString desktopFile); protected: bool eventFilter(QObject *w,QEvent *e);