2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-11-02 18:55:57 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2007-11-02 18:55:57 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
#include "CMakeSetupDialog.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2007-11-04 02:48:59 +03:00
|
|
|
#include <QCloseEvent>
|
2007-11-05 21:20:54 +03:00
|
|
|
#include <QCoreApplication>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QKeySequence>
|
2007-11-06 09:16:11 +03:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QMessageBox>
|
2007-11-07 03:25:43 +03:00
|
|
|
#include <QMimeData>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QProgressBar>
|
|
|
|
#include <QSettings>
|
2008-02-15 02:18:10 +03:00
|
|
|
#include <QShortcut>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QUrl>
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2007-11-13 07:54:49 +03:00
|
|
|
#include "AddCacheEntry.h"
|
2008-12-16 23:00:17 +03:00
|
|
|
#include "FirstConfigure.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "QCMake.h"
|
|
|
|
#include "QCMakeCacheView.h"
|
2015-11-19 00:40:59 +03:00
|
|
|
#include "RegexExplorer.h"
|
2015-12-06 15:33:13 +03:00
|
|
|
#include "WarningMessagesDialog.h"
|
2013-11-20 01:40:22 +04:00
|
|
|
#include "cmSystemTools.h"
|
2009-03-30 18:56:43 +04:00
|
|
|
#include "cmVersion.h"
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2010-09-23 23:47:06 +04:00
|
|
|
QCMakeThread::QCMakeThread(QObject* p)
|
2016-05-16 17:34:04 +03:00
|
|
|
: QThread(p)
|
|
|
|
, CMakeInstance(NULL)
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2007-11-05 21:20:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QCMake* QCMakeThread::cmakeInstance() const
|
|
|
|
{
|
|
|
|
return this->CMakeInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QCMakeThread::run()
|
|
|
|
{
|
|
|
|
this->CMakeInstance = new QCMake;
|
|
|
|
// emit that this cmake thread is ready for use
|
|
|
|
emit this->cmakeInitialized();
|
|
|
|
this->exec();
|
|
|
|
delete this->CMakeInstance;
|
|
|
|
this->CMakeInstance = NULL;
|
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
CMakeSetupDialog::CMakeSetupDialog()
|
2016-05-16 17:34:04 +03:00
|
|
|
: ExitAfterGenerate(true)
|
|
|
|
, CacheModified(false)
|
|
|
|
, ConfigureNeeded(true)
|
|
|
|
, CurrentState(Interrupting)
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2009-09-23 02:29:35 +04:00
|
|
|
QString title = QString(tr("CMake %1"));
|
|
|
|
title = title.arg(cmVersion::GetCMakeVersion());
|
|
|
|
this->setWindowTitle(title);
|
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
// create the GUI
|
2007-11-06 03:26:18 +03:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
2013-09-11 00:35:11 +04:00
|
|
|
restoreGeometry(settings.value("geometry").toByteArray());
|
|
|
|
restoreState(settings.value("windowState").toByteArray());
|
2007-11-06 03:26:18 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddVariableNames =
|
|
|
|
settings.value("AddVariableNames", QStringList("CMAKE_INSTALL_PREFIX"))
|
|
|
|
.toStringList();
|
|
|
|
this->AddVariableTypes =
|
|
|
|
settings.value("AddVariableTypes", QStringList("PATH")).toStringList();
|
2011-11-20 01:21:41 +04:00
|
|
|
|
2007-11-03 17:30:52 +03:00
|
|
|
QWidget* cont = new QWidget(this);
|
|
|
|
this->setupUi(cont);
|
2007-11-08 18:17:37 +03:00
|
|
|
this->Splitter->setStretchFactor(0, 3);
|
2007-11-04 02:48:59 +03:00
|
|
|
this->Splitter->setStretchFactor(1, 1);
|
2007-11-03 17:30:52 +03:00
|
|
|
this->setCentralWidget(cont);
|
2007-11-07 19:31:55 +03:00
|
|
|
this->ProgressBar->reset();
|
2007-11-10 19:36:09 +03:00
|
|
|
this->RemoveEntry->setEnabled(false);
|
2007-11-13 07:54:49 +03:00
|
|
|
this->AddEntry->setEnabled(false);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2009-06-25 00:50:52 +04:00
|
|
|
QByteArray p = settings.value("SplitterSizes").toByteArray();
|
|
|
|
this->Splitter->restoreState(p);
|
2007-11-06 03:26:18 +03:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
bool groupView = settings.value("GroupView", false).toBool();
|
2010-04-27 02:06:21 +04:00
|
|
|
this->setGroupedView(groupView);
|
|
|
|
this->groupedCheck->setCheckState(groupView ? Qt::Checked : Qt::Unchecked);
|
2008-06-13 19:19:53 +04:00
|
|
|
|
2010-09-23 23:48:07 +04:00
|
|
|
bool advancedView = settings.value("AdvancedView", false).toBool();
|
|
|
|
this->setAdvancedView(advancedView);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->advancedCheck->setCheckState(advancedView ? Qt::Checked
|
|
|
|
: Qt::Unchecked);
|
2010-09-23 23:48:07 +04:00
|
|
|
|
2007-11-06 09:16:11 +03:00
|
|
|
QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
|
2007-11-07 03:25:43 +03:00
|
|
|
this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(doReloadCache()));
|
2007-11-07 03:25:43 +03:00
|
|
|
this->DeleteCacheAction = FileMenu->addAction(tr("&Delete Cache"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(doDeleteCache()));
|
2008-04-04 02:35:02 +04:00
|
|
|
this->ExitAction = FileMenu->addAction(tr("E&xit"));
|
2011-12-14 03:51:16 +04:00
|
|
|
this->ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(close()));
|
2007-11-07 03:25:43 +03:00
|
|
|
|
|
|
|
QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
|
|
|
|
this->ConfigureAction = ToolsMenu->addAction(tr("&Configure"));
|
2007-12-06 22:07:52 +03:00
|
|
|
// prevent merging with Preferences menu item on Mac OS X
|
|
|
|
this->ConfigureAction->setMenuRole(QAction::NoRole);
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(doConfigure()));
|
2007-11-07 03:25:43 +03:00
|
|
|
this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(doGenerate()));
|
2009-07-17 22:38:36 +04:00
|
|
|
QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(showChangesAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showUserChanges()));
|
2015-01-26 18:47:57 +03:00
|
|
|
#if defined(Q_WS_MAC) || defined(Q_OS_MAC)
|
2016-05-16 17:34:04 +03:00
|
|
|
this->InstallForCommandLineAction =
|
|
|
|
ToolsMenu->addAction(tr("&How to Install For Command Line Use"));
|
2010-09-23 23:47:06 +04:00
|
|
|
QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)),
|
2008-04-04 00:18:37 +04:00
|
|
|
this, SLOT(doInstallForCommandLine()));
|
2010-09-23 23:47:06 +04:00
|
|
|
#endif
|
2013-04-18 03:01:10 +04:00
|
|
|
ToolsMenu->addSeparator();
|
2016-05-16 17:34:04 +03:00
|
|
|
ToolsMenu->addAction(tr("Regular Expression Explorer..."), this,
|
|
|
|
SLOT(doRegexExplorerDialog()));
|
2015-11-19 00:40:59 +03:00
|
|
|
ToolsMenu->addSeparator();
|
2016-05-16 17:34:04 +03:00
|
|
|
ToolsMenu->addAction(tr("&Find in Output..."), this,
|
|
|
|
SLOT(doOutputFindDialog()), QKeySequence::Find);
|
|
|
|
ToolsMenu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
|
2013-04-18 03:01:10 +04:00
|
|
|
QKeySequence::FindNext);
|
2016-05-16 17:34:04 +03:00
|
|
|
ToolsMenu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
|
2013-04-18 03:01:10 +04:00
|
|
|
QKeySequence::FindPrevious);
|
2016-05-16 17:34:04 +03:00
|
|
|
ToolsMenu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
|
|
|
|
QKeySequence(Qt::Key_F8)); // in Visual Studio
|
|
|
|
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period), this,
|
|
|
|
SLOT(doOutputErrorNext())); // in Eclipse
|
2013-04-18 03:01:10 +04:00
|
|
|
|
2008-04-03 01:41:24 +04:00
|
|
|
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
|
2016-05-16 17:34:04 +03:00
|
|
|
OptionsMenu->addAction(tr("Warning Messages..."), this,
|
|
|
|
SLOT(doWarningMessagesDialog()));
|
2010-08-25 20:35:40 +04:00
|
|
|
this->WarnUninitializedAction =
|
|
|
|
OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
|
|
|
|
this->WarnUninitializedAction->setCheckable(true);
|
2010-08-25 20:43:02 +04:00
|
|
|
this->WarnUnusedAction =
|
2010-09-01 18:22:08 +04:00
|
|
|
OptionsMenu->addAction(tr("&Warn Unused (--warn-unused-vars)"));
|
2010-08-25 20:43:02 +04:00
|
|
|
this->WarnUnusedAction->setCheckable(true);
|
2008-04-04 00:18:37 +04:00
|
|
|
|
2008-04-03 01:41:24 +04:00
|
|
|
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
|
|
|
|
debugAction->setCheckable(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(debugAction, SIGNAL(toggled(bool)), this,
|
|
|
|
SLOT(setDebugOutput(bool)));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
OptionsMenu->addSeparator();
|
2016-05-16 17:34:04 +03:00
|
|
|
QAction* expandAction =
|
|
|
|
OptionsMenu->addAction(tr("&Expand Grouped Entries"));
|
|
|
|
QObject::connect(expandAction, SIGNAL(triggered(bool)), this->CacheValues,
|
|
|
|
SLOT(expandAll()));
|
|
|
|
QAction* collapseAction =
|
|
|
|
OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
|
|
|
|
QObject::connect(collapseAction, SIGNAL(triggered(bool)), this->CacheValues,
|
|
|
|
SLOT(collapseAll()));
|
2008-04-04 00:18:37 +04:00
|
|
|
|
2007-11-06 09:16:11 +03:00
|
|
|
QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
|
2007-11-07 05:27:45 +03:00
|
|
|
QAction* a = HelpMenu->addAction(tr("About"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doAbout()));
|
2007-11-06 09:16:11 +03:00
|
|
|
a = HelpMenu->addAction(tr("Help"));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doHelp()));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-07 03:25:43 +03:00
|
|
|
this->setAcceptDrops(true);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-13 08:33:22 +03:00
|
|
|
// get the saved binary directories
|
|
|
|
QStringList buildPaths = this->loadBuildPaths();
|
|
|
|
this->BinaryDirectory->addItems(buildPaths);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-02-15 03:58:31 +03:00
|
|
|
this->BinaryDirectory->setCompleter(new QCMakeFileCompleter(this, true));
|
|
|
|
this->SourceDirectory->setCompleter(new QCMakeFileCompleter(this, true));
|
2007-11-14 00:25:38 +03:00
|
|
|
|
2008-03-07 19:50:11 +03:00
|
|
|
// fixed pitch font in output window
|
|
|
|
QFont outputFont("Courier");
|
|
|
|
this->Output->setFont(outputFont);
|
2008-04-15 00:15:28 +04:00
|
|
|
this->ErrorFormat.setForeground(QBrush(Qt::red));
|
2007-11-07 03:25:43 +03:00
|
|
|
|
2013-04-18 02:53:12 +04:00
|
|
|
this->Output->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)),
|
2016-05-16 17:34:04 +03:00
|
|
|
this, SLOT(doOutputContextMenu(const QPoint&)));
|
2013-04-18 02:53:12 +04:00
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
// start the cmake worker thread
|
|
|
|
this->CMakeThread = new QCMakeThread(this);
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), this,
|
|
|
|
SLOT(initialize()), Qt::QueuedConnection);
|
2007-11-02 18:50:17 +03:00
|
|
|
this->CMakeThread->start();
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(ReadyConfigure);
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
ProgressOffset = 0.0;
|
|
|
|
ProgressFactor = 1.0;
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::initialize()
|
|
|
|
{
|
|
|
|
// now the cmake worker thread is running, lets make our connections to it
|
2010-09-23 23:47:06 +04:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(propertiesChanged(const QCMakePropertyList&)),
|
|
|
|
this->CacheValues->cacheModel(),
|
|
|
|
SLOT(setProperties(const QCMakePropertyList&)));
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this,
|
|
|
|
SLOT(doConfigure()));
|
2010-12-18 05:04:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
|
|
|
SIGNAL(configureDone(int)), this, SLOT(exitLoop(int)));
|
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
|
|
|
SIGNAL(generateDone(int)), this, SLOT(exitLoop(int)));
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)), this,
|
|
|
|
SLOT(doGenerate()));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
|
|
|
|
this, SLOT(doSourceBrowse()));
|
|
|
|
QObject::connect(this->BrowseBinaryDirectoryButton, SIGNAL(clicked(bool)),
|
|
|
|
this, SLOT(doBinaryBrowse()));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-03 17:30:52 +03:00
|
|
|
QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
|
2007-11-07 18:09:02 +03:00
|
|
|
this, SLOT(onBinaryDirectoryChanged(QString)));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)), this,
|
|
|
|
SLOT(onSourceDirectoryChanged(QString)));
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2007-11-05 21:20:54 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(sourceDirChanged(QString)), this,
|
|
|
|
SLOT(updateSourceDirectory(QString)));
|
2008-04-08 03:19:50 +04:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(binaryDirChanged(QString)), this,
|
|
|
|
SLOT(updateBinaryDirectory(QString)));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-05 21:20:54 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(progressChanged(QString, float)), this,
|
|
|
|
SLOT(showProgress(QString, float)));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-05 21:20:54 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(errorMessage(QString)), this, SLOT(error(QString)));
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2007-11-05 21:20:54 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(outputMessage(QString)), this,
|
|
|
|
SLOT(message(QString)));
|
2007-11-06 03:26:18 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)), this,
|
|
|
|
SLOT(setGroupedView(bool)));
|
|
|
|
QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this,
|
|
|
|
SLOT(setAdvancedView(bool)));
|
|
|
|
QObject::connect(this->Search, SIGNAL(textChanged(QString)), this,
|
|
|
|
SLOT(setSearchFilter(QString)));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-06 08:02:08 +03:00
|
|
|
QObject::connect(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(generatorChanged(QString)), this,
|
|
|
|
SLOT(updateGeneratorLabel(QString)));
|
2007-11-06 08:02:08 +03:00
|
|
|
this->updateGeneratorLabel(QString());
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-09 23:18:49 +03:00
|
|
|
QObject::connect(this->CacheValues->cacheModel(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
|
|
|
|
SLOT(setCacheModified()));
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-10 19:36:09 +03:00
|
|
|
QObject::connect(this->CacheValues->selectionModel(),
|
2016-05-16 17:34:04 +03:00
|
|
|
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
2007-11-10 19:36:09 +03:00
|
|
|
this, SLOT(selectionChanged()));
|
2016-05-16 17:34:04 +03:00
|
|
|
QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), this,
|
|
|
|
SLOT(removeSelectedCacheEntries()));
|
|
|
|
QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this,
|
|
|
|
SLOT(addCacheEntry()));
|
2007-11-09 23:18:49 +03:00
|
|
|
|
2010-08-25 20:35:40 +04:00
|
|
|
QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)),
|
2010-07-12 23:48:51 +04:00
|
|
|
this->CMakeThread->cmakeInstance(),
|
2010-08-25 20:35:40 +04:00
|
|
|
SLOT(setWarnUninitializedMode(bool)));
|
2010-08-25 20:43:02 +04:00
|
|
|
QObject::connect(this->WarnUnusedAction, SIGNAL(triggered(bool)),
|
|
|
|
this->CMakeThread->cmakeInstance(),
|
|
|
|
SLOT(setWarnUnusedMode(bool)));
|
2010-12-17 18:31:19 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SourceDirectory->text().isEmpty() ||
|
|
|
|
!this->BinaryDirectory->lineEdit()->text().isEmpty()) {
|
2007-11-07 18:09:02 +03:00
|
|
|
this->onSourceDirectoryChanged(this->SourceDirectory->text());
|
|
|
|
this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-11-07 18:09:02 +03:00
|
|
|
this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CMakeSetupDialog::~CMakeSetupDialog()
|
|
|
|
{
|
2007-11-06 03:26:18 +03:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
2013-09-11 00:35:11 +04:00
|
|
|
settings.setValue("windowState", QVariant(saveState()));
|
|
|
|
settings.setValue("geometry", QVariant(saveGeometry()));
|
2009-06-25 00:50:52 +04:00
|
|
|
settings.setValue("SplitterSizes", this->Splitter->saveState());
|
2007-11-06 03:26:18 +03:00
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
// wait for thread to stop
|
|
|
|
this->CMakeThread->quit();
|
2012-04-30 23:12:16 +04:00
|
|
|
this->CMakeThread->wait();
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
bool CMakeSetupDialog::prepareConfigure()
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2008-04-02 22:01:37 +04:00
|
|
|
// make sure build directory exists
|
2007-11-07 03:25:43 +03:00
|
|
|
QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
|
|
|
|
QDir dir(bindir);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!dir.exists()) {
|
2009-09-23 21:09:56 +04:00
|
|
|
QString msg = tr("Build directory does not exist, "
|
2016-05-16 17:34:04 +03:00
|
|
|
"should I create it?\n\n"
|
|
|
|
"Directory: ");
|
2009-09-23 21:09:56 +04:00
|
|
|
msg += bindir;
|
2007-11-04 02:48:59 +03:00
|
|
|
QString title = tr("Create Directory");
|
2007-11-05 21:20:54 +03:00
|
|
|
QMessageBox::StandardButton btn;
|
2010-09-23 23:47:06 +04:00
|
|
|
btn = QMessageBox::information(this, title, msg,
|
2007-11-05 21:20:54 +03:00
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (btn == QMessageBox::No) {
|
2010-12-18 05:04:57 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!dir.mkpath(".")) {
|
|
|
|
QMessageBox::information(
|
|
|
|
this, tr("Create Directory Failed"),
|
2010-09-23 23:47:06 +04:00
|
|
|
QString(tr("Failed to create directory %1")).arg(dir.path()),
|
2009-10-30 22:02:25 +03:00
|
|
|
QMessageBox::Ok);
|
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
return false;
|
2007-11-04 02:48:59 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-05 21:20:54 +03:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
// if no generator, prompt for it and other setup stuff
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CMakeThread->cmakeInstance()->generator().isEmpty()) {
|
|
|
|
if (!this->setupFirstConfigure()) {
|
2010-12-18 05:04:57 +03:00
|
|
|
return false;
|
2007-11-05 21:20:54 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-05 21:20:54 +03:00
|
|
|
|
2007-11-07 03:25:43 +03:00
|
|
|
// remember path
|
|
|
|
this->addBinaryPath(dir.absolutePath());
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
return true;
|
|
|
|
}
|
2007-11-07 18:09:02 +03:00
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
void CMakeSetupDialog::exitLoop(int err)
|
|
|
|
{
|
|
|
|
this->LocalLoop.exit(err);
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
void CMakeSetupDialog::doConfigure()
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentState == Configuring) {
|
2010-12-18 05:04:57 +03:00
|
|
|
// stop configure
|
|
|
|
doInterrupt();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prepareConfigure()) {
|
2010-12-18 05:04:57 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
this->enterState(Configuring);
|
|
|
|
|
|
|
|
bool ret = doConfigureInternal();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ret) {
|
2010-12-18 05:04:57 +03:00
|
|
|
this->ConfigureNeeded = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ret && !this->CacheValues->cacheModel()->newPropertyCount()) {
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(ReadyGenerate);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(ReadyConfigure);
|
|
|
|
this->CacheValues->scrollToTop();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
this->ProgressBar->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeSetupDialog::doConfigureInternal()
|
|
|
|
{
|
|
|
|
this->Output->clear();
|
|
|
|
this->CacheValues->selectionModel()->clear();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
QMetaObject::invokeMethod(
|
|
|
|
this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection,
|
|
|
|
Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties()));
|
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "configure",
|
|
|
|
Qt::QueuedConnection);
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
int err = this->LocalLoop.exec();
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (err != 0) {
|
|
|
|
QMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
2010-09-23 23:47:06 +04:00
|
|
|
tr("Error in configuration process, project files may be invalid"),
|
2007-11-03 17:30:52 +03:00
|
|
|
QMessageBox::Ok);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
return 0 == err;
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
void CMakeSetupDialog::doInstallForCommandLine()
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2015-05-19 17:13:08 +03:00
|
|
|
QString title = tr("How to Install For Command Line Use");
|
2016-05-16 17:34:04 +03:00
|
|
|
QString msg = tr("One may add CMake to the PATH:\n"
|
|
|
|
"\n"
|
|
|
|
" PATH=\"%1\":\"$PATH\"\n"
|
|
|
|
"\n"
|
|
|
|
"Or, to install symlinks to '/usr/local/bin', run:\n"
|
|
|
|
"\n"
|
|
|
|
" sudo \"%2\" --install\n"
|
|
|
|
"\n"
|
|
|
|
"Or, to install symlinks to another directory, run:\n"
|
|
|
|
"\n"
|
|
|
|
" sudo \"%3\" --install=/path/to/bin\n");
|
|
|
|
msg = msg.arg(
|
|
|
|
cmSystemTools::GetFilenamePath(cmSystemTools::GetCMakeCommand()).c_str());
|
2015-05-19 17:13:08 +03:00
|
|
|
msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
|
|
|
|
msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
|
|
|
|
|
|
|
|
QDialog dialog;
|
|
|
|
dialog.setWindowTitle(title);
|
|
|
|
QVBoxLayout* l = new QVBoxLayout(&dialog);
|
|
|
|
QLabel* lab = new QLabel(&dialog);
|
|
|
|
l->addWidget(lab);
|
|
|
|
lab->setText(msg);
|
|
|
|
lab->setWordWrap(false);
|
2015-06-08 16:22:24 +03:00
|
|
|
lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
2016-05-16 17:34:04 +03:00
|
|
|
QDialogButtonBox* btns =
|
|
|
|
new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
|
2015-05-19 17:13:08 +03:00
|
|
|
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
|
|
|
l->addWidget(btns);
|
|
|
|
dialog.exec();
|
2010-12-18 05:04:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CMakeSetupDialog::doGenerateInternal()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "generate",
|
|
|
|
Qt::QueuedConnection);
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
int err = this->LocalLoop.exec();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (err != 0) {
|
|
|
|
QMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
2007-11-03 17:30:52 +03:00
|
|
|
tr("Error in generation process, project files may be invalid"),
|
|
|
|
QMessageBox::Ok);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
return 0 == err;
|
2008-04-04 00:18:37 +04:00
|
|
|
}
|
|
|
|
|
2007-11-06 09:16:11 +03:00
|
|
|
void CMakeSetupDialog::doGenerate()
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentState == Generating) {
|
2007-11-13 01:41:15 +03:00
|
|
|
// stop generate
|
|
|
|
doInterrupt();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
// 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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ConfigureNeeded) {
|
|
|
|
if (!prepareConfigure()) {
|
2010-12-18 05:04:57 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(Generating);
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
bool config_passed = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ConfigureNeeded) {
|
2010-12-18 05:04:57 +03:00
|
|
|
this->CacheValues->cacheModel()->setShowNewProperties(false);
|
|
|
|
this->ProgressFactor = 0.5;
|
|
|
|
config_passed = doConfigureInternal();
|
|
|
|
this->ProgressOffset = 0.5;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (config_passed) {
|
2010-12-18 05:04:57 +03:00
|
|
|
doGenerateInternal();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-18 05:04:57 +03:00
|
|
|
|
|
|
|
this->ProgressOffset = 0.0;
|
|
|
|
this->ProgressFactor = 1.0;
|
|
|
|
this->CacheValues->cacheModel()->setShowNewProperties(true);
|
|
|
|
|
|
|
|
this->enterState(ReadyConfigure);
|
|
|
|
this->ProgressBar->reset();
|
|
|
|
|
|
|
|
this->ConfigureNeeded = true;
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-04 02:48:59 +03:00
|
|
|
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2008-02-01 18:41:29 +03:00
|
|
|
// prompt for close if there are unsaved changes, and we're not busy
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CacheModified) {
|
2009-09-23 21:09:56 +04:00
|
|
|
QString msg = tr("You have changed options but not rebuilt, "
|
2016-05-16 17:34:04 +03:00
|
|
|
"are you sure you want to exit?");
|
2007-11-03 17:30:52 +03:00
|
|
|
QString title = tr("Confirm Exit");
|
2007-11-05 21:20:54 +03:00
|
|
|
QMessageBox::StandardButton btn;
|
2009-09-23 21:09:56 +04:00
|
|
|
btn = QMessageBox::critical(this, title, msg,
|
2007-11-05 21:20:54 +03:00
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (btn == QMessageBox::No) {
|
2007-11-04 02:48:59 +03:00
|
|
|
e->ignore();
|
2007-11-03 17:30:52 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-01 18:41:29 +03:00
|
|
|
|
|
|
|
// don't close if we're busy, unless the user really wants to
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentState == Configuring) {
|
|
|
|
QString msg =
|
|
|
|
tr("You are in the middle of a Configure.\n"
|
|
|
|
"If you Exit now the configure information will be lost.\n"
|
|
|
|
"Are you sure you want to Exit?");
|
2008-02-01 18:41:29 +03:00
|
|
|
QString title = tr("Confirm Exit");
|
|
|
|
QMessageBox::StandardButton btn;
|
2009-09-23 21:09:56 +04:00
|
|
|
btn = QMessageBox::critical(this, title, msg,
|
2008-02-01 18:41:29 +03:00
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (btn == QMessageBox::No) {
|
2008-02-01 18:41:29 +03:00
|
|
|
e->ignore();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-02-01 18:41:29 +03:00
|
|
|
this->doInterrupt();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-01 18:41:29 +03:00
|
|
|
|
|
|
|
// let the generate finish
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentState == Generating) {
|
2008-02-01 18:41:29 +03:00
|
|
|
e->ignore();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doHelp()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QString msg = tr(
|
|
|
|
"CMake is used to configure and generate build files for "
|
2007-11-05 21:20:54 +03:00
|
|
|
"software projects. The basic steps for configuring a project are as "
|
2016-05-16 17:34:04 +03:00
|
|
|
"follows:\r\n\r\n1. Select the source directory for the project. This "
|
|
|
|
"should "
|
|
|
|
"contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the "
|
|
|
|
"build "
|
|
|
|
"directory for the project. This is the directory where the project "
|
|
|
|
"will be "
|
2007-11-05 21:20:54 +03:00
|
|
|
"built. It can be the same or a different directory than the source "
|
2016-05-16 17:34:04 +03:00
|
|
|
"directory. For easy clean up, a separate build directory is "
|
|
|
|
"recommended. "
|
2007-11-05 21:20:54 +03:00
|
|
|
"CMake will create the directory if it does not exist.\r\n\r\n3. Once the "
|
|
|
|
"source and binary directories are selected, it is time to press the "
|
2016-05-16 17:34:04 +03:00
|
|
|
"Configure button. This will cause CMake to read all of the input files "
|
|
|
|
"and "
|
|
|
|
"discover all the variables used by the project. The first time a "
|
|
|
|
"variable "
|
|
|
|
"is displayed it will be in Red. Users should inspect red variables "
|
|
|
|
"making "
|
|
|
|
"sure the values are correct. For some projects the Configure process "
|
|
|
|
"can "
|
|
|
|
"be iterative, so continue to press the Configure button until there are "
|
|
|
|
"no "
|
2007-11-05 21:20:54 +03:00
|
|
|
"longer red entries.\r\n\r\n4. Once there are no longer red entries, you "
|
2016-05-16 17:34:04 +03:00
|
|
|
"should click the Generate button. This will write the build files to "
|
|
|
|
"the build "
|
2007-11-13 02:06:09 +03:00
|
|
|
"directory.");
|
2007-11-03 17:30:52 +03:00
|
|
|
|
|
|
|
QDialog dialog;
|
2008-03-28 19:53:31 +03:00
|
|
|
QFontMetrics met(this->font());
|
|
|
|
int msgWidth = met.width(msg);
|
2016-05-16 17:34:04 +03:00
|
|
|
dialog.setMinimumSize(msgWidth / 15, 20);
|
2008-02-01 18:41:29 +03:00
|
|
|
dialog.setWindowTitle(tr("Help"));
|
2007-11-03 17:30:52 +03:00
|
|
|
QVBoxLayout* l = new QVBoxLayout(&dialog);
|
2007-11-05 21:20:54 +03:00
|
|
|
QLabel* lab = new QLabel(&dialog);
|
|
|
|
lab->setText(msg);
|
|
|
|
lab->setWordWrap(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
QDialogButtonBox* btns =
|
|
|
|
new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
|
2007-11-03 17:30:52 +03:00
|
|
|
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
2008-03-28 19:53:31 +03:00
|
|
|
l->addWidget(lab);
|
2007-11-03 17:30:52 +03:00
|
|
|
l->addWidget(btns);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doInterrupt()
|
|
|
|
{
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(Interrupting);
|
2012-01-02 22:07:43 +04:00
|
|
|
this->CMakeThread->cmakeInstance()->interrupt();
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doSourceBrowse()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QString dir = QFileDialog::getExistingDirectory(
|
|
|
|
this, tr("Enter Path to Source"), this->SourceDirectory->text(),
|
2014-03-30 08:39:43 +04:00
|
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!dir.isEmpty()) {
|
2008-04-08 03:19:50 +04:00
|
|
|
this->setSourceDirectory(dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SourceDirectory->text() != dir) {
|
2008-02-15 03:58:31 +03:00
|
|
|
this->SourceDirectory->blockSignals(true);
|
|
|
|
this->SourceDirectory->setText(dir);
|
|
|
|
this->SourceDirectory->blockSignals(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
2008-04-08 03:19:50 +04:00
|
|
|
void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->BinaryDirectory->currentText() != dir) {
|
2008-04-08 03:19:50 +04:00
|
|
|
this->BinaryDirectory->blockSignals(true);
|
|
|
|
this->BinaryDirectory->setEditText(dir);
|
|
|
|
this->BinaryDirectory->blockSignals(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-04-08 03:19:50 +04:00
|
|
|
}
|
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
void CMakeSetupDialog::doBinaryBrowse()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QString dir = QFileDialog::getExistingDirectory(
|
|
|
|
this, tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
|
2014-03-30 08:39:43 +04:00
|
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) {
|
2008-04-08 03:19:50 +04:00
|
|
|
this->setBinaryDirectory(dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::setBinaryDirectory(const QString& dir)
|
2007-11-07 18:09:02 +03:00
|
|
|
{
|
|
|
|
this->BinaryDirectory->setEditText(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::onSourceDirectoryChanged(const QString& dir)
|
|
|
|
{
|
2008-02-25 23:07:38 +03:00
|
|
|
this->Output->clear();
|
2007-11-07 18:09:02 +03:00
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
"setSourceDirectory", Qt::QueuedConnection,
|
|
|
|
Q_ARG(QString, dir));
|
2007-11-07 18:09:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2009-09-23 02:29:35 +04:00
|
|
|
QString title = QString(tr("CMake %1 - %2"));
|
|
|
|
title = title.arg(cmVersion::GetCMakeVersion());
|
|
|
|
title = title.arg(dir);
|
|
|
|
this->setWindowTitle(title);
|
|
|
|
|
2007-11-09 23:18:49 +03:00
|
|
|
this->CacheModified = false;
|
2007-11-05 21:20:54 +03:00
|
|
|
this->CacheValues->cacheModel()->clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
|
|
|
|
->clearChanges();
|
2007-11-05 21:20:54 +03:00
|
|
|
this->Output->clear();
|
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
"setBinaryDirectory", Qt::QueuedConnection,
|
|
|
|
Q_ARG(QString, dir));
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
void CMakeSetupDialog::setSourceDirectory(const QString& dir)
|
|
|
|
{
|
|
|
|
this->SourceDirectory->setText(dir);
|
|
|
|
}
|
|
|
|
|
2007-11-07 19:31:55 +03:00
|
|
|
void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
2010-12-18 05:04:57 +03:00
|
|
|
percent = (percent * ProgressFactor) + ProgressOffset;
|
2007-11-03 17:30:52 +03:00
|
|
|
this->ProgressBar->setValue(qRound(percent * 100));
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
2008-04-15 00:15:28 +04:00
|
|
|
|
2009-09-23 21:09:56 +04:00
|
|
|
void CMakeSetupDialog::error(const QString& msg)
|
2007-11-09 23:18:49 +03:00
|
|
|
{
|
2008-04-15 00:15:28 +04:00
|
|
|
this->Output->setCurrentCharFormat(this->ErrorFormat);
|
2016-05-16 17:34:04 +03:00
|
|
|
// QTextEdit will terminate the msg with a ParagraphSeparator, but it also
|
|
|
|
// replaces
|
|
|
|
// all newlines with ParagraphSeparators. By replacing the newlines by
|
|
|
|
// ourself, one
|
|
|
|
// error msg will be one paragraph.
|
2013-04-18 03:06:00 +04:00
|
|
|
QString paragraph(msg);
|
|
|
|
paragraph.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
|
|
|
this->Output->append(paragraph);
|
2007-11-03 17:30:52 +03:00
|
|
|
}
|
|
|
|
|
2009-09-23 21:09:56 +04:00
|
|
|
void CMakeSetupDialog::message(const QString& msg)
|
2008-02-14 23:06:05 +03:00
|
|
|
{
|
2008-04-15 00:15:28 +04:00
|
|
|
this->Output->setCurrentCharFormat(this->MessageFormat);
|
2009-09-23 21:09:56 +04:00
|
|
|
this->Output->append(msg);
|
2008-02-14 23:06:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-03 17:30:52 +03:00
|
|
|
void CMakeSetupDialog::setEnabledState(bool enabled)
|
|
|
|
{
|
2007-11-07 03:25:43 +03:00
|
|
|
// disable parts of the GUI during configure/generate
|
2007-11-07 18:09:02 +03:00
|
|
|
this->CacheValues->cacheModel()->setEditEnabled(enabled);
|
2007-11-03 17:30:52 +03:00
|
|
|
this->SourceDirectory->setEnabled(enabled);
|
|
|
|
this->BrowseSourceDirectoryButton->setEnabled(enabled);
|
|
|
|
this->BinaryDirectory->setEnabled(enabled);
|
|
|
|
this->BrowseBinaryDirectoryButton->setEnabled(enabled);
|
2007-11-07 03:25:43 +03:00
|
|
|
this->ReloadCacheAction->setEnabled(enabled);
|
|
|
|
this->DeleteCacheAction->setEnabled(enabled);
|
|
|
|
this->ExitAction->setEnabled(enabled);
|
|
|
|
this->ConfigureAction->setEnabled(enabled);
|
2007-11-13 07:54:49 +03:00
|
|
|
this->AddEntry->setEnabled(enabled);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->RemoveEntry->setEnabled(false); // let selection re-enable it
|
2007-11-02 18:50:17 +03:00
|
|
|
}
|
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
bool CMakeSetupDialog::setupFirstConfigure()
|
2007-11-05 21:20:54 +03:00
|
|
|
{
|
2008-12-16 23:00:17 +03:00
|
|
|
FirstConfigure dialog;
|
2007-11-07 03:25:43 +03:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
// initialize dialog and restore saved settings
|
|
|
|
|
|
|
|
// add generators
|
2016-05-16 17:34:04 +03:00
|
|
|
dialog.setGenerators(
|
|
|
|
this->CMakeThread->cmakeInstance()->availableGenerators());
|
2008-05-16 03:21:01 +04:00
|
|
|
|
|
|
|
// restore from settings
|
|
|
|
dialog.loadFromSettings();
|
2008-12-16 23:00:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
2008-05-16 03:21:01 +04:00
|
|
|
dialog.saveToSettings();
|
|
|
|
this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
|
2015-02-15 22:17:54 +03:00
|
|
|
this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
QCMakeCacheModel* m = this->CacheValues->cacheModel();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dialog.compilerSetup()) {
|
2008-05-16 03:21:01 +04:00
|
|
|
QString fortranCompiler = dialog.getFortranCompiler();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fortranCompiler.isEmpty()) {
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
|
2008-05-16 03:21:01 +04:00
|
|
|
"Fortran compiler.", fortranCompiler, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-05-16 03:21:01 +04:00
|
|
|
QString cxxCompiler = dialog.getCXXCompiler();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cxxCompiler.isEmpty()) {
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
|
2008-05-16 03:21:01 +04:00
|
|
|
"CXX compiler.", cxxCompiler, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
QString cCompiler = dialog.getCCompiler();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cCompiler.isEmpty()) {
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
|
2008-05-16 03:21:01 +04:00
|
|
|
"C compiler.", cCompiler, false);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dialog.crossCompilerSetup()) {
|
2008-12-16 23:00:17 +03:00
|
|
|
QString fortranCompiler = dialog.getFortranCompiler();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fortranCompiler.isEmpty()) {
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
|
2008-12-16 23:00:17 +03:00
|
|
|
"Fortran compiler.", fortranCompiler, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-12-16 23:00:17 +03:00
|
|
|
|
|
|
|
QString mode = dialog.getCrossIncludeMode();
|
2016-05-16 17:34:04 +03:00
|
|
|
m->insertProperty(QCMakeProperty::STRING,
|
|
|
|
"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CMake Find Include Mode"), mode, false);
|
2008-12-16 23:00:17 +03:00
|
|
|
mode = dialog.getCrossLibraryMode();
|
2016-05-16 17:34:04 +03:00
|
|
|
m->insertProperty(QCMakeProperty::STRING,
|
|
|
|
"CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CMake Find Library Mode"), mode, false);
|
2008-12-16 23:00:17 +03:00
|
|
|
mode = dialog.getCrossProgramMode();
|
2016-05-16 17:34:04 +03:00
|
|
|
m->insertProperty(QCMakeProperty::STRING,
|
|
|
|
"CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CMake Find Program Mode"), mode, false);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-12-16 23:00:17 +03:00
|
|
|
QString rootPath = dialog.getCrossRoot();
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CMake Find Root Path"), rootPath, false);
|
2008-12-16 23:00:17 +03:00
|
|
|
|
|
|
|
QString systemName = dialog.getSystemName();
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CMake System Name"), systemName, false);
|
2014-08-13 01:18:00 +04:00
|
|
|
QString systemVersion = dialog.getSystemVersion();
|
|
|
|
m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_VERSION",
|
|
|
|
tr("CMake System Version"), systemVersion, false);
|
2008-12-16 23:00:17 +03:00
|
|
|
QString cxxCompiler = dialog.getCXXCompiler();
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("CXX compiler."), cxxCompiler, false);
|
2008-12-16 23:00:17 +03:00
|
|
|
QString cCompiler = dialog.getCCompiler();
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
|
2012-07-06 23:26:39 +04:00
|
|
|
tr("C compiler."), cCompiler, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dialog.crossCompilerToolChainFile()) {
|
2008-12-16 23:00:17 +03:00
|
|
|
QString toolchainFile = dialog.getCrossCompilerToolChainFile();
|
2010-09-23 23:47:06 +04:00
|
|
|
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
|
2016-05-16 17:34:04 +03:00
|
|
|
tr("Cross Compile ToolChain File"), toolchainFile,
|
|
|
|
false);
|
2008-04-02 22:01:37 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2008-04-02 22:01:37 +04:00
|
|
|
|
|
|
|
return false;
|
2007-11-05 21:20:54 +03:00
|
|
|
}
|
2007-11-06 08:02:08 +03:00
|
|
|
|
|
|
|
void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)
|
|
|
|
{
|
2007-11-06 08:04:37 +03:00
|
|
|
QString str = tr("Current Generator: ");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gen.isEmpty()) {
|
2007-11-06 08:02:08 +03:00
|
|
|
str += tr("None");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-11-06 08:02:08 +03:00
|
|
|
str += gen;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-06 08:02:08 +03:00
|
|
|
this->Generator->setText(str);
|
|
|
|
}
|
|
|
|
|
2007-11-06 09:16:11 +03:00
|
|
|
void CMakeSetupDialog::doReloadCache()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "reloadCache",
|
|
|
|
Qt::QueuedConnection);
|
2007-11-06 09:16:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doDeleteCache()
|
2010-09-23 23:47:06 +04:00
|
|
|
{
|
2008-02-14 17:14:04 +03:00
|
|
|
QString title = tr("Delete Cache");
|
2012-07-06 23:26:39 +04:00
|
|
|
QString msg = tr("Are you sure you want to delete the cache?");
|
2008-02-14 17:14:04 +03:00
|
|
|
QMessageBox::StandardButton btn;
|
2010-09-23 23:47:06 +04:00
|
|
|
btn = QMessageBox::information(this, title, msg,
|
2008-02-14 17:14:04 +03:00
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (btn == QMessageBox::No) {
|
2008-02-14 17:14:04 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "deleteCache",
|
|
|
|
Qt::QueuedConnection);
|
2007-11-06 09:16:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doAbout()
|
|
|
|
{
|
2013-11-20 01:27:53 +04:00
|
|
|
QString msg = tr(
|
|
|
|
"CMake %1 (cmake.org).\n"
|
2014-06-03 17:19:57 +04:00
|
|
|
"CMake suite maintained and supported by Kitware (kitware.com/cmake).\n"
|
2013-11-20 01:27:53 +04:00
|
|
|
"Distributed under terms of the BSD 3-Clause License.\n"
|
|
|
|
"\n"
|
|
|
|
"CMake GUI maintained by csimsoft,\n"
|
|
|
|
"built using Qt %2 (qt-project.org).\n"
|
2013-11-20 01:40:22 +04:00
|
|
|
#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL
|
|
|
|
"\n"
|
|
|
|
"The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n"
|
|
|
|
"Qt is licensed under terms of the GNU LGPLv2.1, available at:\n"
|
|
|
|
" \"%3\""
|
|
|
|
#endif
|
2013-11-20 01:27:53 +04:00
|
|
|
);
|
2009-03-30 18:56:43 +04:00
|
|
|
msg = msg.arg(cmVersion::GetCMakeVersion());
|
|
|
|
msg = msg.arg(qVersion());
|
2013-11-20 01:40:22 +04:00
|
|
|
#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string lgpl = cmSystemTools::GetCMakeRoot() + "/Licenses/LGPLv2.1.txt";
|
2013-11-20 01:40:22 +04:00
|
|
|
msg = msg.arg(lgpl.c_str());
|
|
|
|
#endif
|
2007-11-06 09:16:11 +03:00
|
|
|
|
|
|
|
QDialog dialog;
|
2008-02-01 18:41:29 +03:00
|
|
|
dialog.setWindowTitle(tr("About"));
|
2007-11-06 09:16:11 +03:00
|
|
|
QVBoxLayout* l = new QVBoxLayout(&dialog);
|
|
|
|
QLabel* lab = new QLabel(&dialog);
|
|
|
|
l->addWidget(lab);
|
|
|
|
lab->setText(msg);
|
|
|
|
lab->setWordWrap(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
QDialogButtonBox* btns =
|
|
|
|
new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
|
2007-11-06 09:16:11 +03:00
|
|
|
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
|
|
|
l->addWidget(btns);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::setExitAfterGenerate(bool b)
|
|
|
|
{
|
2007-11-07 03:25:43 +03:00
|
|
|
this->ExitAfterGenerate = b;
|
2007-11-06 09:16:11 +03:00
|
|
|
}
|
|
|
|
|
2007-11-07 03:25:43 +03:00
|
|
|
void CMakeSetupDialog::addBinaryPath(const QString& path)
|
|
|
|
{
|
|
|
|
QString cleanpath = QDir::cleanPath(path);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
// update UI
|
|
|
|
this->BinaryDirectory->blockSignals(true);
|
2007-11-07 03:25:43 +03:00
|
|
|
int idx = this->BinaryDirectory->findText(cleanpath);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (idx != -1) {
|
2007-11-07 03:25:43 +03:00
|
|
|
this->BinaryDirectory->removeItem(idx);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 03:25:43 +03:00
|
|
|
this->BinaryDirectory->insertItem(0, cleanpath);
|
|
|
|
this->BinaryDirectory->setCurrentIndex(0);
|
2007-11-07 05:27:45 +03:00
|
|
|
this->BinaryDirectory->blockSignals(false);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
// save to registry
|
|
|
|
QStringList buildPaths = this->loadBuildPaths();
|
|
|
|
buildPaths.removeAll(cleanpath);
|
2007-11-07 03:25:43 +03:00
|
|
|
buildPaths.prepend(cleanpath);
|
2007-11-07 05:27:45 +03:00
|
|
|
this->saveBuildPaths(buildPaths);
|
2007-11-07 03:25:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(this->CurrentState == ReadyConfigure ||
|
|
|
|
this->CurrentState == ReadyGenerate)) {
|
2007-11-07 06:27:09 +03:00
|
|
|
e->ignore();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 06:27:09 +03:00
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
const QMimeData* dat = e->mimeData();
|
|
|
|
QList<QUrl> urls = dat->urls();
|
2007-11-07 03:25:43 +03:00
|
|
|
QString file = urls.count() ? urls[0].toLocalFile() : QString();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!file.isEmpty() &&
|
|
|
|
(file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
|
|
|
|
file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))) {
|
2007-11-07 03:25:43 +03:00
|
|
|
e->accept();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-11-07 03:25:43 +03:00
|
|
|
e->ignore();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 03:25:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::dropEvent(QDropEvent* e)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(this->CurrentState == ReadyConfigure ||
|
|
|
|
this->CurrentState == ReadyGenerate)) {
|
2007-11-07 06:27:09 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-13 01:41:15 +03:00
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
const QMimeData* dat = e->mimeData();
|
|
|
|
QList<QUrl> urls = dat->urls();
|
2007-11-07 03:25:43 +03:00
|
|
|
QString file = urls.count() ? urls[0].toLocalFile() : QString();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive)) {
|
2007-11-07 03:25:43 +03:00
|
|
|
QFileInfo info(file);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
|
|
|
|
info.absolutePath()) {
|
2007-11-07 05:51:08 +03:00
|
|
|
this->setBinaryDirectory(info.absolutePath());
|
2007-11-07 03:25:43 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (file.endsWith("CMakeLists.txt", Qt::CaseInsensitive)) {
|
2007-11-07 03:25:43 +03:00
|
|
|
QFileInfo info(file);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
|
|
|
|
info.absolutePath()) {
|
2007-11-07 05:51:08 +03:00
|
|
|
this->setSourceDirectory(info.absolutePath());
|
|
|
|
this->setBinaryDirectory(info.absolutePath());
|
2007-11-07 03:25:43 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 03:25:43 +03:00
|
|
|
}
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2007-11-07 05:27:45 +03:00
|
|
|
QStringList CMakeSetupDialog::loadBuildPaths()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
|
|
|
|
|
|
|
QStringList buildPaths;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
|
|
|
|
if (!p.isEmpty()) {
|
|
|
|
buildPaths.append(p);
|
2007-11-07 05:27:45 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 05:27:45 +03:00
|
|
|
return buildPaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::saveBuildPaths(const QStringList& paths)
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
|
|
|
|
|
|
|
int num = paths.count();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (num > 10) {
|
2007-11-07 05:27:45 +03:00
|
|
|
num = 10;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 05:27:45 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i < num; i++) {
|
2007-11-07 05:27:45 +03:00
|
|
|
settings.setValue(QString("WhereBuild%1").arg(i), paths[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-07 05:27:45 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-09 23:18:49 +03:00
|
|
|
void CMakeSetupDialog::setCacheModified()
|
|
|
|
{
|
|
|
|
this->CacheModified = true;
|
2013-11-21 08:24:54 +04:00
|
|
|
this->ConfigureNeeded = true;
|
2007-11-13 01:41:15 +03:00
|
|
|
this->enterState(ReadyConfigure);
|
2007-11-09 23:18:49 +03:00
|
|
|
}
|
|
|
|
|
2007-11-10 19:36:09 +03:00
|
|
|
void CMakeSetupDialog::removeSelectedCacheEntries()
|
|
|
|
{
|
|
|
|
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
|
|
|
|
QList<QPersistentModelIndex> pidxs;
|
2016-05-16 17:34:04 +03:00
|
|
|
foreach (QModelIndex i, idxs) {
|
2007-11-10 19:36:09 +03:00
|
|
|
pidxs.append(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
foreach (QPersistentModelIndex pi, pidxs) {
|
2008-06-10 08:17:00 +04:00
|
|
|
this->CacheValues->model()->removeRow(pi.row(), pi.parent());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 19:36:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::selectionChanged()
|
|
|
|
{
|
|
|
|
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (idxs.count() && (this->CurrentState == ReadyConfigure ||
|
|
|
|
this->CurrentState == ReadyGenerate)) {
|
2007-11-10 19:36:09 +03:00
|
|
|
this->RemoveEntry->setEnabled(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-11-10 19:36:09 +03:00
|
|
|
this->RemoveEntry->setEnabled(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 19:36:09 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2007-11-13 01:41:15 +03:00
|
|
|
void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (s == this->CurrentState) {
|
2007-11-13 01:41:15 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-13 01:41:15 +03:00
|
|
|
|
|
|
|
this->CurrentState = s;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (s == Interrupting) {
|
2007-11-13 01:51:23 +03:00
|
|
|
this->ConfigureButton->setEnabled(false);
|
|
|
|
this->GenerateButton->setEnabled(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (s == Configuring) {
|
2007-11-13 01:41:15 +03:00
|
|
|
this->setEnabledState(false);
|
|
|
|
this->GenerateButton->setEnabled(false);
|
|
|
|
this->GenerateAction->setEnabled(false);
|
2008-04-04 00:49:46 +04:00
|
|
|
this->ConfigureButton->setText(tr("&Stop"));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (s == Generating) {
|
2007-11-13 01:51:23 +03:00
|
|
|
this->CacheModified = false;
|
2007-11-13 01:41:15 +03:00
|
|
|
this->setEnabledState(false);
|
|
|
|
this->ConfigureButton->setEnabled(false);
|
|
|
|
this->GenerateAction->setEnabled(false);
|
2008-04-04 00:49:46 +04:00
|
|
|
this->GenerateButton->setText(tr("&Stop"));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (s == ReadyConfigure) {
|
2007-11-13 01:41:15 +03:00
|
|
|
this->setEnabledState(true);
|
2010-12-18 05:04:57 +03:00
|
|
|
this->GenerateButton->setEnabled(true);
|
|
|
|
this->GenerateAction->setEnabled(true);
|
2007-11-13 01:41:15 +03:00
|
|
|
this->ConfigureButton->setEnabled(true);
|
2008-04-04 00:49:46 +04:00
|
|
|
this->ConfigureButton->setText(tr("&Configure"));
|
|
|
|
this->GenerateButton->setText(tr("&Generate"));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (s == ReadyGenerate) {
|
2007-11-13 01:41:15 +03:00
|
|
|
this->setEnabledState(true);
|
|
|
|
this->GenerateButton->setEnabled(true);
|
|
|
|
this->GenerateAction->setEnabled(true);
|
|
|
|
this->ConfigureButton->setEnabled(true);
|
2008-04-04 00:49:46 +04:00
|
|
|
this->ConfigureButton->setText(tr("&Configure"));
|
|
|
|
this->GenerateButton->setText(tr("&Generate"));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-13 01:41:15 +03:00
|
|
|
}
|
|
|
|
|
2007-11-13 07:54:49 +03:00
|
|
|
void CMakeSetupDialog::addCacheEntry()
|
|
|
|
{
|
|
|
|
QDialog dialog(this);
|
|
|
|
dialog.resize(400, 200);
|
2008-02-01 18:41:29 +03:00
|
|
|
dialog.setWindowTitle(tr("Add Cache Entry"));
|
2007-11-13 07:54:49 +03:00
|
|
|
QVBoxLayout* l = new QVBoxLayout(&dialog);
|
2016-05-16 17:34:04 +03:00
|
|
|
AddCacheEntry* w =
|
|
|
|
new AddCacheEntry(&dialog, this->AddVariableNames, this->AddVariableTypes);
|
2007-11-13 07:54:49 +03:00
|
|
|
QDialogButtonBox* btns = new QDialogButtonBox(
|
2016-05-16 17:34:04 +03:00
|
|
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
|
2007-11-13 07:54:49 +03:00
|
|
|
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
|
|
|
QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
|
|
|
l->addWidget(w);
|
|
|
|
l->addStretch();
|
|
|
|
l->addWidget(btns);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (QDialog::Accepted == dialog.exec()) {
|
2007-11-13 07:54:49 +03:00
|
|
|
QCMakeCacheModel* m = this->CacheValues->cacheModel();
|
2016-05-16 17:34:04 +03:00
|
|
|
m->insertProperty(w->type(), w->name(), w->description(), w->value(),
|
|
|
|
false);
|
2011-11-20 01:21:41 +04:00
|
|
|
|
|
|
|
// only add variable names to the completion which are new
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->AddVariableNames.contains(w->name())) {
|
2014-01-13 14:28:16 +04:00
|
|
|
this->AddVariableNames << w->name();
|
|
|
|
this->AddVariableTypes << w->typeString();
|
2011-11-20 01:21:41 +04:00
|
|
|
// limit to at most 100 completion items
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AddVariableNames.size() > 100) {
|
2014-01-13 14:28:16 +04:00
|
|
|
this->AddVariableNames.removeFirst();
|
|
|
|
this->AddVariableTypes.removeFirst();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-11-20 01:21:41 +04:00
|
|
|
// make sure CMAKE_INSTALL_PREFIX is always there
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX")) {
|
2014-01-13 14:28:16 +04:00
|
|
|
this->AddVariableNames << "CMAKE_INSTALL_PREFIX";
|
|
|
|
this->AddVariableTypes << "PATH";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-11-20 01:21:41 +04:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
2014-01-13 14:28:16 +04:00
|
|
|
settings.setValue("AddVariableNames", this->AddVariableNames);
|
|
|
|
settings.setValue("AddVariableTypes", this->AddVariableTypes);
|
2007-11-13 07:54:49 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-13 07:54:49 +03:00
|
|
|
}
|
2007-11-07 05:27:45 +03:00
|
|
|
|
2008-02-15 02:18:10 +03:00
|
|
|
void CMakeSetupDialog::startSearch()
|
|
|
|
{
|
|
|
|
this->Search->setFocus(Qt::OtherFocusReason);
|
|
|
|
this->Search->selectAll();
|
|
|
|
}
|
|
|
|
|
2008-04-03 01:41:24 +04:00
|
|
|
void CMakeSetupDialog::setDebugOutput(bool flag)
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
|
2016-05-16 17:34:04 +03:00
|
|
|
"setDebugOutput", Qt::QueuedConnection,
|
|
|
|
Q_ARG(bool, flag));
|
2008-04-03 01:41:24 +04:00
|
|
|
}
|
2008-02-15 02:18:10 +03:00
|
|
|
|
2010-04-27 02:06:21 +04:00
|
|
|
void CMakeSetupDialog::setGroupedView(bool v)
|
2008-06-13 19:19:53 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView
|
|
|
|
: QCMakeCacheModel::FlatView);
|
2010-04-27 02:06:21 +04:00
|
|
|
this->CacheValues->setRootIsDecorated(v);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
2010-04-27 02:06:21 +04:00
|
|
|
settings.setValue("GroupView", v);
|
2008-06-13 19:19:53 +04:00
|
|
|
}
|
|
|
|
|
2010-04-27 02:06:21 +04:00
|
|
|
void CMakeSetupDialog::setAdvancedView(bool v)
|
|
|
|
{
|
|
|
|
this->CacheValues->setShowAdvanced(v);
|
2010-09-23 23:48:07 +04:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Settings/StartPath");
|
|
|
|
settings.setValue("AdvancedView", v);
|
2010-04-27 02:06:21 +04:00
|
|
|
}
|
|
|
|
|
2009-07-17 22:38:36 +04:00
|
|
|
void CMakeSetupDialog::showUserChanges()
|
|
|
|
{
|
|
|
|
QSet<QCMakeProperty> changes =
|
2016-05-16 17:34:04 +03:00
|
|
|
qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
|
|
|
|
->changes();
|
2009-07-17 22:38:36 +04:00
|
|
|
|
|
|
|
QDialog dialog(this);
|
|
|
|
dialog.setWindowTitle(tr("My Changes"));
|
|
|
|
dialog.resize(600, 400);
|
|
|
|
QVBoxLayout* l = new QVBoxLayout(&dialog);
|
|
|
|
QTextEdit* textedit = new QTextEdit(&dialog);
|
|
|
|
textedit->setReadOnly(true);
|
|
|
|
l->addWidget(textedit);
|
2016-05-16 17:34:04 +03:00
|
|
|
QDialogButtonBox* btns =
|
|
|
|
new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
|
2009-07-17 22:51:31 +04:00
|
|
|
QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(accept()));
|
2009-07-17 22:38:36 +04:00
|
|
|
l->addWidget(btns);
|
|
|
|
|
|
|
|
QString command;
|
|
|
|
QString cache;
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
foreach (QCMakeProperty prop, changes) {
|
2009-07-17 22:38:36 +04:00
|
|
|
QString type;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (prop.Type) {
|
2009-07-17 22:38:36 +04:00
|
|
|
case QCMakeProperty::BOOL:
|
|
|
|
type = "BOOL";
|
|
|
|
break;
|
|
|
|
case QCMakeProperty::PATH:
|
|
|
|
type = "PATH";
|
|
|
|
break;
|
|
|
|
case QCMakeProperty::FILEPATH:
|
|
|
|
type = "FILEPATH";
|
|
|
|
break;
|
|
|
|
case QCMakeProperty::STRING:
|
|
|
|
type = "STRING";
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-07-17 22:38:36 +04:00
|
|
|
QString value;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop.Type == QCMakeProperty::BOOL) {
|
2009-07-17 22:38:36 +04:00
|
|
|
value = prop.Value.toBool() ? "1" : "0";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-07-17 22:38:36 +04:00
|
|
|
value = prop.Value.toString();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-07-17 22:38:36 +04:00
|
|
|
|
|
|
|
QString line("%1:%2=");
|
|
|
|
line = line.arg(prop.Key);
|
|
|
|
line = line.arg(type);
|
|
|
|
|
|
|
|
command += QString("-D%1\"%2\" ").arg(line).arg(value);
|
|
|
|
cache += QString("%1%2\n").arg(line).arg(value);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2009-07-17 22:38:36 +04:00
|
|
|
textedit->append(tr("Commandline options:"));
|
|
|
|
textedit->append(command);
|
|
|
|
textedit->append("\n");
|
|
|
|
textedit->append(tr("Cache file:"));
|
|
|
|
textedit->append(cache);
|
2010-09-23 23:47:06 +04:00
|
|
|
|
2009-07-17 22:38:36 +04:00
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2009-09-05 00:43:07 +04:00
|
|
|
void CMakeSetupDialog::setSearchFilter(const QString& str)
|
|
|
|
{
|
|
|
|
this->CacheValues->selectionModel()->clear();
|
|
|
|
this->CacheValues->setSearchFilter(str);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt)
|
2013-04-18 02:53:12 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
QMenu* menu = this->Output->createStandardContextMenu();
|
2013-04-18 02:53:12 +04:00
|
|
|
|
|
|
|
menu->addSeparator();
|
2016-05-16 17:34:04 +03:00
|
|
|
menu->addAction(tr("Find..."), this, SLOT(doOutputFindDialog()),
|
|
|
|
QKeySequence::Find);
|
|
|
|
menu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
|
|
|
|
QKeySequence::FindNext);
|
|
|
|
menu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
|
|
|
|
QKeySequence::FindPrevious);
|
2013-04-18 03:06:00 +04:00
|
|
|
menu->addSeparator();
|
2016-05-16 17:34:04 +03:00
|
|
|
menu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
|
|
|
|
QKeySequence(Qt::Key_F8));
|
2013-04-18 02:53:12 +04:00
|
|
|
|
|
|
|
menu->exec(this->Output->mapToGlobal(pt));
|
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
2013-04-18 03:01:10 +04:00
|
|
|
void CMakeSetupDialog::doOutputFindDialog()
|
|
|
|
{
|
|
|
|
QStringList strings(this->FindHistory);
|
|
|
|
|
|
|
|
QString selection = this->Output->textCursor().selectedText();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!selection.isEmpty() && !selection.contains(QChar::ParagraphSeparator) &&
|
|
|
|
!selection.contains(QChar::LineSeparator)) {
|
2013-04-18 03:01:10 +04:00
|
|
|
strings.push_front(selection);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:01:10 +04:00
|
|
|
|
|
|
|
bool ok;
|
|
|
|
QString search = QInputDialog::getItem(this, tr("Find in Output"),
|
|
|
|
tr("Find:"), strings, 0, true, &ok);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ok && !search.isEmpty()) {
|
|
|
|
if (!this->FindHistory.contains(search)) {
|
2013-04-18 03:01:10 +04:00
|
|
|
this->FindHistory.push_front(search);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
doOutputFindNext();
|
|
|
|
}
|
2013-04-18 03:01:10 +04:00
|
|
|
}
|
|
|
|
|
2015-11-19 00:40:59 +03:00
|
|
|
void CMakeSetupDialog::doRegexExplorerDialog()
|
|
|
|
{
|
|
|
|
RegexExplorer dialog(this);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2013-04-18 03:01:10 +04:00
|
|
|
void CMakeSetupDialog::doOutputFindPrev()
|
|
|
|
{
|
|
|
|
doOutputFindNext(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMakeSetupDialog::doOutputFindNext(bool directionForward)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FindHistory.isEmpty()) {
|
|
|
|
doOutputFindDialog(); // will re-call this function again
|
2013-04-18 03:01:10 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:01:10 +04:00
|
|
|
|
|
|
|
QString search = this->FindHistory.front();
|
|
|
|
|
2013-11-01 20:56:43 +04:00
|
|
|
QTextCursor textCursor = this->Output->textCursor();
|
2013-04-18 03:01:10 +04:00
|
|
|
QTextDocument* document = this->Output->document();
|
|
|
|
QTextDocument::FindFlags flags;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!directionForward) {
|
2013-04-18 03:01:10 +04:00
|
|
|
flags |= QTextDocument::FindBackward;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-05 00:43:07 +04:00
|
|
|
|
2013-11-01 20:56:43 +04:00
|
|
|
textCursor = document->find(search, textCursor, flags);
|
2013-04-18 03:01:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (textCursor.isNull()) {
|
2013-04-18 03:01:10 +04:00
|
|
|
// first search found nothing, wrap around and search again
|
2013-11-01 20:56:43 +04:00
|
|
|
textCursor = this->Output->textCursor();
|
|
|
|
textCursor.movePosition(directionForward ? QTextCursor::Start
|
|
|
|
: QTextCursor::End);
|
|
|
|
textCursor = document->find(search, textCursor, flags);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:01:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (textCursor.hasSelection()) {
|
2013-11-01 20:56:43 +04:00
|
|
|
this->Output->setTextCursor(textCursor);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:01:10 +04:00
|
|
|
}
|
2013-04-18 03:06:00 +04:00
|
|
|
|
|
|
|
void CMakeSetupDialog::doOutputErrorNext()
|
|
|
|
{
|
2013-11-01 20:56:43 +04:00
|
|
|
QTextCursor textCursor = this->Output->textCursor();
|
2013-04-18 03:06:00 +04:00
|
|
|
bool atEnd = false;
|
|
|
|
|
|
|
|
// move cursor out of current error-block
|
2016-05-16 17:34:04 +03:00
|
|
|
if (textCursor.blockCharFormat() == this->ErrorFormat) {
|
2013-11-01 20:56:43 +04:00
|
|
|
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:06:00 +04:00
|
|
|
|
|
|
|
// move cursor to next error-block
|
2016-05-16 17:34:04 +03:00
|
|
|
while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
|
2013-11-01 20:56:43 +04:00
|
|
|
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:06:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (atEnd) {
|
2013-04-18 03:06:00 +04:00
|
|
|
// first search found nothing, wrap around and search again
|
2013-11-01 20:56:43 +04:00
|
|
|
atEnd = !textCursor.movePosition(QTextCursor::Start);
|
2013-04-18 03:06:00 +04:00
|
|
|
|
|
|
|
// move cursor to next error-block
|
2016-05-16 17:34:04 +03:00
|
|
|
while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
|
2013-11-01 20:56:43 +04:00
|
|
|
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
|
2013-04-18 03:06:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:06:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!atEnd) {
|
2013-11-01 20:56:43 +04:00
|
|
|
textCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
2013-04-18 03:06:00 +04:00
|
|
|
|
|
|
|
QTextCharFormat selectionFormat;
|
|
|
|
selectionFormat.setBackground(Qt::yellow);
|
2016-05-16 17:34:04 +03:00
|
|
|
QTextEdit::ExtraSelection extraSelection = { textCursor, selectionFormat };
|
2013-04-18 03:06:00 +04:00
|
|
|
this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>()
|
|
|
|
<< extraSelection);
|
|
|
|
|
|
|
|
// make the whole error-block visible
|
2013-11-01 20:56:43 +04:00
|
|
|
this->Output->setTextCursor(textCursor);
|
2013-04-18 03:06:00 +04:00
|
|
|
|
|
|
|
// remove the selection to see the extraSelection
|
2013-11-01 20:56:43 +04:00
|
|
|
textCursor.setPosition(textCursor.anchor());
|
|
|
|
this->Output->setTextCursor(textCursor);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-04-18 03:06:00 +04:00
|
|
|
}
|
2015-12-06 15:33:13 +03:00
|
|
|
|
|
|
|
void CMakeSetupDialog::doWarningMessagesDialog()
|
|
|
|
{
|
|
|
|
WarningMessagesDialog dialog(this, this->CMakeThread->cmakeInstance());
|
|
|
|
dialog.exec();
|
|
|
|
}
|