[Pkg-owncloud-commits] [owncloud-client] 135/470: Notifications: Do a GUI tray notification if new notifciations arrive.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:24:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 903e79a7c4023c6f28377d5323b2401cea0cae92
Author: Klaas Freitag <freitag at owncloud.com>
Date: Thu Mar 10 14:49:31 2016 +0100
Notifications: Do a GUI tray notification if new notifciations arrive.
Show a GUI notification once an hour if no new notifications arrive
to not annoy users.
---
src/gui/activitywidget.cpp | 23 +++++++++++++++++++++++
src/gui/activitywidget.h | 3 +++
2 files changed, 26 insertions(+)
diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index 2a1fb7e..191cb29 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -478,6 +478,7 @@ void ActivityWidget::slotNotificationsReceived(const QVariantMap& json, int stat
qDebug() << "Notifications for " << ai->account()->displayName() << notifies;
ActivityList list;
+ int newGuiLogs = 0;
foreach( auto element, notifies ) {
Activity a;
@@ -506,10 +507,31 @@ void ActivityWidget::slotNotificationsReceived(const QVariantMap& json, int stat
a._links.append(al);
}
+ // handle gui logs. In order to NOT annoy the user with every fetching of the
+ // notifications the notification id is stored in a Set. Only if an id
+ // is not in the set, it qualifies for guiLog.
+ // Important: The _guiLoggedNotifications set must be wiped regularly which
+ // will repeat the gui log.
+
+ // after one hour, clear the gui log notification store
+ if( _guiLogTimer.elapsed() > 60*1000 ) {
+ _guiLoggedNotifications.clear();
+ }
+ if( !_guiLoggedNotifications.contains(a._id)) {
+ newGuiLogs++;
+ _guiLoggedNotifications.insert(a._id);
+ }
list.append(a);
}
emit newNotificationList( list );
+ if( newGuiLogs > 0 ) {
+ // restart the gui log timer now that we show a notification
+ _guiLogTimer.restart();
+
+ emit guiLog(tr("Notifications - Action Required"),
+ tr("You received %n new notification(s) from the server!", "", newGuiLogs));
+ }
_notificationJob->deleteLater();
_notificationJob = 0;
}
@@ -615,6 +637,7 @@ ActivitySettings::ActivitySettings(QWidget *parent)
_activityTabId = _tab->insertTab(0, _activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
connect(_activityWidget, SIGNAL(hideAcitivityTab(bool)), this, SLOT(setActivityTabHidden(bool)));
+ connect(_activityWidget, SIGNAL(guiLog(QString,QString)), this, SIGNAL(guiLog(QString,QString)));
_protocolWidget = new ProtocolWidget(this);
_tab->insertTab(1, _protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
diff --git a/src/gui/activitywidget.h b/src/gui/activitywidget.h
index 7ad8c99..44b4a17 100644
--- a/src/gui/activitywidget.h
+++ b/src/gui/activitywidget.h
@@ -199,6 +199,9 @@ private:
QPointer<JsonApiJob> _notificationJob;
ActivityListModel *_model;
QVBoxLayout *_notificationsLayout;
+
+ QElapsedTimer _guiLogTimer;
+ QSet<int> _guiLoggedNotifications;
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list