modify setWirelessEnable && when property change reactive connection

This commit is contained in:
jzxc95 2021-10-18 10:02:46 +08:00
parent 2e09adefdb
commit 400999f1b1
6 changed files with 52 additions and 19 deletions

View File

@ -78,16 +78,17 @@ void DbusAdaptor::setWiredSwitchEnable(bool enable)
void DbusAdaptor::setWirelessSwitchEnable(bool enable)
{
//todo mainwindow调用backend 对开关 打开/关闭
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) {
gsetting->set(KEY_WIRELESS_SWITCH, enable);
}
delete gsetting;
gsetting = nullptr;
} else {
qDebug()<<"isSchemaInstalled false";
}
// if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
// QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
// if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) {
// gsetting->set(KEY_WIRELESS_SWITCH, enable);
// }
// delete gsetting;
// gsetting = nullptr;
// } else {
// qDebug()<<"isSchemaInstalled false";
// }
parent()->setWirelessSwitchEnable(enable);
}
//启用/禁用网卡

View File

@ -448,6 +448,12 @@ void MainWindow::getStoredApInfo(QStringList &list)
m_wlanWidget->getStoredApInfo(list);
}
//无线开关
void MainWindow::setWirelessSwitchEnable(bool enable)
{
m_wlanWidget->setWirelessSwitchEnable(enable);
}
void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
{
m_lanWidget->setWiredDeviceEnable(devName, enable);

View File

@ -42,6 +42,8 @@ public:
//无线连接断开
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void setWiredDeviceEnable(const QString& devName, bool enable);

View File

@ -831,17 +831,24 @@ bool NetDetail::updateConnect()
m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting);
}
if (isWlan && securityPage->checkIsChanged(m_info)) {
KySecuType secuType;
KyEapMethodType enterpriseType;
securityPage->getSecuType(secuType, enterpriseType);
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
updateWirelessEnterPriseConnect(enterpriseType);
} else {
updateWirelessPersonalConnect();
bool securityChange = false;
if (isWlan) {
securityChange = securityPage->checkIsChanged(m_info);
if (securityChange) {
KySecuType secuType;
KyEapMethodType enterpriseType;
securityPage->getSecuType(secuType, enterpriseType);
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
updateWirelessEnterPriseConnect(enterpriseType);
} else {
updateWirelessPersonalConnect();
}
}
}
if (ipv4Change || ipv6Change || securityChange) {
if (isActive) {
//安全性变化 断开-重连
//信息变化 断开-重连
m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName);
}
}

View File

@ -970,6 +970,21 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
netDetail->show();
}
void WlanPage::setWirelessSwitchEnable(bool enable)
{
qDebug() << "dbus setWirelessSwitchEnable = " << enable << __LINE__;
//应该先检测是否有无线网卡可用,才改变开关状态
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
if (m_devList.isEmpty()) {
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
//检测不到无线网卡不再触发click信号
m_netSwitch->setSwitchStatus(false);
m_netSwitch->setEnabled(false);
}else{
m_wirelessConnectOpreation->setWirelessEnabled(enable);
}
}
void WlanPage::getWirelessDeviceCap(QMap<QString, int> &map)
{
for (int i = 0; i < m_devList.size(); ++i) {

View File

@ -39,6 +39,8 @@ public:
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void showDetailPage(QString devName, QString uuid);