Skip to content

Conversation

@caixr23
Copy link
Contributor

@caixr23 caixr23 commented Feb 3, 2026

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. 测试各种状态(已连接、已断开等)的网络连接状态显示

Summary by Sourcery

Refactor network device status presentation and band configuration handling while updating the project’s CMake version requirements.

New Features:

  • Introduce a reusable DeviceStatusItem QML component to centralize network device status display and enable/disable toggling.

Bug Fixes:

  • Correct the PageDetails layout hierarchy so the body container is defined in the proper position, ensuring details rendering and copy behavior work as intended.

Enhancements:

  • Update the minimum CMake requirement to 3.23 and remove redundant cmake_minimum_required declarations from subdirectory CMakeLists files.
  • Move wireless band configuration from SectionDevice to SectionGeneric and propagate the band setting through settings and DSL pages for more consistent handling across connection types.
  • Encapsulate status name mapping within the new DeviceStatusItem component and clean up NetUtils by removing the obsolete helper and debug logging.

Build:

  • Raise the top-level CMake minimum version from 3.7 to 3.23 and rely on it across subprojects by dropping local cmake_minimum_required calls.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 3, 2026

Reviewer's Guide

Refactors network device status presentation into a reusable QML component, centralizes wireless band configuration handling, fixes the details page layout hierarchy, and simplifies CMake configuration by enforcing a higher global minimum version and removing redundant per-directory declarations.

Sequence diagram for unified device enable toggle via DeviceStatusItem

sequenceDiagram
    actor User
    participant PageDevice as PageWiredOrWirelessDevice
    participant DeviceStatusItem
    participant D_Switch as D_Switch
    participant dccData
    participant NetManager
    participant NetworkBackend

    User->>PageDevice: Open device page
    PageDevice->>DeviceStatusItem: Instantiate with netItem
    activate DeviceStatusItem
    DeviceStatusItem->>D_Switch: Bind checked to netItem.isEnabled
    DeviceStatusItem->>D_Switch: Bind enabled to netItem.enabledable
    deactivate DeviceStatusItem

    User->>D_Switch: Click toggle
    D_Switch->>DeviceStatusItem: onClicked()
    alt netItem.isEnabled is true
        DeviceStatusItem->>dccData: exec(NetManager.DisabledDevice, netItem.id, {})
    else netItem.isEnabled is false
        DeviceStatusItem->>dccData: exec(NetManager.EnabledDevice, netItem.id, {})
    end
    dccData->>NetManager: Execute enable/disable command
    NetManager->>NetworkBackend: Apply device state change
    NetworkBackend-->>NetManager: State updated
    NetManager-->>PageDevice: netItem.status and isEnabled updated
    PageDevice->>DeviceStatusItem: netItem property updated
    DeviceStatusItem->>D_Switch: Update checked state
    DeviceStatusItem->>DeviceStatusItem: Recompute status text via getStatusName()
Loading

Updated class diagram for QML components around device status and band configuration

classDiagram
    class DeviceStatusItem {
        <<QML_Component>>
        +var netItem
        +bool connectedNameVisible
        +alias statusVisible
        +getStatusName(status)
    }

    class PageWiredDevice {
        <<QML_Page>>
        +var netItem
        +string name
        +string parentName
        +string displayName
        +string icon
        +int weight
        +int pageType
    }

    class PageWirelessDevice {
        <<QML_Page>>
        +var netItem
        +var airplaneItem
        +var c_levelString
        +string name
        +string parentName
        +string displayName
        +string icon
        +int weight
        +int pageType
    }

    class SectionDevice {
        <<QML_Section>>
        +var config
        +string parentName
        +string type
        +setConfig(config)
        +getConfig() var
    }

    class SectionGeneric {
        <<QML_Section>>
        +var config
        +string settingsID
        +var band
        +string errorKey
        +editClicked()
    }

    class PageSettings {
        <<QML_Page>>
        +var config
        +bool modified
        +setConfig(config)
        +saveConfig()
    }

    class PageDSLSettings {
        <<QML_Page>>
        +var config
        +bool modified
        +setConfig(config)
        +saveConfig()
    }

    class NetUtils {
        <<JS_Module>>
        +numToIp(num)
        +ipToNum(ip)
        +strToByteArray(data)
        -getStatusName(status) removed
    }

    PageWiredDevice *-- DeviceStatusItem : uses_as_main_page
    PageWiredDevice *-- DeviceStatusItem : uses_in_details_item

    PageWirelessDevice *-- DeviceStatusItem : uses_as_main_page
    PageWirelessDevice *-- DeviceStatusItem : uses_in_details_item

    PageSettings o-- SectionDevice : configures
    PageSettings o-- SectionGeneric : configures

    PageDSLSettings o-- SectionDevice : configures
    PageDSLSettings o-- SectionGeneric : configures

    SectionDevice ..> SectionGeneric : band_moved_out

    NetUtils ..> DeviceStatusItem : getStatusName_moved_here
Loading

Flow diagram for wireless band configuration through SectionGeneric

flowchart LR
    A_PageSettings["PageSettings.qml<br/>load existing connection config"] --> B_sectionDevice_setConfig["sectionDevice.setConfig(config[connection.type])"]
    A_PageSettings --> C_set_band_to_SectionGeneric["sectionGeneric.band = config[connection.type].band"]

    A_DSLSettings["PageDSLSettings.qml<br/>load DSL config"] --> D_sectionDevice_setConfig_dsl["sectionDevice.setConfig(config[802-3-ethernet])"]
    A_DSLSettings --> E_set_band_to_SectionGeneric_dsl["sectionGeneric.band = config[802-3-ethernet].band"]

    C_set_band_to_SectionGeneric --> F_SectionGeneric_band["SectionGeneric.qml<br/>property band"]
    E_set_band_to_SectionGeneric_dsl --> F_SectionGeneric_band

    F_SectionGeneric_band --> G_BandEditor["Band DccObject + ComboBox<br/>currentIndex = indexOfValue(root.band)"]
    G_BandEditor --> H_User_selects_band["User selects Auto / 2.4GHz / 5GHz"]
    H_User_selects_band --> I_update_band_property["onActivated: root.band = currentValue<br/>root.editClicked()"]

    I_update_band_property --> J_save_from_PageSettings["PageSettings save handler"]
    I_update_band_property --> K_save_from_PageDSLSettings["PageDSLSettings save handler"]

    J_save_from_PageSettings --> L_devConfig_getConfig["devConfig = sectionDevice.getConfig()"]
    L_devConfig_getConfig --> M_apply_band_normal["If sectionGeneric.band<br/>devConfig.band = sectionGeneric.band<br/>else delete devConfig.band"]
    M_apply_band_normal --> N_write_back_normal["nConfig[connection.type] = devConfig"]

    K_save_from_PageDSLSettings --> O_devConfig_getConfig_dsl["devConfig = sectionDevice.getConfig()"]
    O_devConfig_getConfig_dsl --> P_apply_band_dsl["If sectionGeneric.band<br/>devConfig.band = sectionGeneric.band<br/>else delete devConfig.band"]
    P_apply_band_dsl --> Q_write_back_dsl["nConfig[802-3-ethernet] = devConfig"]
Loading

Flow diagram for PageDetails layout restructuring

flowchart LR
    A_root_DccObject["PageDetails root DccObject"] --> B_body_DccObject_new["New body DccObject<br/>name = body<br/>parentName = root.name"]
    B_body_DccObject_new --> C_DccRepeater["DccRepeater<br/>model NetItemModel"]
    C_DccRepeater --> D_info_DccObject["Per item DccObject<br/>name = infoItem.name<br/>parentName = root.name + /body"]
    D_info_DccObject --> E_title_DccObject["title DccObject<br/>RowLayout with label + copy icon"]
    D_info_DccObject --> F_details_DccObject["details DccObject<br/>ColumnLayout of ItemDelegate rows"]

    subgraph Previous_structure
        G_old_DccRepeater["Old DccRepeater at root level"] --> H_old_info_DccObject["info DccObject children"]
        H_old_info_DccObject --> I_old_title_DccObject
        H_old_info_DccObject --> J_old_details_DccObject
        K_old_body_placeholder["body DccObject declared after repeater"]
    end

    subgraph New_structure
        B_body_DccObject_new
        C_DccRepeater
        D_info_DccObject
        E_title_DccObject
        F_details_DccObject
    end

    K_old_body_placeholder -.replaced_by.-> B_body_DccObject_new
Loading

File-Level Changes

Change Details Files
Centralize device status UI and logic into a reusable QML component and apply it to wired/wireless device pages.
  • Introduce DeviceStatusItem.qml encapsulating status label, connected-name resolution, and enable/disable switch behavior.
  • Move getStatusName logic from NetUtils.js into DeviceStatusItem, localizing status string mapping to the UI component.
  • Replace inline status RowLayout and DevCheck components in PageWiredDevice.qml and PageWirelessDevice.qml with DeviceStatusItem uses, configuring visibility flags as needed.
dcc-network/qml/DeviceStatusItem.qml
dcc-network/qml/PageWiredDevice.qml
dcc-network/qml/PageWirelessDevice.qml
dcc-network/qml/NetUtils.js
Fix PageDetails layout by properly nesting the body container and preserving existing behavior.
  • Wrap the NetItemModel repeater and its delegates inside a DccObject named body attached directly under the page root.
  • Adjust parentName paths for title and details objects to reflect the new body hierarchy while keeping copying and details display logic intact.
  • Ensure padding adjustments and item delegate layout remain unchanged inside the new structure.
dcc-network/qml/PageDetails.qml
Move wireless band configuration from the device section into the generic section and propagate it through settings and DSL pages.
  • Remove the band ComboBox DccObject from SectionDevice and reimplement it inside SectionGeneric with a dedicated band property.
  • Bind SectionGeneric.band to the current connection's band in PageSettings and PageDSLSettings when loading configurations.
  • On save, merge SectionGeneric.band into the device config for both standard and DSL settings, deleting the band key when unset.
dcc-network/qml/SectionDevice.qml
dcc-network/qml/SectionGeneric.qml
dcc-network/qml/PageSettings.qml
dcc-network/qml/PageDSLSettings.qml
Simplify CMake configuration by enforcing a single modern minimum version at the project root and removing redundant subdirectory declarations.
  • Increase the top-level cmake_minimum_required from 3.7 to 3.23 in the main CMakeLists file.
  • Delete cmake_minimum_required calls from plugin, example, src, tests, and network-service-plugin CMakeLists to rely on the global constraint.
CMakeLists.txt
dcc-network-plugin/CMakeLists.txt
dcc-network/CMakeLists.txt
dock-example/CMakeLists.txt
dock-hotspot-plugin/CMakeLists.txt
dss-network-plugin/CMakeLists.txt
dss_example/CMakeLists.txt
example/CMakeLists.txt
network-service-plugin/CMakeLists.txt
src/CMakeLists.txt
tests/CMakeLists.txt
Minor cleanups and logging adjustments in network configuration code.
  • Remove a debug console.log from NetUtils.ipToNum to avoid noisy logs in production.
  • Add temporary console.warn statements in PageSettings to log interface name information when saving configs.
dcc-network/qml/NetUtils.js
dcc-network/qml/PageSettings.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The new DeviceStatusItem logic for resolving the connected child name no longer filters on itemType === NetType.WirelessItem (compared to the previous implementation in PageWirelessDevice), which may change which child is picked as the display name; consider reintroducing an explicit type check or documenting the intended behavior change.
  • There are new console.warn debug statements left in PageSettings.qml around devConfig.interfaceName and connection.interface-name; if these are not meant for permanent logging, they should be removed or converted to the project’s standard logging mechanism.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new DeviceStatusItem logic for resolving the connected child name no longer filters on `itemType === NetType.WirelessItem` (compared to the previous implementation in PageWirelessDevice), which may change which child is picked as the display name; consider reintroducing an explicit type check or documenting the intended behavior change.
- There are new `console.warn` debug statements left in PageSettings.qml around `devConfig.interfaceName` and `connection.interface-name`; if these are not meant for permanent logging, they should be removed or converted to the project’s standard logging mechanism.

## Individual Comments

### Comment 1
<location> `dcc-network/qml/DeviceStatusItem.qml:49-57` </location>
<code_context>
+                        var childrenItem = [netItem]
+                        while (childrenItem.length > 0) {
+                            var childItem = childrenItem.pop()
+                            if (childItem.status === NetType.CS_Connected) {
+                                return childItem.name
+                            }
+                            for (let i in childItem.children) {
+                                childrenItem.push(childItem.children[i])
+                            }
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Connected-name resolution now ignores item type, which may change behavior versus the previous implementation.

The previous logic required both `childItem.itemType === NetType.WirelessItem` and `childItem.status === NetType.CS_Connected`; now only `status` is checked. If non‑wireless children can also be `CS_Connected`, this may select a different (and possibly unintended) child name. If you want to preserve the prior behavior, please reintroduce an `itemType` constraint or otherwise narrow this search.

```suggestion
                        var childrenItem = [netItem]
                        while (childrenItem.length > 0) {
                            var childItem = childrenItem.pop()
                            if (childItem.itemType === NetType.WirelessItem &&
                                    childItem.status === NetType.CS_Connected) {
                                return childItem.name
                            }
                            for (let i in childItem.children) {
                                childrenItem.push(childItem.children[i])
                            }
```
</issue_to_address>

### Comment 2
<location> `dcc-network/qml/PageSettings.qml:248-249` </location>
<code_context>
+                    } else {
+                        delete devConfig["band"]
+                    }
+                    console.warn("devConfig.interfaceName===================",devConfig.interfaceName)
+                    console.warn("connection.interfaceName===================",nConfig["connection"]["interface-name"])
                     if (devConfig.interfaceName.length === 0) {
                         delete nConfig["connection"]["interface-name"]
</code_context>

<issue_to_address>
**suggestion:** Leftover `console.warn` debugging logs should be removed or gated.

These two calls appear to be temporary debug logging and will generate unnecessary noise in normal operation. Please either remove them or wrap them in a debug-only flag so they don’t run in production.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +49 to +57
var childrenItem = [netItem]
while (childrenItem.length > 0) {
var childItem = childrenItem.pop()
if (childItem.status === NetType.CS_Connected) {
return childItem.name
}
for (let i in childItem.children) {
childrenItem.push(childItem.children[i])
}
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Connected-name resolution now ignores item type, which may change behavior versus the previous implementation.

The previous logic required both childItem.itemType === NetType.WirelessItem and childItem.status === NetType.CS_Connected; now only status is checked. If non‑wireless children can also be CS_Connected, this may select a different (and possibly unintended) child name. If you want to preserve the prior behavior, please reintroduce an itemType constraint or otherwise narrow this search.

Suggested change
var childrenItem = [netItem]
while (childrenItem.length > 0) {
var childItem = childrenItem.pop()
if (childItem.status === NetType.CS_Connected) {
return childItem.name
}
for (let i in childItem.children) {
childrenItem.push(childItem.children[i])
}
var childrenItem = [netItem]
while (childrenItem.length > 0) {
var childItem = childrenItem.pop()
if (childItem.itemType === NetType.WirelessItem &&
childItem.status === NetType.CS_Connected) {
return childItem.name
}
for (let i in childItem.children) {
childrenItem.push(childItem.children[i])
}

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. 测试各种状态(已连接、已断开等)的网络连接状态显示
@deepin-ci-robot
Copy link

deepin pr auto review

Git Diff 代码审查报告

1. 总体评价

本次提交主要进行了以下几方面的修改:

  1. 将CMake最低版本要求从3.7/3.13升级到3.23,并清理了子目录中重复的cmake_minimum_required声明
  2. 新增了DeviceStatusItem.qml组件,用于统一显示网络设备状态和开关
  3. 重构了网络设备状态显示逻辑,将getStatusName函数从NetUtils.js移到DeviceStatusItem.qml
  4. 调整了PageDetails.qml的结构,优化了布局层次
  5. 将band配置从SectionDevice.qml移动到SectionGeneric.qml
  6. 删除了调试日志

整体来看,代码质量良好,重构方向合理,但有一些可以改进的地方。

2. 具体审查意见

2.1 CMakeLists.txt 修改

语法逻辑:

  • 修改正确,将所有子目录中的重复cmake_minimum_required声明移除,统一在根目录设置

代码质量:

  • 建议在CMakeLists.txt中添加注释说明为什么选择3.23版本,以及使用了哪些3.23引入的新特性

代码性能:

  • 无明显影响

代码安全:

  • 无安全问题

2.2 DeviceStatusItem.qml 新增文件

语法逻辑:

  • 代码结构清晰,逻辑正确
  • getStatusName函数的实现与原NetUtils.js中的实现一致

代码质量:

  • 建议添加组件文档注释,说明组件的用途和属性
  • 可以考虑将getStatusName函数移到单独的JS文件中,以便于复用和测试
  • 建议为netItem属性添加类型检查,如property NetItem netItem: null

代码性能:

  • 在text属性的计算中使用了深度优先搜索遍历子项,对于大型网络结构可能会有性能问题
  • 建议添加缓存机制,避免重复计算

代码安全:

  • 建议添加对netItem为null的检查,防止空指针异常
  • 在遍历children时建议添加深度限制,防止无限循环

2.3 NetUtils.js 修改

语法逻辑:

  • 删除getStatusName函数是正确的,因为已经移到DeviceStatusItem.qml中
  • 删除调试日志是正确的

代码质量:

  • 无问题

代码性能:

  • 无问题

代码安全:

  • 无问题

2.4 PageDSLSettings.qml 和 PageSettings.qml 修改

语法逻辑:

  • 修改正确,将band配置从SectionDevice移动到SectionGeneric
  • 保存配置时正确处理了band属性

代码质量:

  • 建议添加注释说明band配置的用途和可能的值

代码性能:

  • 无问题

代码安全:

  • 建议添加对sectionGeneric.band的类型检查,确保它是字符串或undefined

2.5 PageDetails.qml 修改

语法逻辑:

  • 修改正确,调整了布局结构,将body对象移到DccRepeater之前

代码质量:

  • 结构更清晰,但建议添加注释说明为什么需要调整布局

代码性能:

  • 无明显影响

代码安全:

  • 无安全问题

2.6 PageWiredDevice.qml 和 PageWirelessDevice.qml 修改

语法逻辑:

  • 修改正确,用DeviceStatusItem替换了原来的DevCheck组件和状态显示逻辑
  • 代码更简洁,复用性更好

代码质量:

  • 建议添加注释说明为什么使用connectedNameVisible属性来控制是否显示连接名称

代码性能:

  • 无问题

代码安全:

  • 建议添加对netItem为null的检查

2.7 SectionDevice.qml 和 SectionGeneric.qml 修改

语法逻辑:

  • 修改正确,将band配置从SectionDevice移动到SectionGeneric
  • 代码结构更合理,符合配置的语义

代码质量:

  • 建议添加注释说明band配置的用途和可能的值

代码性能:

  • 无问题

代码安全:

  • 无安全问题

3. 改进建议

  1. 添加组件文档

    /**
     * DeviceStatusItem.qml
     * 
     * 用于显示网络设备状态和开关的组件
     * 
     * 属性:
     *   - netItem: NetItem 网络设备对象
     *   - connectedNameVisible: bool 是否显示连接名称
     *   - statusVisible: bool 是否显示状态文本
     */
  2. 添加类型检查

    property var netItem: null
    // 改为
    property NetItem netItem: null
  3. 添加空值检查

    function getStatusName(status) {
        if (status === undefined || status === null) {
            return qsTr("Unknown")
        }
        // ... 原有代码
    }
  4. 优化深度搜索

    text: {
        if (connectedNameVisible && netItem) {
            switch (netItem.status) {
            case NetType.DS_Connected:
            case NetType.DS_ConnectNoInternet:
                // 添加深度限制
                const MAX_DEPTH = 10;
                var childrenItem = [{item: netItem, depth: 0}];
                while (childrenItem.length > 0) {
                    var {item: childItem, depth} = childrenItem.pop();
                    if (depth > MAX_DEPTH) continue;
                    
                    if (childItem.status === NetType.CS_Connected) {
                        return childItem.name
                    }
                    for (let i in childItem.children) {
                        childrenItem.push({item: childItem.children[i], depth: depth + 1});
                    }
                }
                break
            default:
                break
            }
        }
        return getStatusName(netItem ? netItem.status : NetType.DS_Unknown)
    }
  5. 添加CMake注释

    # CMake 3.23 is required for:
    # - Newer CMake features used in the project
    # - Better support for Qt 6 integration
    cmake_minimum_required(VERSION 3.23)

4. 总结

本次提交整体质量良好,主要进行了代码重构和优化,提高了代码的复用性和可维护性。主要改进点包括:

  1. 统一了CMake版本要求
  2. 提取了公共组件DeviceStatusItem
  3. 优化了配置管理结构
  4. 删除了冗余代码和调试日志

建议按照上述改进意见进行优化,以提高代码的健壮性和可维护性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@caixr23 caixr23 merged commit 9f67655 into linuxdeepin:master Feb 3, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants