diff options
-rw-r--r-- | views/calendar/qml/DayChooser.qml | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/views/calendar/qml/DayChooser.qml b/views/calendar/qml/DayChooser.qml new file mode 100644 index 00000000..a18bafd0 --- /dev/null +++ b/views/calendar/qml/DayChooser.qml | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com> | ||
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; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick.Layouts 1.2 | ||
21 | import org.kube.framework 1.0 as Kube | ||
22 | import Qt.labs.calendar 1.0 | ||
23 | |||
24 | Item { | ||
25 | id: root | ||
26 | |||
27 | height: button.height | ||
28 | width: button.width | ||
29 | |||
30 | Kube.Button { | ||
31 | id: button | ||
32 | |||
33 | text: "Choose Date" | ||
34 | |||
35 | onClicked: { | ||
36 | popup.open() | ||
37 | } | ||
38 | |||
39 | Kube.Popup { | ||
40 | id: popup | ||
41 | |||
42 | property var year: 2018 | ||
43 | property var month: Calendar.April | ||
44 | |||
45 | x: button.x | ||
46 | y: button.y + button.height | ||
47 | width: monthGrid.width + Kube.Units.largeSpacing * 2 | ||
48 | height: monthGrid.height + Kube.Units.largeSpacing * 2 | ||
49 | modal: true | ||
50 | focus: true | ||
51 | |||
52 | ColumnLayout { | ||
53 | id: monthGrid | ||
54 | |||
55 | anchors.centerIn: parent | ||
56 | |||
57 | RowLayout { | ||
58 | Kube.Label { | ||
59 | text: "May" //FIXME popup.month | ||
60 | } | ||
61 | Kube.Label { | ||
62 | text: popup.year | ||
63 | } | ||
64 | Kube.IconButton { | ||
65 | iconName: Kube.Icons.goUp | ||
66 | |||
67 | onClicked: { | ||
68 | if (popup.month == Calendar.January) { | ||
69 | popup.month = Calendar.December | ||
70 | popup.year--; | ||
71 | } else { | ||
72 | popup.month--; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | } | ||
77 | Kube.IconButton { | ||
78 | iconName: Kube.Icons.goDown | ||
79 | |||
80 | onClicked: { | ||
81 | if (popup.month == Calendar.December) { | ||
82 | popup.month = Calendar.January | ||
83 | popup.year++; | ||
84 | } else { | ||
85 | popup.month++; | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | GridLayout { | ||
92 | |||
93 | columns: 2 | ||
94 | |||
95 | DayOfWeekRow { | ||
96 | locale: grid.locale | ||
97 | |||
98 | Layout.column: 1 | ||
99 | Layout.fillWidth: true | ||
100 | |||
101 | } | ||
102 | |||
103 | WeekNumberColumn { | ||
104 | month: grid.month | ||
105 | year: grid.year | ||
106 | locale: grid.locale | ||
107 | |||
108 | Layout.fillHeight: true | ||
109 | } | ||
110 | |||
111 | MonthGrid { | ||
112 | id: grid | ||
113 | month: popup.month | ||
114 | year: popup.year | ||
115 | locale: Qt.locale("en_GB") //FIXME | ||
116 | |||
117 | Layout.fillWidth: true | ||
118 | Layout.fillHeight: true | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||