Skip to content

Commit 0bc2da3

Browse files
committed
fix: item size not updated when taskbar item count was changed
修复任务栏图标数量过多时,新增图标后,图标大小仍未更新的问题. PMS: BUG-289225 Log:
1 parent a56fa03 commit 0bc2da3

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

example/bridge-example/package/appletitem.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.deepin.ds.dock 1.0
1616
AppletItem {
1717
id: debuggerApplet
1818
property bool useColumnLayout: Panel.position % 2
19-
property int dockOrder: 12
19+
property int dockOrder: 21
2020
// 1:4 the distance between app : dock height; get width/height≈0.8
2121
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : Panel.rootObject.dockItemMaxSize * 0.8
2222
implicitHeight: useColumnLayout ? Panel.rootObject.dockItemMaxSize * 0.8 : Panel.rootObject.dockSize

panels/dock/taskmanager/package/TaskManager.qml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,31 @@ ContainmentItem {
1313
id: taskmanager
1414
property bool useColumnLayout: Panel.position % 2
1515
property int dockOrder: 16
16+
property int remainingSpacesForTaskManager: Panel.rootObject.dockLeftSpaceForCenter - Panel.rootObject.dockItemMaxSize * 1.2
17+
property int forceRelayoutWorkaround: 0
18+
19+
Timer {
20+
// FIXME: dockItemMaxSize(visualModel.cellWidth,actually its implicitWidth/Height) change will cause all delegate item's position change, but
21+
// the newly added item will using the old cellWidth to calculate its position, thus it will be placed in the wrong position. Also it
22+
// seems forceLayout() simply doesn't work, so we use a workaround here to force relayout the ListView inside the OverflowContainer.
23+
// See: QTBUG-133953
24+
id: relayoutWorkaroundTimer
25+
interval: 250 // should longer than OverflowContainer.add duration
26+
repeat: false
27+
onTriggered: {
28+
taskmanager.forceRelayoutWorkaround = visualModel.count % 2 + 1
29+
console.log("force relayout", taskmanager.forceRelayoutWorkaround)
30+
}
31+
}
1632

17-
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : appContainer.implicitWidth
18-
implicitHeight: useColumnLayout ? appContainer.implicitHeight : Panel.rootObject.dockSize
33+
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : (Math.min(remainingSpacesForTaskManager, appContainer.implicitWidth) + forceRelayoutWorkaround)
34+
implicitHeight: useColumnLayout ? (Math.min(remainingSpacesForTaskManager, appContainer.implicitHeight) + forceRelayoutWorkaround) : Panel.rootObject.dockSize
1935

2036
OverflowContainer {
2137
id: appContainer
22-
anchors.centerIn: parent
38+
anchors.fill: parent
2339
useColumnLayout: taskmanager.useColumnLayout
24-
spacing: Panel.rootObject.itemSpacing
40+
spacing: Panel.rootObject.itemSpacing + visualModel.count % 2
2541
add: Transition {
2642
NumberAnimation {
2743
properties: "scale,opacity"
@@ -50,6 +66,9 @@ ContainmentItem {
5066
model: taskmanager.Applet.dataModel
5167
// 1:4 the distance between app : dock height; get width/height≈0.8
5268
property real cellWidth: Panel.rootObject.dockItemMaxSize * 0.8
69+
onCountChanged: function() {
70+
relayoutWorkaroundTimer.start()
71+
}
5372
delegate: DropArea {
5473
id: delegateRoot
5574
required property bool active
@@ -166,7 +185,7 @@ ContainmentItem {
166185

167186
Component.onCompleted: {
168187
Panel.rootObject.dockItemMaxSize = Qt.binding(function(){
169-
return Math.min(Panel.rootObject.dockSize, Panel.rootObject.dockLeftSpaceForCenter * 1.2 / (Panel.rootObject.dockCenterPartCount - 1 + taskmanager.Applet.dataModel.rowCount()) - 2)
188+
return Math.min(Panel.rootObject.dockSize, Panel.rootObject.dockLeftSpaceForCenter * 1.2 / (Panel.rootObject.dockCenterPartCount - 1 + visualModel.count) - 2)
170189
})
171190
}
172191
}

0 commit comments

Comments
 (0)