Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/FullRepresentation.qml
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.10 | 21 | import QtQuick 2.8 | ||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | 23 | | |||
24 | import org.kde.plasma.plasmoid 2.0 | 24 | import org.kde.plasma.plasmoid 2.0 | ||
25 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
26 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
27 | import org.kde.plasma.components 3.0 as PlasmaComponents3 | 27 | import org.kde.plasma.components 3.0 as PlasmaComponents3 | ||
28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
29 | import org.kde.kirigami 2.11 as Kirigami | | |||
30 | 29 | | |||
31 | import org.kde.kcoreaddons 1.0 as KCoreAddons | 30 | import org.kde.kcoreaddons 1.0 as KCoreAddons | ||
32 | 31 | | |||
33 | import org.kde.notificationmanager 1.0 as NotificationManager | 32 | import org.kde.notificationmanager 1.0 as NotificationManager | ||
34 | 33 | | |||
35 | import "global" | 34 | import "global" | ||
36 | 35 | | |||
37 | ColumnLayout{ | 36 | ColumnLayout{ | ||
Show All 24 Lines | 60 | if (plasmoid.expanded) { | |||
62 | list.positionViewAtBeginning(); | 61 | list.positionViewAtBeginning(); | ||
63 | list.currentIndex = -1; | 62 | list.currentIndex = -1; | ||
64 | } | 63 | } | ||
65 | } | 64 | } | ||
66 | } | 65 | } | ||
67 | 66 | | |||
68 | // header | 67 | // header | ||
69 | ColumnLayout { | 68 | ColumnLayout { | ||
70 | id: header | | |||
71 | visible: !Kirigami.Settings.isMobile | | |||
72 | Layout.fillWidth: true | 69 | Layout.fillWidth: true | ||
70 | Layout.leftMargin: units.smallSpacing | ||||
73 | spacing: 0 | 71 | spacing: 0 | ||
74 | 72 | | |||
75 | RowLayout { | 73 | RowLayout { | ||
76 | Layout.fillWidth: true | 74 | Layout.fillWidth: true | ||
77 | spacing: 0 | 75 | spacing: 0 | ||
78 | 76 | | |||
79 | RowLayout { | 77 | RowLayout { | ||
80 | id: dndRow | 78 | id: dndRow | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 160 | if (dndMenu.date.getHours() > dndMorningHour) { | |||
168 | model.push({date: d, text: i18n("Until tomorrow morning")}); | 166 | model.push({date: d, text: i18n("Until tomorrow morning")}); | ||
169 | } | 167 | } | ||
170 | 168 | | |||
171 | // Until Monday | 169 | // Until Monday | ||
172 | // show Friday and Saturday, Sunday is "0" but for that you can use "until tomorrow morning" | 170 | // show Friday and Saturday, Sunday is "0" but for that you can use "until tomorrow morning" | ||
173 | if (dndMenu.date.getDay() >= 5) { | 171 | if (dndMenu.date.getDay() >= 5) { | ||
174 | d = dndMenu.date; | 172 | d = dndMenu.date; | ||
175 | d.setHours(dndMorningHour); | 173 | d.setHours(dndMorningHour); | ||
176 | // wraps around if necessary | 174 | // wraps around if neccessary | ||
177 | d.setDate(d.getDate() + (7 - d.getDay() + 1)); | 175 | d.setDate(d.getDate() + (7 - d.getDay() + 1)); | ||
178 | d.setMinutes(0); | 176 | d.setMinutes(0); | ||
179 | d.setSeconds(0); | 177 | d.setSeconds(0); | ||
180 | model.push({date: d, text: i18n("Until Monday")}); | 178 | model.push({date: d, text: i18n("Until Monday")}); | ||
181 | } | 179 | } | ||
182 | 180 | | |||
183 | // Until "turned off" | 181 | // Until "turned off" | ||
184 | d = dndMenu.date; | 182 | d = dndMenu.date; | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 221 | text: { | |||
260 | 258 | | |||
261 | return sections.join(" · "); | 259 | return sections.join(" · "); | ||
262 | } | 260 | } | ||
263 | visible: text !== "" | 261 | visible: text !== "" | ||
264 | } | 262 | } | ||
265 | } | 263 | } | ||
266 | 264 | | |||
267 | PlasmaCore.SvgItem { | 265 | PlasmaCore.SvgItem { | ||
268 | visible: header.visible | | |||
269 | elementId: "horizontal-line" | 266 | elementId: "horizontal-line" | ||
270 | Layout.fillWidth: true | 267 | Layout.fillWidth: true | ||
271 | // why is this needed here but not in the delegate? | 268 | // why is this needed here but not in the delegate? | ||
272 | Layout.preferredHeight: naturalSize.height | 269 | Layout.preferredHeight: naturalSize.height | ||
273 | svg: PlasmaCore.Svg { | 270 | svg: PlasmaCore.Svg { | ||
274 | id: lineSvg | 271 | id: lineSvg | ||
275 | imagePath: "widgets/line" | 272 | imagePath: "widgets/line" | ||
276 | } | 273 | } | ||
277 | } | 274 | } | ||
278 | 275 | | |||
279 | // actual notifications | 276 | // actual notifications | ||
280 | PlasmaExtras.ScrollArea { | 277 | PlasmaExtras.ScrollArea { | ||
281 | Layout.fillWidth: true | 278 | Layout.fillWidth: true | ||
282 | Layout.fillHeight: true | 279 | Layout.fillHeight: true | ||
283 | Layout.preferredWidth: units.gridUnit * 18 | 280 | Layout.preferredWidth: units.gridUnit * 18 | ||
284 | Layout.preferredHeight: units.gridUnit * 24 | 281 | Layout.preferredHeight: units.gridUnit * 24 | ||
282 | Layout.leftMargin: units.smallSpacing | ||||
285 | 283 | | |||
286 | ListView { | 284 | ListView { | ||
287 | id: list | 285 | id: list | ||
288 | model: historyModel | 286 | model: historyModel | ||
289 | currentIndex: -1 | 287 | currentIndex: -1 | ||
290 | 288 | | |||
291 | Keys.onDeletePressed: { | 289 | Keys.onDeletePressed: { | ||
292 | var idx = historyModel.index(currentIndex, 0); | 290 | var idx = historyModel.index(currentIndex, 0); | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 362 | SequentialAnimation { | |||
370 | } | 368 | } | ||
371 | } | 369 | } | ||
372 | } | 370 | } | ||
373 | addDisplaced: Transition { | 371 | addDisplaced: Transition { | ||
374 | NumberAnimation { properties: "y"; duration: units.longDuration } | 372 | NumberAnimation { properties: "y"; duration: units.longDuration } | ||
375 | } | 373 | } | ||
376 | 374 | | |||
377 | remove: Transition { | 375 | remove: Transition { | ||
378 | id: removeTransition | | |||
379 | ParallelAnimation { | 376 | ParallelAnimation { | ||
380 | NumberAnimation { property: "opacity"; to: 0; duration: units.longDuration } | 377 | NumberAnimation { property: "opacity"; to: 0; duration: units.longDuration } | ||
381 | NumberAnimation { | 378 | NumberAnimation { property: "x"; to: list.width; duration: units.longDuration } | ||
382 | property: "x" | | |||
383 | to: removeTransition.ViewTransition.item.x >= 0 ? list.width : -list.width | | |||
384 | duration: units.longDuration | | |||
385 | } | | |||
386 | } | 379 | } | ||
387 | } | 380 | } | ||
388 | removeDisplaced: Transition { | 381 | removeDisplaced: Transition { | ||
389 | SequentialAnimation { | 382 | SequentialAnimation { | ||
390 | PauseAnimation { duration: units.longDuration } | 383 | PauseAnimation { duration: units.longDuration } | ||
391 | NumberAnimation { properties: "y"; duration: units.longDuration } | 384 | NumberAnimation { properties: "y"; duration: units.longDuration } | ||
392 | } | 385 | } | ||
393 | } | 386 | } | ||
394 | 387 | | |||
395 | // This is so the delegates can detect the change in "isInGroup" and show a separator | 388 | // This is so the delegates can detect the change in "isInGroup" and show a separator | ||
396 | section { | 389 | section { | ||
397 | property: "isInGroup" | 390 | property: "isInGroup" | ||
398 | criteria: ViewSection.FullString | 391 | criteria: ViewSection.FullString | ||
399 | } | 392 | } | ||
400 | 393 | | |||
401 | delegate: DraggableDelegate { | 394 | delegate: Loader { | ||
402 | width: list.width | | |||
403 | contentItem: delegateLoader | | |||
404 | | ||||
405 | draggable: !model.isGroup && model.type != NotificationManager.Notifications.JobType | | |||
406 | | ||||
407 | onDismissRequested: historyModel.close(historyModel.index(index, 0)); | | |||
408 | | ||||
409 | Loader { | | |||
410 | id: delegateLoader | 395 | id: delegateLoader | ||
411 | width: list.width | 396 | width: list.width | ||
412 | sourceComponent: model.isGroup ? groupDelegate : notificationDelegate | 397 | sourceComponent: model.isGroup ? groupDelegate : notificationDelegate | ||
413 | 398 | | |||
414 | Component { | 399 | Component { | ||
415 | id: groupDelegate | 400 | id: groupDelegate | ||
416 | NotificationHeader { | 401 | NotificationHeader { | ||
417 | applicationName: model.applicationName | 402 | applicationName: model.applicationName | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 549 | PlasmaCore.SvgItem { | |||
569 | 554 | | |||
570 | // property is only atached to the delegate itself (the Loader in our case) | 555 | // property is only atached to the delegate itself (the Loader in our case) | ||
571 | visible: (!model.isInGroup || delegateLoader.ListView.nextSection !== delegateLoader.ListView.section) | 556 | visible: (!model.isInGroup || delegateLoader.ListView.nextSection !== delegateLoader.ListView.section) | ||
572 | && delegateLoader.ListView.nextSection !== "" // don't show after last item | 557 | && delegateLoader.ListView.nextSection !== "" // don't show after last item | ||
573 | } | 558 | } | ||
574 | } | 559 | } | ||
575 | } | 560 | } | ||
576 | } | 561 | } | ||
577 | } | | |||
578 | 562 | | |||
579 | PlasmaExtras.Heading { | 563 | PlasmaExtras.Heading { | ||
580 | width: list.width | 564 | width: list.width | ||
581 | height: list.height | | |||
582 | horizontalAlignment: Kirigami.Settings.isMobile ? Text.AlignHCenter : Text.AlignLeft | | |||
583 | verticalAlignment: Kirigami.Settings.isMobile ? Text.AlignVCenter : Text.AlignTop | | |||
584 | wrapMode: Text.WordWrap | | |||
585 | level: 3 | 565 | level: 3 | ||
586 | opacity: 0.6 | 566 | opacity: 0.6 | ||
587 | text: i18n("No unread notifications.") | 567 | text: i18n("No unread notifications.") | ||
588 | visible: list.count === 0 | 568 | visible: list.count === 0 | ||
589 | } | 569 | } | ||
590 | } | 570 | } | ||
591 | } | 571 | } | ||
592 | } | 572 | } |