fix: Fix airplane mode tips display logic#493
fix: Fix airplane mode tips display logic#493deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's GuideAdds tracking of whether any wireless devices are present and uses this state to only display the airplane mode tips when airplane mode is enabled and wireless is supported, wiring the new flag through the NetManager thread and private manager classes. Sequence diagram for updating airplane mode tips visibility based on wireless supportsequenceDiagram
participant NetManager as NetManager
participant NetManagerPrivate as NetManagerPrivate
participant ManagerThread as NetManagerThreadPrivate
participant NetworkController as NetworkController
participant Device as NetworkDeviceBase
Note over ManagerThread,NetworkController: Wireless support tracking
ManagerThread->>NetworkController: devices()
NetworkController-->>ManagerThread: QList<NetworkDeviceBase*>
loop ForEachDevice
ManagerThread->>Device: deviceType()
alt Device is wireless
ManagerThread-->ManagerThread: supportWireless = true
ManagerThread->>ManagerThread: break
end
end
alt supportWireless state changed
ManagerThread-->>NetManagerPrivate: supportWirelessChanged(supportWireless)
NetManagerPrivate->>NetManagerPrivate: onSupportWirelessChanged(supportWireless)
NetManagerPrivate-->NetManagerPrivate: m_supportWireless = supportWireless
end
Note over NetManager,NetManagerPrivate: Airplane mode tips visibility
NetManager->>NetManagerPrivate: updateAirplaneMode(enabled)
NetManagerPrivate->>NetManagerPrivate: m_airplaneMode = enabled
NetManagerPrivate-->>NetManager: airplaneModeChanged(m_airplaneMode)
NetManagerPrivate->>NetManagerPrivate: updateItemVisible(NetAirplaneModeTipsItem, enabled && m_supportWireless)
Updated class diagram for NetManagerThreadPrivate and NetManagerPrivate wireless support trackingclassDiagram
class NetManagerThreadPrivate {
+NetManagerThreadPrivate()
+void onDeviceAdded(QList<NetworkDeviceBase*> devices)
+void onDeviceRemoved(QList<NetworkDeviceBase*> devices)
+void onConnectivityChanged()
+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)
+void toControlCenter()
+void netCheckAvailableChanged(const bool& netCheckAvailable)
+void supportWirelessChanged(bool supportWireless)
-QString m_showPageCmd
-QTimer* m_showPageTimer
-QString m_newVPNuuid
-bool m_supportWireless
}
class NetManagerPrivate {
+NetManagerPrivate(NetManager* manager)
+~NetManagerPrivate()
+void updateAirplaneMode(bool enabled)
+void onItemDestroyed(QObject* obj)
+void onSupportWirelessChanged(bool supportWireless)
+void setDeviceEnabled(const QString& id, bool enabled)
+void clearPasswordRequest(const QString& id)
+void retranslateUi()
-bool m_airplaneMode
-bool m_autoAddConnection
-NetManagerThreadPrivate* m_managerThread
-void* m_passwordRequestData
-int m_deviceCount[DeviceItemCount]
-bool m_supportWireless
-NetManager* q_ptr
}
class NetManager {
+void airplaneModeChanged(bool airplaneMode)
}
NetManagerPrivate --> NetManagerThreadPrivate : uses
NetManagerThreadPrivate --> NetManagerPrivate : supportWirelessChanged(bool)
NetManagerPrivate --> NetManager : airplaneModeChanged(bool)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- When wireless support changes while airplane mode is already enabled, the visibility of
NetAirplaneModeTipsItemwill not update because it’s only toggled inupdateAirplaneMode; consider updating the item visibility inonSupportWirelessChanged(e.g., reusingm_airplaneModethere) to keep the UI in sync. - You only recalculate
m_supportWirelessinonDeviceAdded/onDeviceRemoved; if the initial device list is available at startup, consider callingupdateSupportWireless()once after the initial device enumeration to ensure the tip state is correct from the beginning.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When wireless support changes while airplane mode is already enabled, the visibility of `NetAirplaneModeTipsItem` will not update because it’s only toggled in `updateAirplaneMode`; consider updating the item visibility in `onSupportWirelessChanged` (e.g., reusing `m_airplaneMode` there) to keep the UI in sync.
- You only recalculate `m_supportWireless` in `onDeviceAdded`/`onDeviceRemoved`; if the initial device list is available at startup, consider calling `updateSupportWireless()` once after the initial device enumeration to ensure the tip state is correct from the beginning.
## Individual Comments
### Comment 1
<location> `net-view/operation/private/netmanagerthreadprivate.cpp:1945` </location>
<code_context>
}
}
updateDSLEnabledable();
+ updateSupportWireless();
}
</code_context>
<issue_to_address>
**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.
</issue_to_address>
### Comment 2
<location> `net-view/operation/netmanager.cpp:882-884` </location>
<code_context>
m_dataMap.remove(obj->objectName());
}
+void NetManagerPrivate::onSupportWirelessChanged(bool supportWireless)
+{
+ m_supportWireless = supportWireless;
+}
+
</code_context>
<issue_to_address>
**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.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
| } | ||
| updateDSLEnabledable(); | ||
| updateSupportWireless(); |
There was a problem hiding this comment.
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 NetManagerPrivate::onSupportWirelessChanged(bool supportWireless) | ||
| { | ||
| m_supportWireless = supportWireless; |
There was a problem hiding this comment.
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.
|
|
||
| if (m_supportWireless != supportWireless) { | ||
| m_supportWireless = supportWireless; | ||
| emit supportWirelessChanged(m_supportWireless); |
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
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, ut003640 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review这份代码的改动主要实现了检测系统是否支持无线网络功能,并根据此状态控制"飞行模式提示项"的显示逻辑。整体来看,代码逻辑清晰,能够实现预期功能。以下是对语法逻辑、代码质量、代码性能和代码安全方面的详细审查及改进意见: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 综合改进建议
总结代码改动逻辑正确,线程安全处理得当,性能影响极小。主要建议是增加空指针检查以提高鲁棒性,并确认初始化时的状态同步时序。整体质量较高。 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
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
Summary by Sourcery
Ensure airplane mode tips are only shown when airplane mode is enabled and wireless networking is supported.
Bug Fixes:
Enhancements: