增加通知

This commit is contained in:
jzxc95 2021-11-03 11:48:45 +08:00
parent c156426ddb
commit 0be90ace26
14 changed files with 189 additions and 49 deletions

View File

@ -203,6 +203,7 @@ void SwitchButton::mousePressEvent(QMouseEvent *){
}
if(disabled){
mEndX = 0;
Q_EMIT disabledClick();
return ;
}else{
checked = !checked;

View File

@ -115,7 +115,7 @@ private Q_SLOTS:
Q_SIGNALS:
void checkedChanged(bool checked);
void disabledClick();
};
#endif // SWITCHBUTTON_H

View File

@ -49,6 +49,26 @@ const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
bool sortByVal(const QPair<QString, int> &l, const QPair<QString, int> &r) {
return (l.second < r.second);
}
void NetConnect::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("ukui control center"))
<<((unsigned int) 0)
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
<<tr("ukui control center desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
NetConnect::NetConnect() : mFirstLoad(true) {
QTranslator* translator = new QTranslator(this);
translator->load("/usr/share/kylin-nm/netconnect/" + QLocale::system().name());
@ -147,6 +167,10 @@ void NetConnect::initComponent() {
ui->openWIifLayout->addWidget(wiredSwitch);
ui->detailLayOut->setContentsMargins(MAIN_LAYOUT_MARGINS);
connect(wiredSwitch, &SwitchButton::disabledClick, this, []() {
showDesktopNotify(tr("No ethernet device avaliable"));
});
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
connect(wiredSwitch, &SwitchButton::checkedChanged, this, [=] (bool checked) {

View File

@ -87,6 +87,8 @@ private:
void initComponent();
void runExternalApp();
void showDesktopNotify(const QString &message);
//开关相关
void setSwitchStatus();

View File

@ -4,7 +4,7 @@
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<location filename="../addnetbtn.cpp" line="18"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
@ -13,37 +13,52 @@
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="47"/>
<location filename="../netconnect.cpp" line="129"/>
<location filename="../netconnect.cpp" line="149"/>
<source>Wired Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.ui" line="109"/>
<location filename="../netconnect.cpp" line="131"/>
<location filename="../netconnect.cpp" line="151"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="192"/>
<location filename="../netconnect.cpp" line="128"/>
<location filename="../netconnect.cpp" line="148"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="57"/>
<location filename="../netconnect.cpp" line="60"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="77"/>
<source>WiredConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="403"/>
<location filename="../netconnect.cpp" line="814"/>
<location filename="../netconnect.cpp" line="171"/>
<source>No ethernet device avaliable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="420"/>
<location filename="../netconnect.cpp" line="837"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="467"/>
<location filename="../netconnect.cpp" line="484"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>

View File

@ -4,7 +4,7 @@
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<location filename="../addnetbtn.cpp" line="18"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
@ -13,37 +13,52 @@
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="47"/>
<location filename="../netconnect.cpp" line="129"/>
<location filename="../netconnect.cpp" line="149"/>
<source>Wired Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.ui" line="109"/>
<location filename="../netconnect.cpp" line="131"/>
<location filename="../netconnect.cpp" line="151"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="192"/>
<location filename="../netconnect.cpp" line="128"/>
<location filename="../netconnect.cpp" line="148"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="57"/>
<location filename="../netconnect.cpp" line="60"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="77"/>
<source>WiredConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="403"/>
<location filename="../netconnect.cpp" line="814"/>
<location filename="../netconnect.cpp" line="171"/>
<source>No ethernet device avaliable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="420"/>
<location filename="../netconnect.cpp" line="837"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="467"/>
<location filename="../netconnect.cpp" line="484"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>

View File

@ -4,7 +4,7 @@
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<location filename="../addnetbtn.cpp" line="18"/>
<source>Add WiredNetork</source>
<translation>线</translation>
</message>
@ -13,37 +13,52 @@
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="47"/>
<location filename="../netconnect.cpp" line="129"/>
<location filename="../netconnect.cpp" line="149"/>
<source>Wired Network</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.ui" line="109"/>
<location filename="../netconnect.cpp" line="131"/>
<location filename="../netconnect.cpp" line="151"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="192"/>
<location filename="../netconnect.cpp" line="128"/>
<location filename="../netconnect.cpp" line="148"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="57"/>
<location filename="../netconnect.cpp" line="60"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="77"/>
<source>WiredConnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="403"/>
<location filename="../netconnect.cpp" line="814"/>
<location filename="../netconnect.cpp" line="171"/>
<source>No ethernet device avaliable</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="420"/>
<location filename="../netconnect.cpp" line="837"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="467"/>
<location filename="../netconnect.cpp" line="484"/>
<source>card</source>
<translation></translation>
</message>

View File

@ -5,39 +5,54 @@
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="72"/>
<location filename="../wlanconnect.cpp" line="89"/>
<source>WlanConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="143"/>
<location filename="../wlanconnect.cpp" line="160"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="145"/>
<location filename="../wlanconnect.cpp" line="162"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="142"/>
<location filename="../wlanconnect.cpp" line="159"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="297"/>
<location filename="../wlanconnect.cpp" line="865"/>
<location filename="../wlanconnect.cpp" line="927"/>
<location filename="../wlanconnect.cpp" line="72"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="75"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="182"/>
<source>No wireless network card detected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="319"/>
<location filename="../wlanconnect.cpp" line="906"/>
<location filename="../wlanconnect.cpp" line="968"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="827"/>
<location filename="../wlanconnect.cpp" line="859"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>

View File

@ -5,39 +5,54 @@
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="72"/>
<location filename="../wlanconnect.cpp" line="89"/>
<source>WlanConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="143"/>
<location filename="../wlanconnect.cpp" line="160"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="145"/>
<location filename="../wlanconnect.cpp" line="162"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="142"/>
<location filename="../wlanconnect.cpp" line="159"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="297"/>
<location filename="../wlanconnect.cpp" line="865"/>
<location filename="../wlanconnect.cpp" line="927"/>
<location filename="../wlanconnect.cpp" line="72"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="75"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="182"/>
<source>No wireless network card detected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="319"/>
<location filename="../wlanconnect.cpp" line="906"/>
<location filename="../wlanconnect.cpp" line="968"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="827"/>
<location filename="../wlanconnect.cpp" line="859"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>

View File

@ -5,39 +5,54 @@
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="72"/>
<location filename="../wlanconnect.cpp" line="89"/>
<source>WlanConnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="143"/>
<location filename="../wlanconnect.cpp" line="160"/>
<source>WLAN</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="145"/>
<location filename="../wlanconnect.cpp" line="162"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="142"/>
<location filename="../wlanconnect.cpp" line="159"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="297"/>
<location filename="../wlanconnect.cpp" line="865"/>
<location filename="../wlanconnect.cpp" line="927"/>
<location filename="../wlanconnect.cpp" line="72"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="75"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="182"/>
<source>No wireless network card detected</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="319"/>
<location filename="../wlanconnect.cpp" line="906"/>
<location filename="../wlanconnect.cpp" line="968"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="827"/>
<location filename="../wlanconnect.cpp" line="859"/>
<source>card</source>
<translation></translation>
</message>

View File

@ -62,6 +62,23 @@ bool intThan(int sign1, int sign2)
return sign1 < sign2;
}
void WlanConnect::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("ukui control center"))
<<((unsigned int) 0)
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
<<tr("ukui control center desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
WlanConnect::WlanConnect() : mFirstLoad(true) {
@ -161,6 +178,10 @@ void WlanConnect::initComponent() {
ui->openWIifLayout->addWidget(wifiSwtch);
ui->detailLayOut_3->setContentsMargins(MAIN_LAYOUT_MARGINS);
connect(wifiSwtch, &SwitchButton::disabledClick, this, []() {
showDesktopNotify(tr("No wireless network card detected"));
});
//开关
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);

View File

@ -75,6 +75,8 @@ private:
void runExternalApp();
void initSearchText();
void showDesktopNotify(const QString &message);
//点击item 连接/断开
void activeConnect(QString netName, QString deviceName, int type);
void deActiveConnect(QString netName, QString deviceName, int type);