Changeset View
Standalone View
applets/timer/package/contents/ui/TimerView.qml
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 28 | Item { | |||
---|---|---|---|---|---|
46 | 46 | | |||
47 | PlasmaCore.Svg { | 47 | PlasmaCore.Svg { | ||
48 | id: timerSvg | 48 | id: timerSvg | ||
49 | imagePath: "widgets/timer" | 49 | imagePath: "widgets/timer" | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | Timer { | 52 | Timer { | ||
53 | id: t; | 53 | id: t; | ||
54 | interval: 1000; | 54 | interval: 20; | ||
davidedmundson: that's a lot of wakeups. Do you really need to do this? | |||||
Typical display is 60Hz, so 16.6 ms per frame. A 20ms interval means each clock tick will be displayed between 58-62 frames after the previous one, though usually 59-61. That's 966.8-1033.2ms delay between each tick. I'm pretty sure that's not noticeable to a human, even including any additional random delays caused by all the display logic. But If I increase it too much, it will become noticeable at some point. I guess I can change that to, say 25ms, while still being in the 58-62 range, but I really don't know what difference that 20Hz vs 25Hz makes on a 1GHz cpu? mmazur: Typical display is 60Hz, so 16.6 ms per frame. A 20ms interval means each clock tick will be… | |||||
55 | onTriggered: { | 55 | onTriggered: { | ||
56 | if (root.seconds != 0) { | 56 | var ts = new Date().getTime(); | ||
There's a behavioural change not mentioned in the commit message :/ If I have a timer for 5 minutes and suspend after 1 minute for an hour in the old code when we resume we will see a timer for 4 minutes left. In the new code we will see the timer has finished. You can make an argument this is better, but it shouldn't be accidental. *if* we want this behaviour the clock dataengine might be a good solution, that aligns itself to seconds automatically. davidedmundson: There's a behavioural change not mentioned in the commit message :/
If I have a timer for 5… | |||||
I wasn't aware that Date().getTime() wasn't in UTC. I can change it to a UTC call if there is one. I'm aware of the sleep behavior change, however I do not know how to handle it. (I was hoping the reviewer wouldn't notice.) If there's a trivial way to bind to signals for 'system is suspending'/'system just woke up', then I can pause the timer on those signals. What I cannot do is rewrite the code to use QSomethingOrOther, since I don't know Qt and I'm not going to learn Qt. Just so we're on the same page – nobody cared about this plasmoid for a few years now. To the extent that it plain stopped working when I upgraded to ubuntu 18.04 due to bug 381173. I fixed it the way I knew how and I'm happy with my code, since I can now use the plasmoid. If you have a perfect solution in mind, then you either need to code it yourself or find someone else who will. As far as interacting with me goes, it's either merge my code with minor improvements here and there (I can do the sleep handling if there's a signal for it) or don't and have the thing not work. If it's the former, please tell me upfront, so we don't waste each other's time on further discussions. mmazur: I wasn't aware that Date().getTime() wasn't in UTC. I can change it to a UTC call if there is… | |||||
mmazur: Latter, if it's the latter. | |||||
57 | root.seconds--; | 57 | if (root.seconds > 0) { | ||
58 | root.seconds = root.initialSeconds - Math.floor((ts-root.startedAt)/1000); | ||||
58 | } | 59 | } | ||
59 | if (root.seconds == 0) { | 60 | if (root.seconds <= 0) { | ||
60 | root.running = false; | 61 | resetTimer(); | ||
61 | 62 | | |||
62 | if (showNotification) { | 63 | if (showNotification) { | ||
63 | root.createNotification(); | 64 | root.createNotification(); | ||
64 | } | 65 | } | ||
65 | if (runCommand) { | 66 | if (runCommand) { | ||
66 | TimerPlasmoid.Timer.runCommand(command); | 67 | TimerPlasmoid.Timer.runCommand(command); | ||
67 | } | 68 | } | ||
68 | saveTimer(); | | |||
69 | } | 69 | } | ||
70 | } | 70 | } | ||
71 | repeat: true; | 71 | repeat: true; | ||
72 | running: root.running; | 72 | running: root.running; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | Timer { | 75 | Timer { | ||
76 | id: delayedSaveTimer; | 76 | id: delayedSaveTimer; | ||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
that's a lot of wakeups. Do you really need to do this?