2 import Sailfish.Silica 1.0
3 import harbour.pedalo.settings 1.0
7 property bool update: status === Cover.Active && currentStatus.cycling
10 stopwatch.updateseconds()
11 stopwatchtrigger.restart()
16 property int seconds: 0
17 property int fast: seconds < 60 * 10
18 property bool update: root.update
22 interval: stopwatch.fast ? 200 : 5000
25 triggeredOnStart: true
27 stopwatch.updateseconds()
31 function updateseconds() {
32 stopwatch.seconds = (new Date().getTime() - currentStatus.startTime) / 1000
39 width: Theme.coverSizeLarge.width
40 height: Theme.coverSizeLarge.height
41 property real xScale: root.width / contents.width
44 xScale: contents.xScale
45 yScale: root.height / contents.height
55 margins: Theme.paddingLarge
65 topMargin: Theme.paddingMedium
66 leftMargin: Theme.paddingLarge
67 rightMargin: Theme.paddingLarge
70 textVisible: root.update
75 if (stopwatch.seconds < 60) {
76 return qsTr("%n seconds", "", stopwatch.seconds)
77 } else if (stopwatch.seconds < 60*60) {
78 return qsTr("%1 minutes").arg(Math.floor(stopwatch.seconds/60))
80 var minutes = Math.floor(stopwatch.seconds/60)
81 var hours = Math.floor(minutes/60)
82 minutes = minutes % 60
83 return qsTrId("%1h %2min").arg(hours).arg(minutes)
93 iconSource: currentStatus.cycling ? Settings.getImageUrl("icon-cover-journey-finish") : Settings.getImageUrl("icon-cover-journey-start")
95 if (currentStatus.cycling) {
97 app.showMainPage(PageStackAction.Immediate)
99 var dialog = pageStack.push(Qt.resolvedUrl("../pages/JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
101 dialog.accepted.connect(function() {
102 currentStatus.cycling = false
106 currentStatus.startJourney()