add wifi signal

Change-Id: Idbaaa5d482ab96da360e2f7e5651c675b83e2824
This commit is contained in:
石博文 2016-07-27 10:06:14 +08:00 committed by Hualet Wang
parent 0a78fc01ea
commit 69ed8cf322
6 changed files with 47 additions and 1 deletions

View File

@ -48,3 +48,8 @@ int AccessPoint::strength() const
{
return m_strength;
}
bool AccessPoint::secured() const
{
return m_secured;
}

View File

@ -17,6 +17,7 @@ public:
const QString ssid() const;
int strength() const;
bool secured() const;
private:
int m_strength;

View File

@ -6,16 +6,38 @@
AccessPointWidget::AccessPointWidget(const AccessPoint &ap)
: QWidget(nullptr),
m_ssid(new QLabel)
m_ssid(new QLabel),
m_securityIcon(new QLabel),
m_strengthIcon(new QLabel)
{
m_ssid->setText(ap.ssid());
m_ssid->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_ssid->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
m_ssid->setStyleSheet("color:white;");
if (ap.secured())
m_securityIcon->setPixmap(QPixmap(":/wireless/resources/wireless/security.svg"));
else
m_securityIcon->setPixmap(QPixmap(16, 16));
QHBoxLayout *centeralLayout = new QHBoxLayout;
centeralLayout->addWidget(m_securityIcon);
centeralLayout->addSpacing(5);
centeralLayout->addWidget(m_strengthIcon);
centeralLayout->addSpacing(10);
centeralLayout->addWidget(m_ssid);
centeralLayout->setSpacing(0);
centeralLayout->setMargin(0);
setStrengthIcon(ap.strength());
setLayout(centeralLayout);
}
void AccessPointWidget::setStrengthIcon(const int strength)
{
if (strength == 100)
return m_strengthIcon->setPixmap(QPixmap(":/wireless/resources/wireless/wireless-8-symbolic.svg"));
m_strengthIcon->setPixmap(QPixmap(QString(":/wireless/resources/wireless/wireless-%1-symbolic.svg").arg(strength / 10 & ~0x1)));
}

View File

@ -13,8 +13,13 @@ class AccessPointWidget : public QWidget
public:
explicit AccessPointWidget(const AccessPoint &ap);
private:
void setStrengthIcon(const int strength);
private:
QLabel *m_ssid;
QLabel *m_securityIcon;
QLabel *m_strengthIcon;
};
#endif // ACCESSPOINTWIDGET_H

View File

@ -19,5 +19,6 @@
<file>resources/wireless/wireless-6-symbolic.svg</file>
<file>resources/wireless/wireless-8-symbolic.svg</file>
<file>resources/wireless/wirelss-disconnect-symbolic.svg</file>
<file>resources/wireless/security.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 3.8.3 (29802) - http://www.bohemiancoding.com/sketch -->
<title>小锁</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="小锁" fill="#FFFFFF">
<path d="M5.987,11.006 L9.994,11.006 L9.994,9 L5.987,9 L5.987,11.006 Z M7.008,6.74 C7.008,6.341 7.333,6.016 7.732,6.016 L8.283,6.016 C8.683,6.016 9.008,6.341 9.008,6.74 L9.008,8.016 L7.008,8.016 L7.008,6.74 Z M10.459,8 L10,8 L10,6.74 C10,5.789 9.234,5 8.283,5 L7.732,5 C6.781,5 6,5.789 6,6.74 L6,8 L5.557,8 C5.254,8 5,8.261 5,8.565 L5,11.466 C5,11.77 5.254,12 5.557,12 L10.459,12 C10.762,12 11,11.77 11,11.466 L11,8.565 C11,8.261 10.762,8 10.459,8 L10.459,8 Z" id="Page-1"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1009 B