Skip to content

fix: improve dock center space calculation and taskmanager layout#1548

Open
wjyrich wants to merge 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-355833
Open

fix: improve dock center space calculation and taskmanager layout#1548
wjyrich wants to merge 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-355833

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Apr 9, 2026

  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

Summary by Sourcery

Improve dock center area space calculation and TaskManager layout for more accurate and consistent space distribution.

Enhancements:

  • Compute remaining dock center space dynamically, excluding the TaskManager and other center applets’ footprints for more accurate layout.
  • Simplify dock center container sizing by relying directly on the center loader’s implicit dimensions.
  • Align TaskManager sizing with the shared remaining-space calculation and adjust its implicit width/height based on alignment and orientation.
  • Constrain TaskManager app item sizes using remaining space and item count to distribute available space evenly.
  • Base dockItemMaxSize on the unified remaining-center-space property for consistent item sizing.

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 9, 2026

Reviewer's Guide

Refines 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 sizing

sequenceDiagram
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
Loading

Class diagram for updated dock and TaskManager sizing logic

classDiagram

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
Loading

File-Level Changes

Change Details Files
Replace ad‑hoc dock center overflow/space logic with a dynamic remaining-space calculation that excludes TaskManager and accounts for other center applets.
  • Removed dockLeftSpaceForCenter and previous dockRemainingSpaceForCenter properties based on fixed Screen fractions.
  • Introduced getOtherCenterAppletsCount() to count visible center-region applets excluding TaskManager by dockOrder range.
  • Computed vertical and horizontal space used by other center applets using dockItemMaxSize/dockSize and gridLayout spacing, subtracting that from the total screen space minus left/right parts to get dockRemainingSpaceForCenter.
panels/dock/package/main.qml
Simplify dock center container implicit sizing to rely solely on its loader’s implicit size.
  • Removed TaskManager-specific references from dockCenterPart (taskmanagerRootObject, implicit width/height overrides using appContainer values).
  • Set dockCenterPart.implicitWidth/implicitHeight directly to centerLoader.implicitWidth/implicitHeight.
panels/dock/package/main.qml
Align TaskManager remaining-space usage with the new center calculation and adjust its implicit size behavior based on alignment and orientation.
  • Changed remainingSpacesForTaskManager to always reference Panel.rootObject.dockRemainingSpaceForCenter instead of switching between left and center space props.
  • Reworked TaskManager implicitWidth/implicitHeight to choose max or min of remaining space vs appContainer size depending on Dock alignment and useColumnLayout.
  • Removed remainingSpacesForSplitWindow and appContainerWidth/Height helper properties and routed SplitWindow.delegateLayout.remainingSpace to remainingSpacesForTaskManager.
panels/dock/taskmanager/package/TaskManager.qml
Distribute remaining space across TaskManager app items so they shrink to fit when space is constrained, vertically in column layout and horizontally otherwise.
  • Updated appItem implicitWidth/implicitHeight bindings to compute a target size, then cap it by per-item max size derived from remainingSpacesForTaskManager minus total spacing, divided by item count.
  • Handled edge cases when visualModel.count is zero and ensured a minimum size of 1 to avoid invalid dimensions.
  • Made the sizing logic orientation-aware: width constrained in row layout, height constrained in column layout.
panels/dock/taskmanager/package/TaskManager.qml
Fix dockItemMaxSize computation to use the new remaining-space reference for the center region.
  • Changed the binding for Panel.rootObject.dockItemMaxSize to use dockRemainingSpaceForCenter instead of dockLeftSpaceForCenter when dividing by the total center app count (including TaskManager).
panels/dock/taskmanager/package/TaskManager.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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-bot
Copy link
Copy Markdown

deepin-bot bot commented Apr 9, 2026

TAG Bot

New tag: 2.0.37
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants