forked from Shinonome/dots-hyprland
A simple function to slice keyboard variants to avoid overflow of text when using vertical bars
I added a function that slices keyboard variants to be at most 4 characters long to avoid text overflow, especially when you set the bar to be vertical.
This commit is contained in:
@@ -6,10 +6,16 @@ import qs.modules.common.widgets
|
|||||||
Loader {
|
Loader {
|
||||||
id: root
|
id: root
|
||||||
property bool vertical: false
|
property bool vertical: false
|
||||||
|
|
||||||
active: HyprlandXkb.layoutCodes.length > 1
|
active: HyprlandXkb.layoutCodes.length > 1
|
||||||
visible: active
|
visible: active
|
||||||
|
|
||||||
|
function abbreviateLayoutCode(fullCode) {
|
||||||
|
return fullCode.split(':').map(layout => {
|
||||||
|
const baseLayout = layout.split('-')[0];
|
||||||
|
return baseLayout.length > 4 ? baseLayout.slice(0, 4) : baseLayout;
|
||||||
|
}).join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
sourceComponent: Item {
|
sourceComponent: Item {
|
||||||
implicitWidth: root.vertical ? null : layoutCodeText.implicitWidth
|
implicitWidth: root.vertical ? null : layoutCodeText.implicitWidth
|
||||||
implicitHeight: root.vertical ? layoutCodeText.implicitHeight : null
|
implicitHeight: root.vertical ? layoutCodeText.implicitHeight : null
|
||||||
@@ -18,7 +24,7 @@ Loader {
|
|||||||
id: layoutCodeText
|
id: layoutCodeText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: HyprlandXkb.currentLayoutCode.split(":").join("\n")
|
text: abbreviateLayoutCode(HyprlandXkb.currentLayoutCode)
|
||||||
font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smallie : Appearance.font.pixelSize.small
|
font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smallie : Appearance.font.pixelSize.small
|
||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
animateChange: true
|
animateChange: true
|
||||||
|
|||||||
Reference in New Issue
Block a user