Review Request 127102: Use fixed width for digital clock applet

Daniel Faust hessijames at mailbox.org
Wed Mar 16 15:35:57 UTC 2016



> On März 15, 2016, 5:48 nachm., Martin Klapetek wrote:
> > applets/digital-clock/package/contents/ui/DigitalClock.qml, lines 565-568
> > <https://git.reviewboard.kde.org/r/127102/diff/3/?file=448492#file448492line565>
> >
> >     Can't we just compare "A" and "P" width's and use that? Would spare creating two Date objects and two calls to Qt.formatTime
> 
> Daniel Faust wrote:
>     No, because eg. in german the strings for am and pm are "vorm." and "nachm.".
> 
> Martin Klapetek wrote:
>     Ah, good. Haven't thought of that. Those germans...
>     
>     (on the other hand, I wouldn't expect anyone in Germany to actually not use 24h clock format, but oh well)
>     
>     One other thing - create just a single Date object and then call setHours(13) on it for the second format.

As you wish. But keep in mind that this is not a performance bottleneck.
I added some debug outputs to see where setupLabels is called from and it gets called 10 times when initializing the applet, including 3 times in the onCompleted method.
Even if it is a little bit off topic, here is the log (indentation was done manually and is somewhat guessed):

```
onShowDateChanged
  timeFormatCorrection
    onShowSecondsChanged
      timeFormatCorrection
        setupLabels
          00:00:00 NACHM.
    setupLabels
      00:00:00 NACHM.

onDateFormatChanged
  setupLabels
    00:00:00 NACHM.

onLastSelectedTimezoneChanged
  timeFormatCorrection
    setupLabels
      00:00:00 NACHM.

onDisplayTimezoneAsCodeChanged
  setupLabels
    00:00:00 NACHM.

onUse24hFormatChanged
  timeFormatCorrection
    setupLabels
      00:00:00

onStateChanged
  setupLabels
    00:00:00

onCompleted
  onSelectedTimeZonesChanged
    setupLabels
      00:00:00
  dateTimeChanged
    timeFormatCorrection
      setupLabels
        00:00:00
  timeFormatCorrection
    setupLabels
      00:00:00
```


- Daniel


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/127102/#review93561
-----------------------------------------------------------


On März 16, 2016, 4:35 nachm., Daniel Faust wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127102/
> -----------------------------------------------------------
> 
> (Updated März 16, 2016, 4:35 nachm.)
> 
> 
> Review request for kde-workspace and Plasma.
> 
> 
> Bugs: 347724
>     https://bugs.kde.org/show_bug.cgi?id=347724
> 
> 
> Repository: plasma-workspace
> 
> 
> Description
> -------
> 
> Currently the width of the date label is not fixed but changes depending on the text. This causes the entire applet to change its width (if the time is the widest displayed item). This in turn can cause all other applets in the same panel to move whenever the displayed time changes.
> 
> This patch uses FontMetrics to iterate over all possible time strings (with different width) and chooses the widest of them as reference for the fixed width of the time label.
> 
> This way the width of the applet stays the same (unless the date is displayed and changes). The text remains centered though, which means that it can still move within the applet when the time changes.
> 
> 
> Diffs
> -----
> 
>   applets/digital-clock/package/contents/ui/DigitalClock.qml 95bb071 
> 
> Diff: https://git.reviewboard.kde.org/r/127102/diff/
> 
> 
> Testing
> -------
> 
> Works with horizontal and vertical panel.
> Also displaying different combinations of "seconds", "date" and "timezone" works.
> 
> 
> File Attachments
> ----------------
> 
> 0001-Use-fixed-width-for-digital-clock-applet.patch
>   https://git.reviewboard.kde.org/media/uploaded/files/2016/03/16/81b4a902-1454-4155-9fda-552b8acba1a8__0001-Use-fixed-width-for-digital-clock-applet.patch
> 
> 
> Thanks,
> 
> Daniel Faust
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160316/4c8970a2/attachment-0001.html>


More information about the Plasma-devel mailing list