Merge branch 'sound' into 'dbus-interface'

Sound

See merge request kylin-desktop/kylin-nm!584
This commit is contained in:
赵世旭 2022-05-16 01:44:26 +00:00
commit dd047d81bf
9 changed files with 53 additions and 32 deletions

View File

@ -98,7 +98,7 @@ void LanListItem::onNetButtonClicked()
m_netButton->startLoading(); m_netButton->startLoading();
} else { } else {
qDebug() << LOG_FLAG << m_deviceName << "is not carried, so can not activate connection"; 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 { } else {
qDebug() << LOG_FLAG <<"the connection" << m_lanConnectItem.m_connectName qDebug() << LOG_FLAG <<"the connection" << m_lanConnectItem.m_connectName

View File

@ -52,20 +52,27 @@ void ListItem::setConnectState(ConnectState state)
m_connectState = state; m_connectState = state;
} }
void ListItem::showDesktopNotify(const QString &message) void ListItem::showDesktopNotify(const QString &message, QString soundName)
{ {
QDBusInterface iface("org.freedesktop.Notifications", QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
"org.freedesktop.Notifications", "org.freedesktop.Notifications",
QDBusConnection::sessionBus()); QDBusConnection::sessionBus());
QStringList actions; //跳转动作
actions.append("kylin-nm");
actions.append("default"); //默认动作:点击消息体时打开麒麟录音
QMap<QString, QVariant> hints;
if (!soundName.isEmpty()) {
hints.insert("sound-name",soundName); //添加声音
}
QList<QVariant> args; QList<QVariant> args;
args<<(tr("Kylin NM")) args<<(tr("Kylin NM"))
<<((unsigned int) 0) <<((unsigned int) 0)
<<QString("gnome-dev-ethernet") <<QString("gnome-dev-ethernet")
<<tr("kylin network applet desktop message") //显示的是什么类型的信息 <<tr("kylin network applet desktop message") //显示的是什么类型的信息
<<message //显示的具体信息 <<message //显示的具体信息
<<QStringList() <<actions
<<QVariantMap() <<hints
<<(int)-1; <<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
} }

View File

@ -27,7 +27,7 @@ public:
void setName(const QString &name); void setName(const QString &name);
void setActive(const bool &isActive); void setActive(const bool &isActive);
void setConnectState(ConnectState state); void setConnectState(ConnectState state);
static void showDesktopNotify(const QString &message); static void showDesktopNotify(const QString &message, QString soundName);
protected: protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);

View File

@ -28,20 +28,27 @@
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); //extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
void NetDetail::showDesktopNotify(const QString &message) void NetDetail::showDesktopNotify(const QString &message, QString soundName)
{ {
QDBusInterface iface("org.freedesktop.Notifications", QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
"org.freedesktop.Notifications", "org.freedesktop.Notifications",
QDBusConnection::sessionBus()); QDBusConnection::sessionBus());
QStringList actions; //跳转动作
actions.append("kylin-nm");
actions.append("default"); //默认动作:点击消息体时打开麒麟录音
QMap<QString, QVariant> hints;
if (!soundName.isEmpty()) {
hints.insert("sound-name", soundName); //添加声音
}
QList<QVariant> args; QList<QVariant> args;
args<<(tr("Kylin NM")) args<<(tr("Kylin NM"))
<<((unsigned int) 0) <<((unsigned int) 0)
<<QString("gnome-dev-ethernet") <<QString("gnome-dev-ethernet")
<<tr("kylin network desktop message") //显示的是什么类型的信息 <<tr("kylin network desktop message") //显示的是什么类型的信息
<<message //显示的具体信息 <<message //显示的具体信息
<<QStringList() <<actions
<<QVariantMap() <<hints
<<(int)-1; <<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
} }
@ -679,7 +686,7 @@ void NetDetail::setConfirmEnable()
bool NetDetail::checkIpv4Conflict(QString ipv4Address) bool NetDetail::checkIpv4Conflict(QString ipv4Address)
{ {
showDesktopNotify(tr("start check ipv4 address conflict")); showDesktopNotify(tr("start check ipv4 address conflict"), "networkwrong");
bool isConflict = false; bool isConflict = false;
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address); KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address);
@ -696,7 +703,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address)
bool NetDetail::checkIpv6Conflict(QString ipv6address) bool NetDetail::checkIpv6Conflict(QString ipv6address)
{ {
showDesktopNotify(tr("start check ipv6 address conflict")); showDesktopNotify(tr("start check ipv6 address conflict"), "networkwrong");
bool isConflict = false; bool isConflict = false;
KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address); KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address);
@ -742,7 +749,7 @@ bool NetDetail::createWiredConnect()
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) { if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) { if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict"; qDebug() << "ipv4 conflict";
showDesktopNotify(tr("ipv4 address conflict!")); showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
return false; return false;
} }
} }
@ -793,7 +800,7 @@ bool NetDetail::createWirelessConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) { if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict"; qDebug() << "ipv4 conflict";
showDesktopNotify(tr("ipv4 address conflict!")); showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
return false; return false;
} }
} }
@ -801,7 +808,7 @@ bool NetDetail::createWirelessConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) { if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) { if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict"; qDebug() << "ipv6 conflict";
showDesktopNotify(tr("ipv6 address conflict!")); showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
return false; return false;
} }
} }
@ -881,7 +888,7 @@ bool NetDetail::updateConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) { if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict"; qDebug() << "ipv4 conflict";
showDesktopNotify(tr("ipv4 address conflict!")); showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
return false; return false;
} }
} }
@ -889,7 +896,7 @@ bool NetDetail::updateConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) { if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) { if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict"; qDebug() << "ipv6 conflict";
showDesktopNotify(tr("ipv6 address conflict!")); showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
return false; return false;
} }
} }
@ -925,20 +932,20 @@ bool NetDetail::checkWirelessSecurity(KySecuType secuType)
{ {
if (secuType == WPA_AND_WPA2_ENTERPRISE) { if (secuType == WPA_AND_WPA2_ENTERPRISE) {
if(m_info.strSecType.indexOf("802.1X") < 0) { if(m_info.strSecType.indexOf("802.1X") < 0) {
showDesktopNotify(tr("this wifi no support enterprise type")); showDesktopNotify(tr("this wifi no support enterprise type"), "networkwrong");
return false; return false;
} }
} else { } else {
if (secuType == NONE && m_info.strSecType != tr("None")) { if (secuType == NONE && m_info.strSecType != tr("None")) {
showDesktopNotify(tr("this wifi no support None type")); showDesktopNotify(tr("this wifi no support None type"), "networkwrong");
return false; return false;
} else if (secuType == WPA_AND_WPA2_PERSONAL } else if (secuType == WPA_AND_WPA2_PERSONAL
&& (m_info.strSecType.indexOf("WPA1") < 0 && && (m_info.strSecType.indexOf("WPA1") < 0 &&
m_info.strSecType.indexOf("WPA2") < 0)) { m_info.strSecType.indexOf("WPA2") < 0)) {
showDesktopNotify(tr("this wifi no support WPA2 type")); showDesktopNotify(tr("this wifi no support WPA2 type"), "networkwrong");
return false; return false;
} else if (secuType == WPA3_PERSONAL && m_info.strSecType.indexOf("WPA3") < 0) { } else if (secuType == WPA3_PERSONAL && m_info.strSecType.indexOf("WPA3") < 0) {
showDesktopNotify(tr("this wifi no support WPA3 type")); showDesktopNotify(tr("this wifi no support WPA3 type"), "networkwrong");
return false; return false;
} }
} }

View File

@ -75,7 +75,7 @@ private:
bool checkWirelessSecurity(KySecuType secuType); bool checkWirelessSecurity(KySecuType secuType);
void showDesktopNotify(const QString &message); void showDesktopNotify(const QString &message, QString soundName);
void setNetdetailSomeEnable(bool on); void setNetdetailSomeEnable(bool on);
private: private:

View File

@ -199,7 +199,7 @@ void LanPage::onLanSwitchClicked()
<<"devices count:"<<m_devList.count(); <<"devices count:"<<m_devList.count();
if (m_devList.count() == 0) { if (m_devList.count() == 0) {
this->showDesktopNotify(tr("No ethernet device avaliable")); this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong");
} else { } else {
if (m_netSwitch->getSwitchStatus()) { if (m_netSwitch->getSwitchStatus()) {
//qDebug() << "[wiredSwitch]set true after clicked"; //qDebug() << "[wiredSwitch]set true after clicked";
@ -842,7 +842,7 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem)
deleteConnectionMapItem(m_activeConnectionMap, m_activatedLanListWidget, EMPTY_CONNECT_UUID); deleteConnectionMapItem(m_activeConnectionMap, m_activatedLanListWidget, EMPTY_CONNECT_UUID);
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_activatedLanListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_activatedLanListWidget);
m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); 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) { if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
@ -866,7 +866,7 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem)
qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName; qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName;
QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_inactivatedLanListWidget); QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_inactivatedLanListWidget);
m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); 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) { if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH); m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
@ -1206,7 +1206,7 @@ void LanPage::activateWired(const QString& devName, const QString& connUuid)
qDebug() << "[LanPage] activateWired" << devName << connUuid; qDebug() << "[LanPage] activateWired" << devName << connUuid;
if (!m_deviceResource->wiredDeviceIsCarriered(devName)) { if (!m_deviceResource->wiredDeviceIsCarriered(devName)) {
qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection"; 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 { } else {
m_wiredConnectOperation->activateConnection(connUuid, devName); m_wiredConnectOperation->activateConnection(connUuid, devName);
} }

View File

@ -138,20 +138,27 @@ void TabPage::onPaletteChanged()
} }
} }
void TabPage::showDesktopNotify(const QString &message) void TabPage::showDesktopNotify(const QString &message, QString soundName)
{ {
QDBusInterface iface("org.freedesktop.Notifications", QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
"org.freedesktop.Notifications", "org.freedesktop.Notifications",
QDBusConnection::sessionBus()); QDBusConnection::sessionBus());
QStringList actions; //跳转动作
actions.append("kylin-nm");
actions.append("default"); //默认动作:点击消息体时打开麒麟录音
QMap<QString, QVariant> hints;
if (!soundName.isEmpty()) {
hints.insert("sound-name",soundName); //添加声音
}
QList<QVariant> args; QList<QVariant> args;
args<<(tr("Kylin NM")) args<<(tr("Kylin NM"))
<<((unsigned int) 0) <<((unsigned int) 0)
<<QString("gnome-dev-ethernet") <<QString("gnome-dev-ethernet")
<<tr("kylin network applet desktop message") //显示的是什么类型的信息 <<tr("kylin network applet desktop message") //显示的是什么类型的信息
<<message //显示的具体信息 <<message //显示的具体信息
<<QStringList() <<actions
<<QVariantMap() <<hints
<<(int)-1; <<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
} }

View File

@ -62,7 +62,7 @@ public:
// void updateDefaultDevice(QString &deviceName); // void updateDefaultDevice(QString &deviceName);
// QString getDefaultDevice(); // QString getDefaultDevice();
static void showDesktopNotify(const QString &message); static void showDesktopNotify(const QString &message, QString soundName);
void hideSetting() { void hideSetting() {
if (nullptr != m_settingsFrame) { if (nullptr != m_settingsFrame) {

View File

@ -124,7 +124,7 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key)
void WlanPage::onWlanSwitchClicked() void WlanPage::onWlanSwitchClicked()
{ {
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
showDesktopNotify(tr("No wireless network card detected")); showDesktopNotify(tr("No wireless network card detected"), "networkwrong");
//检测不到无线网卡不再触发click信号 //检测不到无线网卡不再触发click信号
m_netSwitch->setSwitchStatus(false); m_netSwitch->setSwitchStatus(false);
m_netSwitch->setEnabled(false); m_netSwitch->setEnabled(false);
@ -551,7 +551,7 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid)
} else { } else {
deleteWirelessItemFormMap(m_activateConnectionItemMap, deleteWirelessItemFormMap(m_activateConnectionItemMap,
m_activatedNetListWidget, ssid); m_activatedNetListWidget, ssid);
showDesktopNotify(tr("WLAN Disconnected Successfully")); showDesktopNotify(tr("WLAN Disconnected Successfully"), "networkdisconnected");
QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget); QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget);
m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem); m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem);
@ -803,11 +803,11 @@ void WlanPage::wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::St
NetworkManager::ActiveConnection::Reason reason) NetworkManager::ActiveConnection::Reason reason)
{ {
if (state == NetworkManager::ActiveConnection::State::Deactivated) { 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__; qDebug() << "[WlanPage] wlan disconnected successfully" << Q_FUNC_INFO <<__LINE__;
} else if (state == NetworkManager::ActiveConnection::State::Activated) { } else if (state == NetworkManager::ActiveConnection::State::Activated) {
qDebug() << "[WlanPage] wlan connected successfully" << Q_FUNC_INFO <<__LINE__; qDebug() << "[WlanPage] wlan connected successfully" << Q_FUNC_INFO <<__LINE__;
this->showDesktopNotify(tr("WLAN Connected Successfully")); this->showDesktopNotify(tr("WLAN Connected Successfully"), "networkconnected");
} }
return; return;