Some fixes to setting dialogs.
authoreshe <jessehakanen@gmail.com>
Mon, 26 Jul 2010 17:08:44 +0000 (18:08 +0100)
committereshe <jessehakanen@gmail.com>
Mon, 26 Jul 2010 17:08:44 +0000 (18:08 +0100)
src/buttonselector.cpp
src/buttonselector.h
src/mainwindow.cpp
src/poiascreader.cpp
src/poisettings.cpp
src/themescheduler.cpp
src/themescheduler.h
src/themeschedulersettings.cpp
src/themeschedulersettings.h
src/themeselector.cpp
src/themeselector.h

index 22fa6d4..50e8e6e 100644 (file)
@@ -149,5 +149,5 @@ int ButtonSelector::size() const
 
 void ButtonSelector::onSelected(QString const& text)
 {
-    emit selected(currentIndex(), text, value());
+    emit selected();
 }
index 6b92b24..05213be 100644 (file)
@@ -48,7 +48,7 @@ public:
     QVariant value() const;
 
 signals:
-    void selected(unsigned int index, QString const& text, QVariant const& value);
+    void selected();
 
 private slots:
     void onSelected(QString const& text);
index d30e299..3ccacaf 100644 (file)
@@ -37,7 +37,7 @@ MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0), mainScreen_
     setWindowTitle(tr("jSpeed"));
     showFullScreen();
     addScreens();
-    QTimer::singleShot(500, this, SLOT(loadServices()));
+    QTimer::singleShot(800, this, SLOT(loadServices()));
 }
 
 MainWindow::~MainWindow()
index 19e9e82..68bb048 100644 (file)
@@ -29,6 +29,8 @@ PoiAscReader::PoiAscReader(QString filename): PoiReader(), filename_(filename)
 
 bool PoiAscReader::read(QList<Poi>& pois)
 {
+    pois.clear();
+
     QFile file(filename_);
 
     if(!file.open(QIODevice::ReadOnly))
index 5adfa6e..5601c23 100644 (file)
@@ -141,11 +141,13 @@ void PoiSettings::saveSettings()
     Settings::instance().setValue("alert_sound", soundSelector_->value());
     Settings::instance().setValue("alert_poi_file", poiFileSelector_->value());
 
-    hide();
-
     if(!PoiAlerts::instance().loadConfig())
     {
-        QMaemo5InformationBox::information(0, tr("Unable to load poi file: %1.").arg(PoiAlerts::instance().error()),
+        QMaemo5InformationBox::information(this, tr("Unable to load poi file: %1.").arg(PoiAlerts::instance().error()),
                                            QMaemo5InformationBox::NoTimeout);
     }
+    else
+    {
+        hide();
+    }
 }
index a09225f..c8f939a 100644 (file)
@@ -203,3 +203,8 @@ void ThemeScheduler::emitThemeChanged()
         emit themeChanged();
     }
 }
+
+bool ThemeScheduler::isEmpty() const
+{
+    return items_.isEmpty();
+}
index 0501964..be82fb4 100644 (file)
@@ -48,6 +48,7 @@ public:
     QString currentTheme() const;
     void clear();
     void getItems(QList<SchedulerItem>& items);
+    bool isEmpty() const;
 
 public slots:
     void store();
index d03a449..c545b58 100644 (file)
@@ -27,6 +27,7 @@
 #include <QtGui/QDialogButtonBox>
 #include <QtGui/QPushButton>
 #include <QtGui/QListWidget>
+#include <QMaemo5InformationBox>
 #include <QMaemo5ValueButton>
 #include <QMaemo5TimePickSelector>
 #include "themeschedulersettings.h"
@@ -175,8 +176,21 @@ void ThemeSchedulerSettings::loadItems()
 
 void ThemeSchedulerSettings::saveSettings()
 {
-    ThemeScheduler::instance().setEnabled(enabled_->isChecked());
+    bool enabled = enabled_->isChecked();
+
+    if(enabled && ThemeScheduler::instance().isEmpty())
+    {
+        QMaemo5InformationBox::information(this, tr("Theme scheduler is empty."));
+        return;
+    }
+
+    ThemeScheduler::instance().setEnabled(enabled);
     hide();
+
+    if(enabled)
+    {
+        emit themeChanged();
+    }
 }
 
 void ThemeSchedulerSettings::showContextMenu(QPoint const& point)
@@ -213,3 +227,13 @@ void ThemeSchedulerSettings::removeSelection()
         itemList_->clearSelection();
     }
 }
+
+void ThemeSchedulerSettings::setVisible(bool visible)
+{
+    if(visible)
+    {
+        enabled_->setChecked(ThemeScheduler::instance().isEnabled());
+    }
+
+    QDialog::setVisible(visible);
+}
index c4a4fcd..3961fd4 100644 (file)
@@ -37,6 +37,12 @@ class ThemeSchedulerSettings : public QDialog
 public:
     ThemeSchedulerSettings(QWidget* parent = 0);
 
+signals:
+    void themeChanged();
+
+protected:
+    void setVisible(bool visible);
+
 private slots:
     void openAddDialog();
     void addScheduledTheme();
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);
+    }
+}
index ec5f943..1f6fac2 100644 (file)
@@ -39,10 +39,10 @@ private slots:
     void saveTheme();
     void loadFromFile();
     void openScheduler();
+    void disableScheduler();
 
 private:
     ThemePicker* selector_;
-    QString theme_;
     ThemeSchedulerSettings* themeScheduler_;
 };