Merge lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-staging into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 380
Merged at revision: 340
Proposed branch: lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-staging
Merge into: lp:ubuntu-clock-app
Diff against target: 2139 lines (+1391/-309)
32 files modified
AUTHORS (+1/-0)
app/CMakeLists.txt (+2/-0)
app/MainPage.qml (+121/-0)
app/clock/ClockPage.qml (+126/-176)
app/components/ActionIcon.qml (+45/-0)
app/components/CMakeLists.txt (+2/-0)
app/components/HeaderNavigation.qml (+86/-0)
app/graphics/CMakeLists.txt (+2/-0)
app/graphics/Stopwatch_Placeholder.svg (+19/-0)
app/graphics/WorldClock_Placeholder.svg (+22/-0)
app/stopwatch/CMakeLists.txt (+11/-0)
app/stopwatch/LapListView.qml (+140/-0)
app/stopwatch/StopwatchFace.qml (+61/-0)
app/stopwatch/StopwatchPage.qml (+169/-0)
app/stopwatch/StopwatchUtils.qml (+73/-0)
app/ubuntu-clock-app.qml (+19/-20)
app/worldclock/AddWorldCityButton.qml (+8/-4)
app/worldclock/UserWorldCityList.qml (+94/-93)
backend/CMakeLists.txt (+25/-0)
backend/modules/Stopwatch/LapHistory/backend.cpp (+34/-0)
backend/modules/Stopwatch/LapHistory/backend.h (+35/-0)
backend/modules/Stopwatch/LapHistory/history.cpp (+97/-0)
backend/modules/Stopwatch/LapHistory/history.h (+64/-0)
backend/modules/Stopwatch/LapHistory/qmldir (+2/-0)
debian/changelog (+2/-0)
debian/control (+2/-0)
po/com.ubuntu.clock.pot (+38/-8)
tests/unit/CMakeLists.txt (+2/-0)
tests/unit/MockClockApp.qml (+6/-5)
tests/unit/tst_stopwatchUtils.qml (+79/-0)
tests/unit/tst_worldClock.qml (+1/-1)
ubuntu-clock-app.json (+3/-2)
To merge this branch: bzr merge lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-staging
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Victor Thompson Needs Fixing
Review via email: mp+266718@code.launchpad.net

Commit message

Implement the new stopwatch feature

Description of the change

This is a staging MP for the stopwatch feature. All intermediate stopwatch code implementation should be merged into this branch while keep trunk clean and stable.

Things Implemented:
-------------------
- New navigation model
- Stopwatch UI
- Stopwatch backend JS functions
- Stopwatch Laps model & ui
- Header row (icon based navigation model)
- Credited Michael Zanetti for his code in the Authors file
- Minor performance optimization done (unload stopwatch laps when not running, disable bottom-edge in stopwatch tab, stop checking time to next alarm when mainpage is not visible)
- Ran timekeeping test and it performed quite well
- Unit tests
- Rebuilt .pot file
- Manual testing
- UX Feedback/Approval received from James Mullholland.
- Final finishing touches
- Disabled page scrolling after informing James. Will be fixed in another MP later.
- Merged bartosz's MP lp:~ubuntu-clock-dev/ubuntu-clock-app/stopwatch-feature-extended

Note:

For the stopwatch backend, let's use the reference implementation of https://uappexplorer.com/app/stopwatch.mzanetti. It seems to be working quite good with simple qml+js code.

Check out https://bazaar.launchpad.net/~mzanetti/+junk/stopwatch/view/head:/app/StopWatch.qml for the code.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
335. By Nekhelesh Ramananthan

Improved header navigation by making it part of the page flickable

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Awensome work Nekhelesh.

Here my 2 cents:
1. Clicking/touching stopwatch icon should swipe to the corresponding Page (Stopwatch, World Clock)
2. In full sun it is hard to read when stopwatch is enabled, and when not. Some improvement proposal:
   - Change "Start" button color to green and "Stop" button color to red.
   - Enable "Seconds hand". I will visualise the stopwatch progress. It will be also very similar with World Clock. When you press "Lap" button, it will be restarted.
3. During pressing "Lap" it is hard to notice what was happen. Some numbers are changing. Maybe some small "lap scroll down" animation will improve that UX. What do you think?
4. It will be good to add some visual details which will be unique for Stop Watch, so user will know for first look what page it is displayed.

review: Needs Information
336. By Nekhelesh Ramananthan

Changed start/stop button color to green and red for better visual distinction

337. By Nekhelesh Ramananthan

Made the header navigation buttons clickable

338. By Nekhelesh Ramananthan

Increased speed of screen switch transition

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> 1. Clicking/touching stopwatch icon should swipe to the corresponding Page
> (Stopwatch, World Clock)

Fixed

> 2. In full sun it is hard to read when stopwatch is enabled, and when not.
> Some improvement proposal:
> - Change "Start" button color to green and "Stop" button color to red.

Fixed

> - Enable "Seconds hand". I will visualise the stopwatch progress. It will
> be also very similar with World Clock. When you press "Lap" button, it will be
> restarted.

Needs visuals for this. Let's discuss with designers.

> 3. During pressing "Lap" it is hard to notice what was happen. Some numbers
> are changing. Maybe some small "lap scroll down" animation will improve that
> UX. What do you think?

Fixed

> 4. It will be good to add some visual details which will be unique for Stop
> Watch, so user will know for first look what page it is displayed.

I need some visuals for this. I did look at http://design.canonical.com/wp-content/uploads/keyscreens_clock.jpg, but need to brainstorm on how to integrate that with the current design.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
339. By Nekhelesh Ramananthan

Disable flickable scrolling when content height is less than phone height

340. By Nekhelesh Ramananthan

Disabled screen switching by swiping as it conflicts with listitem swipe-to-delete gesture

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

I get the following in the logs before the app crashes:

file:///opt/click.ubuntu.com/com.ubuntu.clock/3.5./share/qml/components/HeaderNavigation.qml:32 ActionIcon is not a type

Is this component perhaps only available on wily/devel-proposed?

review: Needs Fixing
Revision history for this message
Victor Thompson (vthompson) wrote :

Disregard my last comment. It seems I needed to refresh/reload the project so the file would be found by QtCreator.

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Some more remarks:
1. With current implementation page swiping is not working any more.
2. In my opinion the time list is not easy to read, at first look:
  - It is hard to say which time is lap and which total time. In https://uappexplorer.com/app/stopwatch.mzanetti there are additionals description for every row.
  - It is hard to compare time results. In https://uappexplorer.com/app/stopwatch.mzanetti the hours is not displayed and miliseconds are smaller
  - Currently time list it looks like: http://i.imgur.com/qxh932g.png

review: Needs Fixing
341. By Victor Thompson

Use the word resume if the timer has started

Revision history for this message
Victor Thompson (vthompson) wrote :

This would need UX approval, but I think tapping the clock face should start/stop the timer as well. Since the "clock" functionality of the app allows the user to "toggle" an action using the clock face, I think this functionality should probably do so as well--in addition to the button.

342. By Victor Thompson

Don't show clear button if nothing to clear

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

I'm not sure if everyone will be on board with my latest small change. I made it so if the timer hasn't counted any time, that the clear/lap button isn't shown and only the Start button is shown. This is how my Android stopwatch (Google Clock) behaves. Please feel free to revert r342 if anyone disagrees with this.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Some additional inline comments

review: Needs Fixing
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

@Bartosz I addressed the inline comments in the latest commit. Fixed many of them and explained the reasoning for the rest.

343. By Nekhelesh Ramananthan

Merged lp:ubuntu-clock-app trunk changes

344. By Nekhelesh Ramananthan

Fixed some code styling and improve stopwatch utils functions

345. By Nekhelesh Ramananthan

Updated debian changelog

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> Some more remarks:
> 1. With current implementation page swiping is not working any more.

Yes, that's intentional since the swipe-to-delete world city gesture is conflicting with the page swiping gesture. I talked to Unity developers like Michael Zanetti and agree that disabling that is the best way to go. I will bring this up with the designers when we meet.

> 2. In my opinion the time list is not easy to read, at first look:
> - It is hard to say which time is lap and which total time. In
> https://uappexplorer.com/app/stopwatch.mzanetti there are additionals
> description for every row.
> - It is hard to compare time results. In
> https://uappexplorer.com/app/stopwatch.mzanetti the hours is not displayed and
> miliseconds are smaller
> - Currently time list it looks like: http://i.imgur.com/qxh932g.png

I totally agree to both your points. If you look at the design document given to us, it didn't have a lap design. So I just temporarily just implemented something temporarily. I feel that the mzanetti's stopwatch app is a bit crowded. So I don't think showing the string "totalTime" and "laptime" for every list item would look nice. Perhaps as a header maybe? I will see what I can come up with or ask the designers.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> I'm not sure if everyone will be on board with my latest small change. I made
> it so if the timer hasn't counted any time, that the clear/lap button isn't
> shown and only the Start button is shown. This is how my Android stopwatch
> (Google Clock) behaves. Please feel free to revert r342 if anyone disagrees
> with this.

Both the changes you merged to the branch are good. I will make a small improvement to it by adding a small property animation when the lap button is shown/hidden to ease the transition :).

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
346. By Nekhelesh Ramananthan

Added a nice sexy animation when hiding/showing the lap button. Enjoy!

347. By Nekhelesh Ramananthan

Added a lap header to help distinguish between laptime and totaltime

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Some more inline remarks.

review: Needs Fixing
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Addressed most of the inline comments in latest commit.

348. By Nekhelesh Ramananthan

Changed lap# to just lap

349. By Nekhelesh Ramananthan

Ensured lap number respects user locale

350. By Nekhelesh Ramananthan

Replaced GLOB to Set in stopwatch CMake file

351. By Nekhelesh Ramananthan

Merged lp:ubuntu-clock-app

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
352. By Nekhelesh Ramananthan

Added unit tests to stopwatch utils functions

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
353. By Nekhelesh Ramananthan

Fixed stopwatch buttons behaving strangely when returning from the settings page

354. By Nekhelesh Ramananthan

Moved header row to main page instead of duplicating it in every page. Also made listview horizontally scrollable

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
355. By Nekhelesh Ramananthan

merged trunk lp:ubuntu-clock-app

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
356. By Nekhelesh Ramananthan

Merged trunk lp:ubuntu-clock-app

357. By Nekhelesh Ramananthan

Disabled screen dimming when stopwatch is running

358. By Nekhelesh Ramananthan

Merged lp:ubuntu-clock-app

359. By Nekhelesh Ramananthan

Tweaked CMakelist file to include HeaderNavigation and ActionIcon

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
360. By Nekhelesh Ramananthan

Updated clock app dependency to include qml-module-qtsysteminfo without which jenkins fails

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Here is what I'm missing with current StopWatch implementation:
1. Saving laps in database after pressing Lap or stop Button. After close and run Clock application, the results should be still there
2. When you start stopwatch the starttime should be stored in database. After closing Clock app, and reopening it, the time should be still counting (we could just calculate difference between starttime and current time).

These features could be implemented later, but this is good input for UX approval

review: Needs Information
361. By Bartosz Kosiorek

Keep running stopwatch in the background,
even when the phone/clock app is turned off (LP: #1484942)

362. By Bartosz Kosiorek

Remove uneccesary comment

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
363. By Nekhelesh Ramananthan

Reverted r361 and r362

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
364. By Nekhelesh Ramananthan

Removed Flickables and split vertical pane into 2 as per design. Also removed Flickup and FlickDown signals as they are no longer needed

365. By Nekhelesh Ramananthan

Added more official icon placeholders

366. By Nekhelesh Ramananthan

merged lp:ubuntu-clock-app trunk

367. By Nekhelesh Ramananthan

Minor anchor change to remove unnecessary design change

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
368. By Nekhelesh Ramananthan

first attempt at fixing unit test

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
369. By Nekhelesh Ramananthan

Updated pot file

370. By Nekhelesh Ramananthan

Removed remaining FlickUp FlickDown signal

371. By Nekhelesh Ramananthan

More code cleanup

372. By Nekhelesh Ramananthan

Added comment

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
373. By Nekhelesh Ramananthan

Reduced font size of milliseconds and hid the hours in the laptime when possible. Added units to cover this function

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
374. By Nekhelesh Ramananthan

Merged lp:ubuntu-clock-app

375. By Nekhelesh Ramananthan

Disabled page swipe gesture after getting approval from james

376. By Nekhelesh Ramananthan

Increased height of add world city button container

377. By Nekhelesh Ramananthan

Changed color of settings icon to match rest of the header icons

378. By Nekhelesh Ramananthan

Fixed minor anchoring issue

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
379. By Nekhelesh Ramananthan

Merged bartosz stopwatch-feature-extended branch

380. By Nekhelesh Ramananthan

Updated pot file one last time

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

I tested it on Desktop and device and I didn't notice any issues.

review: Approve
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

* Does the MP add/remove user visible strings? If Yes, has the pot file been
    updated?

Updated

* Does the MP change the UI? If Yes, has it been approved by design?

UX change was approved.

* Did you perform an exploratory manual test run of your code change and any
    related functionality?

Extensive testing done on desktop and phone

* If the MP fixes a bug or implements a feature, are there accompanying unit
    and autopilot tests?

Not required

* Is the clock app trunk buildable and runnable using Qtcreator?

Yes
* Was the debian changelog updated?

Yes

* Was the copyright years updated if necessary?

Yes

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AUTHORS'
--- AUTHORS 2015-07-06 17:17:59 +0000
+++ AUTHORS 2015-08-20 20:43:05 +0000
@@ -25,6 +25,7 @@
25Marco Biscaro <marcobiscaro2112@gmail.com>25Marco Biscaro <marcobiscaro2112@gmail.com>
26Mario Guerriero <mefrio.g@gmail.com>26Mario Guerriero <mefrio.g@gmail.com>
27Michael Hall <mhall119@ubuntu.com>27Michael Hall <mhall119@ubuntu.com>
28Michael Zanetti <michael.zanetti@canonical.com>
28Michal Predotka <mpredotka@gmail.com>29Michal Predotka <mpredotka@gmail.com>
29Michał Sawicz <michal.sawicz@canonical.com>30Michał Sawicz <michal.sawicz@canonical.com>
30Nekhelesh Ramananthan <krnekhelesh@hotmail.com>31Nekhelesh Ramananthan <krnekhelesh@hotmail.com>
3132
=== modified file 'app/CMakeLists.txt'
--- app/CMakeLists.txt 2014-09-26 16:58:03 +0000
+++ app/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -10,9 +10,11 @@
10endif(CLICK_MODE)10endif(CLICK_MODE)
1111
12install(FILES ${MAIN_QML} DESTINATION ${UBUNTU-CLOCK_APP_DIR})12install(FILES ${MAIN_QML} DESTINATION ${UBUNTU-CLOCK_APP_DIR})
13install(FILES "MainPage.qml" DESTINATION ${UBUNTU-CLOCK_APP_DIR})
1314
14add_subdirectory(clock)15add_subdirectory(clock)
15add_subdirectory(alarm)16add_subdirectory(alarm)
17add_subdirectory(stopwatch)
16add_subdirectory(graphics)18add_subdirectory(graphics)
17add_subdirectory(components)19add_subdirectory(components)
18add_subdirectory(worldclock)20add_subdirectory(worldclock)
1921
=== added file 'app/MainPage.qml'
--- app/MainPage.qml 1970-01-01 00:00:00 +0000
+++ app/MainPage.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21import QtSystemInfo 5.0
22import Qt.labs.settings 1.0
23import "upstreamcomponents"
24import "alarm"
25import "clock"
26import "stopwatch"
27import "components"
28
29PageWithBottomEdge {
30 id: _mainPage
31 objectName: "mainPage"
32
33 // Property to keep track of the clock time
34 property var clockTime: new Date()
35
36 // Property to keep track of an app cold start status
37 property alias isColdStart: clockPage.isColdStart
38
39 // Property to check if the clock page is currently visible
40 property bool isClockPage: listview.currentIndex === 0
41
42 // Clock App Alarm Model Reference Variable
43 property var alarmModel
44
45 flickable: null
46 bottomEdgeTitle: _mainPage.visible ? alarmUtils.set_bottom_edge_title(alarmModel, clockTime)
47 : i18n.tr("No active alarms")
48
49 Component.onCompleted: {
50 console.log("[LOG]: Main Page loaded")
51 _mainPage.setBottomEdgePage(Qt.resolvedUrl("alarm/AlarmPage.qml"), {})
52 }
53
54 AlarmUtils {
55 id: alarmUtils
56 }
57
58 ScreenSaver {
59 // Disable screen dimming/off when stopwatch is running
60 screenSaverEnabled: !stopwatchPage.running
61 }
62
63 Settings {
64 id: stopwatchState
65 category: "Stopwatch"
66 property alias startTime: stopwatchPage.startTime
67 property alias running: stopwatchPage.running
68 property alias oldDiff: stopwatchPage.oldDiff
69 }
70
71 VisualItemModel {
72 id: navigationModel
73 ClockPage {
74 id: clockPage
75 clockTime: _mainPage.clockTime
76 width: clockApp.width
77 height: listview.height
78 }
79
80 StopwatchPage {
81 id: stopwatchPage
82 width: clockApp.width
83 height: listview.height
84 }
85 }
86
87 HeaderNavigation {
88 id: headerRow
89
90 anchors {
91 top: parent.top
92 left: parent.left
93 right: parent.right
94 topMargin: 0
95 }
96 }
97
98 ListView {
99 id: listview
100
101 // Show the stopwatch page on app startup if it is running
102 Component.onCompleted: {
103 if (stopwatchState.running)
104 positionViewAtIndex(1, ListView.SnapPosition)
105 }
106
107 anchors {
108 top: headerRow.bottom
109 left: parent.left
110 right: parent.right
111 bottom: parent.bottom
112 }
113
114 model: navigationModel
115 orientation: ListView.Horizontal
116 snapMode: ListView.SnapOneItem
117 interactive: false
118 highlightMoveDuration: UbuntuAnimation.BriskDuration
119 highlightRangeMode: ListView.StrictlyEnforceRange
120 }
121}
0122
=== modified file 'app/clock/ClockPage.qml'
--- app/clock/ClockPage.qml 2015-08-07 11:45:17 +0000
+++ app/clock/ClockPage.qml 2015-08-20 20:43:05 +0000
@@ -21,12 +21,10 @@
21import QtPositioning 5.221import QtPositioning 5.2
22import Ubuntu.Components 1.222import Ubuntu.Components 1.2
23import GeoLocation 1.023import GeoLocation 1.0
24import "../alarm"
25import "../components"24import "../components"
26import "../upstreamcomponents"
27import "../worldclock"25import "../worldclock"
2826
29PageWithBottomEdge {27Item {
30 id: _clockPage28 id: _clockPage
31 objectName: "clockPage"29 objectName: "clockPage"
3230
@@ -39,18 +37,9 @@
39 // Property to keep track of app cold start status37 // Property to keep track of app cold start status
40 property alias isColdStart: clock.isColdStart38 property alias isColdStart: clock.isColdStart
4139
42 property var alarmModel
43
44 flickable: null
45 bottomEdgeTitle: alarmUtils.set_bottom_edge_title(alarmModel, clockTime)
46
47 Component.onCompleted: {40 Component.onCompleted: {
48 console.log("[LOG]: Clock Page loaded")41 console.log("[LOG]: Clock Page loaded")
49 _clockPage.setBottomEdgePage(Qt.resolvedUrl("../alarm/AlarmPage.qml"), {})42 otherElementsStartUpAnimation.start()
50 }
51
52 AlarmUtils {
53 id: alarmUtils
54 }43 }
5544
56 PositionSource {45 PositionSource {
@@ -167,178 +156,139 @@
167 }156 }
168 }157 }
169158
170 Flickable {159 MainClock {
171 id: _flickable160 id: clock
172161 objectName: "clock"
173 Component.onCompleted: otherElementsStartUpAnimation.start()162
174163 Component.onCompleted: {
175 onFlickStarted: {164 geoposition.lastUpdate = analogTime
176 forceActiveFocus()165 }
177 }166
178167 analogTime: clockTime
179 anchors.fill: parent168
180 contentWidth: parent.width169 anchors {
181 contentHeight: clock.height + date.height + locationRow.height170 verticalCenter: parent.top
182 + worldCityColumn.height + addWorldCityButton.height171 verticalCenterOffset: units.gu(18)
183 + units.gu(16)172 horizontalCenter: parent.horizontalCenter
184173 }
185 AbstractButton {174 }
186 id: settingsIcon175
187 objectName: "settingsIcon"176 Label {
188177 id: date
189 onClicked: {178
190 mainStack.push(Qt.resolvedUrl("../alarm/AlarmSettingsPage.qml"))179 anchors {
191 }180 top: parent.top
192181 topMargin: units.gu(41)
193 width: units.gu(5)182 horizontalCenter: parent.horizontalCenter
194 height: width183 }
195 opacity: 0184
196185 text: clock.analogTime.toLocaleDateString()
197 anchors {186
198 top: parent.top187 opacity: 0
199 topMargin: units.gu(6)188 color: locationRow.visible ? Theme.palette.normal.baseText : UbuntuColors.midAubergine
200 right: parent.right189 fontSize: "medium"
201 rightMargin: units.gu(2)190 }
202 }191
203192 Row {
204 Rectangle {193 id: locationRow
205 visible: settingsIcon.pressed194 objectName: "locationRow"
206 anchors.fill: parent195
207 color: Theme.palette.selected.background196 opacity: date.opacity
208 }197 spacing: units.gu(1)
209198 visible: location.text !== "Null" && location.text !== "Denied"
210 Icon {199
211 width: units.gu(3)200 anchors {
212 height: width201 top: date.bottom
213 anchors.centerIn: parent202 topMargin: units.gu(1)
214 name: "settings"203 horizontalCenter: parent.horizontalCenter
215 color: "Grey"204 }
216 }205
217 }206 Icon {
218207 id: locationIcon
219 MainClock {208 name: "location"
220 id: clock209 height: units.gu(2.2)
221 objectName: "clock"210 color: "Grey"
222
223 Component.onCompleted: {
224 geoposition.lastUpdate = analogTime
225 }
226
227 analogTime: clockTime
228
229 anchors {
230 verticalCenter: parent.top
231 verticalCenterOffset: units.gu(20)
232 horizontalCenter: parent.horizontalCenter
233 }
234 }211 }
235212
236 Label {213 Label {
237 id: date214 id: location
238215 objectName: "location"
239 anchors {216
240 top: parent.top
241 topMargin: units.gu(36)
242 horizontalCenter: parent.horizontalCenter
243 }
244
245 text: clock.analogTime.toLocaleDateString()
246 opacity: settingsIcon.opacity
247 color: locationRow.visible ? Theme.palette.normal.baseText : UbuntuColors.midAubergine
248 fontSize: "medium"217 fontSize: "medium"
218 anchors.verticalCenter: locationIcon.verticalCenter
219 color: UbuntuColors.midAubergine
220
221 text: {
222 if (userLocationDocument.contents.location === "Null"
223 || userLocationDocument.contents.location === "Denied"
224 && geoposition.sourceError === PositionSource.NoError) {
225 return i18n.tr("Retrieving location...")
226 }
227
228 else {
229 return userLocationDocument.contents.location
230 }
231 }
249 }232 }
250233 }
251 Row {234
252 id: locationRow235 MouseArea {
253 objectName: "locationRow"236 id: worldCityListMouseArea
254237
255 opacity: settingsIcon.opacity238 preventStealing: true
256 spacing: units.gu(1)239
257 visible: location.text !== "Null" && location.text !== "Denied"240 anchors {
258241 top: locationRow.bottom
259 anchors {242 topMargin: units.gu(2)
260 top: date.bottom243 bottom: parent.bottom
261 topMargin: units.gu(1)244 left: parent.left
262 horizontalCenter: parent.horizontalCenter245 right: parent.right
263 }
264
265 Icon {
266 id: locationIcon
267 name: "location"
268 height: units.gu(2.2)
269 color: "Grey"
270 }
271
272 Label {
273 id: location
274 objectName: "location"
275
276 fontSize: "medium"
277 anchors.verticalCenter: locationIcon.verticalCenter
278 color: UbuntuColors.midAubergine
279
280 text: {
281 if (userLocationDocument.contents.location === "Null"
282 || userLocationDocument.contents.location === "Denied"
283 && geoposition.sourceError === PositionSource.NoError) {
284 return i18n.tr("Retrieving location...")
285 }
286
287 else {
288 return userLocationDocument.contents.location
289 }
290 }
291 }
292 }246 }
293247
294 UserWorldCityList {248 UserWorldCityList {
295 id: worldCityColumn249 id: worldCityColumn
296 objectName: "worldCityColumn"250 opacity: date.opacity
297251
298 opacity: settingsIcon.opacity252 footer: AddWorldCityButton {
299 anchors {253 id: addWorldCityButton
300 top: locationRow.bottom254 objectName: "addWorldCityButton"
301 topMargin: units.gu(4)255 }
302 }256 }
303 }257 }
304258
305 AddWorldCityButton {259 ParallelAnimation {
306 id: addWorldCityButton260 id: otherElementsStartUpAnimation
307 objectName: "addWorldCityButton"261
308262 PropertyAnimation {
309 opacity: settingsIcon.opacity263 target: headerRow
310 anchors {264 property: "anchors.topMargin"
311 top: worldCityColumn.bottom265 from: units.gu(4)
312 topMargin: units.gu(1)266 to: 0
313 }267 duration: 900
314 }268 }
315269
316 ParallelAnimation {270 PropertyAnimation {
317 id: otherElementsStartUpAnimation271 target: headerRow
318272 property: "opacity"
319 PropertyAnimation {273 from: 0
320 target: settingsIcon274 to: 1
321 property: "anchors.topMargin"275 duration: 900
322 from: units.gu(6)276 }
323 to: units.gu(2)277
324 duration: 900278 PropertyAnimation {
325 }279 target: date
326280 property: "opacity"
327 PropertyAnimation {281 from: 0
328 target: settingsIcon282 to: 1
329 property: "opacity"283 duration: 900
330 from: 0284 }
331 to: 1285
332 duration: 900286 PropertyAnimation {
333 }287 target: date
334288 property: "anchors.topMargin"
335 PropertyAnimation {289 from: units.gu(41)
336 target: date290 to: units.gu(37)
337 property: "anchors.topMargin"291 duration: 900
338 from: units.gu(36)
339 to: units.gu(40)
340 duration: 900
341 }
342 }292 }
343 }293 }
344}294}
345295
=== added file 'app/components/ActionIcon.qml'
--- app/components/ActionIcon.qml 1970-01-01 00:00:00 +0000
+++ app/components/ActionIcon.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21
22AbstractButton {
23 id: abstractButton
24
25 property alias iconName: _icon.name
26 property alias iconSource: _icon.source
27 property alias iconWidth: _icon.width
28
29 width: units.gu(5)
30 height: width
31
32 Rectangle {
33 visible: abstractButton.pressed
34 anchors.fill: parent
35 color: Theme.palette.selected.background
36 }
37
38 Icon {
39 id: _icon
40 width: units.gu(3)
41 height: width
42 anchors.centerIn: parent
43 color: "#5B5B5B"
44 }
45}
046
=== modified file 'app/components/CMakeLists.txt'
--- app/components/CMakeLists.txt 2015-08-11 15:05:34 +0000
+++ app/components/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -1,4 +1,5 @@
1set(COMPONENTS_QML_JS_FILES1set(COMPONENTS_QML_JS_FILES
2 ActionIcon.qml
2 AnalogMode.qml3 AnalogMode.qml
3 AnalogShadow.qml4 AnalogShadow.qml
4 Background.qml5 Background.qml
@@ -8,6 +9,7 @@
8 DigitalShadow.qml9 DigitalShadow.qml
9 EmptyState.qml10 EmptyState.qml
10 ExpandableListItem.qml11 ExpandableListItem.qml
12 HeaderNavigation.qml
11 Shadow.qml13 Shadow.qml
12 SubtitledListItem.qml14 SubtitledListItem.qml
13)15)
1416
=== added file 'app/components/HeaderNavigation.qml'
--- app/components/HeaderNavigation.qml 1970-01-01 00:00:00 +0000
+++ app/components/HeaderNavigation.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21
22Item {
23 id: headerRow
24
25 height: units.gu(7)
26
27 Row {
28 id: iconContainer
29
30 anchors.centerIn: parent
31
32 ActionIcon {
33 width: units.gu(5.5)
34 height: units.gu(4)
35 iconWidth: units.gu(4)
36 iconSource: Qt.resolvedUrl("../graphics/WorldClock_Placeholder.svg")
37 onClicked: listview.currentIndex = 0
38 }
39
40 ActionIcon {
41 width: units.gu(5.5)
42 height: units.gu(4)
43 iconWidth: units.gu(4)
44 iconSource: Qt.resolvedUrl("../graphics/Stopwatch_Placeholder.svg")
45 onClicked: listview.currentIndex = 1
46 }
47 }
48
49 Rectangle {
50 id: outerProgressRectangle
51 anchors {
52 left: iconContainer.left
53 right: iconContainer.right
54 top: iconContainer.bottom
55 }
56 height: units.gu(0.3)
57 color: UbuntuColors.lightGrey
58
59 Rectangle {
60 height: parent.height
61 x: listview.currentIndex == 0 ? 0 : parent.width-width
62 width: units.gu(5.5)
63 color: UbuntuColors.orange
64 Behavior on x {
65 UbuntuNumberAnimation {}
66 }
67 }
68 }
69
70 ActionIcon {
71 id: settingsIcon
72 objectName: "settingsIcon"
73
74 anchors {
75 verticalCenter: parent.verticalCenter
76 right: parent.right
77 rightMargin: units.gu(2)
78 }
79
80 iconName: "settings"
81
82 onClicked: {
83 mainStack.push(Qt.resolvedUrl("../alarm/AlarmSettingsPage.qml"))
84 }
85 }
86}
087
=== modified file 'app/graphics/CMakeLists.txt'
--- app/graphics/CMakeLists.txt 2015-08-11 16:05:15 +0000
+++ app/graphics/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -7,6 +7,8 @@
7 Second_Hand@27.png7 Second_Hand@27.png
8 select-none.svg8 select-none.svg
9 select.svg9 select.svg
10 Stopwatch_Placeholder.svg
11 WorldClock_Placeholder.svg
10)12)
1113
12# make the files visible in the qtcreator tree14# make the files visible in the qtcreator tree
1315
=== added file 'app/graphics/Stopwatch_Placeholder.svg'
--- app/graphics/Stopwatch_Placeholder.svg 1970-01-01 00:00:00 +0000
+++ app/graphics/Stopwatch_Placeholder.svg 2015-08-20 20:43:05 +0000
@@ -0,0 +1,19 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3 <!-- Generator: Sketch 3.3.3 (12072) - http://www.bohemiancoding.com/sketch -->
4 <title>Placeholder Icons</title>
5 <desc>Created with Sketch.</desc>
6 <defs></defs>
7 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8 <g id="Placeholder-Icons" sketch:type="MSArtboardGroup" stroke="#5B5B5B">
9 <g id="Timer-+-Stopwatch-+-Clock-icon" sketch:type="MSLayerGroup" transform="translate(19.000000, 17.000000)">
10 <g id="Stopwatch" transform="translate(3.000000, 0.000000)" sketch:type="MSShapeGroup">
11 <circle id="Oval-125-Copy" stroke-width="3" cx="28.5" cy="37.5" r="28.5"></circle>
12 <path d="M22,1 L34.0300293,1.00149091" id="Line-Copy-3" stroke-width="5" stroke-linecap="square"></path>
13 <path d="M26,6 L30.0300293,6.00149091" id="Line-Copy-4" stroke-width="5" stroke-linecap="square"></path>
14 <path d="M34.6896914,37.7022985 L34.6896914,22.495895" id="Line-Copy-5" stroke-width="3" stroke-linecap="square" transform="translate(34.689691, 30.099097) rotate(-315.000000) translate(-34.689691, -30.099097) "></path>
15 </g>
16 </g>
17 </g>
18 </g>
19</svg>
0\ No newline at end of file20\ No newline at end of file
121
=== added file 'app/graphics/WorldClock_Placeholder.svg'
--- app/graphics/WorldClock_Placeholder.svg 1970-01-01 00:00:00 +0000
+++ app/graphics/WorldClock_Placeholder.svg 2015-08-20 20:43:05 +0000
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3 <!-- Generator: Sketch 3.3.3 (12072) - http://www.bohemiancoding.com/sketch -->
4 <title>Placeholder Icons</title>
5 <desc>Created with Sketch.</desc>
6 <defs></defs>
7 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8 <g id="Placeholder-Icons" sketch:type="MSArtboardGroup">
9 <g id="Timer-+-Stopwatch-+-Clock-icon" sketch:type="MSLayerGroup" transform="translate(19.000000, 17.000000)">
10 <g id="Clock-icon" transform="translate(0.000000, 5.000000)" sketch:type="MSShapeGroup">
11 <path d="M19.7838596,0 C2.47304842,0 0,2.48317111 0,19.8659897 L0,37.1340103 C0,54.5167567 2.47304842,57 19.7838596,57 L41.2161404,57 C58.5269504,57 61,54.5167567 61,37.1340103 L61,19.8659897 C61,2.48317111 58.5269504,0 41.2161404,0 L19.7838596,0 L19.7838596,0 Z" id="rect4158" stroke="#5B5B5B" stroke-width="3"></path>
12 <g id="Hands" transform="translate(17.632812, 16.884454)">
13 <path d="M0.026502832,4.16418529 L12.8671875,11.6155462" id="path4219" stroke="#5B5B5B" stroke-width="3"></path>
14 <path d="M12.8671875,11.6155462 L32.7118814,0.099807479" id="path4231" stroke="#5B5B5B" stroke-width="2"></path>
15 <ellipse id="path4221" fill="#5B5B5B" cx="12.8570867" cy="10.6155882" rx="4.37271174" ry="4.39499998"></ellipse>
16 <path d="M12.5,11.1155462 L12.5,31.7331933" id="path4223" stroke="#5B5B5B"></path>
17 </g>
18 </g>
19 </g>
20 </g>
21 </g>
22</svg>
0\ No newline at end of file23\ No newline at end of file
124
=== added directory 'app/stopwatch'
=== added file 'app/stopwatch/CMakeLists.txt'
--- app/stopwatch/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ app/stopwatch/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -0,0 +1,11 @@
1set(STOPWATCH_QML_JS_FILES
2 LapListView.qml
3 StopwatchFace.qml
4 StopwatchPage.qml
5 StopwatchUtils.qml
6)
7
8# make the files visible in the qtcreator tree
9add_custom_target(ubuntu-clock-app_stopwatch_QMlFiles ALL SOURCES ${STOPWATCH_QML_JS_FILES})
10
11install(FILES ${STOPWATCH_QML_JS_FILES} DESTINATION ${UBUNTU-CLOCK_APP_DIR}/stopwatch)
012
=== added file 'app/stopwatch/LapListView.qml'
--- app/stopwatch/LapListView.qml 1970-01-01 00:00:00 +0000
+++ app/stopwatch/LapListView.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,140 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import QtQuick.Layouts 1.1
21import Ubuntu.Components 1.2
22
23ListView {
24 id: lapListView
25
26 clip: true
27
28 StopwatchUtils {
29 id: stopwatchUtils
30 }
31
32 header: ListItem {
33 visible: count !== 0
34 Row {
35 anchors {
36 left: parent.left
37 right: parent.right
38 verticalCenter: parent.verticalCenter
39 margins: units.gu(2)
40 }
41
42 Label {
43 // #TRANSLATORS: This refers to the stopwatch lap and is shown as a header where space is limited. Constrain
44 // translation length to a few characters.
45 text: i18n.tr("Lap")
46 width: parent.width / 7
47 elide: Text.ElideRight
48 font.weight: Font.DemiBold
49 horizontalAlignment: Text.AlignHCenter
50 }
51
52 Label {
53 width: 3 * parent.width / 7
54 elide: Text.ElideRight
55 text: i18n.tr("Lap Time")
56 font.weight: Font.DemiBold
57 horizontalAlignment: Text.AlignHCenter
58 }
59
60 Label {
61 width: 3 * parent.width / 7
62 elide: Text.ElideRight
63 text: i18n.tr("Total Time")
64 font.weight: Font.DemiBold
65 horizontalAlignment: Text.AlignHCenter
66 }
67 }
68 }
69
70 displaced: Transition {
71 UbuntuNumberAnimation {
72 property: "y"
73 duration: UbuntuAnimation.BriskDuration
74 }
75 }
76
77 delegate: ListItem {
78 divider.visible: true
79 leadingActions: ListItemActions {
80 actions: [
81 Action {
82 iconName: "delete"
83 onTriggered: {
84 lapHistory.removeLap(index)
85 }
86 }
87 ]
88 }
89
90 Row {
91 anchors {
92 left: parent.left
93 right: parent.right
94 verticalCenter: parent.verticalCenter
95 margins: units.gu(2)
96 }
97
98 Label {
99 color: UbuntuColors.midAubergine
100 text: "#%1".arg(Number(count - index).toLocaleString(Qt.locale(), "f", 0))
101 width: parent.width / 7
102 horizontalAlignment: Text.AlignHCenter
103 }
104
105 Item {
106 width: 3 * parent.width / 7
107 height: childrenRect.height
108 Row {
109 anchors.horizontalCenter: parent.horizontalCenter
110 Label {
111 text: stopwatchUtils.lapTimeToString(model.laptime) + "."
112 }
113 Label {
114 fontSize: "x-small"
115 text: stopwatchUtils.millisToString(model.laptime)
116 anchors.bottom: parent.bottom
117 anchors.bottomMargin: units.dp(1)
118 }
119 }
120 }
121
122 Item {
123 width: 3 * parent.width / 7
124 height: childrenRect.height
125 Row {
126 anchors.horizontalCenter: parent.horizontalCenter
127 Label {
128 text: stopwatchUtils.lapTimeToString(model.totaltime) + "."
129 }
130 Label {
131 fontSize: "x-small"
132 text: stopwatchUtils.millisToString(model.totaltime)
133 anchors.bottom: parent.bottom
134 anchors.bottomMargin: units.dp(1)
135 }
136 }
137 }
138 }
139 }
140}
0141
=== added file 'app/stopwatch/StopwatchFace.qml'
--- app/stopwatch/StopwatchFace.qml 1970-01-01 00:00:00 +0000
+++ app/stopwatch/StopwatchFace.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21import "../components"
22
23ClockCircle {
24 id: outerCirle
25
26 // Property to hold the total time (in milliseconds)
27 property int milliseconds: 0
28
29 isOuter: true
30 width: units.gu(32)
31
32 StopwatchUtils {
33 id: stopwatchUtils
34 }
35
36 ClockCircle {
37 id: innerCircle
38
39 width: units.gu(23)
40 anchors.centerIn: parent
41 }
42
43 Column {
44 id: text
45
46 anchors.centerIn: parent
47
48 Label {
49 text: stopwatchUtils.millisToTimeString(milliseconds, false, true)
50 font.pixelSize: units.dp(34)
51 color: UbuntuColors.midAubergine
52 }
53
54 Label {
55 text: stopwatchUtils.millisToString(milliseconds)
56 font.pixelSize: units.dp(18)
57 color: UbuntuColors.midAubergine
58 anchors.horizontalCenter: parent.horizontalCenter
59 }
60 }
61}
062
=== added file 'app/stopwatch/StopwatchPage.qml'
--- app/stopwatch/StopwatchPage.qml 1970-01-01 00:00:00 +0000
+++ app/stopwatch/StopwatchPage.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,169 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21import Stopwatch.LapHistory 1.0
22
23Item {
24 id: _stopwatchPage
25 objectName: "stopwatchPage"
26
27 property date startTime: new Date()
28 property date snapshot: startTime
29 property bool running: false
30
31 property int timeDiff: snapshot - startTime
32 property int oldDiff: 0
33
34 property int totalTimeDiff: timeDiff + oldDiff
35
36 Component.onCompleted: {
37 console.log("[LOG]: Stopwatch Page Loaded")
38 }
39
40 function start() {
41 startTime = new Date()
42 snapshot = startTime
43 running = true
44 }
45
46 function stop() {
47 oldDiff += timeDiff
48 startTime = new Date()
49 snapshot = startTime
50 running = false
51 }
52
53 function update() {
54 snapshot = new Date()
55 }
56
57 function clear() {
58 oldDiff = 0
59 startTime = new Date()
60 snapshot = startTime
61 lapHistory.clear()
62 }
63
64 Timer {
65 id: refreshTimer
66 interval: 45
67 repeat: true
68 running: _stopwatchPage.running
69 onTriggered: {
70 _stopwatchPage.update()
71 }
72 }
73
74 StopwatchFace {
75 id: stopwatch
76 objectName: "stopwatch"
77
78 milliseconds: _stopwatchPage.totalTimeDiff
79
80 anchors {
81 top: parent.top
82 topMargin: units.gu(2)
83 horizontalCenter: parent.horizontalCenter
84 }
85 }
86
87 Row {
88 id: buttonRow
89
90 spacing: units.gu(2)
91 anchors {
92 top: stopwatch.bottom
93 topMargin: units.gu(3)
94 left: parent.left
95 right: parent.right
96 margins: units.gu(2)
97 }
98
99 Button {
100 id: stopButton
101 width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : parent.width
102 color: !_stopwatchPage.running ? UbuntuColors.green : UbuntuColors.red
103 text: _stopwatchPage.running ? i18n.tr("Stop") : (oldDiff === 0 ? i18n.tr("Start") : i18n.tr("Resume"))
104 onClicked: {
105 if (_stopwatchPage.running) {
106 _stopwatchPage.stop()
107 } else {
108 _stopwatchPage.start()
109 }
110 }
111 Behavior on width {
112 UbuntuNumberAnimation{
113 duration: UbuntuAnimation.BriskDuration
114 }
115 }
116 }
117
118 Button {
119 id: lapButton
120 text: _stopwatchPage.running ? i18n.tr("Lap") : i18n.tr("Clear")
121 width: oldDiff !== 0 || running ? (parent.width - parent.spacing) / 2 : 0
122 strokeColor: UbuntuColors.lightGrey
123 visible: oldDiff !== 0 || running
124 onClicked: {
125 if (_stopwatchPage.running) {
126 _stopwatchPage.update()
127 lapHistory.addLap(_stopwatchPage.totalTimeDiff)
128 } else {
129 _stopwatchPage.clear()
130 }
131 }
132 Behavior on width {
133 UbuntuNumberAnimation{
134 duration: UbuntuAnimation.BriskDuration
135 }
136 }
137 }
138 }
139
140 MouseArea {
141 anchors {
142 top: buttonRow.bottom
143 bottom: parent.bottom
144 left: parent.left
145 right: parent.right
146 topMargin: units.gu(1)
147 }
148
149 preventStealing: true
150
151 Loader {
152 id: lapListViewLoader
153 anchors.fill: parent
154 sourceComponent: !_stopwatchPage.running && _stopwatchPage.totalTimeDiff == 0 ? undefined : lapListViewComponent
155 }
156 }
157
158 LapHistory {
159 id: lapHistory
160 }
161
162 Component {
163 id: lapListViewComponent
164 LapListView {
165 id: lapListView
166 model: lapHistory
167 }
168 }
169}
0170
=== added file 'app/stopwatch/StopwatchUtils.qml'
--- app/stopwatch/StopwatchUtils.qml 1970-01-01 00:00:00 +0000
+++ app/stopwatch/StopwatchUtils.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21
22/*
23 Qt Object containing a collection of useful stopwatch functions
24*/
25QtObject {
26 id: stopwatchUtils
27
28 // Function to return only the milliseconds
29 function millisToString(millis) {
30 return addZeroPrefix(millis % 1000, 3)
31 }
32
33 // Function to break down time (milliseconds) to hours, minutes and seconds
34 function millisToTimeString(millis, showMilliseconds, showHours) {
35 var hours, minutes, seconds
36
37 // Break down total time (milliseconds) to hours, minutes and seconds
38 seconds = Math.floor(millis / 1000) % 60;
39 minutes = Math.floor(millis / 1000 / 60) % 60
40 hours = Math.floor(millis / 1000 / 60 / 60)
41
42 // Build the time string
43 var timeString = ""
44
45 if (showHours) {
46 timeString += addZeroPrefix(hours, 2) + ":"
47 }
48
49 timeString += addZeroPrefix(minutes, 2) + ":"
50 timeString += addZeroPrefix(seconds, 2)
51
52 if (showMilliseconds) {
53 timeString += "." + millisToString(millis)
54 }
55
56 return timeString
57 }
58
59 // Function to add zero prefix if necessary.
60 function addZeroPrefix (str, totalLength) {
61 return ("00000" + str).slice(-totalLength)
62 }
63
64 // Function to return lap time as a string
65 function lapTimeToString(millis) {
66 var hours = hours = Math.floor(millis / 1000 / 60 / 60)
67 if (hours > 0) {
68 return millisToTimeString(millis, false, true)
69 } else {
70 return millisToTimeString(millis, false, false)
71 }
72 }
73}
074
=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml 2015-07-15 22:31:52 +0000
+++ app/ubuntu-clock-app.qml 2015-08-20 20:43:05 +0000
@@ -20,7 +20,6 @@
20import DateTime 1.020import DateTime 1.0
21import U1db 1.0 as U1db21import U1db 1.0 as U1db
22import Ubuntu.Components 1.222import Ubuntu.Components 1.2
23import "clock"
24import "components"23import "components"
2524
26MainView {25MainView {
@@ -89,7 +88,7 @@
89 Reload the alarm model when the clock app gains focus to refresh88 Reload the alarm model when the clock app gains focus to refresh
90 the alarm page UI in the case of alarm notifications.89 the alarm page UI in the case of alarm notifications.
91 */90 */
92 if(applicationState && !clockPage.isColdStart) {91 if(applicationState && !mainPage.isColdStart) {
93 alarmModelLoader.source = ""92 alarmModelLoader.source = ""
94 alarmModelLoader.source = Qt.resolvedUrl("alarm/AlarmModelComponent.qml")93 alarmModelLoader.source = Qt.resolvedUrl("alarm/AlarmModelComponent.qml")
95 }94 }
@@ -98,10 +97,10 @@
98 PageStack {97 PageStack {
99 id: mainStack98 id: mainStack
10099
101 Component.onCompleted: push(clockPage)100 Component.onCompleted: push(mainPage)
102101
103 ClockPage {102 MainPage {
104 id: clockPage103 id: mainPage
105104
106 Loader {105 Loader {
107 id: alarmModelLoader106 id: alarmModelLoader
@@ -113,26 +112,26 @@
113 clock page title. This will then set the correct window title on112 clock page title. This will then set the correct window title on
114 the desktop.113 the desktop.
115114
116 title: "Clock"115 title: i18n.tr("Clock")
117 */116 */
118117
119 /*118 /*
120 Create a new Date() object and pass the date, month, year, hour, minute119 Create a new Date() object and pass the date, month, year, hour, minute
121 and second received from the DateTime plugin manually to ensure the120 and second received from the DateTime plugin manually to ensure the
122 timezone info is set correctly.121 timezone info is set correctly.
123122
124 Javascript Month is 0-11 while QDateTime month is 1-12. Hence the -1123 Javascript Month is 0-11 while QDateTime month is 1-12. Hence the -1
125 is required.124 is required.
126 */125 */
127126
128 /*127 /*
129 FIXME: When the upstream QT bug at128 #FIXME: When the upstream QT bug at
130 https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed it will be129 https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed it will be
131 possible to receive a datetime object directly instead of using this hack.130 possible to receive a datetime object directly instead of using this hack.
132 */131 */
133132
134 alarmModel: alarmModelLoader.item133 alarmModel: alarmModelLoader.item
135 bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready && alarmModelLoader.item.isReady134 bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready && alarmModelLoader.item.isReady && isClockPage
136 clockTime: new Date135 clockTime: new Date
137 (136 (
138 localTimeSource.localDateString.split(":")[0],137 localTimeSource.localDateString.split(":")[0],
139138
=== modified file 'app/worldclock/AddWorldCityButton.qml'
--- app/worldclock/AddWorldCityButton.qml 2015-08-14 05:34:49 +0000
+++ app/worldclock/AddWorldCityButton.qml 2015-08-20 20:43:05 +0000
@@ -24,7 +24,7 @@
24 id: addWorldCityButton24 id: addWorldCityButton
2525
26 width: parent.width26 width: parent.width
27 height: _addButton.height27 height: _addButton.height + units.gu(4)
2828
29 Label {29 Label {
30 text: i18n.tr("Add")30 text: i18n.tr("Add")
@@ -32,7 +32,7 @@
32 anchors {32 anchors {
33 right: _addButton.left33 right: _addButton.left
34 rightMargin: units.gu(1)34 rightMargin: units.gu(1)
35 verticalCenter: parent.verticalCenter35 verticalCenter: _addButton.verticalCenter
36 }36 }
37 }37 }
3838
@@ -41,7 +41,11 @@
4141
42 isOuter: true42 isOuter: true
43 width: units.gu(5)43 width: units.gu(5)
44 anchors.horizontalCenter: parent.horizontalCenter44 anchors {
45 horizontalCenter: parent.horizontalCenter
46 top: parent.top
47 topMargin: units.gu(1)
48 }
4549
46 ClockCircle {50 ClockCircle {
47 width: units.gu(3.5)51 width: units.gu(3.5)
@@ -63,7 +67,7 @@
63 anchors {67 anchors {
64 left: _addButton.right68 left: _addButton.right
65 leftMargin: units.gu(1)69 leftMargin: units.gu(1)
66 verticalCenter: parent.verticalCenter70 verticalCenter: _addButton.verticalCenter
67 }71 }
68 }72 }
6973
7074
=== modified file 'app/worldclock/UserWorldCityList.qml'
--- app/worldclock/UserWorldCityList.qml 2015-08-14 05:34:49 +0000
+++ app/worldclock/UserWorldCityList.qml 2015-08-20 20:43:05 +0000
@@ -21,11 +21,16 @@
21import U1db 1.0 as U1db21import U1db 1.0 as U1db
22import Ubuntu.Components 1.222import Ubuntu.Components 1.2
2323
24Column {24ListView {
25 id: worldCityColumn25 id: worldCityColumn
2626 objectName: "userWorldCityRepeater"
27 width: parent.width27
28 height: childrenRect.height28 clip: true
29 anchors.fill: parent
30
31 onFlickStarted: {
32 forceActiveFocus()
33 }
2934
30 // U1db Index to index all documents storing the world city details35 // U1db Index to index all documents storing the world city details
31 U1db.Index {36 U1db.Index {
@@ -51,93 +56,89 @@
51 results: worldCityQuery.results56 results: worldCityQuery.results
52 }57 }
5358
54 Repeater {59 property var _currentSwipedItem: null
55 id: userWorldCityRepeater60
56 objectName: "userWorldCityRepeater"61 function _updateSwipeState(item)
5762 {
58 property var _currentSwipedItem: null63 if (item.swipping) {
5964 return
60 function _updateSwipeState(item)65 }
61 {66
62 if (item.swipping) {67 if (item.swipeState !== "Normal") {
63 return68 if (worldCityColumn._currentSwipedItem !== item) {
64 }69 if (worldCityColumn._currentSwipedItem) {
6570 worldCityColumn._currentSwipedItem.resetSwipe()
66 if (item.swipeState !== "Normal") {71 }
67 if (userWorldCityRepeater._currentSwipedItem !== item) {72 worldCityColumn._currentSwipedItem = item
68 if (userWorldCityRepeater._currentSwipedItem) {73 }
69 userWorldCityRepeater._currentSwipedItem.resetSwipe()74 } else if (item.swipeState !== "Normal"
70 }75 && worldCityColumn._currentSwipedItem === item) {
71 userWorldCityRepeater._currentSwipedItem = item76 worldCityColumn._currentSwipedItem = null
72 }77 }
73 } else if (item.swipeState !== "Normal"78 }
74 && userWorldCityRepeater._currentSwipedItem === item) {79
75 userWorldCityRepeater._currentSwipedItem = null80 model: u1dbModel
76 }81
77 }82 delegate: UserWorldCityDelegate {
7883 id: userWorldCityDelegate
79 model: u1dbModel84 objectName: "userWorldCityItem" + index
8085
81 delegate: UserWorldCityDelegate {86 property var removalAnimation
82 id: userWorldCityDelegate87
83 objectName: "userWorldCityItem" + index88 function remove() {
8489 removalAnimation.start()
85 property var removalAnimation90 }
8691
87 function remove() {92 onSwippingChanged: {
88 removalAnimation.start()93 worldCityColumn._updateSwipeState(userWorldCityDelegate)
89 }94 }
9095
91 onSwippingChanged: {96 onSwipeStateChanged: {
92 userWorldCityRepeater._updateSwipeState(userWorldCityDelegate)97 worldCityColumn._updateSwipeState(userWorldCityDelegate)
93 }98 }
9499
95 onSwipeStateChanged: {100 leftSideAction: Action {
96 userWorldCityRepeater._updateSwipeState(userWorldCityDelegate)101 iconName: "delete"
97 }102 text: i18n.tr("Delete")
98103 onTriggered: {
99 leftSideAction: Action {104 userWorldCityDelegate.remove()
100 iconName: "delete"105 }
101 text: i18n.tr("Delete")106 }
102 onTriggered: {107
103 userWorldCityDelegate.remove()108 ListView.onRemove: ScriptAction {
104 }109 script: {
105 }110 if (worldCityColumn._currentSwipedItem
106111 === userWorldCityDelegate) {
107 ListView.onRemove: ScriptAction {112 worldCityColumn._currentSwipedItem = null
108 script: {113 }
109 if (userWorldCityRepeater._currentSwipedItem114 }
110 === userWorldCityDelegate) {115 }
111 userWorldCityRepeater._currentSwipedItem = null116
112 }117 removalAnimation: SequentialAnimation {
113 }118 alwaysRunToEnd: true
114 }119
115120 PropertyAction {
116 removalAnimation: SequentialAnimation {121 target: userWorldCityDelegate
117 alwaysRunToEnd: true122 property: "ListView.delayRemove"
118123 value: true
119 PropertyAction {124 }
120 target: userWorldCityDelegate125
121 property: "ListView.delayRemove"126 UbuntuNumberAnimation {
122 value: true127 target: userWorldCityDelegate
123 }128 property: "height"
124129 to: 0
125 UbuntuNumberAnimation {130 }
126 target: userWorldCityDelegate131
127 property: "height"132 PropertyAction {
128 to: 0133 target: userWorldCityDelegate
129 }134 property: "ListView.delayRemove"
130135 value: false
131 PropertyAction {136 }
132 target: userWorldCityDelegate137
133 property: "ListView.delayRemove"138 ScriptAction {
134 value: false139 script: clockDB.deleteDoc(worldCityQuery.documents[index])
135 }140 }
136141 }
137 ScriptAction {142 }
138 script: clockDB.deleteDoc(worldCityQuery.documents[index])143
139 }
140 }
141 }
142 }
143}144}
144145
=== modified file 'backend/CMakeLists.txt'
--- backend/CMakeLists.txt 2015-07-16 21:02:18 +0000
+++ backend/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -34,6 +34,12 @@
34 modules/GeoLocation/geolocation.cpp34 modules/GeoLocation/geolocation.cpp
35)35)
3636
37set(
38 stopwatchlaphistory_SRCS
39 modules/Stopwatch/LapHistory/backend.cpp
40 modules/Stopwatch/LapHistory/history.cpp
41)
42
37add_library(timezone MODULE43add_library(timezone MODULE
38 ${timezone_SRCS}44 ${timezone_SRCS}
39)45)
@@ -50,6 +56,11 @@
50 ${geolocation_SRCS}56 ${geolocation_SRCS}
51)57)
5258
59add_library(stopwatchlaphistory MODULE
60 ${stopwatchlaphistory_SRCS}
61)
62
63
53set_target_properties(timezone PROPERTIES64set_target_properties(timezone PROPERTIES
54 LIBRARY_OUTPUT_DIRECTORY Timezone65 LIBRARY_OUTPUT_DIRECTORY Timezone
55)66)
@@ -66,10 +77,15 @@
66 LIBRARY_OUTPUT_DIRECTORY GeoLocation77 LIBRARY_OUTPUT_DIRECTORY GeoLocation
67)78)
6879
80set_target_properties(stopwatchlaphistory PROPERTIES
81 LIBRARY_OUTPUT_DIRECTORY Stopwatch/LapHistory
82)
83
69qt5_use_modules(datetime Gui Qml Quick)84qt5_use_modules(datetime Gui Qml Quick)
70qt5_use_modules(timezone Gui Qml Quick)85qt5_use_modules(timezone Gui Qml Quick)
71qt5_use_modules(alarmsettings Gui Qml Quick DBus)86qt5_use_modules(alarmsettings Gui Qml Quick DBus)
72qt5_use_modules(geolocation Gui Qml Quick)87qt5_use_modules(geolocation Gui Qml Quick)
88qt5_use_modules(stopwatchlaphistory Qml)
7389
74# Copy qmldir file to build dir for running in QtCreator90# Copy qmldir file to build dir for running in QtCreator
75add_custom_target(timezone-qmldir ALL91add_custom_target(timezone-qmldir ALL
@@ -92,6 +108,12 @@
92 DEPENDS ${QMLFILES}108 DEPENDS ${QMLFILES}
93)109)
94110
111add_custom_target(stopwatchlaphistory-qmldir ALL
112 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/Stopwatch/LapHistory/qmldir ${CMAKE_CURRENT_BINARY_DIR}/Stopwatch/LapHistory
113 DEPENDS ${QMLFILES}
114)
115
116
95# Install plugin file117# Install plugin file
96install(TARGETS timezone DESTINATION ${MODULE_PATH}/Timezone/)118install(TARGETS timezone DESTINATION ${MODULE_PATH}/Timezone/)
97install(FILES modules/Timezone/qmldir DESTINATION ${MODULE_PATH}/Timezone/)119install(FILES modules/Timezone/qmldir DESTINATION ${MODULE_PATH}/Timezone/)
@@ -104,3 +126,6 @@
104126
105install(TARGETS geolocation DESTINATION ${MODULE_PATH}/GeoLocation/)127install(TARGETS geolocation DESTINATION ${MODULE_PATH}/GeoLocation/)
106install(FILES modules/GeoLocation/qmldir DESTINATION ${MODULE_PATH}/GeoLocation/)128install(FILES modules/GeoLocation/qmldir DESTINATION ${MODULE_PATH}/GeoLocation/)
129
130install(TARGETS stopwatchlaphistory DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/)
131install(FILES modules/Stopwatch/LapHistory/qmldir DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/)
107132
=== added directory 'backend/modules/Stopwatch'
=== added directory 'backend/modules/Stopwatch/LapHistory'
=== added file 'backend/modules/Stopwatch/LapHistory/backend.cpp'
--- backend/modules/Stopwatch/LapHistory/backend.cpp 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/LapHistory/backend.cpp 2015-08-20 20:43:05 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <QtQml>
20#include <QtQml/QQmlContext>
21#include "backend.h"
22#include "history.h"
23
24void BackendPlugin::registerTypes(const char *uri)
25{
26 Q_ASSERT(uri == QLatin1String("Stopwatch.LapHistory"));
27
28 qmlRegisterType<LapHistory>(uri, 1, 0, "LapHistory");
29}
30
31void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
32{
33 QQmlExtensionPlugin::initializeEngine(engine, uri);
34}
035
=== added file 'backend/modules/Stopwatch/LapHistory/backend.h'
--- backend/modules/Stopwatch/LapHistory/backend.h 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/LapHistory/backend.h 2015-08-20 20:43:05 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef BACKEND_PLUGIN_H
20#define BACKEND_PLUGIN_H
21
22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlExtensionPlugin>
24
25class BackendPlugin : public QQmlExtensionPlugin
26{
27 Q_OBJECT
28 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29
30public:
31 void registerTypes(const char *uri);
32 void initializeEngine(QQmlEngine *engine, const char *uri);
33};
34#endif // BACKEND_PLUGIN_H
35
036
=== added file 'backend/modules/Stopwatch/LapHistory/history.cpp'
--- backend/modules/Stopwatch/LapHistory/history.cpp 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/LapHistory/history.cpp 2015-08-20 20:43:05 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "history.h"
20
21#include <QStandardPaths>
22#include <QDebug>
23
24LapHistory::LapHistory(QObject *parent) :
25 QAbstractListModel(parent),
26 /*
27 #FIXME: Change QStandardPaths::ConfigLocation to QStandardPaths::AppConfigLocation
28 when Ubuntu Touch moves over to Qt 5.5. AppConfigLocation will directly return
29 /home/phablet/.config/com.ubuntu.clock path.
30 */
31 m_settings(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/com.ubuntu.clock/com.ubuntu.clock.conf", QSettings::IniFormat)
32{
33 qDebug() << "[LOG] Loading laps from " << m_settings.fileName();
34}
35
36int LapHistory::rowCount(const QModelIndex &parent) const
37{
38 /*
39 QT's models also handle tables and tree views, so the index is not just a
40 integer but consists of a parent, row and a column. Since we using a simple
41 list model, let's ignore the parent. Q_UNUSED(parent) gets rid of the
42 compiler warning about the unused variable.
43 */
44 Q_UNUSED(parent)
45
46 return m_settings.value("Stopwatch/laps").toList().count();
47}
48
49QVariant LapHistory::data(const QModelIndex &index, int role) const
50{
51 switch (role) {
52 case RoleTotalTime:
53 return m_settings.value("Stopwatch/laps").toList().at(index.row());
54 case RoleDiffToPrevious: {
55 int previous = 0;
56 if(index.row() != m_settings.value("Stopwatch/laps").toList().count() - 1)
57 {
58 previous = data(this->index(index.row() + 1), RoleTotalTime).toInt();
59 }
60 return m_settings.value("Stopwatch/laps").toList().at(index.row()).toInt() - previous;
61 }
62 }
63 return QVariant();
64}
65
66QHash<int, QByteArray> LapHistory::roleNames() const
67{
68 QHash< int, QByteArray> roles;
69 roles.insert(RoleTotalTime, "totaltime");
70 roles.insert(RoleDiffToPrevious, "laptime");
71 return roles;
72}
73
74void LapHistory::addLap(int timeDiff)
75{
76 QVariantList laps = m_settings.value("Stopwatch/laps").toList();
77 beginInsertRows(QModelIndex(), 0, 0);
78 laps.prepend(timeDiff);
79 m_settings.setValue("Stopwatch/laps", laps);
80 endInsertRows();
81}
82
83void LapHistory::removeLap(int lapIndex)
84{
85 QVariantList laps = m_settings.value("Stopwatch/laps").toList();
86 beginRemoveRows(QModelIndex(), lapIndex, lapIndex);
87 laps.removeAt(lapIndex);
88 m_settings.setValue("Stopwatch/laps", laps);
89 endRemoveRows();
90}
91
92void LapHistory::clear()
93{
94 beginResetModel();
95 m_settings.setValue("Stopwatch/laps", QVariantList());
96 endResetModel();
97}
098
=== added file 'backend/modules/Stopwatch/LapHistory/history.h'
--- backend/modules/Stopwatch/LapHistory/history.h 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/LapHistory/history.h 2015-08-20 20:43:05 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef HISTORY_H
20#define HISTORY_H
21
22#include <QAbstractListModel>
23#include <QSettings>
24
25class LapHistory : public QAbstractListModel
26{
27 Q_OBJECT
28
29public:
30 enum Role {
31 RoleTotalTime,
32 RoleDiffToPrevious
33 };
34
35 explicit LapHistory(QObject *parent = 0);
36
37 /*
38 Let's override the pure virtual functions (the ones marked as
39 "virtual" and have "= 0" in the end.
40 */
41 int rowCount(const QModelIndex &parent) const;
42 QVariant data(const QModelIndex &index, int role) const;
43
44 /*
45 As QML can't really deal with the Roles enum above, we need a mapping
46 between the enum and strings
47 */
48 QHash<int, QByteArray> roleNames() const override;
49
50public slots:
51 // Function to add a stopwatch lap
52 void addLap(int timeDiff);
53
54 // Function to remove a stopwatch lap
55 void removeLap(int lapIndex);
56
57 // Function to clear all stopwatch laps
58 void clear();
59
60private:
61 QSettings m_settings;
62};
63
64#endif // HISTORY_H
065
=== added file 'backend/modules/Stopwatch/LapHistory/qmldir'
--- backend/modules/Stopwatch/LapHistory/qmldir 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/LapHistory/qmldir 2015-08-20 20:43:05 +0000
@@ -0,0 +1,2 @@
1module Stopwatch.LapHistory
2plugin stopwatchlaphistory
03
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-16 20:53:03 +0000
+++ debian/changelog 2015-08-20 20:43:05 +0000
@@ -7,9 +7,11 @@
7 * Fix default alarm time issue (LP: #1484926)7 * Fix default alarm time issue (LP: #1484926)
8 * Translate city and country names after language switch (LP: #1477492)8 * Translate city and country names after language switch (LP: #1477492)
9 * Fix issue when unable to add city/country with apostrophes (LP: #1473074) 9 * Fix issue when unable to add city/country with apostrophes (LP: #1473074)
10 * Keep running stopwatch even when the clock or phone is turned off (LP: #1484942)
1011
11 [Nekhelesh Ramananthan]12 [Nekhelesh Ramananthan]
12 * Increase the height of times in the alarm screen (LP: #1365428)13 * Increase the height of times in the alarm screen (LP: #1365428)
14 * Implement Stopwatch feature (LP: 1437313)
13 * Fixed the confusing behavior of the confirmation button (LP: #1408015)15 * Fixed the confusing behavior of the confirmation button (LP: #1408015)
14 * Added README.mergeproposal checklist to help with the review process.16 * Added README.mergeproposal checklist to help with the review process.
15 * Fix alarm interval information being inconsistent (LP: #1466000)17 * Fix alarm interval information being inconsistent (LP: #1466000)
1618
=== modified file 'debian/control'
--- debian/control 2015-07-27 20:52:03 +0000
+++ debian/control 2015-08-20 20:43:05 +0000
@@ -10,6 +10,8 @@
10 ubuntu-touch-sounds,10 ubuntu-touch-sounds,
11 suru-icon-theme | ubuntu-mobile-icons,11 suru-icon-theme | ubuntu-mobile-icons,
12 qml-module-qttest,12 qml-module-qttest,
13 qml-module-qtsysteminfo,
14 qml-module-qt-labs-settings,
13 qtdeclarative5-u1db1.0,15 qtdeclarative5-u1db1.0,
14 qtdeclarative5-qtmultimedia-plugin,16 qtdeclarative5-qtmultimedia-plugin,
15 qtdeclarative5-qtpositioning-plugin,17 qtdeclarative5-qtpositioning-plugin,
1618
=== modified file 'po/com.ubuntu.clock.pot'
--- po/com.ubuntu.clock.pot 2015-08-16 20:56:27 +0000
+++ po/com.ubuntu.clock.pot 2015-08-20 20:43:05 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: \n"9"Project-Id-Version: \n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2015-08-16 22:55+0200\n"11"POT-Creation-Date: 2015-08-20 22:42+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,13 +18,17 @@
18"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
2020
21#: ../app/MainPage.qml:47 ../app/alarm/AlarmUtils.qml:55
22msgid "No active alarms"
23msgstr ""
24
21#: ../app/alarm/AlarmLabel.qml:33 ../app/alarm/AlarmLabel.qml:7125#: ../app/alarm/AlarmLabel.qml:33 ../app/alarm/AlarmLabel.qml:71
22#: ../app/alarm/EditAlarmPage.qml:29026#: ../app/alarm/EditAlarmPage.qml:290
23msgid "Label"27msgid "Label"
24msgstr ""28msgstr ""
2529
26#: ../app/alarm/AlarmList.qml:61 ../app/alarm/AlarmPage.qml:9930#: ../app/alarm/AlarmList.qml:61 ../app/alarm/AlarmPage.qml:99
27#: ../app/worldclock/UserWorldCityList.qml:10131#: ../app/worldclock/UserWorldCityList.qml:102
28msgid "Delete"32msgid "Delete"
29msgstr ""33msgstr ""
3034
@@ -120,10 +124,6 @@
120msgid "Daily"124msgid "Daily"
121msgstr ""125msgstr ""
122126
123#: ../app/alarm/AlarmUtils.qml:55
124msgid "No active alarms"
125msgstr ""
126
127#: ../app/alarm/AlarmUtils.qml:72127#: ../app/alarm/AlarmUtils.qml:72
128#, qt-format128#, qt-format
129msgid "Next Alarm %1"129msgid "Next Alarm %1"
@@ -160,15 +160,45 @@
160msgid "Delete alarm"160msgid "Delete alarm"
161msgstr ""161msgstr ""
162162
163#: ../app/clock/ClockPage.qml:284163#: ../app/clock/ClockPage.qml:225
164msgid "Retrieving location..."164msgid "Retrieving location..."
165msgstr ""165msgstr ""
166166
167#. TRANSLATORS: This refers to the stopwatch lap and is shown as a header where space is limited. Constrain
168#. translation length to a few characters.
169#: ../app/stopwatch/LapListView.qml:45 ../app/stopwatch/StopwatchPage.qml:120
170msgid "Lap"
171msgstr ""
172
173#: ../app/stopwatch/LapListView.qml:55
174msgid "Lap Time"
175msgstr ""
176
177#: ../app/stopwatch/LapListView.qml:63
178msgid "Total Time"
179msgstr ""
180
181#: ../app/stopwatch/StopwatchPage.qml:103
182msgid "Stop"
183msgstr ""
184
185#: ../app/stopwatch/StopwatchPage.qml:103
186msgid "Start"
187msgstr ""
188
189#: ../app/stopwatch/StopwatchPage.qml:103
190msgid "Resume"
191msgstr ""
192
193#: ../app/stopwatch/StopwatchPage.qml:120
194msgid "Clear"
195msgstr ""
196
167#: ../app/worldclock/AddWorldCityButton.qml:30197#: ../app/worldclock/AddWorldCityButton.qml:30
168msgid "Add"198msgid "Add"
169msgstr ""199msgstr ""
170200
171#: ../app/worldclock/AddWorldCityButton.qml:61201#: ../app/worldclock/AddWorldCityButton.qml:65
172#: ../app/worldclock/WorldCityList.qml:63202#: ../app/worldclock/WorldCityList.qml:63
173msgid "City"203msgid "City"
174msgstr ""204msgstr ""
175205
=== modified file 'tests/unit/CMakeLists.txt'
--- tests/unit/CMakeLists.txt 2015-07-14 20:49:37 +0000
+++ tests/unit/CMakeLists.txt 2015-08-20 20:43:05 +0000
@@ -27,6 +27,7 @@
27 declare_qml_test("AlarmSound" tst_alarmSound.qml)27 declare_qml_test("AlarmSound" tst_alarmSound.qml)
28 declare_qml_test("AlarmUtils" tst_alarmUtils.qml)28 declare_qml_test("AlarmUtils" tst_alarmUtils.qml)
29 declare_qml_test("WorldClock" tst_worldClock.qml)29 declare_qml_test("WorldClock" tst_worldClock.qml)
30 declare_qml_test("StopwatchUtils" tst_stopwatchUtils.qml)
30else()31else()
31 if (NOT QMLTESTRUNNER_BIN)32 if (NOT QMLTESTRUNNER_BIN)
32 message(WARNING "Qml tests disabled: qmltestrunner not found")33 message(WARNING "Qml tests disabled: qmltestrunner not found")
@@ -42,6 +43,7 @@
42 tst_alarmSound.qml43 tst_alarmSound.qml
43 tst_alarmUtils.qml44 tst_alarmUtils.qml
44 tst_worldClock.qml45 tst_worldClock.qml
46 tst_stopwatchUtils.qml
45)47)
46add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})48add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
4749
4850
=== modified file 'tests/unit/MockClockApp.qml'
--- tests/unit/MockClockApp.qml 2015-08-14 05:34:49 +0000
+++ tests/unit/MockClockApp.qml 2015-08-20 20:43:05 +0000
@@ -20,8 +20,9 @@
20import DateTime 1.020import DateTime 1.0
21import U1db 1.0 as U1db21import U1db 1.0 as U1db
22import Ubuntu.Components 1.222import Ubuntu.Components 1.2
23import "../../app"
24import "../../app/components"
23import "../../app/clock"25import "../../app/clock"
24import "../../app/components"
2526
26/*27/*
27 This file is meant to create a fake but fully fleshed clock app with its28 This file is meant to create a fake but fully fleshed clock app with its
@@ -69,10 +70,10 @@
69 id: mainStack70 id: mainStack
70 objectName: "pageStack"71 objectName: "pageStack"
7172
72 Component.onCompleted: push(clockPage)73 Component.onCompleted: push(mainPage)
7374
74 ClockPage {75 MainPage {
75 id: clockPage76 id: mainPage
7677
77 Loader {78 Loader {
78 id: alarmModelLoader79 id: alarmModelLoader
@@ -80,7 +81,7 @@
80 }81 }
8182
82 alarmModel: alarmModelLoader.item83 alarmModel: alarmModelLoader.item
83 bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready84 bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready && alarmModelLoader.item.isReady && isClockPage
84 clockTime: new Date85 clockTime: new Date
85 (86 (
86 localTimeSource.localDateString.split(":")[0],87 localTimeSource.localDateString.split(":")[0],
8788
=== added file 'tests/unit/tst_stopwatchUtils.qml'
--- tests/unit/tst_stopwatchUtils.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_stopwatchUtils.qml 2015-08-20 20:43:05 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Components 1.2
22import "../../app/stopwatch"
23
24TestCase {
25 id: stopwatchUtilsTest
26 name: "StopwatchUtilsLibrary"
27
28 StopwatchUtils {
29 id: stopwatchUtils
30 }
31
32 /*
33 This test checks if the milliseconds is returned correctly in the format
34 mmm (string length 3)
35 */
36 function test_returnMillisecond() {
37 var result
38 result = stopwatchUtils.millisToString(400)
39 compare(result, "400", "Milliseconds not properly converted to the format required")
40 result = stopwatchUtils.millisToString(4)
41 compare(result, "004", "Milliseconds not properly converted to the format required")
42 }
43
44 /*
45 This test checks if the time (in milliseconds) to converted to hh:mm:ss
46 correctly.
47 */
48 function test_convertTimeInMillisecondsToString() {
49 var timeInMilliseconds = 1123000
50 var result = stopwatchUtils.millisToTimeString(timeInMilliseconds, false, true)
51 compare(result, "00:18:43", "Time not properly converted from milliseconds to hh:mm:ss")
52 }
53
54 /*
55 This test checks if the zero prefix is added correctly to ensure that a
56 string is always of the specified string length.
57 */
58 function test_zeroPrefixAddedCorrectly() {
59 var str = "32", result
60 result = stopwatchUtils.addZeroPrefix(str, 2)
61 compare(result, "32", "Zero prefix not added correctly")
62 result = stopwatchUtils.addZeroPrefix(str, 3)
63 compare(result, "032", "Zero prefix not added correctly")
64 result = stopwatchUtils.addZeroPrefix(str, 4)
65 compare(result, "0032", "Zero prefix not added correctly")
66 }
67
68 /*
69 This test checks if the lap time correctly shows or hides the hours
70 as requires and returns it as a string.
71 */
72 function test_lapTimeIncludesHoursCorrectly() {
73 var result
74 result = stopwatchUtils.lapTimeToString(1123000)
75 compare(result, "18:43", "Lap time shows hours despite it not being greater than 0")
76 result = stopwatchUtils.lapTimeToString(8323000)
77 compare(result, "02:18:43", "Lap time not showing hours despite it being greater than 0")
78 }
79}
080
=== modified file 'tests/unit/tst_worldClock.qml'
--- tests/unit/tst_worldClock.qml 2015-08-12 16:57:29 +0000
+++ tests/unit/tst_worldClock.qml 2015-08-20 20:43:05 +0000
@@ -16,7 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */17 */
1818
19import QtQuick 2.019import QtQuick 2.4
20import QtTest 1.020import QtTest 1.0
21import Ubuntu.Test 1.021import Ubuntu.Test 1.0
22import Ubuntu.Components 1.222import Ubuntu.Components 1.2
2323
=== modified file 'ubuntu-clock-app.json'
--- ubuntu-clock-app.json 2015-05-27 16:03:23 +0000
+++ ubuntu-clock-app.json 2015-08-20 20:43:05 +0000
@@ -3,7 +3,8 @@
3 "audio",3 "audio",
4 "calendar",4 "calendar",
5 "networking",5 "networking",
6 "location"6 "location",
7 "keep-display-on"
7 ],8 ],
8 "policy_version": 1.39 "policy_version": 1.3
9}
10\ No newline at end of file10\ No newline at end of file
11}

Subscribers

People subscribed via source and target branches

to all changes: