onClicked: {
var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()})
dialog.accepted.connect(function() {
- time = new Date(0, 0, 0, dialog.hour, dialog.minute)
- duration = ((endTime.time.getHours() - start.getHours()) * 60) + (endTime.time.getMinutes() - start.getMinutes()) * 60
+ // 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(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm')
width: parent.width
onClicked: {
- var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60})
+ 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
})
--- /dev/null
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+//import "editdialog"
+//import "../common"
+
+// Amended version of /usr/share/jolla-clock/pages/ClockEditDialog.qml
+Dialog {
+ id: dialog
+
+ property alias hour: timePicker.hour
+ property alias minute: timePicker.minute
+
+ property Item timePicker: timePicker
+ property bool leftToRight: qsTr("LTR") !== "RTL"
+
+ canAccept: true
+
+ SilicaFlickable {
+ anchors.fill: parent
+ contentHeight: column.height
+ flickableDirection: Flickable.VerticalFlick
+
+ Column {
+ id: column
+
+ width: parent.width
+ spacing: Theme.paddingLarge
+
+ DialogHeader {
+ id: header
+ }
+ Item {
+ height: childrenRect.height
+ width: parent.width
+ TimePicker {
+ id: timePicker
+ x: isPortrait ? (column.width-width)/2 : Theme.horizontalPageMargin
+ // otherwise in 12h mode this caused timer 00:00 to display as 12:00am
+ hourMode: DateTime.TwentyFourHours
+
+ Column {
+ id: timerLabelColumn
+ anchors.centerIn: parent
+
+ //: Can have two values: "LTR" if remaining time in timer item should be written in "[value] [unit]" order i.e. "2 min", or "RTL" i.e. right-to-left like in Arabic writing systems
+ spacing: -Theme.paddingMedium
+ Row {
+ spacing: Theme.paddingSmall
+ anchors.horizontalCenter: parent.horizontalCenter
+ layoutDirection: leftToRight ? Qt.LeftToRight : Qt.RightToLeft
+ Label {
+ id: hours
+ text: timePicker.hour.toLocaleString()
+ font.pixelSize: Theme.fontSizeHuge
+ height: Math.min(implicitHeight, (timePicker.height*0.4 - timerLabelColumn.spacing)/2)
+ fontSizeMode: Text.VerticalFit
+ }
+ Label {
+ id: hoursLabel
+ //: "Hour abbrevation. Should be short form if possible."
+ text: qsTr("h")
+ anchors.baseline: hours.baseline
+ opacity: 0.7
+ }
+ }
+ Row {
+ spacing: Theme.paddingSmall
+ anchors.horizontalCenter: parent.horizontalCenter
+ layoutDirection: leftToRight ? Qt.LeftToRight : Qt.RightToLeft
+ Label {
+ id: minutes
+ text: timePicker.minute.toLocaleString()
+ font.pixelSize: Theme.fontSizeHuge
+ height: Math.min(implicitHeight, (timePicker.height*0.4 - timerLabelColumn.spacing)/2)
+ fontSizeMode: Text.VerticalFit
+ }
+ Label {
+ id: minuteLabel
+ //: "Minute abbrevation. Should be short form if possible."
+ text: qsTr("min")
+ anchors.baseline: minutes.baseline
+ verticalAlignment: Text.AlignBottom
+ opacity: 0.7
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
<translation>Mein Cover</translation>
</message>
</context>
+<context>
+ <name>DurationEditDialog</name>
+ <message>
+ <source>LTR</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>h</source>
+ <extracomment>"Hour abbrevation. Should be short form if possible."</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>min</source>
+ <extracomment>"Minute abbrevation. Should be short form if possible."</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
<context>
<name>JourneyList</name>
<message>
<translation type="unfinished"></translation>
</message>
</context>
+<context>
+ <name>DurationEditDialog</name>
+ <message>
+ <source>LTR</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>h</source>
+ <extracomment>"Hour abbrevation. Should be short form if possible."</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>min</source>
+ <extracomment>"Minute abbrevation. Should be short form if possible."</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
<context>
<name>JourneyList</name>
<message>