[cmake-commits] clinton committed CMakeSetupDialog.cxx 1.19 1.20 CMakeSetupDialog.h 1.15 1.16 CMakeSetupDialog.ui 1.13 1.14

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Nov 12 17:41:17 EST 2007


Update of /cvsroot/CMake/CMake/Source/QtDialog
In directory public:/mounts/ram/cvs-serv30268

Modified Files:
	CMakeSetupDialog.cxx CMakeSetupDialog.h CMakeSetupDialog.ui 
Log Message:

BUG: Fix pause at shutdown.
ENH: Remove interrupt button and make configure/generate turn to stop during runs.
ENH: Add text to remove cache entry button.



Index: CMakeSetupDialog.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CMakeSetupDialog.cxx	10 Nov 2007 16:36:09 -0000	1.19
+++ CMakeSetupDialog.cxx	12 Nov 2007 22:41:15 -0000	1.20
@@ -66,7 +66,7 @@
 }
 
 CMakeSetupDialog::CMakeSetupDialog()
-  : ExitAfterGenerate(true), CacheModified(false)
+  : ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting)
 {
   // create the GUI
   QSettings settings;
@@ -81,9 +81,6 @@
   this->Splitter->setStretchFactor(1, 1);
   this->setCentralWidget(cont);
   this->ProgressBar->reset();
-  this->InterruptButton->setIcon(
-    this->style()->standardPixmap(QStyle::SP_DialogCancelButton));
-  this->InterruptButton->setEnabled(false);
   this->RemoveEntry->setEnabled(false);
 
   QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
@@ -104,15 +101,6 @@
   this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
   QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), 
                    this, SLOT(doGenerate()));
-  /* 
-  QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
-  QAction* a = OptionsMenu->addAction(tr("Exit after Generation"));
-  a->setCheckable(true);
-  this->ExitAfterGenerate = settings.value("ExitAfterGenerate", true).toBool();
-  a->setChecked(this->ExitAfterGenerate);
-  QObject::connect(a, SIGNAL(triggered(bool)),
-                   this, SLOT(setExitAfterGenerate(bool)));
-                   */
 
   QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
   QAction* a = HelpMenu->addAction(tr("About"));
@@ -122,8 +110,6 @@
   QObject::connect(a, SIGNAL(triggered(bool)),
                    this, SLOT(doHelp()));
   
-  this->setGenerateEnabled(false);
-
   this->setAcceptDrops(true);
 
   // start the cmake worker thread
@@ -131,6 +117,8 @@
   QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()),
                    this, SLOT(initialize()), Qt::QueuedConnection);  
   this->CMakeThread->start();
+  
+  this->enterState(ReadyConfigure);
 }
 
 void CMakeSetupDialog::initialize()
@@ -175,9 +163,6 @@
                    SIGNAL(errorMessage(QString)),
                    this, SLOT(error(QString)));
 
-  QObject::connect(this->InterruptButton, SIGNAL(clicked(bool)),
-                   this, SLOT(doInterrupt()));
-  
   QObject::connect(this->CMakeThread->cmakeInstance(),
                    SIGNAL(outputMessage(QString)),
                    this->Output, SLOT(append(QString)));
@@ -234,6 +219,13 @@
   
 void CMakeSetupDialog::doConfigure()
 {
+  if(this->CurrentState == Configuring)
+    {
+    // stop configure
+    doInterrupt();
+    return;
+    }
+
   QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
   QDir dir(bindir);
   if(!dir.exists())
@@ -262,9 +254,7 @@
   // remember path
   this->addBinaryPath(dir.absolutePath());
     
-  this->InterruptButton->setEnabled(true);
-  this->setEnabledState(false);
-  this->setGenerateEnabled(false);
+  this->enterState(Configuring);
 
   this->Output->clear();
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
@@ -277,47 +267,44 @@
 
 void CMakeSetupDialog::finishConfigure(int err)
 {
-  this->InterruptButton->setEnabled(false);
-  this->setEnabledState(true);
-  this->ProgressBar->reset();
+  if(0 == err && 0 == this->CacheValues->cacheModel()->newCount())
+    {
+    this->enterState(ReadyGenerate);
+    }
+  else
+    {
+    this->enterState(ReadyConfigure);
+    this->CacheValues->scrollToTop();
+    }
+  
   if(err != 0)
     {
     QMessageBox::critical(this, tr("Error"), 
       tr("Error in configuration process, project files may be invalid"), 
       QMessageBox::Ok);
     }
-  else if(0 == this->CacheValues->cacheModel()->newCount())
-    {
-    this->setGenerateEnabled(true);
-    }
 }
 
 void CMakeSetupDialog::finishGenerate(int err)
 {
-  this->InterruptButton->setEnabled(false);
-  this->setEnabledState(true);
-  this->setGenerateEnabled(true);
-  this->ProgressBar->reset();
+  this->enterState(ReadyGenerate);
   if(err != 0)
     {
     QMessageBox::critical(this, tr("Error"), 
       tr("Error in generation process, project files may be invalid"),
       QMessageBox::Ok);
     }
-  /*
-  else if(this->ExitAfterGenerate)
-    {
-    QApplication::quit();
-    }
-    */
 }
 
 void CMakeSetupDialog::doGenerate()
 {
-  this->InterruptButton->setEnabled(true);
-  this->setEnabledState(false);
-  this->setGenerateEnabled(false);
-  this->Output->clear();
+  if(this->CurrentState == Generating)
+    {
+    // stop generate
+    doInterrupt();
+    return;
+    }
+  this->enterState(Generating);
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
     "generate", Qt::QueuedConnection);
 }
@@ -325,7 +312,7 @@
 void CMakeSetupDialog::closeEvent(QCloseEvent* e)
 {
   // don't close if we're busy
-  if(this->InterruptButton->isEnabled())
+  if(this->CurrentState == Configuring || this->CurrentState == Generating)
     {
     e->ignore();
     }
@@ -382,7 +369,7 @@
 
 void CMakeSetupDialog::doInterrupt()
 {
-  this->InterruptButton->setEnabled(false);
+  this->enterState(Interrupting);
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
     "interrupt", Qt::QueuedConnection);
 }
@@ -458,7 +445,6 @@
   this->BrowseSourceDirectoryButton->setEnabled(enabled);
   this->BinaryDirectory->setEnabled(enabled);
   this->BrowseBinaryDirectoryButton->setEnabled(enabled);
-  this->ConfigureButton->setEnabled(enabled);
   this->ReloadCacheAction->setEnabled(enabled);
   this->DeleteCacheAction->setEnabled(enabled);
   this->ExitAction->setEnabled(enabled);
@@ -549,17 +535,6 @@
 void CMakeSetupDialog::setExitAfterGenerate(bool b)
 {
   this->ExitAfterGenerate = b;
-  /*
-  QSettings settings;
-  settings.beginGroup("Settings/StartPath");
-  settings.setValue("ExitAfterGenerate", b);
-  */
-}
-
-void CMakeSetupDialog::setGenerateEnabled(bool b)
-{
-  this->GenerateButton->setEnabled(b);
-  this->GenerateAction->setEnabled(b);
 }
 
 void CMakeSetupDialog::addBinaryPath(const QString& path)
@@ -586,7 +561,8 @@
 
 void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e)
 {
-  if(!this->ConfigureButton->isEnabled())
+  if(this->CurrentState != ReadyConfigure || 
+     this->CurrentState != ReadyGenerate)
     {
     e->ignore();
     return;
@@ -609,10 +585,12 @@
 
 void CMakeSetupDialog::dropEvent(QDropEvent* e)
 {
-  if(!this->ConfigureButton->isEnabled())
+  if(this->CurrentState != ReadyConfigure || 
+     this->CurrentState != ReadyGenerate)
     {
     return;
     }
+
   const QMimeData* dat = e->mimeData();
   QList<QUrl> urls = dat->urls();
   QString file = urls.count() ? urls[0].toLocalFile() : QString();
@@ -672,7 +650,7 @@
 void CMakeSetupDialog::setCacheModified()
 {
   this->CacheModified = true;
-  this->setGenerateEnabled(false);
+  this->enterState(ReadyConfigure);
 }
 
 void CMakeSetupDialog::removeSelectedCacheEntries()
@@ -692,7 +670,9 @@
 void CMakeSetupDialog::selectionChanged()
 {
   QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
-  if(idxs.count() && !this->InterruptButton->isEnabled())
+  if(idxs.count() && 
+      (this->CurrentState == ReadyConfigure || 
+       this->CurrentState == ReadyGenerate) )
     {
     this->RemoveEntry->setEnabled(true);
     }
@@ -701,4 +681,64 @@
     this->RemoveEntry->setEnabled(false);
     }
 }
+  
+void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
+{
+  if(s == this->CurrentState)
+    {
+    return;
+    }
+
+  CMakeSetupDialog::State old = this->CurrentState;
+  this->CurrentState = s;
+
+  if(s == Interrupting)
+    {
+    if(old == Configuring)
+      {
+      this->ConfigureButton->setEnabled(false);
+      }
+    if(old == Generating)
+      {
+      this->GenerateButton->setEnabled(false);
+      }
+    }
+  else if(s == Configuring)
+    {
+    this->Output->clear();
+    this->setEnabledState(false);
+    this->GenerateButton->setEnabled(false);
+    this->GenerateAction->setEnabled(false);
+    this->ConfigureButton->setText(tr("Stop"));
+    }
+  else if(s == Generating)
+    {
+    this->Output->clear();
+    this->setEnabledState(false);
+    this->ConfigureButton->setEnabled(false);
+    this->GenerateAction->setEnabled(false);
+    this->GenerateButton->setText(tr("Stop"));
+    }
+  else if(s == ReadyConfigure)
+    {
+    this->ProgressBar->reset();
+    this->setEnabledState(true);
+    this->GenerateButton->setEnabled(false);
+    this->GenerateAction->setEnabled(false);
+    this->ConfigureButton->setEnabled(true);
+    this->ConfigureButton->setText(tr("Configure"));
+    this->GenerateButton->setText(tr("Generate"));
+    }
+  else if(s == ReadyGenerate)
+    {
+    this->ProgressBar->reset();
+    this->setEnabledState(true);
+    this->GenerateButton->setEnabled(true);
+    this->GenerateAction->setEnabled(true);
+    this->ConfigureButton->setEnabled(true);
+    this->ConfigureButton->setText(tr("Configure"));
+    this->GenerateButton->setText(tr("Generate"));
+    }
+}
+
 

Index: CMakeSetupDialog.ui
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.ui,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- CMakeSetupDialog.ui	12 Nov 2007 18:54:29 -0000	1.13
+++ CMakeSetupDialog.ui	12 Nov 2007 22:41:15 -0000	1.14
@@ -70,11 +70,11 @@
       <property name="frameShadow" >
        <enum>QFrame::Raised</enum>
       </property>
-      <layout class="QGridLayout" >
+      <layout class="QVBoxLayout" >
        <property name="margin" >
         <number>0</number>
        </property>
-       <item row="0" column="0" colspan="6" >
+       <item>
         <layout class="QHBoxLayout" >
          <item>
           <widget class="QLabel" name="label_4" >
@@ -128,16 +128,19 @@
             <string>Remove Selected Entries</string>
            </property>
            <property name="text" >
-            <string/>
+            <string>Remove Entry</string>
            </property>
            <property name="icon" >
             <iconset resource="CMakeSetup.qrc" >:/Icons/Delete16.png</iconset>
            </property>
+           <property name="toolButtonStyle" >
+            <enum>Qt::ToolButtonTextBesideIcon</enum>
+           </property>
           </widget>
          </item>
         </layout>
        </item>
-       <item row="1" column="0" colspan="6" >
+       <item>
         <widget class="QCMakeCacheView" name="CacheValues" >
          <property name="alternatingRowColors" >
           <bool>true</bool>
@@ -150,73 +153,7 @@
          </property>
         </widget>
        </item>
-       <item row="3" column="0" >
-        <widget class="QPushButton" name="ConfigureButton" >
-         <property name="text" >
-          <string>Configure</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="1" >
-        <widget class="QPushButton" name="GenerateButton" >
-         <property name="text" >
-          <string>Generate</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="2" >
-        <widget class="QLabel" name="Generator" >
-         <property name="text" >
-          <string>Current Generator:</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="3" >
-        <spacer>
-         <property name="orientation" >
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeType" >
-          <enum>QSizePolicy::Expanding</enum>
-         </property>
-         <property name="sizeHint" >
-          <size>
-           <width>121</width>
-           <height>27</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item row="3" column="5" >
-        <widget class="QProgressBar" name="ProgressBar" >
-         <property name="minimum" >
-          <number>0</number>
-         </property>
-         <property name="maximum" >
-          <number>100</number>
-         </property>
-         <property name="value" >
-          <number>0</number>
-         </property>
-         <property name="textVisible" >
-          <bool>false</bool>
-         </property>
-         <property name="orientation" >
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="textDirection" >
-          <enum>QProgressBar::BottomToTop</enum>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="4" >
-        <widget class="QToolButton" name="InterruptButton" >
-         <property name="text" >
-          <string>...</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="0" colspan="6" >
+       <item>
         <widget class="QLabel" name="label_3" >
          <property name="text" >
           <string>Press Configure to update and display new values in red, then press Generate to generate selected build files.</string>
@@ -229,6 +166,69 @@
          </property>
         </widget>
        </item>
+       <item>
+        <layout class="QHBoxLayout" >
+         <item>
+          <widget class="QPushButton" name="ConfigureButton" >
+           <property name="text" >
+            <string>Configure</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="GenerateButton" >
+           <property name="text" >
+            <string>Generate</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="Generator" >
+           <property name="text" >
+            <string>Current Generator:</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer>
+           <property name="orientation" >
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Expanding</enum>
+           </property>
+           <property name="sizeHint" >
+            <size>
+             <width>121</width>
+             <height>27</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QProgressBar" name="ProgressBar" >
+           <property name="minimum" >
+            <number>0</number>
+           </property>
+           <property name="maximum" >
+            <number>100</number>
+           </property>
+           <property name="value" >
+            <number>0</number>
+           </property>
+           <property name="textVisible" >
+            <bool>false</bool>
+           </property>
+           <property name="orientation" >
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="textDirection" >
+            <enum>QProgressBar::BottomToTop</enum>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
       </layout>
      </widget>
      <widget class="QTextEdit" name="Output" >

Index: CMakeSetupDialog.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- CMakeSetupDialog.h	10 Nov 2007 16:36:09 -0000	1.15
+++ CMakeSetupDialog.h	12 Nov 2007 22:41:15 -0000	1.16
@@ -61,7 +61,6 @@
   void promptForGenerator();
   void updateGeneratorLabel(const QString& gen);
   void setExitAfterGenerate(bool);
-  void setGenerateEnabled(bool);
   void addBinaryPath(const QString&);
   QStringList loadBuildPaths();
   void saveBuildPaths(const QStringList&);
@@ -72,6 +71,10 @@
   void selectionChanged();
 
 protected:
+
+  enum State { Interrupting, ReadyConfigure, ReadyGenerate, Configuring, Generating };
+  void enterState(State s);
+
   void closeEvent(QCloseEvent*);
   void dragEnterEvent(QDragEnterEvent*);
   void dropEvent(QDropEvent*);
@@ -84,6 +87,8 @@
   QAction* ExitAction;
   QAction* ConfigureAction;
   QAction* GenerateAction;
+  State CurrentState;
+
 };
 
 // QCMake instance on a thread



More information about the Cmake-commits mailing list