fix
This commit is contained in:
commit
015e5e350c
|
@ -54,6 +54,7 @@ void KyWirelessNetItem::init(NetworkManager::WirelessNetwork::Ptr net)
|
|||
m_NetSsid = net->ssid();
|
||||
m_signalStrength = net->signalStrength();
|
||||
m_frequency = net->referenceAccessPoint()->frequency();
|
||||
m_channel = NetworkManager::findChannel(m_frequency);
|
||||
NetworkManager::AccessPoint::Capabilities cap = net->referenceAccessPoint()->capabilities();
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = net->referenceAccessPoint()->wpaFlags();
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = net->referenceAccessPoint()->rsnFlags();
|
||||
|
@ -81,7 +82,6 @@ void KyWirelessNetItem::initInfoBySsid()
|
|||
m_connName = conn->name();
|
||||
m_connDbusPath = conn->path();
|
||||
m_isConfigured = true;
|
||||
m_channel = wifi_sett->channel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,16 +117,17 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
|
|||
continue;
|
||||
}
|
||||
|
||||
qDebug() << "getWirelessActiveConnection " << activeConnectionPtr->uuid();
|
||||
QString ssid;
|
||||
QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid);
|
||||
if(ifaceName.isEmpty() || ssid.isNull()) {
|
||||
continue;
|
||||
}
|
||||
if (map.contains(ifaceName)) {
|
||||
map[ifaceName].append(ssid);
|
||||
map[ifaceName].append(activeConnectionPtr->uuid());
|
||||
} else {
|
||||
QStringList list;
|
||||
list.append(ssid);
|
||||
list.append(activeConnectionPtr->uuid());
|
||||
map.insert(ifaceName,list);
|
||||
}
|
||||
}
|
||||
|
@ -159,9 +160,10 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
|
|||
return sett->interfaceName();
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid)
|
||||
void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid, QString &devName)
|
||||
{
|
||||
ssid.clear();
|
||||
devName.clear();
|
||||
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
return;
|
||||
|
@ -173,6 +175,7 @@ void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid)
|
|||
return;
|
||||
}
|
||||
ssid = wireless_sett->ssid();
|
||||
devName = connectPtr->settings()->interfaceName();
|
||||
qDebug() << "getSsidByUuid success " << ssid;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap<QString, QStringList> &map);
|
||||
|
||||
void getSsidByUuid(const QString uuid, QString &ssid);
|
||||
void getSsidByUuid(const QString uuid, QString &ssid, QString &devName);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -78,6 +78,9 @@ void WlanListItem::resizeEvent(QResizeEvent *event)
|
|||
|
||||
void WlanListItem::onRightButtonClicked()
|
||||
{
|
||||
if (!m_menu) {
|
||||
return;
|
||||
}
|
||||
m_menu->clear();
|
||||
if (!this->m_data) {
|
||||
return;
|
||||
|
@ -122,8 +125,8 @@ void WlanListItem::initWlanUI()
|
|||
#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_CONTENT_MARGINS 8,0,34,0
|
||||
#define SHOW_PWD_BUTTON_SIZE 24,24
|
||||
#define PWD_LAYOUT_MARGINS 8,0,8,0
|
||||
//密码输入区域的UI
|
||||
m_pwdFrame = new QFrame(this);
|
||||
|
@ -136,11 +139,15 @@ void WlanListItem::initWlanUI()
|
|||
connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged);
|
||||
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
|
||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
m_pwdLineEdit->setTextMargins(PWD_CONTENT_MARGINS);
|
||||
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);
|
||||
m_showPwdButton->setAutoFillBackground(false);
|
||||
m_showPwdButton->setIcon(QIcon(":/res/h/hide-pwd.png"));
|
||||
m_showPwdButton->setCursor(Qt::PointingHandCursor);
|
||||
connect(m_showPwdButton, &QPushButton::clicked, this, &WlanListItem::onShowPwdButtonClicked);
|
||||
m_pwdLineEditLyt->addStretch();
|
||||
m_pwdLineEditLyt->addWidget(m_showPwdButton);
|
||||
|
@ -329,11 +336,10 @@ void WlanListItem::onShowPwdButtonClicked()
|
|||
return;
|
||||
}
|
||||
if (m_pwdLineEdit->echoMode() == QLineEdit::EchoMode::Password) {
|
||||
//TODO 按钮图标要发生改变
|
||||
|
||||
m_showPwdButton->setIcon(QIcon(":/res/h/show-pwd.png"));
|
||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
} else {
|
||||
//TODO 按钮图标要发生改变
|
||||
m_showPwdButton->setIcon(QIcon(":/res/h/hide-pwd.png"));
|
||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
}
|
||||
|
@ -382,11 +388,12 @@ 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);
|
||||
QString ssid, devName;
|
||||
m_resource->getSsidByUuid(uuid, ssid, devName);
|
||||
if (m_data->m_NetSsid == ssid) {
|
||||
qDebug() << "[WlanPage] State changed to :" << state << Q_FUNC_INFO <<__LINE__;
|
||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
if ((state == NetworkManager::ActiveConnection::State::Activating || state == NetworkManager::ActiveConnection::State::Deactivating)
|
||||
&& devName == m_wlanDevice) {
|
||||
m_netButton->startLoading();
|
||||
} else {
|
||||
m_netButton->stopLoading();
|
||||
|
|
|
@ -111,15 +111,28 @@ void NetDetail::initUI()
|
|||
|
||||
detailBtn = new QPushButton(this);
|
||||
detailBtn->setText(tr("Detail"));
|
||||
detailBtn->setCheckable(true);
|
||||
detailBtn->setChecked(true);
|
||||
|
||||
ipv4Btn = new QPushButton(this);
|
||||
ipv4Btn->setText(tr("Ipv4"));
|
||||
ipv4Btn->setCheckable(true);
|
||||
|
||||
ipv6Btn = new QPushButton(this);
|
||||
ipv6Btn->setText(tr("Ipv6"));
|
||||
ipv6Btn->setCheckable(true);
|
||||
|
||||
securityBtn = new QPushButton(this);
|
||||
securityBtn->setText(tr("Security"));
|
||||
securityBtn->setCheckable(true);
|
||||
|
||||
m_group = new QButtonGroup(this);
|
||||
m_group->addButton(detailBtn);
|
||||
m_group->addButton(ipv4Btn);
|
||||
m_group->addButton(ipv6Btn);
|
||||
if (isWlan) {
|
||||
m_group->addButton(securityBtn);
|
||||
}
|
||||
|
||||
pageLayout->addStretch();
|
||||
pageLayout->addWidget(detailBtn);
|
||||
|
@ -360,9 +373,7 @@ void NetDetail::getBaseInfo(ConInfo &conInfo)
|
|||
qDebug() << "KeyMgmt not support now " << type;
|
||||
}
|
||||
conInfo.strHz = QString::number(item.m_frequency);
|
||||
if (item.m_isConfigured) {
|
||||
conInfo.strChan = QString::number(item.m_channel);
|
||||
}
|
||||
conInfo.strChan = QString::number(item.m_channel);
|
||||
|
||||
initSecuData();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
|
@ -119,6 +120,8 @@ private:
|
|||
|
||||
ConInfo m_info;
|
||||
|
||||
QButtonGroup *m_group;
|
||||
|
||||
private slots:
|
||||
void on_btnConfirm_clicked();
|
||||
void on_btnForget_clicked();
|
||||
|
|
|
@ -94,13 +94,13 @@ void TabPage::initUI()
|
|||
void TabPage::updateDefaultDevice(QString &deviceName)
|
||||
{
|
||||
qDebug() << "updateDefaultDevice" << deviceName;
|
||||
defaultDevice = deviceName;
|
||||
m_defaultDevice = deviceName;
|
||||
}
|
||||
|
||||
QString TabPage::getDefaultDevice()
|
||||
{
|
||||
qDebug() << "getDefaultDevice" << defaultDevice;
|
||||
return defaultDevice;
|
||||
qDebug() << "getDefaultDevice" << m_defaultDevice;
|
||||
return m_defaultDevice;
|
||||
}
|
||||
|
||||
void setDefaultDevice(KyDeviceType deviceType, QString deviceName)
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
QHBoxLayout * m_settingsLayout = nullptr;
|
||||
QLabel * m_settingsLabel = nullptr;
|
||||
|
||||
QString defaultDevice = "";
|
||||
QString m_defaultDevice = "";
|
||||
|
||||
//临时增加的下拉框选择网卡区域
|
||||
QFrame * m_deviceFrame = nullptr;
|
||||
|
|
|
@ -149,14 +149,11 @@ void WlanPage::initDevice()
|
|||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
QString deviceName;
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wireless card is null";
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
updateDefaultDevice(deviceName);
|
||||
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
||||
|
@ -180,7 +177,7 @@ void WlanPage::initDeviceCombox()
|
|||
//空时addItem 会触发currentIndexChanged
|
||||
m_deviceComboBox->addItem(device, device);
|
||||
}
|
||||
int index = m_deviceComboBox->findData(defaultDevice);
|
||||
int index = m_deviceComboBox->findData(m_defaultDevice);
|
||||
qDebug() << index;
|
||||
m_deviceComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -202,9 +199,9 @@ void WlanPage::getActiveWlan()
|
|||
QMap<QString,QStringList>::iterator iter = actMap.begin();
|
||||
int height = 0;
|
||||
while (iter != actMap.end()) {
|
||||
if (iter.key() == defaultDevice && !iter.value().isEmpty()) {
|
||||
QString ssid = iter.value().at(0);
|
||||
appendActiveWlan(ssid, height);
|
||||
if (iter.key() == m_defaultDevice && !iter.value().isEmpty()) {
|
||||
QString uuid = iter.value().at(0);
|
||||
appendActiveWlan(uuid, height);
|
||||
break;
|
||||
}
|
||||
iter ++;
|
||||
|
@ -214,6 +211,7 @@ void WlanPage::getActiveWlan()
|
|||
} else {
|
||||
//未连接任何WiFi的情况
|
||||
m_activatedWlanSSid.clear();
|
||||
m_activatedWlanUuid.clear();
|
||||
WlanListItem *wlanItemWidget = new WlanListItem();
|
||||
qDebug() << "There is no activated wlan." << Q_FUNC_INFO << __LINE__ ;
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
||||
|
@ -224,16 +222,19 @@ void WlanPage::getActiveWlan()
|
|||
}
|
||||
}
|
||||
|
||||
void WlanPage::appendActiveWlan(const QString &ssid, int &height)
|
||||
void WlanPage::appendActiveWlan(const QString &uuid, int &height)
|
||||
{
|
||||
m_activatedWlanSSid = ssid;
|
||||
qDebug() << "appendActiveWlan" << uuid;
|
||||
m_activatedWlanUuid = uuid;
|
||||
m_resource->getSsidByUuid(uuid, m_activatedWlanSSid, m_defaultDevice);
|
||||
|
||||
KyWirelessNetItem data;
|
||||
if (!m_resource->getWifiNetwork(defaultDevice, ssid, data)) {
|
||||
if (!m_resource->getWifiNetwork(m_defaultDevice, m_activatedWlanSSid, data)) {
|
||||
qWarning() << "Get activated wlan failed! ssid = " << m_activatedWlanSSid <<"; device = " << m_defaultDevice << "; uuid = " << m_activatedWlanUuid;
|
||||
return;
|
||||
}
|
||||
KyWirelessNetItem *item_data = new KyWirelessNetItem(data);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data, defaultDevice);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data, m_defaultDevice);
|
||||
qDebug() << "Activated wlan: ssid = " << item_data->m_NetSsid;
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_activatedNetListWidget);
|
||||
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
|
||||
|
@ -257,8 +258,7 @@ void WlanPage::getAllWlan()
|
|||
m_itemsMap.clear();
|
||||
QList<KyWirelessNetItem> wlanList;
|
||||
// if (!m_resource->getAllDeviceWifiNetwork(map))
|
||||
if (!m_resource->getDeviceWifiNetwork(defaultDevice, wlanList)) //ZJP_TODO 获取默认网卡并传入
|
||||
{
|
||||
if (!m_resource->getDeviceWifiNetwork(m_defaultDevice, wlanList)) { //ZJP_TODO 获取默认网卡并传入
|
||||
return;
|
||||
}
|
||||
int height = 0;
|
||||
|
@ -268,7 +268,7 @@ void WlanPage::getAllWlan()
|
|||
}
|
||||
|
||||
KyWirelessNetItem *data = new KyWirelessNetItem(itemData);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, m_defaultDevice);
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget);
|
||||
qDebug() << itemData.m_NetSsid << itemData.m_isConfigured;
|
||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
|
@ -296,12 +296,13 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
|||
|
||||
|
||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
||||
if (interface != defaultDevice) {
|
||||
if (interface != m_defaultDevice) {
|
||||
qDebug() << "wlan add interface not equal defaultdevice,ignore";
|
||||
}
|
||||
KyWirelessNetItem *data = new KyWirelessNetItem(item);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, m_defaultDevice);
|
||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
connect(wlanItemWidget, &WlanListItem::connectButtonClicked, this, &WlanPage::onConnectButtonClicked);
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget);
|
||||
wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height()));
|
||||
m_inactivatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
||||
|
@ -319,7 +320,7 @@ 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__;
|
||||
if (interface != defaultDevice) {
|
||||
if (interface != m_defaultDevice) {
|
||||
qDebug() << "wlan remove interface not equal defaultdevice,ignore";
|
||||
}
|
||||
int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height();
|
||||
|
@ -430,7 +431,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
qDebug() << "[WlanPage] onActivatedWlanChanged but uuid is invalid";
|
||||
}
|
||||
|
||||
m_resource->getSsidByUuid(uuid, ssid);
|
||||
m_resource->getSsidByUuid(uuid, ssid, devName);
|
||||
|
||||
qDebug() << "emit wlanActiveConnectionStateChanged" << devName << ssid << state;
|
||||
emit wlanActiveConnectionStateChanged(devName, ssid, state);
|
||||
|
@ -463,18 +464,31 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
}
|
||||
}
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated && m_defaultDevice == devName) {
|
||||
//onWlanRemoved(m_wlanDevice, ssid);
|
||||
m_activatedNetListWidget->clear();
|
||||
int height = 0;
|
||||
appendActiveWlan(ssid, height);
|
||||
onWlanRemoved(defaultDevice, ssid);
|
||||
appendActiveWlan(uuid, height);
|
||||
onWlanRemoved(m_defaultDevice, ssid);
|
||||
// this->showDesktopNotify(tr("Connect WLAN succeed"));
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
onWlanUpdated();
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated && (uuid.isEmpty() || (!uuid.isEmpty() && uuid == m_activatedWlanUuid))) {
|
||||
QString oldActWlanSsid = m_activatedWlanSSid;
|
||||
getActiveWlan();
|
||||
QString newActWlanSsid = m_activatedWlanSSid;
|
||||
if (oldActWlanSsid != newActWlanSsid) {
|
||||
if (!oldActWlanSsid.isEmpty()) {
|
||||
KyWirelessNetItem item;
|
||||
if(m_resource->getWifiNetwork(m_defaultDevice, oldActWlanSsid, item)) {
|
||||
onWlanAdded(m_defaultDevice, item);
|
||||
}
|
||||
}
|
||||
if (!newActWlanSsid.isEmpty()) {
|
||||
onWlanRemoved(m_defaultDevice, newActWlanSsid);
|
||||
}
|
||||
}
|
||||
// this->showDesktopNotify(tr("Disconnect WLAN succeed"));
|
||||
} else {
|
||||
onWlanUpdated();
|
||||
qDebug() << "Unexpected wlan state, will do nothing." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,7 +516,7 @@ void WlanPage::onItemHeightChanged(const QString &ssid)
|
|||
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);
|
||||
m_wirelessConnectOpreation->addAndActiveWirelessConnect(m_defaultDevice, connSettingInfo, isHidden);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,7 +543,7 @@ void WlanPage::onDeviceComboxIndexChanged(int currentIndex)
|
|||
//TODO 设备变更时更新设备和列表
|
||||
QString currentDevice = m_deviceComboBox->itemText(currentIndex);
|
||||
qDebug() << "Current device changed! device = " << currentDevice << Q_FUNC_INFO << __LINE__;
|
||||
defaultDevice = currentDevice;
|
||||
m_defaultDevice = currentDevice;
|
||||
getActiveWlan();
|
||||
getAllWlan();
|
||||
}
|
||||
|
@ -546,7 +560,7 @@ void WlanPage::requestScan()
|
|||
void WlanPage::onHiddenWlanClicked()
|
||||
{
|
||||
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
|
||||
NetDetail *netDetail = new NetDetail(defaultDevice, "", "", false, true, true, this);
|
||||
NetDetail *netDetail = new NetDetail(m_defaultDevice, "", "", false, true, true, this);
|
||||
netDetail->show();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ private:
|
|||
void initDeviceCombox();
|
||||
|
||||
void getActiveWlan();
|
||||
void appendActiveWlan(const QString &ssid, int &height);
|
||||
void appendActiveWlan(const QString &uuid, int &height);
|
||||
void getAllWlan();
|
||||
QMap<QString, QListWidgetItem*> m_itemsMap;
|
||||
QListWidgetItem *m_expandedItem = nullptr;
|
||||
|
@ -75,6 +75,7 @@ private:
|
|||
QLabel * m_hiddenWlanLabel = nullptr;
|
||||
|
||||
QString m_activatedWlanSSid;
|
||||
QString m_activatedWlanUuid;
|
||||
QStringList m_devList;
|
||||
|
||||
KyWirelessNetResource *m_resource = nullptr;
|
||||
|
|
|
@ -33,6 +33,11 @@ RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
|||
connect(qApp, &QApplication::paletteChanged, this, &RadioItemButton::onPaletteChanged);
|
||||
}
|
||||
|
||||
RadioItemButton::~RadioItemButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RadioItemButton::startLoading()
|
||||
{
|
||||
emit this->requestStartLoading();
|
||||
|
@ -72,50 +77,33 @@ void RadioItemButton::setActive(const bool &isActive)
|
|||
}
|
||||
void RadioItemButton::onLoadingStarted()
|
||||
{
|
||||
if (!m_loadingTimer) {
|
||||
m_loadingTimer = new QTimer();
|
||||
connect(m_loadingTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingTimerTimeout);
|
||||
#define ANIMATION_SPEED 0.5*1000
|
||||
#define START_ROTATION 0
|
||||
#define END_ROTATION 360
|
||||
#define ANIMATION_LOOP -1 //无限旋转
|
||||
if (!m_iconLabel) {
|
||||
qWarning() << "Start loading failed, iconLabel is null pointer!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
if (!m_timeoutTimer) {
|
||||
m_timeoutTimer = new QTimer();
|
||||
connect(m_timeoutTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStopped);
|
||||
if (!m_animation) {
|
||||
m_animation = new QVariantAnimation(m_iconLabel);
|
||||
}
|
||||
if (m_loadingTimer->isActive()) {
|
||||
return;
|
||||
}
|
||||
m_loadingTimer->start(FLASH_SPEED);
|
||||
m_timeoutTimer->stop();
|
||||
m_timeoutTimer->start(TIMEOUT_TIMER);
|
||||
m_animation->setDuration(ANIMATION_SPEED);
|
||||
m_animation->setStartValue(START_ROTATION);
|
||||
m_animation->setEndValue(END_ROTATION);
|
||||
m_animation->setLoopCount(ANIMATION_LOOP);
|
||||
connect(m_animation, &QVariantAnimation::valueChanged, this, &RadioItemButton::onAnimationValueChanged);
|
||||
m_animation->start();
|
||||
}
|
||||
|
||||
void RadioItemButton::onLoadingStopped()
|
||||
{
|
||||
//ZJP_TODO 停止播放转圈动画
|
||||
if (this->m_loadingTimer) {
|
||||
this->m_loadingTimer->stop();
|
||||
if (!m_animation) {
|
||||
qWarning() << "Stop loading failed, m_animation is null pointer!" << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
} else {
|
||||
qWarning() << "Stop loading failed, m_loadingTimer is nullptr." << Q_FUNC_INFO << __LINE__;
|
||||
m_animation->stop();
|
||||
}
|
||||
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::onPaletteChanged()
|
||||
|
@ -129,6 +117,16 @@ void RadioItemButton::onPaletteChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void RadioItemButton::onAnimationValueChanged(const QVariant& value)
|
||||
{
|
||||
if (!m_iconLabel) {
|
||||
return;
|
||||
}
|
||||
QTransform t;
|
||||
t.rotate(value.toReal());
|
||||
m_iconLabel->setPixmap(QIcon(":/res/s/conning-a/1.png").pixmap(ICON_SIZE).transformed(t));
|
||||
}
|
||||
|
||||
void RadioItemButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
#include <QPushButton>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include<QTimer>
|
||||
#include <QTimer>
|
||||
#include <QVariantAnimation>
|
||||
|
||||
#define MIDDLE_COLOR 178
|
||||
|
||||
class RadioItemButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RadioItemButton(QWidget * parent = nullptr);
|
||||
~RadioItemButton() = default;
|
||||
~RadioItemButton();
|
||||
void startLoading();
|
||||
void stopLoading();
|
||||
void setButtonIcon(const QIcon &icon);
|
||||
|
@ -37,18 +39,16 @@ protected:
|
|||
private:
|
||||
bool m_isActivated = false;
|
||||
QLabel * m_iconLabel = nullptr;
|
||||
QTimer * m_loadingTimer = nullptr;
|
||||
QTimer * m_timeoutTimer = nullptr;
|
||||
QColor m_backgroundColor;
|
||||
QVariantAnimation * m_animation = nullptr;
|
||||
|
||||
int currentPage = 8;
|
||||
QPixmap m_pixmap;
|
||||
|
||||
private slots:
|
||||
void onLoadingStarted();
|
||||
void onLoadingStopped();
|
||||
void onLoadingTimerTimeout();
|
||||
void onPaletteChanged();
|
||||
void onAnimationValueChanged(const QVariant& value);
|
||||
};
|
||||
|
||||
#endif // NETBUTTON_H
|
||||
|
|
Loading…
Reference in New Issue