Keyboard nav
This commit is contained in:
@@ -16,9 +16,20 @@ Item {
|
|||||||
property var systemInfo: ({})
|
property var systemInfo: ({})
|
||||||
property var profiles: []
|
property var profiles: []
|
||||||
property string activeProfile: ""
|
property string activeProfile: ""
|
||||||
|
property int profileIndex: 0
|
||||||
|
|
||||||
function closePopout() { popupOpen = false }
|
function closePopout() { popupOpen = false }
|
||||||
|
|
||||||
|
function selectProfileByDelta(delta) {
|
||||||
|
if (profiles.length === 0) { profileIndex = 0; return }
|
||||||
|
profileIndex = Math.max(0, Math.min(profiles.length - 1, profileIndex + delta))
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateSelectedProfile() {
|
||||||
|
if (profileIndex < 0 || profileIndex >= profiles.length) return
|
||||||
|
setProfile(profiles[profileIndex])
|
||||||
|
}
|
||||||
|
|
||||||
function batteryIcon() {
|
function batteryIcon() {
|
||||||
var device = UPower.displayDevice
|
var device = UPower.displayDevice
|
||||||
if (!device || !device.isPresent) return ""
|
if (!device || !device.isPresent) return ""
|
||||||
@@ -82,6 +93,11 @@ Item {
|
|||||||
}
|
}
|
||||||
profiles = list
|
profiles = list
|
||||||
activeProfile = active
|
activeProfile = active
|
||||||
|
if (profileIndex >= profiles.length) profileIndex = Math.max(0, profiles.length - 1)
|
||||||
|
if (popupOpen && activeProfile !== "") {
|
||||||
|
var idx = profiles.indexOf(activeProfile)
|
||||||
|
if (idx >= 0) profileIndex = idx
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProfile(profile) {
|
function setProfile(profile) {
|
||||||
@@ -90,6 +106,15 @@ Item {
|
|||||||
actionProc.running = true
|
actionProc.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPopupOpenChanged: {
|
||||||
|
if (popupOpen) {
|
||||||
|
refresh()
|
||||||
|
var idx = profiles.indexOf(activeProfile)
|
||||||
|
profileIndex = idx >= 0 ? idx : 0
|
||||||
|
Qt.callLater(function() { if (keyCatcher) keyCatcher.forceActiveFocus() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: refresh()
|
Component.onCompleted: refresh()
|
||||||
|
|
||||||
implicitWidth: button.implicitWidth
|
implicitWidth: button.implicitWidth
|
||||||
@@ -145,7 +170,7 @@ printf 'time\t%s\n' "$($OMARCHY_PATH/bin/omarchy-battery-remaining-time 2>/dev/n
|
|||||||
rightExtraMargin: 2
|
rightExtraMargin: 2
|
||||||
active: UPower.displayDevice && UPower.displayDevice.percentage <= 0.2 && UPower.onBattery
|
active: UPower.displayDevice && UPower.displayDevice.percentage <= 0.2 && UPower.onBattery
|
||||||
tooltipText: ""
|
tooltipText: ""
|
||||||
onPressed: function(b) { root.popupOpen = !root.popupOpen; if (root.popupOpen) root.refresh() }
|
onPressed: function(b) { root.popupOpen = !root.popupOpen }
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardPanel {
|
KeyboardPanel {
|
||||||
@@ -157,12 +182,22 @@ printf 'time\t%s\n' "$($OMARCHY_PATH/bin/omarchy-battery-remaining-time 2>/dev/n
|
|||||||
contentWidth: 340
|
contentWidth: 340
|
||||||
contentHeight: column.implicitHeight + 28
|
contentHeight: column.implicitHeight + 28
|
||||||
|
|
||||||
Column {
|
PanelKeyCatcher {
|
||||||
id: column
|
id: keyCatcher
|
||||||
anchors.left: parent.left
|
anchors.fill: parent
|
||||||
anchors.right: parent.right
|
onMoveRequested: function(dx, dy) {
|
||||||
anchors.top: parent.top
|
if (dx !== 0) root.selectProfileByDelta(dx)
|
||||||
spacing: 16
|
else if (dy !== 0) root.selectProfileByDelta(dy)
|
||||||
|
}
|
||||||
|
onActivateRequested: root.activateSelectedProfile()
|
||||||
|
onCloseRequested: root.closePopout()
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: column
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
spacing: 16
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -238,6 +273,7 @@ printf 'time\t%s\n' "$($OMARCHY_PATH/bin/omarchy-battery-remaining-time 2>/dev/n
|
|||||||
model: root.profiles
|
model: root.profiles
|
||||||
CursorPill {
|
CursorPill {
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
required property int index
|
||||||
text: String(modelData).charAt(0).toUpperCase() + String(modelData).slice(1)
|
text: String(modelData).charAt(0).toUpperCase() + String(modelData).slice(1)
|
||||||
foreground: root.bar.foreground
|
foreground: root.bar.foreground
|
||||||
background: Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.04)
|
background: Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.04)
|
||||||
@@ -247,13 +283,18 @@ printf 'time\t%s\n' "$($OMARCHY_PATH/bin/omarchy-battery-remaining-time 2>/dev/n
|
|||||||
horizontalPadding: 10
|
horizontalPadding: 10
|
||||||
verticalPadding: 6
|
verticalPadding: 6
|
||||||
active: root.activeProfile === modelData
|
active: root.activeProfile === modelData
|
||||||
|
hasCursor: root.profileIndex === index
|
||||||
onClicked: root.setProfile(modelData)
|
onClicked: root.setProfile(modelData)
|
||||||
|
onHovered: function(h) {
|
||||||
|
if (h) root.profileIndex = index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
component InfoPair: Row {
|
component InfoPair: Row {
|
||||||
property string label: ""
|
property string label: ""
|
||||||
|
|||||||
Reference in New Issue
Block a user