Theme download link fixed in web page.
[jspeed] / src / themeschedulersettings.cpp
index f736626..7e967fe 100644 (file)
@@ -27,6 +27,7 @@
 #include <QtGui/QDialogButtonBox>
 #include <QtGui/QPushButton>
 #include <QtGui/QListWidget>
+#include <QMaemo5InformationBox>
 #include <QMaemo5ValueButton>
 #include <QMaemo5TimePickSelector>
 #include "themeschedulersettings.h"
@@ -58,9 +59,9 @@ QDialog(parent), currentWidget_(0), addDialog_(0), itemList_(0)
     loadItems();
 
     ButtonBox* buttons = new ButtonBox;
-    buttons->addButton(tr("Save"), this, SLOT(saveSettings()), QDialogButtonBox::AcceptRole);
-    buttons->addButton(tr("Add new theme"), this, SLOT(openAddDialog()), QDialogButtonBox::ActionRole);
-    buttons->addButton(tr("Clear scheduler"), this, SLOT(clearScheduler()), QDialogButtonBox::ActionRole);
+    connect(buttons->addButton(tr("Save"), QDialogButtonBox::AcceptRole), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
+    connect(buttons->addButton(tr("Add new theme"), QDialogButtonBox::ActionRole), SIGNAL(clicked(bool)), this, SLOT(openAddDialog()));
+    connect(buttons->addButton(tr("Clear scheduler"), QDialogButtonBox::ActionRole), SIGNAL(clicked(bool)), this, SLOT(clearScheduler()));
 
     layout->addLayout(layout_, Qt::AlignLeft);
     layout->addWidget(buttons);
@@ -84,7 +85,7 @@ void ThemeSchedulerSettings::openAddDialog()
         themePicker_ = new ThemePicker(tr("Theme"));
 
         ButtonBox* buttons = new ButtonBox;
-        buttons->addButton(tr("Add"), this, SLOT(addScheduledTheme()));
+        connect(buttons->addButton(tr("Add"), QDialogButtonBox::AcceptRole), SIGNAL(clicked(bool)), this, SLOT(addScheduledTheme()));
 
         left->addWidget(timeButton_);
         left->addWidget(themePicker_);
@@ -111,8 +112,11 @@ void ThemeSchedulerSettings::addScheduledTheme()
 
 void ThemeSchedulerSettings::clearScheduler()
 {
-    ThemeScheduler::instance().clear();
-    loadItems();
+    if(!ThemeScheduler::instance().isEmpty())
+    {
+        ThemeScheduler::instance().clear();
+        loadItems();
+    }
 }
 
 void ThemeSchedulerSettings::loadItems()
@@ -166,17 +170,25 @@ void ThemeSchedulerSettings::loadItems()
         currentWidget_ = itemList_;
         layout_->addWidget(itemList_);
     }
-
-    QApplication::processEvents();
-    adjustSize();
-    QApplication::processEvents();
-
 }
 
 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 +225,13 @@ void ThemeSchedulerSettings::removeSelection()
         itemList_->clearSelection();
     }
 }
+
+void ThemeSchedulerSettings::setVisible(bool visible)
+{
+    if(visible)
+    {
+        enabled_->setChecked(ThemeScheduler::instance().isEnabled());
+    }
+
+    QDialog::setVisible(visible);
+}