fix: improve task manager layout calculation#1237
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors the dock layout by introducing a dedicated remaining-space property and updating the size calculations in both TaskManager and dock center components to better utilize available space and center content. Entity relationship diagram for dock layout propertieserDiagram
PANEL {
int dockLeftSpaceForCenter
int dockRemainingSpaceForCenter
}
TASKMANAGER {
int remainingSpacesForTaskManager
int centerWidth
int centerHeight
}
DOCKCENTERPART {
int implicitWidth
int implicitHeight
}
PANEL ||--o{ TASKMANAGER : contains
TASKMANAGER ||--o{ DOCKCENTERPART : manages
Class diagram for updated TaskManager and dock layout propertiesclassDiagram
class Panel {
+int dockLeftSpaceForCenter
+int dockRemainingSpaceForCenter
}
class TaskManager {
+bool useColumnLayout
+int dockOrder
+int remainingSpacesForTaskManager
+int forceRelayoutWorkaround
+int centerWidth
+int centerHeight
}
Panel <|-- TaskManager
class dockCenterPart {
+implicitWidth
+implicitHeight
}
TaskManager o-- dockCenterPart
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 - here's some feedback:
- Extract the hardcoded 1.8 divisor in dockRemainingSpaceForCenter into a named constant or property to remove the magic number and clarify its purpose.
- Cache the DS.applet("org.deepin.ds.dock.taskmanager").rootObject lookup in dockCenterPart implicit size bindings to improve readability and avoid repeated lookups.
- Add a note or consider removing the forceRelayoutWorkaround hack in centerWidth/centerHeight once the underlying layout issue is resolved to avoid lingering temporary workarounds.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract the hardcoded 1.8 divisor in dockRemainingSpaceForCenter into a named constant or property to remove the magic number and clarify its purpose.
- Cache the DS.applet("org.deepin.ds.dock.taskmanager").rootObject lookup in dockCenterPart implicit size bindings to improve readability and avoid repeated lookups.
- Add a note or consider removing the forceRelayoutWorkaround hack in centerWidth/centerHeight once the underlying layout issue is resolved to avoid lingering temporary workarounds.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
9fce8f5 to
411216b
Compare
411216b to
2bbfd66
Compare
| let applet = DS.applet("org.deepin.ds.dock.taskmanager") | ||
| return applet ? applet.rootObject : null | ||
| } | ||
| implicitWidth: centerLoader.implicitWidth - taskmanagerRootObject.implicitWidth + taskmanagerRootObject.centerWidth |
Changed dock layout calculation to use new dockRemainingSpaceForCenter property instead of dockLeftSpaceForCenter Modified implicitWidth/Height calculations in dockCenterPart to account for task manager's center dimensions Replaced Math.min with Math.max in task manager size calculations to ensure proper space allocation Added centerWidth and centerHeight properties in task manager for accurate centering calculations These changes fix layout issues where task manager was not properly utilizing available space and improve centering behavior fix: 改进任务管理器布局计算 使用新的 dockRemainingSpaceForCenter 属性替代 dockLeftSpaceForCenter 进 行停靠栏布局计算 修改 dockCenterPart 中的隐式宽度/高度计算以考虑任务管理器的居中尺寸 将任务管理器尺寸计算中的 Math.min 替换为 Math.max 以确保正确分配空间 在任务管理器中添加 centerWidth 和 centerHeight 属性以实现精确的居中计算 这些更改解决了任务管理器未正确利用可用空间的布局问题,并改进了居中行为 Pms: BUG-327583
2bbfd66 to
7168cea
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich 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 |
deepin pr auto review我对这个Git diff进行了仔细审查,以下是我的分析和改进建议: 1. 代码逻辑分析
2. 语法问题没有明显的语法错误,但代码格式可以进一步优化:
3. 代码质量改进
4. 性能优化
5. 安全性考虑
具体改进建议
// 常量定义
readonly property real DOCK_CENTER_SPACE_RATIO: 1.8
// 任务管理器相关属性分组
property var taskmanagerRootObject: {
let applet = DS.applet("org.deepin.ds.dock.taskmanager")
return applet ? applet.rootObject : null
}
readonly property real taskmanagerImplicitWidth: taskmanagerRootObject ? taskmanagerRootObject.implicitWidth : 0
readonly property real taskmanagerImplicitHeight: taskmanagerRootObject ? taskmanagerRootObject.implicitHeight : 0
readonly property real taskmanagerAppContainerWidth: taskmanagerRootObject ? taskmanagerRootObject.appContainerWidth : 0
readonly property real taskmanagerAppContainerHeight: taskmanagerRootObject ? taskmanagerRootObject.appContainerHeight : 0
// 改进后的尺寸计算
implicitWidth: Math.max(0, centerLoader.implicitWidth - taskmanagerImplicitWidth + taskmanagerAppContainerWidth)
implicitHeight: Math.max(0, centerLoader.implicitHeight - taskmanagerImplicitHeight + taskmanagerAppContainerHeight)
// 常量定义
readonly property real TASK_MANAGER_SPACE_RATIO: 1.2
// 改进后的空间计算
property int remainingSpacesForTaskManager: Panel.itemAlignment === Dock.LeftAlignment ?
Panel.rootObject.dockLeftSpaceForCenter :
Math.max(0, Panel.rootObject.dockRemainingSpaceForCenter)
// 改进后的尺寸计算
implicitWidth: useColumnLayout ?
Panel.rootObject.dockSize :
(Math.max(0, remainingSpacesForTaskManager) + forceRelayoutWorkaround)
implicitHeight: useColumnLayout ?
(Math.max(0, remainingSpacesForTaskManager) + forceRelayoutWorkaround) :
Panel.rootObject.dockSize这些改进可以提高代码的可读性、可靠性和性能,同时更好地处理边界条件。 |
Changed dock layout calculation to use new dockRemainingSpaceForCenter property instead of dockLeftSpaceForCenter
Modified implicitWidth/Height calculations in dockCenterPart to account for task manager's center dimensions
Replaced Math.min with Math.max in task manager size calculations to ensure proper space allocation
Added centerWidth and centerHeight properties in task manager for accurate centering calculations
These changes fix layout issues where task manager was not properly utilizing available space and improve centering behavior
fix: 改进任务管理器布局计算
使用新的 dockRemainingSpaceForCenter 属性替代 dockLeftSpaceForCenter 进 行停靠栏布局计算
修改 dockCenterPart 中的隐式宽度/高度计算以考虑任务管理器的居中尺寸
将任务管理器尺寸计算中的 Math.min 替换为 Math.max 以确保正确分配空间
在任务管理器中添加 centerWidth 和 centerHeight 属性以实现精确的居中计算
这些更改解决了任务管理器未正确利用可用空间的布局问题,并改进了居中行为
Pms: BUG-327583
Summary by Sourcery
Improve the task manager and dock center layout calculations by introducing a new remaining-space property, updating size calculations to use maximum values, and adding explicit center dimensions to ensure proper space utilization and centering.
Bug Fixes:
Enhancements: