mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-27 04:09:36 +03:00
cmake-gui: Use cmake::Open to open generated project
This commit is contained in:
@@ -188,6 +188,9 @@ CMakeSetupDialog::CMakeSetupDialog()
|
||||
connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT(doOutputContextMenu(const QPoint&)));
|
||||
|
||||
// disable open project button
|
||||
this->OpenProjectButton->setDisabled(true);
|
||||
|
||||
// start the cmake worker thread
|
||||
this->CMakeThread = new QCMakeThread(this);
|
||||
QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), this,
|
||||
@@ -249,6 +252,10 @@ void CMakeSetupDialog::initialize()
|
||||
SIGNAL(outputMessage(QString)), this,
|
||||
SLOT(message(QString)));
|
||||
|
||||
QObject::connect(this->CMakeThread->cmakeInstance(),
|
||||
SIGNAL(openPossible(bool)), this->OpenProjectButton,
|
||||
SLOT(setEnabled(bool)));
|
||||
|
||||
QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)), this,
|
||||
SLOT(setGroupedView(bool)));
|
||||
QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this,
|
||||
@@ -492,24 +499,10 @@ void CMakeSetupDialog::doGenerate()
|
||||
this->ConfigureNeeded = true;
|
||||
}
|
||||
|
||||
QString CMakeSetupDialog::getProjectFilename()
|
||||
{
|
||||
QStringList nameFilter;
|
||||
nameFilter << "*.sln"
|
||||
<< "*.xcodeproj";
|
||||
QDir directory(this->BinaryDirectory->currentText());
|
||||
QStringList nlnFile = directory.entryList(nameFilter);
|
||||
|
||||
if (nlnFile.count() == 1) {
|
||||
return this->BinaryDirectory->currentText() + "/" + nlnFile.at(0);
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doOpenProject()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(this->getProjectFilename()));
|
||||
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "open",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
|
||||
@@ -630,11 +623,6 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
|
||||
this->BinaryDirectory->setEditText(dir);
|
||||
this->BinaryDirectory->blockSignals(false);
|
||||
}
|
||||
if (!this->getProjectFilename().isEmpty()) {
|
||||
this->OpenProjectButton->setEnabled(true);
|
||||
} else {
|
||||
this->OpenProjectButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::doBinaryBrowse()
|
||||
@@ -1039,9 +1027,6 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
|
||||
this->GenerateButton->setEnabled(true);
|
||||
this->GenerateAction->setEnabled(true);
|
||||
this->ConfigureButton->setEnabled(true);
|
||||
if (!this->getProjectFilename().isEmpty()) {
|
||||
this->OpenProjectButton->setEnabled(true);
|
||||
}
|
||||
this->ConfigureButton->setText(tr("&Configure"));
|
||||
this->GenerateButton->setText(tr("&Generate"));
|
||||
} else if (s == ReadyGenerate) {
|
||||
@@ -1049,9 +1034,6 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
|
||||
this->GenerateButton->setEnabled(true);
|
||||
this->GenerateAction->setEnabled(true);
|
||||
this->ConfigureButton->setEnabled(true);
|
||||
if (!this->getProjectFilename().isEmpty()) {
|
||||
this->OpenProjectButton->setEnabled(true);
|
||||
}
|
||||
this->ConfigureButton->setText(tr("&Configure"));
|
||||
this->GenerateButton->setText(tr("&Generate"));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ protected slots:
|
||||
void initialize();
|
||||
void doConfigure();
|
||||
void doGenerate();
|
||||
QString getProjectFilename();
|
||||
void doOpenProject();
|
||||
void doInstallForCommandLine();
|
||||
void doHelp();
|
||||
|
||||
@@ -115,6 +115,8 @@ void QCMake::setBinaryDirectory(const QString& _dir)
|
||||
if (toolset) {
|
||||
this->setToolset(QString::fromLocal8Bit(toolset));
|
||||
}
|
||||
|
||||
checkOpenPossible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +185,26 @@ void QCMake::generate()
|
||||
#endif
|
||||
|
||||
emit this->generateDone(err);
|
||||
checkOpenPossible();
|
||||
}
|
||||
|
||||
void QCMake::open()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
UINT lastErrorMode = SetErrorMode(0);
|
||||
#endif
|
||||
|
||||
InterruptFlag = 0;
|
||||
cmSystemTools::ResetErrorOccuredFlag();
|
||||
|
||||
auto successful = this->CMakeInstance->Open(
|
||||
this->BinaryDirectory.toLocal8Bit().data(), false);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
SetErrorMode(lastErrorMode);
|
||||
#endif
|
||||
|
||||
emit this->openDone(successful);
|
||||
}
|
||||
|
||||
void QCMake::setProperties(const QCMakePropertyList& newProps)
|
||||
@@ -450,3 +472,10 @@ void QCMake::setWarnUnusedMode(bool value)
|
||||
{
|
||||
this->WarnUnusedMode = value;
|
||||
}
|
||||
|
||||
void QCMake::checkOpenPossible()
|
||||
{
|
||||
auto data = this->BinaryDirectory.toLocal8Bit().data();
|
||||
auto possible = this->CMakeInstance->Open(data, true);
|
||||
emit openPossible(possible);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ public slots:
|
||||
void configure();
|
||||
/// generate the files
|
||||
void generate();
|
||||
/// open the project
|
||||
void open();
|
||||
/// set the property values
|
||||
void setProperties(const QCMakePropertyList&);
|
||||
/// interrupt the configure or generate process (if connecting, make a direct
|
||||
@@ -111,6 +113,8 @@ public slots:
|
||||
void setWarnUninitializedMode(bool value);
|
||||
/// set whether to run cmake with warnings about unused variables
|
||||
void setWarnUnusedMode(bool value);
|
||||
/// check if project IDE open is possible and emit openPossible signal
|
||||
void checkOpenPossible();
|
||||
|
||||
public:
|
||||
/// get the list of cache properties
|
||||
@@ -151,6 +155,10 @@ signals:
|
||||
void debugOutputChanged(bool);
|
||||
/// signal when the toolset changes
|
||||
void toolsetChanged(const QString& toolset);
|
||||
/// signal when open is done
|
||||
void openDone(bool successful);
|
||||
/// signal when open is done
|
||||
void openPossible(bool possible);
|
||||
|
||||
protected:
|
||||
cmake* CMakeInstance;
|
||||
|
||||
Reference in New Issue
Block a user