mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
desktop plugins: use mapToGlobal on moving widgets
This commit is contained in:
@@ -75,7 +75,7 @@ Item {
|
|||||||
property real minWidth: contentLoader.item?.minWidth ?? 100
|
property real minWidth: contentLoader.item?.minWidth ?? 100
|
||||||
property real minHeight: contentLoader.item?.minHeight ?? 100
|
property real minHeight: contentLoader.item?.minHeight ?? 100
|
||||||
property bool forceSquare: contentLoader.item?.forceSquare ?? false
|
property bool forceSquare: contentLoader.item?.forceSquare ?? false
|
||||||
property bool isInteracting: dragArea.drag.active || resizeArea.pressed
|
property bool isInteracting: dragArea.pressed || resizeArea.pressed
|
||||||
|
|
||||||
function updateVariantPositions(updates) {
|
function updateVariantPositions(updates) {
|
||||||
const positions = JSON.parse(JSON.stringify(variantData?.positions || {}));
|
const positions = JSON.parse(JSON.stringify(variantData?.positions || {}));
|
||||||
@@ -206,28 +206,31 @@ Item {
|
|||||||
id: dragArea
|
id: dragArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.ArrowCursor
|
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.ArrowCursor
|
||||||
|
|
||||||
drag.target: dragProxy
|
property point startPos
|
||||||
drag.minimumX: 0
|
property real startX
|
||||||
drag.minimumY: 0
|
property real startY
|
||||||
drag.maximumX: root.screenWidth - root.widgetWidth
|
|
||||||
drag.maximumY: root.screenHeight - root.widgetHeight
|
onPressed: mouse => {
|
||||||
|
startPos = mapToGlobal(mouse.x, mouse.y);
|
||||||
|
startX = root.widgetX;
|
||||||
|
startY = root.widgetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
onPositionChanged: mouse => {
|
||||||
|
if (!pressed)
|
||||||
|
return;
|
||||||
|
const currentPos = mapToGlobal(mouse.x, mouse.y);
|
||||||
|
const deltaX = currentPos.x - startPos.x;
|
||||||
|
const deltaY = currentPos.y - startPos.y;
|
||||||
|
root.widgetX = Math.max(0, Math.min(startX + deltaX, root.screenWidth - root.widgetWidth));
|
||||||
|
root.widgetY = Math.max(0, Math.min(startY + deltaY, root.screenHeight - root.widgetHeight));
|
||||||
|
}
|
||||||
|
|
||||||
onReleased: root.savePosition()
|
onReleased: root.savePosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
|
||||||
id: dragProxy
|
|
||||||
x: root.widgetX
|
|
||||||
y: root.widgetY
|
|
||||||
|
|
||||||
onXChanged: if (dragArea.drag.active)
|
|
||||||
root.widgetX = x
|
|
||||||
onYChanged: if (dragArea.drag.active)
|
|
||||||
root.widgetY = y
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: resizeArea
|
id: resizeArea
|
||||||
width: 48
|
width: 48
|
||||||
@@ -267,4 +270,5 @@ Item {
|
|||||||
onReleased: root.saveSize()
|
onReleased: root.saveSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user