-
Notifications
You must be signed in to change notification settings - Fork 40
Fix: [network] Disable network failed #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: [network] Disable network failed #542
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
-- 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);
}
总体而言,这个功能实现是合理的,但可以通过上述建议进一步提高代码质量、可读性和健壮性。 |
|
[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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
f720214
into
linuxdeepin:develop/eagle
-- 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: