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); diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index acaf8ee3..193d3da7 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -33,6 +33,8 @@ #define SCROAREA_WIDTH 480 #define MEDIUM_WEIGHT_VALUE 57 +bool LaunchApp(QString desktopFile); + JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent) :m_devName(devName), KDialog(parent) @@ -52,9 +54,19 @@ JoinHiddenWiFiPage::~JoinHiddenWiFiPage() } +void JoinHiddenWiFiPage::setJoinHiddenWiFiShowed(bool state) +{ + m_joinHiddenWiFiShowed = state; +} + void JoinHiddenWiFiPage::closeEvent(QCloseEvent *event) { Q_EMIT this->hiddenWiFiPageClose(m_devName); + + if (m_joinHiddenWiFiShowed) { + LaunchApp("ukui-control-center.desktop"); + m_joinHiddenWiFiShowed = false; + } return QWidget::closeEvent(event); } diff --git a/src/frontend/netdetails/joinhiddenwifipage.h b/src/frontend/netdetails/joinhiddenwifipage.h index f3aa0edb..23d14328 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.h +++ b/src/frontend/netdetails/joinhiddenwifipage.h @@ -43,6 +43,8 @@ public: JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr); ~JoinHiddenWiFiPage(); + void setJoinHiddenWiFiShowed(bool state); + protected: void closeEvent(QCloseEvent *event); @@ -78,6 +80,7 @@ private: bool m_isJoinBtnEnable = false; bool m_isSecuOk = false; + bool m_joinHiddenWiFiShowed = false; ConInfo m_info; private Q_SLOTS: diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index a1ecb4ad..59562f5a 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -56,9 +56,28 @@ #define PEAP_SCRO_HEIGHT 300 #define TLS_SCRO_HEIGHT 480 #define MAX_TAB_TEXT_LENGTH 44 +#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" +#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" +#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" //extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); +bool 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 NetDetail::showDesktopNotify(const QString &message, QString soundName) { QDBusInterface iface("org.freedesktop.Notifications", @@ -265,6 +284,11 @@ void NetDetail::closeEvent(QCloseEvent *event) { Q_EMIT this->detailPageClose(false); Q_EMIT this->createPageClose(m_deviceName); + + if (m_hasDetailPageShowed) { + LaunchApp("ukui-control-center.desktop"); + m_hasDetailPageShowed = false; + } return QWidget::closeEvent(event); } @@ -411,6 +435,7 @@ void NetDetail::loadPage() pageFrame->hide(); stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM); this->setWindowTitle(tr("Add Lan Connect")); + setDetailPageShowed(true); } else { stackWidget->setCurrentIndex(DETAIL_PAGE_NUM); this->setWindowTitle(m_name); @@ -1120,6 +1145,11 @@ bool NetDetail::eventFilter(QObject *w, QEvent *event) return QWidget::eventFilter(w, event); } +void NetDetail::setDetailPageShowed(bool state) +{ + m_hasDetailPageShowed = state; +} + void NetDetail::setNetTabToolTip() { int tabCount = m_netTabBar->count(); diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 13ca9122..cc25c554 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -100,6 +100,8 @@ public: void closeEvent(QCloseEvent *event); bool eventFilter(QObject *w, QEvent *event); + void setDetailPageShowed(bool state); + private: void initUI(); void centerToScreen(); @@ -184,7 +186,7 @@ private: bool isIpv6Ok; bool isSecuOk; bool isConfirmBtnEnable; - + bool m_hasDetailPageShowed = false; ConInfo m_info; ThreadObject *m_object; diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 0a596c02..19b0845c 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -1265,6 +1265,7 @@ void LanPage::showDetailPage(QString devName, QString uuid) NetDetail *netDetail = new NetDetail(devName, p_item->m_connectName, uuid, isActive, false, false); netDetail->show(); + netDetail->setDetailPageShowed(true); delete p_item; p_item = nullptr; diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index efe6ea31..fb1245a0 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -1099,7 +1099,7 @@ void WlanPage::requestScan() void WlanPage::onHiddenWlanClicked() { -// qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ; + qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ; // NetDetail *netDetail = new NetDetail(m_currentDevice, "", "", false, true, true); // netDetail->show(); if(m_hiddenWiFi != nullptr){ @@ -1486,7 +1486,7 @@ void WlanPage::showDetailPage(QString devName, QString ssid) NetDetail *netDetail = new NetDetail(devName, ssid, wirelessNetItem.m_connectUuid, isActive, true, !wirelessNetItem.m_isConfigured); netDetail->show(); - + netDetail->setDetailPageShowed(true); return; }