diff options
-rw-r--r-- | views/calendar/qml/View.qml | 251 |
1 files changed, 127 insertions, 124 deletions
diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml index 065faecb..07127d27 100644 --- a/views/calendar/qml/View.qml +++ b/views/calendar/qml/View.qml | |||
@@ -23,7 +23,7 @@ import QtQuick.Layouts 1.2 | |||
23 | import org.kube.framework 1.0 as Kube | 23 | import org.kube.framework 1.0 as Kube |
24 | 24 | ||
25 | 25 | ||
26 | RowLayout { | 26 | Kube.View { |
27 | id: root | 27 | id: root |
28 | 28 | ||
29 | property date currentDate: new Date() | 29 | property date currentDate: new Date() |
@@ -34,10 +34,8 @@ RowLayout { | |||
34 | console.log("Selected date changed", selectedDate) | 34 | console.log("Selected date changed", selectedDate) |
35 | } | 35 | } |
36 | 36 | ||
37 | Timer { | 37 | onRefresh: { |
38 | running: autoUpdateDate | 38 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "event"}) |
39 | interval: 2000; repeat: true | ||
40 | onTriggered: root.currentDate = new Date() | ||
41 | } | 39 | } |
42 | 40 | ||
43 | function getFirstDayOfWeek(date) { | 41 | function getFirstDayOfWeek(date) { |
@@ -58,156 +56,161 @@ RowLayout { | |||
58 | } | 56 | } |
59 | 57 | ||
60 | 58 | ||
61 | StackView.onActivated: { | 59 | RowLayout { |
62 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "event"}) | ||
63 | } | ||
64 | 60 | ||
65 | Rectangle { | 61 | Timer { |
66 | anchors { | 62 | running: autoUpdateDate |
67 | top: parent.top | 63 | interval: 2000; repeat: true |
68 | bottom: parent.bottom | 64 | onTriggered: root.currentDate = new Date() |
69 | } | 65 | } |
70 | width: Kube.Units.gridUnit * 10 | ||
71 | color: Kube.Colors.darkBackgroundColor | ||
72 | 66 | ||
73 | Column { | 67 | Rectangle { |
74 | id: topLayout | ||
75 | anchors { | 68 | anchors { |
76 | top: parent.top | 69 | top: parent.top |
77 | left: parent.left | ||
78 | right: parent.right | ||
79 | margins: Kube.Units.largeSpacing | ||
80 | } | ||
81 | spacing: Kube.Units.largeSpacing | ||
82 | Kube.PositiveButton { | ||
83 | id: newEventButton | ||
84 | objectName: "newEventButton" | ||
85 | |||
86 | anchors { | ||
87 | left: parent.left | ||
88 | right: parent.right | ||
89 | } | ||
90 | focus: true | ||
91 | text: qsTr("New Event") | ||
92 | onClicked: {} | ||
93 | } | ||
94 | DateView { | ||
95 | anchors { | ||
96 | left: parent.left | ||
97 | right: parent.right | ||
98 | } | ||
99 | date: root.currentDate | ||
100 | MouseArea { | ||
101 | anchors.fill: parent | ||
102 | onClicked: dateSelector.selectedDate = root.currentDate | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | ColumnLayout { | ||
108 | //Grow from the button but don't go over topLayout | ||
109 | anchors { | ||
110 | bottom: parent.bottom | 70 | bottom: parent.bottom |
111 | left: topLayout.left | ||
112 | right: parent.right | ||
113 | bottomMargin: Kube.Units.largeSpacing | ||
114 | rightMargin: Kube.Units.largeSpacing | ||
115 | } | 71 | } |
116 | height: Math.min(implicitHeight, parent.height - (topLayout.y + topLayout.height) - Kube.Units.largeSpacing - anchors.bottomMargin) | 72 | width: Kube.Units.gridUnit * 10 |
117 | 73 | color: Kube.Colors.darkBackgroundColor | |
118 | spacing: Kube.Units.largeSpacing | ||
119 | 74 | ||
120 | DateSelector { | 75 | Column { |
121 | id: dateSelector | 76 | id: topLayout |
122 | anchors { | 77 | anchors { |
78 | top: parent.top | ||
123 | left: parent.left | 79 | left: parent.left |
124 | right: parent.right | 80 | right: parent.right |
81 | margins: Kube.Units.largeSpacing | ||
125 | } | 82 | } |
126 | selectedDate: root.selectedDate | 83 | spacing: Kube.Units.largeSpacing |
127 | onSelectedDateChanged: { | 84 | Kube.PositiveButton { |
128 | root.selectedDate = getFirstDayOfWeek(dateSelector.selectedDate) | 85 | id: newEventButton |
129 | selectedDate = root.selectedDate | 86 | objectName: "newEventButton" |
87 | |||
88 | anchors { | ||
89 | left: parent.left | ||
90 | right: parent.right | ||
91 | } | ||
92 | focus: true | ||
93 | text: qsTr("New Event") | ||
94 | onClicked: {} | ||
95 | } | ||
96 | DateView { | ||
97 | anchors { | ||
98 | left: parent.left | ||
99 | right: parent.right | ||
100 | } | ||
101 | date: root.currentDate | ||
102 | MouseArea { | ||
103 | anchors.fill: parent | ||
104 | onClicked: dateSelector.selectedDate = root.currentDate | ||
105 | } | ||
130 | } | 106 | } |
131 | } | 107 | } |
132 | 108 | ||
133 | Kube.ListView { | 109 | ColumnLayout { |
134 | id: listView | 110 | //Grow from the button but don't go over topLayout |
135 | Layout.fillHeight: true | ||
136 | Layout.preferredHeight: contentHeight | ||
137 | Layout.minimumHeight: Kube.Units.gridUnit | ||
138 | anchors { | 111 | anchors { |
139 | left: parent.left | 112 | bottom: parent.bottom |
113 | left: topLayout.left | ||
140 | right: parent.right | 114 | right: parent.right |
115 | bottomMargin: Kube.Units.largeSpacing | ||
116 | rightMargin: Kube.Units.largeSpacing | ||
141 | } | 117 | } |
142 | spacing: Kube.Units.smallSpacing | 118 | height: Math.min(implicitHeight, parent.height - (topLayout.y + topLayout.height) - Kube.Units.largeSpacing - anchors.bottomMargin) |
143 | model: Kube.CheckableEntityModel { | ||
144 | id: calendarModel | ||
145 | type: "calendar" | ||
146 | roles: ["name", "color"] | ||
147 | } | ||
148 | delegate: ItemDelegate { | ||
149 | id: delegate | ||
150 | width: listView.availableWidth | ||
151 | height: Kube.Units.gridUnit | ||
152 | RowLayout { | ||
153 | anchors.fill: parent | ||
154 | spacing: Kube.Units.smallSpacing | ||
155 | Kube.CheckBox { | ||
156 | id: checkBox | ||
157 | opacity: 0.9 | ||
158 | checked: !model.checked | ||
159 | onCheckedChanged: { | ||
160 | model.checked = !checked | ||
161 | } | ||
162 | 119 | ||
163 | indicator: Rectangle { | 120 | spacing: Kube.Units.largeSpacing |
164 | width: Kube.Units.gridUnit | ||
165 | height: Kube.Units.gridUnit | ||
166 | 121 | ||
167 | color: model.color | 122 | DateSelector { |
123 | id: dateSelector | ||
124 | anchors { | ||
125 | left: parent.left | ||
126 | right: parent.right | ||
127 | } | ||
128 | selectedDate: root.selectedDate | ||
129 | onSelectedDateChanged: { | ||
130 | root.selectedDate = getFirstDayOfWeek(dateSelector.selectedDate) | ||
131 | selectedDate = root.selectedDate | ||
132 | } | ||
133 | } | ||
168 | 134 | ||
169 | Rectangle { | 135 | Kube.ListView { |
170 | id: highlight | 136 | id: listView |
171 | anchors.fill: parent | 137 | Layout.fillHeight: true |
172 | visible: checkBox.hovered || checkBox.visualFocus | 138 | Layout.preferredHeight: contentHeight |
173 | color: Kube.Colors.highlightColor | 139 | Layout.minimumHeight: Kube.Units.gridUnit |
174 | opacity: 0.4 | 140 | anchors { |
141 | left: parent.left | ||
142 | right: parent.right | ||
143 | } | ||
144 | spacing: Kube.Units.smallSpacing | ||
145 | model: Kube.CheckableEntityModel { | ||
146 | id: calendarModel | ||
147 | type: "calendar" | ||
148 | roles: ["name", "color"] | ||
149 | } | ||
150 | delegate: ItemDelegate { | ||
151 | id: delegate | ||
152 | width: listView.availableWidth | ||
153 | height: Kube.Units.gridUnit | ||
154 | RowLayout { | ||
155 | anchors.fill: parent | ||
156 | spacing: Kube.Units.smallSpacing | ||
157 | Kube.CheckBox { | ||
158 | id: checkBox | ||
159 | opacity: 0.9 | ||
160 | checked: !model.checked | ||
161 | onCheckedChanged: { | ||
162 | model.checked = !checked | ||
175 | } | 163 | } |
176 | 164 | ||
177 | Kube.Icon { | 165 | indicator: Rectangle { |
178 | anchors.centerIn: parent | ||
179 | height: Kube.Units.gridUnit | ||
180 | width: Kube.Units.gridUnit | 166 | width: Kube.Units.gridUnit |
181 | visible: checkBox.checked | 167 | height: Kube.Units.gridUnit |
182 | iconName: Kube.Icons.checkbox_inverted | 168 | |
169 | color: model.color | ||
170 | |||
171 | Rectangle { | ||
172 | id: highlight | ||
173 | anchors.fill: parent | ||
174 | visible: checkBox.hovered || checkBox.visualFocus | ||
175 | color: Kube.Colors.highlightColor | ||
176 | opacity: 0.4 | ||
177 | } | ||
178 | |||
179 | Kube.Icon { | ||
180 | anchors.centerIn: parent | ||
181 | height: Kube.Units.gridUnit | ||
182 | width: Kube.Units.gridUnit | ||
183 | visible: checkBox.checked | ||
184 | iconName: Kube.Icons.checkbox_inverted | ||
185 | } | ||
183 | } | 186 | } |
184 | } | ||
185 | 187 | ||
186 | } | 188 | } |
187 | Kube.Label { | 189 | Kube.Label { |
188 | id: label | 190 | id: label |
189 | Layout.fillWidth: true | 191 | Layout.fillWidth: true |
190 | text: model.name | 192 | text: model.name |
191 | color: Kube.Colors.highlightedTextColor | 193 | color: Kube.Colors.highlightedTextColor |
192 | elide: Text.ElideLeft | 194 | elide: Text.ElideLeft |
193 | clip: true | 195 | clip: true |
194 | } | 196 | } |
195 | ToolTip { | 197 | ToolTip { |
196 | id: toolTipItem | 198 | id: toolTipItem |
197 | visible: delegate.hovered && label.truncated | 199 | visible: delegate.hovered && label.truncated |
198 | text: label.text | 200 | text: label.text |
201 | } | ||
199 | } | 202 | } |
200 | } | 203 | } |
201 | } | 204 | } |
202 | } | 205 | } |
203 | } | 206 | } |
204 | } | ||
205 | 207 | ||
206 | WeekView { | 208 | WeekView { |
207 | Layout.fillHeight: true | 209 | Layout.fillHeight: true |
208 | Layout.fillWidth: true | 210 | Layout.fillWidth: true |
209 | currentDate: root.currentDate | 211 | currentDate: root.currentDate |
210 | startDate: root.selectedDate | 212 | startDate: root.selectedDate |
211 | calendarFilter: calendarModel.checkedEntities | 213 | calendarFilter: calendarModel.checkedEntities |
214 | } | ||
212 | } | 215 | } |
213 | } | 216 | } |