From fe73fefc68cf21bdafe136a24b6712080b79f8fb Mon Sep 17 00:00:00 2001 From: eshe Date: Mon, 26 Jul 2010 18:08:44 +0100 Subject: [PATCH] Some fixes to setting dialogs. --- src/buttonselector.cpp | 2 +- src/buttonselector.h | 2 +- src/mainwindow.cpp | 2 +- src/poiascreader.cpp | 2 ++ src/poisettings.cpp | 8 +++++--- src/themescheduler.cpp | 5 +++++ src/themescheduler.h | 1 + src/themeschedulersettings.cpp | 26 +++++++++++++++++++++++++- src/themeschedulersettings.h | 6 ++++++ src/themeselector.cpp | 21 ++++++++++++--------- src/themeselector.h | 2 +- 11 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/buttonselector.cpp b/src/buttonselector.cpp index 22fa6d4..50e8e6e 100644 --- a/src/buttonselector.cpp +++ b/src/buttonselector.cpp @@ -149,5 +149,5 @@ int ButtonSelector::size() const void ButtonSelector::onSelected(QString const& text) { - emit selected(currentIndex(), text, value()); + emit selected(); } diff --git a/src/buttonselector.h b/src/buttonselector.h index 6b92b24..05213be 100644 --- a/src/buttonselector.h +++ b/src/buttonselector.h @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d30e299..3ccacaf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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() diff --git a/src/poiascreader.cpp b/src/poiascreader.cpp index 19e9e82..68bb048 100644 --- a/src/poiascreader.cpp +++ b/src/poiascreader.cpp @@ -29,6 +29,8 @@ PoiAscReader::PoiAscReader(QString filename): PoiReader(), filename_(filename) bool PoiAscReader::read(QList& pois) { + pois.clear(); + QFile file(filename_); if(!file.open(QIODevice::ReadOnly)) diff --git a/src/poisettings.cpp b/src/poisettings.cpp index 5adfa6e..5601c23 100644 --- a/src/poisettings.cpp +++ b/src/poisettings.cpp @@ -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(); + } } diff --git a/src/themescheduler.cpp b/src/themescheduler.cpp index a09225f..c8f939a 100644 --- a/src/themescheduler.cpp +++ b/src/themescheduler.cpp @@ -203,3 +203,8 @@ void ThemeScheduler::emitThemeChanged() emit themeChanged(); } } + +bool ThemeScheduler::isEmpty() const +{ + return items_.isEmpty(); +} diff --git a/src/themescheduler.h b/src/themescheduler.h index 0501964..be82fb4 100644 --- a/src/themescheduler.h +++ b/src/themescheduler.h @@ -48,6 +48,7 @@ public: QString currentTheme() const; void clear(); void getItems(QList& items); + bool isEmpty() const; public slots: void store(); diff --git a/src/themeschedulersettings.cpp b/src/themeschedulersettings.cpp index d03a449..c545b58 100644 --- a/src/themeschedulersettings.cpp +++ b/src/themeschedulersettings.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #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); +} diff --git a/src/themeschedulersettings.h b/src/themeschedulersettings.h index c4a4fcd..3961fd4 100644 --- a/src/themeschedulersettings.h +++ b/src/themeschedulersettings.h @@ -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(); diff --git a/src/themeselector.cpp b/src/themeselector.cpp index 9f377ac..b64548f 100644 --- a/src/themeselector.cpp +++ b/src/themeselector.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #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); + } +} diff --git a/src/themeselector.h b/src/themeselector.h index ec5f943..1f6fac2 100644 --- a/src/themeselector.h +++ b/src/themeselector.h @@ -39,10 +39,10 @@ private slots: void saveTheme(); void loadFromFile(); void openScheduler(); + void disableScheduler(); private: ThemePicker* selector_; - QString theme_; ThemeSchedulerSettings* themeScheduler_; }; -- 1.7.9.5