Skip to content

Commit

Permalink
fix(graph): right update when memory unit changed
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed Apr 28, 2023
1 parent 99b4774 commit 9b47018
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ MouseArea {
}

onCpuUnitChanged: {
cpuGraph.sensors = ["cpu/all/" + cpuUnit]
cpuGraph.sensors = ["cpu/all/" + cpuUnit];
}
onShowCpuClockChanged: {
if (!showCpuClock) {
Expand All @@ -128,7 +128,13 @@ MouseArea {
if ((ramGraph.maxMemory[0] <= 0 && ramGraph.maxMemory[1] <= 0) || memoryUnit === "none") {
return;
}
maxMemoryQueryModel.enabled = true;
if (memoryUnit.endsWith("-percent")) {
ramGraph.uplimits = [100, 100];
} else {
ramGraph.uplimits = ramGraph.maxMemory;
}
ramGraph.updateThresholds();
ramGraph.updateSensors();
}

onShowSwapGraphChanged: {
Expand Down Expand Up @@ -303,10 +309,8 @@ MouseArea {
enabled = false;
if (!memoryUnit.endsWith("-percent")) {
ramGraph.uplimits = ramGraph.maxMemory;
ramGraph.thresholds[0] = [ramGraph.maxMemory[0] * (thresholdWarningMemory / 100.0), ramGraph.maxMemory[0] * (thresholdCriticalMemory / 100.0)];
} else {
ramGraph.thresholds[0] = [thresholdWarningMemory, thresholdCriticalMemory];
}
ramGraph.updateThresholds();
ramGraph.updateSensors();
}
}
Expand All @@ -317,6 +321,14 @@ MouseArea {
secondLineLabel.color = swapColor;
}

function updateThresholds() {
if (!memoryUnit.endsWith("-percent")) {
ramGraph.thresholds[0] = [ramGraph.maxMemory[0] * (thresholdWarningMemory / 100.0), ramGraph.maxMemory[0] * (thresholdCriticalMemory / 100.0)];
} else {
ramGraph.thresholds[0] = [thresholdWarningMemory, thresholdCriticalMemory];
}
}

function updateSensors() {
var _memUnit = memoryUnit.split("-");
var suffix = _memUnit[1] === "percent" ? "Percent" : "";
Expand Down

0 comments on commit 9b47018

Please sign in to comment.