Added saving confirmation for dictionary list widget
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 09:41:56 +0000 (11:41 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 09:41:56 +0000 (11:41 +0200)
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h

index 6209364..9023f08 100644 (file)
@@ -77,6 +77,9 @@ DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
 
     #ifndef Q_WS_MAEMO_5
         setMinimumSize(500,300);
+        closeButton = new QPushButton(tr("Save"));
+        buttonGroup->addWidget(closeButton);
+        connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
     #endif
 }
 
@@ -119,15 +122,22 @@ void DictManagerWidget::showEvent(QShowEvent *e) {
 
 void DictManagerWidget::hideEvent(QHideEvent *e)
 {
-    QList<CommonDictInterface*> checkedDicts;
+    #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) {
+    #endif
+        QList<CommonDictInterface*> checkedDicts;
 
-    for(int i=0; i<dictListWidget->count(); i++) {
-        QListWidgetItem* item = dictListWidget->item(i);
-        if(item->checkState() == Qt::Checked) {
-            checkedDicts.push_back(dictsHash[item]);
+        for(int i=0; i<dictListWidget->count(); i++) {
+            QListWidgetItem* item = dictListWidget->item(i);
+            if(item->checkState() == Qt::Checked) {
+                checkedDicts.push_back(dictsHash[item]);
+            }
         }
+        emit selectedDictionaries(checkedDicts);
     }
-    emit selectedDictionaries(checkedDicts);
 
     QWidget::hideEvent(e);
 }
@@ -168,3 +178,11 @@ void DictManagerWidget::settingsButtonClicked() {
         refreshDictsList();
     }
 }
+
+
+#ifndef Q_WS_MAEMO_5
+    void DictManagerWidget::save() {
+        _save = true;
+        hide();
+    }
+#endif
index 324ae11..1af98e4 100644 (file)
@@ -99,6 +99,14 @@ private:
     GUIInterface* guiInterface;
 
     void refreshDictsList();
+    #ifndef Q_WS_MAEMO_5
+        QPushButton* closeButton;
+        QHBoxLayout* footerLayout;
+        bool _save;
+
+        public Q_SLOTS:
+            void save();
+    #endif
 };
 
 #endif // DICTMANAGERWIDGET_H