Lomiri
Notifications.qml
1 /*
2  * Copyright (C) 2013-2016 Canonical Ltd.
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; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19 import Lomiri.Notifications 1.0 as LomiriNotifications
20 import Utils 0.1
21 import "../Components"
22 
23 ListView {
24  id: notificationList
25 
26  objectName: "notificationList"
27  interactive: false
28 
29  readonly property bool hasNotification: count > 0
30  property real margin
31  property bool hasMouse
32  property url background: ""
33  property bool privacyMode: false
34 
35  readonly property bool useModal: snapDecisionProxyModel.count > 0
36 
37  LomiriSortFilterProxyModel {
38  id: snapDecisionProxyModel
39  objectName: "snapDecisionProxyModel"
40 
41  model: notificationList.model ? notificationList.model : null
42  filterRole: LomiriNotifications.ModelInterface != undefined ? LomiriNotifications.ModelInterface.RoleType : 0
43  filterRegExp: RegExp(LomiriNotifications.Notification.SnapDecision)
44  }
45 
46  property bool topmostIsFullscreen: false
47  spacing: topmostIsFullscreen ? 0 : units.gu(1)
48 
49  currentIndex: -1
50 
51  delegate: Notification {
52  objectName: "notification" + index
53  width: parent.width
54  type: model.type
55  hints: model.hints
56  iconSource: model.icon
57  privacyMode: notificationList.privacyMode
58  secondaryIconSource: model.secondaryIcon ? model.secondaryIcon : ""
59  summary: model.summary
60  body: model.body
61  value: model.value ? model.value : -1
62  actions: model.actions
63  notificationId: model.id
64  notification: notificationList.model.getRaw(notificationId)
65  maxHeight: notificationList.height
66  margins: notificationList.margin
67  hasMouse: notificationList.hasMouse
68  background: notificationList.background
69 
70  Component.onCompleted: topmostIsFullscreen = false; // async, the factory loader will set fullscreen to true later
71 
72  property int theIndex: index
73  onTheIndexChanged: {
74  if (theIndex == 0) {
75  ListView.view.topmostIsFullscreen = fullscreen; // when we get pushed down by e.g. volume notification
76  }
77  }
78 
79  // make sure there's no opacity-difference between the several
80  // elements in a notification
81  // FIXME: disabled all transitions because of LP: #1354406 workaround
82  //layer.enabled: add.running || remove.running || populate.running
83  }
84 
85  onCountChanged: if (count == 0) topmostIsFullscreen = false; // reset
86 
87  // FIXME: disabled all transitions because of LP: #1354406 workaround
88  /*populate: Transition {
89  LomiriNumberAnimation {
90  property: "opacity"
91  to: 1
92  duration: LomiriAnimation.SnapDuration
93  }
94  }
95 
96  add: Transition {
97  LomiriNumberAnimation {
98  property: "opacity"
99  to: 1
100  duration: LomiriAnimation.SnapDuration
101  }
102  }
103 
104  remove: Transition {
105  LomiriNumberAnimation {
106  property: "opacity"
107  to: 0
108  }
109  }
110 
111  displaced: Transition {
112  LomiriNumberAnimation {
113  properties: "x,y"
114  duration: LomiriAnimation.SnapDuration
115  }
116  }*/
117 }