From: David Llewellyn-Jones Date: Sat, 14 Jul 2018 19:13:44 +0000 (+0100) Subject: Rename AddJourney to JourneyEdit X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=commitdiff_plain;h=cc1952786f991bf5d584bbbffb554b0c40cec401 Rename AddJourney to JourneyEdit This fits better with the overall naming scheme and makes sense given the dialog is used more often for editing than for adding. --- diff --git a/harbour-pedalo.pro b/harbour-pedalo.pro index 1ec2ced..647d3bb 100644 --- a/harbour-pedalo.pro +++ b/harbour-pedalo.pro @@ -41,12 +41,12 @@ DISTFILES += qml/harbour-pedalo.qml \ translations/*.ts \ harbour-pedalo.desktop \ qml/pages/MainPage.qml \ - qml/pages/AddJourney.qml \ qml/pages/Stats.qml \ qml/pages/JourneyList.qml \ qml/pages/About.qml \ qml/pages/DurationEditDialog.qml \ - qml/components/InfoRow.qml + qml/components/InfoRow.qml \ + qml/pages/JourneyEdit.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 diff --git a/qml/pages/AddJourney.qml b/qml/pages/AddJourney.qml deleted file mode 100644 index a9124ae..0000000 --- a/qml/pages/AddJourney.qml +++ /dev/null @@ -1,141 +0,0 @@ -import QtQuick 2.0 -import Sailfish.Silica 1.0 - -Dialog { - id: addJourneyDialog - canAccept: true - property string title: "Add journey" - 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: addJourneyView - anchors.fill: parent - contentHeight: addJourneyColumn.implicitHeight - - VerticalScrollDecorator {} - - Column { - id: addJourneyColumn - spacing: Theme.paddingMedium - width: parent.width - - DialogHeader { - title: addJourneyDialog.title - } - - ValueButton { - id: startDate - label: "Date" - value: Qt.formatDate(start, 'd MMM yyyy') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", { date: start }) - dialog.accepted.connect(function() { - start = new Date(dialog.year, dialog.month - 1, dialog.day, start.getHours(), start.getMinutes()) - }) - } - } - - ValueButton { - id: startTime - label: qsTr("Start time") - value: Qt.formatTime(start, 'hh:mm') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: start.getHours(), minute: start.getMinutes()}) - dialog.accepted.connect(function() { - start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), dialog.hour, dialog.minute) - }) - } - } - - ValueButton { - id: endTime - property date time: new Date() - label: qsTr("End time") - value: Qt.formatTime(time, 'hh:mm') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()}) - dialog.accepted.connect(function() { - // We have to hack around the fact that % in Javascript is 'remainder' and not 'mod' (hence will happpily return negative numbers) - duration = ((((((dialog.hour - start.getHours()) * 60) + (dialog.minute - start.getMinutes())) * 60) % 86400) + 86400) % 86400 - // Updating the duration will automatically trigger the end time to be udpated - }) - } - 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 - onClicked: { - var dialog = pageStack.push("DurationEditDialog.qml", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60}) - dialog.accepted.connect(function() { - duration = ((dialog.hour * 60) + dialog.minute) * 60 - }) - } - } - - 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" - EnterKey.onClicked: slower.focus = true - } - - 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" - EnterKey.onClicked: addJourneyDialog.accept() - } - } - } - - onAccepted: { - var overtook = parseInt(faster.text) - var overtakenby = parseInt(slower.text) - if (index < 0) { - journeymodel.addJourney(start, duration, overtook, overtakenby) - } - else { - journeymodel.editJourney(index, start, duration, overtook, overtakenby) - } - } -} diff --git a/qml/pages/JourneyEdit.qml b/qml/pages/JourneyEdit.qml new file mode 100644 index 0000000..1f61b39 --- /dev/null +++ b/qml/pages/JourneyEdit.qml @@ -0,0 +1,141 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Dialog { + id: journeyEditDialog + canAccept: true + property string title: "Add journey" + 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 + + DialogHeader { + title: journeyEditDialog.title + } + + ValueButton { + id: startDate + label: "Date" + value: Qt.formatDate(start, 'd MMM yyyy') + width: parent.width + onClicked: { + var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", { date: start }) + dialog.accepted.connect(function() { + start = new Date(dialog.year, dialog.month - 1, dialog.day, start.getHours(), start.getMinutes()) + }) + } + } + + ValueButton { + id: startTime + label: qsTr("Start time") + value: Qt.formatTime(start, 'hh:mm') + width: parent.width + onClicked: { + var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: start.getHours(), minute: start.getMinutes()}) + dialog.accepted.connect(function() { + start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), dialog.hour, dialog.minute) + }) + } + } + + ValueButton { + id: endTime + property date time: new Date() + label: qsTr("End time") + value: Qt.formatTime(time, 'hh:mm') + width: parent.width + onClicked: { + var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()}) + dialog.accepted.connect(function() { + // We have to hack around the fact that % in Javascript is 'remainder' and not 'mod' (hence will happpily return negative numbers) + duration = ((((((dialog.hour - start.getHours()) * 60) + (dialog.minute - start.getMinutes())) * 60) % 86400) + 86400) % 86400 + // Updating the duration will automatically trigger the end time to be udpated + }) + } + 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 + onClicked: { + var dialog = pageStack.push("DurationEditDialog.qml", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60}) + dialog.accepted.connect(function() { + duration = ((dialog.hour * 60) + dialog.minute) * 60 + }) + } + } + + 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" + EnterKey.onClicked: slower.focus = true + } + + 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" + EnterKey.onClicked: journeyEditDialog.accept() + } + } + } + + onAccepted: { + var overtook = parseInt(faster.text) + var overtakenby = parseInt(slower.text) + if (index < 0) { + journeymodel.addJourney(start, duration, overtook, overtakenby) + } + else { + journeymodel.editJourney(index, start, duration, overtook, overtakenby) + } + } +} diff --git a/qml/pages/JourneyList.qml b/qml/pages/JourneyList.qml index 8831f40..8ecc9b8 100644 --- a/qml/pages/JourneyList.qml +++ b/qml/pages/JourneyList.qml @@ -39,14 +39,14 @@ Page { color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor } } - onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) + onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) Component { id: journeyMenuComponent ContextMenu { MenuItem { text: qsTr("Edit") - onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) + onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby}) } MenuItem { text: qsTr("Delete") diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 03d86a2..0de4dc4 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -42,7 +42,7 @@ Page { text: currentStatus.cycling ? qsTr("Finish") : qsTr("Start a journey") onClicked: { if (currentStatus.cycling) { - var dialog = pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()}) + var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()}) dialog.accepted.connect(function() { currentStatus.cycling = false @@ -61,7 +61,7 @@ Page { Button { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Enter journey") - onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml")) + onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml")) } SectionHeader { diff --git a/translations/harbour-pedalo-de.ts b/translations/harbour-pedalo-de.ts index bb23457..3ea663f 100644 --- a/translations/harbour-pedalo-de.ts +++ b/translations/harbour-pedalo-de.ts @@ -13,49 +13,49 @@ - AddJourney + CoverPage - Start time - + My Cover + Mein Cover + + + DurationEditDialog - End time + LTR - Duration + h + "Hour abbrevation. Should be short form if possible." - Cycles which you overtook + min + "Minute abbrevation. Should be short form if possible." + + + JourneyEdit - Cycles which overtook you + Start time - - - CoverPage - My Cover - Mein Cover + End time + - - - DurationEditDialog - LTR + Duration - h - "Hour abbrevation. Should be short form if possible." + Cycles which you overtook - min - "Minute abbrevation. Should be short form if possible." + Cycles which overtook you diff --git a/translations/harbour-pedalo.ts b/translations/harbour-pedalo.ts index e580051..42cc67b 100644 --- a/translations/harbour-pedalo.ts +++ b/translations/harbour-pedalo.ts @@ -13,49 +13,49 @@ - AddJourney + CoverPage - Start time + My Cover + + + DurationEditDialog - End time + LTR - Duration + h + "Hour abbrevation. Should be short form if possible." - Cycles which you overtook + min + "Minute abbrevation. Should be short form if possible." + + + JourneyEdit - Cycles which overtook you + Start time - - - CoverPage - My Cover + End time - - - DurationEditDialog - LTR + Duration - h - "Hour abbrevation. Should be short form if possible." + Cycles which you overtook - min - "Minute abbrevation. Should be short form if possible." + Cycles which overtook you