diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 07fa5b63..dd364f16 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -95,6 +95,7 @@ Singleton { property bool showNotificationButton: true property bool showBattery: true property bool showControlCenterButton: true + property bool showCapsLockIndicator: true property bool controlCenterShowNetworkIcon: true property bool controlCenterShowBluetoothIcon: true @@ -775,6 +776,7 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr showNotificationButton = true showBattery = true showControlCenterButton = true + showCapsLockIndicator = true saveSettings() } diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index e30c33e1..e1efb66c 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -47,6 +47,7 @@ var SPEC = { showNotificationButton: { def: true }, showBattery: { def: true }, showControlCenterButton: { def: true }, + showCapsLockIndicator: { def: true }, controlCenterShowNetworkIcon: { def: true }, controlCenterShowBluetoothIcon: { def: true }, diff --git a/quickshell/Modules/DankBar/DankBar.qml b/quickshell/Modules/DankBar/DankBar.qml index 546c27b3..f8013f49 100644 --- a/quickshell/Modules/DankBar/DankBar.qml +++ b/quickshell/Modules/DankBar/DankBar.qml @@ -844,6 +844,7 @@ Item { "battery": batteryComponent, "layout": layoutComponent, "controlCenterButton": controlCenterButtonComponent, + "capsLockIndicator": capsLockIndicatorComponent, "idleInhibitor": idleInhibitorComponent, "spacer": spacerComponent, "separator": separatorComponent, @@ -884,6 +885,7 @@ Item { "batteryComponent": batteryComponent, "layoutComponent": layoutComponent, "controlCenterButtonComponent": controlCenterButtonComponent, + "capsLockIndicatorComponent": capsLockIndicatorComponent, "idleInhibitorComponent": idleInhibitorComponent, "spacerComponent": spacerComponent, "separatorComponent": separatorComponent, @@ -1428,6 +1430,16 @@ Item { } } + Component { + id: capsLockIndicatorComponent + + CapsLockIndicator { + widgetThickness: barWindow.widgetThickness + section: topBarContent.getWidgetSection(parent) || "right" + parentScreen: barWindow.screen + } + } + Component { id: idleInhibitorComponent diff --git a/quickshell/Modules/DankBar/WidgetHost.qml b/quickshell/Modules/DankBar/WidgetHost.qml index a3f2ccc6..7c5680aa 100644 --- a/quickshell/Modules/DankBar/WidgetHost.qml +++ b/quickshell/Modules/DankBar/WidgetHost.qml @@ -192,6 +192,7 @@ Loader { "notificationButton": components.notificationButtonComponent, "battery": components.batteryComponent, "controlCenterButton": components.controlCenterButtonComponent, + "capsLockIndicator": components.capsLockIndicatorComponent, "idleInhibitor": components.idleInhibitorComponent, "spacer": components.spacerComponent, "separator": components.separatorComponent, diff --git a/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml b/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml new file mode 100644 index 00000000..e019b550 --- /dev/null +++ b/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml @@ -0,0 +1,53 @@ +import QtQuick +import QtQuick.Controls +import Quickshell +import qs.Common +import qs.Modules.Plugins +import qs.Services +import qs.Widgets + +BasePill { + id: root + + opacity: DMSService.capsLockState ? 1 : 0 + + states: [ + State { + name: "hidden_horizontal" + when: !DMSService.capsLockState && !isVerticalOrientation + PropertyChanges { target: root; width: 0 } + }, + State { + name: "hidden_vertical" + when: !DMSService.capsLockState && isVerticalOrientation + PropertyChanges { target: root; height: 0 } + } + ] + + transitions: [ + Transition { + NumberAnimation { properties: "width,height"; duration: Theme.shortDuration; easing.type: Theme.standardEasing } + } + ] + + Behavior on opacity { + NumberAnimation { + duration: Theme.shortDuration + easing.type: Theme.standardEasing + } + } + + content: Component { + Item { + implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitHeight: root.widgetThickness - root.horizontalPadding * 2 + + DankIcon { + anchors.centerIn: parent + name: "shift_lock" + size: Theme.barIconSize(root.barThickness) + color: Theme.primary + } + } + } +} diff --git a/quickshell/Modules/Settings/DankBarTab.qml b/quickshell/Modules/Settings/DankBarTab.qml index e2246be5..703ee953 100644 --- a/quickshell/Modules/Settings/DankBarTab.qml +++ b/quickshell/Modules/Settings/DankBarTab.qml @@ -155,6 +155,12 @@ Item { "description": I18n.tr("Prevent screen timeout"), "icon": "motion_sensor_active", "enabled": true + }, { + "id": "capsLockIndicator", + "text": I18n.tr("Caps Lock Indicator"), + "description": I18n.tr("Shows when caps lock is active"), + "icon": "shift_lock", + "enabled": true }, { "id": "spacer", "text": I18n.tr("Spacer"),