forked from Shinonome/dots-hyprland
bar: fixed kb layout+variant display in top right (#2016)
This commit is contained in:
@@ -293,11 +293,17 @@ Item { // Bar content region
|
|||||||
active: HyprlandXkb.layoutCodes.length > 1
|
active: HyprlandXkb.layoutCodes.length > 1
|
||||||
visible: active
|
visible: active
|
||||||
Layout.rightMargin: indicatorsRowLayout.realSpacing
|
Layout.rightMargin: indicatorsRowLayout.realSpacing
|
||||||
sourceComponent: StyledText {
|
sourceComponent: Item {
|
||||||
text: HyprlandXkb.currentLayoutCode
|
implicitWidth: layoutCodeText.implicitWidth
|
||||||
font.pixelSize: Appearance.font.pixelSize.small
|
StyledText {
|
||||||
color: rightSidebarButton.colText
|
id: layoutCodeText
|
||||||
animateChange: true
|
anchors.centerIn: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: HyprlandXkb.currentLayoutCode.split(":").join("\n")
|
||||||
|
font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smaller : Appearance.font.pixelSize.small
|
||||||
|
color: rightSidebarButton.colText
|
||||||
|
animateChange: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
|
|||||||
@@ -273,11 +273,18 @@ Item { // Bar content region
|
|||||||
active: HyprlandXkb.layoutCodes.length > 1
|
active: HyprlandXkb.layoutCodes.length > 1
|
||||||
visible: active
|
visible: active
|
||||||
Layout.bottomMargin: indicatorsColumnLayout.realSpacing
|
Layout.bottomMargin: indicatorsColumnLayout.realSpacing
|
||||||
sourceComponent: StyledText {
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: HyprlandXkb.currentLayoutCode
|
sourceComponent: Item {
|
||||||
font.pixelSize: Appearance.font.pixelSize.small
|
implicitHeight: layoutCodeText.implicitHeight
|
||||||
color: rightSidebarButton.colText
|
StyledText {
|
||||||
animateChange: true
|
id: layoutCodeText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: HyprlandXkb.currentLayoutCode.split(":").join("\n")
|
||||||
|
font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smaller : Appearance.font.pixelSize.small
|
||||||
|
color: rightSidebarButton.colText
|
||||||
|
animateChange: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
|
|||||||
@@ -46,13 +46,24 @@ Singleton {
|
|||||||
if (!line.trim() || line.trim().startsWith('!'))
|
if (!line.trim() || line.trim().startsWith('!'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Match: key + whitespace + description
|
// Match layout: (whitespace + ) key + whitespace + description
|
||||||
const match = line.match(/^\s*(\S+)\s+(.+)$/);
|
const matchLayout = line.match(/^\s*(\S+)\s+(.+)$/);
|
||||||
if (match && match[2] === targetDescription) {
|
if (matchLayout && matchLayout[2] === targetDescription) {
|
||||||
root.cachedLayoutCodes[match[2]] = match[1];
|
root.cachedLayoutCodes[matchLayout[2]] = matchLayout[1];
|
||||||
root.currentLayoutCode = match[1];
|
root.currentLayoutCode = matchLayout[1];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Match variant: (whitespace + ) variant + whitespace + key + whitespace + description
|
||||||
|
const matchVariant = line.match(/^\s*(\S+)\s+(\S+)\s+(.+)$/);
|
||||||
|
if (matchVariant && matchVariant[3] === targetDescription) {
|
||||||
|
const complexLayout = matchVariant[2] + matchVariant[1];
|
||||||
|
root.cachedLayoutCodes[matchVariant[3]] = complexLayout;
|
||||||
|
root.currentLayoutCode = complexLayout;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
// console.log("[HyprlandXkb] Found line:", foundLine);
|
// console.log("[HyprlandXkb] Found line:", foundLine);
|
||||||
// console.log("[HyprlandXkb] Layout:", root.currentLayoutName, "| Code:", root.currentLayoutCode);
|
// console.log("[HyprlandXkb] Layout:", root.currentLayoutName, "| Code:", root.currentLayoutCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user