add scan dbus

This commit is contained in:
jzxc95 2021-10-12 19:01:31 +08:00
parent 205bd5b3c5
commit ac5ed03294
9 changed files with 63 additions and 2 deletions

View File

@ -33,6 +33,10 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove);
connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWirelessNetResource::onConnectionUpdate);
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &KyWirelessNetResource::onDeviceAdd);
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &KyWirelessNetResource::onDeviceRemove);
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &KyWirelessNetResource::onDeviceNameUpdate);
}
KyWirelessNetResource::~KyWirelessNetResource()
@ -538,3 +542,34 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
kyWirelessNetItemListInit();
emit wifiNetworkUpdate();
}
void KyWirelessNetResource::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType)
{
if(deviceType == NetworkManager::Device::Type::Wifi) {
if (!m_WifiNetworkList.contains(deviceName)) {
m_WifiNetworkList.insert(deviceName,QList<KyWirelessNetItem>());
}
}
}
void KyWirelessNetResource::onDeviceRemove(QString deviceName)
{
if (m_WifiNetworkList.contains(deviceName)) {
m_WifiNetworkList.remove(deviceName);
}
}
void KyWirelessNetResource::onDeviceNameUpdate(QString oldName, QString newName)
{
if (!m_WifiNetworkList.contains(oldName)) {
return;
}
QMap<QString, QList<KyWirelessNetItem> > newWifiNetworkList(m_WifiNetworkList);
QList<KyWirelessNetItem> list = m_WifiNetworkList[oldName];
newWifiNetworkList.remove(oldName);
newWifiNetworkList.insert(newName,list);
m_WifiNetworkList = newWifiNetworkList;
}

View File

@ -7,6 +7,7 @@
#include "kyenterpricesettinginfo.h"
#include "kylinconnectresource.h"
#include "kywirelessconnectoperation.h"
#include "kylinnetworkdeviceresource.h"
//class KyWirelessNetItem;
@ -47,6 +48,10 @@ public slots:
void onConnectionUpdate(QString uuid);
void onConnectionRemove(QString);
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
void onDeviceRemove(QString deviceName);
void onDeviceNameUpdate(QString oldName, QString newName);
signals:
void signalStrengthChange(QString, QString, int);
void bssidChange(QString, QString, QString);
@ -61,6 +66,7 @@ private:
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
KyConnectResourse *m_connectResource = nullptr;
KyWirelessConnectOperation *m_operation = nullptr;
KyNetworkDeviceResourse *m_device = nullptr;
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
};

View File

@ -209,3 +209,10 @@ QStringList DbusAdaptor::getStoredApInfo()
parent()->getStoredApInfo(list);
return list;
}
//扫描
void DbusAdaptor::reScan()
{
parent()->rescan();
}

View File

@ -78,6 +78,8 @@ public Q_SLOTS: // METHODS
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
//获取热点
QStringList getStoredApInfo();
//wifi扫描
void reScan();
Q_SIGNALS: // SIGNALS
// void wirelessActivating(QString devName, QString ssid);
// void wiredActivating(QString devName, QString ssid);

View File

@ -504,3 +504,8 @@ void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->deactivateWireless(devName, ssid);
}
void MainWindow::rescan()
{
m_wlanWidget->requestScan();
}

View File

@ -49,6 +49,8 @@ public:
//唤起新建有线连接界面
void showCreateWiredConnectWidget(const QString devName);
void rescan();
signals:
//设备插拔
void deviceStatusChanged();

View File

@ -81,7 +81,6 @@ void DetailPage::initUI() {
mSSID = new QLineEdit(this);
mSSID->setAlignment(Qt::AlignRight);
qDebug() << "DetailPage" << isCreate;
if (!isCreate) {
mSSID->setStyleSheet("background:transparent;border-width:0;border-style:outset");
mSSID->setFocusPolicy(Qt::NoFocus);

View File

@ -815,6 +815,10 @@ bool NetDetail::updateConnect()
} else {
updateWirelessPersonalConnect();
}
if (isActive) {
//安全性变化 断开-重连
m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName);
}
}
return true;
}

View File

@ -40,6 +40,7 @@ public:
void deactivateWireless(const QString& devName, const QString& ssid);
void showDetailPage(QString devName, QString uuid);
signals:
void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info);
@ -54,6 +55,7 @@ signals:
public slots:
void onMainWindowVisibleChanged(const bool &visible);
void requestScan();
protected:
bool eventFilter(QObject *watched, QEvent *event);
@ -119,7 +121,6 @@ private slots:
void onWlanSwitchClicked();
void onWlanSwitchStatusChanged(const bool &checked);
void onDeviceComboxIndexChanged(int currentIndex);
void requestScan();
void onHiddenWlanClicked();
void showControlCenter();
void onWifiEnabledChanged(bool isWifiOn);