Unity 8
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.4
18 import Ubuntu.Components 1.3
19 import Unity.Notifications 1.0 as UnityNotifications
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 > 1 // placeholder is index 0
30  property real margin
31  property bool hasMouse
32  property url background: ""
33 
34  readonly property bool useModal: snapDecisionProxyModel.count > 0
35 
36  UnitySortFilterProxyModel {
37  id: snapDecisionProxyModel
38  objectName: "snapDecisionProxyModel"
39 
40  model: notificationList.model ? notificationList.model : null
41  filterRole: UnityNotifications.ModelInterface != undefined ? UnityNotifications.ModelInterface.RoleType : 0
42  filterRegExp: RegExp(UnityNotifications.Notification.SnapDecision)
43  }
44 
45  readonly property bool topmostIsFullscreen: fullscreenIndex != -1
46  spacing: topmostIsFullscreen ? 0 : units.gu(1)
47 
48  currentIndex: count > 1 ? 1 : -1
49 
50  property int fullscreenIndex: -1
51  onFullscreenIndexChanged: {
52  if (fullscreenIndex != -1) {
53  positionViewAtIndex(fullscreenIndex, ListView.Beginning);
54  }
55  }
56 
57  delegate: Notification {
58  objectName: "notification" + index
59  width: parent.width
60  type: model.type
61  hints: model.hints
62  iconSource: model.icon
63  secondaryIconSource: model.secondaryIcon ? model.secondaryIcon : ""
64  summary: model.summary
65  body: model.body
66  value: model.value ? model.value : -1
67  actions: model.actions
68  notificationId: model.id
69  notification: notificationList.model.getRaw(notificationId)
70  maxHeight: notificationList.height
71  margins: notificationList.margin
72  hasMouse: notificationList.hasMouse
73  background: notificationList.background
74 
75  // make sure there's no opacity-difference between the several
76  // elements in a notification
77  // FIXME: disabled all transitions because of LP: #1354406 workaround
78  //layer.enabled: add.running || remove.running || populate.running
79 
80  onFullscreenChanged: updateListTopMostIsFullscreen();
81 
82  function updateListTopMostIsFullscreen() {
83  if (fullscreen) {
84  fullscreenIndex = index;
85  }
86  }
87 
88  onDismissed: {
89  if (fullscreenIndex == index) {
90  fullscreenIndex = -1;
91  notificationList.positionViewAtBeginning();
92  }
93  }
94  }
95 
96  // FIXME: disabled all transitions because of LP: #1354406 workaround
97  /*populate: Transition {
98  UbuntuNumberAnimation {
99  property: "opacity"
100  to: 1
101  duration: UbuntuAnimation.SnapDuration
102  }
103  }
104 
105  add: Transition {
106  UbuntuNumberAnimation {
107  property: "opacity"
108  to: 1
109  duration: UbuntuAnimation.SnapDuration
110  }
111  }
112 
113  remove: Transition {
114  UbuntuNumberAnimation {
115  property: "opacity"
116  to: 0
117  }
118  }
119 
120  displaced: Transition {
121  UbuntuNumberAnimation {
122  properties: "x,y"
123  duration: UbuntuAnimation.SnapDuration
124  }
125  }*/
126 }