Bug 452581 - Horizontal Bars style unable to show empty and low states
Summary: Horizontal Bars style unable to show empty and low states
Status: RESOLVED FIXED
Alias: None
Product: plasma-systemmonitor
Classification: Applications
Component: general (show other bugs)
Version: 5.24.4
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2022-04-13 16:04 UTC by Trent M
Modified: 2022-05-05 14:19 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.25


Attachments
Screenshot of not particularly meaningful horizontal bars. (45.41 KB, image/png)
2022-04-13 16:04 UTC, Trent M
Details
Screenshot of horizontal bars after patch, using smaller circles for low values. (45.85 KB, image/png)
2022-04-13 16:34 UTC, Trent M
Details
Patch to Bar.qml to allow for using smaller circles than the parent's height for low values. (2.43 KB, patch)
2022-04-13 16:35 UTC, Trent M
Details
Patch to Bar.qml to allow for using smaller circles than the parent's height for low values. (Corrected.) (973 bytes, patch)
2022-04-13 16:37 UTC, Trent M
Details
Patch to Bar.qml to use smaller circles than the parent's height for low values, now clamping to values that fit evenly within parent. (1.09 KB, patch)
2022-04-22 14:36 UTC, Trent M
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trent M 2022-04-13 16:04:34 UTC
Created attachment 148139 [details]
Screenshot of not particularly meaningful horizontal bars.

SUMMARY
I'd like to use the Horizontal Bars style to show my total CPU usage, RAM usage, and Swap usage. But because of the way the bars are designed to show a dot with the bar's radius even when the value is zero, I can't get any useful information from it that way.

If I try tweaking the QML such that it does take zero as a valid value, what ends up happening is that the left side of the bar has zero radius whenever the value is less than the radius. So is this actually a QML bug because of the fact that rectangle radius gets discarded when its width is smaller than its specified radius?

The only way I can get the bars to show anything meaningful without looking inconsistent is if I tweak the QML to make their radius zero.

STEPS TO REPRODUCE
1. Create a system monitor widget with horizontal bars style
2. Select sensors that you can reasonably expect to be low to zero, like total CPU usage percent and Swap usage percent.

OBSERVED RESULT
Values of zero are not meaningfully conveyed; they look more like 10% on a 40px vertical panel.

EXPECTED RESULT
A legitimately empty bar is shown when the value is zero, and some sort of small fill is shown for low values.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon 5.24.4
(available in About System)
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.93
Qt Version: 5.15.3

ADDITIONAL INFORMATION
N/A
Comment 1 Trent M 2022-04-13 16:34:02 UTC
I did manage to come up with something. By centering the second rectangle vertically within the parent and then making the height the minimum between parent.height and width x percentage, it at least looks better than no radius and/or letting it just square off the corners when the value is zero. I'll attach my patch and a screenshot of what it looks like now with low values. If this rectangle radius thing is something that can't be fixed in QML, I at least think this will make the horizontal bars more usable and meaningful.
Comment 2 Trent M 2022-04-13 16:34:40 UTC
Created attachment 148140 [details]
Screenshot of horizontal bars after patch, using smaller circles for low values.
Comment 3 Trent M 2022-04-13 16:35:27 UTC
Created attachment 148141 [details]
Patch to Bar.qml to allow for using smaller circles than the parent's height for low values.
Comment 4 Trent M 2022-04-13 16:37:20 UTC
Created attachment 148142 [details]
Patch to Bar.qml to allow for using smaller circles than the parent's height for low values. (Corrected.)
Comment 5 Nate Graham 2022-04-18 16:31:11 UTC
Looks like a legitimate issue, and your change seems sane to me. Would you be interested in submitting a merge request with it? I can help!
Comment 6 Trent M 2022-04-18 20:37:58 UTC
(In reply to Nate Graham from comment #5)
> Looks like a legitimate issue, and your change seems sane to me. Would you
> be interested in submitting a merge request with it? I can help!

Definitely! And I would very much appreciate the help.

The only thing I think I would want to change about my patch as it is now is that I might want to round up the rectangle height for the lowe values somehow such that it's always centered within the bar. So if the bar is 7px high, it will never have a 4px high rectangle that it can't actually center, or if the bar is 8px high, it will never have a 5px rectangle that it can't actually center. I'm sure there's some math to do this, but I haven't thought it up yet, haha.
Comment 7 Nate Graham 2022-04-18 20:46:15 UTC
I don't think the bar can have an odd-numbered height... or if it can, that's a bug we should fix in our qqc2-desktop-style. So I don't think it's something you need to worry about per se.

That said, it's good practice to use Math.round() whenever you divide size numbers in UI code, just to avoid having the toolkit trying to draw on fractional pixels.
Comment 8 Trent M 2022-04-22 14:32:50 UTC
I'm not sure if the bar can or can't have an odd-numbered height, but in my earlier implementation, the inner bar *could* have an odd-numbered height, which would result in more space on bottom than on top. I figured out a way to bump the height up to the nearest number that leaves equal space on top and bottom. This does lose precision, but it looks better. I'll attach my patch here anyways, but I think I found where the faces are upstream, so I'm going to get an MR ready. :)
Comment 9 Trent M 2022-04-22 14:36:25 UTC
Created attachment 148302 [details]
Patch to Bar.qml to use smaller circles than the parent's height for low values, now clamping to values that fit evenly within parent.
Comment 10 Nate Graham 2022-05-05 14:19:41 UTC
Fixed by Trent McPheron with https://invent.kde.org/plasma/libksysguard/-/commit/3d6acfc69c96a26d8274d426c4178fb6f449bdce in Plasma 5.25!