diff --git a/panels/dock/tray/package/ActionShowStashDelegate.qml b/panels/dock/tray/package/ActionShowStashDelegate.qml index cf2fa17c5..507cc08dd 100644 --- a/panels/dock/tray/package/ActionShowStashDelegate.qml +++ b/panels/dock/tray/package/ActionShowStashDelegate.qml @@ -29,6 +29,22 @@ D.ToolButton { leftPadding: itemPadding rightPadding: itemPadding + property var itemGlobalPoint: { + var a = root + var x = 0, y = 0 + while(a.parent) { + x += a.x + y += a.y + a = a.parent + } + + return Qt.point(x + width / 2, y + height / 2) + } + + onItemGlobalPointChanged: { + stashedPopup.collapsedBtnCenterPoint = itemGlobalPoint + } + states: [ State { name: "opened" @@ -55,32 +71,6 @@ D.ToolButton { } onClicked: { - switch (Panel.position) { - case Dock.Top: { - var point = root.mapToItem(null, root.width / 2, 0) - stashedPopup.popupX = Qt.binding(function () { return point.x - stashedPopup.width / 2 }) - stashedPopup.popupY = Qt.binding(function () { return Panel.rootObject.dockSize + 10 }) - break - } - case Dock.Bottom: { - var point = root.mapToItem(null, root.width / 2, 0) - stashedPopup.popupX = Qt.binding(function () { return point.x - stashedPopup.width / 2 }) - stashedPopup.popupY = Qt.binding(function () { return -stashedPopup.height - 10 }) - break - } - case Dock.Left: { - var point = root.mapToItem(null, 0, root.height / 2) - stashedPopup.popupX = Qt.binding(function () { return Panel.rootObject.dockSize + 10 }) - stashedPopup.popupY = Qt.binding(function () { return point.y - stashedPopup.height / 2 }) - break - } - case Dock.Right: { - var point = root.mapToItem(null, 0, root.height / 2) - stashedPopup.popupX = Qt.binding(function () { return -stashedPopup.width - 10 }) - stashedPopup.popupY = Qt.binding(function () { return point.y - stashedPopup.height / 2 }) - break - } - } stashedPopup.open() } } diff --git a/panels/dock/tray/package/tray.qml b/panels/dock/tray/package/tray.qml index 1987a6302..6ecce0bc3 100644 --- a/panels/dock/tray/package/tray.qml +++ b/panels/dock/tray/package/tray.qml @@ -100,6 +100,11 @@ AppletItem { width: stashedContainer.width height: stashedContainer.height + popupX: DockPanelPositioner.x + popupY: DockPanelPositioner.y + + property point collapsedBtnCenterPoint: Qt.point(0, 0) + Control { id: stashedContainer contentItem: StashContainer { @@ -116,15 +121,20 @@ AppletItem { anchors.centerIn: parent } } + + Component.onCompleted: { + DockPanelPositioner.bounding = Qt.binding(function () { + return Qt.rect(collapsedBtnCenterPoint.x, collapsedBtnCenterPoint.y, stashedPopup.width, stashedPopup.height) + }) + } } Connections { target: DDT.TraySortOrderModel function onActionsAlwaysVisibleChanged(val) { - if (val) { - if (!stashedPopup.popupVisible) { - // TODO: position? - stashedPopup.open() - } + if (val && !stashedPopup.popupVisible) { + stashedPopup.open() + } else if (!val) { + stashedPopup.close() } } }