1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

anotehr qmlfmt round and extra GPU data

This commit is contained in:
bbedward
2025-08-08 19:17:53 -04:00
parent 6c8e6568dc
commit 0a22565cbd
5 changed files with 804 additions and 499 deletions

View File

@@ -17,6 +17,7 @@ Singleton {
property string profileLastPath: ""
property bool doNotDisturb: false
property var pinnedApps: []
property int selectedGpuIndex: 0
Component.onCompleted: {
loadSettings()
@@ -37,6 +38,7 @@ Singleton {
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : []
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0
}
} catch (e) {
@@ -50,7 +52,8 @@ Singleton {
"wallpaperLastPath": wallpaperLastPath,
"profileLastPath": profileLastPath,
"doNotDisturb": doNotDisturb,
"pinnedApps": pinnedApps
"pinnedApps": pinnedApps,
"selectedGpuIndex": selectedGpuIndex
}, null, 2))
}
@@ -115,6 +118,11 @@ Singleton {
return appId && pinnedApps.indexOf(appId) !== -1
}
function setSelectedGpuIndex(index) {
selectedGpuIndex = index
saveSettings()
}
FileView {
id: settingsFile

View File

@@ -237,12 +237,34 @@ Row {
width: (parent.width - Theme.spacingM * 2) / 3
height: 80
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.08)
color: {
if (gpuCardMouseArea.containsMouse
&& SysMonitorService.availableGpus.length > 1)
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.16)
else
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.08)
}
border.color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.2)
border.width: 1
MouseArea {
id: gpuCardMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: SysMonitorService.availableGpus.length
> 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (SysMonitorService.availableGpus.length > 1) {
var nextIndex = (SessionData.selectedGpuIndex + 1)
% SysMonitorService.availableGpus.length
SessionData.setSelectedGpuIndex(nextIndex)
}
}
}
Column {
anchors.left: parent.left
anchors.leftMargin: Theme.spacingM
@@ -250,7 +272,7 @@ Row {
spacing: 2
StyledText {
text: "Graphics"
text: "GPU"
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: Theme.secondary
@@ -261,29 +283,15 @@ Row {
text: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return "None"
return "--°"
}
if (SysMonitorService.availableGpus.length === 1) {
var gpu = SysMonitorService.availableGpus[0]
var temp = gpu.temperature
var tempText = (temp === undefined || temp === null
|| temp === 0) ? "--°" : Math.round(temp) + "°"
return tempText
}
// Multiple GPUs - show average temp
var totalTemp = 0
var validTemps = 0
for (var i = 0; i < SysMonitorService.availableGpus.length; i++) {
var temp = SysMonitorService.availableGpus[i].temperature
if (temp !== undefined && temp !== null && temp > 0) {
totalTemp += temp
validTemps++
}
}
if (validTemps > 0) {
return Math.round(totalTemp / validTemps) + "°"
}
return "--°"
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length - 1)]
var temp = gpu.temperature
return (temp === undefined || temp === null
|| temp === 0) ? "--°" : Math.round(temp) + "°"
}
font.pixelSize: Theme.fontSizeLarge
font.family: SettingsData.monoFontFamily
@@ -293,25 +301,15 @@ Row {
|| SysMonitorService.availableGpus.length === 0) {
return Theme.surfaceText
}
if (SysMonitorService.availableGpus.length === 1) {
var temp = SysMonitorService.availableGpus[0].temperature || 0
if (temp > 80)
return Theme.tempDanger
if (temp > 60)
return Theme.tempWarning
return Theme.surfaceText
}
// Multiple GPUs - get max temp for coloring
var maxTemp = 0
for (var i = 0; i < SysMonitorService.availableGpus.length; i++) {
var temp = SysMonitorService.availableGpus[i].temperature || 0
if (temp > maxTemp)
maxTemp = temp
}
if (maxTemp > 80)
return Theme.tempDanger
if (maxTemp > 60)
return Theme.tempWarning
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length - 1)]
var temp = gpu.temperature || 0
if (temp > 80)
return Theme.error
if (temp > 60)
return Theme.warning
return Theme.surfaceText
}
}
@@ -322,15 +320,25 @@ Row {
|| SysMonitorService.availableGpus.length === 0) {
return "No GPUs detected"
}
if (SysMonitorService.availableGpus.length === 1) {
return SysMonitorService.availableGpus[0].driver.toUpperCase()
}
return SysMonitorService.availableGpus.length + " GPUs detected"
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length - 1)]
return gpu.vendor + " " + gpu.displayName
}
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
color: Theme.surfaceText
opacity: 0.7
width: parent.parent.width - Theme.spacingM * 2
elide: Text.ElideRight
maximumLineCount: 1
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
}
}
}

View File

@@ -104,8 +104,7 @@ ScrollView {
Rectangle {
width: (parent.width - Theme.spacingXL) / 2
height: Math.max(hardwareColumn.implicitHeight,
memoryColumn.implicitHeight) + Theme.spacingM
height: hardwareColumn.implicitHeight + Theme.spacingL
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainerHigh.r,
Theme.surfaceContainerHigh.g,
@@ -135,7 +134,7 @@ ScrollView {
}
StyledText {
text: "Hardware"
text: "System"
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Bold
@@ -180,23 +179,57 @@ ScrollView {
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
StyledText {
text: SysMonitorService.formatSystemMemory(
SysMonitorService.totalMemoryKB) + " RAM"
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.8)
width: parent.width
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
}
}
Rectangle {
width: (parent.width - Theme.spacingXL) / 2
height: Math.max(hardwareColumn.implicitHeight,
memoryColumn.implicitHeight) + Theme.spacingM
height: gpuColumn.implicitHeight + Theme.spacingL
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainerHigh.r,
Theme.surfaceContainerHigh.g,
Theme.surfaceContainerHigh.b, 0.4)
color: {
if (gpuCardMouseArea.containsMouse
&& SysMonitorService.availableGpus.length > 1)
return Qt.rgba(Theme.surfaceContainerHigh.r,
Theme.surfaceContainerHigh.g,
Theme.surfaceContainerHigh.b, 0.6)
else
return Qt.rgba(Theme.surfaceContainerHigh.r,
Theme.surfaceContainerHigh.g,
Theme.surfaceContainerHigh.b, 0.4)
}
border.width: 1
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.1)
MouseArea {
id: gpuCardMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: SysMonitorService.availableGpus.length
> 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (SysMonitorService.availableGpus.length > 1) {
var nextIndex = (SessionData.selectedGpuIndex + 1)
% SysMonitorService.availableGpus.length
SessionData.setSelectedGpuIndex(nextIndex)
}
}
}
Column {
id: memoryColumn
id: gpuColumn
anchors.left: parent.left
anchors.right: parent.right
@@ -209,14 +242,14 @@ ScrollView {
spacing: Theme.spacingS
DankIcon {
name: "developer_board"
name: "auto_awesome_mosaic"
size: Theme.iconSizeSmall
color: Theme.secondary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: "Memory"
text: "GPU"
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Bold
@@ -226,35 +259,113 @@ ScrollView {
}
StyledText {
text: SysMonitorService.formatSystemMemory(
SysMonitorService.totalMemoryKB) + " Total"
text: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return "No GPUs detected"
}
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
return gpu.fullName
}
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Medium
color: Theme.surfaceText
width: parent.width
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Text.AlignVCenter
}
StyledText {
text: SysMonitorService.formatSystemMemory(
SysMonitorService.usedMemoryKB) + " Used • "
+ SysMonitorService.formatSystemMemory(
SysMonitorService.totalMemoryKB
- SysMonitorService.usedMemoryKB) + " Available"
text: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return "Vendor: N/A"
}
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
return "Vendor: " + gpu.vendor
}
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.7)
Theme.surfaceText.b, 0.8)
width: parent.width
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
Item {
StyledText {
text: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return "Driver: N/A"
}
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
return "Driver: " + gpu.driver
}
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.8)
width: parent.width
height: Theme.fontSizeSmall + Theme.spacingXS
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
StyledText {
text: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return "Temp: --°"
}
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
var temp = gpu.temperature
return "Temp: " + ((temp === undefined || temp === null
|| temp === 0) ? "--°" : Math.round(
temp) + "°C")
}
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
color: {
if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) {
return Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.7)
}
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
var temp = gpu.temperature || 0
if (temp > 80)
return Theme.error
if (temp > 60)
return Theme.warning
return Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.7)
}
width: parent.width
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
}
}
}

View File

@@ -87,7 +87,8 @@ Rectangle {
SequentialAnimation on opacity {
id: pulseAnimation
running: parent.visible && hasActivePrivacy && PrivacyService.cameraActive
running: parent.visible && hasActivePrivacy
&& PrivacyService.cameraActive
loops: Animation.Infinite
NumberAnimation {

File diff suppressed because it is too large Load Diff