Optimize code.
This commit is contained in:
parent
6f523698e5
commit
fc45183146
|
@ -516,5 +516,5 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
|
||||||
}
|
}
|
||||||
m_WifiNetworkList.clear();
|
m_WifiNetworkList.clear();
|
||||||
kyWirelessNetItemListInit();
|
kyWirelessNetItemListInit();
|
||||||
emit wifiNetworkUpadte();
|
emit wifiNetworkUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ signals:
|
||||||
void secuTypeChange(QString, QString, QString);
|
void secuTypeChange(QString, QString, QString);
|
||||||
void connectionRemove(QString, QString);
|
void connectionRemove(QString, QString);
|
||||||
void connectionAdd(QString, QString);
|
void connectionAdd(QString, QString);
|
||||||
void wifiNetworkUpadte();
|
void wifiNetworkUpdate();
|
||||||
void wifiNetworkAdd(QString, KyWirelessNetItem&);
|
void wifiNetworkAdd(QString, KyWirelessNetItem&);
|
||||||
void wifiNetworkRemove(QString, QString);
|
void wifiNetworkRemove(QString, QString);
|
||||||
|
|
||||||
|
|
|
@ -48,43 +48,51 @@ void WlanListItem::initWlanConnection()
|
||||||
|
|
||||||
void WlanListItem::refreshIcon()
|
void WlanListItem::refreshIcon()
|
||||||
{
|
{
|
||||||
|
#define FULL_SIGNAL 5
|
||||||
|
#define EXCELLENT_SIGNAL 4
|
||||||
|
#define GOOD_SIGNAL 3
|
||||||
|
#define OK_SIGNAL 2
|
||||||
|
#define LOW_SIGNAL 1
|
||||||
|
#define STEP 25
|
||||||
// if (m_data->m_state) //ZJP_TODO 连接中、已连接、未连接的处理,要单独写逻辑,后端接口待补全
|
// if (m_data->m_state) //ZJP_TODO 连接中、已连接、未连接的处理,要单独写逻辑,后端接口待补全
|
||||||
if (!m_hasPwd) {
|
if (!m_hasPwd) {
|
||||||
//ZJP_TODO 无加密 注意信号格数计算方式,可能需要修改
|
//ZJP_TODO 无加密 注意信号格数计算方式,可能需要修改
|
||||||
switch (m_data->m_signalStrength / 25 + 1) {
|
switch (m_data->m_signalStrength / STEP + 1) {
|
||||||
case 5:
|
case FULL_SIGNAL:
|
||||||
case 4:
|
case EXCELLENT_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/w/wifi-full.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/w/wifi-full.png")));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case GOOD_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic", QIcon(":/res/w/wifi-high.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic", QIcon(":/res/w/wifi-high.png")));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case OK_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok", QIcon(":/res/w/wifi-medium.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok", QIcon(":/res/w/wifi-medium.png")));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case LOW_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low", QIcon(":/res/w/wifi-low.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low", QIcon(":/res/w/wifi-low.png")));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
qDebug() << "Set wlan(without passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//ZJP_TODO 有加密
|
//ZJP_TODO 有加密
|
||||||
switch (m_data->m_signalStrength / 25 + 1) {
|
switch (m_data->m_signalStrength / STEP + 1) {
|
||||||
case 5:
|
case FULL_SIGNAL:
|
||||||
case 4:
|
case EXCELLENT_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic", QIcon(":/res/w/wifi-full-pwd.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic", QIcon(":/res/w/wifi-full-pwd.png")));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case GOOD_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic", QIcon(":/res/w/wifi-high-pwd.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic", QIcon(":/res/w/wifi-high-pwd.png")));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case OK_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic", QIcon(":/res/w/wifi-medium-pwd.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic", QIcon(":/res/w/wifi-medium-pwd.png")));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case LOW_SIGNAL:
|
||||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic", QIcon(":/res/w/wifi-low-pwd.png")));
|
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic", QIcon(":/res/w/wifi-low-pwd.png")));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
qDebug() << "Set wlan(with passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ void NmDemo::initConnect()
|
||||||
|
|
||||||
connect(m_wnr, &KyWirelessNetResource::connectionRemove, this ,&NmDemo::onConnectionRemove);
|
connect(m_wnr, &KyWirelessNetResource::connectionRemove, this ,&NmDemo::onConnectionRemove);
|
||||||
connect(m_wnr, &KyWirelessNetResource::connectionAdd, this ,&NmDemo::onConnectionAdd);
|
connect(m_wnr, &KyWirelessNetResource::connectionAdd, this ,&NmDemo::onConnectionAdd);
|
||||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkUpadte, this ,&NmDemo::onWifiNetworkUpdate);
|
connect(m_wnr, &KyWirelessNetResource::wifiNetworkUpdate, this ,&NmDemo::onWifiNetworkUpdate);
|
||||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
||||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ void WlanPage::initConnections()
|
||||||
{
|
{
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded);
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkUpadte, this, &WlanPage::onWlanUpdated);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,9 @@ void WlanPage::getAllWlan()
|
||||||
}
|
}
|
||||||
int height = 0;
|
int height = 0;
|
||||||
foreach (auto itemData, wlanList) {
|
foreach (auto itemData, wlanList) {
|
||||||
if (itemData.m_NetSsid == this->m_activatedWlanSSid) { continue; }
|
if (itemData.m_NetSsid == this->m_activatedWlanSSid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
KyWirelessNetItem *data = new KyWirelessNetItem(itemData);
|
KyWirelessNetItem *data = new KyWirelessNetItem(itemData);
|
||||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data);
|
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data);
|
||||||
|
@ -139,7 +141,9 @@ void WlanPage::getAllWlan()
|
||||||
wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height()));
|
wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height()));
|
||||||
m_inactivatedNetListWidget->addItem(wlanItem);
|
m_inactivatedNetListWidget->addItem(wlanItem);
|
||||||
m_inactivatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
m_inactivatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
||||||
if (height == 0) height += wlanItemWidget->height();
|
if (height == 0) {
|
||||||
|
height += wlanItemWidget->height();
|
||||||
|
}
|
||||||
height += wlanItemWidget->height() + NET_LIST_SPACING;
|
height += wlanItemWidget->height() + NET_LIST_SPACING;
|
||||||
}
|
}
|
||||||
m_inactivatedNetListWidget->setFixedHeight(height);
|
m_inactivatedNetListWidget->setFixedHeight(height);
|
||||||
|
|
Loading…
Reference in New Issue