@@ -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