Skip to content

Commit 3db0756

Browse files
committed
fix: address bot review
1 parent c2ebe9a commit 3db0756

9 files changed

Lines changed: 129 additions & 187 deletions

File tree

screen-toolkit/Annotate.qml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,26 @@ Variants {
204204
ctx.lineTo(stroke.x2, stroke.y2)
205205
ctx.stroke()
206206
} else if (stroke.type === "arrow") {
207-
var dx = stroke.x2 - stroke.x1
208-
var dy = stroke.y2 - stroke.y1
209-
var len = Math.sqrt(dx * dx + dy * dy)
207+
var dx = stroke.x2 - stroke.x1
208+
var dy = stroke.y2 - stroke.y1
209+
var len = Math.sqrt(dx * dx + dy * dy)
210210
if (len < 2) { ctx.restore(); return }
211+
var angle = Math.atan2(dy, dx)
212+
var hs = Math.max(stroke.size * 3.5, 10)
213+
var hw = Math.PI / 5
214+
var baseFrac = Math.max(0, 1 - hs / len)
215+
var bx = stroke.x1 + dx * baseFrac
216+
var by = stroke.y1 + dy * baseFrac
211217
ctx.beginPath()
212218
ctx.moveTo(stroke.x1, stroke.y1)
213-
ctx.lineTo(stroke.x2, stroke.y2)
219+
ctx.lineTo(bx, by)
214220
ctx.stroke()
215-
var angle = Math.atan2(dy, dx)
216-
var hs = Math.max(stroke.size * 4, 12)
217221
ctx.beginPath()
218222
ctx.moveTo(stroke.x2, stroke.y2)
219-
ctx.lineTo(stroke.x2 - hs * Math.cos(angle - Math.PI / 6),
220-
stroke.y2 - hs * Math.sin(angle - Math.PI / 6))
221-
ctx.lineTo(stroke.x2 - hs * Math.cos(angle + Math.PI / 6),
222-
stroke.y2 - hs * Math.sin(angle + Math.PI / 6))
223+
ctx.lineTo(stroke.x2 - hs * Math.cos(angle - hw),
224+
stroke.y2 - hs * Math.sin(angle - hw))
225+
ctx.lineTo(stroke.x2 - hs * Math.cos(angle + hw),
226+
stroke.y2 - hs * Math.sin(angle + hw))
223227
ctx.closePath()
224228
ctx.fill()
225229
} else if (stroke.type === "rect") {
@@ -362,6 +366,7 @@ Variants {
362366
Shortcut {
363367
sequence: "Escape"
364368
onActivated: {
369+
if (overlayWin.isSaving) return
365370
overlayWin.strokes = []
366371
_invalidateCache()
367372
root.hide()
@@ -485,16 +490,16 @@ Variants {
485490
}
486491
Rectangle {
487492
visible: overlayWin.isPrimary && root.zoomScale > 1.0
488-
x: overlayWin.localX + root.regionW - width - 8
489-
y: overlayWin.localY + 8
490-
width: zoomBadgeRow.implicitWidth + 12
493+
x: overlayWin.localX + root.regionW - width - Style.marginXS
494+
y: overlayWin.localY + Style.marginXS
495+
width: zoomBadgeRow.implicitWidth + Style.marginS * 2
491496
height: 22
492-
radius: 6
497+
radius: Style.radiusS
493498
color: Qt.rgba(0, 0, 0, 0.6)
494499
Row {
495500
id: zoomBadgeRow
496501
anchors.centerIn: parent
497-
spacing: 4
502+
spacing: Style.marginXS
498503
NIcon { icon: "zoom-in"; color: "#ffffff" }
499504
NText {
500505
text: Math.round(root.zoomScale) + "× — view only"
@@ -769,14 +774,14 @@ Variants {
769774
height: useVertical ? (toolbarContent.implicitHeight + Style.marginS * 2) : 52
770775
readonly property real _autoX: useVertical
771776
? (spaceRight >= 56
772-
? Math.min(overlayWin.localX + root.regionW + 8, overlayWin.width - width - 8)
773-
: Math.max(8, overlayWin.localX - width - 8))
774-
: Math.max(8, Math.min(overlayWin.localX + (root.regionW - width) / 2, overlayWin.width - width - 8))
777+
? Math.min(overlayWin.localX + root.regionW + Style.marginS, overlayWin.width - width - Style.marginS)
778+
: Math.max(Style.marginS, overlayWin.localX - width - Style.marginS))
779+
: Math.max(Style.marginS, Math.min(overlayWin.localX + (root.regionW - width) / 2, overlayWin.width - width - Style.marginS))
775780
readonly property real _autoY: useVertical
776-
? Math.max(8, Math.min(overlayWin.localY + (root.regionH - height) / 2, overlayWin.height - height - 8))
781+
? Math.max(Style.marginS, Math.min(overlayWin.localY + (root.regionH - height) / 2, overlayWin.height - height - Style.marginS))
777782
: (spaceBelow >= 56
778-
? overlayWin.localY + root.regionH + 8
779-
: Math.max(8, overlayWin.localY - height - 8))
783+
? overlayWin.localY + root.regionH + Style.marginS
784+
: Math.max(Style.marginS, overlayWin.localY - height - Style.marginS))
780785
x: overlayWin._tbUserX >= 0
781786
? Math.max(0, Math.min(overlayWin.width - width, overlayWin._tbUserX))
782787
: _autoX
@@ -790,7 +795,7 @@ Variants {
790795
component ToolbarSeparator: Rectangle {
791796
readonly property bool vertical: toolbar.useVertical
792797
width: vertical ? 28 : 1
793-
height: vertical ? 1 : 28
798+
height: vertical ? 1 : 28
794799
color: Color.mOnSurfaceVariant
795800
opacity: 0.3
796801
anchors.horizontalCenter: vertical ? parent.horizontalCenter : undefined
@@ -879,7 +884,7 @@ Variants {
879884
property bool primary: false
880885
height: 36
881886
radius: Style.radiusS
882-
width: _sbRow.implicitWidth + 32
887+
width: _sbRow.implicitWidth + Style.marginL
883888
color: sbHover.containsMouse
884889
? (primary ? Color.mPrimary : Color.mSecondary || Color.mPrimary)
885890
: (primary ? Color.mPrimaryContainer || Color.mSurfaceVariant : Color.mSurfaceVariant)
@@ -912,7 +917,7 @@ Variants {
912917
color: dragMA.containsMouse || dragMA.pressed ? Color.mHover : "transparent"
913918
Column {
914919
anchors.centerIn: parent
915-
spacing: 3
920+
spacing: Style.marginXS
916921
visible: !parent.isVertical
917922
Repeater {
918923
model: 3
@@ -921,7 +926,7 @@ Variants {
921926
}
922927
Row {
923928
anchors.centerIn: parent
924-
spacing: 3
929+
spacing: Style.marginXS
925930
visible: parent.isVertical
926931
Repeater {
927932
model: 3
@@ -965,9 +970,9 @@ Variants {
965970
"#44AAFF", "#CC44FF", "#FF44CC", "#FFFFFF", "#000000"
966971
]
967972
readonly property var sizeDefs: [
968-
{ size: 2, label: "S" },
969-
{ size: 4, label: "M" },
970-
{ size: 7, label: "L" }
973+
{ size: 2, label: root.mainInstance?.pluginApi?.tr("annotate.sizeS") ?? "S" },
974+
{ size: 4, label: root.mainInstance?.pluginApi?.tr("annotate.sizeM") ?? "M" },
975+
{ size: 7, label: root.mainInstance?.pluginApi?.tr("annotate.sizeL") ?? "L" }
971976
]
972977
function doUndo() {
973978
if (overlayWin.strokes.length > 0) {
@@ -1127,14 +1132,14 @@ Variants {
11271132
color: Color.mSurface
11281133
border.color: Style.capsuleBorderColor || "transparent"
11291134
border.width: Style.capsuleBorderWidth || 1
1130-
width: toolbar.useVertical ? (popContent.implicitWidth + 12) : (popContent.implicitWidth + 16)
1131-
height: toolbar.useVertical ? (popContent.implicitHeight + 16) : (popContent.implicitHeight + 12)
1135+
width: toolbar.useVertical ? (popContent.implicitWidth + Style.marginS) : (popContent.implicitWidth + Style.marginM)
1136+
height: toolbar.useVertical ? (popContent.implicitHeight + Style.marginM) : (popContent.implicitHeight + Style.marginS)
11321137
x: toolbar.useVertical
1133-
? (toolbar.spaceRight >= 56 ? toolbar.x + toolbar.width + 6 : toolbar.x - width - 6)
1134-
: Math.max(8, Math.min(toolbar.x + (toolbar.width - width) / 2, overlayWin.width - width - 8))
1138+
? (toolbar.spaceRight >= 56 ? toolbar.x + toolbar.width + Style.marginXS : toolbar.x - width - Style.marginXS)
1139+
: Math.max(Style.marginS, Math.min(toolbar.x + (toolbar.width - width) / 2, overlayWin.width - width - Style.marginS))
11351140
y: toolbar.useVertical
1136-
? Math.max(8, Math.min(toolbar.y + (toolbar.height - height) / 2, overlayWin.height - height - 8))
1137-
: (toolbar.spaceAbove >= height + 10 ? toolbar.y - height - 6 : toolbar.y + toolbar.height + 6)
1141+
? Math.max(Style.marginS, Math.min(toolbar.y + (toolbar.height - height) / 2, overlayWin.height - height - Style.marginS))
1142+
: (toolbar.spaceAbove >= height + Style.marginS ? toolbar.y - height - Style.marginXS : toolbar.y + toolbar.height + Style.marginXS)
11381143
Loader {
11391144
id: popContent
11401145
anchors.centerIn: parent
@@ -1168,7 +1173,7 @@ Variants {
11681173
border.color: overlayWin.drawSize === modelData.size ? Color.mPrimary : "transparent"
11691174
border.width: 1
11701175
Row {
1171-
anchors.centerIn: parent; spacing: 3
1176+
anchors.centerIn: parent; spacing: Style.marginXS
11721177
Rectangle { width: modelData.size * 2; height: modelData.size * 2; radius: modelData.size; color: overlayWin.drawColor; anchors.verticalCenter: parent.verticalCenter }
11731178
NText { text: modelData.label; pointSize: Style.fontSizeXS; color: Color.mOnSurfaceVariant; anchors.verticalCenter: parent.verticalCenter }
11741179
}
@@ -1209,7 +1214,7 @@ Variants {
12091214
border.color: overlayWin.drawSize === modelData.size ? Color.mPrimary : "transparent"
12101215
border.width: 1
12111216
Row {
1212-
anchors.centerIn: parent; spacing: 3
1217+
anchors.centerIn: parent; spacing: Style.marginXS
12131218
Rectangle { width: modelData.size * 2; height: modelData.size * 2; radius: modelData.size; color: overlayWin.drawColor; anchors.verticalCenter: parent.verticalCenter }
12141219
NText { text: modelData.label; pointSize: Style.fontSizeXS; color: Color.mOnSurfaceVariant; anchors.verticalCenter: parent.verticalCenter }
12151220
}

screen-toolkit/Main.qml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Item {
109109
function _grimRegionCmd(outFile) {
110110
if (!root._regionScreen)
111111
Logger.w("ScreenToolkit", "_grimRegionCmd: _regionScreen is null")
112-
var scale = root._regionScreen?.devicePixelRatio ?? 1.0
112+
var scale = Math.max(0.1, root._regionScreen?.devicePixelRatio ?? 1.0)
113113
var sx = root._regionScreen?.x ?? 0
114114
var sy = root._regionScreen?.y ?? 0
115115
var gx = sx + Math.round(root._regionX / scale)
@@ -563,7 +563,6 @@ Timer {
563563
annotateWinProc.exec({ command: ["bash", "-c", cmd] })
564564
}
565565
}
566-
567566
Timer {
568567
id: launchAnnotateFullscreen
569568
interval: 380; repeat: false
@@ -581,7 +580,7 @@ Timer {
581580
id: launchPin
582581
interval: 50; repeat: false
583582
onTriggered: {
584-
var scale = root._regionScreen?.devicePixelRatio ?? 1.0
583+
var scale = Math.max(0.1, root._regionScreen?.devicePixelRatio ?? 1.0)
585584
var sx = root._regionScreen?.x ?? 0
586585
var sy = root._regionScreen?.y ?? 0
587586
var gx = sx + Math.round(root._regionX / scale)

screen-toolkit/Mirror.qml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ Item {
2121
_primaryScreen = Quickshell.screens[0] ?? null
2222
}
2323
isVisible = true
24+
_cameraActive = true
2425
}
2526
function hide() {
2627
isVisible = false
28+
_cameraActive = false
2729
_primaryScreen = null
2830
}
2931
function toggle(screen) {
@@ -38,6 +40,7 @@ Item {
3840
property int xPos: -1
3941
property int yPos: -1
4042
property var _primaryScreen: null
43+
property bool _cameraActive: false
4144
Variants {
4245
model: Quickshell.screens
4346
delegate: PanelWindow {
@@ -79,7 +82,7 @@ Item {
7982
clip: true
8083
Loader {
8184
id: cameraLoader
82-
active: win.visible && win.isPrimary
85+
active: root._cameraActive && win.isPrimary
8386
anchors.fill: parent
8487
sourceComponent: Component {
8588
Item {
@@ -211,8 +214,8 @@ Item {
211214
}
212215
}
213216
component ResizeHandle: MouseArea {
214-
property int mode: 0 // 0: BR, 1: BL, 2: TR, 3: TL
215-
width: 24; height: 24 // Slightly larger hit area
217+
property int mode: 0
218+
width: 24; height: 24
216219
hoverEnabled: true
217220
preventStealing: true
218221
cursorShape: {
@@ -242,7 +245,7 @@ Item {
242245
nw = Math.max(150, startW + dx)
243246
} else {
244247
nw = Math.max(150, startW - dx)
245-
nx = startX + (startW - nw) // Adjust X to keep right edge stable
248+
nx = startX + (startW - nw)
246249
}
247250
var nh = root.isSquare ? nw : Math.round(nw * 9 / 16)
248251
nh = Math.max(100, nh)
@@ -269,4 +272,3 @@ Item {
269272
}
270273
}
271274
}
272-

screen-toolkit/Panel.qml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ Item {
337337
Rectangle {
338338
width: (parent.width - Style.marginS * 2) / 3
339339
height: 38; radius: Style.radiusM
340-
// BUG FIX: was `root.mainInstance?.isHyprland`, correct binding is root._isHyprland
341340
enabled: root._isHyprland
342341
color: !enabled ? Color.mSurfaceVariant : (annotWinBtn.containsMouse ? Color.mSurfaceVariant : Color.mSurface)
343342
border.color: Style.capsuleBorderColor
@@ -462,43 +461,35 @@ Item {
462461
Row {
463462
width: parent.width; spacing: Style.marginS
464463
visible: root.viewedTool === "pin" && !root.isRunning
465-
466-
467464
Rectangle {
468465
width: (parent.width - Style.marginS) / 2
469466
height: 38; radius: Style.radiusM
470467
color: pinScreenBtn.containsMouse ? Color.mPrimary : Color.mSurface
471468
border.color: Color.mPrimary
472469
border.width: Style.capsuleBorderWidth || 1
473-
474470
Row {
475471
anchors.centerIn: parent; spacing: Style.marginS
476472
NIcon { icon: "crosshair"; color: pinScreenBtn.containsMouse ? Color.mOnPrimary : Color.mPrimary }
477473
NText { text: pluginApi.tr("panel.pinCapture"); color: pinScreenBtn.containsMouse ? Color.mOnPrimary : Color.mPrimary; font.weight: Font.Bold; pointSize: Style.fontSizeS }
478474
}
479-
480475
MouseArea {
481476
id: pinScreenBtn; anchors.fill: parent; hoverEnabled: true; cursorShape: Qt.PointingHandCursor
482477
onClicked: root.mainInstance?.runPin()
483478
onEntered: TooltipService.show(pinScreenBtn, pluginApi.tr("tooltips.pinRegion"))
484479
onExited: TooltipService.hide()
485480
}
486481
}
487-
488-
489482
Rectangle {
490483
width: (parent.width - Style.marginS) / 2
491484
height: 38; radius: Style.radiusM
492485
color: pinFileBtn.containsMouse ? Color.mSurfaceVariant : Color.mSurface
493486
border.color: Style.capsuleBorderColor || "transparent"
494487
border.width: Style.capsuleBorderWidth || 1
495-
496488
Row {
497489
anchors.centerIn: parent; spacing: Style.marginS
498490
NIcon { icon: "folder-open"; color: pinFileBtn.containsMouse ? Color.mOnSurface : Color.mOnSurfaceVariant }
499491
NText { text: pluginApi.tr("panel.pinFile"); color: pinFileBtn.containsMouse ? Color.mOnSurface : Color.mOnSurfaceVariant; font.weight: Font.Bold; pointSize: Style.fontSizeS }
500492
}
501-
502493
MouseArea {
503494
id: pinFileBtn; anchors.fill: parent; hoverEnabled: true; cursorShape: Qt.PointingHandCursor
504495
onClicked: root.mainInstance?.runPinFromFile()
@@ -628,12 +619,12 @@ Item {
628619
Image {
629620
id: pixelImg
630621
anchors.fill: parent
631-
source: root.colorCapturePath !== "" && root.colorCacheBust > 0
632-
? ("file://" + root.colorCapturePath + "?t=" + root.colorCacheBust) : ""
622+
source: root.colorCapturePath !== "" ? ("file://" + root.colorCapturePath) : ""
633623
fillMode: Image.Stretch; smooth: false; cache: false
634624
visible: status === Image.Ready
625+
onStatusChanged: if (status === Image.Ready) visible = true
635626
}
636-
Rectangle { anchors.centerIn: parent; width: 10; height: 10; radius: 5; color: "transparent"; border.color: "white"; border.width: 1; visible: pixelImg.status === Image.Ready }
627+
Rectangle { anchors.centerIn: parent; width: 10; height: 10; radius: 5; color: "transparent"; border.color: "white"; border.width: Style.capsuleBorderWidth || 1; visible: pixelImg.status === Image.Ready }
637628
NText { anchors.centerIn: parent; visible: pixelImg.status !== Image.Ready; text: "..."; color: Color.mOnSurfaceVariant; pointSize: Style.fontSizeS }
638629
}
639630
Column {
@@ -1144,7 +1135,7 @@ Item {
11441135
property bool running: false
11451136
signal triggered()
11461137
Column {
1147-
anchors.centerIn: parent; spacing: 3
1138+
anchors.centerIn: parent; spacing: Style.marginXS
11481139
Rectangle {
11491140
width: Math.min(btn.width - 4, 44)
11501141
height: Math.min(btn.width - 4, 44)

0 commit comments

Comments
 (0)