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