C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 12s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 28s
Python / verify (pull_request) Failing after 1m41s
Rust / build (pull_request) Successful in 1m15s
Rust / fmt (pull_request) Successful in 42s
Rust / clippy (pull_request) Successful in 1m6s
96 lines
2.1 KiB
QML
96 lines
2.1 KiB
QML
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();
|
|
}
|
|
}
|
|
}
|