Skip to content

Commit 0c73dd1

Browse files
ut003640deepin-bot[bot]
authored andcommitted
fix: Fix airplane mode tips display logic
Fix the logic for displaying airplane mode tips by adding wireless support check. Only show the tips when airplane mode is enabled AND wireless is supported. Log: Fixed airplane mode tips display condition PMS: BUG-349721 fix: 修复飞行模式提示显示逻辑 修复飞行模式提示的显示逻辑,增加无线支持检查。仅在飞行模式启用且支持无线功能时显示提示。 Log: 修复飞行模式提示显示条件 PMS: BUG-349721
1 parent d3aee5c commit 0c73dd1

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

net-view/operation/netmanager.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ NetManagerPrivate::NetManagerPrivate(NetManager *manager)
204204
, m_autoAddConnection(false)
205205
, m_managerThread(new NetManagerThreadPrivate)
206206
, m_passwordRequestData(nullptr)
207+
, m_supportWireless(false)
207208
, q_ptr(manager)
208209
{
209210
m_root->updateenabled(false);
@@ -225,6 +226,7 @@ NetManagerPrivate::NetManagerPrivate(NetManager *manager)
225226
connect(q_ptr, &NetManager::languageChange, this, &NetManagerPrivate::retranslateUi);
226227
connect(m_managerThread, &NetManagerThreadPrivate::toControlCenter, q_ptr, &NetManager::toControlCenter, Qt::QueuedConnection);
227228
connect(m_managerThread, &NetManagerThreadPrivate::netCheckAvailableChanged, q_ptr, &NetManager::netCheckAvailableChanged, Qt::QueuedConnection);
229+
connect(m_managerThread, &NetManagerThreadPrivate::supportWirelessChanged, this, &NetManagerPrivate::onSupportWirelessChanged, Qt::QueuedConnection);
228230
}
229231

230232
NetManagerPrivate::~NetManagerPrivate()
@@ -877,6 +879,11 @@ void NetManagerPrivate::onItemDestroyed(QObject *obj)
877879
m_dataMap.remove(obj->objectName());
878880
}
879881

882+
void NetManagerPrivate::onSupportWirelessChanged(bool supportWireless)
883+
{
884+
m_supportWireless = supportWireless;
885+
}
886+
880887
void NetManagerPrivate::setDeviceEnabled(const QString &id, bool enabled)
881888
{
882889
NetItemPrivate *item = findItem(id);
@@ -1010,7 +1017,7 @@ void NetManagerPrivate::updateAirplaneMode(bool enabled)
10101017
Q_Q(NetManager);
10111018
Q_EMIT q->airplaneModeChanged(m_airplaneMode);
10121019
}
1013-
updateItemVisible("NetAirplaneModeTipsItem", enabled);
1020+
updateItemVisible("NetAirplaneModeTipsItem", enabled && m_supportWireless);
10141021
if (enabled) {
10151022
updateItemVisible("NetWirelessDisabledItem", false);
10161023
updateItemVisible("NetWiredDisabledItem", false);

net-view/operation/private/netmanager_p.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected Q_SLOTS:
6161
void clearPasswordRequest(const QString &id);
6262
void retranslateUi();
6363
void onItemDestroyed(QObject *obj);
64+
void onSupportWirelessChanged(bool supportWireless);
6465

6566
protected:
6667
void setDeviceEnabled(const QString &id, bool enabled);
@@ -92,6 +93,7 @@ protected Q_SLOTS:
9293
QString m_showInputId;
9394

9495
int m_deviceCount[DeviceItemCount];
96+
bool m_supportWireless;
9597

9698
NetManager *q_ptr;
9799
Q_DECLARE_PUBLIC(NetManager)

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ NetManagerThreadPrivate::NetManagerThreadPrivate()
9898
, m_netCheckAvailable(false)
9999
, m_isSleeping(false)
100100
, m_showPageTimer(nullptr)
101+
, m_supportWireless(false)
101102
{
102103
moveToThread(m_thread);
103104
m_thread->start();
@@ -1941,6 +1942,7 @@ void NetManagerThreadPrivate::onDeviceAdded(QList<NetworkDeviceBase *> devices)
19411942
}
19421943
}
19431944
updateDSLEnabledable();
1945+
updateSupportWireless();
19441946
}
19451947

19461948
void NetManagerThreadPrivate::onDeviceRemoved(QList<NetworkDeviceBase *> devices)
@@ -1953,6 +1955,7 @@ void NetManagerThreadPrivate::onDeviceRemoved(QList<NetworkDeviceBase *> devices
19531955
updateDetails();
19541956
}
19551957
updateDSLEnabledable();
1958+
updateSupportWireless();
19561959
}
19571960

19581961
void NetManagerThreadPrivate::onConnectivityChanged()
@@ -2994,6 +2997,24 @@ NetworkManager::WirelessSecuritySetting::KeyMgmt NetManagerThreadPrivate::getKey
29942997
return keyMgmt;
29952998
}
29962999

3000+
void NetManagerThreadPrivate::updateSupportWireless()
3001+
{
3002+
bool supportWireless = false;
3003+
QList<dde::network::NetworkDeviceBase *> devices = NetworkController::instance()->devices();
3004+
for (dde::network::NetworkDeviceBase *device : devices) {
3005+
if (device->deviceType() != dde::network::DeviceType::Wireless)
3006+
continue;
3007+
3008+
supportWireless = true;
3009+
break;
3010+
}
3011+
3012+
if (m_supportWireless != supportWireless) {
3013+
m_supportWireless = supportWireless;
3014+
Q_EMIT supportWirelessChanged(m_supportWireless);
3015+
}
3016+
}
3017+
29973018
NetType::NetDeviceStatus NetManagerThreadPrivate::toNetDeviceStatus(ConnectionStatus status)
29983019
{
29993020
switch (status) {

net-view/operation/private/netmanagerthreadprivate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class NetManagerThreadPrivate : public QObject
107107
// clang-format on
108108
void toControlCenter();
109109
void netCheckAvailableChanged(const bool &netCheckAvailable);
110+
void supportWirelessChanged(bool supportWireless);
110111

111112
public Q_SLOTS:
112113
void setDeviceEnabled(const QString &id, bool enabled);
@@ -257,6 +258,8 @@ protected Q_SLOTS:
257258
QString connectionSuffixNum(const QString &matchConnName, const QString &name = QString(), NetworkManager::Connection *exception = nullptr);
258259
NetworkManager::WirelessSecuritySetting::KeyMgmt getKeyMgmtByAp(NetworkManager::AccessPoint *ap);
259260

261+
void updateSupportWireless();
262+
260263
static NetType::NetDeviceStatus toNetDeviceStatus(ConnectionStatus status);
261264
static NetType::NetConnectionStatus toNetConnectionStatus(ConnectionStatus status);
262265
static NetType::NetDeviceStatus deviceStatus(NetworkDeviceBase *device);
@@ -290,6 +293,7 @@ protected Q_SLOTS:
290293
QString m_showPageCmd;
291294
QTimer *m_showPageTimer;
292295
QString m_newVPNuuid;
296+
bool m_supportWireless;
293297
};
294298

295299
} // namespace network

0 commit comments

Comments
 (0)