Changeset View
Changeset View
Standalone View
Standalone View
applets/timer/package/contents/ui/main.qml
Show All 29 Lines | 26 | Item { | |||
---|---|---|---|---|---|
30 | property int seconds : restoreToSeconds(plasmoid.configuration.running, plasmoid.configuration.savedAt, plasmoid.configuration.seconds); | 30 | property int seconds : restoreToSeconds(plasmoid.configuration.running, plasmoid.configuration.savedAt, plasmoid.configuration.seconds); | ||
31 | 31 | | |||
32 | // show title (can be customized in the settings dialog, default: disabled) | 32 | // show title (can be customized in the settings dialog, default: disabled) | ||
33 | property bool showTitle: plasmoid.configuration.showTitle; | 33 | property bool showTitle: plasmoid.configuration.showTitle; | ||
34 | property string title: plasmoid.configuration.title; | 34 | property string title: plasmoid.configuration.title; | ||
35 | property bool running: (plasmoid.configuration.running > 0) ? true : false; | 35 | property bool running: (plasmoid.configuration.running > 0) ? true : false; | ||
36 | property bool suspended: false; | 36 | property bool suspended: false; | ||
37 | 37 | | |||
38 | // timestamp from when the user clicked 'start timer'; in ms | ||||
39 | property var startedAt: 0; | ||||
40 | // value of 'seconds' when the user clicked 'start timer' | ||||
41 | property int initialSeconds: 0; | ||||
42 | | ||||
43 | | ||||
38 | property string notificationText: plasmoid.configuration.notificationText; | 44 | property string notificationText: plasmoid.configuration.notificationText; | ||
39 | 45 | | |||
40 | Plasmoid.toolTipMainText: { | 46 | Plasmoid.toolTipMainText: { | ||
41 | var timerName = ""; | 47 | var timerName = ""; | ||
42 | if (showTitle && title != "") { | 48 | if (showTitle && title != "") { | ||
43 | timerName = title; | 49 | timerName = title; | ||
44 | } else { | 50 | } else { | ||
45 | timerName = i18n("Timer"); | 51 | timerName = i18n("Timer"); | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 100 | function secondsToDisplayableString(sec) { | |||
95 | return ~~((sec / (60*60)) / 10) + "" + | 101 | return ~~((sec / (60*60)) / 10) + "" + | ||
96 | (~~(~~(sec / (60*60))) % 10) + ":" + | 102 | (~~(~~(sec / (60*60))) % 10) + ":" + | ||
97 | ~~(~~((sec % (60*60)) / 60) / 10) + "" + | 103 | ~~(~~((sec % (60*60)) / 60) / 10) + "" + | ||
98 | ~~((sec % (60*60)) / 60) % 10 + ":" + | 104 | ~~((sec % (60*60)) / 60) % 10 + ":" + | ||
99 | ~~((sec % 60) / 10) + "" + | 105 | ~~((sec % 60) / 10) + "" + | ||
100 | (sec % 60) % 10; | 106 | (sec % 60) % 10; | ||
101 | } | 107 | } | ||
102 | function startTimer() { | 108 | function startTimer() { | ||
109 | startedAt = new Date().getTime(); | ||||
110 | initialSeconds = seconds; | ||||
103 | running = true; | 111 | running = true; | ||
104 | suspended = false; | 112 | suspended = false; | ||
105 | opacityNeedsReset() | 113 | opacityNeedsReset() | ||
106 | saveTimer(); | 114 | saveTimer(); | ||
107 | } | 115 | } | ||
108 | 116 | | |||
109 | function stopTimer() { | 117 | function stopTimer() { | ||
110 | running = false; | 118 | running = false; | ||
111 | suspended = true; | 119 | suspended = true; | ||
120 | startedAt = 0; | ||||
121 | initialSeconds = 0; | ||||
112 | saveTimer(); | 122 | saveTimer(); | ||
113 | } | 123 | } | ||
114 | 124 | | |||
115 | function resetTimer() { | 125 | function resetTimer() { | ||
116 | running = false; | 126 | running = false; | ||
117 | suspended = false; | 127 | suspended = false; | ||
118 | seconds = 0; | 128 | seconds = 0; | ||
129 | startedAt = 0; | ||||
130 | initialSeconds = 0; | ||||
119 | opacityNeedsReset() | 131 | opacityNeedsReset() | ||
120 | saveTimer(); | 132 | saveTimer(); | ||
121 | } | 133 | } | ||
122 | 134 | | |||
123 | signal opacityNeedsReset() | 135 | signal opacityNeedsReset() | ||
124 | signal digitHasChanged() | 136 | signal digitHasChanged() | ||
125 | 137 | | |||
126 | function saveTimer() { | 138 | function saveTimer() { | ||
Show All 40 Lines |