summaryrefslogtreecommitdiff
path: root/modules/bar/components/ActiveWindow.qml
diff options
context:
space:
mode:
authorLaurens Duin <85798751+Laurens256@users.noreply.github.com>2025-08-13 06:31:48 +0200
committerGitHub <noreply@github.com>2025-08-13 14:31:48 +1000
commit3710df29f588c2aa430d9797a36afa1cbd85b128 (patch)
tree5f804118369ab2db0dbffbbd604b4ddc33af93ed /modules/bar/components/ActiveWindow.qml
parentnix: add home manager module (#402) (diff)
downloadcaelestia-shell-3710df29f588c2aa430d9797a36afa1cbd85b128.tar.gz
caelestia-shell-3710df29f588c2aa430d9797a36afa1cbd85b128.tar.bz2
caelestia-shell-3710df29f588c2aa430d9797a36afa1cbd85b128.zip
bar: allow hiding items and reordering (#379)
* feat: reorder bar, no popout yet * chore: cleanup * refactor: use DelegateChooser * feat: popouts * chore: cleanup * better popout check + fix async stuff + bar interaction + a bunch of other fixes * fix activewindow and bar vertical padding * readme: add config opt * bar: fix top/bottom padding * bar: better wheel behaviour --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Diffstat (limited to 'modules/bar/components/ActiveWindow.qml')
-rw-r--r--modules/bar/components/ActiveWindow.qml97
1 files changed, 43 insertions, 54 deletions
diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml
index de0f0ad..3bea956 100644
--- a/modules/bar/components/ActiveWindow.qml
+++ b/modules/bar/components/ActiveWindow.qml
@@ -9,73 +9,62 @@ import QtQuick
Item {
id: root
+ required property var bar
required property Brightness.Monitor monitor
property color colour: Colours.palette.m3primary
- readonly property Item child: child
- implicitWidth: child.implicitWidth
- implicitHeight: child.implicitHeight
-
- Item {
- id: child
-
- property Item current: text1
-
- anchors.centerIn: parent
+ readonly property int maxHeight: {
+ const otherModules = bar.children.filter(c => c.id && c.item !== this && c.id !== "spacer");
+ const otherHeight = otherModules.reduce((acc, curr) => acc + curr.height, 0);
+ // Length - 2 cause repeater counts as a child
+ return bar.height - otherHeight - bar.spacing * (bar.children.length - 1) - bar.vPadding * 2;
+ }
+ property Title current: text1
- clip: true
- implicitWidth: Math.max(icon.implicitWidth, current.implicitHeight)
- implicitHeight: icon.implicitHeight + current.implicitWidth + current.anchors.topMargin
+ clip: true
+ implicitWidth: Math.max(icon.implicitWidth, current.implicitHeight)
+ implicitHeight: icon.implicitHeight + current.implicitWidth + current.anchors.topMargin
- MaterialIcon {
- id: icon
+ MaterialIcon {
+ id: icon
- animate: true
- text: Icons.getAppCategoryIcon(Hyprland.activeToplevel?.lastIpcObject.class, "desktop_windows")
- color: root.colour
+ anchors.horizontalCenter: parent.horizontalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- }
+ animate: true
+ text: Icons.getAppCategoryIcon(Hyprland.activeToplevel?.lastIpcObject.class, "desktop_windows")
+ color: root.colour
+ }
- Title {
- id: text1
- }
+ Title {
+ id: text1
+ }
- Title {
- id: text2
- }
+ Title {
+ id: text2
+ }
- TextMetrics {
- id: metrics
+ TextMetrics {
+ id: metrics
- text: Hyprland.activeToplevel?.title ?? qsTr("Desktop")
- font.pointSize: Appearance.font.size.smaller
- font.family: Appearance.font.family.mono
- elide: Qt.ElideRight
- elideWidth: root.height - icon.height
+ text: Hyprland.activeToplevel?.title ?? qsTr("Desktop")
+ font.pointSize: Appearance.font.size.smaller
+ font.family: Appearance.font.family.mono
+ elide: Qt.ElideRight
+ elideWidth: root.maxHeight - icon.height
- onTextChanged: {
- const next = child.current === text1 ? text2 : text1;
- next.text = elidedText;
- child.current = next;
- }
- onElideWidthChanged: child.current.text = elidedText
- }
-
- Behavior on implicitWidth {
- NumberAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.emphasized
- }
+ onTextChanged: {
+ const next = root.current === text1 ? text2 : text1;
+ next.text = elidedText;
+ root.current = next;
}
+ onElideWidthChanged: root.current.text = elidedText
+ }
- Behavior on implicitHeight {
- NumberAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.emphasized
- }
+ Behavior on implicitHeight {
+ NumberAnimation {
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
@@ -89,7 +78,7 @@ Item {
font.pointSize: metrics.font.pointSize
font.family: metrics.font.family
color: root.colour
- opacity: child.current === this ? 1 : 0
+ opacity: root.current === this ? 1 : 0
transform: Rotation {
angle: 90