1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 05:55:37 -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 string profileLastPath: ""
property bool doNotDisturb: false property bool doNotDisturb: false
property var pinnedApps: [] property var pinnedApps: []
property int selectedGpuIndex: 0
Component.onCompleted: { Component.onCompleted: {
loadSettings() loadSettings()
@@ -37,6 +38,7 @@ Singleton {
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "" profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : [] pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : []
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0
} }
} catch (e) { } catch (e) {
@@ -50,7 +52,8 @@ Singleton {
"wallpaperLastPath": wallpaperLastPath, "wallpaperLastPath": wallpaperLastPath,
"profileLastPath": profileLastPath, "profileLastPath": profileLastPath,
"doNotDisturb": doNotDisturb, "doNotDisturb": doNotDisturb,
"pinnedApps": pinnedApps "pinnedApps": pinnedApps,
"selectedGpuIndex": selectedGpuIndex
}, null, 2)) }, null, 2))
} }
@@ -115,6 +118,11 @@ Singleton {
return appId && pinnedApps.indexOf(appId) !== -1 return appId && pinnedApps.indexOf(appId) !== -1
} }
function setSelectedGpuIndex(index) {
selectedGpuIndex = index
saveSettings()
}
FileView { FileView {
id: settingsFile id: settingsFile

View File

@@ -237,12 +237,34 @@ Row {
width: (parent.width - Theme.spacingM * 2) / 3 width: (parent.width - Theme.spacingM * 2) / 3
height: 80 height: 80
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, color: {
Theme.surfaceVariant.b, 0.08) 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, border.color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g,
Theme.surfaceVariant.b, 0.2) Theme.surfaceVariant.b, 0.2)
border.width: 1 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 { Column {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Theme.spacingM anchors.leftMargin: Theme.spacingM
@@ -250,7 +272,7 @@ Row {
spacing: 2 spacing: 2
StyledText { StyledText {
text: "Graphics" text: "GPU"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium font.weight: Font.Medium
color: Theme.secondary color: Theme.secondary
@@ -261,29 +283,15 @@ Row {
text: { text: {
if (!SysMonitorService.availableGpus if (!SysMonitorService.availableGpus
|| SysMonitorService.availableGpus.length === 0) { || SysMonitorService.availableGpus.length === 0) {
return "None" return "--°"
} }
if (SysMonitorService.availableGpus.length === 1) {
var gpu = SysMonitorService.availableGpus[0] var gpu = SysMonitorService.availableGpus[Math.min(
var temp = gpu.temperature SessionData.selectedGpuIndex,
var tempText = (temp === undefined || temp === null SysMonitorService.availableGpus.length - 1)]
|| temp === 0) ? "--°" : Math.round(temp) + "°" var temp = gpu.temperature
return tempText return (temp === undefined || temp === null
} || temp === 0) ? "--°" : Math.round(temp) + "°"
// 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 "--°"
} }
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeLarge
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
@@ -293,25 +301,15 @@ Row {
|| SysMonitorService.availableGpus.length === 0) { || SysMonitorService.availableGpus.length === 0) {
return Theme.surfaceText return Theme.surfaceText
} }
if (SysMonitorService.availableGpus.length === 1) {
var temp = SysMonitorService.availableGpus[0].temperature || 0 var gpu = SysMonitorService.availableGpus[Math.min(
if (temp > 80) SessionData.selectedGpuIndex,
return Theme.tempDanger SysMonitorService.availableGpus.length - 1)]
if (temp > 60) var temp = gpu.temperature || 0
return Theme.tempWarning if (temp > 80)
return Theme.surfaceText return Theme.error
} if (temp > 60)
// Multiple GPUs - get max temp for coloring return Theme.warning
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
return Theme.surfaceText return Theme.surfaceText
} }
} }
@@ -322,15 +320,25 @@ Row {
|| SysMonitorService.availableGpus.length === 0) { || SysMonitorService.availableGpus.length === 0) {
return "No GPUs detected" return "No GPUs detected"
} }
if (SysMonitorService.availableGpus.length === 1) {
return SysMonitorService.availableGpus[0].driver.toUpperCase() var gpu = SysMonitorService.availableGpus[Math.min(
} SessionData.selectedGpuIndex,
return SysMonitorService.availableGpus.length + " GPUs detected" SysMonitorService.availableGpus.length - 1)]
return gpu.vendor + " " + gpu.displayName
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
color: Theme.surfaceText color: Theme.surfaceText
opacity: 0.7 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 { Rectangle {
width: (parent.width - Theme.spacingXL) / 2 width: (parent.width - Theme.spacingXL) / 2
height: Math.max(hardwareColumn.implicitHeight, height: hardwareColumn.implicitHeight + Theme.spacingL
memoryColumn.implicitHeight) + Theme.spacingM
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainerHigh.r, color: Qt.rgba(Theme.surfaceContainerHigh.r,
Theme.surfaceContainerHigh.g, Theme.surfaceContainerHigh.g,
@@ -135,7 +134,7 @@ ScrollView {
} }
StyledText { StyledText {
text: "Hardware" text: "System"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
font.weight: Font.Bold font.weight: Font.Bold
@@ -180,23 +179,57 @@ ScrollView {
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter 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 { Rectangle {
width: (parent.width - Theme.spacingXL) / 2 width: (parent.width - Theme.spacingXL) / 2
height: Math.max(hardwareColumn.implicitHeight, height: gpuColumn.implicitHeight + Theme.spacingL
memoryColumn.implicitHeight) + Theme.spacingM
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainerHigh.r, color: {
Theme.surfaceContainerHigh.g, if (gpuCardMouseArea.containsMouse
Theme.surfaceContainerHigh.b, 0.4) && 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.width: 1
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.1) 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 { Column {
id: memoryColumn id: gpuColumn
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
@@ -209,14 +242,14 @@ ScrollView {
spacing: Theme.spacingS spacing: Theme.spacingS
DankIcon { DankIcon {
name: "developer_board" name: "auto_awesome_mosaic"
size: Theme.iconSizeSmall size: Theme.iconSizeSmall
color: Theme.secondary color: Theme.secondary
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
StyledText { StyledText {
text: "Memory" text: "GPU"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
font.weight: Font.Bold font.weight: Font.Bold
@@ -226,35 +259,113 @@ ScrollView {
} }
StyledText { StyledText {
text: SysMonitorService.formatSystemMemory( text: {
SysMonitorService.totalMemoryKB) + " Total" 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.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
font.weight: Font.Medium font.weight: Font.Medium
color: Theme.surfaceText color: Theme.surfaceText
width: parent.width width: parent.width
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
StyledText { StyledText {
text: SysMonitorService.formatSystemMemory( text: {
SysMonitorService.usedMemoryKB) + " Used • " if (!SysMonitorService.availableGpus
+ SysMonitorService.formatSystemMemory( || SysMonitorService.availableGpus.length === 0) {
SysMonitorService.totalMemoryKB return "Vendor: N/A"
- SysMonitorService.usedMemoryKB) + " Available" }
var gpu = SysMonitorService.availableGpus[Math.min(
SessionData.selectedGpuIndex,
SysMonitorService.availableGpus.length
- 1)]
return "Vendor: " + gpu.vendor
}
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily font.family: SettingsData.monoFontFamily
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
Theme.surfaceText.b, 0.7) Theme.surfaceText.b, 0.8)
width: parent.width width: parent.width
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter 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 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 { SequentialAnimation on opacity {
id: pulseAnimation id: pulseAnimation
running: parent.visible && hasActivePrivacy && PrivacyService.cameraActive running: parent.visible && hasActivePrivacy
&& PrivacyService.cameraActive
loops: Animation.Infinite loops: Animation.Infinite
NumberAnimation { NumberAnimation {

File diff suppressed because it is too large Load Diff