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
9 changes: 8 additions & 1 deletion net-view/operation/netmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ NetManagerPrivate::NetManagerPrivate(NetManager *manager)
, m_autoAddConnection(false)
, m_managerThread(new NetManagerThreadPrivate)
, m_passwordRequestData(nullptr)
, m_supportWireless(false)
, q_ptr(manager)
{
m_root->updateenabled(false);
Expand All @@ -225,6 +226,7 @@ NetManagerPrivate::NetManagerPrivate(NetManager *manager)
connect(q_ptr, &NetManager::languageChange, this, &NetManagerPrivate::retranslateUi);
connect(m_managerThread, &NetManagerThreadPrivate::toControlCenter, q_ptr, &NetManager::toControlCenter, Qt::QueuedConnection);
connect(m_managerThread, &NetManagerThreadPrivate::netCheckAvailableChanged, q_ptr, &NetManager::netCheckAvailableChanged, Qt::QueuedConnection);
connect(m_managerThread, &NetManagerThreadPrivate::supportWirelessChanged, this, &NetManagerPrivate::onSupportWirelessChanged, Qt::QueuedConnection);
}

NetManagerPrivate::~NetManagerPrivate()
Expand Down Expand Up @@ -877,6 +879,11 @@ void NetManagerPrivate::onItemDestroyed(QObject *obj)
m_dataMap.remove(obj->objectName());
}

void NetManagerPrivate::onSupportWirelessChanged(bool supportWireless)
{
m_supportWireless = supportWireless;
Comment on lines +882 to +884
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Wireless support changes don’t update airplane-mode UI when airplane mode is already enabled.

updateAirplaneMode ties NetAirplaneModeTipsItem visibility to enabled && m_supportWireless, but onSupportWirelessChanged only updates m_supportWireless. If wireless support changes while airplane mode is already enabled, the tips item visibility won’t update until airplane mode is toggled again. Consider having onSupportWirelessChanged refresh the relevant item visibility when m_airplaneMode is true.

}

void NetManagerPrivate::setDeviceEnabled(const QString &id, bool enabled)
{
NetItemPrivate *item = findItem(id);
Expand Down Expand Up @@ -1010,7 +1017,7 @@ void NetManagerPrivate::updateAirplaneMode(bool enabled)
Q_Q(NetManager);
Q_EMIT q->airplaneModeChanged(m_airplaneMode);
}
updateItemVisible("NetAirplaneModeTipsItem", enabled);
updateItemVisible("NetAirplaneModeTipsItem", enabled && m_supportWireless);
if (enabled) {
updateItemVisible("NetWirelessDisabledItem", false);
updateItemVisible("NetWiredDisabledItem", false);
Expand Down
2 changes: 2 additions & 0 deletions net-view/operation/private/netmanager_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected Q_SLOTS:
void clearPasswordRequest(const QString &id);
void retranslateUi();
void onItemDestroyed(QObject *obj);
void onSupportWirelessChanged(bool supportWireless);

protected:
void setDeviceEnabled(const QString &id, bool enabled);
Expand Down Expand Up @@ -92,6 +93,7 @@ protected Q_SLOTS:
QString m_showInputId;

int m_deviceCount[DeviceItemCount];
bool m_supportWireless;

NetManager *q_ptr;
Q_DECLARE_PUBLIC(NetManager)
Expand Down
21 changes: 21 additions & 0 deletions net-view/operation/private/netmanagerthreadprivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ NetManagerThreadPrivate::NetManagerThreadPrivate()
, m_netCheckAvailable(false)
, m_isSleeping(false)
, m_showPageTimer(nullptr)
, m_supportWireless(false)
{
moveToThread(m_thread);
m_thread->start();
Expand Down Expand Up @@ -1941,6 +1942,7 @@ void NetManagerThreadPrivate::onDeviceAdded(QList<NetworkDeviceBase *> devices)
}
}
updateDSLEnabledable();
updateSupportWireless();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Wireless support state is only refreshed on add/remove, so the initial value may be wrong until the first device event.

If the system boots with existing wireless devices but no add/remove events occur, m_supportWireless and the UI will stay false indefinitely. To avoid this, initialize the value by calling updateSupportWireless() once during startup, after the thread and NetworkController are ready, so the initial state matches the actual hardware.

}

void NetManagerThreadPrivate::onDeviceRemoved(QList<NetworkDeviceBase *> devices)
Expand All @@ -1953,6 +1955,7 @@ void NetManagerThreadPrivate::onDeviceRemoved(QList<NetworkDeviceBase *> devices
updateDetails();
}
updateDSLEnabledable();
updateSupportWireless();
}

void NetManagerThreadPrivate::onConnectivityChanged()
Expand Down Expand Up @@ -2994,6 +2997,24 @@ NetworkManager::WirelessSecuritySetting::KeyMgmt NetManagerThreadPrivate::getKey
return keyMgmt;
}

void NetManagerThreadPrivate::updateSupportWireless()
{
bool supportWireless = false;
QList<dde::network::NetworkDeviceBase *> devices = NetworkController::instance()->devices();
for (dde::network::NetworkDeviceBase *device : devices) {
if (device->deviceType() != dde::network::DeviceType::Wireless)
continue;

supportWireless = true;
break;
}

if (m_supportWireless != supportWireless) {
m_supportWireless = supportWireless;
Q_EMIT supportWirelessChanged(m_supportWireless);
}
}

NetType::NetDeviceStatus NetManagerThreadPrivate::toNetDeviceStatus(ConnectionStatus status)
{
switch (status) {
Expand Down
4 changes: 4 additions & 0 deletions net-view/operation/private/netmanagerthreadprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@
// clang-format on
void toControlCenter();
void netCheckAvailableChanged(const bool &netCheckAvailable);
void supportWirelessChanged(bool supportWireless);

public Q_SLOTS:

Check warning on line 112 in net-view/operation/private/netmanagerthreadprivate.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.
void setDeviceEnabled(const QString &id, bool enabled);
void requestScan(const QString &id);
void disconnectDevice(const QString &id);
Expand Down Expand Up @@ -257,6 +258,8 @@
QString connectionSuffixNum(const QString &matchConnName, const QString &name = QString(), NetworkManager::Connection *exception = nullptr);
NetworkManager::WirelessSecuritySetting::KeyMgmt getKeyMgmtByAp(NetworkManager::AccessPoint *ap);

void updateSupportWireless();

static NetType::NetDeviceStatus toNetDeviceStatus(ConnectionStatus status);
static NetType::NetConnectionStatus toNetConnectionStatus(ConnectionStatus status);
static NetType::NetDeviceStatus deviceStatus(NetworkDeviceBase *device);
Expand Down Expand Up @@ -290,6 +293,7 @@
QString m_showPageCmd;
QTimer *m_showPageTimer;
QString m_newVPNuuid;
bool m_supportWireless;
};

} // namespace network
Expand Down