feat: drag move for mac

This commit is contained in:
rankun 2020-10-11 09:27:23 +08:00
commit a46693a931

View file

@ -4,7 +4,7 @@ import QtQuick.Window 2.12
Window { Window {
id: root id: root
visible: true visible: true
flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowMaximizeButtonHint flags: Qt.Window | Qt.WindowMaximizeButtonHint | (Qt.platform.os == "windows" ? Qt.FramelessWindowHint : 0)
width: 800 width: 800
height: 600 height: 600
color: "transparent" color: "transparent"
@ -36,8 +36,28 @@ Window {
color: "transparent" color: "transparent"
DragHandler { DragHandler {
// startSystemMove only windows enabled
enabled: Qt.platform.os == "windows" ? true : false
grabPermissions: TapHandler.CanTakeOverFromAnything grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { root.startSystemMove(); } onActiveChanged: if (active) {root.startSystemMove(); }
}
// drag move for other system
MouseArea{
property real pressMouseX;
property real pressMouseY;
anchors.fill: parent
enabled: Qt.platform.os != "windows" ? true : false
onPressed: {
pressMouseX = mouse.x;
pressMouseY = mouse.y;
}
onPositionChanged: {
root.x = root.x + (mouse.x - pressMouseX);
root.y = root.y + (mouse.y - pressMouseY);
}
} }
} }
} }