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 {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
easing.bezierCurve: Appearance.animation.elementDecel.bezierCurve
}
}
+1 -1
View File
@@ -77,7 +77,7 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight // Truncates the text on the right
color: Appearance.colors.colOnLayer1
text: `${cleanedTitle} ${activePlayer?.trackArtist}`
text: `${cleanedTitle}${activePlayer?.trackArtist ? ' • ' + activePlayer.trackArtist : ''}`
}
}
+44 -20
View File
@@ -5,32 +5,56 @@ import QtQuick.Layouts
import Quickshell
import Quickshell.Io
RowLayout {
Rectangle {
required property string iconName
required property double percentage
spacing: 4
property bool shown: true
clip: true
implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width
implicitHeight: childrenRect.height
color: "transparent"
CircularProgress {
Layout.alignment: Qt.AlignVCenter
lineWidth: 2
value: percentage
size: 26
secondaryColor: Appearance.m3colors.m3secondaryContainer
primaryColor: Appearance.m3colors.m3onSecondaryContainer
RowLayout {
spacing: 4
id: resourceRowLayout
x: shown ? 0 : -resourceRowLayout.width
MaterialSymbol {
anchors.centerIn: parent
text: iconName
font.pointSize: Appearance.font.pointSize.normal
color: Appearance.m3colors.m3onSecondaryContainer
CircularProgress {
Layout.alignment: Qt.AlignVCenter
lineWidth: 2
value: percentage
size: 26
secondaryColor: Appearance.m3colors.m3secondaryContainer
primaryColor: Appearance.m3colors.m3onSecondaryContainer
MaterialSymbol {
anchors.centerIn: parent
text: iconName
font.pointSize: Appearance.font.pointSize.normal
color: Appearance.m3colors.m3onSecondaryContainer
}
}
StyledText {
Layout.alignment: Qt.AlignVCenter
color: Appearance.colors.colOnLayer1
text: `${Math.round(percentage * 100)}%`
}
Behavior on x {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
}
StyledText {
Layout.alignment: Qt.AlignVCenter
color: Appearance.colors.colOnLayer1
text: `${Math.round(percentage * 100)}%`
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 Quickshell
import Quickshell.Io
import Quickshell.Services.Mpris
Rectangle {
implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2
implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin
implicitHeight: 32
color: Appearance.colors.colLayer1
radius: Appearance.rounding.small
@@ -14,20 +15,28 @@ Rectangle {
RowLayout {
id: rowLayout
spacing: 4
anchors.centerIn: parent
spacing: 0
anchors.fill: parent
anchors.leftMargin: 4
anchors.rightMargin: 4
Resource {
iconName: "memory"
percentage: ResourceUsage.memoryUsedPercentage
}
Resource {
iconName: "swap_horiz"
percentage: ResourceUsage.swapUsedPercentage
shown: ConfigOptions.bar.resources.alwaysShowSwap || (MprisController.activePlayer == null)
Layout.leftMargin: shown ? 4 : 0
}
Resource {
iconName: "settings_slow_motion"
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 int duration: 350
property int type: Easing.OutQuint
property int type: Easing.OutExpo
}
}
@@ -6,6 +6,10 @@ Singleton {
property QtObject bar: QtObject {
property int workspacesShown: 10
property int batteryLowThreshold: 20
property QtObject resources: QtObject {
property bool alwaysShowSwap: true
property bool alwaysShowCpu: false
}
}
property QtObject resources: QtObject {
property int updateInterval: 3000
+3
View File
@@ -4,8 +4,11 @@ import QtQuick.Layouts
import Quickshell
import "./modules/bar"
import QtQuick.Window
ShellRoot {
Bar {
}
}