[Applet]Fix traffic monitor labels width
ClosedPublic

Authored by gvgeo on Mar 2 2020, 8:03 PM.

Details

Summary

Use text metrics to set a proper space for labels.
And remove unused plotter width.

Test Plan

Change default font styles and family.
Change small font size.
Space available must follow the font.

Diff Detail

Repository
R116 Plasma Network Management Applet
Branch
traffic (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 23157
Build 23175: arc lint + arc unit
gvgeo created this revision.Mar 2 2020, 8:03 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 2 2020, 8:03 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
gvgeo requested review of this revision.Mar 2 2020, 8:03 PM
gvgeo edited the test plan for this revision. (Show Details)Mar 2 2020, 8:05 PM
gvgeo added a comment.Mar 2 2020, 8:08 PM

@ngraham Is there a better way to fix this?

Looks this changed introduced an issue. The traffic monitor doesn't fit into the applet.

See picture below:

davidedmundson added inline comments.
applet/contents/ui/TrafficMonitor.qml
107

what is this number about?

gvgeo added a comment.Mar 2 2020, 8:15 PM

Is it?

applet/contents/ui/TrafficMonitor.qml
107

Biggest number it can display?

gvgeo added a comment.Mar 4 2020, 6:50 AM

VDG Does a better way exist, to measure the width of transfer speed text?

ngraham accepted this revision.Mar 4 2020, 7:06 PM

If you need to measure the width of text, then you're doing it the right way.

However this problem wouldn't be happening in the first place if this UI used Layouts, which handle this kind of case more elegantly so you don't need to manually set margins and measure the width of items.

So I say feel free to land this now since it's a correct bugfix and the current code is obviously wrong. And I think we should move towards porting to Layouts in another patch. I can do that if you're sick of plasma-nm. :)

gvgeo added a comment.EditedMar 4 2020, 7:32 PM

I don't plan to make more patches, for now. But if the problem would not exist with Layouts, I would prefer to do it than make quick bugfixes.

But can't see how the Layouts would help with that. Everything can be done without Layouts too AFAIK, just more messy.
I want to keep the plotter dimensions constant. It would not be nice to change width constantly.

gvgeo marked 2 inline comments as done.Mar 4 2020, 7:33 PM

Yeah, if you want to keep the plotter dimensions constant, then there's no way around measuring the width of the labels.

Regarding not opening any new patches, I hope you didn't have a bad experience in KDE that's left a bad taste in your mouth. If anything's gone wrong, don't hesitate to let me know and I'll do what I can.

jgrulich accepted this revision.Mar 5 2020, 5:38 AM
This revision is now accepted and ready to land.Mar 5 2020, 5:38 AM
This revision was automatically updated to reflect the committed changes.