Storing window size and geometry
[opentodolist:opentodolist.git] / OpenTodoList / qml / OpenTodoList / controls / DatePicker.qml
1 /*
2  *  OpenTodoListDesktopQml - Desktop QML frontend for OpenTodoList
3  *  Copyright (C) 2013  Martin Höher <martin@rpdev.net>
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 import QtQuick 2.0
20 import "../js/Utils.js" as Utils
21
22 Item {
23     id: root
24
25     height: childrenRect.height
26     width: childrenRect.width
27     clip: true
28
29     property date date: new Date()
30     property bool selecting: false
31     property int baseHeight: 100
32     property int baseWidth: 100
33
34     Flipable {
35         id: flipable
36         width: front.width
37         height: front.width
38
39         front: Item {
40             height: childrenRect.height
41             width: childrenRect.width
42             Column {
43                 id: emblem
44                 Text {
45                     font.family: symbolFont.name
46                     font.pixelSize: root.baseHeight * 0.75
47                     anchors.horizontalCenter: parent.horizontalCenter
48                     text: Utils.isValidDate( root.date ) ? "\uf073" : "\uf133"
49                 }
50                 Text {
51                     font.pixelSize: root.baseHeight * 0.2
52                     anchors.horizontalCenter: parent.horizontalCenter
53                     text: Utils.formatDate( root.date, "No Due Date" )
54                 }
55             }
56             MouseArea {
57                 anchors.fill: emblem
58                 enabled: !root.selecting
59                 onClicked: {
60                     calendar.selectedDate = root.date
61                     root.selecting = true
62                 }
63             }
64         }
65
66         back: Item {
67             height: editColumn.height
68             width: editColumn.width
69             Column {
70                 id: editColumn
71                 Calendar {
72                     id: calendar
73                 }
74                 Row {
75                     spacing: 5
76                     Button {
77                         label: "OK"
78                         onClicked: {
79                             root.date = calendar.selectedDate
80                             root.selecting = false
81                         }
82                     }
83                     Button {
84                         label: "Cancel"
85                         onClicked: root.selecting = false
86                     }
87                     Button {
88                         label: "Reset"
89                         onClicked: {
90                             root.date = Utils.getNullDate()
91                             root.selecting = false
92                         }
93                     }
94                 }
95             }
96         }
97
98         transform: Rotation {
99             id: rotation
100             axis { x: 0; y: 1; z: 0 }
101             origin.x: root.width/2
102             angle: 0
103         }
104
105         states: State {
106             name: "flipped"
107             when: root.selecting
108             PropertyChanges { target: rotation; angle: 180 }
109             PropertyChanges { target: flipable; width: flipable.back.width; height: flipable.back.height }
110         }
111
112         transitions: Transition {
113             reversible: true
114             ParallelAnimation {
115                 NumberAnimation {
116                     id: rotationAnimation
117                     target: rotation
118                     property: "angle"
119                     duration: 500
120                 }
121                 NumberAnimation {
122                     target: flipable
123                     property: "width"
124                     duration: rotationAnimation.duration
125                 }
126                 NumberAnimation {
127                     target: flipable
128                     property: "height"
129                     duration: rotationAnimation.duration
130                 }
131             }
132         }
133     }
134 }