Added Progress indicator handling in error situations
[situare] / src / ui / mainwindow.cpp
index 5d54ec7..6050503 100644 (file)
@@ -55,6 +55,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_errorShown(false),
     m_loggedIn(false),
     m_refresh(false),
+    m_progressIndicatorCount(0),
     m_ownLocationCrosshair(0),
     m_email(),    
     m_password(),
@@ -669,9 +670,6 @@ void MainWindow::loginFailed()
     qDebug() << __PRETTY_FUNCTION__;
 
     clearCookieJar();
-
-    toggleProgressIndicator(false);
-
     startLoginProcess();
 }
 
@@ -899,7 +897,16 @@ void MainWindow::toggleProgressIndicator(bool value)
     qDebug() << __PRETTY_FUNCTION__;
 
 #ifdef Q_WS_MAEMO_5
-    setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
+    if(value) {
+        m_progressIndicatorCount++;
+        setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+    } else {
+        if(m_progressIndicatorCount > 0)
+            m_progressIndicatorCount--;
+
+        if(m_progressIndicatorCount == 0)
+            setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+    }
 #else
     Q_UNUSED(value);
 #endif // Q_WS_MAEMO_5
@@ -945,7 +952,6 @@ void MainWindow::webViewRequestFinished(QNetworkReply *reply)
     if(reply->error() != QNetworkReply::OperationCanceledError &&
        reply->error() != QNetworkReply::NoError) {
         emit error(reply->error());
-        toggleProgressIndicator(false);
     }
 }