fix: improve dock center space calculation and taskmanager layout#1548
fix: improve dock center space calculation and taskmanager layout#1548deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's GuideRefines the dock center area’s remaining-space calculation to account for other center applets, simplifies dock center implicit sizing, and reworks TaskManager sizing logic so app items share available space more accurately across orientations and alignments. Sequence diagram for dock remaining space and TaskManager item sizingsequenceDiagram
actor User
participant DockWindow
participant TaskManager
participant AppContainer
participant AppItemDelegate
participant VisualModel
User->>DockWindow: Change dock orientation or add center applets
DockWindow->>DockWindow: getOtherCenterAppletsCount()
DockWindow->>DockWindow: compute dockRemainingSpaceForCenter
TaskManager->>DockWindow: read dockRemainingSpaceForCenter
TaskManager->>TaskManager: set remainingSpacesForTaskManager
TaskManager->>TaskManager: compute implicitWidth and implicitHeight
TaskManager->>AppContainer: set remainingSpace
AppItemDelegate->>VisualModel: read count
AppItemDelegate->>TaskManager: read remainingSpacesForTaskManager and appTitleSpacing
AppItemDelegate->>AppItemDelegate: compute implicitWidth and implicitHeight based on layout and remaining space
Class diagram for updated dock and TaskManager sizing logicclassDiagram
class DockWindow {
+bool useColumnLayout
+int dockRemainingSpaceForCenter
+int dockPartSpacing
+function getOtherCenterAppletsCount()
}
class DockCenterPart {
+int implicitWidth
+int implicitHeight
}
class TaskManager {
+bool useColumnLayout
+real remainingSpacesForTaskManager
+int appTitleSpacing
+real implicitWidth
+real implicitHeight
}
class AppContainer {
+real remainingSpace
+int spacing
+int cellSize
+int itemPadding
}
class AppItemDelegate {
+real implicitWidth
+real implicitHeight
+int visualIndex
}
DockWindow "1" o-- "1" DockCenterPart
DockWindow "1" o-- "1" TaskManager
TaskManager "1" o-- "1" AppContainer
AppContainer "1" o-- "*" AppItemDelegate
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 found 1 issue, and left some high level feedback:
- The new
getOtherCenterAppletsCount()walksApplet.appletItemsand is used inside a property binding; consider caching the count or listening to model changes to avoid repeatedly scanning the model on every layout recomputation. - The
dockRemainingSpaceForCenterandremainingSpacesForTaskManagervalues can become negative when the dock is overfull; it would be safer to clamp these to a minimum of 0 before using them in size calculations to avoid unexpected layout artifacts. - The hard-coded dock order values (10–20 range and 16 for TaskManager) in
getOtherCenterAppletsCount()would benefit from being centralized as named constants/enums to make the intent clearer and reduce the risk of future mismatch.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `getOtherCenterAppletsCount()` walks `Applet.appletItems` and is used inside a property binding; consider caching the count or listening to model changes to avoid repeatedly scanning the model on every layout recomputation.
- The `dockRemainingSpaceForCenter` and `remainingSpacesForTaskManager` values can become negative when the dock is overfull; it would be safer to clamp these to a minimum of 0 before using them in size calculations to avoid unexpected layout artifacts.
- The hard-coded dock order values (10–20 range and 16 for TaskManager) in `getOtherCenterAppletsCount()` would benefit from being centralized as named constants/enums to make the intent clearer and reduce the risk of future mismatch.
## Individual Comments
### Comment 1
<location path="panels/dock/package/main.qml" line_range="41" />
<code_context>
+ property int dockRemainingSpaceForCenter: {
+ let otherCount = getOtherCenterAppletsCount();
+
+ let otherHeight = otherCount > 0 ? (otherCount * (useColumnLayout ? dockItemMaxSize : dock.dockSize) + otherCount * gridLayout.rowSpacing) : 0;
+ let otherWidth = otherCount > 0 ? (otherCount * (useColumnLayout ? dock.dockSize : dockItemMaxSize) + otherCount * gridLayout.columnSpacing) : 0;
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Circular QML binding between `dockRemainingSpaceForCenter` and `dockItemMaxSize` in column layout.
Here `dockRemainingSpaceForCenter` depends on `dockItemMaxSize` (via `otherHeight`), but `dockItemMaxSize` is later bound to `dockRemainingSpaceForCenter` in `Component.onCompleted`, creating a circular binding that can cause runtime binding errors or undefined values. Please break this cycle, for example by using `dock.dockSize` (or a fixed estimate) here, or by computing `dockItemMaxSize` from a remaining-space value that does not itself depend on `dockItemMaxSize`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| property int dockRemainingSpaceForCenter: { | ||
| let otherCount = getOtherCenterAppletsCount(); | ||
|
|
||
| let otherHeight = otherCount > 0 ? (otherCount * (useColumnLayout ? dockItemMaxSize : dock.dockSize) + otherCount * gridLayout.rowSpacing) : 0; |
There was a problem hiding this comment.
issue (bug_risk): Circular QML binding between dockRemainingSpaceForCenter and dockItemMaxSize in column layout.
Here dockRemainingSpaceForCenter depends on dockItemMaxSize (via otherHeight), but dockItemMaxSize is later bound to dockRemainingSpaceForCenter in Component.onCompleted, creating a circular binding that can cause runtime binding errors or undefined values. Please break this cycle, for example by using dock.dockSize (or a fixed estimate) here, or by computing dockItemMaxSize from a remaining-space value that does not itself depend on dockItemMaxSize.
|
TAG Bot New tag: 2.0.37 |
| // TODO missing property binding to update ProxyModel's filter and sort opearation. | ||
| Repeater { | ||
| model: Applet.appletItems | ||
| onCountChanged: { |
|
[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 |
1. Replaced temporary overflow logic with dynamic calculation of remaining space for center dock area 2. Added function to count center applets excluding TaskManager for accurate space allocation 3. Simplified dockCenterPart implicit dimensions by removing TaskManager-specific adjustments 4. Updated TaskManager to use consistent remaining space calculation and improved implicit dimension logic 5. Enhanced app container sizing to properly distribute available space among app items 6. Fixed dockItemMaxSize calculation to use correct remaining space reference Log: Improved dock layout calculation for better space distribution and task manager display Influence: 1. Test dock layout in different positions (left, right, top, bottom) 2. Verify center area plugins display correctly with varying numbers 3. Check TaskManager app item sizing and spacing in different configurations 4. Test with multiple center area plugins alongside TaskManager 5. Verify layout stability when adding/removing center plugins 6. Test edge cases with minimal/maximal numbers of app items fix: 改进任务栏中心区域空间计算和任务管理器布局 1. 用动态计算替换临时的溢出逻辑,准确计算中心区域剩余空间 2. 新增函数统计除任务管理器外的中心区域插件数量,实现精确空间分配 3. 简化dockCenterPart的隐式尺寸计算,移除任务管理器特定调整 4. 更新任务管理器使用一致的剩余空间计算和改进的隐式尺寸逻辑 5. 增强应用容器尺寸计算,在应用项之间合理分配可用空间 6. 修复dockItemMaxSize计算,使用正确的剩余空间引用 Log: 改进任务栏布局计算,优化空间分配和任务管理器显示 Influence: 1. 测试任务栏在不同位置(左、右、上、下)的布局 2. 验证中心区域插件在不同数量下的正确显示 3. 检查任务管理器应用项在不同配置下的尺寸和间距 4. 测试多个中心区域插件与任务管理器共存的情况 5. 验证添加/移除中心插件时的布局稳定性 6. 测试最小/最大应用项数量的边界情况 PMS: BUG-355833
deepin pr auto reviewGit Diff 代码审查报告1. 语法逻辑审查1.1 主要变更分析这次提交主要对Dock面板的布局和空间计算逻辑进行了重构:
1.2 潜在逻辑问题
2. 代码质量审查2.1 优点
2.2 改进建议
3. 代码性能审查
4. 代码安全审查
5. 综合改进建议
6. 示例改进代码// 定义常量
readonly property real screenUsageRatio: 1.8
readonly property real sizeMultiplier: 1.2
readonly property real minItemSize: 1
// 改进的dockRemainingSpaceForCenter计算
property int dockRemainingSpaceForCenter: Qt.binding(function() {
if (!Panel.rootObject) return 0;
const otherCount = dockCenterPartCount - 1; // not include taskmanager
const spacing = useColumnLayout ? gridLayout.rowSpacing : gridLayout.columnSpacing;
let otherOccupied = 0;
if (otherCount > 0) {
otherOccupied = otherCount * dockItemMaxSize + otherCount * spacing;
}
if (useColumnLayout) {
return Screen.height - dockLeftPart.implicitHeight - dockRightPart.implicitHeight - otherOccupied;
} else {
return Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth - otherOccupied;
}
})
// 提取的计算函数
function calculateImplicitSize(targetSize, isVertical, count, spacing, remainingSpace) {
if (isVertical || count <= 0) return targetSize;
let totalSpacing = Math.max(0, count - 1) * spacing;
let availableSize = remainingSpace - totalSpacing;
let maxSize = availableSize / count;
return Math.min(targetSize, Math.max(minItemSize, maxSize));
}
// 使用提取的函数
implicitWidth: {
if (!Panel.rootObject) return 0;
let targetW = useColumnLayout ? taskmanager.implicitWidth : appItem.implicitWidth;
return calculateImplicitSize(targetW, useColumnLayout, visualModel.count,
taskmanager.appTitleSpacing, taskmanager.remainingSpacesForTaskManager);
}这些改进将使代码更健壮、更易维护,并提高性能和安全性。 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Log: Improved dock layout calculation for better space distribution and task manager display
Influence:
fix: 改进任务栏中心区域空间计算和任务管理器布局
Log: 改进任务栏布局计算,优化空间分配和任务管理器显示
Influence:
PMS: BUG-355833
Summary by Sourcery
Improve dock center area space calculation and TaskManager layout for more accurate and consistent space distribution.
Enhancements: