summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/Clock.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Clock.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Clock.qml137
1 files changed, 68 insertions, 69 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml
index 56f8d41f..3e0f8200 100644
--- a/accounts/gkleen@sif/shell/quickshell/Clock.qml
+++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml
@@ -61,18 +61,20 @@ Item {
61 Repeater { 61 Repeater {
62 model: 12 62 model: 12
63 63
64 Column { 64 GridLayout {
65 columns: 2
66
65 required property int index 67 required property int index
66 property int month: index 68 property int month: index
67 69
68 id: monthCalendar 70 id: monthCalendar
69 71
70 width: parent.width
71
72 Layout.alignment: Qt.AlignTop | Qt.AlignRight 72 Layout.alignment: Qt.AlignTop | Qt.AlignRight
73 Layout.fillWidth: false
73 74
74 Text { 75 Text {
75 width: parent.width 76 Layout.column: 1
77 Layout.fillWidth: true
76 78
77 horizontalAlignment: Text.AlignHCenter 79 horizontalAlignment: Text.AlignHCenter
78 80
@@ -87,96 +89,93 @@ Item {
87 color: "#ffead3" 89 color: "#ffead3"
88 } 90 }
89 91
90 GridLayout { 92 DayOfWeekRow {
91 columns: 2 93 locale: grid.locale
92 94
93 DayOfWeekRow { 95 Layout.row: 1
94 locale: grid.locale 96 Layout.column: 1
97 Layout.fillWidth: true
95 98
96 Layout.column: 1 99 delegate: Text {
97 Layout.fillWidth: true 100 required property string shortName
98 101
99 delegate: Text { 102 font.pointSize: 10
100 required property string shortName 103 font.family: "Fira Mono"
101
102 font.pointSize: 10
103 font.family: "Fira Mono"
104 104
105 text: shortName 105 text: shortName
106 color: "#ffcc66" 106 color: "#ffcc66"
107 107
108 horizontalAlignment: Text.AlignRight 108 horizontalAlignment: Text.AlignRight
109 verticalAlignment: Text.AlignVCenter 109 verticalAlignment: Text.AlignVCenter
110 }
111 } 110 }
111 }
112 112
113 WeekNumberColumn { 113 WeekNumberColumn {
114 month: grid.month 114 month: grid.month
115 year: grid.year 115 year: grid.year
116 locale: grid.locale 116 locale: grid.locale
117
118 Layout.fillHeight: true
119 117
120 delegate: Text { 118 Layout.fillHeight: true
121 required property int weekNumber
122 119
123 opacity: { 120 delegate: Text {
124 const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); 121 required property int weekNumber
125 const dayOfWeek = simple.getDay();
126 const isoWeekStart = simple;
127 122
128 isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); 123 opacity: {
129 if (dayOfWeek > 4) { 124 const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7);
130 isoWeekStart.setDate(isoWeekStart.getDate() + 7); 125 const dayOfWeek = simple.getDay();
131 } 126 const isoWeekStart = simple;
132 127
133 for (let i = 0; i < 7; i++) { 128 isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1);
134 const dayInWeek = isoWeekStart; 129 if (dayOfWeek > 4) {
135 dayInWeek.setDate(dayInWeek.getDate() + i); 130 isoWeekStart.setDate(isoWeekStart.getDate() + 7);
136 if (dayInWeek.getMonth() == monthCalendar.month) 131 }
137 return 1;
138 }
139 132
140 return 0; 133 for (let i = 0; i < 7; i++) {
134 const dayInWeek = isoWeekStart;
135 dayInWeek.setDate(dayInWeek.getDate() + i);
136 if (dayInWeek.getMonth() == monthCalendar.month)
137 return 1;
141 } 138 }
142 139
143 font.pointSize: 10 140 return 0;
144 font.family: "Fira Sans" 141 }
145 font.features: { "tnum": 1 }
146 142
147 text: weekNumber 143 font.pointSize: 10
148 color: "#99ffdd" 144 font.family: "Fira Sans"
145 font.features: { "tnum": 1 }
149 146
150 horizontalAlignment: Text.AlignRight 147 text: weekNumber
151 verticalAlignment: Text.AlignVCenter 148 color: "#99ffdd"
152 } 149
150 horizontalAlignment: Text.AlignRight
151 verticalAlignment: Text.AlignVCenter
153 } 152 }
153 }
154 154
155 MonthGrid { 155 MonthGrid {
156 id: grid 156 id: grid
157 157
158 year: yearCalendar.year 158 year: yearCalendar.year
159 month: monthCalendar.month 159 month: monthCalendar.month
160 locale: Qt.locale("en_DK") 160 locale: Qt.locale("en_DK")
161 161
162 Layout.fillWidth: true 162 Layout.fillWidth: true
163 Layout.fillHeight: true 163 Layout.fillHeight: true
164 164
165 delegate: Text { 165 delegate: Text {
166 required property var model 166 required property var model
167 167
168 opacity: model.month === monthCalendar.month ? 1 : 0 168 opacity: model.month === monthCalendar.month ? 1 : 0
169 169
170 font.pointSize: 10 170 font.pointSize: 10
171 font.family: "Fira Sans" 171 font.family: "Fira Sans"
172 font.features: { "tnum": 1 } 172 font.features: { "tnum": 1 }
173 173
174 text: model.day 174 text: model.day
175 color: model.today ? "#ff6699" : "white" 175 color: model.today ? "#ff6699" : "white"
176 176
177 horizontalAlignment: Text.AlignRight 177 horizontalAlignment: Text.AlignRight
178 verticalAlignment: Text.AlignVCenter 178 verticalAlignment: Text.AlignVCenter
179 }
180 } 179 }
181 } 180 }
182 } 181 }