From 8d3109abe9448aa22e9eea4bc2b76e4254c81e19 Mon Sep 17 00:00:00 2001 From: Wu JiangYu Date: Thu, 26 Nov 2026 14:23:05 +0800 Subject: [PATCH] refactor(dock): simplify task overflow logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove adaptive icon shrinking and keep dock-sized task icons 2. Enable overflow whenever the title layout cannot fit available space 3. Drop minimum size solving and the minimumReached property 4. Simplify overflow latching to depend only on available extent Log: Simplify task overflow to fixed icon size with overflow fallback Influence: Dock icons stay at dock size; excess tasks move to overflow refactor(dock): 简化任务溢出逻辑 1. 移除图标自适应缩小,保持任务图标为停靠栏尺寸 2. 标题布局无法容纳可用空间时即可触发溢出 3. 移除最小尺寸求解及 minimumReached 属性 4. 简化溢出锁定逻辑,仅依据可用空间判断 Log: 简化任务溢出逻辑,图标固定尺寸并用溢出承接多余任务 Influence: 停靠栏图标保持原尺寸,多余任务移入溢出区 PMS: BUG-384519 --- .../dock/taskmanager/package/TaskManager.qml | 60 +------------------ .../taskmanager/taskoverflowcontroller.cpp | 10 +--- .../dock/taskmanager/taskoverflowcontroller.h | 8 --- 3 files changed, 4 insertions(+), 74 deletions(-) diff --git a/panels/dock/taskmanager/package/TaskManager.qml b/panels/dock/taskmanager/package/TaskManager.qml index 2ca900386..04441e524 100644 --- a/panels/dock/taskmanager/package/TaskManager.qml +++ b/panels/dock/taskmanager/package/TaskManager.qml @@ -40,9 +40,6 @@ ContainmentItem { // Defined in main.qml as dockItemIconSize = dockItemMaxSize * 9 / 14. // At default dock size (56), icon = 36px; at min (37), icon ≈ 24px; at max (100), icon ≈ 64px. readonly property real iconWidthToMaxSizeRatio: 9 / 14 - readonly property int minimumDockItemSize: Math.max( - Dock.MIN_DOCK_SIZE, - Math.round(Panel.rootObject.dockSize * Dock.MIN_DOCK_SIZE / Dock.DEFAULT_DOCK_SIZE)) readonly property real startPadding: Math.max(0, appTitleSpacing - (Panel.rootObject.dockItemMaxSize * (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2)) implicitWidth: { @@ -105,12 +102,10 @@ ContainmentItem { TaskOverflowController { id: taskOverflow - // Window-split title layout has priority. Only fall back to adaptive icon - // shrinking and overflow when no title layout can fit the available space. - enabled: Panel.fashionModeEnabled - && (!textCalculator.enabled || textCalculator.totalWidth <= 0) + // Window-split title layout has priority. Otherwise keep the dock-sized + // icons and move excess tasks into overflow. + enabled: !textCalculator.enabled || textCalculator.totalWidth <= 0 availableExtent: Math.max(0, taskmanager.calcRemainingSpace(Panel.rootObject.dockItemMaxSize) - taskmanager.startPadding) - minimumReached: Panel.rootObject.dockItemMaxSize <= taskmanager.minimumDockItemSize + 0.5 fallbackItemExtent: Math.max(1, Panel.rootObject.dockItemMaxSize * taskmanager.iconWidthToMaxSizeRatio) spacing: taskmanager.appTitleSpacing overflowSidePadding: taskmanager.appTitleSpacing + 1 @@ -515,57 +510,8 @@ ContainmentItem { } } - - // Solve for S (dockItemMaxSize). The forward layout equation is: - // totalSpace = appCount×S×itemRatio + gaps×max(10, S×spacingRatio) - // + max(0, spacing - S×k) + otherCount×S×multitaskViewIconRatio - // - // The max(10,…) makes this piecewise. Ignoring Math.round (continuous approx): - // - // Regime 1 (S×spacingRatio ≥ 10): no clamp, every term ∝ S. - // Factor out S → S = totalSpace / sum_of_coefficients. - // - // Regime 2 (S×spacingRatio < 10): spacing clamped to 10 (constant). - // startPad flips from S×(spacingRatio-k) to 10 - S×k. - // Separate constants from S-terms → S = (total - constants) / S_coefficient. - function solveMaxSizeFull(totalSpace, appCount, otherCount) { - if (appCount <= 0) { - return totalSpace; - } - - const spacingRatio = iconWidthToMaxSizeRatio / 3; // 9/14 / 3 - const k = (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2; // ≈ 0.0786 - const gaps = Math.max(0, appCount - 1); - const otherRatio = otherCount > 0 ? otherCount * multitaskViewIconRatio : 0; - - // Regime 1: continuous spacing model - const S = totalSpace / (appCount * iconWidthToMaxSizeRatio + gaps * spacingRatio + otherRatio + spacingRatio - k); - - // Regime 2: spacing clamped to 10 - if (S * spacingRatio < 10) { - return Math.max(0, (totalSpace - gaps * 10 - 10) / (appCount * iconWidthToMaxSizeRatio - k + otherRatio)); - } - return Math.max(0, S); - } - Component.onCompleted: { taskmanager.Applet.setFashionMode(fashionMode) - Panel.rootObject.dockItemMaxSize = Qt.binding(function(){ - const dockSize = Panel.rootObject.dockSize; - const appCount = visualModel.count; - - if (appCount <= 0 || dockSize <= 0) - return dockSize; - - if (textCalculator.enabled && textCalculator.totalWidth > 0) - return dockSize; - - const otherItems = Math.max(0, Panel.rootObject.dockCenterPartCount - 1); - const optimal = solveMaxSizeFull(Panel.rootObject.dockEffectiveCenterSpace, appCount, otherItems); - const fitted = optimal >= dockSize ? dockSize : optimal; - // Before task overflow, icons kept shrinking to fit all tasks. - return Panel.fashionModeEnabled ? Math.max(taskmanager.minimumDockItemSize, fitted) : fitted; - }) taskOverflow.scheduleSync() } } diff --git a/panels/dock/taskmanager/taskoverflowcontroller.cpp b/panels/dock/taskmanager/taskoverflowcontroller.cpp index 6bc982b95..d564e3346 100644 --- a/panels/dock/taskmanager/taskoverflowcontroller.cpp +++ b/panels/dock/taskmanager/taskoverflowcontroller.cpp @@ -94,14 +94,6 @@ void TaskOverflowController::setAvailableExtent(qreal availableExtent) } } -void TaskOverflowController::setMinimumReached(bool minimumReached) -{ - if (m_minimumReached != minimumReached) { - m_minimumReached = minimumReached; - scheduleSync(); - } -} - void TaskOverflowController::setFallbackItemExtent(qreal fallbackItemExtent) { fallbackItemExtent = std::isfinite(fallbackItemExtent) ? std::max(1, fallbackItemExtent) : 1; @@ -379,7 +371,7 @@ bool TaskOverflowController::syncEnabledState(int totalCount, qreal fullExtent) const qreal stopThreshold = std::max(0, m_availableExtent - OverflowReleaseHysteresis); const bool nextLatched = m_latched ? fullExtent > stopThreshold - : (m_minimumReached && fullExtent > startThreshold); + : fullExtent > startThreshold; m_latched = nextLatched; return m_latched; } diff --git a/panels/dock/taskmanager/taskoverflowcontroller.h b/panels/dock/taskmanager/taskoverflowcontroller.h index 53b28d564..2d538930b 100644 --- a/panels/dock/taskmanager/taskoverflowcontroller.h +++ b/panels/dock/taskmanager/taskoverflowcontroller.h @@ -37,7 +37,6 @@ class TaskOverflowController : public QObject Q_OBJECT Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(qreal availableExtent READ availableExtent WRITE setAvailableExtent) - Q_PROPERTY(bool minimumReached READ minimumReached WRITE setMinimumReached) Q_PROPERTY(qreal fallbackItemExtent READ fallbackItemExtent WRITE setFallbackItemExtent NOTIFY fallbackItemExtentChanged) Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) Q_PROPERTY(qreal overflowSidePadding READ overflowSidePadding WRITE setOverflowSidePadding NOTIFY overflowSidePaddingChanged) @@ -70,12 +69,6 @@ class TaskOverflowController : public QObject } void setAvailableExtent(qreal availableExtent); - bool minimumReached() const - { - return m_minimumReached; - } - void setMinimumReached(bool minimumReached); - qreal fallbackItemExtent() const { return m_fallbackItemExtent; @@ -162,7 +155,6 @@ private Q_SLOTS: bool m_enabled = true; qreal m_availableExtent = 0; - bool m_minimumReached = false; qreal m_fallbackItemExtent = 1; qreal m_spacing = 0; qreal m_overflowSidePadding = 0;