Some fixes to setting dialogs.
[jspeed] / src / themeselector.cpp
index 9f377ac..b64548f 100644 (file)
@@ -26,6 +26,7 @@
 #include <QtGui/QHBoxLayout>
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QMessageBox>
+#include <QMaemo5InformationBox>
 #include "themeselector.h"
 #include "themepicker.h"
 #include "themeloader.h"
@@ -48,7 +49,7 @@ ThemeSelector::ThemeSelector(QWidget* parent): QDialog(parent), themeScheduler_(
     buttons->addButton(saveButton, QDialogButtonBox::AcceptRole);
 
     selector_ = new ThemePicker(tr("Theme"), this);
-    theme_ = Settings::instance().value("theme", "default").toString();
+    connect(selector_, SIGNAL(selected()), this, SLOT(disableScheduler()));
 
     QPushButton* loadButton = new QPushButton(tr("Import"));
     connect(loadButton, SIGNAL(clicked(bool)), this, SLOT(loadFromFile()));
@@ -72,16 +73,8 @@ ThemeSelector::ThemeSelector(QWidget* parent): QDialog(parent), themeScheduler_(
 void ThemeSelector::saveTheme()
 {
     QString theme = selector_->value().toString();
-
-    if(theme == theme_)
-    {
-        hide();
-        return;
-    }
-
     Settings::instance().setValue("theme", theme);
     hide();
-    theme_ = theme;
     emit themeChanged();
 }
 
@@ -105,7 +98,17 @@ void ThemeSelector::openScheduler()
     if(!themeScheduler_)
     {
         themeScheduler_ = new ThemeSchedulerSettings(this);
+        connect(themeScheduler_, SIGNAL(themeChanged()), this, SIGNAL(themeChanged()));
     }
 
     themeScheduler_->show();
 }
+
+void ThemeSelector::disableScheduler()
+{
+    if(ThemeScheduler::instance().isEnabled())
+    {
+        QMaemo5InformationBox::information(this, tr("Disabling theme scheduler..."), 1000);
+        ThemeScheduler::instance().setEnabled(false);
+    }
+}