Fix: [network] Disable network failed#542
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom Oct 10, 2025
Merged
Fix: [network] Disable network failed#542deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a canDisable() check on DeviceNetwork, exposes it through the UI model, and filters the disable option in the context menu accordingly. Sequence diagram for context menu disable option filteringsequenceDiagram
participant "User"
participant "TableWidget"
participant "QTableWidgetItem"
participant "DeviceNetwork"
"User"->>"TableWidget": Right-clicks on network device row
"TableWidget"->>"QTableWidgetItem": Get data (canDisable)
"TableWidget"->>"DeviceNetwork": canDisable()
"DeviceNetwork"-->>"TableWidget": true/false
"TableWidget"->>"TableWidget": If canDisable == false, remove disable action from menu
"TableWidget"->>"User": Show context menu
Class diagram for DeviceNetwork changesclassDiagram
class DeviceNetwork {
+QString hwAddress()
+bool canDisable()
}
DeviceNetwork --|> DeviceBaseInfo
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp:251-257` </location>
<code_context>
return m_MACAddress;
}
+bool DeviceNetwork::canDisable()
+{
+ if (m_SysPath.isEmpty()) {
+ return false;
+ }
+ return true;
+}
+
</code_context>
<issue_to_address>
**suggestion:** canDisable() could be simplified.
Consider replacing the method body with 'return !m_SysPath.isEmpty();' for improved clarity and brevity.
```suggestion
bool DeviceNetwork::canDisable()
{
return !m_SysPath.isEmpty();
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
add-uos
approved these changes
Oct 10, 2025
-- The network control not have logic name and address, so disable failed. Log: fix issue Bug: https://pms.uniontech.com/bug-view-334701.html
2aeed58 to
2e646ac
Compare
deepin pr auto review这段代码的审查意见如下:
// 在DeviceNetwork.h中定义常量
static const int CanDisableRole = Qt::UserRole + 3;
// 改进canDisable()的实现
bool DeviceNetwork::canDisable()
{
// 检查系统路径是否有效
if (m_SysPath.isEmpty()) {
return false;
}
// 可以添加更多检查,比如设备状态、权限等
// 例如:检查设备是否处于活动状态
if (!m_IsActive) {
return false;
}
return true;
}
// 在PageMultiInfo.cpp中使用布尔值而非字符串
menuControl.append(network->canDisable());
// 在TableWidget.cpp中使用常量
QVariant canDisableForNetwork = item->data(TableWidget::CanDisableRole);
if (canDisableForNetwork.isValid() && !canDisableForNetwork.toBool()) {
mp_Menu->removeAction(mp_Enable);
}
总体而言,这个功能实现是合理的,但可以通过上述建议进一步提高代码质量、可读性和健壮性。 |
max-lvs
approved these changes
Oct 10, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, GongHeng2017, max-lvs 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 |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
f720214
into
linuxdeepin:develop/eagle
16 of 18 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-- The network control not have logic name and address,
so disable failed.
Log: fix issue
Bug: https://pms.uniontech.com/bug-view-334701.html
Summary by Sourcery
Add logic to conditionally disable network interfaces based on availability and update the UI to hide the disable action when unsupported
New Features:
Bug Fixes:
Enhancements: