Feature:Add wlan switch function.
This commit is contained in:
parent
5d8a6f3b3d
commit
8b27a51583
|
@ -613,6 +613,12 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
||||||
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
|
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
NetworkManager::setWirelessEnabled(enabled);
|
NetworkManager::setWirelessEnabled(enabled);
|
||||||
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
|
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA);
|
||||||
|
gsetting->set(WIRELESS_SWITCH, enabled);
|
||||||
|
} else {
|
||||||
|
qDebug()<<"isSchemaInstalled false";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KyWirelessConnectOperation::getWirelessEnabled()
|
bool KyWirelessConnectOperation::getWirelessEnabled()
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
#define KYWIRELESSCONNECTOPERATION_H
|
#define KYWIRELESSCONNECTOPERATION_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QGSettings>
|
||||||
#include "kyenterpricesettinginfo.h"
|
#include "kyenterpricesettinginfo.h"
|
||||||
#include "kylinconnectoperation.h"
|
#include "kylinconnectoperation.h"
|
||||||
#include "kyenterpricesettinginfo.h"
|
#include "kyenterpricesettinginfo.h"
|
||||||
|
|
||||||
|
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||||
|
const QString WIRELESS_SWITCH = "wirelessswitch";
|
||||||
|
|
||||||
enum KySecuType {
|
enum KySecuType {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
WPA_AND_WPA2_PERSONAL,
|
WPA_AND_WPA2_PERSONAL,
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
||||||
{
|
{
|
||||||
initUI();
|
initUI();
|
||||||
|
initConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
ListItem::~ListItem()
|
ListItem::~ListItem()
|
||||||
|
|
|
@ -16,6 +16,7 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
||||||
initDevice();
|
initDevice();
|
||||||
m_wirelessConnectOpreation = new KyWirelessConnectOperation(this);
|
m_wirelessConnectOpreation = new KyWirelessConnectOperation(this);
|
||||||
initWlanUI();
|
initWlanUI();
|
||||||
|
//要在initUI之后调用,保证UI的信号槽顺利绑定
|
||||||
initConnections();
|
initConnections();
|
||||||
getActiveWlan();
|
getActiveWlan();
|
||||||
getAllWlan();
|
getAllWlan();
|
||||||
|
@ -80,6 +81,7 @@ void WlanPage::initWlanUI()
|
||||||
m_activatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
m_activatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
m_activatedNetListWidget->setSpacing(NET_LIST_SPACING);
|
m_activatedNetListWidget->setSpacing(NET_LIST_SPACING);
|
||||||
m_activatedNetListWidget->setFixedHeight(NORMAL_HEIGHT);
|
m_activatedNetListWidget->setFixedHeight(NORMAL_HEIGHT);
|
||||||
|
m_activatedNetListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
m_activatedNetLayout->addWidget(m_activatedNetListWidget);
|
m_activatedNetLayout->addWidget(m_activatedNetListWidget);
|
||||||
// m_inactivatedNetListArea->setFixedHeight(SCROLLAREA_HEIGHT);
|
// m_inactivatedNetListArea->setFixedHeight(SCROLLAREA_HEIGHT);
|
||||||
m_inactivatedNetListArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
m_inactivatedNetListArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
@ -94,6 +96,21 @@ void WlanPage::initConnections()
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
||||||
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||||
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
||||||
|
connect(m_netSwitch, &SwitchButton::clicked, this, &WlanPage::onWlanSwitchClicked);
|
||||||
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
|
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||||
|
if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) {
|
||||||
|
m_netSwitch->setSwitchStatus(m_switchGsettings->get(WIRELESS_SWITCH).toBool());
|
||||||
|
connect(m_switchGsettings, &QGSettings::changed, this, [ = ](const QString &key) {
|
||||||
|
if (key == WIRELESS_SWITCH) {
|
||||||
|
onWlanSwitchStatusChanged(m_switchGsettings->get(WIRELESS_SWITCH).toBool());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug()<<"isSchemaInstalled false" << Q_FUNC_INFO << __LINE__;
|
||||||
|
m_netSwitch->setSwitchStatus(m_wirelessConnectOpreation->getWirelessEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,3 +365,19 @@ void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo,
|
||||||
qDebug() << "Received signal of connecting wlan, ssid = " << connSettingInfo.m_ssid << Q_FUNC_INFO << __LINE__;
|
qDebug() << "Received signal of connecting wlan, ssid = " << connSettingInfo.m_ssid << Q_FUNC_INFO << __LINE__;
|
||||||
m_wirelessConnectOpreation->addAndActiveWirelessConnect(defaultDevice, connSettingInfo, isHidden);
|
m_wirelessConnectOpreation->addAndActiveWirelessConnect(defaultDevice, connSettingInfo, isHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief WlanPage::onWlanSwitchClicked 点击无线网开关
|
||||||
|
*/
|
||||||
|
void WlanPage::onWlanSwitchClicked()
|
||||||
|
{
|
||||||
|
qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
||||||
|
m_wirelessConnectOpreation->setWirelessEnabled(m_netSwitch->getSwitchStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlanPage::onWlanSwitchStatusChanged(const bool &checked)
|
||||||
|
{
|
||||||
|
m_netSwitch->setSwitchStatus(checked);
|
||||||
|
qDebug() << "On wlan switch status changed! new state = " << m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
||||||
|
onWlanUpdated();
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "kylinnetworkdeviceresource.h"
|
#include "kylinnetworkdeviceresource.h"
|
||||||
#include "kywirelessconnectoperation.h"
|
#include "kywirelessconnectoperation.h"
|
||||||
#include "wlanlistitem.h"
|
#include "wlanlistitem.h"
|
||||||
|
#include <QGSettings>
|
||||||
|
|
||||||
//#define SCROLLAREA_HEIGHT 150
|
//#define SCROLLAREA_HEIGHT 150
|
||||||
#define MORE_TEXT_MARGINS 16,0,0,0
|
#define MORE_TEXT_MARGINS 16,0,0,0
|
||||||
|
@ -53,6 +54,7 @@ private:
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||||
KyWirelessConnectOperation * m_wirelessConnectOpreation = nullptr;
|
KyWirelessConnectOperation * m_wirelessConnectOpreation = nullptr;
|
||||||
|
QGSettings *m_switchGsettings = nullptr;
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -68,6 +70,8 @@ private slots:
|
||||||
NetworkManager::ActiveConnection::Reason reason);
|
NetworkManager::ActiveConnection::Reason reason);
|
||||||
void onItemHeightChanged(const QString &ssid);
|
void onItemHeightChanged(const QString &ssid);
|
||||||
void onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden);
|
void onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden);
|
||||||
|
void onWlanSwitchClicked();
|
||||||
|
void onWlanSwitchStatusChanged(const bool &checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WLANPAGE_H
|
#endif // WLANPAGE_H
|
||||||
|
|
Loading…
Reference in New Issue