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.
This commit is contained in:
Clinton Stimpson 2007-11-12 17:41:15 -05:00
parent f97dddf0ee
commit fcc62c6d0d
3 changed files with 177 additions and 132 deletions

View File

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

View File

@ -61,7 +61,6 @@ protected slots:
void promptForGenerator(); void promptForGenerator();
void updateGeneratorLabel(const QString& gen); void updateGeneratorLabel(const QString& gen);
void setExitAfterGenerate(bool); void setExitAfterGenerate(bool);
void setGenerateEnabled(bool);
void addBinaryPath(const QString&); void addBinaryPath(const QString&);
QStringList loadBuildPaths(); QStringList loadBuildPaths();
void saveBuildPaths(const QStringList&); void saveBuildPaths(const QStringList&);
@ -72,6 +71,10 @@ protected slots:
void selectionChanged(); void selectionChanged();
protected: protected:
enum State { Interrupting, ReadyConfigure, ReadyGenerate, Configuring, Generating };
void enterState(State s);
void closeEvent(QCloseEvent*); void closeEvent(QCloseEvent*);
void dragEnterEvent(QDragEnterEvent*); void dragEnterEvent(QDragEnterEvent*);
void dropEvent(QDropEvent*); void dropEvent(QDropEvent*);
@ -84,6 +87,8 @@ protected:
QAction* ExitAction; QAction* ExitAction;
QAction* ConfigureAction; QAction* ConfigureAction;
QAction* GenerateAction; QAction* GenerateAction;
State CurrentState;
}; };
// QCMake instance on a thread // QCMake instance on a thread

View File

@ -70,11 +70,11 @@
<property name="frameShadow" > <property name="frameShadow" >
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" > <layout class="QVBoxLayout" >
<property name="margin" > <property name="margin" >
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0" colspan="6" > <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4" >
@ -128,16 +128,19 @@
<string>Remove Selected Entries</string> <string>Remove Selected Entries</string>
</property> </property>
<property name="text" > <property name="text" >
<string/> <string>Remove Entry</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="CMakeSetup.qrc" >:/Icons/Delete16.png</iconset> <iconset resource="CMakeSetup.qrc" >:/Icons/Delete16.png</iconset>
</property> </property>
<property name="toolButtonStyle" >
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" colspan="6" > <item>
<widget class="QCMakeCacheView" name="CacheValues" > <widget class="QCMakeCacheView" name="CacheValues" >
<property name="alternatingRowColors" > <property name="alternatingRowColors" >
<bool>true</bool> <bool>true</bool>
@ -150,73 +153,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" > <item>
<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" >
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3" >
<property name="text" > <property name="text" >
<string>Press Configure to update and display new values in red, then press Generate to generate selected build files.</string> <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> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<widget class="QTextEdit" name="Output" > <widget class="QTextEdit" name="Output" >