[Timer applet] Minor fixes for the applet
Needs RevisionPublic

Authored by gepardo on Dec 9 2018, 9:48 PM.

Details

Summary

BUG: 395182
BUG: 361025

Here are the changes made:

  • Allow Timer widget to work well on panels, both vertical and horizontal.
  • Use root.digitHasChanged(); instead of main.digitChanged(); This line was changed before in https://phabricator.kde.org/D12534, but it seems that main.digitChanged(); doesn't exist also.
  • Increase notification time from 2s to 5s, so it's harder to miss it.
Test Plan

Tried placing the timer on a panel, then tried to resize the panel. Tested on both vertical and horizontal panels.

I regularly use this applet on a vertical panel without issues.

Diff Detail

Repository
R114 Plasma Addons
Branch
arcpatch-D17464
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14549
Build 14567: arc lint + arc unit
gepardo created this revision.Dec 9 2018, 9:48 PM
Restricted Application added a project: Plasma. · View Herald TranscriptDec 9 2018, 9:48 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
gepardo requested review of this revision.Dec 9 2018, 9:48 PM

Cool.

applets/timer/package/contents/ui/TimerView.qml
46

what if it's neither (i.e on the desktop) ?

53

never set size hints from current size, you're asking for binding loops.

setting it based on the implicitWith is ok

65

where has 0.77 come from

gepardo added inline comments.Dec 9 2018, 10:13 PM
applets/timer/package/contents/ui/TimerView.qml
46

Doesn't it use the default sizing settings (as used before this patch)?

gepardo added inline comments.Dec 9 2018, 10:24 PM
applets/timer/package/contents/ui/TimerView.qml
65

As I remember, I was trying to make the digits size of timer equal nearer to clock font size. Setting this to 1.0 won't break anything, but the digits will take the full height of the panel.

BTW, clock itself uses height * 0.71.

davidedmundson added inline comments.Dec 9 2018, 10:33 PM
applets/timer/package/contents/ui/TimerView.qml
65

I dislike the clock code, but if you leave a comment of why it's that way, then ok.

gepardo added inline comments.Dec 9 2018, 10:35 PM
applets/timer/package/contents/ui/TimerView.qml
53

Can't get it work with implicitWidth and implicitHeight.

By the way, when using parent.width and parent.height it works OK (but parent.implicitWidth and parent.implicitHeight don't work correctly). Is it OK or are there other ideas how to rewrite this part of code?

gepardo updated this revision to Diff 47224.Dec 9 2018, 10:39 PM

Add a comment about value 0.77

gepardo marked 3 inline comments as done.Dec 9 2018, 10:39 PM
davidedmundson added inline comments.Dec 10 2018, 9:06 AM
applets/timer/package/contents/ui/TimerView.qml
65

Clock is 0.71

gepardo updated this revision to Diff 62660.Jul 27 2019, 8:40 PM

Updating D17464: [Timer applet] Minor fixes for the applet

Change clock size ratio to 0.84 for better compatibility with Clock's font size

gepardo marked an inline comment as done.EditedJul 27 2019, 8:43 PM

After some experiments, I finally set clock size to 0.84:

The main problem is that the clock widget uses a real font, but the timer uses SVGs to render digits, so the ideal is not so easy to reach.

I still can't accept a patch with an unexplained magic number.

If the rationale is that it's to match the clock, then it has to match the clock. If there's something else, please can the comment say what.

The rationale is to make the clock font size and the timer font size identical. Setting 0.84 as timer height multiplier indeed reaches this goal. But two other problems remain:

  • the fonts are different itself, as clock uses the real font, and timer uses SVGs to render digits
  • if the panel is large enough, the vertical position of the text differs (timer's top and bottom margins are equal, but clock's top and bottom margins have different size)

Should I fix some of these issues also?

gepardo updated this revision to Diff 62730.Jul 29 2019, 11:46 AM

Minor change in the comment for the "magic" value 0.84

The rationale is to make the clock font size and the timer font size identical. Setting 0.84 as timer height multiplier indeed reaches this goal. But two other problems remain:

I don't follow how it makes them the same when the other number is different.

gepardo updated this revision to Diff 62750.Jul 29 2019, 5:07 PM

Change magic value to 0.86, as it looks nearer to the clock font size

I don't follow how it makes them the same when the other number is different.

Timer applet is rendered using SVGs, clock applet is rendered using text. So, as the SVGs and font glyphs have different sizes, we need different coefficients. The coefficient 0.86 itself is obtained by trying different other "magic" numbers and finding the nearest one visually.

Here is how it looks:

Or, I can just give up and remove 0.86 from the code :)

gepardo updated this revision to Diff 62751.Jul 29 2019, 5:18 PM

Now the widget doesn't become too wide if the panel is tall. The size formula now looks similar to the size formula of the clock widget. Expanatory comment is updated.

Here is how it looks on tall panels:

ngraham accepted this revision.Aug 2 2019, 9:18 PM

LGTM, but let's wait for @davidedmundson.

This revision is now accepted and ready to land.Aug 2 2019, 9:18 PM

Still waiting for the feedback.

davidedmundson requested changes to this revision.Aug 17 2019, 3:20 PM

If it's the exact same code as before, then my opinion will be the same.

The digital clock set the text height to 0.7 of the panel and the width is inferred through layouting.
This patch sets the width based on the height of the parent. Which is why you need a different magic number.

We adjust the layout with which in turn adjust the width which in turn adjusts the digitH..it's all very messy.

Our best bet will be to fix the layouting, so that the width can be inferred automatically and you can use the same logic to set the height.

This revision now requires changes to proceed.Aug 17 2019, 3:20 PM

Thanks, now I got your point much clearer.