summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/calendar/qml/DateSelector.qml85
-rw-r--r--views/calendar/qml/View.qml73
2 files changed, 128 insertions, 30 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}
diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml
index 917d0c80..601ca0cf 100644
--- a/views/calendar/qml/View.qml
+++ b/views/calendar/qml/View.qml
@@ -27,6 +27,7 @@ RowLayout {
27 id: root 27 id: root
28 28
29 property date currentDate: new Date() 29 property date currentDate: new Date()
30 property date selectedDate: currentDate
30 property bool autoUpdateDate: true 31 property bool autoUpdateDate: true
31 32
32 Timer { 33 Timer {
@@ -72,12 +73,10 @@ RowLayout {
72 DateView { 73 DateView {
73 date: root.currentDate 74 date: root.currentDate
74 } 75 }
75 color: Kube.Colors.highlightedTextColor 76
76 }
77 }
78 } 77 }
79 78
80 Column { 79 ColumnLayout {
81 anchors { 80 anchors {
82 bottom: parent.bottom 81 bottom: parent.bottom
83 left: newEventButton.left 82 left: newEventButton.left
@@ -85,36 +84,50 @@ RowLayout {
85 bottomMargin: Kube.Units.largeSpacing 84 bottomMargin: Kube.Units.largeSpacing
86 } 85 }
87 86
88 spacing: Kube.Units.smallSpacing 87 spacing: Kube.Units.largeSpacing
89 88
90 Repeater { 89 DateSelector {
91 model: Kube.EntityModel { 90 selectedDate: root.selectedDate
92 type: "calendar" 91 onSelectedDateChanged: {
93 roles: ["name", "color"] 92 root.selectedDate = selectedDate
94 } 93 }
95 delegate: Item { 94 }
96 width: parent.width - Kube.Units.largeSpacing 95
97 height: Kube.Units.gridUnit 96 Column {
98 Row { 97 anchors {
99 spacing: Kube.Units.smallSpacing 98 left: parent.left
100 Kube.CheckBox { 99 right: parent.right
101 opacity: 0.9 100 }
102 checked: true 101 spacing: Kube.Units.smallSpacing
102 Repeater {
103 model: Kube.EntityModel {
104 type: "calendar"
105 roles: ["name", "color"]
106 }
107 delegate: Item {
108 width: parent.width - Kube.Units.largeSpacing
109 height: Kube.Units.gridUnit
110 Row {
111 spacing: Kube.Units.smallSpacing
112 Kube.CheckBox {
113 opacity: 0.9
114 checked: true
115 }
116 Kube.Label {
117 text: model.name
118 color: Kube.Colors.highlightedTextColor
119 }
103 } 120 }
104 Kube.Label { 121 Rectangle {
105 text: model.name 122 anchors.right: parent.right
106 color: Kube.Colors.highlightedTextColor 123 anchors.verticalCenter: parent.verticalCenter
124 width: Kube.Units.gridUnit
125 height: width
126 radius: width / 2
127 color: model.color
128 opacity: 0.9
107 } 129 }
108 } 130 }
109 Rectangle {
110 anchors.right: parent.right
111 anchors.verticalCenter: parent.verticalCenter
112 width: Kube.Units.gridUnit
113 height: width
114 radius: width / 2
115 color: model.color
116 opacity: 0.9
117 }
118 } 131 }
119 } 132 }
120 } 133 }
@@ -123,6 +136,6 @@ RowLayout {
123 WeekView { 136 WeekView {
124 Layout.fillHeight: true 137 Layout.fillHeight: true
125 Layout.fillWidth: true 138 Layout.fillWidth: true
126 currentDate: root.currentDate 139 currentDate: root.selectedDate
127 } 140 }
128} 141}