hide ap list when device disable

Change-Id: Ide4214c6bb607c184559a5045cc36d4d065ad894
This commit is contained in:
石博文 2016-07-27 10:53:08 +08:00 committed by Hualet Wang
parent a44c4f8f92
commit a239ca0559
2 changed files with 17 additions and 7 deletions

View File

@ -21,7 +21,7 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent)
centeralLayout->setMargin(0);
setLayout(centeralLayout);
setFixedHeight(20);
setFixedHeight(25);
connect(m_switchBtn, &DSwitchButton::checkedChanged, this, &DeviceControlWidget::deviceEnableChanged);
}

View File

@ -27,6 +27,8 @@ WirelessApplet::WirelessApplet(const QString &devicePath, QWidget *parent)
m_centeralWidget->setLayout(m_centeralLayout);
m_centeralLayout->addWidget(m_controlPanel);
m_centeralLayout->setSpacing(0);
m_centeralLayout->setMargin(0);
setWidget(m_centeralWidget);
setFrameStyle(QFrame::NoFrame);
@ -154,16 +156,23 @@ void WirelessApplet::updateAPList()
delete item;
}
// sort ap list by strength
std::sort(m_apList.begin(), m_apList.end(), std::greater<AccessPoint>());
int avaliableAPCount = 0;
for (auto ap : m_apList)
if (m_networkInter->IsDeviceEnabled(QDBusObjectPath(m_devicePath)))
{
AccessPointWidget *apw = new AccessPointWidget(ap);
m_centeralLayout->addWidget(apw);
// sort ap list by strength
std::sort(m_apList.begin(), m_apList.end(), std::greater<AccessPoint>());
for (auto ap : m_apList)
{
AccessPointWidget *apw = new AccessPointWidget(ap);
m_centeralLayout->addWidget(apw);
++avaliableAPCount;
}
}
const int contentHeight = m_apList.count() * ITEM_HEIGHT + m_controlPanel->height();
const int contentHeight = avaliableAPCount * ITEM_HEIGHT + m_controlPanel->height();
m_centeralWidget->setFixedHeight(contentHeight);
setFixedHeight(std::min(contentHeight, MAX_HEIGHT));
}
@ -171,4 +180,5 @@ void WirelessApplet::updateAPList()
void WirelessApplet::deviceEnableChanged(const bool enable)
{
m_networkInter->EnableDevice(QDBusObjectPath(m_devicePath), enable);
m_updateAPTimer->start();
}