diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-04 13:46:26 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-04 13:46:26 +0200 |
commit | c75ee648a9446a37e7a4e38e891c047d23d374a2 (patch) | |
tree | ef2806cb3bfac55db3233793745c6c5b499656a5 | |
parent | 14c1c31ce47560bad7509fe68afee5467112be30 (diff) | |
download | kube-c75ee648a9446a37e7a4e38e891c047d23d374a2.tar.gz kube-c75ee648a9446a37e7a4e38e891c047d23d374a2.zip |
Cleanup
-rw-r--r-- | views/calendar/qml/DateView.qml | 48 | ||||
-rw-r--r-- | views/calendar/qml/DayLabels.qml | 52 | ||||
-rw-r--r-- | views/calendar/qml/View.qml | 22 | ||||
-rw-r--r-- | views/calendar/qml/WeekView.qml | 28 |
4 files changed, 107 insertions, 43 deletions
diff --git a/views/calendar/qml/DateView.qml b/views/calendar/qml/DateView.qml new file mode 100644 index 00000000..c42b35fe --- /dev/null +++ b/views/calendar/qml/DateView.qml | |||
@@ -0,0 +1,48 @@ | |||
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.Layouts 1.1 | ||
20 | import QtQuick.Controls 2.2 | ||
21 | |||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | Row { | ||
25 | id: root | ||
26 | property date date: null | ||
27 | |||
28 | spacing: Kube.Units.smallSpacing | ||
29 | |||
30 | Kube.Label { | ||
31 | anchors.verticalCenter: parent.verticalCenter | ||
32 | text: root.date.getDate() | ||
33 | color: Kube.Colors.highlightedTextColor | ||
34 | font.pointSize: Kube.Units.defaultFontSize * 3 | ||
35 | } | ||
36 | Column { | ||
37 | anchors.verticalCenter: parent.verticalCenter | ||
38 | Kube.Label { | ||
39 | text: root.date.toLocaleString(Qt.locale(), "dddd") | ||
40 | color: Kube.Colors.highlightedTextColor | ||
41 | } | ||
42 | Kube.Label { | ||
43 | text: root.date.toLocaleString(Qt.locale(), "MMMM yyyy") | ||
44 | color: Kube.Colors.highlightedTextColor | ||
45 | font.pointSize: Kube.Units.smallFontSize | ||
46 | } | ||
47 | } | ||
48 | } | ||
diff --git a/views/calendar/qml/DayLabels.qml b/views/calendar/qml/DayLabels.qml new file mode 100644 index 00000000..cd961068 --- /dev/null +++ b/views/calendar/qml/DayLabels.qml | |||
@@ -0,0 +1,52 @@ | |||
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.Layouts 1.1 | ||
20 | import QtQuick.Controls 2.2 | ||
21 | |||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | Row { | ||
25 | id: root | ||
26 | property date startDate | ||
27 | property int dayWidth | ||
28 | property int daysToShow | ||
29 | |||
30 | height: childrenRect.height | ||
31 | width: dayWidth * daysToShow | ||
32 | |||
33 | spacing: 0 | ||
34 | Repeater { | ||
35 | model: root.daysToShow | ||
36 | delegate: Item { | ||
37 | width: root.dayWidth | ||
38 | height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3 | ||
39 | Kube.Label { | ||
40 | function addDaysToDate(date, days) { | ||
41 | var date = new Date(date); | ||
42 | date.setDate(date.getDate() + days); | ||
43 | return date; | ||
44 | } | ||
45 | font.bold: true | ||
46 | |||
47 | anchors.centerIn: parent | ||
48 | text: addDaysToDate(root.startDate, modelData).toLocaleString(Qt.locale(), "dddd") | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml index 2a819ab6..917d0c80 100644 --- a/views/calendar/qml/View.qml +++ b/views/calendar/qml/View.qml | |||
@@ -69,27 +69,11 @@ RowLayout { | |||
69 | width: parent.width | 69 | width: parent.width |
70 | spacing: Kube.Units.smallSpacing | 70 | spacing: Kube.Units.smallSpacing |
71 | 71 | ||
72 | Row { | 72 | DateView { |
73 | spacing: Kube.Units.smallSpacing | 73 | date: root.currentDate |
74 | Kube.Label { | 74 | } |
75 | anchors.verticalCenter: parent.verticalCenter | ||
76 | text: root.currentDate.getDate() | ||
77 | color: Kube.Colors.highlightedTextColor | 75 | color: Kube.Colors.highlightedTextColor |
78 | font.pointSize: Kube.Units.defaultFontSize * 3 | ||
79 | } | 76 | } |
80 | Column { | ||
81 | anchors.verticalCenter: parent.verticalCenter | ||
82 | Kube.Label { | ||
83 | text: root.currentDate.toLocaleString(Qt.locale(), "dddd") | ||
84 | color: Kube.Colors.highlightedTextColor | ||
85 | } | ||
86 | Kube.Label { | ||
87 | text: root.currentDate.toLocaleString(Qt.locale(), "MMMM yyyy") | ||
88 | color: Kube.Colors.highlightedTextColor | ||
89 | font.pointSize: Kube.Units.smallFontSize | ||
90 | } | ||
91 | } | ||
92 | |||
93 | } | 77 | } |
94 | } | 78 | } |
95 | 79 | ||
diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml index f78a4a8d..484a151f 100644 --- a/views/calendar/qml/WeekView.qml +++ b/views/calendar/qml/WeekView.qml | |||
@@ -59,34 +59,14 @@ FocusScope { | |||
59 | width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2 | 59 | width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2 |
60 | height: root.height | 60 | height: root.height |
61 | 61 | ||
62 | //BEGIN day labels | 62 | DayLabels { |
63 | Row { | ||
64 | id: dayLabels | 63 | id: dayLabels |
65 | anchors.top: parent.top | 64 | anchors.top: parent.top |
66 | anchors.right: parent.right | 65 | anchors.right: parent.right |
67 | spacing: 0 | 66 | startDate: root.startDate |
68 | height: childrenRect.height | 67 | dayWidth: root.dayWidth |
69 | width: root.dayWidth * root.daysToShow | 68 | daysToShow: root.daysToShow |
70 | Repeater { | ||
71 | model: root.daysToShow | ||
72 | delegate: Item { | ||
73 | width: root.dayWidth | ||
74 | height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3 | ||
75 | Kube.Label { | ||
76 | function addDaysToDate(date, days) { | ||
77 | var date = new Date(date); | ||
78 | date.setDate(date.getDate() + days); | ||
79 | return date; | ||
80 | } | ||
81 | font.bold: true | ||
82 | |||
83 | anchors.centerIn: parent | ||
84 | text: addDaysToDate(root.startDate, modelData).toLocaleString(Qt.locale(), "dddd") | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | } | 69 | } |
89 | //END day labels | ||
90 | 70 | ||
91 | //BEGIN daylong events | 71 | //BEGIN daylong events |
92 | Rectangle { | 72 | Rectangle { |