Skip to content

fix: fix proxy method change handling and add type property#524

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Mar 20, 2026
Merged

fix: fix proxy method change handling and add type property#524
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Mar 20, 2026

  1. Fixed Connections target in PageSystemProxy.qml from 'item' to
    'netItem' to properly handle method changes
  2. Added 'type' property binding in PageSettings.qml to pass network
    type to SectionGeneric
  3. Added 'type' property declaration in SectionGeneric.qml with default
    value NetType.WiredItem

Log: Fixed network proxy settings not updating when connection method
changes

Influence:

  1. Test network proxy settings page to ensure method changes are
    properly reflected
  2. Verify that different network types (wired/wireless) display correct
    configuration options
  3. Test editing network settings to ensure all properties are properly
    passed between components
  4. Verify that proxy method changes trigger appropriate UI updates

fix: 修复代理方法变更处理并添加类型属性

  1. 修复 PageSystemProxy.qml 中 Connections 目标从 'item' 改为
    'netItem',以正确处理方法变更
  2. 在 PageSettings.qml 中添加 'type' 属性绑定,将网络类型传递给
    SectionGeneric
  3. 在 SectionGeneric.qml 中添加 'type' 属性声明,默认值为
    NetType.WiredItem

Log: 修复网络代理设置在连接方法变更时无法正确更新的问题

Influence:

  1. 测试网络代理设置页面,确保方法变更能正确反映
  2. 验证不同网络类型(有线/无线)显示正确的配置选项
  3. 测试编辑网络设置,确保所有属性在组件间正确传递
  4. 验证代理方法变更能触发适当的UI更新

Summary by Sourcery

Ensure network proxy UI responds correctly to connection method changes and propagates network type information through settings components.

Bug Fixes:

  • Correct proxy method change handling by listening to method changes on the appropriate network item.

Enhancements:

  • Pass network type from the settings page into the generic section component and expose a typed property on the generic section for network-type-specific behavior.

1. Fixed Connections target in PageSystemProxy.qml from 'item' to
'netItem' to properly handle method changes
2. Added 'type' property binding in PageSettings.qml to pass network
type to SectionGeneric
3. Added 'type' property declaration in SectionGeneric.qml with default
value NetType.WiredItem

Log: Fixed network proxy settings not updating when connection method
changes

Influence:
1. Test network proxy settings page to ensure method changes are
properly reflected
2. Verify that different network types (wired/wireless) display correct
configuration options
3. Test editing network settings to ensure all properties are properly
passed between components
4. Verify that proxy method changes trigger appropriate UI updates

fix: 修复代理方法变更处理并添加类型属性

1. 修复 PageSystemProxy.qml 中 Connections 目标从 'item' 改为
'netItem',以正确处理方法变更
2. 在 PageSettings.qml 中添加 'type' 属性绑定,将网络类型传递给
SectionGeneric
3. 在 SectionGeneric.qml 中添加 'type' 属性声明,默认值为
NetType.WiredItem

Log: 修复网络代理设置在连接方法变更时无法正确更新的问题

Influence:
1. 测试网络代理设置页面,确保方法变更能正确反映
2. 验证不同网络类型(有线/无线)显示正确的配置选项
3. 测试编辑网络设置,确保所有属性在组件间正确传递
4. 验证代理方法变更能触发适当的UI更新
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts network proxy handling and propagates network type information through QML components so that proxy method changes and per-type settings are correctly reflected in the UI.

Sequence diagram for updated proxy method change handling

sequenceDiagram
    actor User
    participant PageSystemProxy
    participant netItem
    participant ProxyUI

    User->>ProxyUI: Change proxy method in UI
    ProxyUI->>netItem: Update connection method
    netItem-->>PageSystemProxy: methodChanged(m)
    PageSystemProxy->>PageSystemProxy: Connections.onMethodChanged(m)
    PageSystemProxy->>ProxyUI: Update bound method property
    ProxyUI->>User: Display updated proxy method state
Loading

Class diagram for updated QML components and type propagation

classDiagram
    class PageSystemProxy {
        +Connections connectionToNetItem
        +netItem: var
        +method: var
        +onMethodChanged(m)
    }

    class PageSettings {
        +type: int
        +sectionGeneric: SectionGeneric
    }

    class SectionGeneric {
        +config: var
        +settingsID: string
        +band: var
        +type: int
        +errorKey: string
        +editClicked()
    }

    class NetItem {
        +method: var
        +methodChanged(m)
        +type: int
    }

    PageSystemProxy --> NetItem : listens_via_Connections
    PageSettings --> SectionGeneric : sets_type_property
    SectionGeneric --> NetItem : configures_by_type
    PageSettings --> NetItem : passes_type_indirectly
Loading

File-Level Changes

Change Details Files
Fix proxy method change handling by listening to the correct network item in PageSystemProxy.
  • Update Connections target from the generic item reference to netItem so onMethodChanged reacts to the active network object.
  • Keep method property in sync with the network item when its proxy method changes.
dcc-network/qml/PageSystemProxy.qml
Propagate network type from the settings page into the generic section component so it can render type-specific options.
  • Bind SectionGeneric.type to root.type in the settings page to pass the network type down.
  • Declare a new type property in SectionGeneric with default value NetType.WiredItem for use in its UI logic.
dcc-network/qml/PageSettings.qml
dcc-network/qml/SectionGeneric.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

@deepin-ci-robot
Copy link

deepin pr auto review

以下是对提供的 Git diff 输入的审查意见:

1. 语法逻辑

  • 文件头修改(所有文件)

    • SPDX-FileCopyrightText 的年份范围从 2024 - 2027 修改为 2024 - 2026
    • 审查意见:这看起来像是一个版权年份的修正,符合逻辑,没有语法错误。
  • dcc-network/qml/PageSettings.qml

    • SectionGeneric 组件中添加了 type: root.type
    • 审查意见:这表明 SectionGeneric 现在依赖于父组件 roottype 属性。这需要确保 root 对象确实定义了 type 属性,否则会导致运行时错误 "ReferenceError: root is not defined" 或 "Property 'type' not found"。如果 rootDccObject 的实例,需确认其定义。
  • dcc-network/qml/PageSystemProxy.qml

    • Connections 对象中,将 target: item 修改为 target: netItem
    • 审查意见:这是一个重大的逻辑变更。这意味着监听信号的对象从 item 变成了 netItem。必须确保在 Connections 所在的作用域内定义了名为 netItem 的对象,并且该对象确实拥有 methodChanged 信号。如果 netItem 未定义或作用域不对,会导致 Connections 静默失效或报错。原代码中的 item 可能是指代 delegate 中的 item,请确认 netItem 的来源是否正确。

2. 代码质量

  • dcc-network/qml/SectionGeneric.qml
    • 添加了 property int type: NetType.WiredItem
    • 审查意见:为组件添加了明确的属性定义,并提供了默认值。这提高了代码的可读性和组件的封装性。默认值设为 NetType.WiredItem 是一个合理的回退值。

3. 代码性能

  • dcc-network/qml/PageSettings.qml
    • type: root.type:这是一个属性绑定。如果 root.type 频繁变化,会导致 SectionGeneric 中的 type 属性频繁更新,进而可能触发级联更新。
    • 审查意见:如果 root.type 在初始化后不再变化,这种绑定是高效的。如果它会频繁变化,需要评估其影响。

4. 代码安全

  • 潜在的作用域问题
    • PageSystemProxy.qml 中,target: netItem 的修改引入了安全风险。如果 netItem 是一个动态创建的对象,或者在某些情况下为 nullundefinedConnections 将无法正常工作。建议在 Connections 中添加 enabled: netItem !== null 来确保安全性,或者确保 netItem 的生命周期管理得当。
    • 在 QML 中,直接引用 root 或其他外部 ID(如 netItem)依赖于组件树的结构。如果组件结构发生变化(例如,SectionGeneric 被移到其他地方使用),这种紧耦合会导致代码难以维护和潜在的运行时错误。建议通过属性显式传递依赖,而不是直接引用外部 ID。

总结与改进建议

  1. 确认 rootnetItem 的定义:请确保在 PageSettings.qmlroot 确实有 type 属性,且在 PageSystemProxy.qmlnetItem 已正确定义并拥有 methodChanged 信号。
  2. 检查 Connections 的目标:在 PageSystemProxy.qml 中,将 targetitem 改为 netItem 是一个逻辑变更。请确认这是预期的行为,而不是笔误。
  3. 属性传递优化:在 PageSettings.qml 中,虽然 type: root.type 可以工作,但为了降低耦合度,建议检查是否可以通过显式的属性传递(例如在创建 SectionGeneric 时直接传递 type 参数)来替代直接引用 root
  4. 版权年份:确认版权年份的修改是符合公司规定的。

示例改进代码(针对 PageSystemProxy.qml 的 Connections 安全性):

Connections {
    target: netItem
    // 确保 netItem 存在时才启用连接
    enabled: netItem !== null && netItem !== undefined
    function onMethodChanged(m) {
        method = m
    }
}

示例改进代码(针对 PageSettings.qml 的属性绑定):

如果 root.type 不会动态变化,可以使用初始化时赋值而非绑定,以减少不必要的绑定开销:

SectionGeneric {
    id: sectionGeneric
    parentName: root.parentUrl + "/body"
    weight: 100
    // 如果 root.type 在初始化后不变,可以使用 Component.onCompleted 赋值
    Component.onCompleted: {
        type = root.type
    }
    onEditClicked: modified = true
}

或者,如果 root 是外部传入的属性,确保其命名清晰:

property DccObject rootObject: parent // 假设 root 是通过这种方式传递的

SectionGeneric {
    // ...
    type: rootObject.type
    // ...
}

请根据实际代码结构选择最合适的改进方案。

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 left some high level feedback:

  • The new type property in SectionGeneric.qml is declared as int; if it’s meant to be tied to NetType, consider using a more strongly-typed or at least documented enum mapping to avoid misuse and magic numbers later.
  • The Connections target change to netItem assumes this is always non-null and available; if there are states where netItem is not yet set, you may want to guard against null targets to avoid runtime warnings.
  • The SPDX copyright year range was changed from 2024 - 2027 to 2024 - 2026; please confirm this reduction is intentional and consistent with the project’s licensing conventions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `type` property in `SectionGeneric.qml` is declared as `int`; if it’s meant to be tied to `NetType`, consider using a more strongly-typed or at least documented enum mapping to avoid misuse and magic numbers later.
- The `Connections` target change to `netItem` assumes this is always non-null and available; if there are states where `netItem` is not yet set, you may want to guard against null targets to avoid runtime warnings.
- The SPDX copyright year range was changed from `2024 - 2027` to `2024 - 2026`; please confirm this reduction is intentional and consistent with the project’s licensing conventions.

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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@18202781743 18202781743 merged commit 11ed2b0 into linuxdeepin:master Mar 20, 2026
17 of 19 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