mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
region selector: remove auto fullscreen ocr, make close btn fab
ocr-ing the whole screen slow and messy. it's better to just go with the regular flow of selecting a region
This commit is contained in:
@@ -12,9 +12,9 @@ RippleButton {
|
||||
property bool expanded: false
|
||||
property real baseSize: 56
|
||||
property real elementSpacing: 5
|
||||
implicitWidth: Math.max(contentRowLayout.implicitWidth + 10 * 2, baseSize)
|
||||
implicitWidth: expanded ? (Math.max(contentRowLayout.implicitWidth + 10 * 2, baseSize)) : baseSize
|
||||
implicitHeight: baseSize
|
||||
buttonRadius: Appearance.rounding.small
|
||||
buttonRadius: baseSize / 14 * 4
|
||||
colBackground: Appearance.colors.colPrimaryContainer
|
||||
colBackgroundHover: Appearance.colors.colPrimaryContainerHover
|
||||
colRipple: Appearance.colors.colPrimaryContainerActive
|
||||
|
||||
@@ -11,6 +11,7 @@ RippleButton {
|
||||
property string mainText: "Button text"
|
||||
property Component mainContentComponent: Component {
|
||||
StyledText {
|
||||
visible: text !== ""
|
||||
text: buttonWithIconRoot.mainText
|
||||
font.pixelSize: Appearance.font.pixelSize.small
|
||||
color: Appearance.colors.colOnSecondaryContainer
|
||||
|
||||
@@ -64,9 +64,4 @@ Toolbar {
|
||||
onClicked: root.selectionMode = RegionSelection.SelectionMode.Circle
|
||||
}
|
||||
|
||||
IconToolbarButton {
|
||||
text: "close"
|
||||
colBackground: Appearance.colors.colLayer3
|
||||
onClicked: root.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,6 @@ PanelWindow {
|
||||
});
|
||||
return offsetAdjustedLayers;
|
||||
}
|
||||
property list<var> textRegions: []
|
||||
|
||||
property bool isCircleSelection: (root.selectionMode === RegionSelection.SelectionMode.Circle)
|
||||
property bool enableWindowRegions: Config.options.regionSelector.targetRegions.windows && !isCircleSelection
|
||||
@@ -182,7 +181,6 @@ PanelWindow {
|
||||
onExited: (exitCode, exitStatus) => {
|
||||
root.visible = true;
|
||||
if (root.enableContentRegions) imageDetectionProcess.running = true;
|
||||
// if (root.action === RegionSelection.SnipAction.CharRecognition) ocrProc.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,41 +202,6 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: ocrProc
|
||||
command: ["bash", "-c", `tesseract '${StringUtils.shellSingleQuoteEscape(root.screenshotPath)}' stdout tsv 2>/dev/null`]
|
||||
stdout: StdioCollector {
|
||||
id: outputCollector
|
||||
onStreamFinished: {
|
||||
// level page_num block_num par_num line_num word_num left top width height conf text
|
||||
const output = outputCollector.text
|
||||
const lines = output.split("\n").slice(1) // Skip header
|
||||
const filteredLines = lines.filter(line => (!line.trim().endsWith("-1")))
|
||||
let regions = filteredLines.map(line => {
|
||||
const parts = line.split("\t")
|
||||
return ({
|
||||
"block_num": parseInt(parts[2]),
|
||||
"line_num": parseInt(parts[4]),
|
||||
"word_num": parseInt(parts[5]),
|
||||
"left": parseInt(parts[6]),
|
||||
"top": parseInt(parts[7]),
|
||||
"width": parseInt(parts[8]),
|
||||
"height": parseInt(parts[9]),
|
||||
"conf": parseInt(parts[10]),
|
||||
"text": parts.slice(11).join("\t")
|
||||
})
|
||||
}).filter(region => {
|
||||
if (region === null) return false;
|
||||
// if (region.text.length <= 3 && region.text.replace(/[^a-zA-Z0-9]/g, "").length < region.text.length / 2) return false;
|
||||
// if (region.text.length < 2) return false;
|
||||
return true;
|
||||
})
|
||||
// print(`[Region Selector] OCR Regions: ${JSON.stringify(regions, null, 2)}`)
|
||||
root.textRegions = regions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function snip() {
|
||||
// Validity check
|
||||
if (root.regionWidth <= 0 || root.regionHeight <= 0) {
|
||||
@@ -450,35 +413,9 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// OCR text regions
|
||||
// Repeater {
|
||||
// model: ScriptModel {
|
||||
// values: root.textRegions
|
||||
// }
|
||||
// delegate: Rectangle {
|
||||
// id: textRegionItem
|
||||
// z: 5
|
||||
// required property var modelData
|
||||
// property real padding: 4
|
||||
// color: ColorUtils.transparentize(Appearance.colors.colTooltip, 0.3)
|
||||
// radius: 6
|
||||
// x: modelData.left - padding
|
||||
// y: modelData.top - padding
|
||||
// width: modelData.width + padding
|
||||
// height: modelData.height + padding
|
||||
|
||||
// StyledText {
|
||||
// font.pixelSize: Appearance.font.pixelSize.smallie
|
||||
// anchors.centerIn: parent
|
||||
// text: textRegionItem.modelData.text
|
||||
// color: ColorUtils.transparentize(Appearance.colors.colOnTooltip, 0.2)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Options toolbar
|
||||
OptionsToolbar {
|
||||
id: toolbar
|
||||
// Controls
|
||||
Row {
|
||||
id: regionSelectionControls
|
||||
z: 9999
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
@@ -490,8 +427,8 @@ PanelWindow {
|
||||
target: root
|
||||
function onVisibleChanged() {
|
||||
if (!visible) return;
|
||||
toolbar.anchors.bottomMargin = 8;
|
||||
toolbar.opacity = 1;
|
||||
regionSelectionControls.anchors.bottomMargin = 8;
|
||||
regionSelectionControls.opacity = 1;
|
||||
}
|
||||
}
|
||||
Behavior on opacity {
|
||||
@@ -500,16 +437,42 @@ PanelWindow {
|
||||
Behavior on anchors.bottomMargin {
|
||||
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
|
||||
}
|
||||
spacing: 6
|
||||
|
||||
Synchronizer on action {
|
||||
property alias source: root.action
|
||||
OptionsToolbar {
|
||||
Synchronizer on action {
|
||||
property alias source: root.action
|
||||
}
|
||||
Synchronizer on selectionMode {
|
||||
property alias source: root.selectionMode
|
||||
}
|
||||
onDismiss: root.dismiss();
|
||||
}
|
||||
Synchronizer on selectionMode {
|
||||
property alias source: root.selectionMode
|
||||
Item {
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
implicitWidth: closeFab.implicitWidth
|
||||
implicitHeight: closeFab.implicitHeight
|
||||
StyledRectangularShadow {
|
||||
target: closeFab
|
||||
radius: closeFab.buttonRadius
|
||||
}
|
||||
FloatingActionButton {
|
||||
id: closeFab
|
||||
baseSize: 48
|
||||
iconText: "close"
|
||||
onClicked: root.dismiss();
|
||||
StyledToolTip {
|
||||
text: Translation.tr("Close")
|
||||
}
|
||||
colBackground: Appearance.colors.colTertiaryContainer
|
||||
colBackgroundHover: Appearance.colors.colTertiaryContainerHover
|
||||
colRipple: Appearance.colors.colTertiaryContainerActive
|
||||
}
|
||||
}
|
||||
|
||||
onDismiss: root.dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user