diff options
Diffstat (limited to 'views/calendar/qml/View.qml')
-rw-r--r-- | views/calendar/qml/View.qml | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml index 601ca0cf..f49d8bff 100644 --- a/views/calendar/qml/View.qml +++ b/views/calendar/qml/View.qml | |||
@@ -27,7 +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 date selectedDate: getFirstDayOfWeek(currentDate) |
31 | property bool autoUpdateDate: true | 31 | property bool autoUpdateDate: true |
32 | 32 | ||
33 | Timer { | 33 | Timer { |
@@ -36,6 +36,24 @@ RowLayout { | |||
36 | onTriggered: root.currentDate = new Date() | 36 | onTriggered: root.currentDate = new Date() |
37 | } | 37 | } |
38 | 38 | ||
39 | function getFirstDayOfWeek(date) { | ||
40 | var firstDay = Qt.locale().firstDayOfWeek | ||
41 | var year = date.getFullYear() | ||
42 | var month = date.getMonth() | ||
43 | //Jup, getDate returns the day of the month | ||
44 | var day = date.getDate() | ||
45 | |||
46 | while (true) { | ||
47 | if (date.getDay() === firstDay) { | ||
48 | return date | ||
49 | } | ||
50 | day = day - 1 | ||
51 | date = new Date(year, month, day) | ||
52 | } | ||
53 | return date | ||
54 | } | ||
55 | |||
56 | |||
39 | StackView.onActivated: { | 57 | StackView.onActivated: { |
40 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "event"}) | 58 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "event"}) |
41 | } | 59 | } |
@@ -136,6 +154,7 @@ RowLayout { | |||
136 | WeekView { | 154 | WeekView { |
137 | Layout.fillHeight: true | 155 | Layout.fillHeight: true |
138 | Layout.fillWidth: true | 156 | Layout.fillWidth: true |
139 | currentDate: root.selectedDate | 157 | currentDate: root.currentDate |
158 | startDate: root.selectedDate | ||
140 | } | 159 | } |
141 | } | 160 | } |