Skip to content

Commit 9f67655

Browse files
committed
feat: refactor network device status display and CMake version
Updated CMake minimum version requirement from 3.7 to 3.23 in main CMakeLists.txt Removed redundant cmake_minimum_required declarations from subdirectory CMakeLists files Added new DeviceStatusItem.qml component to centralize device status display logic Moved getStatusName function from NetUtils.js to DeviceStatusItem.qml for better encapsulation Refactored PageWiredDevice.qml and PageWirelessDevice.qml to use new DeviceStatusItem component Moved band configuration from SectionDevice.qml to SectionGeneric.qml for better organization Fixed PageDetails.qml layout structure by moving body container to proper position Removed debug console.log statements from NetUtils.js Log: Improved network device status display with unified component and better layout structure Influence: 1. Test wired and wireless device status display in network settings 2. Verify device enable/disable toggle functionality 3. Check band selection for wireless connections in network configuration 4. Test network details page layout and copy functionality 5. Verify DSL settings configuration with band parameter 6. Test network connection status display for various states (connected, disconnected, etc) feat: 重构网络设备状态显示和 CMake 版本 将主 CMakeLists.txt 中的 CMake 最低版本要求从 3.7 更新到 3.23 从子目录的 CMakeLists 文件中移除冗余的 cmake_minimum_required 声明 新增 DeviceStatusItem.qml 组件来集中管理设备状态显示逻辑 将 getStatusName 函数从 NetUtils.js 移至 DeviceStatusItem.qml 以实现更好 的封装 重构 PageWiredDevice.qml 和 PageWirelessDevice.qml 以使用新的 DeviceStatusItem 组件 将频段配置从 SectionDevice.qml 移至 SectionGeneric.qml 以优化组织结构 修复 PageDetails.qml 布局结构,将 body 容器移动到正确位置 移除 NetUtils.js 中的调试 console.log 语句 Log: 使用统一组件和更好的布局结构改进了网络设备状态显示 Influence: 1. 测试网络设置中有线和无线设备状态显示 2. 验证设备启用/禁用切换功能 3. 检查无线连接配置中的频段选择功能 4. 测试网络详情页面布局和复制功能 5. 验证包含频段参数的 DSL 设置配置 6. 测试各种状态(已连接、已断开等)的网络连接状态显示
1 parent 2097c72 commit 9f67655

20 files changed

Lines changed: 254 additions & 235 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.7)
1+
cmake_minimum_required(VERSION 3.23)
22

33
set(VERSION "2.0.18" CACHE STRING "define project version")
44
project(dde-network-core

dcc-network-plugin/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cmake_minimum_required(VERSION 3.7)
21

32
set(PLUGIN_NAME "dcc-network-plugin")
43

dcc-network/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cmake_minimum_required(VERSION 3.7)
21

32
set(PLUGIN_NAME "dcc-network-plugin")
43

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
import QtQuick 2.15
4+
import QtQuick.Controls 2.15
5+
import QtQuick.Layouts 1.15
6+
import org.deepin.dtk 1.0 as D
7+
import org.deepin.dcc 1.0
8+
import org.deepin.dcc.network 1.0
9+
10+
RowLayout {
11+
id: root
12+
property var netItem: null
13+
property bool connectedNameVisible: false
14+
property alias statusVisible: loader.active
15+
16+
function getStatusName(status) {
17+
switch (status) {
18+
case NetType.DS_Disabled:
19+
return qsTr("Off")
20+
case NetType.DS_Connected:
21+
case NetType.DS_ConnectNoInternet:
22+
return qsTr("Connected")
23+
case NetType.DS_IpConflicted:
24+
return qsTr("IP conflict")
25+
case NetType.DS_Connecting:
26+
return qsTr("Connecting")
27+
case NetType.DS_ObtainingIP:
28+
return qsTr("Obtaining address")
29+
case NetType.DS_Authenticating:
30+
return qsTr("Authenticating")
31+
case NetType.DS_ObtainIpFailed:
32+
case NetType.DS_ConnectFailed:
33+
case NetType.DS_Unknown:
34+
case NetType.DS_Enabled:
35+
case NetType.DS_NoCable:
36+
case NetType.DS_Disconnected:
37+
default:
38+
return qsTr("Disconnected")
39+
}
40+
}
41+
Loader {
42+
id: loader
43+
sourceComponent: DccLabel {
44+
text: {
45+
if (connectedNameVisible) {
46+
switch (netItem.status) {
47+
case NetType.DS_Connected:
48+
case NetType.DS_ConnectNoInternet:
49+
var childrenItem = [netItem]
50+
while (childrenItem.length > 0) {
51+
var childItem = childrenItem.pop()
52+
if (childItem.status === NetType.CS_Connected) {
53+
return childItem.name
54+
}
55+
for (let i in childItem.children) {
56+
childrenItem.push(childItem.children[i])
57+
}
58+
}
59+
break
60+
default:
61+
break
62+
}
63+
}
64+
return getStatusName(netItem.status)
65+
}
66+
}
67+
}
68+
D.Switch {
69+
checked: root.netItem.isEnabled
70+
enabled: root.netItem.enabledable
71+
onClicked: {
72+
dccData.exec(root.netItem.isEnabled ? NetManager.DisabledDevice : NetManager.EnabledDevice, root.netItem.id, {})
73+
}
74+
}
75+
}

dcc-network/qml/NetUtils.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function numToIp(num) {
6969
}
7070

7171
function ipToNum(ip) {
72-
console.log("ipToNum----", ip, typeof ip)
7372
const ips = ip.split('.')
7473
let cidr = 0
7574
let ipNum = 0
@@ -174,29 +173,3 @@ function strToByteArray(data) {
174173
}
175174
return undefined
176175
}
177-
178-
function getStatusName(status) {
179-
switch (status) {
180-
case NetType.DS_Disabled:
181-
return qsTr("Off")
182-
case NetType.DS_Connected:
183-
case NetType.DS_ConnectNoInternet:
184-
return qsTr("Connected")
185-
case NetType.DS_IpConflicted:
186-
return qsTr("IP conflict")
187-
case NetType.DS_Connecting:
188-
return qsTr("Connecting")
189-
case NetType.DS_ObtainingIP:
190-
return qsTr("Obtaining address")
191-
case NetType.DS_Authenticating:
192-
return qsTr("Authenticating")
193-
case NetType.DS_ObtainIpFailed:
194-
case NetType.DS_ConnectFailed:
195-
case NetType.DS_Unknown:
196-
case NetType.DS_Enabled:
197-
case NetType.DS_NoCable:
198-
case NetType.DS_Disconnected:
199-
default:
200-
return qsTr("Disconnected")
201-
}
202-
}

dcc-network/qml/PageDSLSettings.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ DccObject {
8989
sectionDNS.setConfig(combinedDns.length > 0 ? combinedDns : null)
9090
sectionDevice.setConfig(config["802-3-ethernet"])
9191
sectionPPP.setConfig(config["ppp"])
92+
sectionGeneric.band = config["802-3-ethernet"].band
9293
modified = config.connection.uuid === "{00000000-0000-0000-0000-000000000000}"
9394
}
9495

@@ -235,6 +236,11 @@ DccObject {
235236
if (devConfig.interfaceName.length !== 0) {
236237
nConfig["pppoe"]["parent"] = devConfig.interfaceName
237238
}
239+
if (sectionGeneric.band) {
240+
devConfig["band"] = sectionGeneric.band
241+
} else {
242+
delete devConfig["band"]
243+
}
238244
nConfig["connection"]["interface-name"] = devConfig.interfaceName
239245
nConfig["802-3-ethernet"] = devConfig
240246
nConfig["ppp"] = sectionPPP.getConfig()

0 commit comments

Comments
 (0)