diff --git a/Modules/Bar/Widgets/KeyboardLayout.qml b/Modules/Bar/Widgets/KeyboardLayout.qml index a09d1e6..74ef083 100644 --- a/Modules/Bar/Widgets/KeyboardLayout.qml +++ b/Modules/Bar/Widgets/KeyboardLayout.qml @@ -13,6 +13,26 @@ Item { property ShellScreen screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" + property string barSection: "" + property int sectionWidgetIndex: -1 + property int sectionWidgetsCount: 0 + + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] + property var widgetSettings: { + var section = barSection.replace("Section", "").toLowerCase() + if (section && sectionWidgetIndex >= 0) { + var widgets = Settings.data.bar.widgets[section] + if (widgets && sectionWidgetIndex < widgets.length) { + return widgets[sectionWidgetIndex] + } + } + return {} + } + + readonly property bool forceOpen: (widgetSettings.forceOpen !== undefined) ? widgetSettings.forceOpen : widgetMetadata.forceOpen + // Use the shared service for keyboard layout property string currentLayout: KeyboardLayoutService.currentLayout @@ -26,8 +46,10 @@ Item { rightOpen: BarWidgetRegistry.getNPillDirection(root) icon: "keyboard" autoHide: false // Important to be false so we can hover as long as we want - text: currentLayout - tooltipText: "Keyboard layout: " + currentLayout + text: currentLayout.toUpperCase() + tooltipText: "Keyboard layout: " + currentLayout.toUpperCase() + forceOpen: root.forceOpen + fontSize: Style.fontSizeS // Use larger font size onClicked: { diff --git a/Modules/SettingsPanel/Bar/BarWidgetSettingsDialog.qml b/Modules/SettingsPanel/Bar/BarWidgetSettingsDialog.qml index 775b148..47b9aaa 100644 --- a/Modules/SettingsPanel/Bar/BarWidgetSettingsDialog.qml +++ b/Modules/SettingsPanel/Bar/BarWidgetSettingsDialog.qml @@ -46,6 +46,7 @@ Popup { "Brightness": "WidgetSettings/BrightnessSettings.qml", "Clock": "WidgetSettings/ClockSettings.qml", "CustomButton": "WidgetSettings/CustomButtonSettings.qml", + "KeyboardLayout": "WidgetSettings/KeyboardLayoutSettings.qml", "MediaMini": "WidgetSettings/MediaMiniSettings.qml", "Microphone": "WidgetSettings/MicrophoneSettings.qml", "NotificationHistory": "WidgetSettings/NotificationHistorySettings.qml", diff --git a/Modules/SettingsPanel/Bar/WidgetSettings/KeyboardLayoutSettings.qml b/Modules/SettingsPanel/Bar/WidgetSettings/KeyboardLayoutSettings.qml new file mode 100644 index 0000000..c97e782 --- /dev/null +++ b/Modules/SettingsPanel/Bar/WidgetSettings/KeyboardLayoutSettings.qml @@ -0,0 +1,31 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import qs.Commons +import qs.Widgets +import qs.Services + +ColumnLayout { + id: root + spacing: Style.marginM * scaling + + // Properties to receive data from parent + property var widgetData: null + property var widgetMetadata: null + + // Local state + property bool valueForceOpen: widgetData.forceOpen !== undefined ? widgetData.forceOpen : widgetMetadata.forceOpen + + function saveSettings() { + var settings = Object.assign({}, widgetData || {}) + settings.forceOpen = valueForceOpen + return settings + } + + NToggle { + label: "Force open" + description: "Keep the keyboard layout widget always expanded." + checked: valueForceOpen + onToggled: checked => valueForceOpen = checked + } +} diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index f104d07..76d36a9 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -104,6 +104,10 @@ Singleton { "Volume": { "allowUserSettings": true, "alwaysShowPercentage": false + }, + "KeyboardLayout": { + "allowUserSettings": true, + "forceOpen": false } }) diff --git a/Widgets/NPill.qml b/Widgets/NPill.qml index 7b57ad8..c385406 100644 --- a/Widgets/NPill.qml +++ b/Widgets/NPill.qml @@ -15,6 +15,7 @@ Item { property bool disableOpen: false property bool rightOpen: false property bool hovered: false + property real fontSize: Style.fontSizeXS // Effective shown state (true if hovered/animated open or forced) readonly property bool revealed: forceOpen || showPill @@ -69,7 +70,7 @@ Item { return centerX + offset } text: root.text - font.pointSize: Style.fontSizeXS * scaling + font.pointSize: root.fontSize * scaling font.weight: Style.fontWeightBold color: Color.mPrimary visible: revealed