Website updated.
[irwi] / src / settingsdlg.cpp
index 6100100..84c72ea 100644 (file)
@@ -16,6 +16,7 @@
 SettingsDlg::SettingsDlg(QWidget *parent)
     : QDialog(parent)
     , m_busy(true)
+    , m_netConfMan(NULL)
 {
     QSettings settings(this);
     m_layout = new QVBoxLayout(this);
@@ -26,14 +27,14 @@ SettingsDlg::SettingsDlg(QWidget *parent)
     m_selectRemoteBtn = new QPushButton(tr("Select remote"), this);
     m_aboutBtn = new QPushButton(tr("About"), this);
     m_rateUpBtn = new QPushButton(
-            QIcon(settings.value("rateUpIcon",
-                "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_happy.png").
-                toString()),
+            QIcon(settings.value("symbolPath",
+                "/usr/share/irwi/symbols/").
+                toString() + "symbol_thumbs_up.png"),
             "", this);
     m_rateDownBtn = new QPushButton(
-            QIcon(settings.value("rateDownIcon",
-                "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_sad.png").
-                toString()),
+            QIcon(settings.value("symbolPath",
+                "/usr/share/irwi/symbols/").
+                toString() + "symbol_thumbs_down.png"),
             "", this);
     m_rateUpBtn->setMaximumSize(72, 72);
     m_rateDownBtn->setMaximumSize(72, 72);
@@ -64,23 +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_remote = Remote(selectedRemote);
-        m_remoteNameLabel->setText(selectedRemote);
+        m_remote = Remote(remoteName);
         connect(&m_remote, SIGNAL(infoUpdated()),
-            this, SLOT(updateRemoteInfo()));
-        m_netConfMan = new QTM_PREPEND_NAMESPACE(
-                QNetworkConfigurationManager)(this);
-        connect(m_netConfMan, SIGNAL(updateCompleted()),
-                this, SLOT(onNetworkStatusUpdate()));
-        m_netConfMan->updateConfigurations();
-        enableRateBtns(false);
+                this, SLOT(updateRemoteInfo()));
+        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()
@@ -100,7 +101,9 @@ SettingsDlg::~SettingsDlg()
 
 void SettingsDlg::setBusy(bool busy)
 {
+#ifdef Q_WS_MAEMO_5
     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy);
+#endif
     m_busy = busy;
 }
 
@@ -108,6 +111,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()
@@ -115,8 +123,9 @@ void SettingsDlg::showSelectRemoteDlg()
     SelectRemoteDlg dlg;
     connect(&dlg, SIGNAL(remoteChanged(Remote)),
             this, SLOT(setRemote(Remote)));
-    dlg.exec();
-    onNetworkStatusUpdate();
+    if (dlg.exec() == QDialog::Rejected) {
+        onNetworkStatusUpdate();
+    }
 }
 
 void SettingsDlg::showAboutDlg()
@@ -136,12 +145,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);
     }
 }
 
@@ -155,21 +168,20 @@ void SettingsDlg::updateRemoteInfo()
 
 void SettingsDlg::rateUpClicked()
 {
-    m_remote.sendRating(Rating::Up);
     processRatingSent();
+    m_remote.sendRating(Rating::Up);
 }
 
 void SettingsDlg::rateDownClicked()
 {
-    m_remote.sendRating(Rating::Down);
     processRatingSent();
+    m_remote.sendRating(Rating::Down);
 }
 
 void SettingsDlg::processRatingSent()
 {
     setBusy();
     enableRateBtns(false);
-    m_remote.updateInfo();
 }
 
 void SettingsDlg::enableRateBtns(bool enable)