Progress indicator is now visible right after SettingsDlg is opened
authorJari Jarvi <t7jaja00@students.oamk.fi>
Tue, 6 Jul 2010 09:57:52 +0000 (12:57 +0300)
committerJari Jarvi <t7jaja00@students.oamk.fi>
Tue, 6 Jul 2010 09:57:52 +0000 (12:57 +0300)
src/settingsdlg.cpp
src/settingsdlg.h

index 8755529..6100100 100644 (file)
 #include <QLabel>
 #include <QDebug>
 #include <QNetworkConfiguration>
+#include <QShowEvent>
 
 SettingsDlg::SettingsDlg(QWidget *parent)
     : QDialog(parent)
+    , m_busy(true)
 {
     QSettings settings(this);
     m_layout = new QVBoxLayout(this);
@@ -70,6 +72,8 @@ SettingsDlg::SettingsDlg(QWidget *parent)
         // Create remote by name and update it's info if online
         m_remote = Remote(selectedRemote);
         m_remoteNameLabel->setText(selectedRemote);
+        connect(&m_remote, SIGNAL(infoUpdated()),
+            this, SLOT(updateRemoteInfo()));
         m_netConfMan = new QTM_PREPEND_NAMESPACE(
                 QNetworkConfigurationManager)(this);
         connect(m_netConfMan, SIGNAL(updateCompleted()),
@@ -97,7 +101,7 @@ SettingsDlg::~SettingsDlg()
 void SettingsDlg::setBusy(bool busy)
 {
     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy);
-    setEnabled(!busy);
+    m_busy = busy;
 }
 
 void SettingsDlg::showAdvSettingsDlg()
@@ -124,6 +128,8 @@ void SettingsDlg::showAboutDlg()
 void SettingsDlg::setRemote(Remote r)
 {
     m_remote = r;
+    connect(&m_remote, SIGNAL(infoUpdated()),
+            this, SLOT(updateRemoteInfo()));
     updateRemoteInfo();
     enableRateBtns();
 }
@@ -131,13 +137,11 @@ void SettingsDlg::setRemote(Remote r)
 void SettingsDlg::onNetworkStatusUpdate()
 {
     if (m_netConfMan->isOnline()) {
-        setBusy();
-        connect(&m_remote, SIGNAL(infoUpdated()),
-                this, SLOT(updateRemoteInfo()));
         m_remote.updateInfo();
         enableRateBtns();
     } else {
         m_ratingLabel->setText(tr("Offline"));
+        setBusy(false);
     }
 }
 
@@ -163,6 +167,7 @@ void SettingsDlg::rateDownClicked()
 
 void SettingsDlg::processRatingSent()
 {
+    setBusy();
     enableRateBtns(false);
     m_remote.updateInfo();
 }
@@ -173,4 +178,11 @@ void SettingsDlg::enableRateBtns(bool enable)
     m_rateDownBtn->setEnabled(enable);
 }
 
+void SettingsDlg::showEvent(QShowEvent *event)
+{
+    setBusy(m_busy);
+    QDialog::showEvent(event);
+}
+
+
 
index 78c72f6..09cda7a 100644 (file)
@@ -20,6 +20,7 @@ class SettingsDlg : public QDialog
 public:
     SettingsDlg(QWidget *parent = 0);
     ~SettingsDlg();
+    void showEvent(class QShowEvent *);
 
 private slots:
     void showAdvSettingsDlg();
@@ -37,6 +38,7 @@ private:
     void setBusy(bool busy = true);
 
 private:
+    bool m_busy;
     Remote m_remote;
 
     QVBoxLayout *m_layout;