forked from Shinonome/dots-hyprland
bar: resources/music: dynamic show/hide
This commit is contained in:
@@ -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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 : ''}`
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,32 +5,56 @@ 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
|
||||||
spacing: 4
|
property bool shown: true
|
||||||
|
clip: true
|
||||||
|
implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
color: "transparent"
|
||||||
|
|
||||||
CircularProgress {
|
RowLayout {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
spacing: 4
|
||||||
lineWidth: 2
|
id: resourceRowLayout
|
||||||
value: percentage
|
x: shown ? 0 : -resourceRowLayout.width
|
||||||
size: 26
|
|
||||||
secondaryColor: Appearance.m3colors.m3secondaryContainer
|
|
||||||
primaryColor: Appearance.m3colors.m3onSecondaryContainer
|
|
||||||
|
|
||||||
MaterialSymbol {
|
CircularProgress {
|
||||||
anchors.centerIn: parent
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text: iconName
|
lineWidth: 2
|
||||||
font.pointSize: Appearance.font.pointSize.normal
|
value: percentage
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
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 {
|
Behavior on implicitWidth {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
NumberAnimation {
|
||||||
color: Appearance.colors.colOnLayer1
|
duration: Appearance.animation.elementDecel.duration
|
||||||
text: `${Math.round(percentage * 100)}%`
|
easing.type: Appearance.animation.elementDecel.type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import QtQuick.Layouts
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import "./modules/bar"
|
import "./modules/bar"
|
||||||
|
|
||||||
|
import QtQuick.Window
|
||||||
|
|
||||||
ShellRoot {
|
ShellRoot {
|
||||||
Bar {
|
Bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user