Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net-view/operation/netmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ void NetManagerPrivate::updateAirplaneMode(bool enabled)
Q_Q(NetManager);
Q_EMIT q->airplaneModeChanged(m_airplaneMode);
}
updateItemVisible("NetAirplaneModeTipsItem", enabled);
updateItemVisible("NetAirplaneModeTipsItem", enabled && m_managerThread->supportWireless());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

netmanager.cpp在主线程中,m_managerThread在子线程中,不要直接调用。
使用缓存,有变化时信号更新

if (enabled) {
updateItemVisible("NetWirelessDisabledItem", false);
updateItemVisible("NetWiredDisabledItem", false);
Expand Down
19 changes: 12 additions & 7 deletions net-view/operation/private/netmanagerthreadprivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ bool NetManagerThreadPrivate::CheckPasswordValid(const QString &key, const QStri
return !password.isEmpty();
}

bool NetManagerThreadPrivate::supportWireless() const
{
NetworkManager::Device::List devices = NetworkManager::networkInterfaces();
for (NetworkManager::Device::Ptr device : devices) {
if (device->type() == NetworkManager::Device::Type::Wifi && device->managed())
return true;
}

return false;
}

void NetManagerThreadPrivate::getNetCheckAvailableFromDBus()
{
QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.defender.netcheck", "/com/deepin/defender/netcheck", "org.freedesktop.DBus.Properties", "Get");
Expand Down Expand Up @@ -861,13 +872,7 @@ bool NetManagerThreadPrivate::supportAirplaneMode() const
}
}

NetworkManager::Device::List devices = NetworkManager::networkInterfaces();
for (NetworkManager::Device::Ptr device : devices) {
if (device->type() == NetworkManager::Device::Type::Wifi && device->managed())
return true;
}

return false;
return supportWireless();
}

void NetManagerThreadPrivate::doConnectOrInfo(const QString &id, NetType::NetItemType type, const QVariantMap &param)
Expand Down
2 changes: 2 additions & 0 deletions net-view/operation/private/netmanagerthreadprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class NetManagerThreadPrivate : public QObject

inline bool AirplaneModeEnabled() const { return m_airplaneModeEnabled; }

bool supportWireless() const;

void setEnabled(bool enabled);
void setAutoScanInterval(int ms);
void setAutoScanEnabled(bool enabled);
Expand Down