From: David Llewellyn-Jones Date: Sat, 14 Jul 2018 19:40:29 +0000 (+0100) Subject: Add journey info page X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=commitdiff_plain;h=41bb8de4779e59d272f753bc53033bd467bff811 Add journey info page When items are clicked in the journey list, default behaviour is now to show an info page that can't be edited. --- diff --git a/harbour-pedalo.pro b/harbour-pedalo.pro index 647d3bb..e50d930 100644 --- a/harbour-pedalo.pro +++ b/harbour-pedalo.pro @@ -46,7 +46,8 @@ DISTFILES += qml/harbour-pedalo.qml \ qml/pages/About.qml \ qml/pages/DurationEditDialog.qml \ qml/components/InfoRow.qml \ - qml/pages/JourneyEdit.qml + qml/pages/JourneyEdit.qml \ + qml/pages/JourneyInfo.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 diff --git a/qml/pages/JourneyInfo.qml b/qml/pages/JourneyInfo.qml new file mode 100644 index 0000000..6b0377d --- /dev/null +++ b/qml/pages/JourneyInfo.qml @@ -0,0 +1,107 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Page { + id: journeyInfoPage + property string title: "Journey info" + property var start: new Date() + property int duration: 0 + property int overtook: -1 + property int overtakenby: -1 + property int index: -1 + + onDurationChanged: { + var structured = new Date(0, 0, 0, 0, parseInt(duration / 60)) + durationTime.value = Qt.formatTime(structured, 'hh:mm') + endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes()) + } + + onStartChanged: { + startDate.value = Qt.formatDate(start, 'd MMM yyyy') + startTime.value = Qt.formatTime(start, 'hh:mm') + + var structured = new Date(0, 0, 0, 0, parseInt(duration / 60)) + endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes()) + } + + // The effective value will be restricted by ApplicationWindow.allowedOrientations + allowedOrientations: Orientation.All + + SilicaFlickable { + id: journeyEditView + anchors.fill: parent + contentHeight: journeyEditColumn.implicitHeight + + VerticalScrollDecorator {} + + Column { + id: journeyEditColumn + spacing: Theme.paddingMedium + width: parent.width + + PageHeader { + title: journeyInfoPage.title + } + + ValueButton { + id: startDate + label: "Date" + value: Qt.formatDate(start, 'd MMM yyyy') + width: parent.width + enabled: false + } + + ValueButton { + id: startTime + label: qsTr("Start time") + value: Qt.formatTime(start, 'hh:mm') + width: parent.width + enabled: false + } + + ValueButton { + id: endTime + property date time: new Date() + label: qsTr("End time") + value: Qt.formatTime(time, 'hh:mm') + width: parent.width + enabled: false + onTimeChanged: { + value = Qt.formatTime(time, 'hh:mm') + } + } + + ValueButton { + id: durationTime + label: qsTr("Duration") + value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm') + width: parent.width + enabled: false + } + + TextField { + id: faster + width: parent.width + inputMethodHints: Qt.ImhDigitsOnly + label: qsTr("Cycles which you overtook") + placeholderText: label + text: overtook >= 0 ? "" + overtook : "" + horizontalAlignment: TextInput.AlignLeft + EnterKey.iconSource: "image://theme/icon-m-enter-next" + enabled: false + } + + TextField { + id: slower + width: parent.width + inputMethodHints: Qt.ImhDigitsOnly + label: qsTr("Cycles which overtook you") + placeholderText: label + text: overtakenby >= 0 ? "" + overtakenby : "" + horizontalAlignment: TextInput.AlignLeft + EnterKey.iconSource: "image://theme/icon-m-enter-next" + enabled: false + } + } + } +} diff --git a/qml/pages/JourneyList.qml b/qml/pages/JourneyList.qml index 8ecc9b8..1708d20 100644 --- a/qml/pages/JourneyList.qml +++ b/qml/pages/JourneyList.qml @@ -39,7 +39,7 @@ Page { color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor } } - onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) + onClicked: pageStack.push(Qt.resolvedUrl("JourneyInfo.qml"), {title: "Journey info", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) Component { id: journeyMenuComponent diff --git a/translations/harbour-pedalo-de.ts b/translations/harbour-pedalo-de.ts index 3ea663f..9bff26f 100644 --- a/translations/harbour-pedalo-de.ts +++ b/translations/harbour-pedalo-de.ts @@ -59,6 +59,29 @@ + + JourneyInfo + + Start time + + + + End time + + + + Duration + + + + Cycles which you overtook + + + + Cycles which overtook you + + + JourneyList diff --git a/translations/harbour-pedalo.ts b/translations/harbour-pedalo.ts index 42cc67b..79a127d 100644 --- a/translations/harbour-pedalo.ts +++ b/translations/harbour-pedalo.ts @@ -59,6 +59,29 @@ + + JourneyInfo + + Start time + + + + End time + + + + Duration + + + + Cycles which you overtook + + + + Cycles which overtook you + + + JourneyList