瀏覽代碼

ENH: Allow cancelling the dialog that prompts for the generator.

Clinton Stimpson 17 年之前
父節點
當前提交
76ed89cede
共有 2 個文件被更改,包括 20 次插入10 次删除
  1. 19 9
      Source/QtDialog/CMakeSetupDialog.cxx
  2. 1 1
      Source/QtDialog/CMakeSetupDialog.h

+ 19 - 9
Source/QtDialog/CMakeSetupDialog.cxx

@@ -237,6 +237,7 @@ void CMakeSetupDialog::doConfigure()
     return;
     }
 
+  // make sure build directory exists
   QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
   QDir dir(bindir);
   if(!dir.exists())
@@ -257,10 +258,13 @@ void CMakeSetupDialog::doConfigure()
     dir.mkpath(".");
     }
 
-  // prompt for generator if one doesn't exist
+  // prompt for generator if it hasn't been set
   if(this->CMakeThread->cmakeInstance()->generator().isEmpty())
     {
-    this->promptForGenerator();
+    if(!this->promptForGenerator())
+      {
+      return;
+      }
     }
 
   // remember path
@@ -520,7 +524,7 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
   this->RemoveEntry->setEnabled(false);  // let selection re-enable it
 }
 
-void CMakeSetupDialog::promptForGenerator()
+bool CMakeSetupDialog::promptForGenerator()
 {
   QSettings settings;
   settings.beginGroup("Settings/StartPath");
@@ -540,19 +544,25 @@ void CMakeSetupDialog::promptForGenerator()
     {
     combo->setCurrentIndex(idx);
     }
-  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
+  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok |
+                                                QDialogButtonBox::Cancel,
                                                 Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
+  QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject()));
   
   QVBoxLayout* l = new QVBoxLayout(&dialog);
   l->addWidget(lab);
   l->addWidget(combo);
   l->addWidget(btns);
-  dialog.exec();
-  
-  lastGen = combo->currentText();
-  settings.setValue("LastGenerator", lastGen);
-  this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText());
+  if(dialog.exec() == QDialog::Accepted)
+    {
+    lastGen = combo->currentText();
+    settings.setValue("LastGenerator", lastGen);
+    this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText());
+    return true;
+    }
+
+  return false;
 }
 
 void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)

+ 1 - 1
Source/QtDialog/CMakeSetupDialog.h

@@ -60,7 +60,7 @@ protected slots:
   void updateSourceDirectory(const QString& dir);
   void showProgress(const QString& msg, float percent);
   void setEnabledState(bool);
-  void promptForGenerator();
+  bool promptForGenerator();
   void updateGeneratorLabel(const QString& gen);
   void setExitAfterGenerate(bool);
   void addBinaryPath(const QString&);