~nskaggs/ubuntu-calendar-app/regress-test

« back to all changes in this revision

Viewing changes to TimePicker.qml

  • Committer: Riccardo Padovani
  • Date: 2013-07-11 13:17:04 UTC
  • mto: This revision was merged to the branch mainline in revision 68.
  • Revision ID: rpadovani@ubuntu-it.org-20130711131704-2uiia3n3yr9p4hpu
Implemented DatePicker. Thanks to Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Michael Zanetti <michael_zanetti@gmx.net>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 0.1
 
19
import Ubuntu.Components.Popups 0.1
 
20
 
 
21
Dialog {
 
22
    id: root
 
23
    title: qsTr("Time")
 
24
    height: units.gu(100)
 
25
 
 
26
    property alias hour: hourScroller.currentIndex
 
27
    property alias minute: minuteScroller.currentIndex
 
28
 
 
29
    signal accepted(int hours, int minutes)
 
30
    signal rejected()
 
31
 
 
32
    QtObject {
 
33
        id: priv
 
34
 
 
35
        property date now: new Date()
 
36
    }
 
37
 
 
38
    contents: [
 
39
        Row {
 
40
            height: units.gu(24)
 
41
            Scroller {
 
42
                id: hourScroller
 
43
                anchors {
 
44
                    top: parent.top
 
45
                    bottom: parent.bottom
 
46
                }
 
47
                width: parent.width / 2
 
48
                labelText: qsTr("Hour")
 
49
                min: 00
 
50
                max: 23
 
51
                currentIndex: priv.now.getHours()
 
52
            }
 
53
            Scroller {
 
54
                id: minuteScroller
 
55
                anchors {
 
56
                    top: parent.top
 
57
                    bottom: parent.bottom
 
58
                }
 
59
                width: parent.width / 2
 
60
                labelText: qsTr("Minute")
 
61
 
 
62
                min: 00
 
63
                max: 59
 
64
                currentIndex: priv.now.getMinutes()
 
65
            }
 
66
        },
 
67
        Row {
 
68
            spacing: units.gu(1)
 
69
            Button {
 
70
                text: "Cancel"
 
71
                onClicked: {
 
72
                    root.rejected()
 
73
                    PopupUtils.close(root)
 
74
                }
 
75
                width: (parent.width - parent.spacing) / 2
 
76
            }
 
77
            Button {
 
78
                text: "OK"
 
79
                color: "#dd4814"
 
80
 
 
81
                onClicked: {
 
82
                    root.accepted(root.hour, root.minute)
 
83
                    PopupUtils.close(root)
 
84
                }
 
85
                width: (parent.width - parent.spacing) / 2
 
86
            }
 
87
        }
 
88
 
 
89
    ]
 
90
}
 
 
b'\\ No newline at end of file'