Add duration entry dialog
[harbour-pedalo.git] / qml / pages / DurationEditDialog.qml
diff --git a/qml/pages/DurationEditDialog.qml b/qml/pages/DurationEditDialog.qml
new file mode 100644 (file)
index 0000000..95e2dff
--- /dev/null
@@ -0,0 +1,91 @@
+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
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}