bar/statusicons: add lock keys indicator (#514)

* [StatusIcons] Add caps lock indicator

* Seprate CapsLock icon

* Use material icon

* fixes

---------

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
Belal 2025-09-03 12:56:50 +03:00 committed by GitHub
parent dbf87354af
commit 04d867b149
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 106 additions and 10 deletions

View file

@ -349,7 +349,8 @@ The module automatically adds Caelestia shell to the path with **full functional
"showBattery": true, "showBattery": true,
"showBluetooth": true, "showBluetooth": true,
"showKbLayout": false, "showKbLayout": false,
"showNetwork": true "showNetwork": true,
"showLockStatus": true
}, },
"tray": { "tray": {
"background": false, "background": false,

View file

@ -78,6 +78,7 @@ JsonObject {
property bool showNetwork: true property bool showNetwork: true
property bool showBluetooth: true property bool showBluetooth: true
property bool showBattery: true property bool showBattery: true
property bool showLockStatus: true
} }
component Clock: JsonObject { component Clock: JsonObject {

View file

@ -21,14 +21,88 @@ StyledRect {
clip: true clip: true
implicitWidth: Config.bar.sizes.innerWidth implicitWidth: Config.bar.sizes.innerWidth
implicitHeight: iconColumn.implicitHeight + Appearance.padding.normal * 2 implicitHeight: iconColumn.implicitHeight + Appearance.padding.normal * 2 - (Config.bar.status.showLockStatus && !Hypr.capsLock && !Hypr.numLock ? iconColumn.spacing : 0)
ColumnLayout { ColumnLayout {
id: iconColumn id: iconColumn
anchors.centerIn: parent anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: Appearance.padding.normal
spacing: Appearance.spacing.smaller / 2 spacing: Appearance.spacing.smaller / 2
// Lock keys status
WrappedLoader {
name: "lockstatus"
active: Config.bar.status.showLockStatus
sourceComponent: ColumnLayout {
spacing: 0
Item {
implicitWidth: capslockIcon.implicitWidth
implicitHeight: Hypr.capsLock ? capslockIcon.implicitHeight : 0
MaterialIcon {
id: capslockIcon
anchors.centerIn: parent
scale: Hypr.capsLock ? 1 : 0.5
opacity: Hypr.capsLock ? 1 : 0
text: "keyboard_capslock_badge"
color: root.colour
Behavior on opacity {
Anim {}
}
Behavior on scale {
Anim {}
}
}
Behavior on implicitHeight {
Anim {}
}
}
Item {
Layout.topMargin: Hypr.capsLock && Hypr.numLock ? iconColumn.spacing : 0
implicitWidth: numlockIcon.implicitWidth
implicitHeight: Hypr.numLock ? numlockIcon.implicitHeight : 0
MaterialIcon {
id: numlockIcon
anchors.centerIn: parent
scale: Hypr.numLock ? 1 : 0.5
opacity: Hypr.numLock ? 1 : 0
text: "looks_one"
color: root.colour
Behavior on opacity {
Anim {}
}
Behavior on scale {
Anim {}
}
}
Behavior on implicitHeight {
Anim {}
}
}
}
}
// Audio icon // Audio icon
WrappedLoader { WrappedLoader {
name: "audio" name: "audio"
@ -68,6 +142,8 @@ StyledRect {
// Bluetooth section // Bluetooth section
WrappedLoader { WrappedLoader {
Layout.preferredHeight: implicitHeight
name: "bluetooth" name: "bluetooth"
active: Config.bar.status.showBluetooth active: Config.bar.status.showBluetooth
@ -124,6 +200,10 @@ StyledRect {
} }
} }
} }
Behavior on Layout.preferredHeight {
Anim {}
}
} }
// Battery icon // Battery icon
@ -157,13 +237,6 @@ StyledRect {
} }
} }
Behavior on implicitHeight {
Anim {
duration: Appearance.anim.durations.large
easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
component WrappedLoader: Loader { component WrappedLoader: Loader {
required property string name required property string name

View file

@ -58,6 +58,11 @@ Item {
source: "KbLayout.qml" source: "KbLayout.qml"
} }
Popout {
name: "lockstatus"
source: "LockStatus.qml"
}
Repeater { Repeater {
model: ScriptModel { model: ScriptModel {
values: [...SystemTray.items.values] values: [...SystemTray.items.values]

View file

@ -0,0 +1,16 @@
import qs.components
import qs.services
import qs.config
import QtQuick.Layouts
ColumnLayout {
spacing: Appearance.spacing.small
StyledText {
text: qsTr("Capslock: %1").arg(Hypr.capsLock ? "Enabled" : "Disabled")
}
StyledText {
text: qsTr("Numlock: %1").arg(Hypr.numLock ? "Enabled" : "Disabled")
}
}