Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/FullRepresentation.qml
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 58 | Connections { | |||
---|---|---|---|---|---|
60 | onExpandedChanged: { | 60 | onExpandedChanged: { | ||
61 | if (plasmoid.expanded) { | 61 | if (plasmoid.expanded) { | ||
62 | list.positionViewAtBeginning(); | 62 | list.positionViewAtBeginning(); | ||
63 | list.currentIndex = -1; | 63 | list.currentIndex = -1; | ||
64 | } | 64 | } | ||
65 | } | 65 | } | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | // header | | |||
69 | ColumnLayout { | | |||
70 | id: header | | |||
71 | visible: !Kirigami.Settings.isMobile | | |||
72 | Layout.fillWidth: true | | |||
73 | spacing: 0 | | |||
74 | | ||||
75 | RowLayout { | | |||
76 | Layout.fillWidth: true | | |||
77 | spacing: 0 | | |||
78 | | ||||
79 | RowLayout { | | |||
80 | id: dndRow | | |||
81 | spacing: units.smallSpacing | | |||
82 | enabled: NotificationManager.Server.valid | | |||
83 | | ||||
84 | PlasmaComponents3.CheckBox { | | |||
85 | id: dndCheck | | |||
86 | text: i18n("Do not disturb") | | |||
87 | spacing: units.smallSpacing | | |||
88 | checkable: true | | |||
89 | checked: Globals.inhibited | | |||
90 | | ||||
91 | // Let the menu open on press | | |||
92 | onPressed: { | | |||
93 | if (!Globals.inhibited) { | | |||
94 | dndMenu.date = new Date(); | | |||
95 | // shows ontop of CheckBox to hide the fact that it's unchecked | | |||
96 | // until you actually select something :) | | |||
97 | dndMenu.open(0, 0); | | |||
98 | } | | |||
99 | } | | |||
100 | // but disable only on click | | |||
101 | onClicked: { | | |||
102 | if (Globals.inhibited) { | | |||
103 | Globals.revokeInhibitions(); | | |||
104 | } | | |||
105 | } | | |||
106 | | ||||
107 | contentItem: RowLayout { | | |||
108 | spacing: dndCheck.spacing | | |||
109 | | ||||
110 | PlasmaCore.IconItem { | | |||
111 | Layout.leftMargin: dndCheck.mirrored ? 0 : dndCheck.indicator.width + dndCheck.spacing | | |||
112 | Layout.rightMargin: dndCheck.mirrored ? dndCheck.indicator.width + dndCheck.spacing : 0 | | |||
113 | source: "notifications-disabled" | | |||
114 | Layout.preferredWidth: units.iconSizes.smallMedium | | |||
115 | Layout.preferredHeight: units.iconSizes.smallMedium | | |||
116 | } | | |||
117 | | ||||
118 | PlasmaComponents.Label { | | |||
119 | text: i18n("Do not disturb") | | |||
120 | } | | |||
121 | } | | |||
122 | | ||||
123 | PlasmaComponents.ModelContextMenu { | | |||
124 | id: dndMenu | | |||
125 | property date date | | |||
126 | visualParent: dndCheck | | |||
127 | | ||||
128 | onClicked: { | | |||
129 | notificationSettings.notificationsInhibitedUntil = model.date; | | |||
130 | notificationSettings.save(); | | |||
131 | } | | |||
132 | | ||||
133 | model: { | | |||
134 | var model = []; | | |||
135 | | ||||
136 | // For 1 hour | | |||
137 | var d = dndMenu.date; | | |||
138 | d.setHours(d.getHours() + 1); | | |||
139 | d.setSeconds(0); | | |||
140 | model.push({date: d, text: i18n("For 1 hour")}); | | |||
141 | | ||||
142 | d = dndMenu.date; | | |||
143 | d.setHours(d.getHours() + 4); | | |||
144 | d.setSeconds(0); | | |||
145 | model.push({date: d, text: i18n("For 4 hours")}); | | |||
146 | | ||||
147 | // Until this evening | | |||
148 | if (dndMenu.date.getHours() < dndEveningHour) { | | |||
149 | d = dndMenu.date; | | |||
150 | // TODO make the user's preferred time schedule configurable | | |||
151 | d.setHours(dndEveningHour); | | |||
152 | d.setMinutes(0); | | |||
153 | d.setSeconds(0); | | |||
154 | model.push({date: d, text: i18n("Until this evening")}); | | |||
155 | } | | |||
156 | | ||||
157 | // Until next morning | | |||
158 | if (dndMenu.date.getHours() > dndMorningHour) { | | |||
159 | d = dndMenu.date; | | |||
160 | d.setDate(d.getDate() + 1); | | |||
161 | d.setHours(dndMorningHour); | | |||
162 | d.setMinutes(0); | | |||
163 | d.setSeconds(0); | | |||
164 | model.push({date: d, text: i18n("Until tomorrow morning")}); | | |||
165 | } | | |||
166 | | ||||
167 | // Until Monday | | |||
168 | // show Friday and Saturday, Sunday is "0" but for that you can use "until tomorrow morning" | | |||
169 | if (dndMenu.date.getDay() >= 5) { | | |||
170 | d = dndMenu.date; | | |||
171 | d.setHours(dndMorningHour); | | |||
172 | // wraps around if necessary | | |||
173 | d.setDate(d.getDate() + (7 - d.getDay() + 1)); | | |||
174 | d.setMinutes(0); | | |||
175 | d.setSeconds(0); | | |||
176 | model.push({date: d, text: i18n("Until Monday")}); | | |||
177 | } | | |||
178 | | ||||
179 | // Until "turned off" | | |||
180 | d = dndMenu.date; | | |||
181 | // Just set it to one year in the future so we don't need yet another "do not disturb enabled" property | | |||
182 | d.setFullYear(d.getFullYear() + 1); | | |||
183 | model.push({date: d, text: i18n("Until turned off")}); | | |||
184 | | ||||
185 | return model; | | |||
186 | } | | |||
187 | } | | |||
188 | } | | |||
189 | } | | |||
190 | | ||||
191 | Item { | | |||
192 | Layout.fillWidth: true | | |||
193 | } | | |||
194 | | ||||
195 | PlasmaComponents.ToolButton { | | |||
196 | iconName: "configure" | | |||
197 | // remove mnemonics | | |||
198 | tooltip: plasmoid.action("openKcm").text.replace(/([^&]*)&(.)([^&]*)/g, function (match, p1, p2, p3) { | | |||
199 | return p1.concat(p2, p3); | | |||
200 | }); | | |||
201 | visible: plasmoid.action("openKcm").enabled | | |||
202 | onClicked: plasmoid.action("openKcm").trigger() | | |||
203 | } | | |||
204 | | ||||
205 | PlasmaComponents.ToolButton { | | |||
206 | iconName: "edit-clear-history" | | |||
207 | tooltip: i18n("Clear History") | | |||
208 | enabled: plasmoid.action("clearHistory").visible | | |||
209 | onClicked: action_clearHistory() | | |||
210 | } | | |||
211 | } | | |||
212 | | ||||
213 | PlasmaExtras.DescriptiveLabel { | | |||
214 | Layout.leftMargin: dndCheck.mirrored ? 0 : dndCheck.indicator.width + 2 * dndCheck.spacing + units.iconSizes.smallMedium | | |||
215 | Layout.rightMargin: dndCheck.mirrored ? dndCheck.indicator.width + 2 * dndCheck.spacing + units.iconSizes.smallMedium : 0 | | |||
216 | Layout.fillWidth: true | | |||
217 | wrapMode: Text.WordWrap | | |||
218 | textFormat: Text.PlainText | | |||
219 | text: { | | |||
220 | if (!Globals.inhibited) { | | |||
221 | return ""; | | |||
222 | } | | |||
223 | | ||||
224 | var inhibitedUntil = notificationSettings.notificationsInhibitedUntil; | | |||
225 | var inhibitedByApp = notificationSettings.notificationsInhibitedByApplication; | | |||
226 | var inhibitedByMirroredScreens = notificationSettings.inhibitNotificationsWhenScreensMirrored | | |||
227 | && notificationSettings.screensMirrored; | | |||
228 | | ||||
229 | var sections = []; | | |||
230 | | ||||
231 | // Show until time if valid but not if too far int he future | | |||
232 | if (!isNaN(inhibitedUntil.getTime()) && inhibitedUntil.getTime() - new Date().getTime() < 365 * 24 * 60 * 60 * 1000 /* 1 year*/) { | | |||
233 | sections.push(i18nc("Do not disturb until date", "Until %1", | | |||
234 | KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat))); | | |||
235 | } | | |||
236 | | ||||
237 | if (inhibitedByApp) { | | |||
238 | var inhibitionAppNames = notificationSettings.notificationInhibitionApplications; | | |||
239 | var inhibitionAppReasons = notificationSettings.notificationInhibitionReasons; | | |||
240 | | ||||
241 | for (var i = 0, length = inhibitionAppNames.length; i < length; ++i) { | | |||
242 | var name = inhibitionAppNames[i]; | | |||
243 | var reason = inhibitionAppReasons[i]; | | |||
244 | | ||||
245 | if (reason) { | | |||
246 | sections.push(i18nc("Do not disturb until app has finished (reason)", "While %1 is active (%2)", name, reason)); | | |||
247 | } else { | | |||
248 | sections.push(i18nc("Do not disturb until app has finished", "While %1 is active", name)); | | |||
249 | } | | |||
250 | } | | |||
251 | } | | |||
252 | | ||||
253 | if (inhibitedByMirroredScreens) { | | |||
254 | sections.push(i18nc("Do not disturb because external mirrored screens connected", "Screens are mirrored")) | | |||
255 | } | | |||
256 | | ||||
257 | return sections.join(" · "); | | |||
258 | } | | |||
259 | visible: text !== "" | | |||
260 | } | | |||
261 | } | | |||
262 | | ||||
263 | PlasmaCore.SvgItem { | | |||
264 | visible: header.visible | | |||
265 | elementId: "horizontal-line" | | |||
266 | Layout.fillWidth: true | | |||
267 | // why is this needed here but not in the delegate? | | |||
268 | Layout.preferredHeight: naturalSize.height | | |||
269 | svg: PlasmaCore.Svg { | | |||
270 | id: lineSvg | | |||
271 | imagePath: "widgets/line" | | |||
272 | } | | |||
273 | } | | |||
274 | | ||||
275 | // actual notifications | 68 | // actual notifications | ||
276 | PlasmaExtras.ScrollArea { | 69 | PlasmaExtras.ScrollArea { | ||
277 | Layout.fillWidth: true | 70 | Layout.fillWidth: true | ||
278 | Layout.fillHeight: true | 71 | Layout.fillHeight: true | ||
279 | Layout.preferredWidth: units.gridUnit * 18 | 72 | Layout.preferredWidth: units.gridUnit * 18 | ||
280 | Layout.preferredHeight: units.gridUnit * 24 | 73 | Layout.preferredHeight: units.gridUnit * 24 | ||
281 | 74 | | |||
282 | ListView { | 75 | ListView { | ||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Line(s) | 412 | text: currentOwner ? i18nc("Vendor and product name", | |||
621 | currentOwner.vendor, | 414 | currentOwner.vendor, | ||
622 | currentOwner.name) | 415 | currentOwner.name) | ||
623 | : "" | 416 | : "" | ||
624 | visible: currentOwner && currentOwner.vendor && currentOwner.name | 417 | visible: currentOwner && currentOwner.vendor && currentOwner.name | ||
625 | } | 418 | } | ||
626 | } | 419 | } | ||
627 | } | 420 | } | ||
628 | } | 421 | } | ||
422 | | ||||
filipf: added row is fine but there are 4 spaces added here | |||||
423 | PlasmaCore.SvgItem { | ||||
424 | visible: footer.visible | ||||
425 | elementId: "horizontal-line" | ||||
426 | Layout.fillWidth: true | ||||
427 | // why is this needed here but not in the delegate? | ||||
428 | Layout.preferredHeight: naturalSize.height | ||||
429 | svg: PlasmaCore.Svg { | ||||
430 | id: lineSvg | ||||
431 | imagePath: "widgets/line" | ||||
432 | } | ||||
433 | } | ||||
434 | | ||||
435 | // footer | ||||
436 | ColumnLayout { | ||||
437 | id: footer | ||||
438 | visible: !Kirigami.Settings.isMobile | ||||
439 | Layout.fillWidth: true | ||||
440 | spacing: 0 | ||||
441 | | ||||
442 | RowLayout { | ||||
443 | Layout.fillWidth: true | ||||
444 | spacing: 0 | ||||
445 | | ||||
446 | RowLayout { | ||||
447 | id: dndRow | ||||
448 | spacing: units.smallSpacing | ||||
449 | enabled: NotificationManager.Server.valid | ||||
450 | | ||||
451 | PlasmaComponents3.CheckBox { | ||||
452 | id: dndCheck | ||||
453 | text: i18n("Do not disturb") | ||||
454 | spacing: units.smallSpacing | ||||
455 | checkable: true | ||||
456 | checked: Globals.inhibited | ||||
457 | | ||||
458 | // Let the menu open on press | ||||
459 | onPressed: { | ||||
460 | if (!Globals.inhibited) { | ||||
461 | dndMenu.date = new Date(); | ||||
462 | // shows ontop of CheckBox to hide the fact that it's unchecked | ||||
463 | // until you actually select something :) | ||||
464 | dndMenu.open(0, 0); | ||||
broulik: The menu placement is quite odd now, it should open upwards. | |||||
465 | } | ||||
466 | } | ||||
467 | // but disable only on click | ||||
468 | onClicked: { | ||||
469 | if (Globals.inhibited) { | ||||
470 | Globals.revokeInhibitions(); | ||||
471 | } | ||||
472 | } | ||||
473 | | ||||
474 | contentItem: RowLayout { | ||||
475 | spacing: dndCheck.spacing | ||||
476 | | ||||
477 | PlasmaCore.IconItem { | ||||
478 | Layout.leftMargin: dndCheck.mirrored ? 0 : dndCheck.indicator.width + dndCheck.spacing | ||||
479 | Layout.rightMargin: dndCheck.mirrored ? dndCheck.indicator.width + dndCheck.spacing : 0 | ||||
480 | source: "notifications-disabled" | ||||
481 | Layout.preferredWidth: units.iconSizes.smallMedium | ||||
482 | Layout.preferredHeight: units.iconSizes.smallMedium | ||||
483 | } | ||||
484 | | ||||
485 | PlasmaComponents.Label { | ||||
486 | text: i18n("Do not disturb") | ||||
487 | } | ||||
488 | } | ||||
489 | | ||||
490 | PlasmaComponents.ModelContextMenu { | ||||
491 | id: dndMenu | ||||
492 | property date date | ||||
493 | visualParent: dndCheck | ||||
494 | | ||||
495 | onClicked: { | ||||
496 | notificationSettings.notificationsInhibitedUntil = model.date; | ||||
497 | notificationSettings.save(); | ||||
498 | } | ||||
499 | | ||||
500 | model: { | ||||
501 | var model = []; | ||||
502 | | ||||
503 | // For 1 hour | ||||
504 | var d = dndMenu.date; | ||||
505 | d.setHours(d.getHours() + 1); | ||||
506 | d.setSeconds(0); | ||||
507 | model.push({date: d, text: i18n("For 1 hour")}); | ||||
508 | | ||||
509 | d = dndMenu.date; | ||||
510 | d.setHours(d.getHours() + 4); | ||||
511 | d.setSeconds(0); | ||||
512 | model.push({date: d, text: i18n("For 4 hours")}); | ||||
513 | | ||||
514 | // Until this evening | ||||
515 | if (dndMenu.date.getHours() < dndEveningHour) { | ||||
516 | d = dndMenu.date; | ||||
517 | // TODO make the user's preferred time schedule configurable | ||||
518 | d.setHours(dndEveningHour); | ||||
519 | d.setMinutes(0); | ||||
520 | d.setSeconds(0); | ||||
521 | model.push({date: d, text: i18n("Until this evening")}); | ||||
522 | } | ||||
523 | | ||||
524 | // Until next morning | ||||
525 | if (dndMenu.date.getHours() > dndMorningHour) { | ||||
526 | d = dndMenu.date; | ||||
527 | d.setDate(d.getDate() + 1); | ||||
528 | d.setHours(dndMorningHour); | ||||
529 | d.setMinutes(0); | ||||
530 | d.setSeconds(0); | ||||
531 | model.push({date: d, text: i18n("Until tomorrow morning")}); | ||||
532 | } | ||||
533 | | ||||
534 | // Until Monday | ||||
535 | // show Friday and Saturday, Sunday is "0" but for that you can use "until tomorrow morning" | ||||
536 | if (dndMenu.date.getDay() >= 5) { | ||||
537 | d = dndMenu.date; | ||||
538 | d.setHours(dndMorningHour); | ||||
539 | // wraps around if necessary | ||||
540 | d.setDate(d.getDate() + (7 - d.getDay() + 1)); | ||||
541 | d.setMinutes(0); | ||||
542 | d.setSeconds(0); | ||||
543 | model.push({date: d, text: i18n("Until Monday")}); | ||||
544 | } | ||||
545 | | ||||
546 | // Until "turned off" | ||||
547 | d = dndMenu.date; | ||||
548 | // Just set it to one year in the future so we don't need yet another "do not disturb enabled" property | ||||
549 | d.setFullYear(d.getFullYear() + 1); | ||||
550 | model.push({date: d, text: i18n("Until turned off")}); | ||||
551 | | ||||
552 | return model; | ||||
553 | } | ||||
554 | } | ||||
555 | } | ||||
556 | } | ||||
557 | | ||||
558 | Item { | ||||
559 | Layout.fillWidth: true | ||||
560 | } | ||||
561 | | ||||
562 | PlasmaComponents.ToolButton { | ||||
563 | iconName: "configure" | ||||
564 | // remove mnemonics | ||||
565 | tooltip: plasmoid.action("openKcm").text.replace(/([^&]*)&(.)([^&]*)/g, function (match, p1, p2, p3) { | ||||
566 | return p1.concat(p2, p3); | ||||
567 | }); | ||||
568 | visible: plasmoid.action("openKcm").enabled | ||||
569 | onClicked: plasmoid.action("openKcm").trigger() | ||||
570 | } | ||||
571 | | ||||
572 | PlasmaComponents.ToolButton { | ||||
573 | iconName: "edit-clear-history" | ||||
574 | tooltip: i18n("Clear History") | ||||
575 | enabled: plasmoid.action("clearHistory").visible | ||||
576 | onClicked: action_clearHistory() | ||||
577 | } | ||||
578 | } | ||||
579 | | ||||
580 | PlasmaExtras.DescriptiveLabel { | ||||
581 | Layout.leftMargin: dndCheck.mirrored ? 0 : dndCheck.indicator.width + 2 * dndCheck.spacing + units.iconSizes.smallMedium | ||||
582 | Layout.rightMargin: dndCheck.mirrored ? dndCheck.indicator.width + 2 * dndCheck.spacing + units.iconSizes.smallMedium : 0 | ||||
583 | Layout.fillWidth: true | ||||
584 | wrapMode: Text.WordWrap | ||||
585 | textFormat: Text.PlainText | ||||
586 | text: { | ||||
587 | if (!Globals.inhibited) { | ||||
588 | return ""; | ||||
589 | } | ||||
590 | | ||||
591 | var inhibitedUntil = notificationSettings.notificationsInhibitedUntil; | ||||
592 | var inhibitedByApp = notificationSettings.notificationsInhibitedByApplication; | ||||
593 | var inhibitedByMirroredScreens = notificationSettings.inhibitNotificationsWhenScreensMirrored | ||||
594 | && notificationSettings.screensMirrored; | ||||
595 | | ||||
596 | var sections = []; | ||||
597 | | ||||
598 | // Show until time if valid but not if too far int he future | ||||
599 | if (!isNaN(inhibitedUntil.getTime()) && inhibitedUntil.getTime() - new Date().getTime() < 365 * 24 * 60 * 60 * 1000 /* 1 year*/) { | ||||
600 | sections.push(i18nc("Do not disturb until date", "Until %1", | ||||
601 | KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat))); | ||||
602 | } | ||||
603 | | ||||
604 | if (inhibitedByApp) { | ||||
605 | var inhibitionAppNames = notificationSettings.notificationInhibitionApplications; | ||||
606 | var inhibitionAppReasons = notificationSettings.notificationInhibitionReasons; | ||||
607 | | ||||
608 | for (var i = 0, length = inhibitionAppNames.length; i < length; ++i) { | ||||
609 | var name = inhibitionAppNames[i]; | ||||
610 | var reason = inhibitionAppReasons[i]; | ||||
611 | | ||||
612 | if (reason) { | ||||
613 | sections.push(i18nc("Do not disturb until app has finished (reason)", "While %1 is active (%2)", name, reason)); | ||||
614 | } else { | ||||
615 | sections.push(i18nc("Do not disturb until app has finished", "While %1 is active", name)); | ||||
616 | } | ||||
617 | } | ||||
618 | } | ||||
619 | | ||||
620 | if (inhibitedByMirroredScreens) { | ||||
621 | sections.push(i18nc("Do not disturb because external mirrored screens connected", "Screens are mirrored")) | ||||
622 | } | ||||
623 | | ||||
624 | return sections.join(" · "); | ||||
625 | } | ||||
626 | visible: text !== "" | ||||
627 | } | ||||
628 | } | ||||
629 | } | 629 | } |
added row is fine but there are 4 spaces added here