Remote mfg is saved to settings and it is visible immediately in the gui.
[irwi] / src / settingsdlg.cpp
index f7b4cfa..443c37b 100644 (file)
@@ -15,7 +15,7 @@
 
 SettingsDlg::SettingsDlg(QWidget *parent)
     : QDialog(parent)
-    , m_busy(false)
+    , m_busy(true)
     , m_netConfMan(NULL)
 {
     QSettings settings(this);
@@ -65,24 +65,23 @@ SettingsDlg::SettingsDlg(QWidget *parent)
     m_layout->addLayout(m_btnLayout);
     this->setLayout(m_layout);
 
-    QString selectedRemote = settings.value("remoteName", "").toString();
-    if (selectedRemote == "") {
+    QString remoteName = settings.value("remoteName", "").toString();
+    if (remoteName == "") {
         m_remoteNameLabel->setText(tr("No remote selected"));
-        enableRateBtns(false);
     } else {
         // Create remote by name and update it's info if online
-        m_busy = true;
-        m_remote = Remote(selectedRemote);
+        m_remote = Remote(remoteName);
         connect(&m_remote, SIGNAL(infoUpdated()),
                 this, SLOT(updateRemoteInfo()));
-        m_remoteNameLabel->setText(selectedRemote);
-        m_netConfMan = new QTM_PREPEND_NAMESPACE(
-                QNetworkConfigurationManager)(this);
-        connect(m_netConfMan, SIGNAL(updateCompleted()),
-                this, SLOT(onNetworkStatusUpdate()));
-        m_netConfMan->updateConfigurations();
-        enableRateBtns(false);
+        m_remoteNameLabel->setText(settings.value("remoteMfg", "").toString()
+                + " " + remoteName);
     }
+    m_netConfMan = new QTM_PREPEND_NAMESPACE(
+            QNetworkConfigurationManager)(this);
+    connect(m_netConfMan, SIGNAL(updateCompleted()),
+            this, SLOT(onNetworkStatusUpdate()));
+    m_netConfMan->updateConfigurations();
+    enableRateBtns(false);
 }
 
 SettingsDlg::~SettingsDlg()
@@ -110,6 +109,11 @@ void SettingsDlg::showAdvSettingsDlg()
 {
     AdvSettingsDlg dlg;
     dlg.exec();
+    if (QSettings(this).value("remoteName", "").toString() == "") {
+        m_remoteNameLabel->setText(tr("No remote selected"));
+        m_ratingLabel->setText("");
+        enableRateBtns(false);
+    }
 }
 
 void SettingsDlg::showSelectRemoteDlg()
@@ -118,7 +122,6 @@ void SettingsDlg::showSelectRemoteDlg()
     connect(&dlg, SIGNAL(remoteChanged(Remote)),
             this, SLOT(setRemote(Remote)));
     dlg.exec();
-    onNetworkStatusUpdate();
 }
 
 void SettingsDlg::showAboutDlg()
@@ -138,13 +141,16 @@ void SettingsDlg::setRemote(Remote r)
 
 void SettingsDlg::onNetworkStatusUpdate()
 {
-    if (m_netConfMan->isOnline()) {
+    if (m_netConfMan->isOnline() &&
+        QSettings(this).value("remoteName", "").toString() != "") {
         setBusy();
         m_remote.updateInfo();
         enableRateBtns();
-    } else {
+    } else if (!m_netConfMan->isOnline()) {
         m_ratingLabel->setText(tr("Offline"));
         setBusy(false);
+    } else {
+        setBusy(false);
     }
 }