mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-25 05:52:50 -05:00
migrate to dankgop monitoring
This commit is contained in:
@@ -8,10 +8,10 @@ Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef();
|
||||
DankgopService.addRef(["cpu", "memory", "system"]);
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef();
|
||||
DankgopService.removeRef(["cpu", "memory", "system"]);
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -19,15 +19,15 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (SysMonitorService.sortBy === "cpu")
|
||||
if (DankgopService.sortBy === "cpu")
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.16);
|
||||
else if (cpuCardMouseArea.containsMouse)
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12);
|
||||
else
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08);
|
||||
}
|
||||
border.color: SysMonitorService.sortBy === "cpu" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: SysMonitorService.sortBy === "cpu" ? 2 : 1
|
||||
border.color: DankgopService.sortBy === "cpu" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: DankgopService.sortBy === "cpu" ? 2 : 1
|
||||
|
||||
MouseArea {
|
||||
id: cpuCardMouseArea
|
||||
@@ -35,7 +35,7 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: SysMonitorService.setSortBy("cpu")
|
||||
onClicked: DankgopService.setSortBy("cpu")
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -48,15 +48,19 @@ Row {
|
||||
text: "CPU"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.sortBy === "cpu" ? Theme.primary : Theme.secondary
|
||||
opacity: SysMonitorService.sortBy === "cpu" ? 1 : 0.8
|
||||
color: DankgopService.sortBy === "cpu" ? Theme.primary : Theme.secondary
|
||||
opacity: DankgopService.sortBy === "cpu" ? 1 : 0.8
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalCpuUsage.toFixed(1) + "%"
|
||||
text: {
|
||||
if (DankgopService.cpuUsage === undefined || DankgopService.cpuUsage === null)
|
||||
return "--%"
|
||||
return DankgopService.cpuUsage.toFixed(1) + "%"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
@@ -73,19 +77,19 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.cpuTemperature === undefined || SysMonitorService.cpuTemperature === null || SysMonitorService.cpuTemperature < 0)
|
||||
if (DankgopService.cpuTemperature === undefined || DankgopService.cpuTemperature === null || DankgopService.cpuTemperature <= 0)
|
||||
return "--°";
|
||||
|
||||
return Math.round(SysMonitorService.cpuTemperature) + "°";
|
||||
return Math.round(DankgopService.cpuTemperature) + "°";
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Medium
|
||||
color: {
|
||||
if (SysMonitorService.cpuTemperature > 80)
|
||||
if (DankgopService.cpuTemperature > 80)
|
||||
return Theme.error;
|
||||
|
||||
if (SysMonitorService.cpuTemperature > 60)
|
||||
if (DankgopService.cpuTemperature > 60)
|
||||
return Theme.warning;
|
||||
|
||||
return Theme.surfaceText;
|
||||
@@ -96,7 +100,7 @@ Row {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.cpuCount + " cores"
|
||||
text: DankgopService.cpuCores + " cores"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Theme.surfaceText
|
||||
@@ -126,15 +130,15 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (SysMonitorService.sortBy === "memory")
|
||||
if (DankgopService.sortBy === "memory")
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.16);
|
||||
else if (memoryCardMouseArea.containsMouse)
|
||||
return Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.12);
|
||||
else
|
||||
return Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08);
|
||||
}
|
||||
border.color: SysMonitorService.sortBy === "memory" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.2)
|
||||
border.width: SysMonitorService.sortBy === "memory" ? 2 : 1
|
||||
border.color: DankgopService.sortBy === "memory" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.2)
|
||||
border.width: DankgopService.sortBy === "memory" ? 2 : 1
|
||||
|
||||
MouseArea {
|
||||
id: memoryCardMouseArea
|
||||
@@ -142,7 +146,7 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: SysMonitorService.setSortBy("memory")
|
||||
onClicked: DankgopService.setSortBy("memory")
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -155,15 +159,15 @@ Row {
|
||||
text: "Memory"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.sortBy === "memory" ? Theme.primary : Theme.secondary
|
||||
opacity: SysMonitorService.sortBy === "memory" ? 1 : 0.8
|
||||
color: DankgopService.sortBy === "memory" ? Theme.primary : Theme.secondary
|
||||
opacity: DankgopService.sortBy === "memory" ? 1 : 0.8
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatSystemMemory(SysMonitorService.usedMemoryKB)
|
||||
text: DankgopService.formatSystemMemory(DankgopService.usedMemoryKB)
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
@@ -176,27 +180,27 @@ Row {
|
||||
height: 20
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: SysMonitorService.totalSwapKB > 0
|
||||
visible: DankgopService.totalSwapKB > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalSwapKB > 0 ? SysMonitorService.formatSystemMemory(SysMonitorService.usedSwapKB) : ""
|
||||
text: DankgopService.totalSwapKB > 0 ? DankgopService.formatSystemMemory(DankgopService.usedSwapKB) : ""
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.usedSwapKB > 0 ? Theme.warning : Theme.surfaceText
|
||||
color: DankgopService.usedSwapKB > 0 ? Theme.warning : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: SysMonitorService.totalSwapKB > 0
|
||||
visible: DankgopService.totalSwapKB > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.totalSwapKB > 0)
|
||||
return "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB) + " + swap";
|
||||
if (DankgopService.totalSwapKB > 0)
|
||||
return "of " + DankgopService.formatSystemMemory(DankgopService.totalMemoryKB) + " + swap";
|
||||
|
||||
return "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB);
|
||||
return "of " + DankgopService.formatSystemMemory(DankgopService.totalMemoryKB);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
@@ -227,40 +231,40 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.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);
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var vendor = gpu.vendor.toLowerCase();
|
||||
if (vendor.includes("nvidia")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.12);
|
||||
} else if (vendor.includes("amd")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12);
|
||||
} else if (vendor.includes("intel")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.12);
|
||||
}
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.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: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2);
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var vendor = gpu.vendor.toLowerCase();
|
||||
if (vendor.includes("nvidia"))
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.3);
|
||||
@@ -278,11 +282,11 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: SysMonitorService.availableGpus.length > 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
cursorShape: DankgopService.availableGpus.length > 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: (mouse) => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (SysMonitorService.availableGpus.length > 1) {
|
||||
var nextIndex = (SessionData.selectedGpuIndex + 1) % SysMonitorService.availableGpus.length;
|
||||
if (DankgopService.availableGpus.length > 1) {
|
||||
var nextIndex = (SessionData.selectedGpuIndex + 1) % DankgopService.availableGpus.length;
|
||||
SessionData.setSelectedGpuIndex(nextIndex);
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
@@ -307,12 +311,14 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return "No GPU";
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
// Check if temperature monitoring is enabled for this GPU
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature;
|
||||
var hasTemp = temp !== undefined && temp !== null && temp !== 0;
|
||||
var hasTemp = tempEnabled && temp !== undefined && temp !== null && temp !== 0;
|
||||
if (hasTemp)
|
||||
return Math.round(temp) + "°";
|
||||
else
|
||||
@@ -322,15 +328,16 @@ Row {
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return Theme.surfaceText;
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature || 0;
|
||||
if (temp > 80)
|
||||
if (tempEnabled && temp > 80)
|
||||
return Theme.error;
|
||||
|
||||
if (temp > 60)
|
||||
if (tempEnabled && temp > 60)
|
||||
return Theme.warning;
|
||||
|
||||
return Theme.surfaceText;
|
||||
@@ -339,12 +346,13 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return "No GPUs detected";
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature;
|
||||
var hasTemp = temp !== undefined && temp !== null && temp !== 0;
|
||||
var hasTemp = tempEnabled && temp !== undefined && temp !== null && temp !== 0;
|
||||
if (hasTemp)
|
||||
return gpu.vendor + " " + gpu.displayName;
|
||||
else
|
||||
@@ -365,41 +373,40 @@ Row {
|
||||
id: gpuContextMenu
|
||||
|
||||
MenuItem {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
return "Enable GPU Temperature"
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
return isNvidia ? "Enable GPU Temperature" : "Enable GPU Temperature"
|
||||
}
|
||||
text: "Enable GPU Temperature"
|
||||
checkable: true
|
||||
checked: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
return isNvidia ? SysMonitorService.nvidiaGpuTempEnabled : SysMonitorService.nonNvidiaGpuTempEnabled
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
if (!gpu.pciId) return false
|
||||
|
||||
return SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1 : false
|
||||
}
|
||||
onTriggered: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
if (!gpu.pciId) return
|
||||
|
||||
if (isNvidia) {
|
||||
SessionData.setNvidiaGpuTempEnabled(checked)
|
||||
} else {
|
||||
SessionData.setNonNvidiaGpuTempEnabled(checked)
|
||||
var enabledIds = SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.slice() : []
|
||||
var index = enabledIds.indexOf(gpu.pciId)
|
||||
|
||||
if (checked && index === -1) {
|
||||
enabledIds.push(gpu.pciId)
|
||||
DankgopService.addGpuPciId(gpu.pciId)
|
||||
} else if (!checked && index !== -1) {
|
||||
enabledIds.splice(index, 1)
|
||||
DankgopService.removeGpuPciId(gpu.pciId)
|
||||
}
|
||||
|
||||
SessionData.setEnabledGpuPciIds(enabledIds)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
|
||||
Reference in New Issue
Block a user