[Pkg-owncloud-commits] [owncloud-client] 327/470: Activity tab visibility fixes #4651

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:25:21 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 dfd7d4d2f9360f55b471e47487c704203fa17020
Author: Christian Kamm <mail at ckamm.de>
Date:   Thu Apr 14 11:35:16 2016 +0200

    Activity tab visibility fixes #4651
---
 src/gui/activitywidget.cpp | 46 +++++++++++++++++++++++++---------------------
 src/gui/activitywidget.h   |  8 ++++++++
 2 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index 3f9b748..f342102 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -158,16 +158,7 @@ void ActivityWidget::slotAccountActivityStatus(AccountState *ast, int statusCode
         _accountsWithoutActivities.remove(ast->account()->displayName());
     }
 
-    int accountCount = AccountManager::instance()->accounts().count();
-
-    // hide the activity pane in case there are no accounts enabled.
-    if( _accountsWithoutActivities.count() == accountCount ) {
-        _ui->_headerLabel->hide();
-        _ui->_activityList->hide();
-    }
-    emit hideActivityTab(_accountsWithoutActivities.count() == accountCount
-                          && _widgetForNotifId.count() == 0 ); // do not hide if there are notifications
-
+    checkActivityTabVisibility();
     showLabels();
 }
 
@@ -220,6 +211,22 @@ void ActivityWidget::storeActivityList( QTextStream& ts )
     }
 }
 
+void ActivityWidget::checkActivityTabVisibility()
+{
+    int accountCount = AccountManager::instance()->accounts().count();
+    bool hasAccountsWithActivity =
+            _accountsWithoutActivities.count() != accountCount;
+    bool hasNotifications = !_widgetForNotifId.isEmpty();
+
+    _ui->_headerLabel->setVisible( hasAccountsWithActivity );
+    _ui->_activityList->setVisible( hasAccountsWithActivity );
+
+    _ui->_notifyLabel->setVisible( hasNotifications );
+    _ui->_notifyScroll->setVisible( hasNotifications );
+
+    emit hideActivityTab(!hasAccountsWithActivity && !hasNotifications);
+}
+
 void ActivityWidget::slotOpenFile(QModelIndex indx)
 {
     qDebug() << Q_FUNC_INFO << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
@@ -332,10 +339,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
         scheduleWidgetToRemove(widgetToGo, 0);
     }
 
-    emit hideActivityTab(false);
-
-    _ui->_notifyLabel->setHidden(  _widgetForNotifId.isEmpty() );
-    _ui->_notifyScroll->setHidden( _widgetForNotifId.isEmpty() );
+    checkActivityTabVisibility();
 
     int newGuiLogCount = accNotified.count();
 
@@ -611,7 +615,11 @@ void ActivitySettings::slotRemoveAccount( AccountState *ptr )
 
 void ActivitySettings::slotRefresh( AccountState* ptr )
 {
-    QElapsedTimer timer = _timeSinceLastCheck[ptr];
+    // QElapsedTimer isn't actually constructed as invalid.
+    if ( !_timeSinceLastCheck.contains(ptr) ) {
+        _timeSinceLastCheck[ptr].invalidate();
+    }
+    QElapsedTimer & timer = _timeSinceLastCheck[ptr];
 
     // Fetch Activities only if visible and if last check is longer than 15 secs ago
     if( timer.isValid() && timer.elapsed() < NOTIFICATION_REQUEST_FREE_PERIOD ) {
@@ -619,16 +627,12 @@ void ActivitySettings::slotRefresh( AccountState* ptr )
         return;
     }
     if( ptr && ptr->isConnected() ) {
-        if( isVisible() ) {
+        if( isVisible() || !timer.isValid() ) {
             _progressIndicator->startAnimation();
             _activityWidget->slotRefreshActivities( ptr);
         }
         _activityWidget->slotRefreshNotifications(ptr);
-        if( !( _timeSinceLastCheck[ptr].isValid() ) ) {
-            _timeSinceLastCheck[ptr].start();
-        } else {
-            _timeSinceLastCheck[ptr].restart();
-        }
+        timer.start();
     }
 }
 
diff --git a/src/gui/activitywidget.h b/src/gui/activitywidget.h
index efee263..f8818b5 100644
--- a/src/gui/activitywidget.h
+++ b/src/gui/activitywidget.h
@@ -60,6 +60,14 @@ public:
     QSize sizeHint() const Q_DECL_OVERRIDE { return ownCloudGui::settingsDialogSize(); }
     void storeActivityList(QTextStream &ts);
 
+    /**
+     * Adjusts the activity tab's and some widgets' visibility
+     *
+     * Based on whether activities are enabled and whether notifications are
+     * available.
+     */
+    void checkActivityTabVisibility();
+
 public slots:
     void slotOpenFile(QModelIndex indx);
     void slotRefreshActivities(AccountState* ptr);

-- 
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