fixes for drawing
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 9s
Python / lint-format (pull_request) Successful in 14s
Python / test (pull_request) Successful in 29s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m8s

This commit is contained in:
2026-06-20 14:23:15 +02:00
parent a1c148bf70
commit 81eb56e1d0
7 changed files with 56 additions and 39 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ CustomRect {
id: stateLayer id: stateLayer
color: root.internalChecked ? root.activeOnColor : root.inactiveOnColor color: root.internalChecked ? root.activeOnColor : root.inactiveOnColor
enabled: enabled enabled: root.enabled
onClicked: { onClicked: {
if (root.isToggle) if (root.isToggle)
+5 -5
View File
@@ -45,10 +45,10 @@ Item {
} }
function syncFromPenColor() { function syncFromPenColor() {
if (!drawing) if (!drawing.drawingState)
return; return;
const c = drawing.penColor; const c = drawing.drawingState.penColor;
if (c.hsvSaturation > 0) { if (c.hsvSaturation > 0) {
currentHue = c.hsvHue; currentHue = c.hsvHue;
@@ -85,7 +85,7 @@ Item {
currentHue = relative / arcSweep; currentHue = relative / arcSweep;
lastChromaticHue = currentHue; lastChromaticHue = currentHue;
drawing.penColor = Qt.hsva(currentHue, drawing.penColor.hsvSaturation, drawing.penColor.hsvValue, drawing.penColor.a); drawing.drawingState.penColor = Qt.hsva(currentHue, drawing.drawingState.penColor.hsvSaturation, drawing.drawingState.penColor.hsvValue, drawing.drawingState.penColor.a);
} }
implicitHeight: 180 implicitHeight: 180
@@ -111,7 +111,7 @@ Item {
root.syncFromPenColor(); root.syncFromPenColor();
} }
target: root.drawing target: root.drawing.drawingState
} }
Canvas { Canvas {
@@ -151,7 +151,7 @@ Item {
CustomRect { CustomRect {
anchors.centerIn: parent anchors.centerIn: parent
color: root.drawing?.penColor color: root.drawing?.drawingState.penColor
implicitHeight: implicitWidth implicitHeight: implicitWidth
implicitWidth: canvas.height - root.handleSize - Appearance.padding.extraLarge * 2 implicitWidth: canvas.height - root.handleSize - Appearance.padding.extraLarge * 2
radius: Appearance.rounding.full radius: Appearance.rounding.full
+24 -3
View File
@@ -1,9 +1,30 @@
pragma ComponentBehavior: Bound
import Quickshell
import QtQuick import QtQuick
import ZShell.Internal import ZShell.Internal
StrokeCanvas { Item {
id: root id: root
penColor: "white" readonly property alias content: contentLoader.item
penWidth: 4 readonly property PersistentProperties drawingState: PersistentProperties {
property color penColor: "white"
property int penWidth: 4
reloadableId: "drawingState"
}
required property PersistentProperties visibilities
Loader {
id: contentLoader
active: root.visibilities.isDrawing
anchors.fill: parent
sourceComponent: StrokeCanvas {
penColor: root.drawingState.penColor
penWidth: root.drawingState.penWidth
}
}
} }
+7 -6
View File
@@ -123,13 +123,12 @@ Item {
property bool setInitialPoint: false property bool setInitialPoint: false
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
enabled: root.visibilities.isDrawing && !root.inLeftPanel(root.panels.drawing, hoverHandler.point.position.x, hoverHandler.point.position.y) enabled: root.visibilities.isDrawing && (!root.inLeftPanel(root.panels.drawing, hoverHandler.point.position.x, hoverHandler.point.position.y) || !root.panels.drawing.expanded)
grabPermissions: PointerHandler.CanTakeOverFromAnything | PointerHandler.TakeOverForbidden
onActiveChanged: { onActiveChanged: {
if (!active) { if (!active) {
setInitialPoint = false; setInitialPoint = false;
root.drawing.endStroke(); root.drawing.content.endStroke();
} else { } else {
root.panels.drawing.expanded = false; root.panels.drawing.expanded = false;
} }
@@ -149,17 +148,19 @@ Item {
if (!setInitialPoint) { if (!setInitialPoint) {
setInitialPoint = true; setInitialPoint = true;
root.drawing.beginStroke(origX, origY); root.drawing.content.beginStroke(origX, origY);
return; return;
} }
root.drawing.appendPoint(x, y); root.drawing.content.appendPoint(x, y);
} }
} }
HoverHandler { HoverHandler {
id: hoverHandler id: hoverHandler
cursorShape: root.visibilities.isDrawing && !root.inLeftPanel(root.panels.drawing, point.position.x, point.position.y) ? Qt.CrossCursor : undefined
onHoveredChanged: { onHoveredChanged: {
if (!hovered) { if (!hovered) {
if (!root.osdShortcutActive) { if (!root.osdShortcutActive) {
@@ -180,7 +181,7 @@ Item {
const y = point.position.y; const y = point.position.y;
if (root.visibilities.isDrawing) { if (root.visibilities.isDrawing) {
if (root.inLeftPanel(root.panels.drawing, x, y)) if (root.inLeftPanel(root.panels.drawing, x, y) && !(drawingHandler.point.pressedButtons & Qt.LeftButton))
root.panels.drawing.expanded = true; root.panels.drawing.expanded = true;
return; return;
} }
+10 -15
View File
@@ -361,23 +361,18 @@ CustomWindow {
} }
} }
Loader { Drawing {
id: drawingLoader id: drawing
active: visibilities.isDrawing
anchors.fill: parent anchors.fill: parent
layer.enabled: true
visibilities: visibilities
z: 2 z: 2
sourceComponent: Drawing { layer.effect: MultiEffect {
id: drawing maskEnabled: true
maskInverted: true
layer.enabled: true maskSource: maskSource
layer.effect: MultiEffect {
maskEnabled: true
maskInverted: true
maskSource: maskSource
}
} }
} }
@@ -406,7 +401,7 @@ CustomWindow {
anchors.fill: parent anchors.fill: parent
bar: bar bar: bar
borderThickness: root.borderLayoutThickness borderThickness: root.borderLayoutThickness
drawing: drawingLoader.item drawing: drawing
enabled: true enabled: true
panels: panels panels: panels
popouts: panels.popouts popouts: panels.popouts
@@ -418,7 +413,7 @@ CustomWindow {
bar: bar bar: bar
borderThickness: root.borderThickness borderThickness: root.borderThickness
drawingItem: drawingLoader.item drawingItem: drawing
screen: root.screen screen: root.screen
visibilities: visibilities visibilities: visibilities
+7 -7
View File
@@ -19,17 +19,17 @@ Item {
return; return;
if (!saturationSlider.pressed) if (!saturationSlider.pressed)
saturationSlider.value = drawing.penColor.hsvSaturation; saturationSlider.value = drawing.drawingState.penColor.hsvSaturation;
if (!brightnessSlider.pressed) if (!brightnessSlider.pressed)
brightnessSlider.value = drawing.penColor.hsvValue; brightnessSlider.value = drawing.drawingState.penColor.hsvValue;
} }
function updatePenColorFromHsv() { function updatePenColorFromHsv() {
if (!drawing) if (!drawing)
return; return;
drawing.penColor = Qt.hsva(huePicker.currentHue, saturationSlider.value, brightnessSlider.value, drawing.penColor.a); drawing.drawingState.penColor = Qt.hsva(huePicker.currentHue, saturationSlider.value, brightnessSlider.value, drawing.drawingState.penColor.a);
} }
implicitHeight: column.height + Appearance.padding.larger * 2 implicitHeight: column.height + Appearance.padding.larger * 2
@@ -42,7 +42,7 @@ Item {
root.syncFromPenColor(); root.syncFromPenColor();
} }
target: root.drawing target: root.drawing.drawingState
} }
Column { Column {
@@ -126,9 +126,9 @@ Item {
multiplier: 1 multiplier: 1
orientation: Qt.Horizontal orientation: Qt.Horizontal
to: 45 to: 45
value: root.drawing.penWidth value: root.drawing.drawingState.penWidth
onMoved: root.drawing.penWidth = value onMoved: root.drawing.drawingState.penWidth = value
} }
} }
@@ -146,6 +146,6 @@ Item {
shapeMorph: true shapeMorph: true
shapeMorphExpansion: pressed ? 12 : 0 shapeMorphExpansion: pressed ? 12 : 0
onClicked: root.drawing.penColor = modelData onClicked: root.drawing.drawingState.penColor = modelData
} }
} }
+2 -2
View File
@@ -44,7 +44,7 @@ Item {
Loader { Loader {
id: icon id: icon
active: root.shouldBeActive || root.visible active: (root.shouldBeActive || root.visible) && opacity > 0
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
asynchronous: true asynchronous: true
@@ -63,7 +63,7 @@ Item {
Loader { Loader {
id: content id: content
active: root.shouldBeActive || root.visible active: (root.shouldBeActive || root.visible) && opacity > 0
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
asynchronous: true asynchronous: true