From 9dfa1a24d171e5b11af5db3f5dd071e3bfbc3789 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Fri, 13 May 2022 10:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A3=B0=E9=9F=B3=E6=95=88=E6=9E=9C=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/list-items/lanlistitem.cpp | 2 +- src/frontend/list-items/listitem.cpp | 13 ++++++--- src/frontend/list-items/listitem.h | 2 +- src/frontend/netdetails/netdetail.cpp | 35 +++++++++++++++---------- src/frontend/netdetails/netdetail.h | 2 +- src/frontend/tab-pages/lanpage.cpp | 8 +++--- src/frontend/tab-pages/tabpage.cpp | 9 ++++++- src/frontend/tab-pages/tabpage.h | 2 +- src/frontend/tab-pages/wlanpage.cpp | 8 +++--- 9 files changed, 51 insertions(+), 30 deletions(-) diff --git a/src/frontend/list-items/lanlistitem.cpp b/src/frontend/list-items/lanlistitem.cpp index 18e8e4e1..5b7c7b9f 100644 --- a/src/frontend/list-items/lanlistitem.cpp +++ b/src/frontend/list-items/lanlistitem.cpp @@ -98,7 +98,7 @@ void LanListItem::onNetButtonClicked() m_netButton->startLoading(); } else { qDebug() << LOG_FLAG << m_deviceName << "is not carried, so can not activate connection"; - this->showDesktopNotify(tr("Wired Device not carried")); + this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong"); } } else { qDebug() << LOG_FLAG <<"the connection" << m_lanConnectItem.m_connectName diff --git a/src/frontend/list-items/listitem.cpp b/src/frontend/list-items/listitem.cpp index 1c459ce7..88c8d72a 100644 --- a/src/frontend/list-items/listitem.cpp +++ b/src/frontend/list-items/listitem.cpp @@ -52,20 +52,27 @@ void ListItem::setConnectState(ConnectState state) m_connectState = state; } -void ListItem::showDesktopNotify(const QString &message) +void ListItem::showDesktopNotify(const QString &message, QString soundName) { QDBusInterface iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); + QStringList actions; //跳转动作 + actions.append("kylin-nm"); + actions.append("default"); //默认动作:点击消息体时打开麒麟录音 + QMap hints; + if (!soundName.isEmpty()) { + hints.insert("sound-name",soundName); //添加声音 + } QList args; args<<(tr("Kylin NM")) <<((unsigned int) 0) < hints; + if (!soundName.isEmpty()) { + hints.insert("sound-name", soundName); //添加声音 + } QList args; args<<(tr("Kylin NM")) <<((unsigned int) 0) <showDesktopNotify(tr("No ethernet device avaliable")); + this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong"); } else { if (m_netSwitch->getSwitchStatus()) { //qDebug() << "[wiredSwitch]set true after clicked"; @@ -842,7 +842,7 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem) deleteConnectionMapItem(m_activeConnectionMap, m_activatedLanListWidget, EMPTY_CONNECT_UUID); QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_activatedLanListWidget); m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); - this->showDesktopNotify(tr("LAN Connected Successfully")); + this->showDesktopNotify(tr("LAN Connected Successfully"), "networkconnected"); } if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); @@ -866,7 +866,7 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem) qDebug()<<"[LanPage] update connection item"<m_connectName; QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_inactivatedLanListWidget); m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); - this->showDesktopNotify(tr("LAN Disconnected Successfully")); + this->showDesktopNotify(tr("LAN Disconnected Successfully"), "networkdisconnected"); } if (m_inactivatedLanListWidget->count() < MAX_ITEMS) { m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); @@ -1206,7 +1206,7 @@ void LanPage::activateWired(const QString& devName, const QString& connUuid) qDebug() << "[LanPage] activateWired" << devName << connUuid; if (!m_deviceResource->wiredDeviceIsCarriered(devName)) { qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection"; - this->showDesktopNotify(tr("Wired Device not carried")); + this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong"); } else { m_wiredConnectOperation->activateConnection(connUuid, devName); } diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index b1d73308..87a757d3 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -138,12 +138,19 @@ void TabPage::onPaletteChanged() } } -void TabPage::showDesktopNotify(const QString &message) +void TabPage::showDesktopNotify(const QString &message, QString soundName) { QDBusInterface iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); + QStringList actions; //跳转动作 + actions.append("kylin-nm"); + actions.append("default"); //默认动作:点击消息体时打开麒麟录音 + QMap hints; + if (!soundName.isEmpty()) { + hints.insert("sound-name",soundName); //添加声音 + } QList args; args<<(tr("Kylin NM")) <<((unsigned int) 0) diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index d8bd8712..599bfeb3 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -62,7 +62,7 @@ public: // void updateDefaultDevice(QString &deviceName); // QString getDefaultDevice(); - static void showDesktopNotify(const QString &message); + static void showDesktopNotify(const QString &message, QString soundName); void hideSetting() { if (nullptr != m_settingsFrame) { diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 935c78fb..7b03dcaa 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -124,7 +124,7 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key) void WlanPage::onWlanSwitchClicked() { if (m_devList.isEmpty()) { - showDesktopNotify(tr("No wireless network card detected")); + showDesktopNotify(tr("No wireless network card detected"), "networkwrong"); //检测不到无线网卡不再触发click信号 m_netSwitch->setSwitchStatus(false); m_netSwitch->setEnabled(false); @@ -551,7 +551,7 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid) } else { deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, ssid); - showDesktopNotify(tr("WLAN Disconnected Successfully")); + showDesktopNotify(tr("WLAN Disconnected Successfully"), "networkdisconnected"); QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget); m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem); @@ -803,11 +803,11 @@ void WlanPage::wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::St NetworkManager::ActiveConnection::Reason reason) { if (state == NetworkManager::ActiveConnection::State::Deactivated) { - showDesktopNotify(tr("WLAN Disconnected Successfully")); + showDesktopNotify(tr("WLAN Disconnected Successfully"), "networkdisconnected"); qDebug() << "[WlanPage] wlan disconnected successfully" << Q_FUNC_INFO <<__LINE__; } else if (state == NetworkManager::ActiveConnection::State::Activated) { qDebug() << "[WlanPage] wlan connected successfully" << Q_FUNC_INFO <<__LINE__; - this->showDesktopNotify(tr("WLAN Connected Successfully")); + this->showDesktopNotify(tr("WLAN Connected Successfully"), "networkconnected"); } return;