wlanpage changed

This commit is contained in:
jinxujie 2021-09-23 09:56:23 +08:00
parent c20a9a94c6
commit 0c739884a6
3 changed files with 21 additions and 16 deletions

View File

@ -348,13 +348,10 @@ void MainWindow::onThemeChanged(const QString &key)
void MainWindow::onGetConnectChangedIcon()
{
if (m_lanWidget->lanIsConnected == true){
qDebug()<<"11111111111111111111111111";
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
} else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->lanIsConnected == false){
qDebug()<<"2222222222222222222";
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
} else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->lanIsConnected == false){
qDebug()<<"333333333333333333333333";
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
}
}

View File

@ -394,7 +394,7 @@ void LanPage::initUI()
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
emit this->lanConnectChanged();
// emit this->lanConnectChanged();
}
void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
@ -617,7 +617,21 @@ void LanPage::onLanDataChange(QString uuid)
void LanPage::getLanConnectStatus(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
{
//lanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
QString devName;
NetworkManager::ConnectionSettings::ConnectionType type;
if (m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
return;
}
}
if (NetworkManager::ActiveConnection::State::Activated == state){
lanIsConnected = true;
qDebug() << "[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ;
} else {
lanIsConnected = false;
qDebug() << "=[lanpage]lanIsConnected status : " << lanIsConnected << Q_FUNC_INFO << __LINE__ ;
}
}
void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)

View File

@ -229,8 +229,7 @@ void WlanPage::getActiveWlan()
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
m_activatedNetListWidget->addItem(wlanItem);
emit this->wlanConnectChanged();
qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ;
// emit this->wlanConnectChanged();
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
height += wlanItemWidget->height();
}
@ -269,7 +268,7 @@ void WlanPage::getAllWlan()
if (!m_inactivatedNetListWidget) {
return;
}
qDebug() << "Started loading wlan list! time=我的getallwlah" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
qDebug() << "Started loading wlan list!" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
m_inactivatedNetListWidget->clear();
m_itemsMap.clear();
QList<KyWirelessNetItem> wlanList;
@ -488,7 +487,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
m_activatedNetListWidget->clear();
int height = 0;
appendActiveWlan(uuid, height);
emit this->wlanConnectChanged();
// emit this->wlanConnectChanged();
onWlanRemoved(m_defaultDevice, ssid);
// this->showDesktopNotify(tr("Connect WLAN succeed"));
} else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) {
@ -547,7 +546,6 @@ void WlanPage::onWlanSwitchClicked()
qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
//应该先检测是否有无线网卡可用,才改变开关状态
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
qDebug()<< "------------应该先检测是否有无线网卡可用,才改变开关状态-------------" <<m_devList.isEmpty();
if (m_devList.isEmpty()) {
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
//检测不到无线网卡不再触发click信号
@ -584,9 +582,7 @@ void WlanPage::requestScan()
qWarning() << "Scan failed! m_wirelessConnectOpreation is nullptr!" << Q_FUNC_INFO << __LINE__;
return;
}
qWarning() << "Scan ------requestScan------刷新列表-----------------------------------" << Q_FUNC_INFO << __LINE__;
m_wirelessConnectOpreation->requestWirelessScan();
getAllWlan();
}
void WlanPage::onHiddenWlanClicked()
@ -614,17 +610,16 @@ void WlanPage::getWlanConnectStatus(QString uuid, NetworkManager::ActiveConnecti
}
if(NetworkManager::ActiveConnection::State::Activated == state){
wlanIsConnected = true;
qDebug() << "111111111111[wlanpage]------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
} else {
wlanIsConnected = false;
qDebug() << "1111111111111[wlanpage]--------------" << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
}
}
void WlanPage::onWifinEnabledChanged(bool isWifiOn)
{
//监听外部命令导致wifi状态变化更新界面
qDebug() <<"------------------------------监听外部命令导致wifi状态变化更新界面-----------------------------------------";
//应该先检测是否有无线网卡可用,才改变开关状态
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
if (m_devList.isEmpty()) {
@ -635,7 +630,6 @@ void WlanPage::onWifinEnabledChanged(bool isWifiOn)
return;
}else{
//m_wirelessConnectOpreation->setWirelessEnabled(isWifiOn);
qDebug() << "have no device to use++++++++++++++++ " << Q_FUNC_INFO << __LINE__;
m_netSwitch->setSwitchStatus(isWifiOn);
//外部命令导致连接状态发生变化,通知主界面刷新图标
emit this->wlanConnectChanged();