expanded resource usage

This commit is contained in:
Zacharias-Brohn
2025-11-18 01:37:59 +01:00
parent 57746ffc9e
commit bc24ef07d7
5 changed files with 208 additions and 43 deletions
+2
View File
@@ -7,6 +7,7 @@ Singleton {
property alias appCount: adapter.appCount property alias appCount: adapter.appCount
property alias baseBgColor: adapter.baseBgColor property alias baseBgColor: adapter.baseBgColor
property alias baseBorderColor: adapter.baseBorderColor
property alias accentColor: adapter.accentColor property alias accentColor: adapter.accentColor
property alias wallpaperPath: adapter.wallpaperPath property alias wallpaperPath: adapter.wallpaperPath
property alias maxWallpapers: adapter.maxWallpapers property alias maxWallpapers: adapter.maxWallpapers
@@ -29,6 +30,7 @@ Singleton {
property int appCount: 20 property int appCount: 20
property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers" property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers"
property string baseBgColor: "#801a1a1a" property string baseBgColor: "#801a1a1a"
property string baseBorderColor: "#444444"
property AccentColor accentColor: AccentColor {} property AccentColor accentColor: AccentColor {}
property int maxWallpapers: 7 property int maxWallpapers: 7
property bool wallust: false property bool wallust: false
+1 -1
View File
@@ -71,7 +71,7 @@ Scope {
x: Math.round(( parent.width - width ) / 2 ) x: Math.round(( parent.width - width ) / 2 )
color: "#d01a1a1a" color: "#d01a1a1a"
opacity: 1 opacity: 1
border.color: "#444444" border.color: Config.baseBorderColor
border.width: 1 border.width: 1
ParallelAnimation { ParallelAnimation {
-24
View File
@@ -35,7 +35,6 @@ Item {
implicitWidth: 14 implicitWidth: 14
implicitHeight: root.implicitHeight implicitHeight: root.implicitHeight
// Background circle
Rectangle { Rectangle {
id: backgroundCircle id: backgroundCircle
anchors.centerIn: parent anchors.centerIn: parent
@@ -47,7 +46,6 @@ Item {
border.width: 1 border.width: 1
} }
// Pie progress indicator
Canvas { Canvas {
id: progressCanvas id: progressCanvas
anchors.fill: backgroundCircle anchors.fill: backgroundCircle
@@ -80,28 +78,6 @@ Item {
ctx.fill(); ctx.fill();
} }
} }
// // Percentage text
// Item {
// anchors.centerIn: backgroundCircle
// implicitWidth: fullPercentageTextMetrics.width
// implicitHeight: percentageText.implicitHeight
//
// TextMetrics {
// id: fullPercentageTextMetrics
// text: "100"
// font.pixelSize: 12
// }
//
// Text {
// id: percentageText
// anchors.centerIn: parent
// color: "#ffffff"
// font.pixelSize: 12
// font.bold: true
// text: `${Math.round(percentage * 100).toString()}`
// }
// }
} }
} }
} }
+72
View File
@@ -0,0 +1,72 @@
import Quickshell
import QtQuick
import QtQuick.Layouts
import qs.Config
Item {
id: root
required property string resourceName
required property double percentage
required property int warningThreshold
required property string details
required property string iconString
height: columnLayout.childrenRect.height
anchors.left: parent.left
anchors.right: parent.right
ColumnLayout {
id: columnLayout
anchors.fill: parent
spacing: 4
Row {
spacing: 6
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
Text {
font.family: "Material Symbols Rounded"
font.pixelSize: 32
text: root.iconString
color: "#ffffff"
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.resourceName
font.pixelSize: 14
color: "#ffffff"
}
}
Rectangle {
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
Layout.preferredHeight: 6
radius: height / 2
color: "#40000000"
Rectangle {
width: parent.width * Math.min(root.percentage, 1)
height: parent.height
radius: height / 2
color: root.percentage * 100 >= root.warningThreshold ? Config.accentColor.accents.warning : Config.accentColor.accents.primary
Behavior on width {
Anim {
duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.expressiveEffects
}
}
}
}
Text {
Layout.alignment: Qt.AlignLeft
text: root.details
font.pixelSize: 12
color: "#cccccc"
}
}
}
+123 -8
View File
@@ -1,7 +1,10 @@
import QtQuick import QtQuick
import Quickshell import Quickshell
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell.Wayland
import qs.Modules import qs.Modules
import qs.Config
import qs.Effects
Item { Item {
id: root id: root
@@ -76,34 +79,146 @@ Item {
} }
} }
} }
MouseArea { MouseArea {
id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: {
if (popoutLoader.sourceComponent === null) {
popoutLoader.sourceComponent = resourcePopout;
}
}
} }
Loader { Loader {
id: popoutLoader
z: 0
anchors.left: parent.left anchors.left: parent.left
sourceComponent: mouseArea.containsMouse ? resourcePopout : null sourceComponent: null
} }
Component { component ResourcePopout: PanelWindow {
id: resourcePopout id: popoutWindow
PanelWindow { property alias containsMouse: popoutWindow.mouseAreaContainsMouse
property int rectHeight: contentRect.implicitHeight
property bool mouseAreaContainsMouse: mouseArea.containsMouse
WlrLayershell.exclusionMode: ExclusionMode.Ignore
anchors { anchors {
left: true left: true
top: true top: true
right: true right: true
bottom: true bottom: true
} }
color: "transparent" color: "transparent"
mask: Region { item: contentRect }
ShadowRect {
anchors.fill: contentRect
radius: 8
}
ParallelAnimation {
id: openAnim
Anim {
target: contentRect
property: "y"
to: 0 - 1
duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.expressiveEffects
}
}
ParallelAnimation {
id: closeAnim
Anim {
target: contentRect
property: "y"
to: - contentRect.implicitHeight
duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.expressiveEffects
}
onStopped: {
popoutLoader.sourceComponent = null
}
}
Rectangle { Rectangle {
id: contentRect
x: mapFromItem(root, 0, 0).x x: mapFromItem(root, 0, 0).x
implicitHeight: 300 y: - implicitHeight
implicitHeight: contentColumn.childrenRect.height + 20
implicitWidth: root.implicitWidth implicitWidth: root.implicitWidth
color: "#80000000" color: Config.baseBgColor
radius: 12 border.color: Config.baseBorderColor
border.width: 1
bottomLeftRadius: 8
bottomRightRadius: 8
Component.onCompleted: {
openAnim.start();
}
Column {
id: contentColumn
anchors.fill: parent
anchors.margins: 10
spacing: 10
ResourceDetail {
resourceName: qsTr("Memory Usage")
iconString: "\uf7a3"
percentage: ResourceUsage.memoryUsedPercentage
warningThreshold: 95
details: qsTr("%1 of %2 MB used")
.arg(Math.round(ResourceUsage.memoryUsed * 0.001))
.arg(Math.round(ResourceUsage.memoryTotal * 0.001))
}
ResourceDetail {
resourceName: qsTr("CPU Usage")
iconString: "\ue322"
percentage: ResourceUsage.cpuUsage
warningThreshold: 95
details: qsTr("%1% used")
.arg(Math.round(ResourceUsage.cpuUsage * 100))
}
ResourceDetail {
resourceName: qsTr("GPU Usage")
iconString: "\ue30f"
percentage: ResourceUsage.gpuUsage
warningThreshold: 95
details: qsTr("%1% used")
.arg(Math.round(ResourceUsage.gpuUsage * 100))
}
ResourceDetail {
resourceName: qsTr("VRAM Usage")
iconString: "\ue30d"
percentage: ResourceUsage.gpuMemUsage
warningThreshold: 95
details: qsTr("%1% used")
.arg(Math.round(ResourceUsage.gpuMemUsage * 100))
} }
} }
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onExited: {
closeAnim.start();
}
}
}
}
Component {
id: resourcePopout
ResourcePopout { }
} }
} }