Ask for confirmation (general setting) only after changing some of the settings
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 10:28:38 +0000 (12:28 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 10:28:38 +0000 (12:28 +0200)
trunk/src/base/backbone/backbone.cpp
trunk/src/base/gui/SettingsWidget.cpp
trunk/src/base/gui/SettingsWidget.h

index 713f504..451ca9f 100644 (file)
@@ -566,6 +566,8 @@ void Backbone::setSettings(Settings *settings) {
     else
         _searchBookmarks = 0;
     dictUpdated();
+    if(settings)
+        delete settings;
 }
 
 
index 7bd7d77..468f8b8 100644 (file)
@@ -65,6 +65,16 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
     verticalLayout->addWidget(searchInBookmarksCheckBox);
 
 
+    connect(historySizeSpinBox, SIGNAL(editingFinished()), this,
+            SLOT(changed()));
+    connect(searchResultSizeSpinBox, SIGNAL(editingFinished()), 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
@@ -84,6 +94,7 @@ void SettingsWidget::showEvent(QShowEvent *e) {
    #ifndef Q_WS_MAEMO_5
        _save = false;
    #endif
+   _changed = false;
    settings = guiInterface->settings();
 
    historySizeSpinBox->setValue(
@@ -111,7 +122,7 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
     #ifndef Q_WS_MAEMO_5
     if(settings && _save) {
     #else
-    if(settings &&
+    if(settings && _changed &&
             QMessageBox::question(this, "Save", "Do you want to save changes?",
              QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
 
@@ -150,6 +161,10 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
 }
 
 
+void SettingsWidget::changed() {
+    _changed = true;
+}
+
 #ifndef Q_WS_MAEMO_5
     void SettingsWidget::save() {
         _save = true;
index 3f56d10..a4cde9c 100644 (file)
@@ -52,6 +52,7 @@ public:
       */
     explicit SettingsWidget(GUIInterface *parent = 0);
 
+
 protected:
     void showEvent(QShowEvent *);
     void hideEvent(QHideEvent *);
@@ -68,15 +69,19 @@ private:
 
     GUIInterface* guiInterface;
     Settings* settings;
+    bool _changed;
     #ifndef Q_WS_MAEMO_5
         QPushButton* closeButton;
         QHBoxLayout* footerLayout;
         bool _save;
 
-        public Q_SLOTS:
+        private Q_SLOTS:
             void save();
     #endif
 
+private Q_SLOTS:
+    void changed();
+
 };
 
 #endif // SETTINGSWIDGET_H