mark current active accesspoint as hilight

Change-Id: Iba8ae4a1d7198979e0699d57b37488f073b29042
This commit is contained in:
石博文 2016-07-28 10:46:00 +08:00 committed by Hualet Wang
parent d4d6f58a58
commit 553c666770
4 changed files with 33 additions and 5 deletions

View File

@ -32,7 +32,7 @@ AccessPoint::AccessPoint()
bool AccessPoint::operator==(const AccessPoint &ap) const
{
return m_ssid == ap.m_ssid;
return m_path == ap.m_path;
}
bool AccessPoint::operator>(const AccessPoint &ap) const

View File

@ -6,6 +6,7 @@
AccessPointWidget::AccessPointWidget(const AccessPoint &ap)
: QWidget(nullptr),
m_ap(ap),
m_ssid(new QLabel),
m_securityIcon(new QLabel),
m_strengthIcon(new QLabel)
@ -34,6 +35,19 @@ AccessPointWidget::AccessPointWidget(const AccessPoint &ap)
setLayout(centeralLayout);
}
void AccessPointWidget::setActive(const bool active)
{
if (m_active == active)
return;
m_active = active;
if (m_active)
m_ssid->setStyleSheet("color:#2c8cde;");
else
m_ssid->setStyleSheet("color:white;");
}
void AccessPointWidget::setStrengthIcon(const int strength)
{
if (strength == 100)

View File

@ -13,10 +13,15 @@ class AccessPointWidget : public QWidget
public:
explicit AccessPointWidget(const AccessPoint &ap);
void setActive(const bool active);
private:
void setStrengthIcon(const int strength);
private:
bool m_active;
AccessPoint m_ap;
QLabel *m_ssid;
QLabel *m_securityIcon;
QLabel *m_strengthIcon;

View File

@ -130,14 +130,21 @@ void WirelessApplet::APPropertiesChanged(const QString &devPath, const QString &
if (it == m_apList.end())
return;
if (*it > ap)
*it = ap;
if (m_activeAP == ap)
{
*it = ap;
m_activeAP = ap;
m_updateAPTimer->start();
emit activeAPChanged();
}
// if (*it > ap)
// {
// *it = ap;
// m_activeAP = ap;
// m_updateAPTimer->start();
// emit activeAPChanged();
// }
}
void WirelessApplet::updateAPList()
@ -161,6 +168,8 @@ void WirelessApplet::updateAPList()
for (auto ap : m_apList)
{
AccessPointWidget *apw = new AccessPointWidget(ap);
if (ap == m_activeAP)
apw->setActive(true);
m_centeralLayout->addWidget(apw);
++avaliableAPCount;