Repository navigation
fix: hide VPN and system proxy switches when no configuration exists - #638
Conversation
Reviewer's GuideThe PR makes VPN and system proxy switches conditional on actual configuration existence without removing the corresponding menu entries, preserves context-specific system proxy visibility semantics, and fixes stale proxy-existence state for PAC and manual proxy updates. Sequence diagram for proxy configuration state updatessequenceDiagram
participant ProxySettings as ProxySettings
participant NetworkProxy as NetworkProxy
participant ProxyController as ProxyController
participant NetManagerThread as NetManagerThread
participant SystemProxyItem as SystemProxyItem
participant SystemProxyPage as SystemProxyPage
ProxySettings->>NetworkProxy: onConfigChanged(key)
NetworkProxy-->>ProxyController: proxyChanged(type, value)
alt type is auto
ProxyController->>ProxyController: queryAutoProxy()
else manual proxy type
ProxyController->>ProxyController: queryProxyDataByType(type)
end
ProxyController-->>NetManagerThread: systemProxyExistChanged(exists)
NetManagerThread->>NetManagerThread: onSystemProxyExistChanged(exists)
NetManagerThread-->>SystemProxyItem: updateenabledable(exists)
SystemProxyItem-->>SystemProxyPage: enabledable
SystemProxyPage->>SystemProxyPage: visible = netItem.enabledable
Flow diagram for VPN switch visibilityflowchart TD
VPNControlItem[VPN control item] --> ConnectionChildren{Has VPN connection children?}
ConnectionChildren -- Yes --> ShowSwitch[Show VPN switch]
ConnectionChildren -- No --> HideSwitch[Hide VPN switch]
VPNControlItem --> OpenPage[Keep VPN page available for add or import]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Add Net_SysProxyEnabledable flag: the enabledable of
NetSystemProxyControlItem now follows whether a system proxy
configuration exists, without affecting whether the menu item
itself is shown (Net_SysProxyAlwaysShow keeps the item always
visible in the control center, see BUG-350619).
2. In NetManagerThreadPrivate::doInit, track systemProxyExistChanged
whenever Net_SysProxyEnabledable is set, and emit the initial
enabledable state.
3. In NetManagerPrivate::onDataChanged DeviceAvailableChanged, only
hide the SystemProxyControlItem via updateItemVisible when
Net_SysProxyAlwaysShow is NOT set; otherwise just update
enabledable. VPNControlItem keeps the existing hide-by-existence
behavior (its children are the VPN connections).
4. In PageSystemProxy.qml, drive the switches' presence with
netItem.enabledable (page: proxyConfigExist ? devCheck : null,
visible: netItem.enabledable) instead of computing existence from
raw proxy data.
5. In PageVPN.qml, only show the VPN switches when the VPN control
item has children (hasVpnConnection).
6. In ProxyController::onProxyChanged, route the "auto" proxyChanged
signal to queryAutoProxy(): the daemon emits proxyChanged("auto",
url) when the PAC URL changes, but queryProxyDataByType only
understands http/https/ftp/socks, so m_autoProxyURL was never
refreshed and systemProxyExist stayed stale.
Log: When there is no VPN connection or no system proxy
configuration, the VPN and system proxy menu entries no longer show
their switches, while the entries themselves remain accessible for
adding/importing VPN connections or configuring the proxy.
Influence:
1. With no VPN connection and no system proxy config, open the
network page: the VPN and system proxy entries show no switch
(arrow only), and both pages can still be opened to add/import
VPN or configure the proxy.
2. Add a VPN connection (nmcli/import): the VPN switch appears in
real time; delete all VPN connections: the switch disappears.
3. Configure a manual proxy (any http/https/ftp/socks host) or a PAC
URL: the system proxy switch appears; clear all proxy values: the
switch disappears (auto PAC and manual host both covered, and the
previously stale autoProxy refresh path is fixed).
4. Dock/lock/greeter: system proxy item visibility still follows
whether a proxy configuration exists (no AlwaysShow flag there),
unchanged behavior vs before this change.
fix: 不存在VPN连接和系统代理配置时隐藏VPN与系统代理开关
1. 新增 Net_SysProxyEnabledable 标志:NetSystemProxyControlItem 的
enabledable 跟随是否存在系统代理配置,且不影响菜单项本身是否显示
(Net_SysProxyAlwaysShow 仍保证控制中心菜单项恒显,见 BUG-350619)。
2. NetManagerThreadPrivate::doInit 中,设置 Net_SysProxyEnabledable
时跟踪 systemProxyExistChanged,并下发初始 enabledable 状态。
3. NetManagerPrivate::onDataChanged 的 DeviceAvailableChanged 分支,
仅当未设置 Net_SysProxyAlwaysShow 时才用 updateItemVisible 隐藏
SystemProxyControlItem;否则只更新 enabledable。VPNControlItem 保留
原有"按是否存在连接子项显隐"的行为。
4. PageSystemProxy.qml 的开关显隐改为由 netItem.enabledable 驱动
(page: proxyConfigExist ? devCheck : null, visible: netItem.enabledable),
不再自行根据原始代理数据计算。
5. PageVPN.qml 仅在 VPN 控制项存在子连接时展示开关(hasVpnConnection)。
6. ProxyController::onProxyChanged 对 "auto" 类型的 proxyChanged 信号
改走 queryAutoProxy():daemon 在 PAC URL 变化时发出的是
proxyChanged("auto", url),而 queryProxyDataByType 只识别
http/https/ftp/socks,导致 m_autoProxyURL 从不刷新、
systemProxyExist 一直停留在旧值。
Log: 不存在VPN连接或系统代理配置时,VPN 与系统代理菜单项不再展示开关,
菜单项本身仍可点开用于添加/导入VPN或配置代理。
Influence:
1. 无VPN连接且无系统代理配置时打开网络页:VPN 与系统代理菜单项不显示
开关(仅箭头),仍可进入页面添加/导入VPN或配置代理。
2. 添加一个VPN连接(nmcli/导入):VPN 开关实时出现;删除全部VPN连接:
开关消失。
3. 配置手动代理(任一 http/https/ftp/socks host)或 PAC URL:系统代理
开关出现;清空全部代理值:开关消失(自动PAC与手动host均覆盖,并修复了
此前 autoProxy 刷新不到位的缺陷)。
4. dock/锁屏/greeter:系统代理项仍按是否存在代理配置显隐(不带
AlwaysShow 标志),行为与改动前一致。
PMS: BUG-378285
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 四维度评分
详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 潜在问题: 分析详情:
2. 代码质量 ✅评价: 代码结构清晰,注释完整 潜在问题:
建议: 代码亮点:
3. 代码性能 ✅评价: 性能良好,资源使用合理 潜在问题: 分析详情:
4. 代码安全 🔒评价: 存在0个安全漏洞
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 安全漏洞详情: 分析详情:
📁 逐文件分析
💡 改进建议代码示例// netmanager.cpp - 建议将复杂条件提取为命名变量
void NetManagerPrivate::onDataChanged(int dataType, const QString &id, const QVariant &value)
{
// ...
NetControlItemPrivate *item = NetItemPrivate::toItem<NetControlItemPrivate>(findItem(id));
if (item) {
item->updateenabledable(value.toBool());
// 提取复杂条件为命名变量,提升可读性
bool isSystemProxy = item->itemType() == NetType::SystemProxyControlItem;
bool canHideSystemProxy = isSystemProxy && !flags().testFlags(NetType::Net_SysProxyAlwaysShow);
bool isVpn = item->itemType() == NetType::VPNControlItem;
if (canHideSystemProxy || isVpn) {
updateItemVisible(item->id(), value.toBool());
return;
}
}
// ...
}📋 审查检查清单
本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, caixr23, mhduiy 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 |
Log: When there is no VPN connection or no system proxy configuration, the VPN and system proxy menu entries no longer show their switches, while the entries themselves remain accessible for adding/importing VPN connections or configuring the proxy.
Influence:
fix: 不存在VPN连接和系统代理配置时隐藏VPN与系统代理开关
Log: 不存在VPN连接或系统代理配置时,VPN 与系统代理菜单项不再展示开关,
菜单项本身仍可点开用于添加/导入VPN或配置代理。
Influence:
PMS: BUG-378285
Summary by Sourcery
Hide VPN and system proxy switches without configurations while keeping their configuration pages accessible and ensuring proxy state updates remain accurate.
Bug Fixes:
Enhancements: