Summary: | CPU Applet does not round Load average numbers | ||
---|---|---|---|
Product: | [Plasma] plasmashell | Reporter: | Gerald Weber <weberge42> |
Component: | System Monitor widgets | Assignee: | Plasma Bugs List <plasma-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ahiemstra, kishore96, nate, notmart, plasma-bugs-null, sebastien.picavet |
Priority: | NOR | ||
Version First Reported In: | 5.20.0 | ||
Target Milestone: | 1.0 | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 6.0 | |
Sentry Crash Report: | |||
Attachments: |
screenshot of system monitor sensor 1.0
A very dirty fix Still an issue |
Come from the new grid system? https://invent.kde.org/plasma/libksysguard/-/merge_requests/44 Created attachment 135334 [details]
A very dirty fix
I tried to analyze a bit. Without the knowledge of Qt/C++… a bit difficult^^.
It looks like new grid system use a Unit not listed in
Formatter::formatValue cases. So it goes to default one “value.toString();” (Formatter.cpp line 319 in master branch).
=> So I change the default to use formatNumber function. I do not know the impacts… but works fine for me.
=> It looks like also that the grid value is not a QVariant double. So, I add a dirty parameter (I did not find where I can change the type properly…)
With my usage of applets. Only load average and disk usage are affect by that.
diff --git a/formatter/Formatter.cpp b/formatter/Formatter.cpp
index 29ef6a6..17d8d6d 100644
--- a/formatter/Formatter.cpp
+++ b/formatter/Formatter.cpp
@@ -233,7 +233,7 @@ static Unit adjustedUnit(qreal value, Unit unit, MetricPrefix prefix)
return Unit(prefix + baseUnit);
}
-static QString formatNumber(const QVariant &value, Unit unit, MetricPrefix prefix, FormatOptions options)
+static QString formatNumber(const QVariant &value, Unit unit, MetricPrefix prefix, FormatOptions options, bool forceDouble)
{
qreal amount = value.toDouble();
@@ -246,7 +246,7 @@ static QString formatNumber(const QVariant &value, Unit unit, MetricPrefix prefi
amount /= std::pow(unitOrder(unit), adjusted - unit);
}
- const int precision = (value.type() != QVariant::Double && adjusted <= unit) ? 0 : 1;
+ const int precision = (value.type() != QVariant::Double && adjusted <= unit && !forceDouble) ? 0 : 1;
const QString text = QLocale().toString(amount, 'f', precision);
return unitFormat(adjusted).subs(text).toString();
@@ -307,7 +307,7 @@ QString Formatter::formatValue(const QVariant &value, Unit unit, MetricPrefix ta
case UnitVolt:
case UnitWatt:
case UnitSecond:
- return formatNumber(value, unit, targetPrefix, options);
+ return formatNumber(value, unit, targetPrefix, options, false);
case UnitBootTimestamp:
qCWarning(FORMATTER) << "UnitBootTimestamp is deprecated and is not formatted anymore";
@@ -316,7 +316,7 @@ QString Formatter::formatValue(const QVariant &value, Unit unit, MetricPrefix ta
return formatTime(value);
default:
- return value.toString();
+ return formatNumber(value, unit, targetPrefix, options, true);
}
}
Hi Gerald, Do you have a commit hash/know version? (In reply to Sébastien P. from comment #3) > Hi Gerald, > Do you have a commit hash/know version? hi, um, no, i closed the issue since i don't see the problem anymore with the actual version regards Ok, I will have to wait the full stabilisation of 5.23 on my distro. I had another issue since 5.21: https://bugs.kde.org/show_bug.cgi?id=438554 so I do not have any load average now :) It is fine for CPU, but not for load average. I think I will create another issue for that. Or reopen it since it is the same issue^^. I tried to recreate a new load average applet but the numbers are not rounded. libksysguard 5.23.4 Frameworks 5.88.0 Qt 5.15.2 Screenshot to come. Created attachment 145056 [details]
Still an issue
As you can see, the text part is fine but not the chart.
This was fixed a while ago. |
Created attachment 132404 [details] screenshot of system monitor sensor 1.0 SUMMARY CPU Load Applet does not round decimal points for 1/5/15min Load Average counters STEPS TO REPRODUCE 1. add applet total cpu monitor to desktop 2. change to line diagram 3. change sensor details to 1/5/15min load average OBSERVED RESULT long numbers displayed on y axis EXPECTED RESULT rounded numbers to x (2?) decimal points SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: Manjaro (available in About System) KDE Plasma Version: 5.20.0 KDE Frameworks Version: 5.75.0 Qt Version: 5.15.1 ADDITIONAL INFORMATION