Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 71 additions & 9 deletions ryoku/shell/quickshell/ryoshot/RegionBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ Item {
property bool keypressesOn: false
property bool webcamOn: false
property int delaySeconds: 0
property bool hintsVisible: true

Timer {
id: hintTimer
interval: 1400
onTriggered: bar.hintsVisible = false
}

onVisibleChanged: {
if (visible) {
hintsVisible = true;
hintTimer.restart();
} else {
hintTimer.stop();
hintsVisible = false;
}
}

Component.onCompleted: {
if (visible) {
hintsVisible = true;
hintTimer.restart();
}
}

signal actionPicked(string id)
signal colorPickRequested()
Expand Down Expand Up @@ -67,6 +91,7 @@ Item {
id: tab
required property var modelData
readonly property bool current: bar.activeAction === modelData.id
readonly property bool showKey: bar.hintsVisible && !!(tab.modelData && tab.modelData.key)
width: tabContent.implicitWidth + 22
height: 34
radius: height / 2
Expand All @@ -77,21 +102,58 @@ Item {
id: tabContent
anchors.centerIn: parent
spacing: 6

Icon {
anchors.verticalCenter: parent.verticalCenter
name: tab.modelData.icon
size: 17
tint: tab.current ? Theme.accentInk
: (tabMa.containsMouse ? Theme.ink : Theme.inkDim)
}
Text {
Row {
anchors.verticalCenter: parent.verticalCenter
text: tab.modelData.label
font.family: Theme.ui
font.pixelSize: 13
font.weight: tab.current ? Font.DemiBold : Font.Normal
color: tab.current ? Theme.accentInk
: (tabMa.containsMouse ? Theme.ink : Theme.inkDim)
spacing: tab.showKey ? 5 : 0
Behavior on spacing {
NumberAnimation { duration: 250; easing.type: Easing.OutCubic }
}

Text {
anchors.verticalCenter: parent.verticalCenter
text: tab.modelData.label
font.family: Theme.ui
font.pixelSize: 13
font.weight: tab.current ? Font.DemiBold : Font.Normal
color: tab.current ? Theme.accentInk
: (tabMa.containsMouse ? Theme.ink : Theme.inkDim)
}
Item {
id: keySlot
anchors.verticalCenter: parent.verticalCenter
width: tab.showKey ? keyText.implicitWidth : 0
height: keyText.implicitHeight
clip: true
visible: tab.showKey || width > 0

Behavior on width {
NumberAnimation { duration: 250; easing.type: Easing.OutCubic }
}

Text {
id: keyText
anchors.centerIn: parent
text: (tab.modelData && tab.modelData.key ? tab.modelData.key : "").toUpperCase()
font.family: Theme.mono
font.pixelSize: 10
font.weight: Font.Medium
color: tab.current ? Theme.accentInk
: (tabMa.containsMouse ? Theme.inkDim : Theme.inkFaint)
opacity: tab.showKey ? (tab.current ? 0.8 : 0.55) : 0

Behavior on opacity {
NumberAnimation { duration: 200; easing.type: Easing.OutCubic }
}
}
}
}
}

Expand Down Expand Up @@ -189,13 +251,13 @@ Item {
IconButton {
Layout.alignment: Qt.AlignVCenter
icon: "eyedropper"
tooltip: I18n.tr("Pick a colour")
tooltip: I18n.tr("Pick a colour") + " (C)"
onClicked: bar.colorPickRequested()
}
IconButton {
Layout.alignment: Qt.AlignVCenter
icon: "fullscreen"
tooltip: I18n.tr("Capture this monitor")
tooltip: I18n.tr("Capture this monitor") + " (Enter)"
onClicked: bar.fullscreenRequested()
}
IconButton {
Expand Down
30 changes: 22 additions & 8 deletions ryoku/shell/quickshell/ryoshot/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ ShellRoot {
// capture and colour pick know which output the cursor sits on.
property var lastPointer: null
readonly property var frontActions: [
{ id: "shot", icon: "camera", label: I18n.tr("Shot") },
{ id: "edit", icon: "pen", label: I18n.tr("Edit") },
{ id: "ocr", icon: "ocr", label: I18n.tr("OCR") },
{ id: "search", icon: "magnify", label: I18n.tr("Search") },
{ id: "record", icon: "video", label: I18n.tr("Record") }
{ id: "shot", icon: "camera", label: I18n.tr("Shot"), key: "s" },
{ id: "edit", icon: "pen", label: I18n.tr("Edit"), key: "e" },
{ id: "ocr", icon: "ocr", label: I18n.tr("OCR"), key: "o" },
{ id: "search", icon: "magnify", label: I18n.tr("Search"), key: "f" },
{ id: "record", icon: "video", label: I18n.tr("Record"), key: "r" }
]
// RYOSHOT_OPEN=<path>: skip selection and open that image straight in the
// beautify editor. fromFile makes Escape / close quit, since there is no live
Expand Down Expand Up @@ -1467,15 +1467,29 @@ ShellRoot {
}
return false;
}
var ctrl = (e.modifiers & Qt.ControlModifier) !== 0;
var alt = (e.modifiers & Qt.AltModifier) !== 0;
var shift = (e.modifiers & Qt.ShiftModifier) !== 0;

if (e.key === Qt.Key_Space) { root.cycleTarget(); return true; }
if (e.key === Qt.Key_A && (e.modifiers & Qt.ControlModifier)) { root.wholeMonitor(); return true; }
if (e.key === Qt.Key_Question) { root.shortcutsOpen = !root.shortcutsOpen; return true; }
// Number keys pick the action; the count matches frontActions.
if (ctrl && e.key === Qt.Key_A) { root.wholeMonitor(); return true; }
if (e.key === Qt.Key_Question || (shift && e.key === Qt.Key_Slash)) {
root.shortcutsOpen = !root.shortcutsOpen;
return true;
}
if (ctrl || alt) return false;

// Number keys or action mnemonics pick the action.
if (e.key >= Qt.Key_1 && e.key <= Qt.Key_5) {
var d = root.frontActions[e.key - Qt.Key_1];
if (d) { root.setFrontAction(d.id); return true; }
return false;
}
if (e.key === Qt.Key_S) { root.setFrontAction("shot"); return true; }
if (e.key === Qt.Key_E) { root.setFrontAction("edit"); return true; }
if (e.key === Qt.Key_O) { root.setFrontAction("ocr"); return true; }
if (e.key === Qt.Key_F) { root.setFrontAction("search"); return true; }
if (e.key === Qt.Key_R) { root.setFrontAction("record"); return true; }
if (e.key === Qt.Key_C) { root.startColorPick(); return true; }
if (e.key === Qt.Key_Return || e.key === Qt.Key_Enter) {
var m = root.lastPointer ? root.monitorAt(root.lastPointer.x, root.lastPointer.y) : null;
Expand Down
Loading