verticalLayout->addWidget(searchInBookmarksCheckBox);
+ connect(historySizeSpinBox, SIGNAL(valueChanged(int)), this,
+ SLOT(changed()));
+ connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)), this,
+ SLOT(changed()));
+ connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)), this,
+ SLOT(changed()));
+ connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)), this,
+ SLOT(changed()));
+
+
+ settings = 0;
+
#ifndef Q_WS_MAEMO_5
setMinimumWidth(250);
setMaximumWidth(250);
+ footerLayout = new QHBoxLayout(this);
+ closeButton = new QPushButton(tr("Save"));
+ footerLayout->addStretch(0);
+ footerLayout->addWidget(closeButton);
+ verticalLayout->addLayout(footerLayout);
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
#endif
}
void SettingsWidget::showEvent(QShowEvent *e) {
- settings = guiInterface->settings();
+ #ifndef Q_WS_MAEMO_5
+ _save = false;
+ #endif
+ settings = guiInterface->settings();
- historySizeSpinBox->setValue(
+ historySizeSpinBox->setValue(
settings->value("history_size").toInt());
searchResultSizeSpinBox->setValue(
else
searchInDictionariesCheckBox->setChecked(false);
+ _changed = false;
QDialog::showEvent(e);
}
void SettingsWidget::hideEvent(QHideEvent *e) {
- Settings* newSettings = new Settings;
- newSettings->setValue("history_size",
- QString::number(historySizeSpinBox->value()));
- newSettings->setValue("search_limit",
- QString::number(searchResultSizeSpinBox->value()));
-
- if(searchInDictionariesCheckBox->isChecked())
- newSettings->setValue("search_dictionaries", "true");
- else
- newSettings->setValue("search_dictionaries", "false");
+ QDialog::hideEvent(e);
- if(searchInBookmarksCheckBox->isChecked())
- newSettings->setValue("search_bookmarks", "true");
- else
- newSettings->setValue("search_bookmarks", "false");
-
- //setting new settings only if their are different that old ones
- QString key;
- foreach(key, newSettings->keys()) {
- if(settings->value(key) != newSettings->value(key)) {
- guiInterface->setSettings(newSettings);
- break;
+ #ifndef Q_WS_MAEMO_5
+ if(settings && _save) {
+ #else
+ if(settings && _changed &&
+ QMessageBox::question(this, "Save", "Do you want to save changes?",
+ QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+
+ #endif
+ Settings* newSettings = new Settings;
+ newSettings->setValue("history_size",
+ QString::number(historySizeSpinBox->value()));
+ newSettings->setValue("search_limit",
+ QString::number(
+ searchResultSizeSpinBox->value()));
+
+ if(searchInDictionariesCheckBox->isChecked())
+ newSettings->setValue("search_dictionaries", "true");
+ else
+ newSettings->setValue("search_dictionaries", "false");
+
+ if(searchInBookmarksCheckBox->isChecked())
+ newSettings->setValue("search_bookmarks", "true");
+ else
+ newSettings->setValue("search_bookmarks", "false");
+
+ //setting new settings only if their are different that old ones
+ QString key;
+ foreach(key, newSettings->keys()) {
+ if(settings->value(key) != newSettings->value(key)) {
+ guiInterface->setSettings(newSettings);
+ break;
+ }
}
+
}
+ if(settings) {
+ delete settings;
+ settings = 0;
+ }
+ _changed = false;
+}
- QDialog::hideEvent(e);
+
+void SettingsWidget::changed() {
+ _changed = true;
}
+
+#ifndef Q_WS_MAEMO_5
+ void SettingsWidget::save() {
+ _save = true;
+ hide();
+ }
+#endif