summaryrefslogtreecommitdiffstats
path: root/views/calendar/qml/DateSelector.qml
diff options
context:
space:
mode:
Diffstat (limited to 'views/calendar/qml/DateSelector.qml')
-rw-r--r--views/calendar/qml/DateSelector.qml85
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 */
18import QtQuick 2.4
19import QtQuick.Controls 2.2
20import Qt.labs.calendar 1.0
21
22import org.kube.framework 1.0 as Kube
23
24Column {
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}