mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
@@ -11,6 +11,33 @@ BasePill {
|
|||||||
|
|
||||||
property var widgetData: null
|
property var widgetData: null
|
||||||
property bool compactMode: widgetData?.keyboardLayoutNameCompactMode !== undefined ? widgetData.keyboardLayoutNameCompactMode : SettingsData.keyboardLayoutNameCompactMode
|
property bool compactMode: widgetData?.keyboardLayoutNameCompactMode !== undefined ? widgetData.keyboardLayoutNameCompactMode : SettingsData.keyboardLayoutNameCompactMode
|
||||||
|
readonly property var langCodes: ({
|
||||||
|
"afrikaans": "af", "albanian": "sq", "amharic": "am", "arabic": "ar",
|
||||||
|
"armenian": "hy", "azerbaijani": "az", "basque": "eu", "belarusian": "be",
|
||||||
|
"bengali": "bn", "bosnian": "bs", "bulgarian": "bg", "burmese": "my",
|
||||||
|
"catalan": "ca", "chinese": "zh", "croatian": "hr", "czech": "cs",
|
||||||
|
"danish": "da", "dutch": "nl", "english": "en", "esperanto": "eo",
|
||||||
|
"estonian": "et", "filipino": "fil", "finnish": "fi", "french": "fr",
|
||||||
|
"galician": "gl", "georgian": "ka", "german": "de", "greek": "el",
|
||||||
|
"gujarati": "gu", "hausa": "ha", "hebrew": "he", "hindi": "hi",
|
||||||
|
"hungarian": "hu", "icelandic": "is", "igbo": "ig", "indonesian": "id",
|
||||||
|
"irish": "ga", "italian": "it", "japanese": "ja", "javanese": "jv",
|
||||||
|
"kannada": "kn", "kazakh": "kk", "khmer": "km", "korean": "ko",
|
||||||
|
"kurdish": "ku", "kyrgyz": "ky", "lao": "lo", "latvian": "lv",
|
||||||
|
"lithuanian": "lt", "luxembourgish": "lb", "macedonian": "mk", "malay": "ms",
|
||||||
|
"malayalam": "ml", "maltese": "mt", "maori": "mi", "marathi": "mr",
|
||||||
|
"mongolian": "mn", "nepali": "ne", "norwegian": "no", "pashto": "ps",
|
||||||
|
"persian": "fa", "iranian": "fa", "farsi": "fa", "polish": "pl",
|
||||||
|
"portuguese": "pt", "punjabi": "pa", "romanian": "ro", "russian": "ru",
|
||||||
|
"serbian": "sr", "sindhi": "sd", "sinhala": "si", "slovak": "sk",
|
||||||
|
"slovenian": "sl", "somali": "so", "spanish": "es", "swahili": "sw",
|
||||||
|
"swedish": "sv", "tajik": "tg", "tamil": "ta", "tatar": "tt",
|
||||||
|
"telugu": "te", "thai": "th", "tibetan": "bo", "turkish": "tr",
|
||||||
|
"turkmen": "tk", "ukrainian": "uk", "urdu": "ur", "uyghur": "ug",
|
||||||
|
"uzbek": "uz", "vietnamese": "vi", "welsh": "cy", "yiddish": "yi",
|
||||||
|
"yoruba": "yo", "zulu": "zu"
|
||||||
|
})
|
||||||
|
readonly property var validVariants: ["US", "UK", "GB", "AZERTY", "QWERTY", "Dvorak", "Colemak", "Mac", "Intl", "International"]
|
||||||
property string currentLayout: {
|
property string currentLayout: {
|
||||||
if (CompositorService.isNiri) {
|
if (CompositorService.isNiri) {
|
||||||
return NiriService.getCurrentKeyboardLayoutName();
|
return NiriService.getCurrentKeyboardLayoutName();
|
||||||
@@ -43,11 +70,9 @@ BasePill {
|
|||||||
text: {
|
text: {
|
||||||
if (!root.currentLayout)
|
if (!root.currentLayout)
|
||||||
return "";
|
return "";
|
||||||
const parts = root.currentLayout.split(" ");
|
const lang = root.currentLayout.split(" ")[0].toLowerCase();
|
||||||
if (parts.length > 0) {
|
const code = root.langCodes[lang] || lang.substring(0, 2);
|
||||||
return parts[0].substring(0, 2).toUpperCase();
|
return code.toUpperCase();
|
||||||
}
|
|
||||||
return root.currentLayout.substring(0, 2).toUpperCase();
|
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
color: Theme.widgetTextColor
|
color: Theme.widgetTextColor
|
||||||
@@ -62,7 +87,26 @@ BasePill {
|
|||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: root.currentLayout
|
text: {
|
||||||
|
if (!root.currentLayout)
|
||||||
|
return "";
|
||||||
|
if (root.compactMode && !CompositorService.isHyprland) {
|
||||||
|
const match = root.currentLayout.match(/^(\S+)(?:.*\(([^)]+)\))?/);
|
||||||
|
if (match) {
|
||||||
|
const lang = match[1].toLowerCase();
|
||||||
|
const code = root.langCodes[lang] || lang.substring(0, 2);
|
||||||
|
if (match[2]) {
|
||||||
|
const variant = match[2].trim();
|
||||||
|
const isValid = root.validVariants.some(v => variant.toUpperCase().includes(v.toUpperCase())) || variant.length <= 3;
|
||||||
|
if (isValid)
|
||||||
|
return code + "-" + variant;
|
||||||
|
}
|
||||||
|
return code.toUpperCase();
|
||||||
|
}
|
||||||
|
return root.currentLayout.substring(0, 2).toUpperCase();
|
||||||
|
}
|
||||||
|
return root.currentLayout;
|
||||||
|
}
|
||||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
|
||||||
color: Theme.widgetTextColor
|
color: Theme.widgetTextColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|||||||
Reference in New Issue
Block a user