Merge branch '1027-cc' into 'dbus-interface'
当收到状态变化时,且网卡名称不存在于当前列表中,删除当前列表中uuid相同的项 See merge request kylin-desktop/kylin-nm!376
This commit is contained in:
commit
d8ac8df38b
|
@ -203,6 +203,7 @@ void SwitchButton::mousePressEvent(QMouseEvent *){
|
|||
}
|
||||
if(disabled){
|
||||
mEndX = 0;
|
||||
Q_EMIT disabledClick();
|
||||
return ;
|
||||
}else{
|
||||
checked = !checked;
|
||||
|
|
|
@ -115,7 +115,7 @@ private Q_SLOTS:
|
|||
|
||||
Q_SIGNALS:
|
||||
void checkedChanged(bool checked);
|
||||
|
||||
void disabledClick();
|
||||
};
|
||||
|
||||
#endif // SWITCHBUTTON_H
|
||||
|
|
|
@ -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) {
|
||||
|
@ -783,6 +807,16 @@ void NetConnect::onActiveConnectionChanged(QString deviceName, QString uuid, int
|
|||
}
|
||||
itemActiveConnectionStatusChanged(item, status);
|
||||
}
|
||||
} else {
|
||||
if (status == ACTIVATED || status == DEACTIVATED) {
|
||||
//虚拟网卡处理
|
||||
QMap<QString, ItemFrame *>::iterator iters;
|
||||
for (iters = deviceFrameMap.begin(); iters != deviceFrameMap.end(); iters++) {
|
||||
if (iters.value()->itemMap.contains(uuid)) {
|
||||
removeOneLanFrame(iters.value(), iters.key(), uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,8 @@ private:
|
|||
void initComponent();
|
||||
void runExternalApp();
|
||||
|
||||
void showDesktopNotify(const QString &message);
|
||||
|
||||
|
||||
//开关相关
|
||||
void setSwitchStatus();
|
||||
|
|
|
@ -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"</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>
|
||||
|
|
|
@ -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"</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>
|
||||
|
|
Binary file not shown.
|
@ -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"</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>
|
||||
|
|
|
@ -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"</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>
|
||||
|
|
|
@ -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"</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>
|
||||
|
|
Binary file not shown.
|
@ -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"</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>
|
||||
|
|
|
@ -62,8 +62,25 @@ 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) {
|
||||
WlanConnect::WlanConnect() : m_firstLoad(true) {
|
||||
|
||||
QTranslator* translator = new QTranslator(this);
|
||||
translator->load("/usr/share/kylin-nm/wlanconnect/" + QLocale::system().name());
|
||||
|
@ -75,7 +92,7 @@ WlanConnect::WlanConnect() : mFirstLoad(true) {
|
|||
|
||||
WlanConnect::~WlanConnect()
|
||||
{
|
||||
if (!mFirstLoad) {
|
||||
if (!m_firstLoad) {
|
||||
delete ui;
|
||||
ui = nullptr;
|
||||
}
|
||||
|
@ -92,8 +109,8 @@ int WlanConnect::pluginTypes() {
|
|||
}
|
||||
|
||||
QWidget *WlanConnect::pluginUi() {
|
||||
if (mFirstLoad) {
|
||||
mFirstLoad = false;
|
||||
if (m_firstLoad) {
|
||||
m_firstLoad = false;
|
||||
|
||||
ui = new Ui::WlanConnect;
|
||||
pluginWidget = new QWidget;
|
||||
|
@ -157,18 +174,22 @@ bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
|
|||
}
|
||||
|
||||
void WlanConnect::initComponent() {
|
||||
wifiSwtch = new SwitchButton(pluginWidget, false);
|
||||
ui->openWIifLayout->addWidget(wifiSwtch);
|
||||
m_wifiSwitch = new SwitchButton(pluginWidget, false);
|
||||
ui->openWIifLayout->addWidget(m_wifiSwitch);
|
||||
ui->detailLayOut_3->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
|
||||
connect(m_wifiSwitch, &SwitchButton::disabledClick, this, [=]() {
|
||||
showDesktopNotify(tr("No wireless network card detected"));
|
||||
});
|
||||
|
||||
//开关
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||
connect(wifiSwtch, &SwitchButton::checkedChanged, this, [=] (bool checked) {
|
||||
connect(m_wifiSwitch, &SwitchButton::checkedChanged, this, [=] (bool checked) {
|
||||
if (!m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
if (wifiSwtch->getDisabledFlag()) {
|
||||
if (m_wifiSwitch->getDisabledFlag()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call setWirelessSwitchEnable " << checked << __LINE__;
|
||||
|
@ -182,9 +203,9 @@ void WlanConnect::initComponent() {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
wifiSwtch->blockSignals(true);
|
||||
wifiSwtch->setChecked(true);
|
||||
wifiSwtch->blockSignals(false);
|
||||
m_wifiSwitch->blockSignals(true);
|
||||
m_wifiSwitch->setChecked(true);
|
||||
m_wifiSwitch->blockSignals(false);
|
||||
qDebug()<<"[netconnect] org.ukui.kylin-nm.switch is not installed!";
|
||||
}
|
||||
|
||||
|
@ -192,8 +213,8 @@ void WlanConnect::initComponent() {
|
|||
getDeviceList(deviceList);
|
||||
if (deviceList.isEmpty()) {
|
||||
qDebug() << "[WlanConnect]no device exist when init, set switch disable";
|
||||
wifiSwtch->setDisabledFlag(true);
|
||||
wifiSwtch->setChecked(false);
|
||||
m_wifiSwitch->setDisabledFlag(true);
|
||||
m_wifiSwitch->setChecked(false);
|
||||
}
|
||||
initNet();
|
||||
|
||||
|
@ -245,7 +266,7 @@ void WlanConnect::reScan()
|
|||
//更新列表顺序
|
||||
void WlanConnect::updateList()
|
||||
{
|
||||
if (!wifiSwtch->isChecked()) {
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "update list";
|
||||
|
@ -363,7 +384,7 @@ void WlanConnect::updateIcon(WlanItem *item, QString signalStrength, QString sec
|
|||
//void WlanConnect::updateStrengthList(QString deviceName, QString ssid, int strength)
|
||||
//{
|
||||
// return;
|
||||
// if(!wifiSwtch->isChecked()) {
|
||||
// if(!m_wifiSwitch->isChecked()) {
|
||||
// return;
|
||||
// }
|
||||
// qDebug()<<"[WlanConnect]Update wireless network signal strength:" << deviceName <<ssid << strength;
|
||||
|
@ -439,10 +460,10 @@ void WlanConnect::onDeviceStatusChanged()
|
|||
}
|
||||
deviceList = list;
|
||||
if (deviceList.isEmpty()) {
|
||||
wifiSwtch->setDisabledFlag(true);
|
||||
wifiSwtch->setChecked(false);
|
||||
m_wifiSwitch->setDisabledFlag(true);
|
||||
m_wifiSwitch->setChecked(false);
|
||||
} else {
|
||||
wifiSwtch->setDisabledFlag(false);
|
||||
m_wifiSwitch->setDisabledFlag(false);
|
||||
setSwitchStatus();
|
||||
}
|
||||
}
|
||||
|
@ -475,7 +496,7 @@ void WlanConnect::onDeviceNameChanged(QString oldName, QString newName, int type
|
|||
//activeconnect status change
|
||||
void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status)
|
||||
{
|
||||
if (!wifiSwtch->isChecked()) {
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
return;
|
||||
}
|
||||
if (uuid.isEmpty()) {
|
||||
|
@ -534,7 +555,7 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
|
|||
void WlanConnect::onNetworkAdd(QString deviceName, QStringList wlanInfo)
|
||||
{
|
||||
qDebug()<<"[WlanConnect]onNetworkAdd "<< deviceName << " " << wlanInfo;
|
||||
if(!wifiSwtch->isChecked() || deviceName.isEmpty()) {
|
||||
if(!m_wifiSwitch->isChecked() || deviceName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -566,7 +587,7 @@ void WlanConnect::onNetworkAdd(QString deviceName, QStringList wlanInfo)
|
|||
void WlanConnect::onNetworkRemove(QString deviceName, QString wlannName)
|
||||
{
|
||||
//开关已关闭 忽略
|
||||
// if (!wifiSwtch->isChecked()) {
|
||||
// if (!m_wifiSwitch->isChecked()) {
|
||||
// qDebug() << "[WlanConnect]recieve network remove,but wireless switch is off";
|
||||
// return;
|
||||
// }
|
||||
|
@ -608,17 +629,17 @@ void WlanConnect::getDeviceList(QStringList &list)
|
|||
void WlanConnect::setSwitchStatus()
|
||||
{
|
||||
// if (deviceList.size() == 0) {
|
||||
// wifiSwtch->blockSignals(true);
|
||||
// wifiSwtch->setChecked(false);
|
||||
// wifiSwtch->blockSignals(false);
|
||||
// m_wifiSwitch->blockSignals(true);
|
||||
// m_wifiSwitch->setChecked(false);
|
||||
// m_wifiSwitch->blockSignals(false);
|
||||
// return;
|
||||
// }
|
||||
bool status = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||
qDebug() << "[WlanConnect]setSwitchStatus" << status;
|
||||
wifiSwtch->blockSignals(true);
|
||||
wifiSwtch->setChecked(status);
|
||||
wifiSwtch->blockSignals(false);
|
||||
if (!wifiSwtch->isChecked()) {
|
||||
m_wifiSwitch->blockSignals(true);
|
||||
m_wifiSwitch->setChecked(status);
|
||||
m_wifiSwitch->blockSignals(false);
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
} else {
|
||||
showLayout(ui->availableLayout);
|
||||
|
@ -642,7 +663,7 @@ void WlanConnect::initNet() {
|
|||
void WlanConnect::initNetListFromDevice(QString deviceName)
|
||||
{
|
||||
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName;
|
||||
if (!wifiSwtch->isChecked()) {
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " switch off";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -143,8 +145,8 @@ private:
|
|||
QTimer * m_scanTimer = nullptr;
|
||||
// QTimer * m_updateTimer = nullptr;
|
||||
private:
|
||||
SwitchButton *wifiSwtch;
|
||||
bool mFirstLoad;
|
||||
SwitchButton *m_wifiSwitch;
|
||||
bool m_firstLoad;
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
Loading…
Reference in New Issue