bar/activewindow: add compact option (#1201)
Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
parent
0903a6a84b
commit
b68f0bae14
5 changed files with 73 additions and 20 deletions
|
|
@ -331,6 +331,10 @@ default, you must create it manually.
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bar": {
|
"bar": {
|
||||||
|
"activeWindow": {
|
||||||
|
"compact": false,
|
||||||
|
"inverted": false
|
||||||
|
},
|
||||||
"clock": {
|
"clock": {
|
||||||
"showIcon": true
|
"showIcon": true
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ JsonObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
component ActiveWindow: JsonObject {
|
component ActiveWindow: JsonObject {
|
||||||
|
property bool compact: false
|
||||||
property bool inverted: false
|
property bool inverted: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,10 @@ Singleton {
|
||||||
capitalisation: bar.workspaces.capitalisation,
|
capitalisation: bar.workspaces.capitalisation,
|
||||||
specialWorkspaceIcons: bar.workspaces.specialWorkspaceIcons
|
specialWorkspaceIcons: bar.workspaces.specialWorkspaceIcons
|
||||||
},
|
},
|
||||||
|
activeWindow: {
|
||||||
|
compact: bar.activeWindow.compact,
|
||||||
|
inverted: bar.activeWindow.inverted
|
||||||
|
},
|
||||||
tray: {
|
tray: {
|
||||||
background: bar.tray.background,
|
background: bar.tray.background,
|
||||||
recolour: bar.tray.recolour,
|
recolour: bar.tray.recolour,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,18 @@ 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")
|
||||||
|
|
||||||
|
function getCompactName() {
|
||||||
|
if (!root.windowTitle || root.windowTitle === qsTr("Desktop"))
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
readonly property int maxHeight: {
|
readonly property int maxHeight: {
|
||||||
const otherModules = bar.children.filter(c => c.id && c.item !== this && c.id !== "spacer");
|
const otherModules = bar.children.filter(c => c.id && c.item !== this && c.id !== "spacer");
|
||||||
const otherHeight = otherModules.reduce((acc, curr) => acc + (curr.item.nonAnimHeight ?? curr.height), 0);
|
const otherHeight = otherModules.reduce((acc, curr) => acc + (curr.item.nonAnimHeight ?? curr.height), 0);
|
||||||
|
|
@ -46,7 +58,7 @@ Item {
|
||||||
TextMetrics {
|
TextMetrics {
|
||||||
id: metrics
|
id: metrics
|
||||||
|
|
||||||
text: Hypr.activeToplevel?.title ?? qsTr("Desktop")
|
text: Config.bar.activeWindow.compact ? root.getCompactName() : 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
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ Item {
|
||||||
|
|
||||||
required property Session session
|
required property Session session
|
||||||
|
|
||||||
|
property bool activeWindowCompact: Config.bar.activeWindow.compact ?? false
|
||||||
|
property bool activeWindowInverted: Config.bar.activeWindow.inverted ?? false
|
||||||
property bool clockShowIcon: Config.bar.clock.showIcon ?? true
|
property bool clockShowIcon: Config.bar.clock.showIcon ?? true
|
||||||
property bool persistent: Config.bar.persistent ?? true
|
property bool persistent: Config.bar.persistent ?? true
|
||||||
property bool showOnHover: Config.bar.showOnHover ?? true
|
property bool showOnHover: Config.bar.showOnHover ?? true
|
||||||
|
|
@ -65,6 +67,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveConfig(entryIndex, entryEnabled) {
|
function saveConfig(entryIndex, entryEnabled) {
|
||||||
|
Config.bar.activeWindow.compact = root.activeWindowCompact;
|
||||||
|
Config.bar.activeWindow.inverted = root.activeWindowInverted;
|
||||||
Config.bar.clock.showIcon = root.clockShowIcon;
|
Config.bar.clock.showIcon = root.clockShowIcon;
|
||||||
Config.bar.persistent = root.persistent;
|
Config.bar.persistent = root.persistent;
|
||||||
Config.bar.showOnHover = root.showOnHover;
|
Config.bar.showOnHover = root.showOnHover;
|
||||||
|
|
@ -595,6 +599,34 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SectionContainer {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
alignTop: true
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: qsTr("Active window")
|
||||||
|
font.pointSize: Appearance.font.size.normal
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchRow {
|
||||||
|
label: qsTr("Compact")
|
||||||
|
checked: root.activeWindowCompact
|
||||||
|
onToggled: checked => {
|
||||||
|
root.activeWindowCompact = checked;
|
||||||
|
root.saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchRow {
|
||||||
|
label: qsTr("Inverted")
|
||||||
|
checked: root.activeWindowInverted
|
||||||
|
onToggled: checked => {
|
||||||
|
root.activeWindowInverted = checked;
|
||||||
|
root.saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|
@ -700,7 +732,7 @@ Item {
|
||||||
propertyName: `monitor${e}`,
|
propertyName: `monitor${e}`,
|
||||||
onToggled: function (_) {
|
onToggled: function (_) {
|
||||||
// if the given monitor is in the excluded list, it should be added back
|
// if the given monitor is in the excluded list, it should be added back
|
||||||
let addedBack = excludedScreens.includes(e)
|
let addedBack = excludedScreens.includes(e);
|
||||||
if (addedBack) {
|
if (addedBack) {
|
||||||
const index = excludedScreens.indexOf(e);
|
const index = excludedScreens.indexOf(e);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue