import Quickshell import QtQuick import ZShell.Config import qs.Components CustomMouseArea { id: root required property real borderThickness required property Drawing drawing required property Panels panels required property ScreenState screenState required property EdgeGeometry geometry function inLeftPanel(panel: Item, x: real, y: real): bool { return x < panel.x + panel.width + geometry.insetLeft(borderThickness) && withinPanelHeight(panel, x, y); } function withinPanelHeight(panel: Item, x: real, y: real): bool { const panelY = panel.y + geometry.insetTop(borderThickness); return y >= panelY && y <= panelY + panel.height; } anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: Qt.BlankCursor enabled: z > 0 hoverEnabled: true focus: root.screenState.isDrawing z: 2 Binding { target: root.drawing.content property: "hoverPoint" value: Qt.point(root.mouseX, root.mouseY) } Keys.onPressed: e => { const mod = e.modifiers; const key = e.key; if ((key == Qt.Key_Z) && (mod & Qt.ControlModifier) && (mod & Qt.ShiftModifier)) { root.drawing.content.redo(); e.accepted = true; } else if ((key == Qt.Key_Z) && (mod & Qt.ControlModifier)) { root.drawing.content.undoLastGroup(); e.accepted = true; } } onPositionChanged: event => { const x = event.x; const y = event.y; if (!drawing.content.hoverVisible) drawing.content.showHover(); if (event.buttons & Qt.LeftButton) { drawing.content.appendPoint(x, y); return; } if (!(event.buttons & Qt.LeftButton) && inLeftPanel(panels.drawing, x, y)) { z = -2; panels.drawing.expand(); drawing.content.hideHover(); } } onPressed: event => { const x = event.x; const y = event.y; panels.drawing.collapse(); if (event.buttons & Qt.LeftButton) { panels.drawing.collapse(); drawing.content.beginStroke(x, y); return; } if (event.button & Qt.RightButton) { drawing.content.clear(); return; } } onReleased: event => { const x = event.x; const y = event.y; if (event.button & Qt.LeftButton) { drawing.content.endStroke(); drawing.content.showHover(); } } }