repaint if ap status changed

Change-Id: Ie38fbb561228ccd67e18baef99c61728d3bed7f5
This commit is contained in:
石博文 2016-07-28 10:15:53 +08:00 committed by Hualet Wang
parent 636753a99f
commit d4d6f58a58
5 changed files with 24 additions and 3 deletions

View File

@ -56,6 +56,11 @@ NetworkDevice::NetworkState WirelessApplet::wirelessState() const
return m_device.state();
}
int WirelessApplet::activeAPStrgength() const
{
return m_activeAP.strength();
}
void WirelessApplet::init()
{
setDeviceInfo();
@ -191,7 +196,7 @@ void WirelessApplet::deviceStateChanegd()
const QJsonObject info = wireless.toObject();
if (info.value("Path") == m_device.path())
{
NetworkDevice prevInfo = m_device;
const NetworkDevice prevInfo = m_device;
m_device = NetworkDevice(NetworkDevice::Wireless, info);
if (prevInfo.state() != m_device.state())

View File

@ -19,6 +19,7 @@ public:
explicit WirelessApplet(const QSet<NetworkDevice>::const_iterator &deviceIter, QWidget *parent = 0);
NetworkDevice::NetworkState wirelessState() const;
int activeAPStrgength() const;
signals:
void wirelessStateChanged(const NetworkDevice::NetworkState state) const;

View File

@ -43,8 +43,20 @@ void WirelessItem::resizeEvent(QResizeEvent *e)
const QPixmap WirelessItem::iconPix(const Dock::DisplayMode displayMode, const int size)
{
QString type;
if (m_applet->wirelessState() != NetworkDevice::Activated)
type = "disconnect";
else
{
const int strength = m_applet->activeAPStrgength();
if (strength == 100)
type = "8";
else
type = QString::number(strength / 10 & ~0x1);
}
const QString key = QString("wireless-%1%2")
.arg(8)
.arg(type)
.arg(displayMode == Dock::Fashion ? "" : "-symbolic");
return cachedPix(key, size);
@ -69,4 +81,7 @@ void WirelessItem::init()
m_applet = new WirelessApplet(devInfo, this);
m_applet->setVisible(false);
connect(m_applet, &WirelessApplet::activeAPChanged, this, static_cast<void (WirelessItem::*)()>(&WirelessItem::update));
connect(m_applet, &WirelessApplet::wirelessStateChanged, this, static_cast<void (WirelessItem::*)()>(&WirelessItem::update));
}

View File

@ -18,7 +18,7 @@
<file>resources/wireless/wireless-4-symbolic.svg</file>
<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/wireless-disconnect-symbolic.svg</file>
<file>resources/wireless/security.svg</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 953 B

After

Width:  |  Height:  |  Size: 953 B