bar/activewindow: format
This commit is contained in:
parent
f5f4c51a73
commit
dc8767e28b
1 changed files with 12 additions and 11 deletions
|
|
@ -13,16 +13,17 @@ Item {
|
|||
required property Brightness.Monitor monitor
|
||||
property color colour: Colours.palette.m3primary
|
||||
|
||||
readonly property string windowTitle: Hypr.activeToplevel?.title ?? qsTr("Desktop")
|
||||
|
||||
function getCompactName() {
|
||||
if (!root.windowTitle || root.windowTitle === qsTr("Desktop"))
|
||||
readonly property string windowTitle: {
|
||||
const title = Hypr.activeToplevel?.title;
|
||||
if (!title)
|
||||
return qsTr("Desktop");
|
||||
// " - " (standard hyphen), " — " (em dash), " – " (en dash)
|
||||
const parts = root.windowTitle.split(/\s+[\-\u2013\u2014]\s+/);
|
||||
if (parts.length > 1)
|
||||
return parts[parts.length - 1].trim();
|
||||
return root.windowTitle;
|
||||
if (Config.bar.activeWindow.compact) {
|
||||
// " - " (standard hyphen), " — " (em dash), " – " (en dash)
|
||||
const parts = root.windowTitle.split(/\s+[\-\u2013\u2014]\s+/);
|
||||
if (parts.length > 1)
|
||||
return parts[parts.length - 1].trim();
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
readonly property int maxHeight: {
|
||||
|
|
@ -58,7 +59,7 @@ Item {
|
|||
TextMetrics {
|
||||
id: metrics
|
||||
|
||||
text: Config.bar.activeWindow.compact ? root.getCompactName() : root.windowTitle
|
||||
text: root.windowTitle
|
||||
font.pointSize: Appearance.font.size.smaller
|
||||
font.family: Appearance.font.family.mono
|
||||
elide: Qt.ElideRight
|
||||
|
|
@ -93,7 +94,7 @@ Item {
|
|||
|
||||
transform: [
|
||||
Translate {
|
||||
x: Config.bar.activeWindow.inverted ? -implicitWidth + text.implicitHeight : 0
|
||||
x: Config.bar.activeWindow.inverted ? -text.implicitWidth + text.implicitHeight : 0
|
||||
},
|
||||
Rotation {
|
||||
angle: Config.bar.activeWindow.inverted ? 270 : 90
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue