bar: resources/music: dynamic show/hide

This commit is contained in:
end-4
2025-04-11 16:03:54 +02:00
parent d9ed5434ac
commit c29041aa9e
7 changed files with 65 additions and 26 deletions
@@ -80,7 +80,6 @@ Rectangle {
NumberAnimation { NumberAnimation {
duration: Appearance.animation.elementDecel.duration duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type easing.type: Appearance.animation.elementDecel.type
easing.bezierCurve: Appearance.animation.elementDecel.bezierCurve
} }
} }
+1 -1
View File
@@ -77,7 +77,7 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight // Truncates the text on the right elide: Text.ElideRight // Truncates the text on the right
color: Appearance.colors.colOnLayer1 color: Appearance.colors.colOnLayer1
text: `${cleanedTitle} ${activePlayer?.trackArtist}` text: `${cleanedTitle}${activePlayer?.trackArtist ? ' • ' + activePlayer.trackArtist : ''}`
} }
} }
+25 -1
View File
@@ -5,10 +5,19 @@ import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
RowLayout { Rectangle {
required property string iconName required property string iconName
required property double percentage required property double percentage
property bool shown: true
clip: true
implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width
implicitHeight: childrenRect.height
color: "transparent"
RowLayout {
spacing: 4 spacing: 4
id: resourceRowLayout
x: shown ? 0 : -resourceRowLayout.width
CircularProgress { CircularProgress {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
@@ -33,4 +42,19 @@ RowLayout {
text: `${Math.round(percentage * 100)}%` text: `${Math.round(percentage * 100)}%`
} }
Behavior on x {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
}
Behavior on implicitWidth {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
} }
+12 -3
View File
@@ -4,9 +4,10 @@ import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import Quickshell.Services.Mpris
Rectangle { Rectangle {
implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin
implicitHeight: 32 implicitHeight: 32
color: Appearance.colors.colLayer1 color: Appearance.colors.colLayer1
radius: Appearance.rounding.small radius: Appearance.rounding.small
@@ -14,20 +15,28 @@ Rectangle {
RowLayout { RowLayout {
id: rowLayout id: rowLayout
spacing: 4 spacing: 0
anchors.centerIn: parent anchors.fill: parent
anchors.leftMargin: 4
anchors.rightMargin: 4
Resource { Resource {
iconName: "memory" iconName: "memory"
percentage: ResourceUsage.memoryUsedPercentage percentage: ResourceUsage.memoryUsedPercentage
} }
Resource { Resource {
iconName: "swap_horiz" iconName: "swap_horiz"
percentage: ResourceUsage.swapUsedPercentage percentage: ResourceUsage.swapUsedPercentage
shown: ConfigOptions.bar.resources.alwaysShowSwap || (MprisController.activePlayer == null)
Layout.leftMargin: shown ? 4 : 0
} }
Resource { Resource {
iconName: "settings_slow_motion" iconName: "settings_slow_motion"
percentage: ResourceUsage.cpuUsage percentage: ResourceUsage.cpuUsage
shown: ConfigOptions.bar.resources.alwaysShowCpu || (MprisController.activePlayer == null)
Layout.leftMargin: shown ? 4 : 0
} }
} }
@@ -146,7 +146,7 @@ Singleton {
} }
property QtObject menuDecel: QtObject { property QtObject menuDecel: QtObject {
property int duration: 350 property int duration: 350
property int type: Easing.OutQuint property int type: Easing.OutExpo
} }
} }
@@ -6,6 +6,10 @@ Singleton {
property QtObject bar: QtObject { property QtObject bar: QtObject {
property int workspacesShown: 10 property int workspacesShown: 10
property int batteryLowThreshold: 20 property int batteryLowThreshold: 20
property QtObject resources: QtObject {
property bool alwaysShowSwap: true
property bool alwaysShowCpu: false
}
} }
property QtObject resources: QtObject { property QtObject resources: QtObject {
property int updateInterval: 3000 property int updateInterval: 3000
+3
View File
@@ -4,8 +4,11 @@ import QtQuick.Layouts
import Quickshell import Quickshell
import "./modules/bar" import "./modules/bar"
import QtQuick.Window
ShellRoot { ShellRoot {
Bar { Bar {
} }
} }