diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-04 14:41:18 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-04 14:42:54 +0200 |
commit | 7984ce207450e285ba959502e0caf19f459c1e7a (patch) | |
tree | f4f54b39e9f3df448d17f159e852cc99d8cb242d /views/calendar/qml/DateSelector.qml | |
parent | 2255dd415d9d6858388ccf92561abb3e02d4b5a5 (diff) | |
download | kube-7984ce207450e285ba959502e0caf19f459c1e7a.tar.gz kube-7984ce207450e285ba959502e0caf19f459c1e7a.zip |
A date selector
Diffstat (limited to 'views/calendar/qml/DateSelector.qml')
-rw-r--r-- | views/calendar/qml/DateSelector.qml | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/views/calendar/qml/DateSelector.qml b/views/calendar/qml/DateSelector.qml new file mode 100644 index 00000000..2a341c41 --- /dev/null +++ b/views/calendar/qml/DateSelector.qml | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 Christian Mollekopf, <mollekopf@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 | import QtQuick 2.4 | ||
19 | import QtQuick.Controls 2.2 | ||
20 | import Qt.labs.calendar 1.0 | ||
21 | |||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | Column { | ||
25 | id: root | ||
26 | property date selectedDate | ||
27 | spacing: Kube.Units.smallSpacing | ||
28 | |||
29 | Row { | ||
30 | Kube.IconButton { | ||
31 | color: Kube.Colors.darkBackgroundColor | ||
32 | iconName: Kube.Icons.goBack_inverted | ||
33 | onClicked: { | ||
34 | var dateOffset = (24*60*60*1000) * 7; //7 days | ||
35 | var myDate = root.selectedDate; | ||
36 | myDate.setTime(myDate.getTime() - dateOffset); | ||
37 | root.selectedDate = myDate | ||
38 | } | ||
39 | } | ||
40 | Kube.Label { | ||
41 | anchors.verticalCenter: parent.verticalCenter | ||
42 | color: Kube.Colors.highlightedTextColor | ||
43 | font.bold: true | ||
44 | text: root.selectedDate.toLocaleString(Qt.locale(), "MMMM yyyy") | ||
45 | } | ||
46 | Kube.IconButton { | ||
47 | color: Kube.Colors.darkBackgroundColor | ||
48 | iconName: Kube.Icons.goNext_inverted | ||
49 | onClicked: { | ||
50 | var dateOffset = (24*60*60*1000) * 7; //7 days | ||
51 | var myDate = root.selectedDate; | ||
52 | myDate.setTime(myDate.getTime() + dateOffset); | ||
53 | root.selectedDate = myDate | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | MonthGrid { | ||
59 | id: grid | ||
60 | month: root.selectedDate.getMonth() | ||
61 | year: root.selectedDate.getFullYear() | ||
62 | locale: Qt.locale() | ||
63 | |||
64 | delegate: Text { | ||
65 | horizontalAlignment: Text.AlignHCenter | ||
66 | verticalAlignment: Text.AlignVCenter | ||
67 | opacity: model.month === grid.month ? 1 : 0.5 | ||
68 | text: model.day | ||
69 | font: grid.font | ||
70 | color: Kube.Colors.highlightedTextColor | ||
71 | Rectangle { | ||
72 | anchors { | ||
73 | left: parent.left | ||
74 | right: parent.right | ||
75 | bottom: parent.bottom | ||
76 | } | ||
77 | width: Kube.Units.gridUnit | ||
78 | height: 1 | ||
79 | color: Kube.Colors.plasmaBlue | ||
80 | opacity: 0.6 | ||
81 | visible: model.day === root.selectedDate.getDate() && model.month === root.selectedDate.getMonth() | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||