hyprland xkb layout indicator: fix weird placement on vertical bar

This commit is contained in:
end-4
2025-09-20 13:02:18 +02:00
parent ed56d03c09
commit 5d1a3fe6a7
3 changed files with 24 additions and 11 deletions
@@ -293,13 +293,19 @@ 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 {
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 color: rightSidebarButton.colText
animateChange: true animateChange: true
} }
} }
}
MaterialSymbol { MaterialSymbol {
Layout.rightMargin: indicatorsRowLayout.realSpacing Layout.rightMargin: indicatorsRowLayout.realSpacing
text: Network.materialSymbol text: Network.materialSymbol
@@ -273,13 +273,20 @@ 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
StyledText {
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 color: rightSidebarButton.colText
animateChange: true animateChange: true
} }
} }
}
MaterialSymbol { MaterialSymbol {
Layout.bottomMargin: indicatorsColumnLayout.realSpacing Layout.bottomMargin: indicatorsColumnLayout.realSpacing
text: Network.materialSymbol text: Network.materialSymbol
@@ -57,7 +57,7 @@ Singleton {
// Match variant: (whitespace + ) variant + whitespace + key + whitespace + description // Match variant: (whitespace + ) variant + whitespace + key + whitespace + description
const matchVariant = line.match(/^\s*(\S+)\s+(\S+)\s+(.+)$/); const matchVariant = line.match(/^\s*(\S+)\s+(\S+)\s+(.+)$/);
if (matchVariant && matchVariant[3] === targetDescription) { if (matchVariant && matchVariant[3] === targetDescription) {
const complexLayout = matchVariant[2] + " " + matchVariant[1]; const complexLayout = matchVariant[2] + matchVariant[1];
root.cachedLayoutCodes[matchVariant[3]] = complexLayout; root.cachedLayoutCodes[matchVariant[3]] = complexLayout;
root.currentLayoutCode = complexLayout; root.currentLayoutCode = complexLayout;
return true; return true;