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 _maximumItems: height >= Theme.coverSizeLarge.height
18 : height >= Theme.coverSizeSmall.height ? 1 : 0
23 property int seconds: 0
24 property int fast: seconds < 60 * 10
25 property bool update: root.update
29 interval: stopwatch.fast ? 200 : 5000
32 triggeredOnStart: true
34 stopwatch.updateseconds()
38 function updateseconds() {
39 stopwatch.seconds = (new Date().getTime() - currentStatus.startTime) / 1000
46 width: Theme.coverSizeLarge.width
47 height: Theme.coverSizeLarge.height
48 property real xScale: root.width / contents.width
51 xScale: contents.xScale
52 yScale: root.height / contents.height
62 margins: Theme.paddingLarge
72 topMargin: Theme.paddingMedium
73 leftMargin: Theme.paddingLarge
74 rightMargin: Theme.paddingLarge
77 titleVisible: ((!root.update) && _maximumItems > 0) || (_maximumItems > 1)
78 textVisible: (root.update && (_maximumItems > 0))
83 if (stopwatch.seconds < 60) {
84 return qsTr("%n seconds", "", stopwatch.seconds)
85 } else if (stopwatch.seconds < 60*60) {
86 return qsTr("%1 minutes").arg(Math.floor(stopwatch.seconds/60))
88 var minutes = Math.floor(stopwatch.seconds/60)
89 var hours = Math.floor(minutes/60)
90 minutes = minutes % 60
91 return qsTrId("%1h %2min").arg(hours).arg(minutes)
101 iconSource: currentStatus.cycling ? Settings.getImageUrl("icon-cover-journey-finish") : Settings.getImageUrl("icon-cover-journey-start")
103 if (currentStatus.cycling) {
105 app.showMainPage(PageStackAction.Immediate)
107 var dialog = pageStack.push(Qt.resolvedUrl("../pages/JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
109 dialog.accepted.connect(function() {
110 currentStatus.cycling = false
114 currentStatus.startJourney()