diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp index 9ee32391..6d160fdf 100644 --- a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp +++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp @@ -7,10 +7,20 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare // m_activeConnectUuidList.clear(); m_activeConnectUuidMap.clear(); + m_deviceMap.clear(); //TODO::get uuid from settings for system reboot; - connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, &KyNetworkDeviceResourse::deviceAdd); - connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove, this, &KyNetworkDeviceResourse::deviceRemove); + initDeviceMap(); + + connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, [=](QString deviceName, QString uni, NetworkManager::Device::Type deviceType) { + m_deviceMap.insert(uni,deviceName); + emit deviceAdd(deviceName, deviceType); + }); + connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove, this, [=](QString deviceName, QString uni) { + m_deviceMap.remove(uni); + emit deviceRemove(deviceName); + }); + connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceUpdate, this, &KyNetworkDeviceResourse::onDeviceUpdate); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChanage, this, &KyNetworkDeviceResourse::carrierChanage); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceBitRateChanage, this, &KyNetworkDeviceResourse::deviceBitRateChanage); @@ -23,6 +33,22 @@ KyNetworkDeviceResourse::~KyNetworkDeviceResourse() m_networkResourceInstance = nullptr; } +void KyNetworkDeviceResourse::initDeviceMap() +{ + NetworkManager::Device::List deviceList + = m_networkResourceInstance->getNetworkDeviceList(); + + if (deviceList.isEmpty()) {; + return; + } + + NetworkManager::Device::Ptr devicePtr = nullptr; + for (int index = 0; index < deviceList.size(); ++index) { + devicePtr = deviceList.at(index); + m_deviceMap.insert(devicePtr->uni(), devicePtr->interfaceName()); + } +} + void KyNetworkDeviceResourse::getNetworkDeviceList( NetworkManager::Device::Type deviceType, QStringList &networkDeviceList) @@ -213,3 +239,15 @@ void KyNetworkDeviceResourse::setDeviceAutoConnect() return; } +void KyNetworkDeviceResourse::onDeviceUpdate(NetworkManager::Device * dev) +{ + QString dbusPath = dev->uni(); + QString interface = dev->interfaceName(); + if (m_deviceMap.contains(dbusPath)) { + if (m_deviceMap[dbusPath] != interface) { + QString oldName = m_deviceMap[dbusPath]; + m_deviceMap[dbusPath] = interface; + emit deviceNameUpdate(oldName, interface); + } + } +} diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.h b/src/backend/dbus-interface/kylinnetworkdeviceresource.h index c20fb0cf..216bf9f7 100644 --- a/src/backend/dbus-interface/kylinnetworkdeviceresource.h +++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.h @@ -16,6 +16,7 @@ public: signals: void deviceAdd(QString deviceName, NetworkManager::Device::Type deviceType); void deviceUpdate(QString deviceName); + void deviceNameUpdate(QString oldName, QString newName); void deviceRemove(QString deviceName); void stateChange(QString deviceName, int state); @@ -23,6 +24,9 @@ signals: void deviceBitRateChanage(QString deviceName, int bitRate); void deviceMacAddressChanaged(QString deviceName, const QString &hwAddress); +public slots: + void onDeviceUpdate(NetworkManager::Device * dev); + public: void getNetworkDeviceList(NetworkManager::Device::Type deviceType, QStringList &networkDeviceList); void getHardwareInfo(QString ifaceName, QString &hardAddress, int &bandWith); @@ -37,6 +41,9 @@ private: KyWiredConnectOperation wiredOperation; KyNetworkResourceManager *m_networkResourceInstance = nullptr; QStringList m_activeConnectUuidList; - QMap m_activeConnectUuidMap; + QMap m_activeConnectUuidMap; + QMap m_deviceMap; + + void initDeviceMap(); }; #endif // KYLINNETORKDEVICERESOURCE_H diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index 150ed422..87bdbfeb 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -654,7 +654,7 @@ void KyNetworkResourceManager::onDeviceAdded(QString const & uni) if (0 > m_devices.indexOf(networkDevice)) { addDevice(networkDevice); - emit deviceAdd(networkDevice->interfaceName(), networkDevice->type()); + emit deviceAdd(networkDevice->interfaceName(), networkDevice->uni(), networkDevice->type()); } else { qWarning() << networkDevice->interfaceName() <<"the device is exist in network device list."; } @@ -676,7 +676,7 @@ void KyNetworkResourceManager::onDeviceRemoved(QString const & uni) if (m_devices.cend() != index) { const int pos = index - m_devices.cbegin(); removeDevice(pos); - emit deviceRemove(networkDevice->interfaceName()); + emit deviceRemove(networkDevice->interfaceName(), networkDevice->uni()); } return; diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h index de75bfb0..5204cef6 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h @@ -106,9 +106,9 @@ signals: void connectionUpdate(QString uuid); void connectionRemove(QString path); - void deviceAdd(QString deviceName, NetworkManager::Device::Type deviceType); + void deviceAdd(QString deviceName, QString uni, NetworkManager::Device::Type deviceType); void deviceUpdate(NetworkManager::Device * dev); - void deviceRemove(QString deviceName); + void deviceRemove(QString deviceName, QString uni); void deviceCarrierChanage(QString deviceName, bool pluged); void deviceBitRateChanage(QString deviceName, int bitRate); diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index 18eda755..edf1c957 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -93,9 +93,8 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo map.clear(); NetworkManager::ActiveConnection::List activeConnectionList; - map.clear(); activeConnectionList.clear(); - activeConnectionList = m_networkResourceInstance->m_activeConns; + activeConnectionList = m_networkResourceInstance->getActiveConnectList(); if (activeConnectionList.isEmpty()) { return; } @@ -103,14 +102,23 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr; for (; index < activeConnectionList.size(); index++) { activeConnectionPtr = activeConnectionList.at(index); + if (activeConnectionPtr.isNull()) { + continue; + } + if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type()) { continue; } + if (state != activeConnectionPtr->state()) { continue; } + QString ssid; QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid); + if(ifaceName.isEmpty() || ssid.isNull()) { + continue; + } if (map.contains(ifaceName)) { map[ifaceName].append(ssid); } else { @@ -130,13 +138,42 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection:: } NetworkManager::Connection::Ptr conn = actConn->connection(); + if (conn.isNull()) { + return ""; + } + NetworkManager::ConnectionSettings::Ptr sett = conn->settings(); + if (sett.isNull()) { + return ""; + } + NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast(); + if (wireless_sett.isNull()) { + return ""; + } wirelessNetResourcessid = wireless_sett->ssid(); return sett->interfaceName(); } +void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid) +{ + ssid.clear(); + NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid); + if (connectPtr.isNull()) { + return; + } + NetworkManager::WirelessSetting::Ptr wireless_sett + = connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast(); + if (wireless_sett.isNull()) { + qDebug() << "don't have WirelessSetting connection"; + return; + } + ssid = wireless_sett->ssid(); + + return; +} + void KyWirelessNetResource::kyWirelessNetItemListInit() { qDebug() << m_networkResourceInstance->m_wifiNets.size(); diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h index 1da8b1bd..3249fe90 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.h +++ b/src/backend/dbus-interface/kywirelessnetresource.h @@ -28,6 +28,8 @@ public: void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap &map); + void getSsidByUuid(const QString uuid, QString &ssid); + private: void kyWirelessNetItemListInit(); diff --git a/src/backend/dbusadaptor.cpp b/src/backend/dbusadaptor.cpp index e9f51e1a..a880de80 100644 --- a/src/backend/dbusadaptor.cpp +++ b/src/backend/dbusadaptor.cpp @@ -72,6 +72,54 @@ bool getDeviceEnableState(QMap &map) return true; } +//设置默认网卡 +void setDefaultDevice(KyDeviceType deviceType, QString deviceName) +{ + QString key; + switch (deviceType) { + case WIRED: + key = "wired"; + break; + case WIRELESS: + key = "wireless"; + break; + default: + return; + break; + } + QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); + m_settings->beginGroup("DEFAULTCARD"); + m_settings->setValue(key, deviceName); + m_settings->endGroup(); + m_settings->sync(); + delete m_settings; + m_settings = nullptr; + return; +} + +bool checkDeviceExist(KyDeviceType deviceType, QString deviceName) +{ + NetworkManager::Device::Type type; + switch (deviceType) { + case WIRED: + type = NetworkManager::Device::Type::Ethernet; + break; + case WIRELESS: + type = NetworkManager::Device::Type::Wifi; + break; + default: + return false; + break; + } + + KyNetworkDeviceResourse * kdr = new KyNetworkDeviceResourse(); + QStringList devList; + devList.clear(); + + kdr->getNetworkDeviceList(type, devList); + return devList.contains(deviceName); +} + /* * Implementation of adaptor class DbusAdaptor */ @@ -141,14 +189,10 @@ void DbusAdaptor::setDeviceEnable(QString devName, bool enable) //设置默认网卡 void DbusAdaptor::setDefaultWiredDevice(QString deviceName) { - QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); - m_settings->beginGroup("DEFAULTCARD"); - QString key("wired"); - m_settings->setValue(key, deviceName); - m_settings->endGroup(); - m_settings->sync(); - delete m_settings; - m_settings = nullptr; + if (!checkDeviceExist(WIRED, deviceName)) { + return; + } + setDefaultDevice(WIRED, deviceName); parent()->setWiredDefaultDevice(deviceName); return; } @@ -167,14 +211,10 @@ QString DbusAdaptor::getDefaultWiredDevice() void DbusAdaptor::setDefaultWirelessDevice(QString deviceName) { - QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); - m_settings->beginGroup("DEFAULTCARD"); - QString key("wireless"); - m_settings->setValue(key, deviceName); - m_settings->endGroup(); - m_settings->sync(); - delete m_settings; - m_settings = nullptr; + if (!checkDeviceExist(WIRED, deviceName)) { + return; + } + setDefaultDevice(WIRELESS, deviceName); parent()->setWirelessDefaultDevice(deviceName); return; } diff --git a/src/backend/dbusadaptor.h b/src/backend/dbusadaptor.h index 7abc5c7f..be0f1fbd 100644 --- a/src/backend/dbusadaptor.h +++ b/src/backend/dbusadaptor.h @@ -84,6 +84,15 @@ class WirelessInfo }; Q_DECLARE_METATYPE(WirelessInfo) +enum KyDeviceType +{ + WIRED, + WIRELESS +}; + +bool checkDeviceExist(KyDeviceType deviceType, QString deviceName); +void setDefaultDevice(KyDeviceType deviceType, QString deviceName); + class DbusAdaptor: public QDBusAbstractAdaptor { Q_OBJECT @@ -127,6 +136,9 @@ Q_SIGNALS: // SIGNALS void deviceUpdate(); //仅失败,若成功直接发listUpdate void activateFinish(QString devName, QString ssid); + //设备插拔 + void deviceStatusChanged(); + void deviceNameUpdate(QString oldName, QString newName); }; #endif diff --git a/src/frontend/list-items/listitem.h b/src/frontend/list-items/listitem.h index 9ab5af16..db139e06 100644 --- a/src/frontend/list-items/listitem.h +++ b/src/frontend/list-items/listitem.h @@ -20,11 +20,10 @@ protected: NetButton * m_netButton = nullptr; InfoButton * m_infoButton = nullptr; -private: +public: QVBoxLayout * m_mainLayout = nullptr; QHBoxLayout * m_hItemLayout = nullptr; - private: void initUI(); }; diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 910d1cf0..98b52582 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -1,17 +1,32 @@ #include "wlanlistitem.h" +#include -WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QWidget *parent) : ListItem(parent) +WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent) : ListItem(parent) { m_data = data; m_resource = resource; + m_wlanDevice = device; + m_connoperation = new KyWirelessConnectOperation(this); initWlanUI(); setExpanded(false); initWlanConnection(); } +WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent) +{ + m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic")); + const QString str="未连接任何wifi"; + setExpanded(false); + this->setName(str); + this->m_netButton->setEnabled(false); + this->m_infoButton->hide(); +} + WlanListItem::~WlanListItem() { disconnect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged); + disconnect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd); + disconnect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove); } void WlanListItem::setWlanSignal(const int &signal) @@ -28,8 +43,32 @@ void WlanListItem::setWlanState(const int &state) void WlanListItem::setExpanded(const bool &expanded) { - m_isExpanded = expanded; + if (!m_pwdFrame || !m_autoConnectFrame) { + this->setFixedHeight(NORMAL_HEIGHT); + return; + } this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT); + + m_pwdFrame->setVisible(expanded); + m_autoConnectFrame->setVisible(expanded); + emit this->itemHeightChanged(m_data->m_NetSsid); +} + +void WlanListItem::setActivated(bool activated) +{ + this->m_isActivated = activated; +} + +void WlanListItem::resizeEvent(QResizeEvent *event) +{ + this->blockSignals(true); + if (this->height() == EXPANDED_HEIGHT) { + this->setExpanded(true); + } else { + this->setExpanded(false); + } + this->blockSignals(false); + return ListItem::resizeEvent(event); } void WlanListItem::initWlanUI() @@ -39,11 +78,68 @@ void WlanListItem::initWlanUI() this->setName((m_data->m_connName != "") ? m_data->m_connName : m_data->m_NetSsid); //刷新左侧按钮图标 refreshIcon(); + +#define PWD_AREA_HEIGHT 36 +#define CONNECT_BUTTON_WIDTH 96 +#define FRAME_CONTENT_MARGINS 56,4,16,4 +#define FRAME_SPACING 8 +#define PWD_CONTENT_MARGINS 8,0,32,0 +#define SHOW_PWD_BUTTON_SIZE 16,16 +#define PWD_LAYOUT_MARGINS 8,0,8,0 + //密码输入区域的UI + m_pwdFrame = new QFrame(this); + m_pwdFrameLyt = new QHBoxLayout(m_pwdFrame); + m_pwdFrameLyt->setContentsMargins(FRAME_CONTENT_MARGINS); + m_pwdFrameLyt->setSpacing(FRAME_SPACING); + m_pwdFrame->setLayout(m_pwdFrameLyt); + { + m_pwdLineEdit = new QLineEdit(m_pwdFrame); + connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged); + m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT); + m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password); + m_pwdLineEditLyt = new QHBoxLayout(m_pwdLineEdit); + m_pwdLineEditLyt->setContentsMargins(PWD_LAYOUT_MARGINS); + m_pwdLineEdit->setLayout(m_pwdLineEditLyt); + m_showPwdButton = new QPushButton(m_pwdLineEdit); + m_showPwdButton->setFixedSize(SHOW_PWD_BUTTON_SIZE); + connect(m_showPwdButton, &QPushButton::clicked, this, &WlanListItem::onShowPwdButtonClicked); + m_pwdLineEditLyt->addStretch(); + m_pwdLineEditLyt->addWidget(m_showPwdButton); + } + m_connectButton = new QPushButton(m_pwdFrame); + m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT); + m_connectButton->setText(tr("Connect")); + m_connectButton->setEnabled(false); + connect(m_connectButton, &QPushButton::clicked, this, &WlanListItem::onConnectButtonClicked); + m_pwdFrameLyt->addWidget(m_pwdLineEdit); + m_pwdFrameLyt->addWidget(m_connectButton); + + //自动连接选择区域UI + m_autoConnectFrame = new QFrame(this); + m_autoConnectFrameLyt = new QHBoxLayout(m_autoConnectFrame); + m_autoConnectFrameLyt->setContentsMargins(FRAME_CONTENT_MARGINS); + m_autoConnectFrameLyt->setSpacing(FRAME_SPACING); + m_autoConnectFrame->setLayout(m_autoConnectFrameLyt); + m_autoConnectCheckBox = new QCheckBox(m_autoConnectFrame); + m_autoConnectCheckBox->setChecked(true); + m_autoConnectCheckBox->setFixedSize(SHOW_PWD_BUTTON_SIZE); + m_autoConnectLabel = new QLabel(m_autoConnectFrame); + m_autoConnectLabel->setText(tr("Auto Connect")); + m_autoConnectFrameLyt->addWidget(m_autoConnectCheckBox); + m_autoConnectFrameLyt->addWidget(m_autoConnectLabel); + m_autoConnectFrameLyt->addStretch(); + + m_mainLayout->addWidget(m_pwdFrame); + m_mainLayout->addWidget(m_autoConnectFrame); + m_pwdFrame->hide(); + m_autoConnectFrame->hide(); } void WlanListItem::initWlanConnection() { connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged); + connect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd); + connect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove); } void WlanListItem::refreshIcon() @@ -101,15 +197,77 @@ void WlanListItem::refreshIcon() void WlanListItem::onInfoButtonClicked() { //ZJP_TODO 呼出无线详情页 - qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." < actMap; + m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap); + QMap::iterator iter = actMap.begin(); + while (iter != actMap.end()) { + if (iter.key() == m_wlanDevice && !iter.value().isEmpty()) { + activedssid = iter.value().at(0); + break; + } + iter ++; + } + qDebug()<<"Get activated wlan succeed! ssid = " << activedssid <m_NetSsid == activedssid) { + m_connoperation->deActivateWirelessConnection(m_wlanDevice,m_data->m_connectUuid); + qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; + return; + } + + if (m_data->m_isConfigured) { + m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid); + qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__; + return; + } + if (!this->m_connectButton->isVisible() && m_data->m_secuType != "") { + this->setExpanded(true); + } else { + onConnectButtonClicked(); + } } +//void WlanListItem::onNameLableClicked() +//{ +// m_mainLayout = new QVBoxLayout(this); +// m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); +// m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING); +// this->setLayout(m_mainLayout); + +// m_itemFrame = new QFrame(this); + +// m_hItemLayout = new QHBoxLayout(m_itemFrame); +// m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS); +// m_hItemLayout->setSpacing(ITEM_FRAME_SPACING); + +// m_lineEdit = new QLineEdit(m_itemFrame); + +// m_hItemLayout->addWidget(m_lineEdit); +// m_hItemLayout->addStretch(); + +// m_mainLayout->addWidget(m_itemFrame); +//} + void WlanListItem::onSecurityChanged(QString interface, QString ssid, QString securityType) { if (ssid != m_data->m_NetSsid) { @@ -123,3 +281,72 @@ void WlanListItem::onSecurityChanged(QString interface, QString ssid, QString se refreshIcon(); } } + +void WlanListItem::onPwdEditorTextChanged() +{ + if (!m_pwdLineEdit || !m_connectButton) { + return; + } + if (m_pwdLineEdit->text().length() < PWD_LENGTH_LIMIT) { + m_connectButton->setEnabled(false); + } else { + m_connectButton->setEnabled(true); + } +} + +void WlanListItem::onShowPwdButtonClicked() +{ + if (!m_pwdLineEdit) { + return; + } + if (m_pwdLineEdit->echoMode() == QLineEdit::EchoMode::Password) { + //TODO 按钮图标要发生改变 + + m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Normal); + } else { + //TODO 按钮图标要发生改变 + m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password); + } +} + +void WlanListItem::onConnectButtonClicked() +{ + if (!m_connectButton->isEnabled() || !m_data) { + return; + } + KyWirelessConnectSetting settings; + settings.m_connectName = m_data->m_NetSsid; + settings.m_ssid = m_data->m_NetSsid; + settings.isAutoConnect = m_autoConnectCheckBox->isChecked(); + settings.m_psk = m_pwdLineEdit->text(); + if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") { + settings.m_type = WpaNone; + } else if (m_data->m_secuType.contains("WPA1") || m_data->m_secuType.contains("WPA2")) { + settings.m_type = WpaPsk; + } else if (m_data->m_secuType.contains("WPA3")) { + settings.m_type = SAE; + } + qDebug() << "On button connect clicked, will connect wlan. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO <<__LINE__; + + emit this->connectButtonClicked(settings, false); +} + +void WlanListItem::onConnectionAdd(QString deviceName, QString ssid) +{ + if (!m_data) { + return; + } + if (ssid == m_data->m_NetSsid) { + m_data->m_isConfigured = true; + } +} + +void WlanListItem::onConnectionRemove(QString deviceName, QString ssid) +{ + if (!m_data) { + return; + } + if (ssid == m_data->m_NetSsid) { + m_data->m_isConfigured = false; + } +} diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 2824c40d..5556cc83 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -3,21 +3,38 @@ #include "listitem.h" #include "kywirelessnetitem.h" #include "kywirelessnetresource.h" +#include "wlanpage.h" +#include "kywirelessconnectoperation.h" +#include + +#include + +#define PSK_SETTING_NAME "802-11-wireless-security" #define NORMAL_HEIGHT 48 #define EXPANDED_HEIGHT 120 +#define PWD_LENGTH_LIMIT 8 class WlanListItem : public ListItem { Q_OBJECT public: - WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QWidget *parent = nullptr); + WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent = nullptr); + WlanListItem(QWidget *parent = nullptr); ~WlanListItem(); public: void setWlanSignal(const int &signal); void setWlanState(const int &state); void setExpanded(const bool &expanded); + void setActivated(bool activated); + +protected: + void resizeEvent(QResizeEvent *event); + +signals: + void itemHeightChanged(const QString &ssid); + void connectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden); private: void initWlanUI(); @@ -27,13 +44,42 @@ private: private: KyWirelessNetResource *m_resource = nullptr; KyWirelessNetItem *m_data = nullptr; - bool m_isExpanded = false; + KyWirelessConnectOperation *m_connoperation = nullptr; bool m_hasPwd = true; + bool m_isActivated = false; + QString m_wlanDevice; + + //密码输入区域的UI + QFrame *m_pwdFrame = nullptr; + QHBoxLayout *m_pwdFrameLyt = nullptr; + + QLineEdit * m_pwdLineEdit = nullptr; + QHBoxLayout *m_pwdLineEditLyt = nullptr; + QPushButton *m_showPwdButton = nullptr; + + QPushButton *m_connectButton = nullptr; + + //自动连接选择区域UI + QFrame *m_autoConnectFrame = nullptr; + QHBoxLayout *m_autoConnectFrameLyt = nullptr; + QCheckBox *m_autoConnectCheckBox = nullptr; + QLabel *m_autoConnectLabel = nullptr; + +// QVBoxLayout * m_mainLayout = nullptr; +// QFrame * m_itemFrame = nullptr; +// QHBoxLayout * m_hItemLayout = nullptr; +// QLineEdit * m_lineEdit = nullptr; private slots: void onInfoButtonClicked(); void onNetButtonClicked(); +// void onNameLableClicked(); void onSecurityChanged(QString interface, QString ssid, QString securityType); + void onPwdEditorTextChanged(); + void onShowPwdButtonClicked(); + void onConnectButtonClicked(); + void onConnectionAdd(QString deviceName, QString ssid); + void onConnectionRemove(QString deviceName, QString ssid); }; #endif // WLANLISTITEM_H diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index b68f67bd..9087cce4 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -112,6 +112,11 @@ void MainWindow::initUI() m_wlanWidget = new WlanPage(m_centralWidget); 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")); + + connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged); + connect(m_lanWidget, &LanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged); + connect(m_wlanWidget, &WlanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged); + connect(m_wlanWidget, &WlanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged); } /** diff --git a/src/frontend/new-mainwindow.h b/src/frontend/new-mainwindow.h index 25f7ca6d..b5b94352 100644 --- a/src/frontend/new-mainwindow.h +++ b/src/frontend/new-mainwindow.h @@ -23,6 +23,8 @@ public: void setWiredDefaultDevice(QString deviceName); void setWirelessDefaultDevice(QString deviceName); signals: + void deviceStatusChanged(); + void deviceNameChanged(QString oldName, QString newName); public slots: diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index c320c9d4..799c1d2f 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -36,6 +36,8 @@ public: QString getDefaultDevice(); signals: + void deviceStatusChanged(); + void deviceNameChanged(QString oldName, QString newName); protected: void initUI(); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 0bc0bf7a..c386be6c 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -1,6 +1,6 @@ #include "wlanpage.h" -#include "wlanlistitem.h" #include "kywirelessnetitem.h" +#include "dbusadaptor.h" #include #include #include @@ -9,14 +9,27 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) { m_resource = new KyWirelessNetResource(this); - m_device = new KyNetworkDeviceResourse(this); + m_connectResource = new KyActiveConnectResourse(); + m_networkResourceInstance = KyNetworkResourceManager::getInstance(); + m_netDeviceResource=new KyNetworkDeviceResourse(this); + devList.empty(); initDevice(); + m_wirelessConnectOpreation = new KyWirelessConnectOperation(this); initWlanUI(); initConnections(); getActiveWlan(); getAllWlan(); + + connect(m_netDeviceResource, &KyNetworkDeviceResourse::deviceAdd, this, &WlanPage::onDeviceAdd); + connect(m_netDeviceResource, &KyNetworkDeviceResourse::deviceRemove, this, &WlanPage::onDeviceRemove); + connect(m_netDeviceResource, &KyNetworkDeviceResourse::deviceNameUpdate, this, &WlanPage::onDeviceNameUpdate); } +//QString WlanPage::getSsidFromUuid(const QString &uuid) +//{ + +//} + bool WlanPage::eventFilter(QObject *w, QEvent *e) { if (e->type() == QEvent::MouseButtonPress) { @@ -79,7 +92,8 @@ void WlanPage::initConnections() { connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded); connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved); - connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated); +// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated); + connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged); } /** @@ -91,13 +105,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); if (deviceName.isEmpty()) { qDebug() << "initDevice but defalut wireless card is null"; - QStringList list; - list.empty(); - m_device->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list); - if (!list.isEmpty()) { - deviceName = list.at(0); + if (!devList.isEmpty()) { + deviceName = devList.at(0); m_settings->setValue(key, deviceName); } } @@ -121,22 +133,9 @@ void WlanPage::getActiveWlan() QMap::iterator iter = actMap.begin(); int height = 0; while (iter != actMap.end()) { - if (iter.key() == "wlp3s0" && !iter.value().isEmpty()) { + if (iter.key() == defaultDevice && !iter.value().isEmpty()) { QString ssid = iter.value().at(0); - m_activatedWlanSSid = ssid; - - KyWirelessNetItem data; - if (!m_resource->getWifiNetwork("wlp3s0", ssid, data)) { - return; - } - KyWirelessNetItem *item_data = new KyWirelessNetItem(data); - WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data); - qDebug() << "Activated wlan: ssid = " << item_data->m_NetSsid; - QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); - wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); - m_activatedNetListWidget->addItem(wlanItem); - m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); - height += wlanItemWidget->height(); + appendActiveWlan(ssid, height); break; } iter ++; @@ -144,11 +143,38 @@ void WlanPage::getActiveWlan() if (height > 0) { m_activatedNetListWidget->setFixedHeight(height); } else { - //ZJP_TODO 未连接任何WiFi的情况 + //未连接任何WiFi的情况 m_activatedWlanSSid.clear(); + WlanListItem *wlanItemWidget = new WlanListItem(); + qDebug() << "There is no activated wlan." << Q_FUNC_INFO << __LINE__ ; + QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); + wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); + m_activatedNetListWidget->addItem(wlanItem); + m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); + height += wlanItemWidget->height(); } } +void WlanPage::appendActiveWlan(const QString &ssid, int &height) +{ + m_activatedWlanSSid = ssid; + + KyWirelessNetItem data; + if (!m_resource->getWifiNetwork(defaultDevice, ssid, data)) { + return; + } + KyWirelessNetItem *item_data = new KyWirelessNetItem(data); + WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data, defaultDevice); + wlanItemWidget->setActivated(true); + qDebug() << "Activated wlan: ssid = " << item_data->m_NetSsid; + QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget); + wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); + m_activatedNetListWidget->addItem(wlanItem); + m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); + + height += wlanItemWidget->height(); +} + /** * @brief WlanPage::getAllWlan 获取所有Wlan //ZJP_TODO 需要针对网卡进行筛选 */ @@ -159,7 +185,7 @@ void WlanPage::getAllWlan() m_itemsMap.clear(); QList wlanList; // if (!m_resource->getAllDeviceWifiNetwork(map)) - if (!m_resource->getDeviceWifiNetwork("wlp3s0", wlanList)) //ZJP_TODO 获取默认网卡并传入 + if (!m_resource->getDeviceWifiNetwork(defaultDevice, wlanList)) //ZJP_TODO 获取默认网卡并传入 { return; } @@ -170,8 +196,10 @@ void WlanPage::getAllWlan() } KyWirelessNetItem *data = new KyWirelessNetItem(itemData); - WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data); + WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice); QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget); + connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); + connect(wlanItemWidget, &WlanListItem::connectButtonClicked, this, &WlanPage::onConnectButtonClicked); m_itemsMap.insert(data->m_NetSsid, wlanItem); wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height())); m_inactivatedNetListWidget->addItem(wlanItem); @@ -191,7 +219,8 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__; KyWirelessNetItem *data = new KyWirelessNetItem(item); - WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data); + WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice); + connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget); wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height())); m_inactivatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); @@ -206,11 +235,11 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) void WlanPage::onWlanRemoved(QString interface, QString ssid) { if (!m_itemsMap.contains(ssid)) { return; } + if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; } qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__; - m_inactivatedNetListWidget->removeItemWidget(m_itemsMap.value(ssid)); - m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - - m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height() - - NET_LIST_SPACING); + int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height(); + m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid))); + m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING); m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); m_itemsMap.remove(ssid); } @@ -218,5 +247,104 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid) void WlanPage::onWlanUpdated() { //ZJP_TODO 某些特定情况下不可重绘整个列表,此处代码需要修改 + m_expandedItem = nullptr; + getActiveWlan(); getAllWlan(); } + + +void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType) +{ + qDebug() << "deviceAdd" << deviceName; + if (deviceType != NetworkManager::Device::Type::Wifi) { + return; + } + devList << deviceName; + if (getDefaultDevice().isEmpty()) + { + updateDefaultDevice(deviceName); + setDefaultDevice(WIRELESS, deviceName); + + } + emit deviceStatusChanged(); +} + +void WlanPage::onDeviceRemove(QString deviceName) +{ + qDebug() << "deviceRemove" << deviceName; + if (getDefaultDevice() == deviceName) + { + QStringList list; + QString newDefaultDevice = ""; + list.empty(); + m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list); + if (!list.isEmpty()) { + newDefaultDevice = list.at(0); + } + updateDefaultDevice(newDefaultDevice); + setDefaultDevice(WIRELESS, newDefaultDevice); + } + if (devList.contains(deviceName)) { + devList.removeOne(deviceName); + emit deviceStatusChanged(); + } +} + +void WlanPage::onDeviceNameUpdate(QString oldName, QString newName) +{ + if (getDefaultDevice() == oldName) { + updateDefaultDevice(newName); + setDefaultDevice(WIRELESS, newName); + } + + if (devList.contains(oldName)) { + devList.removeOne(oldName); + devList.append(newName); + qDebug() << "WlanPage emit deviceNameUpdate " << oldName << newName; + emit deviceNameChanged(oldName, newName); + } +} + +void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason) +{ + qDebug()<< "Activated wlan changed, uuid = " << uuid << "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__; + + if (state == NetworkManager::ActiveConnection::State::Activated) { + //onWlanRemoved(m_wlanDevice, ssid); + QString ssid; + m_resource->getSsidByUuid(uuid, ssid); + m_activatedNetListWidget->clear(); + int height = 0; + appendActiveWlan(ssid, height); + onWlanRemoved(defaultDevice, ssid); + } else { + onWlanUpdated(); + } +} + +void WlanPage::onItemHeightChanged(const QString &ssid) +{ + if (!m_itemsMap.contains(ssid)) { return; } + QListWidgetItem *item = m_itemsMap.value(ssid); + + if (m_expandedItem && m_expandedItem != item) { + QSize size(m_inactivatedNetListWidget->itemWidget(m_expandedItem)->size().width(), NORMAL_HEIGHT); + //旧的收起 + m_expandedItem->setSizeHint(size); + m_inactivatedNetListWidget->itemWidget(m_expandedItem)->setFixedHeight(NORMAL_HEIGHT); + //新的展开 + m_expandedItem = item; + item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); + } else if (!m_expandedItem) { + m_expandedItem = item; + m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_inactivatedNetListWidget->itemWidget(item)->height() - item->sizeHint().height()); + m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); + item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); + } +} + +void WlanPage::onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden) +{ + qDebug() << "Received signal of connecting wlan, ssid = " << connSettingInfo.m_ssid << Q_FUNC_INFO << __LINE__; + m_wirelessConnectOpreation->addAndActiveWirelessConnect(defaultDevice, connSettingInfo, isHidden); +} diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index 1a44b7fb..ff0b6db4 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -3,10 +3,14 @@ #include "tabpage.h" #include "kywirelessnetresource.h" +#include "kylinactiveconnectresource.h" #include "kylinnetworkdeviceresource.h" +#include "kywirelessconnectoperation.h" +#include "wlanlistitem.h" //#define SCROLLAREA_HEIGHT 150 #define MORE_TEXT_MARGINS 16,0,0,0 +#define SCROLLAREA_HEIGHT 200 class WlanPage : public TabPage { @@ -15,9 +19,10 @@ public: explicit WlanPage(QWidget *parent = nullptr); ~WlanPage() = default; - void setDefaultDevice(QString deviceName) {defaultDevice = deviceName;} + //static QString getSsidFromUuid(const QString &uuid); signals: + void oneItemExpanded(const QString &ssid); protected: bool eventFilter(QObject *watched, QEvent *event); @@ -25,10 +30,14 @@ protected: private: void initWlanUI(); void initConnections(); + void initDevice();//初始化默认设备 + void getActiveWlan(); + void appendActiveWlan(const QString &ssid, int &height); void getAllWlan(); QMap m_itemsMap; + QListWidgetItem *m_expandedItem = nullptr; QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr; QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr; QFrame * m_hiddenWlanWidget = nullptr; @@ -37,15 +46,28 @@ private: QLabel * m_hiddenWlanLabel = nullptr; QString m_activatedWlanSSid; - QString defaultDevice = ""; + QStringList devList; KyWirelessNetResource *m_resource = nullptr; - KyNetworkDeviceResourse *m_device = nullptr; + KyActiveConnectResourse *m_connectResource = nullptr; + KyNetworkResourceManager *m_networkResourceInstance = nullptr; + KyNetworkDeviceResourse *m_netDeviceResource = nullptr; + KyWirelessConnectOperation * m_wirelessConnectOpreation = nullptr; + private slots: void onWlanAdded(QString interface, KyWirelessNetItem &item); void onWlanRemoved(QString interface, QString ssid); void onWlanUpdated(); + + void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType); + void onDeviceRemove(QString deviceName); + void onDeviceNameUpdate(QString oldName, QString newName); + void onActivatedWlanChanged(QString uuid, + NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason); + void onItemHeightChanged(const QString &ssid); + void onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden); }; #endif // WLANPAGE_H diff --git a/src/frontend/tools/radioitembutton.cpp b/src/frontend/tools/radioitembutton.cpp index adc52d58..3f0b0dee 100644 --- a/src/frontend/tools/radioitembutton.cpp +++ b/src/frontend/tools/radioitembutton.cpp @@ -1,4 +1,8 @@ #include "radioitembutton.h" +#define BUTTON_SIZE 32,32 + +#define FRAMESPEED 60 //帧与帧之间的间隔时间(ms) +#define ALLTIME 40*1000 //等待动画持续总时间 RadioItemButton::RadioItemButton(bool isActivated, QWidget *parent) : QPushButton(parent) { @@ -8,8 +12,35 @@ RadioItemButton::RadioItemButton(bool isActivated, QWidget *parent) : QPushButto this->setAutoFillBackground(false); m_iconLabel = new QLabel(this); m_iconLabel->setScaledContents(true); + this->setFixedSize(BUTTON_SIZE); + +// this->switchTimer = new QTimer(this); //QTimer对象,控制等待动画播放 + + this->raise(); + this->hide(); } +//void RadioItemButton::switchAnimStep() +//{ +// //另外一种加载方法 +// QString qpmQss = ":/res/s/conning-b/"; +// 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 = 12; //循环播放 +// } +// this->countCurrentTime += FRAMESPEED; +// if (this->countCurrentTime >= ALLTIME) { +// emit this->toStopLoading(); //发出信号停止主界面和托盘区的等待动画 +// } +//} + void RadioItemButton::startLoading() { emit this->requestStartLoading(); @@ -38,7 +69,9 @@ void RadioItemButton::setReleased() void RadioItemButton::setButtonIcon(QIcon *icon) { - if (!icon) { return; } + if (!icon) { + return; + } //ZJP_TODO 绘制圆形按钮 m_iconLabel->setPixmap(icon->pixmap(this->size())); } @@ -46,9 +79,18 @@ void RadioItemButton::setButtonIcon(QIcon *icon) void RadioItemButton::onLoadingStarted() { //ZJP_TODO 开始播放转圈动画 +// this->currentPage = 12; +// this->countCurrentTime = 0; +// this->switchTimer->start(FRAMESPEED); +// this->show(); +// if (this->countCurrentTime >= ALLTIME) { +// emit this->requestStopLoading(); //发出信号停止主界面和托盘区的等待动画 +// } } void RadioItemButton::onLoadingStopped() { //ZJP_TODO 停止播放转圈动画 +// this->switchTimer->stop(); +// this->hide(); }