Merge lp:~mterry/unity-notifications/allow-delays into lp:unity-notifications

Proposed by Michael Terry
Status: Work in progress
Proposed branch: lp:~mterry/unity-notifications/allow-delays
Merge into: lp:unity-notifications
Diff against target: 107 lines (+30/-4)
3 files modified
debian/changelog (+4/-0)
include/NotificationModel.h (+7/-0)
src/NotificationModel.cpp (+19/-4)
To merge this branch: bzr merge lp:~mterry/unity-notifications/allow-delays
Reviewer Review Type Date Requested Status
Unity API Team Pending
Review via email: mp+293411@code.launchpad.net

Commit message

WIP

Description of the change

WIP

To post a comment you must log in.

Unmerged revisions

238. By Michael Terry

Add paused property on the model

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-10-21 11:48:58 +0000
3+++ debian/changelog 2016-04-29 15:16:17 +0000
4@@ -1,3 +1,7 @@
5+unity-notifications (0.1.4+15.10.20151021-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ -- Michael Terry <mterry@ubuntu.com> Fri, 29 Apr 2016 17:10:09 +0200
8+
9 unity-notifications (0.1.3+15.10.20151021-0ubuntu1) wily; urgency=medium
10
11 [ Michal Sawicz ]
12
13=== modified file 'include/NotificationModel.h'
14--- include/NotificationModel.h 2015-10-12 15:21:27 +0000
15+++ include/NotificationModel.h 2016-04-29 15:16:17 +0000
16@@ -33,6 +33,9 @@
17 class NotificationModel : public QAbstractListModel {
18 Q_OBJECT
19
20+ // Set to true to queue non-snap, non-confirmation notifications until unset
21+ Q_PROPERTY(bool paused READ getPaused WRITE setPaused NOTIFY pausedChanged)
22+
23 public:
24 static const int maxNotifications = MAX_NOTIFICATIONS;
25 static const int maxSnapsShown = 5;
26@@ -65,12 +68,16 @@
27
28 void notificationUpdated(const NotificationID id);
29
30+ bool getPaused() const;
31+ void setPaused(bool paused);
32+
33 private Q_SLOTS:
34 void timeout();
35 void onDataChanged(unsigned int id);
36
37 Q_SIGNALS:
38 void queueSizeChanged(int newSize);
39+ void pausedChanged(bool paused);
40
41 private:
42 QScopedPointer<NotificationModelPrivate> p;
43
44=== modified file 'src/NotificationModel.cpp'
45--- src/NotificationModel.cpp 2015-10-13 13:49:02 +0000
46+++ src/NotificationModel.cpp 2016-04-29 15:16:17 +0000
47@@ -39,6 +39,7 @@
48 QVector<QSharedPointer<Notification> > interactiveQueue;
49 QVector<QSharedPointer<Notification> > snapQueue;
50 QMap<NotificationID, int> displayTimes;
51+ bool paused = false;
52 };
53
54 bool notificationCompare(const QSharedPointer<Notification> &first, const QSharedPointer<Notification> &second) {
55@@ -364,14 +365,14 @@
56
57 bool NotificationModel::nonSnapTimeout() {
58 bool restartTimer;
59- if(!showingNotificationOfType(Notification::Type::Interactive) && !p->interactiveQueue.empty()) {
60+ if(!p->paused && !showingNotificationOfType(Notification::Type::Interactive) && !p->interactiveQueue.empty()) {
61 QSharedPointer<Notification> n = p->interactiveQueue[0];
62 p->interactiveQueue.pop_front();
63 insertToVisible(n, insertionPoint(n));
64 restartTimer = true;
65 Q_EMIT queueSizeChanged(queued());
66 }
67- if(!showingNotificationOfType(Notification::Type::Ephemeral) && !p->ephemeralQueue.empty()) {
68+ if(!p->paused && !showingNotificationOfType(Notification::Type::Ephemeral) && !p->ephemeralQueue.empty()) {
69 QSharedPointer<Notification> n = p->ephemeralQueue[0];
70 p->ephemeralQueue.pop_front();
71 insertToVisible(n, insertionPoint(n));
72@@ -430,7 +431,7 @@
73 void NotificationModel::insertEphemeral(const QSharedPointer<Notification> &n) {
74 Q_ASSERT(n->getType() == Notification::Type::Ephemeral);
75
76- if(showingNotificationOfType(Notification::Type::SnapDecision)) {
77+ if(p->paused || showingNotificationOfType(Notification::Type::SnapDecision)) {
78 p->ephemeralQueue.push_back(n);
79 qStableSort(p->ephemeralQueue.begin(), p->ephemeralQueue.end(), notificationCompare);
80 Q_EMIT queueSizeChanged(queued());
81@@ -454,7 +455,7 @@
82 void NotificationModel::insertInteractive(const QSharedPointer<Notification> &n) {
83 Q_ASSERT(n->getType() == Notification::Type::Interactive);
84
85- if(showingNotificationOfType(Notification::Type::SnapDecision)) {
86+ if(p->paused || showingNotificationOfType(Notification::Type::SnapDecision)) {
87 p->interactiveQueue.push_back(n);
88 qStableSort(p->interactiveQueue.begin(), p->interactiveQueue.end(), notificationCompare);
89 Q_EMIT queueSizeChanged(queued());
90@@ -659,3 +660,17 @@
91 }
92 }
93 }
94+
95+bool NotificationModel::getPaused() const {
96+ return p->paused;
97+}
98+
99+void NotificationModel::setPaused(bool paused) {
100+ if (p->paused != paused) {
101+ p->paused = paused;
102+ Q_EMIT pausedChanged(paused);
103+ if (!p->paused) {
104+ timeout(); // trigger showing any queued notifications if needed
105+ }
106+ }
107+}

Subscribers

People subscribed via source and target branches

to all changes: