mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
Added a Compact mode to the keyboard_layout_name widget. (#554)
* Added a Compact mode to the keyboard_layout_name widget. * Added another root.currentLayout = "Unknown" that was missing.
This commit is contained in:
@@ -11,6 +11,7 @@ import qs.Widgets
|
||||
BasePill {
|
||||
id: root
|
||||
|
||||
property bool compactMode: SettingsData.keyboardLayoutNameCompactMode
|
||||
property string currentLayout: ""
|
||||
property string hyprlandKeyboard: ""
|
||||
|
||||
@@ -109,8 +110,31 @@ BasePill {
|
||||
const data = JSON.parse(output)
|
||||
const mainKeyboard = data.keyboards.find(kb => kb.main === true)
|
||||
root.hyprlandKeyboard = mainKeyboard.name
|
||||
if (mainKeyboard && mainKeyboard.active_keymap) {
|
||||
root.currentLayout = mainKeyboard.active_keymap
|
||||
|
||||
if (mainKeyboard) {
|
||||
const layout = mainKeyboard.layout
|
||||
const variant = mainKeyboard.variant
|
||||
const index = mainKeyboard.active_layout_index
|
||||
|
||||
if (root.compactMode && layout && variant && index !== undefined) {
|
||||
const layouts = mainKeyboard.layout.split(",")
|
||||
const variants = mainKeyboard.variant.split(",")
|
||||
const index = mainKeyboard.active_layout_index
|
||||
|
||||
if (layouts[index] && variants[index] !== undefined) {
|
||||
if (variants[index] === "") {
|
||||
root.currentLayout = layouts[index]
|
||||
} else {
|
||||
root.currentLayout = layouts[index] + "-" + variants[index]
|
||||
}
|
||||
} else {
|
||||
root.currentLayout = "Unknown"
|
||||
}
|
||||
} else if (mainKeyboard && mainKeyboard.active_keymap) {
|
||||
root.currentLayout = mainKeyboard.active_keymap
|
||||
} else {
|
||||
root.currentLayout = "Unknown"
|
||||
}
|
||||
} else {
|
||||
root.currentLayout = "Unknown"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user