From a46693a931514882def30e4058832a62aedb9433 Mon Sep 17 00:00:00 2001 From: rankun Date: Sun, 11 Oct 2020 09:27:23 +0800 Subject: [PATCH] feat: drag move for mac --- QtScrcpy/MainWindow.qml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/QtScrcpy/MainWindow.qml b/QtScrcpy/MainWindow.qml index b7f8dac..83c0ed6 100644 --- a/QtScrcpy/MainWindow.qml +++ b/QtScrcpy/MainWindow.qml @@ -4,7 +4,7 @@ import QtQuick.Window 2.12 Window { id: root visible: true - flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowMaximizeButtonHint + flags: Qt.Window | Qt.WindowMaximizeButtonHint | (Qt.platform.os == "windows" ? Qt.FramelessWindowHint : 0) width: 800 height: 600 color: "transparent" @@ -36,8 +36,28 @@ Window { color: "transparent" DragHandler { + // startSystemMove only windows enabled + enabled: Qt.platform.os == "windows" ? true : false 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); + } } } }