Merge branch 'dbus-interface' into 'dbus-interface'
wlanpage changed See merge request kylin-desktop/kylin-nm!273
This commit is contained in:
commit
36fef6beb3
|
@ -22,6 +22,7 @@ public:
|
||||||
KyConnectResourse *m_connectResource = nullptr;
|
KyConnectResourse *m_connectResource = nullptr;
|
||||||
|
|
||||||
QString deviceName = "";
|
QString deviceName = "";
|
||||||
|
void refreshIcon();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setIcon(bool isOn);
|
void setIcon(bool isOn);
|
||||||
|
|
|
@ -270,8 +270,8 @@ 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直接连接
|
||||||
if (m_data->m_isConfigured) {
|
if (m_data->m_isConfigured || m_hasPwd == false) {
|
||||||
m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid);
|
m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid);
|
||||||
qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||||
return;
|
return;
|
||||||
|
@ -399,35 +399,6 @@ void WlanListItem::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnec
|
||||||
m_netButton->stopLoading();
|
m_netButton->stopLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 网络状态改变的通知
|
|
||||||
// if (state == NetworkManager::ActiveConnection::State::Activated) {
|
|
||||||
//// this->showDesktopNotify(tr("WLAN Connected Successfully"));
|
|
||||||
// } else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
|
||||||
// switch (reason) {
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::UserDisconnected:
|
|
||||||
// this->showDesktopNotify(tr("WLAN Disconnected Successfully"));
|
|
||||||
// break;
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::ServiceStopped:
|
|
||||||
// this->showDesktopNotify(tr("The service providing the VPN connection was stopped"));
|
|
||||||
// break;
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::IpConfigInvalid:
|
|
||||||
// this->showDesktopNotify(tr("The IP config of the active connection was invalid"));
|
|
||||||
// break;
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::ConnectTimeout:
|
|
||||||
// this->showDesktopNotify(tr("The connection attempt to the VPN service timed out"));
|
|
||||||
// break;
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::NoSecrets:
|
|
||||||
// this->showDesktopNotify(tr("Necessary secrets for the connection were not provided"));
|
|
||||||
// break;
|
|
||||||
// case NetworkManager::ActiveConnection::Reason::LoginFailed:
|
|
||||||
// this->showDesktopNotify(tr("Authentication to the server failed"));
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// qDebug() << "Wlan disconnected with unkown reason." << Q_FUNC_INFO << __LINE__;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanListItem::onMenuTriggered(QAction *action)
|
void WlanListItem::onMenuTriggered(QAction *action)
|
||||||
|
|
|
@ -146,7 +146,7 @@ void MainWindow::initTrayIcon()
|
||||||
m_trayIconMenu->addAction(m_showMainwindowAction);
|
m_trayIconMenu->addAction(m_showMainwindowAction);
|
||||||
m_trayIconMenu->addAction(m_showSettingsAction);
|
m_trayIconMenu->addAction(m_showSettingsAction);
|
||||||
m_trayIcon->setContextMenu(m_trayIconMenu);
|
m_trayIcon->setContextMenu(m_trayIconMenu);
|
||||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||||
|
|
||||||
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
|
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
|
||||||
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
|
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
|
||||||
|
@ -170,6 +170,7 @@ void MainWindow::initDbusConnnect()
|
||||||
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);
|
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);
|
||||||
connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate);
|
connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate);
|
||||||
connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged);
|
connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged);
|
||||||
|
connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onRefreshTrayIcon);
|
||||||
|
|
||||||
|
|
||||||
connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd);
|
connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd);
|
||||||
|
@ -179,6 +180,7 @@ void MainWindow::initDbusConnnect()
|
||||||
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
||||||
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
|
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
|
||||||
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
|
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
|
||||||
|
connect(m_wlanWidget, &WlanPage::wlanConnectChanged, this, &MainWindow::onRefreshTrayIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -301,7 +303,11 @@ void MainWindow::resetWindowTheme()
|
||||||
void MainWindow::showControlCenter()
|
void MainWindow::showControlCenter()
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.startDetached("ukui-control-center --netconnect");
|
if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->wlanIsConnected == true){
|
||||||
|
process.startDetached("ukui-control-center --wlanconnect");
|
||||||
|
} else {
|
||||||
|
process.startDetached("ukui-control-center --wiredconnect");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,6 +344,18 @@ void MainWindow::onThemeChanged(const QString &key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onRefreshTrayIcon()
|
||||||
|
{
|
||||||
|
//更新托盘图标显示
|
||||||
|
if (m_lanWidget->m_isLanConnected == true){
|
||||||
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||||
|
} else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){
|
||||||
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
|
||||||
|
} else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){
|
||||||
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MainWindow::keyPressEvent 按esc键关闭主界面
|
* @brief MainWindow::keyPressEvent 按esc键关闭主界面
|
||||||
* @param event
|
* @param event
|
||||||
|
@ -466,7 +484,6 @@ void MainWindow::activateWired(const QString& devName, const QString& connUuid)
|
||||||
{
|
{
|
||||||
m_lanWidget->activateWired(devName, connUuid);
|
m_lanWidget->activateWired(devName, connUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::deactivateWired(const QString& devName, const QString& connUuid)
|
void MainWindow::deactivateWired(const QString& devName, const QString& connUuid)
|
||||||
{
|
{
|
||||||
m_lanWidget->deactivateWired(devName, connUuid);
|
m_lanWidget->deactivateWired(devName, connUuid);
|
||||||
|
|
|
@ -117,6 +117,7 @@ private slots:
|
||||||
void onShowMainwindowActionTriggled();
|
void onShowMainwindowActionTriggled();
|
||||||
void onShowSettingsActionTriggled();
|
void onShowSettingsActionTriggled();
|
||||||
void onThemeChanged(const QString &key);
|
void onThemeChanged(const QString &key);
|
||||||
|
void onRefreshTrayIcon();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -333,6 +333,7 @@ void LanPage::initUI()
|
||||||
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
|
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
|
||||||
|
|
||||||
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
|
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
|
||||||
|
// emit this->lanConnectChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
||||||
|
@ -362,6 +363,7 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显
|
||||||
for (int i = 0; i < m_activedList.size(); i++) {
|
for (int i = 0; i < m_activedList.size(); i++) {
|
||||||
KyConnectItem *activeItemData = m_activedList.at(i);
|
KyConnectItem *activeItemData = m_activedList.at(i);
|
||||||
addNewItem(activeItemData, m_activatedLanListWidget);
|
addNewItem(activeItemData, m_activatedLanListWidget);
|
||||||
|
emit this->lanConnectChanged();
|
||||||
|
|
||||||
m_activeMap.insert(activeItemData, m_listWidgetItem);
|
m_activeMap.insert(activeItemData, m_listWidgetItem);
|
||||||
}
|
}
|
||||||
|
@ -387,9 +389,24 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显
|
||||||
|
|
||||||
void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
||||||
{
|
{
|
||||||
qDebug()<<"[LanPage] State change slot:"<<state;
|
//lanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||||
QString devName;
|
QString devName;
|
||||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
if (m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (NetworkManager::ActiveConnection::State::Activated == state){
|
||||||
|
m_isLanConnected = true;
|
||||||
|
qDebug() << "[lanpage]lanIsConnected status : " << m_isLanConnected << Q_FUNC_INFO << __LINE__ ;
|
||||||
|
} else {
|
||||||
|
m_isLanConnected = false;
|
||||||
|
qDebug() << "=[lanpage]lanIsConnected status : " << m_isLanConnected << Q_FUNC_INFO << __LINE__ ;
|
||||||
|
}
|
||||||
|
qDebug()<<"[LanPage] State change slot:"<<state;
|
||||||
|
// QString devName;
|
||||||
|
// NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
|
||||||
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||||
|
@ -426,6 +443,7 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
|
||||||
if (m_item->m_connectUuid == uuid) {
|
if (m_item->m_connectUuid == uuid) {
|
||||||
m_activatedLanListWidget->removeItemWidget(i.value());
|
m_activatedLanListWidget->removeItemWidget(i.value());
|
||||||
delete(i.value());
|
delete(i.value());
|
||||||
|
emit this->lanConnectChanged();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ class LanPage : public TabPage
|
||||||
public:
|
public:
|
||||||
explicit LanPage(QWidget *parent = nullptr);
|
explicit LanPage(QWidget *parent = nullptr);
|
||||||
~LanPage();
|
~LanPage();
|
||||||
|
bool m_isLanConnected = false;
|
||||||
|
|
||||||
//for dbus
|
//for dbus
|
||||||
void getWiredList(QMap<QString, QVector<QStringList> > &map);
|
void getWiredList(QMap<QString, QVector<QStringList> > &map);
|
||||||
|
@ -33,6 +34,7 @@ signals:
|
||||||
void lanRemove(QString dbusPath);
|
void lanRemove(QString dbusPath);
|
||||||
void lanUpdate(QString devName, QStringList info);
|
void lanUpdate(QString devName, QStringList info);
|
||||||
void lanActiveConnectionStateChanged(QString interface, QString uuid, int status);
|
void lanActiveConnectionStateChanged(QString interface, QString uuid, int status);
|
||||||
|
void lanConnectChanged();
|
||||||
private:
|
private:
|
||||||
void initDeviceCombox();
|
void initDeviceCombox();
|
||||||
void initUI();
|
void initUI();
|
||||||
|
|
|
@ -109,6 +109,24 @@ QString TabPage::getDefaultDevice()
|
||||||
return m_defaultDevice;
|
return m_defaultDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabPage::showDesktopNotify(const QString &message)
|
||||||
|
{
|
||||||
|
QDBusInterface iface("org.freedesktop.Notifications",
|
||||||
|
"/org/freedesktop/Notifications",
|
||||||
|
"org.freedesktop.Notifications",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
QList<QVariant> args;
|
||||||
|
args<<(tr("Kylin NM"))
|
||||||
|
<<((unsigned int) 0)
|
||||||
|
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
|
||||||
|
<<tr("kylin network applet desktop message") //显示的是什么类型的信息
|
||||||
|
<<message //显示的具体信息
|
||||||
|
<<QStringList()
|
||||||
|
<<QVariantMap()
|
||||||
|
<<(int)-1;
|
||||||
|
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||||
|
}
|
||||||
|
|
||||||
void setDefaultDevice(KyDeviceType deviceType, QString deviceName)
|
void setDefaultDevice(KyDeviceType deviceType, QString deviceName)
|
||||||
{
|
{
|
||||||
QString key;
|
QString key;
|
||||||
|
@ -174,6 +192,7 @@ void getDeviceEnableState(int type, QMap<QString, bool> &map)
|
||||||
map.clear();
|
map.clear();
|
||||||
if (!QFile::exists(CONFIG_FILE_PATH)) {
|
if (!QFile::exists(CONFIG_FILE_PATH)) {
|
||||||
qDebug() << "CONFIG_FILE_PATH not exist";
|
qDebug() << "CONFIG_FILE_PATH not exist";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (type != WIRED && type != WIRELESS) {
|
if (type != WIRED && type != WIRELESS) {
|
||||||
qDebug() << "getDeviceEnableState but wrong type";
|
qDebug() << "getDeviceEnableState but wrong type";
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QDebug>
|
||||||
#include "kylinnetworkdeviceresource.h"
|
#include "kylinnetworkdeviceresource.h"
|
||||||
|
|
||||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||||
|
@ -50,6 +53,7 @@ public:
|
||||||
|
|
||||||
void updateDefaultDevice(QString &deviceName);
|
void updateDefaultDevice(QString &deviceName);
|
||||||
QString getDefaultDevice();
|
QString getDefaultDevice();
|
||||||
|
static void showDesktopNotify(const QString &message);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceStatusChanged();
|
void deviceStatusChanged();
|
||||||
|
|
|
@ -17,6 +17,8 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
||||||
initDevice();
|
initDevice();
|
||||||
m_wirelessConnectOpreation = new KyWirelessConnectOperation(this);
|
m_wirelessConnectOpreation = new KyWirelessConnectOperation(this);
|
||||||
m_connectoperation = new KyConnectOperation(this);
|
m_connectoperation = new KyConnectOperation(this);
|
||||||
|
m_settingsLabel->installEventFilter(this);
|
||||||
|
m_connectResource = new KyActiveConnectResourse();
|
||||||
initWlanUI();
|
initWlanUI();
|
||||||
//要在initUI之后调用,保证UI的信号槽顺利绑定
|
//要在initUI之后调用,保证UI的信号槽顺利绑定
|
||||||
initConnections();
|
initConnections();
|
||||||
|
@ -33,6 +35,8 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
||||||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed);
|
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed);
|
||||||
|
|
||||||
connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked);
|
connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked);
|
||||||
|
connect(this, &WlanPage::settingsClicked, this, &WlanPage::showControlCenter);
|
||||||
|
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifinEnabledChanged, this, &WlanPage::onWifiEnabledChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
//QString WlanPage::getSsidFromUuid(const QString &uuid)
|
//QString WlanPage::getSsidFromUuid(const QString &uuid)
|
||||||
|
@ -48,6 +52,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
||||||
emit this->hiddenWlanClicked();
|
emit this->hiddenWlanClicked();
|
||||||
} else if (w == m_settingsLabel) {
|
} else if (w == m_settingsLabel) {
|
||||||
//ZJP_TODO 打开控制面板
|
//ZJP_TODO 打开控制面板
|
||||||
|
emit this->settingsClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QWidget::eventFilter(w,e);
|
return QWidget::eventFilter(w,e);
|
||||||
|
@ -154,6 +159,11 @@ void WlanPage::initDevice()
|
||||||
if (!m_devList.isEmpty()) {
|
if (!m_devList.isEmpty()) {
|
||||||
deviceName = m_devList.at(0);
|
deviceName = m_devList.at(0);
|
||||||
m_settings->setValue(key, deviceName);
|
m_settings->setValue(key, deviceName);
|
||||||
|
} else {
|
||||||
|
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
|
||||||
|
//检测不到无线网卡不再触发click信号
|
||||||
|
m_netSwitch->setSwitchStatus(false);
|
||||||
|
m_netSwitch->setEnabled(false);
|
||||||
}
|
}
|
||||||
updateDefaultDevice(deviceName);
|
updateDefaultDevice(deviceName);
|
||||||
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
||||||
|
@ -217,6 +227,7 @@ void WlanPage::getActiveWlan()
|
||||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
||||||
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
|
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
|
||||||
m_activatedNetListWidget->addItem(wlanItem);
|
m_activatedNetListWidget->addItem(wlanItem);
|
||||||
|
// emit this->wlanConnectChanged();
|
||||||
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
||||||
height += wlanItemWidget->height();
|
height += wlanItemWidget->height();
|
||||||
}
|
}
|
||||||
|
@ -239,6 +250,8 @@ void WlanPage::appendActiveWlan(const QString &uuid, int &height)
|
||||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
||||||
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
|
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
|
||||||
m_activatedNetListWidget->addItem(wlanItem);
|
m_activatedNetListWidget->addItem(wlanItem);
|
||||||
|
emit this->wlanConnectChanged();
|
||||||
|
qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ;
|
||||||
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
||||||
wlanItemWidget->setActive(true);
|
wlanItemWidget->setActive(true);
|
||||||
|
|
||||||
|
@ -253,7 +266,7 @@ void WlanPage::getAllWlan()
|
||||||
if (!m_inactivatedNetListWidget) {
|
if (!m_inactivatedNetListWidget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Started loading wlan list! time=" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
|
qDebug() << "Started loading wlan list!" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
|
||||||
m_inactivatedNetListWidget->clear();
|
m_inactivatedNetListWidget->clear();
|
||||||
m_itemsMap.clear();
|
m_itemsMap.clear();
|
||||||
QList<KyWirelessNetItem> wlanList;
|
QList<KyWirelessNetItem> wlanList;
|
||||||
|
@ -293,8 +306,6 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
||||||
QStringList info;
|
QStringList info;
|
||||||
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
|
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
|
||||||
emit wlanAdd(interface, info);
|
emit wlanAdd(interface, info);
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << 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";
|
||||||
|
@ -345,6 +356,8 @@ void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devi
|
||||||
if (deviceType != NetworkManager::Device::Type::Wifi) {
|
if (deviceType != NetworkManager::Device::Type::Wifi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_netSwitch->setEnabled(true);
|
||||||
|
m_netSwitch->setSwitchStatus(true);
|
||||||
m_devList << deviceName;
|
m_devList << deviceName;
|
||||||
if (getDefaultDevice().isEmpty())
|
if (getDefaultDevice().isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -375,6 +388,9 @@ void WlanPage::onDeviceRemove(QString deviceName)
|
||||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list);
|
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
newDefaultDevice = list.at(0);
|
newDefaultDevice = list.at(0);
|
||||||
|
} else {
|
||||||
|
m_netSwitch->setSwitchStatus(false);
|
||||||
|
m_netSwitch->setEnabled(false);
|
||||||
}
|
}
|
||||||
updateDefaultDevice(newDefaultDevice);
|
updateDefaultDevice(newDefaultDevice);
|
||||||
setDefaultDevice(WIRELESS, newDefaultDevice);
|
setDefaultDevice(WIRELESS, newDefaultDevice);
|
||||||
|
@ -419,8 +435,48 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
||||||
{
|
{
|
||||||
qDebug()<< "Activated wlan changed, uuid = " << uuid << "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__;
|
qDebug()<< "Activated wlan changed, uuid = " << uuid << "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__;
|
||||||
|
|
||||||
QString ssid,devName;
|
//wlanpage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||||
|
QString devName,ssid;
|
||||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(NetworkManager::ActiveConnection::State::Activated == state){
|
||||||
|
wlanIsConnected = true;
|
||||||
|
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||||
|
} else {
|
||||||
|
wlanIsConnected = false;
|
||||||
|
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//弹窗显示wifi连接状况
|
||||||
|
qDebug() << "[WlanPage] State changed to :" << state << reason << Q_FUNC_INFO <<__LINE__;
|
||||||
|
//QString ssid;
|
||||||
|
m_resource->getSsidByUuid(uuid, ssid, m_defaultDevice);
|
||||||
|
if (m_activatedWlanSSid == ssid && state == NetworkManager::ActiveConnection::State::Activated) {
|
||||||
|
if(m_activedssid != m_activatedWlanSSid){
|
||||||
|
m_activedssid = m_activatedWlanSSid;
|
||||||
|
qDebug() << "[WlanPage] State changed to :" << state << ssid << reason << Q_FUNC_INFO <<__LINE__;
|
||||||
|
this->showDesktopNotify(tr("WLAN Connected Successfully"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == NetworkManager::ActiveConnection::State::Deactivating){
|
||||||
|
m_disconnectuuid = uuid;
|
||||||
|
m_disconnectingflag = true;
|
||||||
|
}
|
||||||
|
if (state == NetworkManager::ActiveConnection::State::Deactivated && m_disconnectuuid == uuid){
|
||||||
|
if(m_disconnectingflag){
|
||||||
|
m_disconnectingflag = false;
|
||||||
|
this->showDesktopNotify(tr("WLAN Disconnected Successfully"));
|
||||||
|
qDebug() << "clear the activessid" << Q_FUNC_INFO <<__LINE__;
|
||||||
|
m_activedssid = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//QString ssid,devName;
|
||||||
|
//NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
|
||||||
if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) {
|
if(m_apConnectResource->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
|
||||||
|
@ -469,6 +525,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
||||||
m_activatedNetListWidget->clear();
|
m_activatedNetListWidget->clear();
|
||||||
int height = 0;
|
int height = 0;
|
||||||
appendActiveWlan(uuid, height);
|
appendActiveWlan(uuid, height);
|
||||||
|
// emit this->wlanConnectChanged();
|
||||||
onWlanRemoved(m_defaultDevice, ssid);
|
onWlanRemoved(m_defaultDevice, ssid);
|
||||||
// this->showDesktopNotify(tr("Connect WLAN succeed"));
|
// this->showDesktopNotify(tr("Connect WLAN succeed"));
|
||||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) {
|
} else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) {
|
||||||
|
@ -525,12 +582,20 @@ void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo,
|
||||||
void WlanPage::onWlanSwitchClicked()
|
void WlanPage::onWlanSwitchClicked()
|
||||||
{
|
{
|
||||||
qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
qDebug() << "On wlan switch button clicked! old state = " << !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
||||||
m_wirelessConnectOpreation->setWirelessEnabled(m_netSwitch->getSwitchStatus());
|
//应该先检测是否有无线网卡可用,才改变开关状态
|
||||||
|
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(m_netSwitch->getSwitchStatus());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanPage::onWlanSwitchStatusChanged(const bool &checked)
|
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__;
|
qDebug() << "On wlan switch status changed! new state = " << m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
||||||
onWlanUpdated();
|
onWlanUpdated();
|
||||||
}
|
}
|
||||||
|
@ -553,6 +618,7 @@ void WlanPage::requestScan()
|
||||||
{
|
{
|
||||||
if (!m_wirelessConnectOpreation) {
|
if (!m_wirelessConnectOpreation) {
|
||||||
qWarning() << "Scan failed! m_wirelessConnectOpreation is nullptr!" << Q_FUNC_INFO << __LINE__;
|
qWarning() << "Scan failed! m_wirelessConnectOpreation is nullptr!" << Q_FUNC_INFO << __LINE__;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
m_wirelessConnectOpreation->requestWirelessScan();
|
m_wirelessConnectOpreation->requestWirelessScan();
|
||||||
}
|
}
|
||||||
|
@ -564,6 +630,29 @@ void WlanPage::onHiddenWlanClicked()
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WlanPage::showControlCenter()
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("ukui-control-center --wlanconnect");
|
||||||
|
}
|
||||||
|
void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
||||||
|
{
|
||||||
|
//监听外部命令导致wifi状态变化,更新界面
|
||||||
|
//应该先检测是否有无线网卡可用,才改变开关状态
|
||||||
|
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
|
||||||
|
if (m_devList.isEmpty()) {
|
||||||
|
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(m_netSwitch->getSwitchStatus() == isWifiOn){
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
//m_wirelessConnectOpreation->setWirelessEnabled(isWifiOn);
|
||||||
|
m_netSwitch->setSwitchStatus(isWifiOn);
|
||||||
|
//外部命令导致连接状态发生变化,通知主界面刷新图标
|
||||||
|
emit this->wlanConnectChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//for dbus
|
//for dbus
|
||||||
void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
|
void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
|
||||||
|
@ -714,6 +803,7 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
||||||
m_scanTimer->stop();
|
m_scanTimer->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanPage::showDetailPage(QString devName, QString ssid)
|
void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||||
{
|
{
|
||||||
KyWirelessNetItem data;
|
KyWirelessNetItem data;
|
||||||
|
@ -724,8 +814,13 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||||
|
|
||||||
QMap<QString,QStringList> actMap;
|
QMap<QString,QStringList> actMap;
|
||||||
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
||||||
|
if (!actMap.contains(devName)) {
|
||||||
|
qDebug()<<"[WlanPage] " << devName << " is missing when showDetailPage";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool isActive = actMap[devName].contains(ssid);
|
bool isActive = actMap[devName].contains(ssid);
|
||||||
NetDetail *netDetail = new NetDetail(devName, ssid, data.m_connectUuid, isActive, true, false, this);
|
NetDetail *netDetail = new NetDetail(devName, ssid, data.m_connectUuid, isActive, true, false, this);
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#include "kylinconnectoperation.h"
|
#include "kylinconnectoperation.h"
|
||||||
#include <QGSettings>
|
#include <QGSettings>
|
||||||
#include "netdetails/netdetail.h"
|
#include "netdetails/netdetail.h"
|
||||||
|
#include <QProcess>
|
||||||
|
#include "kylinactiveconnectresource.h"
|
||||||
|
#include "kywirelessnetresource.h"
|
||||||
|
|
||||||
//#define SCROLLAREA_HEIGHT 150
|
//#define SCROLLAREA_HEIGHT 150
|
||||||
#define MORE_TEXT_MARGINS 16,0,0,0
|
#define MORE_TEXT_MARGINS 16,0,0,0
|
||||||
|
@ -21,6 +24,7 @@ class WlanPage : public TabPage
|
||||||
public:
|
public:
|
||||||
explicit WlanPage(QWidget *parent = nullptr);
|
explicit WlanPage(QWidget *parent = nullptr);
|
||||||
~WlanPage() = default;
|
~WlanPage() = default;
|
||||||
|
bool wlanIsConnected = false;
|
||||||
|
|
||||||
//for dbus
|
//for dbus
|
||||||
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
|
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
|
||||||
|
@ -44,6 +48,8 @@ signals:
|
||||||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||||
void hiddenWlanClicked();
|
void hiddenWlanClicked();
|
||||||
|
void settingsClicked();
|
||||||
|
void wlanConnectChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onMainWindowVisibleChanged(const bool &visible);
|
void onMainWindowVisibleChanged(const bool &visible);
|
||||||
|
@ -54,6 +60,10 @@ protected:
|
||||||
private:
|
private:
|
||||||
void initWlanUI();
|
void initWlanUI();
|
||||||
void initConnections();
|
void initConnections();
|
||||||
|
QString m_activedssid;
|
||||||
|
QString m_disconnectuuid;
|
||||||
|
int m_disconnecting;
|
||||||
|
bool m_disconnectingflag = false;
|
||||||
|
|
||||||
//定时触发扫描的定时器
|
//定时触发扫描的定时器
|
||||||
void initTimer();
|
void initTimer();
|
||||||
|
@ -106,6 +116,8 @@ private slots:
|
||||||
void onDeviceComboxIndexChanged(int currentIndex);
|
void onDeviceComboxIndexChanged(int currentIndex);
|
||||||
void requestScan();
|
void requestScan();
|
||||||
void onHiddenWlanClicked();
|
void onHiddenWlanClicked();
|
||||||
|
void showControlCenter();
|
||||||
|
void onWifiEnabledChanged(bool isWifiOn);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WLANPAGE_H
|
#endif // WLANPAGE_H
|
||||||
|
|
Loading…
Reference in New Issue