X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=trunk%2Fsrc%2Fbase%2Fgui%2FSettingsWidget.cpp;h=81bde6e74ac1bb01121c595f39937292e85983eb;hb=c3803b8013456900e4e4c27fa23d9ae56f29f309;hp=4cf721de02cf0d37cc8bc35312015a2a792c9b02;hpb=e14e2ce1375108725a1249285ba76ab6cbcd1328;p=mdictionary diff --git a/trunk/src/base/gui/SettingsWidget.cpp b/trunk/src/base/gui/SettingsWidget.cpp index 4cf721d..81bde6e 100644 --- a/trunk/src/base/gui/SettingsWidget.cpp +++ b/trunk/src/base/gui/SettingsWidget.cpp @@ -65,16 +65,35 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) : 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) { + #ifndef Q_WS_MAEMO_5 + _save = false; + #endif settings = guiInterface->settings(); historySizeSpinBox->setValue( @@ -93,13 +112,21 @@ void SettingsWidget::showEvent(QShowEvent *e) { else searchInDictionariesCheckBox->setChecked(false); + _changed = false; QDialog::showEvent(e); } void SettingsWidget::hideEvent(QHideEvent *e) { QDialog::hideEvent(e); - if(settings) { + #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())); @@ -126,7 +153,22 @@ void SettingsWidget::hideEvent(QHideEvent *e) { } } + } + if(settings) { delete settings; settings = 0; } + _changed = false; +} + + +void SettingsWidget::changed() { + _changed = true; } + +#ifndef Q_WS_MAEMO_5 + void SettingsWidget::save() { + _save = true; + hide(); + } +#endif