Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions panels/dock/taskmanager/package/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,17 @@ ContainmentItem {
property bool useColumnLayout: Panel.position % 2
property int dockOrder: 16
property int remainingSpacesForTaskManager: Panel.itemAlignment === Dock.LeftAlignment ? Panel.rootObject.dockLeftSpaceForCenter : Panel.rootObject.dockRemainingSpaceForCenter
property int forceRelayoutWorkaround: 0

property int remainingSpacesForSplitWindow: Panel.rootObject.dockLeftSpaceForCenter - (Panel.rootObject.dockCenterPartCount - 1) * Panel.rootObject.dockItemMaxSize * 9 / 14
// 用于居中计算的实际应用区域尺寸
property int appContainerWidth: useColumnLayout ? Panel.rootObject.dockSize : (appContainer.implicitWidth + forceRelayoutWorkaround)
property int appContainerHeight: useColumnLayout ? (appContainer.implicitHeight + forceRelayoutWorkaround) : Panel.rootObject.dockSize
property int appContainerWidth: useColumnLayout ? Panel.rootObject.dockSize : appContainer.implicitWidth
property int appContainerHeight: useColumnLayout ? appContainer.implicitHeight : Panel.rootObject.dockSize

// 动态字符限制数组,存储每个应用的最大显示字符数
property var dynamicCharLimits: []

Timer {
// FIXME: dockItemMaxSize(visualModel.cellWidth,actually its implicitWidth/Height) change will cause all delegate item's position change, but
// the newly added item will using the old cellWidth to calculate its position, thus it will be placed in the wrong position. Also it
// seems forceLayout() simply doesn't work, so we use a workaround here to force relayout the ListView inside the OverflowContainer.
// See: QTBUG-133953
id: relayoutWorkaroundTimer
interval: 250 // should longer than OverflowContainer.add duration
repeat: false
onTriggered: {
taskmanager.forceRelayoutWorkaround = visualModel.count % 2 + 1
console.log("force relayout", taskmanager.forceRelayoutWorkaround)
}
}

implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : (Math.max(remainingSpacesForTaskManager, appContainer.implicitWidth) + forceRelayoutWorkaround)
implicitHeight: useColumnLayout ? (Math.max(remainingSpacesForTaskManager, appContainer.implicitHeight) + forceRelayoutWorkaround) : Panel.rootObject.dockSize
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : Math.max(remainingSpacesForTaskManager, appContainer.implicitWidth)
implicitHeight: useColumnLayout ? Math.max(remainingSpacesForTaskManager, appContainer.implicitHeight) : Panel.rootObject.dockSize

// Helper function to find the current index of an app by its appId in the visualModel
function findAppIndex(appId) {
Expand Down Expand Up @@ -238,14 +223,6 @@ ContainmentItem {
anchors.fill: parent
useColumnLayout: taskmanager.useColumnLayout
spacing: Panel.rootObject.itemSpacing + visualModel.count % 2
add: Transition {
NumberAnimation {
properties: "scale,opacity"
from: 0
to: 1
duration: 200
}
}
remove: Transition {
NumberAnimation {
properties: "scale,opacity"
Expand Down Expand Up @@ -277,7 +254,6 @@ ContainmentItem {
// 1:4 the distance between app : dock height; get width/height≈0.8
property real cellWidth: Panel.rootObject.dockItemMaxSize * 0.8
onCountChanged: function() {
relayoutWorkaroundTimer.start()
DS.singleShot(300, updateDynamicCharLimits)
}
delegate: Item {
Expand Down Expand Up @@ -312,6 +288,14 @@ ContainmentItem {
return false
}

ListView.onAdd: NumberAnimation {
Copy link
Contributor

Choose a reason for hiding this comment

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

add是附加属性的信号,这里是响应信号的槽函数么,这样写是什么意思呀?

Copy link
Member Author

Choose a reason for hiding this comment

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

就是在 onAdd 信号触发的时候触发动画。

(p.s. 这是 QTBUG-133953 里给我的建议修改方式)

target: delegateRoot
properties: "scale,opacity"
from: 0
to: 1
duration: 200
}

Comment on lines +291 to +298
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The syntax ListView.onAdd: NumberAnimation { ... } appears non-standard. In QML, ListView.onAdd is an attached signal handler that typically expects JavaScript code, not a direct Animation assignment. The standard approach would be to define the animation separately and start it within the signal handler, or use the ListView's add transition (the original approach). This may not execute as intended. Additionally, this approach could conflict with the existing state-based PropertyChanges (lines 299-310) and Behaviors (lines 312-313) that also control the opacity and scale properties.

Suggested change
ListView.onAdd: NumberAnimation {
target: delegateRoot
properties: "scale,opacity"
from: 0
to: 1
duration: 200
}

Copilot uses AI. Check for mistakes.
states: [
State {
name: "item-visible"
Expand Down Expand Up @@ -472,7 +456,6 @@ ContainmentItem {
repeat: false
onTriggered: {
updateDynamicCharLimits()
taskmanager.forceRelayoutWorkaround = (visualModel.count + 1) % 2 + 1
}
}

Expand Down