This commit is contained in:
zhangjiaping 2021-10-08 11:38:58 +08:00
parent 45f4817cfb
commit c0d2a259c2
2 changed files with 13 additions and 10 deletions

View File

@ -287,10 +287,10 @@ void WlanListItem::onNetButtonClicked()
qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
return; return;
} }
//有配置或者无密码的wifi直接连接 //有配置的wifi直接连接
if (m_data->m_isConfigured || m_hasPwd == false) { if (m_data->m_isConfigured) {
this->onConnectButtonClicked(); // this->onConnectButtonClicked();
// m_connoperation->activeWirelessConnect(m_wlanDevice, m_data->m_connectUuid);//初始化没有uuid只有激活一次才有uuid m_connoperation->activeWirelessConnect(m_wlanDevice, m_data->m_connectUuid);//初始化没有uuid只有激活一次才有uuid
qDebug() << "Has configuration, will be activated. ssid = " << m_data->m_NetSsid << m_wlanDevice << m_data->m_connectUuid << Q_FUNC_INFO << __LINE__; qDebug() << "Has configuration, will be activated. ssid = " << m_data->m_NetSsid << m_wlanDevice << m_data->m_connectUuid << Q_FUNC_INFO << __LINE__;
return; return;
} }
@ -301,7 +301,7 @@ void WlanListItem::onNetButtonClicked()
} else { } else {
this->setExpanded(true); this->setExpanded(true);
} }
} else { } else { //无密码的情况
onConnectButtonClicked(); onConnectButtonClicked();
} }
} }
@ -369,9 +369,8 @@ void WlanListItem::onShowPwdButtonClicked()
void WlanListItem::onConnectButtonClicked() void WlanListItem::onConnectButtonClicked()
{ {
if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") { if ((m_connectButton->isVisible() && !m_connectButton->isEnabled()) || !m_data) {
qDebug() << "connect to no password wifi" << Q_FUNC_INFO << __LINE__; qWarning() << "Connect wlan failed because of null pointer or button state!" << Q_FUNC_INFO << __LINE__;
} else if (!m_connectButton->isEnabled() || !m_data) {
return; return;
} }
@ -386,6 +385,7 @@ void WlanListItem::onConnectButtonClicked()
settings.isAutoConnect = m_autoConnectCheckBox->isChecked(); settings.isAutoConnect = m_autoConnectCheckBox->isChecked();
settings.m_psk = m_pwdLineEdit->text(); settings.m_psk = m_pwdLineEdit->text();
if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") { if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") {
qDebug() << "connect to no password wifi" << Q_FUNC_INFO << __LINE__;
settings.m_type = WpaNone; settings.m_type = WpaNone;
} else if (m_data->m_secuType.contains("WPA1") || m_data->m_secuType.contains("WPA2")) { } else if (m_data->m_secuType.contains("WPA1") || m_data->m_secuType.contains("WPA2")) {
settings.m_type = WpaPsk; settings.m_type = WpaPsk;

View File

@ -333,6 +333,7 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << "interface" << interface << Q_FUNC_INFO <<__LINE__; qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << "interface" << interface << Q_FUNC_INFO <<__LINE__;
if (interface != m_defaultDevice) { if (interface != m_defaultDevice) {
qDebug() << "wlan add interface not equal defaultdevice,ignore"; qDebug() << "wlan add interface not equal defaultdevice,ignore";
return;
} }
KyWirelessNetItem *data = new KyWirelessNetItem(item); KyWirelessNetItem *data = new KyWirelessNetItem(item);
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, m_defaultDevice); WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, m_defaultDevice);
@ -495,7 +496,8 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
//弹窗显示wifi连接状况 //弹窗显示wifi连接状况
qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__; qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__;
//QString ssid; //QString ssid;
m_resource->getSsidByUuid(uuid, ssid, m_defaultDevice); QString device = m_defaultDevice;
m_resource->getSsidByUuid(uuid, ssid, device);
if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) { if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) {
if(m_activedssid != m_activatedWlanSSid){ if(m_activedssid != m_activatedWlanSSid){
m_activedssid = m_activatedWlanSSid; m_activedssid = m_activatedWlanSSid;
@ -573,6 +575,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
QString oldActWlanSsid = m_activatedWlanSSid; QString oldActWlanSsid = m_activatedWlanSSid;
getActiveWlan(); getActiveWlan();
QString newActWlanSsid = m_activatedWlanSSid; QString newActWlanSsid = m_activatedWlanSSid;
qDebug() << "Refresh active wlan succeed, old ssid = " << oldActWlanSsid << "; new ssid = " << newActWlanSsid << Q_FUNC_INFO << __LINE__;
if (oldActWlanSsid != newActWlanSsid) { if (oldActWlanSsid != newActWlanSsid) {
if (!oldActWlanSsid.isEmpty()) { if (!oldActWlanSsid.isEmpty()) {
KyWirelessNetItem item; KyWirelessNetItem item;
@ -613,7 +616,7 @@ void WlanPage::onItemHeightChanged(const QString &ssid)
void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden) void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden)
{ {
qDebug() << "Received signal of connecting wlan, ssid = " << connSettingInfo.m_ssid << Q_FUNC_INFO << __LINE__; qDebug() << "Received signal of connecting wlan, ssid = " << connSettingInfo.m_ssid << "device name = " << m_defaultDevice << Q_FUNC_INFO << __LINE__;
m_wirelessConnectOpreation->addAndActiveWirelessConnect(m_defaultDevice, connSettingInfo, isHidden); m_wirelessConnectOpreation->addAndActiveWirelessConnect(m_defaultDevice, connSettingInfo, isHidden);
} }