Add duration entry dialog
[harbour-pedalo.git] / qml / pages / DurationEditDialog.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 //import "editdialog"
4 //import "../common"
5
6 // Amended version of /usr/share/jolla-clock/pages/ClockEditDialog.qml
7 Dialog {
8     id: dialog
9
10     property alias hour: timePicker.hour
11     property alias minute: timePicker.minute
12
13     property Item timePicker: timePicker
14     property bool leftToRight: qsTr("LTR") !== "RTL"
15
16     canAccept: true
17
18     SilicaFlickable {
19         anchors.fill: parent
20         contentHeight: column.height
21         flickableDirection: Flickable.VerticalFlick
22
23         Column {
24             id: column
25
26             width: parent.width
27             spacing: Theme.paddingLarge
28
29             DialogHeader {
30                 id: header
31             }
32             Item {
33                 height: childrenRect.height
34                 width: parent.width
35                 TimePicker {
36                     id: timePicker
37                     x: isPortrait ? (column.width-width)/2 : Theme.horizontalPageMargin
38                     // otherwise in 12h mode this caused timer 00:00 to display as 12:00am
39                     hourMode: DateTime.TwentyFourHours
40
41                     Column {
42                         id: timerLabelColumn
43                         anchors.centerIn: parent
44
45                         //: 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
46                         spacing: -Theme.paddingMedium
47                         Row {
48                             spacing: Theme.paddingSmall
49                             anchors.horizontalCenter: parent.horizontalCenter
50                             layoutDirection: leftToRight ? Qt.LeftToRight : Qt.RightToLeft
51                             Label {
52                                 id: hours
53                                 text: timePicker.hour.toLocaleString()
54                                 font.pixelSize: Theme.fontSizeHuge
55                                 height: Math.min(implicitHeight, (timePicker.height*0.4 - timerLabelColumn.spacing)/2)
56                                 fontSizeMode: Text.VerticalFit
57                             }
58                             Label {
59                                 id: hoursLabel
60                                 //: "Hour abbrevation. Should be short form if possible."
61                                 text: qsTr("h")
62                                 anchors.baseline: hours.baseline
63                                 opacity: 0.7
64                             }
65                         }
66                         Row {
67                             spacing: Theme.paddingSmall
68                             anchors.horizontalCenter: parent.horizontalCenter
69                             layoutDirection: leftToRight ? Qt.LeftToRight : Qt.RightToLeft
70                             Label {
71                                 id: minutes
72                                 text: timePicker.minute.toLocaleString()
73                                 font.pixelSize: Theme.fontSizeHuge
74                                 height: Math.min(implicitHeight, (timePicker.height*0.4 - timerLabelColumn.spacing)/2)
75                                 fontSizeMode: Text.VerticalFit
76                             }
77                             Label {
78                                 id: minuteLabel
79                                 //: "Minute abbrevation. Should be short form if possible."
80                                 text: qsTr("min")
81                                 anchors.baseline: minutes.baseline
82                                 verticalAlignment: Text.AlignBottom
83                                 opacity: 0.7
84                             }
85                         }
86                     }
87                 }
88             }
89         }
90     }
91 }