cmake-gui: always enable generate button.
This commit is contained in:
parent
d11c70295b
commit
3f158c6dfa
|
@ -55,7 +55,7 @@ void QCMakeThread::run()
|
|||
}
|
||||
|
||||
CMakeSetupDialog::CMakeSetupDialog()
|
||||
: ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting)
|
||||
: ExitAfterGenerate(true), CacheModified(false), ConfigureNeeded(true), CurrentState(Interrupting)
|
||||
{
|
||||
QString title = QString(tr("CMake %1"));
|
||||
title = title.arg(cmVersion::GetCMakeVersion());
|
||||
|
@ -167,6 +167,9 @@ CMakeSetupDialog::CMakeSetupDialog()
|
|||
this->CMakeThread->start();
|
||||
|
||||
this->enterState(ReadyConfigure);
|
||||
|
||||
ProgressOffset = 0.0;
|
||||
ProgressFactor = 1.0;
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::initialize()
|
||||
|
@ -179,12 +182,11 @@ void CMakeSetupDialog::initialize()
|
|||
|
||||
QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(doConfigure()));
|
||||
QObject::connect(this->CMakeThread->cmakeInstance(),
|
||||
SIGNAL(configureDone(int)),
|
||||
this, SLOT(finishConfigure(int)));
|
||||
QObject::connect(this->CMakeThread->cmakeInstance(),
|
||||
SIGNAL(generateDone(int)),
|
||||
this, SLOT(finishGenerate(int)));
|
||||
|
||||
QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(configureDone(int)),
|
||||
this, SLOT(exitLoop(int)));
|
||||
QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(generateDone(int)),
|
||||
this, SLOT(exitLoop(int)));
|
||||
|
||||
QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(doGenerate()));
|
||||
|
@ -270,15 +272,8 @@ CMakeSetupDialog::~CMakeSetupDialog()
|
|||
this->CMakeThread->wait(2000);
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doConfigure()
|
||||
bool CMakeSetupDialog::prepareConfigure()
|
||||
{
|
||||
if(this->CurrentState == Configuring)
|
||||
{
|
||||
// stop configure
|
||||
doInterrupt();
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure build directory exists
|
||||
QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
|
||||
QDir dir(bindir);
|
||||
|
@ -295,7 +290,7 @@ void CMakeSetupDialog::doConfigure()
|
|||
QMessageBox::Yes | QMessageBox::No);
|
||||
if(btn == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if(!dir.mkpath("."))
|
||||
{
|
||||
|
@ -303,7 +298,7 @@ void CMakeSetupDialog::doConfigure()
|
|||
QString(tr("Failed to create directory %1")).arg(dir.path()),
|
||||
QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,27 +307,45 @@ void CMakeSetupDialog::doConfigure()
|
|||
{
|
||||
if(!this->setupFirstConfigure())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// remember path
|
||||
this->addBinaryPath(dir.absolutePath());
|
||||
|
||||
this->enterState(Configuring);
|
||||
|
||||
this->CacheValues->selectionModel()->clear();
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"setProperties", Qt::QueuedConnection,
|
||||
Q_ARG(QCMakePropertyList,
|
||||
this->CacheValues->cacheModel()->properties()));
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"configure", Qt::QueuedConnection);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::finishConfigure(int err)
|
||||
void CMakeSetupDialog::exitLoop(int err)
|
||||
{
|
||||
if(0 == err && !this->CacheValues->cacheModel()->newPropertyCount())
|
||||
this->LocalLoop.exit(err);
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doConfigure()
|
||||
{
|
||||
if(this->CurrentState == Configuring)
|
||||
{
|
||||
// stop configure
|
||||
doInterrupt();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!prepareConfigure())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->enterState(Configuring);
|
||||
|
||||
bool ret = doConfigureInternal();
|
||||
|
||||
if(ret)
|
||||
{
|
||||
this->ConfigureNeeded = false;
|
||||
}
|
||||
|
||||
if(ret && !this->CacheValues->cacheModel()->newPropertyCount())
|
||||
{
|
||||
this->enterState(ReadyGenerate);
|
||||
}
|
||||
|
@ -341,6 +354,22 @@ void CMakeSetupDialog::finishConfigure(int err)
|
|||
this->enterState(ReadyConfigure);
|
||||
this->CacheValues->scrollToTop();
|
||||
}
|
||||
this->ProgressBar->reset();
|
||||
}
|
||||
|
||||
bool CMakeSetupDialog::doConfigureInternal()
|
||||
{
|
||||
this->Output->clear();
|
||||
this->CacheValues->selectionModel()->clear();
|
||||
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"setProperties", Qt::QueuedConnection,
|
||||
Q_ARG(QCMakePropertyList,
|
||||
this->CacheValues->cacheModel()->properties()));
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"configure", Qt::QueuedConnection);
|
||||
|
||||
int err = this->LocalLoop.exec();
|
||||
|
||||
if(err != 0)
|
||||
{
|
||||
|
@ -348,17 +377,8 @@ void CMakeSetupDialog::finishConfigure(int err)
|
|||
tr("Error in configuration process, project files may be invalid"),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::finishGenerate(int err)
|
||||
{
|
||||
this->enterState(ReadyConfigure);
|
||||
if(err != 0)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("Error in generation process, project files may be invalid"),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
return 0 == err;
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doInstallForCommandLine()
|
||||
|
@ -367,6 +387,23 @@ void CMakeSetupDialog::doInstallForCommandLine()
|
|||
setupdialog.exec();
|
||||
}
|
||||
|
||||
bool CMakeSetupDialog::doGenerateInternal()
|
||||
{
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"generate", Qt::QueuedConnection);
|
||||
|
||||
int err = this->LocalLoop.exec();
|
||||
|
||||
if(err != 0)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("Error in generation process, project files may be invalid"),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
|
||||
return 0 == err;
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doGenerate()
|
||||
{
|
||||
if(this->CurrentState == Generating)
|
||||
|
@ -375,9 +412,43 @@ void CMakeSetupDialog::doGenerate()
|
|||
doInterrupt();
|
||||
return;
|
||||
}
|
||||
|
||||
// see if we need to configure
|
||||
// we'll need to configure if:
|
||||
// the configure step hasn't been done yet
|
||||
// generate was the last step done
|
||||
if(this->ConfigureNeeded)
|
||||
{
|
||||
if(!prepareConfigure())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->enterState(Generating);
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
||||
"generate", Qt::QueuedConnection);
|
||||
|
||||
bool config_passed = true;
|
||||
if(this->ConfigureNeeded)
|
||||
{
|
||||
this->CacheValues->cacheModel()->setShowNewProperties(false);
|
||||
this->ProgressFactor = 0.5;
|
||||
config_passed = doConfigureInternal();
|
||||
this->ProgressOffset = 0.5;
|
||||
}
|
||||
|
||||
if(config_passed)
|
||||
{
|
||||
doGenerateInternal();
|
||||
}
|
||||
|
||||
this->ProgressOffset = 0.0;
|
||||
this->ProgressFactor = 1.0;
|
||||
this->CacheValues->cacheModel()->setShowNewProperties(true);
|
||||
|
||||
this->enterState(ReadyConfigure);
|
||||
this->ProgressBar->reset();
|
||||
|
||||
this->ConfigureNeeded = true;
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
|
||||
|
@ -542,6 +613,7 @@ void CMakeSetupDialog::setSourceDirectory(const QString& dir)
|
|||
|
||||
void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
|
||||
{
|
||||
percent = (percent * ProgressFactor) + ProgressOffset;
|
||||
this->ProgressBar->setValue(qRound(percent * 100));
|
||||
}
|
||||
|
||||
|
@ -883,7 +955,6 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
|
|||
}
|
||||
else if(s == Configuring)
|
||||
{
|
||||
this->Output->clear();
|
||||
this->setEnabledState(false);
|
||||
this->GenerateButton->setEnabled(false);
|
||||
this->GenerateAction->setEnabled(false);
|
||||
|
@ -899,17 +970,15 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
|
|||
}
|
||||
else if(s == ReadyConfigure)
|
||||
{
|
||||
this->ProgressBar->reset();
|
||||
this->setEnabledState(true);
|
||||
this->GenerateButton->setEnabled(false);
|
||||
this->GenerateAction->setEnabled(false);
|
||||
this->GenerateButton->setEnabled(true);
|
||||
this->GenerateAction->setEnabled(true);
|
||||
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);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "QCMake.h"
|
||||
#include <QMainWindow>
|
||||
#include <QThread>
|
||||
#include <QEventLoop>
|
||||
#include "ui_CMakeSetupDialog.h"
|
||||
|
||||
class QCMakeThread;
|
||||
|
@ -43,8 +44,6 @@ protected slots:
|
|||
void doHelp();
|
||||
void doAbout();
|
||||
void doInterrupt();
|
||||
void finishConfigure(int error);
|
||||
void finishGenerate(int error);
|
||||
void error(const QString& message);
|
||||
void message(const QString& message);
|
||||
|
||||
|
@ -74,6 +73,10 @@ protected slots:
|
|||
void setGroupedView(bool);
|
||||
void showUserChanges();
|
||||
void setSearchFilter(const QString& str);
|
||||
bool prepareConfigure();
|
||||
bool doConfigureInternal();
|
||||
bool doGenerateInternal();
|
||||
void exitLoop(int);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -87,6 +90,7 @@ protected:
|
|||
QCMakeThread* CMakeThread;
|
||||
bool ExitAfterGenerate;
|
||||
bool CacheModified;
|
||||
bool ConfigureNeeded;
|
||||
QAction* ReloadCacheAction;
|
||||
QAction* DeleteCacheAction;
|
||||
QAction* ExitAction;
|
||||
|
@ -99,6 +103,10 @@ protected:
|
|||
QTextCharFormat ErrorFormat;
|
||||
QTextCharFormat MessageFormat;
|
||||
|
||||
QEventLoop LocalLoop;
|
||||
|
||||
float ProgressOffset;
|
||||
float ProgressFactor;
|
||||
};
|
||||
|
||||
// QCMake instance on a thread
|
||||
|
|
|
@ -200,6 +200,7 @@ QCMakeCacheModel::QCMakeCacheModel(QObject* p)
|
|||
NewPropertyCount(0),
|
||||
View(FlatView)
|
||||
{
|
||||
this->ShowNewProperties = true;
|
||||
QStringList labels;
|
||||
labels << tr("Name") << tr("Value");
|
||||
this->setHorizontalHeaderLabels(labels);
|
||||
|
@ -214,6 +215,11 @@ static uint qHash(const QCMakeProperty& p)
|
|||
return qHash(p.Key);
|
||||
}
|
||||
|
||||
void QCMakeCacheModel::setShowNewProperties(bool f)
|
||||
{
|
||||
this->ShowNewProperties = f;
|
||||
}
|
||||
|
||||
void QCMakeCacheModel::clear()
|
||||
{
|
||||
this->QStandardItemModel::clear();
|
||||
|
@ -226,13 +232,21 @@ void QCMakeCacheModel::clear()
|
|||
|
||||
void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
|
||||
{
|
||||
QSet<QCMakeProperty> newProps = props.toSet();
|
||||
QSet<QCMakeProperty> newProps2 = newProps;
|
||||
QSet<QCMakeProperty> oldProps = this->properties().toSet();
|
||||
|
||||
oldProps.intersect(newProps);
|
||||
newProps.subtract(oldProps);
|
||||
newProps2.subtract(newProps);
|
||||
QSet<QCMakeProperty> newProps, newProps2;
|
||||
|
||||
if(this->ShowNewProperties)
|
||||
{
|
||||
newProps = props.toSet();
|
||||
newProps2 = newProps;
|
||||
QSet<QCMakeProperty> oldProps = this->properties().toSet();
|
||||
oldProps.intersect(newProps);
|
||||
newProps.subtract(oldProps);
|
||||
newProps2.subtract(newProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
newProps2 = props.toSet();
|
||||
}
|
||||
|
||||
bool b = this->blockSignals(true);
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ public slots:
|
|||
// become new properties and be marked red.
|
||||
void setProperties(const QCMakePropertyList& props);
|
||||
|
||||
// set whether to show new properties in red
|
||||
void setShowNewProperties(bool);
|
||||
|
||||
// clear everything from the model
|
||||
void clear();
|
||||
|
||||
|
@ -115,6 +118,7 @@ public:
|
|||
protected:
|
||||
bool EditEnabled;
|
||||
int NewPropertyCount;
|
||||
bool ShowNewProperties;
|
||||
ViewType View;
|
||||
|
||||
// set the data in the model for this property
|
||||
|
|
Loading…
Reference in New Issue