#include <QtGui/QDialogButtonBox>
#include <QtGui/QPushButton>
#include <QtGui/QListWidget>
+#include <QMaemo5InformationBox>
#include <QMaemo5ValueButton>
#include <QMaemo5TimePickSelector>
#include "themeschedulersettings.h"
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);
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_);
void ThemeSchedulerSettings::clearScheduler()
{
- ThemeScheduler::instance().clear();
- loadItems();
+ if(!ThemeScheduler::instance().isEmpty())
+ {
+ ThemeScheduler::instance().clear();
+ loadItems();
+ }
}
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)
itemList_->clearSelection();
}
}
+
+void ThemeSchedulerSettings::setVisible(bool visible)
+{
+ if(visible)
+ {
+ enabled_->setChecked(ThemeScheduler::instance().isEnabled());
+ }
+
+ QDialog::setVisible(visible);
+}