On Donnerstag, 18. Dezember 2014 10:42:04 CEST, Pali Rohár wrote:

I do not know if 500ms is enough for me (when updating about 40 imap folders), but if you can provide easy/small patch I can test it what happens...

It's not a very complex patch.
Given your concerns and a personal flavor, I raised the dealy a bit, though ;-)

Notice that Jan terribly hates lazy members and thus likely local statics as well, I just wanted to keep the patch as local as possible.

Cheers,
Thomas
diff --git a/src/Gui/TaskProgressIndicator.cpp b/src/Gui/TaskProgressIndicator.cpp
index da32e87..81deeab 100644
--- a/src/Gui/TaskProgressIndicator.cpp
+++ b/src/Gui/TaskProgressIndicator.cpp
@@ -23,6 +23,7 @@
 #include "TaskProgressIndicator.h"
 #include <QApplication>
 #include <QMouseEvent>
+#include <QTimer>
 #include "Imap/Model/Model.h"
 #include "Imap/Model/VisibleTasksModel.h"
 
@@ -54,12 +55,22 @@ void TaskProgressIndicator::updateActivityIndication()
     if (!m_visibleTasksModel)
         return;
 
+    static QTimer *busyCursorTrigger = 0;
+    if (!busyCursorTrigger) {
+        busyCursorTrigger = new QTimer(this);
+        connect(busyCursorTrigger, SIGNAL(timeout()), SLOT(setCursorBusy()));
+        busyCursorTrigger->setSingleShot(true);
+        busyCursorTrigger->setInterval(2*333);
+    }
     bool busy = m_visibleTasksModel->hasChildren();
     setVisible(busy);
     if (!m_busy && busy) {
-        QApplication::setOverrideCursor(Qt::WaitCursor);
+        if (!busyCursorTrigger->isActive())
+            busyCursorTrigger->start(); // do NOT restart, we don't want to prolong this delay
     } else if (m_busy && !busy) {
-        QApplication::restoreOverrideCursor();
+        if (!busyCursorTrigger->isActive()) // don't restore unless we've alredy set it
+            QApplication::restoreOverrideCursor();
+        busyCursorTrigger->stop(); // don't cause future timeout
     }
 
     if (busy) {
@@ -71,6 +82,10 @@ void TaskProgressIndicator::updateActivityIndication()
     m_busy = busy;
 }
 
+void TaskProgressIndicator::setCursorBusy() {
+    QApplication::setOverrideCursor(Qt::BusyCursor);
+}
+
 /** @short Reimplemented from QProgressBar for launching the pop-up widgets with detailed activity */
 void TaskProgressIndicator::mousePressEvent(QMouseEvent *event)
 {
diff --git a/src/Gui/TaskProgressIndicator.h b/src/Gui/TaskProgressIndicator.h
index 49640c5..10664ac 100644
--- a/src/Gui/TaskProgressIndicator.h
+++ b/src/Gui/TaskProgressIndicator.h
@@ -53,6 +53,9 @@ public slots:
 protected:
     void mousePressEvent(QMouseEvent *event);
 
+private slots:
+    void setCursorBusy();
+
 private:
     /** @short Model for a list of "visible tasks" */
     QPointer<Imap::Mailbox::VisibleTasksModel> m_visibleTasksModel;

Reply via email to