Few small fixes for confirmation system
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 10:50:42 +0000 (12:50 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 10:50:42 +0000 (12:50 +0200)
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/SettingsWidget.cpp

index 9023f08..19133b5 100644 (file)
@@ -73,6 +73,9 @@ DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
     connect(dictListWidget, SIGNAL(itemClicked(QListWidgetItem*)),
             this, SLOT(itemSelected(QListWidgetItem*)));
 
+    connect(dictListWidget, SIGNAL(itemActivated(QListWidgetItem*)),
+            this, SLOT(changed()));
+
     refreshDictsList();
 
     #ifndef Q_WS_MAEMO_5
@@ -116,6 +119,7 @@ void DictManagerWidget::refreshDictsList() {
 }
 
 void DictManagerWidget::showEvent(QShowEvent *e) {
+    _changed = false;
     refreshDictsList();
     QWidget::showEvent(e);
 }
@@ -125,8 +129,9 @@ void DictManagerWidget::hideEvent(QHideEvent *e)
     #ifndef Q_WS_MAEMO_5
     if(_save) {
     #else
-    if(QMessageBox::question(this, "Save", "Do you want to save changes?",
-             QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+    if(_changed &&
+            QMessageBox::question(this, "Save", "Do you want to save changes?",
+            QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
     #endif
         QList<CommonDictInterface*> checkedDicts;
 
@@ -139,6 +144,7 @@ void DictManagerWidget::hideEvent(QHideEvent *e)
         emit selectedDictionaries(checkedDicts);
     }
 
+    _changed = false;
     QWidget::hideEvent(e);
 }
 
@@ -180,6 +186,11 @@ void DictManagerWidget::settingsButtonClicked() {
 }
 
 
+void DictManagerWidget::changed() {
+    _changed=true;
+}
+
+
 #ifndef Q_WS_MAEMO_5
     void DictManagerWidget::save() {
         _save = true;
index ba9dc7a..fa80275 100644 (file)
@@ -85,6 +85,9 @@ private Q_SLOTS:
     /*! Shows plugin's settings dialog*/
     void settingsButtonClicked();
 
+    //! Each change of state (that needs to be saved) should call this to indicate state change
+    void changed();
+
 private:
     QPushButton* addNewDictButton;
     QPushButton* removeDictButton;
@@ -97,6 +100,7 @@ private:
     //holds association between items on list and CommonDictInterface objects
     QHash<QListWidgetItem*, CommonDictInterface*> dictsHash;
     GUIInterface* guiInterface;
+    bool _changed;
 
     void refreshDictsList();
     #ifndef Q_WS_MAEMO_5
index 01840f9..90596a6 100644 (file)
@@ -550,7 +550,8 @@ void MainWindow::removeBookmarks() {
              "Do you want to delete all bookmarks? (This action cannot be revoked)",
              QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
         backbone->removeAllBookmarks();
-        backbone->search(searchString);
+        if(searchString.size())
+            backbone->search(searchString);
 
     }
 }
index 468f8b8..e20ffdd 100644 (file)
@@ -65,9 +65,9 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
     verticalLayout->addWidget(searchInBookmarksCheckBox);
 
 
-    connect(historySizeSpinBox, SIGNAL(editingFinished()), this,
+    connect(historySizeSpinBox, SIGNAL(valueChanged(int)), this,
             SLOT(changed()));
-    connect(searchResultSizeSpinBox, SIGNAL(editingFinished()), this,
+    connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)), this,
             SLOT(changed()));
     connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)), this,
             SLOT(changed()));
@@ -81,7 +81,7 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
         setMinimumWidth(250);
         setMaximumWidth(250);
         footerLayout = new QHBoxLayout(this);
-        closeButton = new QPushButton(tr("Ok"));
+        closeButton = new QPushButton(tr("Save"));
         footerLayout->addStretch(0);
         footerLayout->addWidget(closeButton);
         verticalLayout->addLayout(footerLayout);
@@ -94,7 +94,6 @@ void SettingsWidget::showEvent(QShowEvent *e) {
    #ifndef Q_WS_MAEMO_5
        _save = false;
    #endif
-   _changed = false;
    settings = guiInterface->settings();
 
    historySizeSpinBox->setValue(
@@ -113,6 +112,7 @@ void SettingsWidget::showEvent(QShowEvent *e) {
     else
         searchInDictionariesCheckBox->setChecked(false);
 
+    _changed = false;
     QDialog::showEvent(e);
 }
 
@@ -158,6 +158,7 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
         delete settings;
         settings = 0;
     }
+    _changed = false;
 }