Merge branch 'dbus-interface' into '0908'
# Conflicts: # src/backend/dbus-interface/kylinnetworkresourcemanager.cpp # src/frontend/tools/radioitembutton.cpp
This commit is contained in:
commit
e3ed056f6e
|
@ -548,8 +548,10 @@ void KyNetworkResourceManager::onActiveConnectionChanged(
|
|||
NetworkManager::ActiveConnection * activeConnect =
|
||||
qobject_cast<NetworkManager::ActiveConnection *>(sender());
|
||||
if (activeConnect->isValid()) {
|
||||
// qDebug()<<"!New state change activate connect"<<activeConnect->uuid();
|
||||
// qDebug()<<"!New the active connect state"<<state;
|
||||
qDebug()<<"!New state change activate connect"<<activeConnect->uuid();
|
||||
qDebug()<<"!New the active connect state"<<state;
|
||||
emit activeConnectStateChangeReason(activeConnect->uuid(), state,
|
||||
NetworkManager::ActiveConnection::Reason::UknownReason);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
|
|
@ -97,6 +97,11 @@ void LanListItem::refreshIcon()
|
|||
}
|
||||
}
|
||||
|
||||
void LanListItem::onRightButtonClicked()
|
||||
{
|
||||
//右键点击事件
|
||||
}
|
||||
|
||||
void LanListItem::onInfoButtonClicked()
|
||||
{
|
||||
if(m_data){
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
void onRightButtonClicked();
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,7 +13,7 @@ ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
|||
{
|
||||
initUI();
|
||||
initConnection();
|
||||
m_itemFrame->installEventFilter(this);
|
||||
// m_itemFrame->installEventFilter(this);
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
|
@ -37,16 +37,44 @@ void ListItem::setActive(const bool &isActive)
|
|||
m_isActive = isActive;
|
||||
}
|
||||
|
||||
bool ListItem::eventFilter(QObject *watched, QEvent *event)
|
||||
void ListItem::showDesktopNotify(const QString &message)
|
||||
{
|
||||
if (watched == m_itemFrame) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
onNetButtonClicked();
|
||||
}
|
||||
}
|
||||
return QFrame::eventFilter(watched, event);
|
||||
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 ListItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
onNetButtonClicked();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
onRightButtonClicked();
|
||||
}
|
||||
return QFrame::mousePressEvent(event);
|
||||
}
|
||||
|
||||
//bool ListItem::eventFilter(QObject *watched, QEvent *event)
|
||||
//{
|
||||
// if (watched == m_itemFrame) {
|
||||
// if (event->type() == QEvent::MouseButtonPress) {
|
||||
// onNetButtonClicked();
|
||||
// }
|
||||
// }
|
||||
// return QFrame::eventFilter(watched, event);
|
||||
//}
|
||||
|
||||
void ListItem::initUI()
|
||||
{
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include "radioitembutton.h"
|
||||
#include "infobutton.h"
|
||||
#include "netdetails/netdetail.h"
|
||||
|
@ -16,9 +17,12 @@ public:
|
|||
~ListItem();
|
||||
void setName(const QString &name);
|
||||
void setActive(const bool &isActive);
|
||||
static void showDesktopNotify(const QString &message);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
// bool eventFilter(QObject *watched, QEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
virtual void onRightButtonClicked() = 0;
|
||||
|
||||
protected:
|
||||
QFrame * m_itemFrame = nullptr;
|
||||
|
|
|
@ -7,9 +7,13 @@ WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *d
|
|||
m_resource = resource;
|
||||
m_wlanDevice = device;
|
||||
m_connoperation = new KyWirelessConnectOperation(this);
|
||||
m_connectResource = new KyActiveConnectResourse();
|
||||
initWlanUI();
|
||||
setExpanded(false);
|
||||
initWlanConnection();
|
||||
|
||||
m_menu = new QMenu();//右键菜单
|
||||
connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered);
|
||||
}
|
||||
|
||||
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
|
||||
|
@ -67,6 +71,23 @@ void WlanListItem::resizeEvent(QResizeEvent *event)
|
|||
return ListItem::resizeEvent(event);
|
||||
}
|
||||
|
||||
void WlanListItem::onRightButtonClicked()
|
||||
{
|
||||
m_menu->clear();
|
||||
if (!this->m_data) {
|
||||
return;
|
||||
}
|
||||
if (this->m_isActive) {
|
||||
m_menu->addAction(new QAction(tr("Disconnect"), this));
|
||||
} else {
|
||||
m_menu->addAction(new QAction(tr("Connect"), this));
|
||||
}
|
||||
if (m_data->m_isConfigured)
|
||||
m_menu->addAction(new QAction(tr("Forget"), this));
|
||||
m_menu->move(cursor().pos());
|
||||
m_menu->show();
|
||||
}
|
||||
|
||||
void WlanListItem::initWlanUI()
|
||||
{
|
||||
m_hasPwd = (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") ? false : true;
|
||||
|
@ -137,6 +158,7 @@ void WlanListItem::initWlanConnection()
|
|||
connect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd);
|
||||
connect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove);
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
|
||||
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanListItem::onWlanStatusChange);
|
||||
}
|
||||
|
||||
void WlanListItem::refreshIcon()
|
||||
|
@ -222,7 +244,6 @@ void WlanListItem::onNetButtonClicked()
|
|||
|
||||
if (m_data->m_isConfigured) {
|
||||
m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid);
|
||||
// m_netButton->startLoading();
|
||||
qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
|
@ -337,3 +358,55 @@ void WlanListItem::onConnectionRemove(QString deviceName, QString ssid)
|
|||
}
|
||||
}
|
||||
|
||||
void WlanListItem::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
QString ssid;
|
||||
m_resource->getSsidByUuid(uuid,ssid);
|
||||
if (m_data->m_NetSsid == ssid) {
|
||||
qDebug() << "[WlanPage] State changed to :" << state << Q_FUNC_INFO <<__LINE__;
|
||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
m_netButton->startLoading();
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (action->text() == tr("Disconnect") || action->text() == tr("Connect")) {
|
||||
this->onNetButtonClicked();
|
||||
} else if (action->text() == tr("Forget")) {
|
||||
m_connoperation->deleteWirelessConnect(m_data->m_connectUuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include "wlanpage.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include <QCheckBox>
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
||||
|
||||
|
@ -29,6 +32,7 @@ public:
|
|||
void setExpanded(const bool &expanded);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void onRightButtonClicked();
|
||||
|
||||
signals:
|
||||
void itemHeightChanged(const QString &ssid);
|
||||
|
@ -43,6 +47,7 @@ private:
|
|||
KyWirelessNetResource *m_resource = nullptr;
|
||||
KyWirelessNetItem *m_data = nullptr;
|
||||
KyWirelessConnectOperation *m_connoperation = nullptr;
|
||||
KyActiveConnectResourse *m_connectResource = nullptr;
|
||||
bool m_hasPwd = true;
|
||||
QString m_wlanDevice;
|
||||
|
||||
|
@ -62,6 +67,10 @@ private:
|
|||
QCheckBox *m_autoConnectCheckBox = nullptr;
|
||||
QLabel *m_autoConnectLabel = nullptr;
|
||||
|
||||
QMenu *m_menu = nullptr;
|
||||
|
||||
NetworkManager::ActiveConnection::State m_state;
|
||||
|
||||
// QVBoxLayout * m_mainLayout = nullptr;
|
||||
// QFrame * m_itemFrame = nullptr;
|
||||
// QHBoxLayout * m_hItemLayout = nullptr;
|
||||
|
@ -79,6 +88,10 @@ private slots:
|
|||
void onConnectButtonClicked();
|
||||
void onConnectionAdd(QString deviceName, QString ssid);
|
||||
void onConnectionRemove(QString deviceName, QString ssid);
|
||||
void onWlanStatusChange(QString uuid,
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason);
|
||||
void onMenuTriggered(QAction *action);
|
||||
};
|
||||
|
||||
#endif // WLANLISTITEM_H
|
||||
|
|
|
@ -30,6 +30,7 @@ void MainWindow::showMainwindow()
|
|||
this->showNormal();
|
||||
this->raise();
|
||||
this->activateWindow();
|
||||
emit this->mainWindowVisibleChanged(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +39,7 @@ void MainWindow::showMainwindow()
|
|||
void MainWindow::hideMainwindow()
|
||||
{
|
||||
this->hide();
|
||||
emit this->mainWindowVisibleChanged(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,6 +113,7 @@ void MainWindow::initUI()
|
|||
m_centralWidget->tabBar()->setFixedWidth(this->width());
|
||||
m_lanWidget = new LanPage(m_centralWidget);
|
||||
m_wlanWidget = new WlanPage(m_centralWidget);
|
||||
connect(this, &MainWindow::mainWindowVisibleChanged, m_wlanWidget, &WlanPage::onMainWindowVisibleChanged);
|
||||
m_centralWidget->addTab(m_lanWidget, QIcon::fromTheme("network-wired-connected-symbolic", QIcon::fromTheme("network-wired-symbolic", QIcon(":/res/l/network-online.svg"))), tr("LAN"));
|
||||
m_centralWidget->addTab(m_wlanWidget, QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/x/wifi-list-bg.svg")), tr("WLAN"));
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ signals:
|
|||
//热点断开
|
||||
void hotspotDeactivated(QString devName, QString ssid);
|
||||
void hotspotActivated(QString devName, QString ssid);
|
||||
void mainWindowVisibleChanged(const bool &visible);
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "tabpage.h"
|
||||
#include <qsettings.h>
|
||||
#include <QDBusInterface>
|
||||
|
||||
TabPage::TabPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -34,10 +35,11 @@ void TabPage::initUI()
|
|||
//临时增加的下拉框选择网卡区域
|
||||
m_deviceFrame = new QFrame(this);
|
||||
m_deviceLayout = new QHBoxLayout(m_deviceFrame);
|
||||
m_deviceLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||
m_deviceLayout->setContentsMargins(DEVICE_LAYOUT_MARGINS);
|
||||
m_deviceFrame->setLayout(m_deviceLayout);
|
||||
m_deviceLabel = new QLabel(m_deviceFrame);
|
||||
m_deviceComboBox = new QComboBox(m_deviceFrame);
|
||||
m_deviceComboBox->setFixedWidth(DEVICE_COMBOBOX_WIDTH);
|
||||
m_deviceLabel->setText(tr("Current Device"));
|
||||
m_deviceLayout->addWidget(m_deviceLabel);
|
||||
m_deviceLayout->addStretch();
|
||||
|
@ -45,6 +47,7 @@ void TabPage::initUI()
|
|||
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TabPage::onDeviceComboxIndexChanged);
|
||||
|
||||
m_activatedNetFrame = new QFrame(this);
|
||||
m_activatedNetFrame->setMaximumHeight(ACTIVE_AREA_MAX_HEIGHT);
|
||||
m_activatedNetLayout = new QVBoxLayout(m_activatedNetFrame);
|
||||
m_activatedNetLayout->setContentsMargins(ACTIVE_NET_LAYOUT_MARGINS);
|
||||
m_activatedNetLayout->setSpacing(NET_LAYOUT_SPACING);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define TITLE_FRAME_HEIGHT 52
|
||||
#define TITLE_LAYOUT_MARGINS 24,0,24,0
|
||||
#define DEVICE_LAYOUT_MARGINS 24,0,24,8
|
||||
#define DEVICE_COMBOBOX_WIDTH 150
|
||||
#define ACTIVE_NET_LAYOUT_MARGINS 8,8,8,8
|
||||
#define NET_LAYOUT_MARGINS 8,8,0,8
|
||||
#define NET_LAYOUT_SPACING 8
|
||||
|
@ -24,7 +26,8 @@
|
|||
//#define SCROLL_AREA_HEIGHT 200
|
||||
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
|
||||
#define TRANSPARENT_COLOR QColor(0,0,0,0)
|
||||
#define INACTIVE_AREA_MIN_HEIGHT 200
|
||||
#define INACTIVE_AREA_MIN_HEIGHT 150
|
||||
#define ACTIVE_AREA_MAX_HEIGHT 100
|
||||
|
||||
enum KyDeviceType
|
||||
{
|
||||
|
|
|
@ -13,13 +13,14 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
|||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
m_netDeviceResource=new KyNetworkDeviceResourse(this);
|
||||
m_apConnectResource = new KyConnectResourse(this);
|
||||
devList.empty();
|
||||
m_devList.empty();
|
||||
initDevice();
|
||||
m_wirelessConnectOpreation = new KyWirelessConnectOperation(this);
|
||||
m_connectoperation = new KyConnectOperation(this);
|
||||
initWlanUI();
|
||||
initDeviceCombox();
|
||||
//要在initUI之后调用,保证UI的信号槽顺利绑定
|
||||
initConnections();
|
||||
initTimer();
|
||||
getActiveWlan();
|
||||
getAllWlan();
|
||||
|
||||
|
@ -30,6 +31,8 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
|||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::activateConnectionError, this, &WlanPage::activateFailed);
|
||||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::addAndActivateConnectionError, this, &WlanPage::activateFailed);
|
||||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed);
|
||||
|
||||
connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked);
|
||||
}
|
||||
|
||||
//QString WlanPage::getSsidFromUuid(const QString &uuid)
|
||||
|
@ -42,6 +45,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
|||
if (e->type() == QEvent::MouseButtonPress) {
|
||||
if (w == m_hiddenWlanLabel) {
|
||||
//ZJP_TODO 打开隐藏WiFi添加弹窗
|
||||
emit this->hiddenWlanClicked();
|
||||
} else if (w == m_settingsLabel) {
|
||||
//ZJP_TODO 打开控制面板
|
||||
}
|
||||
|
@ -77,6 +81,7 @@ void WlanPage::initWlanUI()
|
|||
m_hiddenWlanLabel = new QLabel(m_hiddenWlanWidget);
|
||||
m_hiddenWlanLabel->setText(tr("More..."));
|
||||
m_hiddenWlanLabel->setContentsMargins(MORE_TEXT_MARGINS);
|
||||
m_hiddenWlanLabel->installEventFilter(this);
|
||||
m_hiddenWlanLayout->addWidget(m_hiddenWlanLabel);
|
||||
m_hiddenWlanLayout->addStretch();
|
||||
|
||||
|
@ -105,6 +110,10 @@ void WlanPage::initConnections()
|
|||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate);
|
||||
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
||||
// connect(m_connectoperation, &KyConnectOperation::activateConnectionError, this, &WlanPage::showDesktopNotify);
|
||||
// connect(m_connectoperation, &KyConnectOperation::createConnectionError, this, &WlanPage::showDesktopNotify);
|
||||
// connect(m_connectoperation, &KyConnectOperation::deactivateConnectionError, this, &WlanPage::showDesktopNotify);
|
||||
// connect(m_connectoperation, &KyConnectOperation::deleteConnectionError, this, &WlanPage::showDesktopNotify);
|
||||
connect(m_netSwitch, &SwitchButton::clicked, this, &WlanPage::onWlanSwitchClicked);
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||
|
@ -122,6 +131,13 @@ void WlanPage::initConnections()
|
|||
m_netSwitch->setSwitchStatus(m_wirelessConnectOpreation->getWirelessEnabled());
|
||||
}
|
||||
|
||||
void WlanPage::initTimer()
|
||||
{
|
||||
m_scanTimer = new QTimer(this);
|
||||
connect(m_scanTimer, &QTimer::timeout, this, &WlanPage::requestScan);
|
||||
// m_scanTimer->start(10 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WlanPage::initDevice 初始化默认网卡
|
||||
*/
|
||||
|
@ -131,11 +147,11 @@ void WlanPage::initDevice()
|
|||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, devList);
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wireless card is null";
|
||||
if (!devList.isEmpty()) {
|
||||
deviceName = devList.at(0);
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
}
|
||||
|
@ -145,12 +161,21 @@ void WlanPage::initDevice()
|
|||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
//获取完m_devList后调用,减少重复获取
|
||||
initDeviceCombox();
|
||||
}
|
||||
|
||||
void WlanPage::initDeviceCombox()
|
||||
{
|
||||
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框
|
||||
if (m_devList.length() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
foreach (QString device, m_devList) {
|
||||
m_deviceComboBox->addItem(device, device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,6 +183,9 @@ void WlanPage::initDeviceCombox()
|
|||
*/
|
||||
void WlanPage::getActiveWlan()
|
||||
{
|
||||
if (!m_activatedNetListWidget) {
|
||||
return;
|
||||
}
|
||||
QMap<QString,QStringList> actMap;
|
||||
m_activatedNetListWidget->clear();
|
||||
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
||||
|
@ -211,6 +239,9 @@ void WlanPage::appendActiveWlan(const QString &ssid, int &height)
|
|||
*/
|
||||
void WlanPage::getAllWlan()
|
||||
{
|
||||
if (!m_inactivatedNetListWidget) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "Started loading wlan list! time=" << QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
|
||||
m_inactivatedNetListWidget->clear();
|
||||
m_itemsMap.clear();
|
||||
|
@ -290,13 +321,22 @@ void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devi
|
|||
if (deviceType != NetworkManager::Device::Type::Wifi) {
|
||||
return;
|
||||
}
|
||||
devList << deviceName;
|
||||
m_devList << deviceName;
|
||||
if (getDefaultDevice().isEmpty())
|
||||
{
|
||||
updateDefaultDevice(deviceName);
|
||||
setDefaultDevice(WIRELESS, deviceName);
|
||||
|
||||
}
|
||||
|
||||
//往下拉框添加新的网卡
|
||||
if (m_deviceComboBox->findData(deviceName) == -1) {
|
||||
if (m_devList.length() > 1 && !m_deviceFrame->isVisible()) {
|
||||
m_deviceFrame->show();
|
||||
}
|
||||
m_deviceComboBox->addItem(deviceName, deviceName);
|
||||
}
|
||||
|
||||
emit deviceStatusChanged();
|
||||
}
|
||||
|
||||
|
@ -315,10 +355,20 @@ void WlanPage::onDeviceRemove(QString deviceName)
|
|||
updateDefaultDevice(newDefaultDevice);
|
||||
setDefaultDevice(WIRELESS, newDefaultDevice);
|
||||
}
|
||||
if (devList.contains(deviceName)) {
|
||||
devList.removeOne(deviceName);
|
||||
|
||||
if (m_devList.contains(deviceName)) {
|
||||
m_devList.removeOne(deviceName);
|
||||
emit deviceStatusChanged();
|
||||
}
|
||||
|
||||
//从下拉框删除已消失的网卡
|
||||
if (m_deviceComboBox->findData(deviceName) != -1) {
|
||||
if (m_devList.length() <= 1 && m_deviceFrame->isVisible()) {
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
m_deviceComboBox->removeItem(m_deviceComboBox->findData(deviceName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WlanPage::onDeviceNameUpdate(QString oldName, QString newName)
|
||||
|
@ -328,12 +378,17 @@ void WlanPage::onDeviceNameUpdate(QString oldName, QString newName)
|
|||
setDefaultDevice(WIRELESS, newName);
|
||||
}
|
||||
|
||||
if (devList.contains(oldName)) {
|
||||
devList.removeOne(oldName);
|
||||
devList.append(newName);
|
||||
if (m_devList.contains(oldName)) {
|
||||
m_devList.removeOne(oldName);
|
||||
m_devList.append(newName);
|
||||
qDebug() << "WlanPage emit deviceNameUpdate " << oldName << newName;
|
||||
emit deviceNameChanged(oldName, newName);
|
||||
}
|
||||
|
||||
if (m_deviceComboBox->findData(oldName) != -1) {
|
||||
m_deviceComboBox->removeItem(m_deviceComboBox->findData(oldName));
|
||||
m_deviceComboBox->addItem(newName, newName);
|
||||
}
|
||||
}
|
||||
|
||||
void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
||||
|
@ -399,6 +454,10 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
int height = 0;
|
||||
appendActiveWlan(ssid, height);
|
||||
onWlanRemoved(defaultDevice, ssid);
|
||||
// this->showDesktopNotify(tr("Connect WLAN succeed"));
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
onWlanUpdated();
|
||||
// this->showDesktopNotify(tr("Disconnect WLAN succeed"));
|
||||
} else {
|
||||
onWlanUpdated();
|
||||
}
|
||||
|
@ -449,7 +508,31 @@ void WlanPage::onWlanSwitchStatusChanged(const bool &checked)
|
|||
|
||||
void WlanPage::onDeviceComboxIndexChanged(int currentIndex)
|
||||
{
|
||||
if (!m_deviceComboBox || currentIndex < 0) {
|
||||
return;
|
||||
}
|
||||
//TODO 设备变更时更新设备和列表
|
||||
QString currentDevice = m_deviceComboBox->itemText(currentIndex);
|
||||
qDebug() << "Current device changed! device = " << currentDevice << Q_FUNC_INFO << __LINE__;
|
||||
defaultDevice = currentDevice;
|
||||
getActiveWlan();
|
||||
getAllWlan();
|
||||
}
|
||||
|
||||
//申请触发扫描,初始化执行&定时执行
|
||||
void WlanPage::requestScan()
|
||||
{
|
||||
if (!m_wirelessConnectOpreation) {
|
||||
qWarning() << "Scan failed! m_wirelessConnectOpreation is nullptr!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
m_wirelessConnectOpreation->requestWirelessScan();
|
||||
}
|
||||
|
||||
void WlanPage::onHiddenWlanClicked()
|
||||
{
|
||||
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
|
||||
NetDetail *netDetail = new NetDetail("", "", false, true, false);
|
||||
netDetail->show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -552,3 +635,23 @@ void WlanPage::deactivateWireless(const QString& devName, const QString& ssid)
|
|||
{
|
||||
//todo
|
||||
}
|
||||
|
||||
void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
||||
{
|
||||
qDebug() << "Received signal of mainwindow visible changed. cur_state = " << visible << Q_FUNC_INFO << __LINE__;
|
||||
if (visible) {
|
||||
//打开页面时先触发一次扫描
|
||||
requestScan();
|
||||
}
|
||||
|
||||
if (!m_scanTimer) {
|
||||
qWarning() << "No QTimer!" << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
//若页面打开,开始扫描倒计时,若关闭,停止扫描倒计时
|
||||
if (visible) {
|
||||
m_scanTimer->start(10 * 1000);
|
||||
} else {
|
||||
m_scanTimer->stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "wlanlistitem.h"
|
||||
#include "kylinconnectoperation.h"
|
||||
#include <QGSettings>
|
||||
#include "netdetails/netdetail.h"
|
||||
|
||||
//#define SCROLLAREA_HEIGHT 150
|
||||
#define MORE_TEXT_MARGINS 16,0,0,0
|
||||
|
@ -30,11 +32,16 @@ public:
|
|||
void getStoredApInfo(QStringList &list);
|
||||
void activateWireless(const QString& devName, const QString& ssid);
|
||||
void deactivateWireless(const QString& devName, const QString& ssid);
|
||||
|
||||
signals:
|
||||
void oneItemExpanded(const QString &ssid);
|
||||
void wirelessActivating(QString devName, QString ssid);
|
||||
void hotspotDeactivated(QString devName, QString ssid);
|
||||
void hotspotActivated(QString devName, QString ssid);
|
||||
void hiddenWlanClicked();
|
||||
|
||||
public slots:
|
||||
void onMainWindowVisibleChanged(const bool &visible);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
@ -43,6 +50,10 @@ private:
|
|||
void initWlanUI();
|
||||
void initConnections();
|
||||
|
||||
//定时触发扫描的定时器
|
||||
void initTimer();
|
||||
QTimer * m_scanTimer = nullptr;
|
||||
|
||||
void initDevice();//初始化默认设备
|
||||
void initDeviceCombox();
|
||||
|
||||
|
@ -59,13 +70,14 @@ private:
|
|||
QLabel * m_hiddenWlanLabel = nullptr;
|
||||
|
||||
QString m_activatedWlanSSid;
|
||||
QStringList devList;
|
||||
QStringList m_devList;
|
||||
|
||||
KyWirelessNetResource *m_resource = nullptr;
|
||||
KyActiveConnectResourse *m_connectResource = nullptr;
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||
KyWirelessConnectOperation * m_wirelessConnectOpreation = nullptr;
|
||||
KyConnectOperation *m_connectoperation = nullptr;
|
||||
KyConnectResourse * m_apConnectResource = nullptr;
|
||||
QGSettings *m_switchGsettings = nullptr;
|
||||
|
||||
|
@ -86,6 +98,8 @@ private slots:
|
|||
void onWlanSwitchClicked();
|
||||
void onWlanSwitchStatusChanged(const bool &checked);
|
||||
void onDeviceComboxIndexChanged(int currentIndex);
|
||||
void requestScan();
|
||||
void onHiddenWlanClicked();
|
||||
};
|
||||
|
||||
#endif // WLANPAGE_H
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "radioitembutton.h"
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#define FRAMESPEED 100
|
||||
#define ALLTIME 10000
|
||||
#define FLASH_SPEED 100
|
||||
#define TIMEOUT_TIMER 90*1000
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
#define BACKGROUND_COLOR QColor(0,0,0,0)
|
||||
|
@ -13,8 +13,6 @@
|
|||
|
||||
RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
connect(this, &RadioItemButton::requestStartLoading, this, &RadioItemButton::onLoadingStarted);
|
||||
connect(this, &RadioItemButton::requestStopLoading, this, &RadioItemButton::onLoadingStopped);
|
||||
this->setAutoFillBackground(false);
|
||||
m_iconLabel = new QLabel(this);
|
||||
|
||||
|
@ -27,8 +25,6 @@ RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
|||
|
||||
setActive(false);
|
||||
//JXJ_TODO loading动画
|
||||
switchTimer = new QTimer(this);
|
||||
connect(switchTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStarted);
|
||||
connect(this, &RadioItemButton::requestStartLoading, this, &RadioItemButton::onLoadingStarted);
|
||||
connect(this , &RadioItemButton::requestStopLoading, this, &RadioItemButton::onLoadingStopped);
|
||||
}
|
||||
|
@ -48,7 +44,6 @@ void RadioItemButton::setButtonIcon(const QIcon &icon)
|
|||
if (icon.isNull()) {
|
||||
return;
|
||||
}
|
||||
//ZJP_TODO 绘制圆形按钮
|
||||
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
|
||||
}
|
||||
|
||||
|
@ -59,33 +54,50 @@ void RadioItemButton::setActive(const bool &isActive)
|
|||
}
|
||||
void RadioItemButton::onLoadingStarted()
|
||||
{
|
||||
//ZJP_TODO 开始播放转圈动画
|
||||
switchTimer->start(FRAMESPEED);
|
||||
QString qpmQss = ":/res/s/conning-s/";
|
||||
qpmQss.append(QString::number(this->currentPage));
|
||||
qpmQss.append(".png");
|
||||
m_iconLabel->setPixmap(QPixmap(qpmQss));
|
||||
// m_iconLabel->setProperty("useIconHighlightEffect",true);
|
||||
// m_iconLabel->setProperty("iconHighlightEffectMode",true);
|
||||
|
||||
this->currentPage --;
|
||||
|
||||
if (this->currentPage < 1) {
|
||||
this->currentPage = 10; //循环播放
|
||||
}
|
||||
this->countCurrentTime += FRAMESPEED;
|
||||
//达到一定的时间退出。应该是收到连接成功或者失败的信号断开
|
||||
if (this->countCurrentTime >= ALLTIME) {
|
||||
countCurrentTime=0;
|
||||
emit this->onLoadingStopped();
|
||||
}
|
||||
if (!m_loadingTimer) {
|
||||
m_loadingTimer = new QTimer();
|
||||
connect(m_loadingTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingTimerTimeout);
|
||||
}
|
||||
if (!m_timeoutTimer) {
|
||||
m_timeoutTimer = new QTimer();
|
||||
connect(m_timeoutTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStopped);
|
||||
}
|
||||
if (m_loadingTimer->isActive()) {
|
||||
return;
|
||||
}
|
||||
m_loadingTimer->start(FLASH_SPEED);
|
||||
m_timeoutTimer->stop();
|
||||
m_timeoutTimer->start(TIMEOUT_TIMER);
|
||||
}
|
||||
|
||||
void RadioItemButton::onLoadingStopped()
|
||||
{
|
||||
//ZJP_TODO 停止播放转圈动画
|
||||
this->switchTimer->stop();
|
||||
// this->m_iconLabel->hide();
|
||||
if (this->m_loadingTimer) {
|
||||
this->m_loadingTimer->stop();
|
||||
} else {
|
||||
qWarning() << "Stop loading failed, m_loadingTimer is nullptr." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
if (this->m_timeoutTimer) {
|
||||
this->m_timeoutTimer->stop();
|
||||
} else {
|
||||
qWarning() << "Stop timeout_timer failed, m_timeoutTimer is nullptr." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
void RadioItemButton::onLoadingTimerTimeout()
|
||||
{
|
||||
QString qpmQss = ":/res/s/conning-a/";
|
||||
qpmQss.append(QString::number(this->currentPage));
|
||||
qpmQss.append(".png");
|
||||
qDebug()<<qpmQss;
|
||||
m_iconLabel->setPixmap(QPixmap(qpmQss));
|
||||
|
||||
this->currentPage --;
|
||||
|
||||
if (this->currentPage < 1) {
|
||||
this->currentPage = 8; //循环播放
|
||||
}
|
||||
}
|
||||
|
||||
void RadioItemButton::paintEvent(QPaintEvent *event)
|
||||
|
|
|
@ -28,15 +28,16 @@ protected:
|
|||
private:
|
||||
bool m_isActivated = false;
|
||||
QLabel * m_iconLabel = nullptr;
|
||||
QTimer * switchTimer = nullptr;
|
||||
QTimer * m_loadingTimer = nullptr;
|
||||
QTimer * m_timeoutTimer = nullptr;
|
||||
QColor m_backgroundColor;
|
||||
|
||||
int currentPage;
|
||||
int countCurrentTime;
|
||||
int currentPage = 8;
|
||||
|
||||
private slots:
|
||||
void onLoadingStarted();
|
||||
void onLoadingStopped();
|
||||
void onLoadingTimerTimeout();
|
||||
};
|
||||
|
||||
#endif // NETBUTTON_H
|
||||
|
|
Loading…
Reference in New Issue