Skip to content

Commit

Permalink
fix: active connection info invalid
Browse files Browse the repository at this point in the history
Change-Id: I96c040230ce47b3a4ccd0ac7a2a90af1dd2883b7
  • Loading branch information
listenerri committed Jul 19, 2018
1 parent af5b7bf commit e55d595
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions plugins/network/item/wirelessitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ WirelessItem::WirelessItem(WirelessDevice *device)
connect(m_device, static_cast<void (NetworkDevice::*) (const QString &statStr) const>(&NetworkDevice::statusChanged), m_refershTimer, static_cast<void (QTimer::*) ()>(&QTimer::start));
connect(static_cast<WirelessDevice *>(m_device), &WirelessDevice::activeApInfoChanged, m_refershTimer, static_cast<void (QTimer::*) ()>(&QTimer::start));
connect(static_cast<WirelessDevice *>(m_device), &WirelessDevice::activeConnectionChanged, m_refershTimer, static_cast<void (QTimer::*) ()>(&QTimer::start));
connect(m_refershTimer, &QTimer::timeout, this, static_cast<void (WirelessItem::*)()>(&WirelessItem::update));
connect(m_refershTimer, &QTimer::timeout, [=] {
if (m_device->status() == NetworkDevice::Activated && static_cast<WirelessDevice *>(m_device)->activeApInfo().isEmpty()) {
Q_EMIT queryActiveConnInfo();
return;
}
update();
});

//QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
init();
Expand Down Expand Up @@ -169,9 +175,7 @@ const QPixmap WirelessItem::iconPix(const Dock::DisplayMode displayMode, const i
if (state == NetworkDevice::Activated)
{
const auto &activeApInfo = static_cast<WirelessDevice *>(m_device)->activeApInfo();
if (activeApInfo.isEmpty()) {
m_refershTimer->start();
} else {
if (!activeApInfo.isEmpty()) {
strength = activeApInfo.value("Strength").toInt();
m_refershTimer->stop();
}
Expand Down
1 change: 1 addition & 0 deletions plugins/network/item/wirelessitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public Q_SLOTS:
void requestDeactiveAP(const QString &devPath) const;
void feedSecret(const QString &connectionPath, const QString &settingName, const QString &password, const bool autoConnect);
void cancelSecret(const QString &connectionPath, const QString &settingName);
void queryActiveConnInfo();

protected:
bool eventFilter(QObject *o, QEvent *e);
Expand Down
3 changes: 3 additions & 0 deletions plugins/network/networkplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ void NetworkPlugin::onDeviceListChanged(const QList<NetworkDevice *> devices)
item = new WirelessItem(static_cast<WirelessDevice *>(device));
wirelessItems.append(static_cast<WirelessItem *>(item));

connect(static_cast<WirelessItem *>(item), &WirelessItem::queryActiveConnInfo,
m_networkWorker, &NetworkWorker::queryActiveConnInfo);
connect(static_cast<WirelessItem *>(item), &WirelessItem::requestActiveAP,
m_networkWorker, &NetworkWorker::activateAccessPoint);
connect(static_cast<WirelessItem *>(item), &WirelessItem::requestDeactiveAP,
Expand All @@ -188,6 +190,7 @@ void NetworkPlugin::onDeviceListChanged(const QList<NetworkDevice *> devices)
static_cast<WirelessItem *>(item), &WirelessItem::onNeedSecrets);
connect(m_networkModel, &NetworkModel::needSecretsFinished,
static_cast<WirelessItem *>(item), &WirelessItem::onNeedSecretsFinished);

m_networkWorker->queryAccessPoints(path);
break;
default:
Expand Down

0 comments on commit e55d595

Please sign in to comment.