]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Add "Yes to all" and "No to all" options to user data saving dialog on
authorMichal Malý <madcatxster@prifuk.cz>
Wed, 12 Mar 2014 17:08:00 +0000 (18:08 +0100)
committerMichal Malý <madcatxster@prifuk.cz>
Wed, 12 Mar 2014 17:08:00 +0000 (18:08 +0100)
exit

datamanager.cpp

index 0428d7c356e060151b4fc9b0e7df16bca1ef6368..3d624ef8e8c7b925373b13d391a8f7e55c57d241 100644 (file)
@@ -50,6 +50,9 @@ DataManager::DataManager(QObject* parent) :
 
 void DataManager::saveUserDataOnExit()
 {
+  enum class Choice { YESTOALL, NOTOALL, ASK };
+  Choice c = Choice::ASK;
+
   for (NameSequencePair& nsp : m_sequences) {
     const QString seqName = nsp.first;
     std::shared_ptr<Sequence> seq = nsp.second;
@@ -57,14 +60,37 @@ void DataManager::saveUserDataOnExit()
 
     while (it != seq->end()) {
       std::shared_ptr<SingleRunData> sr = it->second;
+
       if (sr->userDataModified()) {
-        const QString srName = QString::fromStdString(it->first);
-        int ret = QMessageBox::question(nullptr, "Save changes?" , "User data in sequence " + seqName + ", signal " + srName + " have been modified. "
-                                        "Would you like to save the changes?", QMessageBox::Yes, QMessageBox::No);
-        if (ret == QMessageBox::Yes)
+        switch (c) {
+        case Choice::YESTOALL:
           sr->saveUserDataToJSON();
+          break;
+        case Choice::NOTOALL:
+          return;
+        case Choice::ASK: {
+          const QString srName = QString::fromStdString(it->first);
+          int ret = QMessageBox::question(nullptr, "Save changes?" , "User data in sequence " + seqName + ", signal " + srName + " have been modified. "
+                                        "Would you like to save the changes?",
+                                        QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No | QMessageBox::NoToAll,
+                                        QMessageBox::Yes);
+          switch (ret) {
+          case QMessageBox::YesToAll:
+            c = Choice::YESTOALL;
+          case QMessageBox::Yes:
+            sr->saveUserDataToJSON();
+            break;
+          case QMessageBox::NoToAll:
+            c = Choice::NOTOALL;
+            break;
+          default:
+            break;
+          }
+        }
       }
-      ++it;
+    }
+
+    ++it;
     }
   }
 }