fix: Optimize UI display of the network module#523
fix: Optimize UI display of the network module#523deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the NetFileChooseEdit layout so the text field keeps a consistent width relative to its implicit size and the browse button, and exposes the browse button for layout calculations while retaining its behavior. Class diagram for updated NetFileChooseEdit layoutclassDiagram
class NetFileChooseEdit {
+int implicitWidth
+var dataItem
+var nameFilters
+string placeholderText
+string text
+bool readOnly
+bool acceptableInput
}
class EditLineEdit {
+int Layout_preferredWidth
+string placeholderText
+string text
+bool readOnly
+bool acceptableInput
+onTextChanged()
+Component_onCompleted()
}
class BrowseButton {
+string text
+onClicked()
}
NetFileChooseEdit *-- EditLineEdit : contains
NetFileChooseEdit *-- BrowseButton : contains
NetFileChooseEdit : implicitWidth = EditLineEdit.implicitWidth
EditLineEdit : Layout_preferredWidth = EditLineEdit.implicitWidth - BrowseButton.width - NetFileChooseEdit.spacing
BrowseButton : id browseBtn
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
implicitWidth: edit.implicitWidthonrootcombined withLayout.preferredWidth: edit.implicitWidth - browseBtn.width - root.spacinginsideeditrisks a binding loop or unstable layout; consider basing widths onroot.widthor explicit constants rather than chainingimplicitWidthvalues together. - The subtraction
edit.implicitWidth - browseBtn.width - root.spacingcan easily go negative or behave unexpectedly with different themes/fonts; it would be more robust to useLayout.fillWidth: truefor the line edit and rely on the RowLayout to allocate remaining space after the button. - The
// TEMP: 验证改动是否生效,去掉按钮comment no longer matches the actual code (the button is still present); either remove the temporary comment or adjust the code so the comment reflects the current behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `implicitWidth: edit.implicitWidth` on `root` combined with `Layout.preferredWidth: edit.implicitWidth - browseBtn.width - root.spacing` inside `edit` risks a binding loop or unstable layout; consider basing widths on `root.width` or explicit constants rather than chaining `implicitWidth` values together.
- The subtraction `edit.implicitWidth - browseBtn.width - root.spacing` can easily go negative or behave unexpectedly with different themes/fonts; it would be more robust to use `Layout.fillWidth: true` for the line edit and rely on the RowLayout to allocate remaining space after the button.
- The `// TEMP: 验证改动是否生效,去掉按钮` comment no longer matches the actual code (the button is still present); either remove the temporary comment or adjust the code so the comment reflects the current behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这段代码是一个 QML 文件( 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 其他建议
总结
改进后的代码示例RowLayout {
id: root
property var dataItem
property var nameFilters: [qsTr("All files (*)")]
property alias placeholderText: edit.placeholderText
property alias text: edit.text
property alias buttonVisible: browseBtn.visible
spacing: 10 // 显式定义间距
D.LineEdit {
id: edit
Layout.fillWidth: true // 自动占据剩余空间
Layout.minimumWidth: 100
Layout.maximumWidth: 500
onTextChanged: {
if (!initialized) {
return
}
dataItem = text
}
Component.onCompleted: initialized = true
}
NetButton {
id: browseBtn
text: qsTr("...")
onClicked: {
fileDialog.createObject(this).open()
}
}
}这样改进后,代码更清晰、性能更好,且避免了潜在的布局问题。 |
log: Keep text field widths consistent pms: bug-337919
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, JWWTSL 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) |
log: Keep text field widths consistent
pms: bug-337919
Summary by Sourcery
Bug Fixes: