diff options
Diffstat (limited to 'Source/QtDialog')
26 files changed, 460 insertions, 238 deletions
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index 6284ac946..f5e0777bf 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -21,8 +21,8 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames, , VarTypes(varTypes) { this->setupUi(this); - for (int i = 0; i < NumTypes; i++) { - this->Type->addItem(TypeStrings[i]); + for (auto const& elem : TypeStrings) { + this->Type->addItem(elem); } QWidget* cb = new QCheckBox(); QWidget* path = new QCMakePathEditor(); @@ -32,12 +32,12 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames, this->StackedWidget->addWidget(path); this->StackedWidget->addWidget(filepath); this->StackedWidget->addWidget(string); - this->setTabOrder(this->Name, this->Type); - this->setTabOrder(this->Type, cb); - this->setTabOrder(cb, path); - this->setTabOrder(path, filepath); - this->setTabOrder(filepath, string); - this->setTabOrder(string, this->Description); + AddCacheEntry::setTabOrder(this->Name, this->Type); + AddCacheEntry::setTabOrder(this->Type, cb); + AddCacheEntry::setTabOrder(cb, path); + AddCacheEntry::setTabOrder(path, filepath); + AddCacheEntry::setTabOrder(filepath, string); + AddCacheEntry::setTabOrder(string, this->Description); QCompleter* completer = new QCompleter(this->VarNames, this); this->Name->setCompleter(completer); connect(completer, SIGNAL(activated(const QString&)), this, diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index cc710f558..e7a60ddb3 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -4,14 +4,15 @@ #define AddCacheEntry_h #include "QCMake.h" - #include <QCheckBox> #include <QStringList> #include <QWidget> #include "ui_AddCacheEntry.h" -class AddCacheEntry : public QWidget, public Ui::AddCacheEntry +class AddCacheEntry + : public QWidget + , public Ui::AddCacheEntry { Q_OBJECT public: diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 9e9df781e..cb89d19fd 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -2,9 +2,6 @@ # file Copyright.txt or https://cmake.org/licensing for details. project(QtDialog) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required -endif() CMake_OPTIONAL_COMPONENT(cmake-gui) find_package(Qt5Widgets QUIET) if (Qt5Widgets_FOUND) @@ -19,9 +16,20 @@ if (Qt5Widgets_FOUND) macro(qt4_add_resources) qt5_add_resources(${ARGN}) endmacro() + set(CMake_QT_LIBRARIES ${Qt5Widgets_LIBRARIES}) set(QT_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES}) + # Try to find the package WinExtras for the task bar progress + if(WIN32) + find_package(Qt5WinExtras QUIET) + if (Qt5WinExtras_FOUND) + include_directories(${Qt5WinExtras_INCLUDE_DIRS}) + add_definitions(-DQT_WINEXTRAS) + list(APPEND CMake_QT_LIBRARIES ${Qt5WinExtras_LIBRARIES}) + endif() + endif() + # Remove this when the minimum version of Qt is 4.6. add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) @@ -33,8 +41,14 @@ if (Qt5Widgets_FOUND) PROPERTY COMPILE_DEFINITIONS USE_QXcbIntegrationPlugin) endif() + if(CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES) + list(APPEND CMake_QT_LIBRARIES ${CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES}) + set_property(SOURCE CMakeSetup.cxx + PROPERTY COMPILE_DEFINITIONS USE_QWindowsIntegrationPlugin) + endif() + # We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows. - # FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly + # FIXME: This should be part of Qt5 CMake scripts, but unfortunately # Qt5 support is missing there. if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var) @@ -65,7 +79,7 @@ if (Qt5Widgets_FOUND) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" ${COMPONENT}) - elseif(WIN32) + elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES) install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = ../${_qt_plugin_dir}\n") @@ -160,6 +174,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS} ${MANIFEST_FILE}) target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES}) +if(WIN32) + target_sources(cmake-gui PRIVATE $<TARGET_OBJECTS:CMakeVersion>) +endif() + # cmake-gui has not been updated for `include-what-you-use`. # Block the tool until this is done. set_target_properties(cmake-gui PROPERTIES diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 7fa2ac661..ee81a7d62 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -1,16 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "QCMake.h" // include to disable MS warnings +#include <iostream> -#include "CMakeSetupDialog.h" -#include "cmAlgorithms.h" -#include "cmDocumentation.h" -#include "cmDocumentationEntry.h" -#include "cmVersion.h" -#include "cmake.h" -#include "cmsys/CommandLineArguments.hxx" -#include "cmsys/Encoding.hxx" -#include "cmsys/SystemTools.hxx" +#include "QCMake.h" // include to disable MS warnings #include <QApplication> #include <QDir> #include <QLocale> @@ -18,23 +10,34 @@ #include <QTextCodec> #include <QTranslator> #include <QtPlugin> -#include <iostream> +#include "cmsys/CommandLineArguments.hxx" +#include "cmsys/Encoding.hxx" +#include "cmsys/SystemTools.hxx" + +#include "CMakeSetupDialog.h" +#include "cmAlgorithms.h" +#include "cmDocumentation.h" +#include "cmDocumentationEntry.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" // IWYU pragma: keep +#include "cmVersion.h" +#include "cmake.h" -static const char* cmDocumentationName[][2] = { { CM_NULLPTR, +static const char* cmDocumentationName[][2] = { { nullptr, " cmake-gui - CMake GUI." }, - { CM_NULLPTR, CM_NULLPTR } }; + { nullptr, nullptr } }; static const char* cmDocumentationUsage[][2] = { - { CM_NULLPTR, " cmake-gui [options]\n" - " cmake-gui [options] <path-to-source>\n" - " cmake-gui [options] <path-to-existing-build>" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, + " cmake-gui [options]\n" + " cmake-gui [options] <path-to-source>\n" + " cmake-gui [options] <path-to-existing-build>\n" + " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n" }, + { nullptr, nullptr } }; -static const char* cmDocumentationOptions[] - [2] = { { CM_NULLPTR, CM_NULLPTR } }; +static const char* cmDocumentationOptions[][2] = { { nullptr, nullptr } }; #if defined(Q_OS_MAC) static int cmOSXInstall(std::string dir); @@ -45,13 +48,22 @@ static void cmAddPluginPath(); Q_IMPORT_PLUGIN(QXcbIntegrationPlugin); #endif +#if defined(USE_QWindowsIntegrationPlugin) +Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); +# if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin); +# endif +#endif + int main(int argc, char** argv) { + cmSystemTools::EnsureStdPipes(); cmsys::Encoding::CommandLineArguments encoding_args = cmsys::Encoding::CommandLineArguments::Main(argc, argv); int argc2 = encoding_args.argc(); char const* const* argv2 = encoding_args.argv(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(argv2[0]); // check docs first so that X is not need to get docs // do docs, if args were given @@ -59,13 +71,12 @@ int main(int argc, char** argv) doc.addCMakeStandardDocSections(); if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal); + cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); - std::vector<cmDocumentationEntry> generators; - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); @@ -93,6 +104,10 @@ int main(int argc, char** argv) cmAddPluginPath(); #endif +#if QT_VERSION >= 0x050600 + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + QApplication app(argc, argv); setlocale(LC_NUMERIC, "C"); @@ -121,36 +136,66 @@ int main(int argc, char** argv) QTranslator translator; QString transfile = QString("cmake_%1").arg(QLocale::system().name()); translator.load(transfile, translationsDir.path()); - app.installTranslator(&translator); + QApplication::installTranslator(&translator); // app setup - app.setApplicationName("CMakeSetup"); - app.setOrganizationName("Kitware"); + QApplication::setApplicationName("CMakeSetup"); + QApplication::setOrganizationName("Kitware"); QIcon appIcon; appIcon.addFile(":/Icons/CMakeSetup32.png"); appIcon.addFile(":/Icons/CMakeSetup128.png"); - app.setWindowIcon(appIcon); + QApplication::setWindowIcon(appIcon); CMakeSetupDialog dialog; dialog.show(); - cmsys::CommandLineArguments arg; - arg.Initialize(argc2, argv2); + QStringList args = QApplication::arguments(); std::string binaryDirectory; std::string sourceDirectory; - typedef cmsys::CommandLineArguments argT; - arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory, - "Binary Directory"); - arg.AddArgument("-H", argT::CONCAT_ARGUMENT, &sourceDirectory, - "Source Directory"); - // do not complain about unknown options - arg.StoreUnusedArguments(true); - arg.Parse(); + for (int i = 1; i < args.size(); ++i) { + const QString& arg = args[i]; + if (arg.startsWith("-S")) { + QString path = arg.mid(2); + if (path.isEmpty()) { + ++i; + if (i >= args.size()) { + std::cerr << "No source directory specified for -S" << std::endl; + return 1; + } + path = args[i]; + if (path[0] == '-') { + std::cerr << "No source directory specified for -S" << std::endl; + return 1; + } + } + + sourceDirectory = + cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + cmSystemTools::ConvertToUnixSlashes(sourceDirectory); + } else if (arg.startsWith("-B")) { + QString path = arg.mid(2); + if (path.isEmpty()) { + ++i; + if (i >= args.size()) { + std::cerr << "No build directory specified for -B" << std::endl; + return 1; + } + path = args[i]; + if (path[0] == '-') { + std::cerr << "No build directory specified for -B" << std::endl; + return 1; + } + } + + binaryDirectory = + cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + cmSystemTools::ConvertToUnixSlashes(binaryDirectory); + } + } if (!sourceDirectory.empty() && !binaryDirectory.empty()) { dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str())); dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str())); } else { - QStringList args = app.arguments(); if (args.count() == 2) { std::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); @@ -180,14 +225,16 @@ int main(int argc, char** argv) } } - return app.exec(); + return QApplication::exec(); } #if defined(Q_OS_MAC) -#include "cm_sys_stat.h" -#include <errno.h> -#include <string.h> -#include <unistd.h> +# include <cerrno> +# include <cstring> + +# include <unistd.h> + +# include "cm_sys_stat.h" static bool cmOSXInstall(std::string const& dir, std::string const& tool) { if (tool.empty()) { @@ -207,12 +254,11 @@ static bool cmOSXInstall(std::string const& dir, std::string const& tool) if (symlink(tool.c_str(), link.c_str()) == 0) { std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n"; return true; - } else { - int err = errno; - std::cerr << "Failed: '" << link << "' -> '" << tool - << "': " << strerror(err) << "\n"; - return false; } + int err = errno; + std::cerr << "Failed: '" << link << "' -> '" << tool + << "': " << strerror(err) << "\n"; + return false; } static int cmOSXInstall(std::string dir) { diff --git a/Source/QtDialog/CMakeSetup.icns b/Source/QtDialog/CMakeSetup.icns Binary files differindex 4a50c0416..e0bf8fdfa 100644 --- a/Source/QtDialog/CMakeSetup.icns +++ b/Source/QtDialog/CMakeSetup.icns diff --git a/Source/QtDialog/CMakeSetup.ico b/Source/QtDialog/CMakeSetup.ico Binary files differindex e13bb156f..1ac13c830 100644 --- a/Source/QtDialog/CMakeSetup.ico +++ b/Source/QtDialog/CMakeSetup.ico diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png Binary files differindex 12f1d9a9a..32984e104 100644 --- a/Source/QtDialog/CMakeSetup128.png +++ b/Source/QtDialog/CMakeSetup128.png diff --git a/Source/QtDialog/CMakeSetup32.png b/Source/QtDialog/CMakeSetup32.png Binary files differindex 7bbcee413..78df82f15 100644 --- a/Source/QtDialog/CMakeSetup32.png +++ b/Source/QtDialog/CMakeSetup32.png diff --git a/Source/QtDialog/CMakeSetup64.png b/Source/QtDialog/CMakeSetup64.png Binary files differindex 43a8cc6af..5c2dbf552 100644 --- a/Source/QtDialog/CMakeSetup64.png +++ b/Source/QtDialog/CMakeSetup64.png diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 57f8e107e..436a90466 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -21,18 +21,25 @@ #include <QToolButton> #include <QUrl> -#include "AddCacheEntry.h" -#include "FirstConfigure.h" +#ifdef QT_WINEXTRAS +# include <QWinTaskbarButton> +# include <QWinTaskbarProgress> +#endif + #include "QCMake.h" #include "QCMakeCacheView.h" -#include "RegexExplorer.h" -#include "WarningMessagesDialog.h" + #include "cmSystemTools.h" #include "cmVersion.h" +#include "AddCacheEntry.h" +#include "FirstConfigure.h" +#include "RegexExplorer.h" +#include "WarningMessagesDialog.h" + QCMakeThread::QCMakeThread(QObject* p) : QThread(p) - , CMakeInstance(CM_NULLPTR) + , CMakeInstance(nullptr) { } @@ -48,7 +55,7 @@ void QCMakeThread::run() emit this->cmakeInitialized(); this->exec(); delete this->CMakeInstance; - this->CMakeInstance = CM_NULLPTR; + this->CMakeInstance = nullptr; } CMakeSetupDialog::CMakeSetupDialog() @@ -108,7 +115,7 @@ CMakeSetupDialog::CMakeSetupDialog() QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools")); this->ConfigureAction = ToolsMenu->addAction(tr("&Configure")); - // prevent merging with Preferences menu item on Mac OS X + // prevent merging with Preferences menu item on macOS this->ConfigureAction->setMenuRole(QAction::NoRole); QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this, SLOT(doConfigure())); @@ -188,6 +195,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 +259,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, @@ -287,6 +301,11 @@ void CMakeSetupDialog::initialize() } else { this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text()); } + +#ifdef QT_WINEXTRAS + this->TaskbarButton = new QWinTaskbarButton(this); + this->TaskbarButton->setWindow(this->windowHandle()); +#endif } CMakeSetupDialog::~CMakeSetupDialog() @@ -374,6 +393,10 @@ void CMakeSetupDialog::doConfigure() this->CacheValues->scrollToTop(); } this->ProgressBar->reset(); + +#ifdef QT_WINEXTRAS + this->TaskbarButton->progress()->reset(); +#endif } bool CMakeSetupDialog::doConfigureInternal() @@ -488,28 +511,17 @@ void CMakeSetupDialog::doGenerate() this->enterState(ReadyConfigure); this->ProgressBar->reset(); +#ifdef QT_WINEXTRAS + this->TaskbarButton->progress()->reset(); +#endif 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 +642,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() @@ -686,6 +693,12 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent) { percent = (percent * ProgressFactor) + ProgressOffset; this->ProgressBar->setValue(qRound(percent * 100)); + +#ifdef QT_WINEXTRAS + QWinTaskbarProgress* progress = this->TaskbarButton->progress(); + progress->setVisible(true); + progress->setValue(qRound(percent * 100)); +#endif } void CMakeSetupDialog::error(const QString& msg) @@ -739,6 +752,7 @@ bool CMakeSetupDialog::setupFirstConfigure() if (dialog.exec() == QDialog::Accepted) { dialog.saveToSettings(); this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); + this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform()); this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset()); QCMakeCacheModel* m = this->CacheValues->cacheModel(); @@ -850,11 +864,11 @@ void CMakeSetupDialog::doAbout() "built using Qt %2 (qt-project.org).\n" #ifdef USE_LGPL "\n" - "The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n" + "The Qt Toolkit is Copyright (C) The Qt Company Ltd.\n" "Qt is licensed under terms of the GNU LGPLv" USE_LGPL ", available at:\n" " \"%3\"" #endif - ); + ); msg = msg.arg(cmVersion::GetCMakeVersion()); msg = msg.arg(qVersion()); #ifdef USE_LGPL @@ -1001,8 +1015,9 @@ void CMakeSetupDialog::removeSelectedCacheEntries() void CMakeSetupDialog::selectionChanged() { QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows(); - if (idxs.count() && (this->CurrentState == ReadyConfigure || - this->CurrentState == ReadyGenerate)) { + if (idxs.count() && + (this->CurrentState == ReadyConfigure || + this->CurrentState == ReadyGenerate)) { this->RemoveEntry->setEnabled(true); } else { this->RemoveEntry->setEnabled(false); @@ -1039,9 +1054,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 +1061,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")); } @@ -1195,7 +1204,7 @@ void CMakeSetupDialog::setSearchFilter(const QString& str) this->CacheValues->setSearchFilter(str); } -void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt) +void CMakeSetupDialog::doOutputContextMenu(QPoint pt) { QMenu* menu = this->Output->createStandardContextMenu(); diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 1abdb462d..f23aee6e8 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -4,19 +4,25 @@ #define CMakeSetupDialog_h #include "QCMake.h" - -#include "ui_CMakeSetupDialog.h" #include <QEventLoop> #include <QMainWindow> #include <QThread> +#include "ui_CMakeSetupDialog.h" + class QCMakeThread; class CMakeCacheModel; class QProgressBar; class QToolButton; +#ifdef QT_WINEXTRAS +class QWinTaskbarButton; +#endif + /// Qt user interface for CMake -class CMakeSetupDialog : public QMainWindow, public Ui::CMakeSetupDialog +class CMakeSetupDialog + : public QMainWindow + , public Ui::CMakeSetupDialog { Q_OBJECT public: @@ -31,7 +37,6 @@ protected slots: void initialize(); void doConfigure(); void doGenerate(); - QString getProjectFilename(); void doOpenProject(); void doInstallForCommandLine(); void doHelp(); @@ -70,7 +75,7 @@ protected slots: bool doConfigureInternal(); bool doGenerateInternal(); void exitLoop(int); - void doOutputContextMenu(const QPoint&); + void doOutputContextMenu(QPoint pt); void doOutputFindDialog(); void doOutputFindNext(bool directionForward = true); void doOutputFindPrev(); @@ -117,6 +122,10 @@ protected: QEventLoop LocalLoop; +#ifdef QT_WINEXTRAS + QWinTaskbarButton* TaskbarButton; +#endif + float ProgressOffset; float ProgressFactor; }; diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index 8d8e0cdc2..dc22a2989 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -57,6 +57,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="styleSheet"> + <string notr="true">padding-left: 0</string> + </property> <property name="editable"> <bool>true</bool> </property> diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h index 6c8c8f52a..931c93566 100644 --- a/Source/QtDialog/Compilers.h +++ b/Source/QtDialog/Compilers.h @@ -3,17 +3,19 @@ #ifndef COMPILERS_HPP #define COMPILERS_HPP -#include "cmConfigure.h" - -#include <QWidget> +#include "cmConfigure.h" // IWYU pragma: keep #include <ui_Compilers.h> -class Compilers : public QWidget, public Ui::Compilers +#include <QWidget> + +class Compilers + : public QWidget + , public Ui::Compilers { Q_OBJECT public: - Compilers(QWidget* p = CM_NULLPTR) + Compilers(QWidget* p = nullptr) : QWidget(p) { this->setupUi(this); diff --git a/Source/QtDialog/Delete16.png b/Source/QtDialog/Delete16.png Binary files differindex 16989fee1..9d2f2b7ec 100644 --- a/Source/QtDialog/Delete16.png +++ b/Source/QtDialog/Delete16.png diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index b193a2782..ca28b1972 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -1,13 +1,15 @@ #include "FirstConfigure.h" -#include "Compilers.h" - #include <QComboBox> #include <QRadioButton> #include <QSettings> #include <QVBoxLayout> +#include "cmStringAlgorithms.h" + +#include "Compilers.h" + StartCompilerSetup::StartCompilerSetup(QWidget* p) : QWizardPage(p) { @@ -16,8 +18,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) this->GeneratorOptions = new QComboBox(this); l->addWidget(this->GeneratorOptions); + // Add the generator platform + this->PlatformFrame = CreatePlatformWidgets(); + l->addWidget(PlatformFrame); + // Add the ability to specify toolset (-T parameter) - ToolsetFrame = CreateToolsetWidgets(); + this->ToolsetFrame = CreateToolsetWidgets(); l->addWidget(ToolsetFrame); l->addSpacing(6); @@ -45,7 +51,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) SLOT(onSelectionChanged(bool))); QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this, SLOT(onSelectionChanged(bool))); - QObject::connect(GeneratorOptions, + QObject::connect(this->GeneratorOptions, SIGNAL(currentIndexChanged(QString const&)), this, SLOT(onGeneratorChanged(QString const&))); } @@ -65,10 +71,25 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets() return frame; } -StartCompilerSetup::~StartCompilerSetup() +QFrame* StartCompilerSetup::CreatePlatformWidgets() { + QFrame* frame = new QFrame(this); + QVBoxLayout* l = new QVBoxLayout(frame); + l->setContentsMargins(0, 0, 0, 0); + + this->PlatformLabel = new QLabel(tr("Optional platform for generator")); + l->addWidget(this->PlatformLabel); + + this->PlatformOptions = new QComboBox(frame); + this->PlatformOptions->setEditable(true); + + l->addWidget(this->PlatformOptions); + + return frame; } +StartCompilerSetup::~StartCompilerSetup() = default; + void StartCompilerSetup::setGenerators( std::vector<cmake::GeneratorInfo> const& gens) { @@ -76,13 +97,31 @@ void StartCompilerSetup::setGenerators( QStringList generator_list; - std::vector<cmake::GeneratorInfo>::const_iterator it; - for (it = gens.begin(); it != gens.end(); ++it) { - generator_list.append(QString::fromLocal8Bit(it->name.c_str())); + for (cmake::GeneratorInfo const& gen : gens) { + generator_list.append(QString::fromLocal8Bit(gen.name.c_str())); + + if (gen.supportsPlatform) { + this->GeneratorsSupportingPlatform.append( + QString::fromLocal8Bit(gen.name.c_str())); + + this + ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] = + QString::fromLocal8Bit(gen.defaultPlatform.c_str()); + + auto platformIt = gen.supportedPlatforms.cbegin(); + while (platformIt != gen.supportedPlatforms.cend()) { + + this->GeneratorSupportedPlatforms.insert( + QString::fromLocal8Bit(gen.name.c_str()), + QString::fromLocal8Bit((*platformIt).c_str())); + + platformIt++; + } + } - if (it->supportsToolset) { + if (gen.supportsToolset) { this->GeneratorsSupportingToolset.append( - QString::fromLocal8Bit(it->name.c_str())); + QString::fromLocal8Bit(gen.name.c_str())); } } @@ -102,6 +141,11 @@ QString StartCompilerSetup::getGenerator() const return this->GeneratorOptions->currentText(); }; +QString StartCompilerSetup::getPlatform() const +{ + return this->PlatformOptions->currentText(); +}; + QString StartCompilerSetup::getToolset() const { return this->Toolset->text(); @@ -136,6 +180,30 @@ void StartCompilerSetup::onSelectionChanged(bool on) void StartCompilerSetup::onGeneratorChanged(QString const& name) { + // Display the generator platform for the generators supporting it + if (GeneratorsSupportingPlatform.contains(name)) { + + // Change the label title to include the default platform + std::string label = + cmStrCat("Optional platform for generator(if empty, generator uses: ", + this->GeneratorDefaultPlatform[name].toStdString(), ')'); + this->PlatformLabel->setText(tr(label.c_str())); + + // Regenerate the list of supported platform + this->PlatformOptions->clear(); + QStringList platform_list; + platform_list.append(""); + + QList<QString> platforms = this->GeneratorSupportedPlatforms.values(name); + platform_list.append(platforms); + + this->PlatformOptions->addItems(platform_list); + PlatformFrame->show(); + } else { + PlatformFrame->hide(); + } + + // Display the toolset box for the generators supporting it if (GeneratorsSupportingToolset.contains(name)) { ToolsetFrame->show(); } else { @@ -166,9 +234,7 @@ NativeCompilerSetup::NativeCompilerSetup(QWidget* p) this->setupUi(c); } -NativeCompilerSetup::~NativeCompilerSetup() -{ -} +NativeCompilerSetup::~NativeCompilerSetup() = default; QString NativeCompilerSetup::getCCompiler() const { @@ -230,9 +296,7 @@ CrossCompilerSetup::CrossCompilerSetup(QWidget* p) this->registerField("systemName*", this->systemName); } -CrossCompilerSetup::~CrossCompilerSetup() -{ -} +CrossCompilerSetup::~CrossCompilerSetup() = default; QString CrossCompilerSetup::getCCompiler() const { @@ -301,7 +365,7 @@ QString CrossCompilerSetup::getFindRoot() const void CrossCompilerSetup::setFindRoot(const QString& t) { - return this->crossFindRoot->setText(t); + this->crossFindRoot->setText(t); } int CrossCompilerSetup::getProgramMode() const @@ -343,9 +407,7 @@ ToolchainCompilerSetup::ToolchainCompilerSetup(QWidget* p) l->addWidget(this->ToolchainFile); } -ToolchainCompilerSetup::~ToolchainCompilerSetup() -{ -} +ToolchainCompilerSetup::~ToolchainCompilerSetup() = default; QString ToolchainCompilerSetup::toolchainFile() const { @@ -375,9 +437,7 @@ FirstConfigure::FirstConfigure() this->setPage(ToolchainSetup, this->mToolchainCompilerSetupPage); } -FirstConfigure::~FirstConfigure() -{ -} +FirstConfigure::~FirstConfigure() = default; void FirstConfigure::setGenerators( std::vector<cmake::GeneratorInfo> const& gens) @@ -390,6 +450,11 @@ QString FirstConfigure::getGenerator() const return this->mStartCompilerSetupPage->getGenerator(); } +QString FirstConfigure::getPlatform() const +{ + return this->mStartCompilerSetupPage->getPlatform(); +} + QString FirstConfigure::getToolset() const { return this->mStartCompilerSetupPage->getToolset(); diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h index c467ddb19..d1db5bff6 100644 --- a/Source/QtDialog/FirstConfigure.h +++ b/Source/QtDialog/FirstConfigure.h @@ -35,6 +35,7 @@ public: void setCurrentGenerator(const QString& gen); QString getGenerator() const; QString getToolset() const; + QString getPlatform() const; bool defaultSetup() const; bool compilerSetup() const; @@ -56,14 +57,23 @@ protected: QFrame* ToolsetFrame; QLineEdit* Toolset; QLabel* ToolsetLabel; + QFrame* PlatformFrame; + QComboBox* PlatformOptions; + QLabel* PlatformLabel; QStringList GeneratorsSupportingToolset; + QStringList GeneratorsSupportingPlatform; + QMultiMap<QString, QString> GeneratorSupportedPlatforms; + QMap<QString, QString> GeneratorDefaultPlatform; private: QFrame* CreateToolsetWidgets(); + QFrame* CreatePlatformWidgets(); }; //! the page that gives basic options for native compilers -class NativeCompilerSetup : public QWizardPage, protected Ui::Compilers +class NativeCompilerSetup + : public QWizardPage + , protected Ui::Compilers { Q_OBJECT public: @@ -83,7 +93,9 @@ public: }; //! the page that gives options for cross compilers -class CrossCompilerSetup : public QWizardPage, protected Ui::CrossCompiler +class CrossCompilerSetup + : public QWizardPage + , protected Ui::CrossCompiler { Q_OBJECT public: @@ -155,6 +167,7 @@ public: void setGenerators(std::vector<cmake::GeneratorInfo> const& gens); QString getGenerator() const; + QString getPlatform() const; QString getToolset() const; bool defaultSetup() const; diff --git a/Source/QtDialog/Plus16.png b/Source/QtDialog/Plus16.png Binary files differindex 552f6f004..1c33bc763 100644 --- a/Source/QtDialog/Plus16.png +++ b/Source/QtDialog/Plus16.png diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index d473d9b8f..b608fcbfc 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -7,10 +7,11 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #ifdef Q_OS_WIN -#include "qt_windows.h" // For SetErrorMode +# include "qt_windows.h" // For SetErrorMode #endif QCMake::QCMake(QObject* p) @@ -23,32 +24,33 @@ QCMake::QCMake(QObject* p) cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); - cmSystemTools::SetMessageCallback(QCMake::messageCallback, this); - cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this); - cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this); - this->CMakeInstance = new cmake(cmake::RoleProject); + cmSystemTools::SetMessageCallback( + [this](std::string const& msg, const char* title) { + this->messageCallback(msg, title); + }); + cmSystemTools::SetStdoutCallback( + [this](std::string const& msg) { this->stdoutCallback(msg); }); + cmSystemTools::SetStderrCallback( + [this](std::string const& msg) { this->stderrCallback(msg); }); + + this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeGUICommand()); - this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); + this->CMakeInstance->SetProgressCallback( + [this](const std::string& msg, float percent) { + this->progressCallback(msg, percent); + }); - cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); + cmSystemTools::SetInterruptCallback( + [this] { return this->interruptCallback(); }); std::vector<cmake::GeneratorInfo> generators; - this->CMakeInstance->GetRegisteredGenerators(generators); - - std::vector<cmake::GeneratorInfo>::const_iterator it; - for (it = generators.begin(); it != generators.end(); ++it) { - // Skip the generator "KDevelop3", since there is also - // "KDevelop3 - Unix Makefiles", which is the full and official name. - // The short name is actually only still there since this was the name - // in CMake 2.4, to keep "command line argument compatibility", but - // this is not necessary in the GUI. - if (it->name == "KDevelop3") { - continue; - } + this->CMakeInstance->GetRegisteredGenerators( + generators, /*includeNamesWithPlatform=*/false); - this->AvailableGenerators.push_back(*it); + for (cmake::GeneratorInfo const& gen : generators) { + this->AvailableGenerators.push_back(gen); } } @@ -83,6 +85,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmState* state = this->CMakeInstance->GetState(); this->setGenerator(QString()); this->setToolset(QString()); + this->setPlatform(QString()); if (!this->CMakeInstance->LoadCache( this->BinaryDirectory.toLocal8Bit().data())) { QDir testDir(this->BinaryDirectory); @@ -103,18 +106,26 @@ void QCMake::setBinaryDirectory(const QString& _dir) } const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR"); if (gen) { - const char* extraGen = + const std::string* extraGen = state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); std::string curGen = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - gen, extraGen ? extraGen : ""); + gen, extraGen ? *extraGen : ""); this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } + const char* platform = + state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); + if (platform) { + this->setPlatform(QString::fromLocal8Bit(platform)); + } + const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET"); if (toolset) { this->setToolset(QString::fromLocal8Bit(toolset)); } + + checkOpenPossible(); } } @@ -126,6 +137,14 @@ void QCMake::setGenerator(const QString& gen) } } +void QCMake::setPlatform(const QString& platform) +{ + if (this->Platform != platform) { + this->Platform = platform; + emit this->platformChanged(this->Platform); + } +} + void QCMake::setToolset(const QString& toolset) { if (this->Toolset != toolset) { @@ -147,7 +166,8 @@ void QCMake::configure() this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator( this->Generator.toLocal8Bit().data())); - this->CMakeInstance->SetGeneratorPlatform(""); + this->CMakeInstance->SetGeneratorPlatform( + this->Platform.toLocal8Bit().data()); this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data()); this->CMakeInstance->LoadCache(); this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); @@ -183,6 +203,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) @@ -194,38 +234,37 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) // set the value of properties cmState* state = this->CMakeInstance->GetState(); std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); - for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); - it != cacheKeys.end(); ++it) { - cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it); + for (std::string const& key : cacheKeys) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key); if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) { continue; } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(it->c_str()); + prop.Key = QString::fromLocal8Bit(key.c_str()); int idx = props.indexOf(prop); if (idx == -1) { - toremove.append(QString::fromLocal8Bit(it->c_str())); + toremove.append(QString::fromLocal8Bit(key.c_str())); } else { prop = props[idx]; if (prop.Value.type() == QVariant::Bool) { - state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF"); + state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF"); } else { - state->SetCacheEntryValue(*it, + state->SetCacheEntryValue(key, prop.Value.toString().toLocal8Bit().data()); } props.removeAt(idx); } } - // remove some properites + // remove some properties foreach (QString const& s, toremove) { this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data()); state->RemoveCacheEntry(s.toLocal8Bit().data()); } - // add some new properites + // add some new properties foreach (QCMakeProperty const& s, props) { this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data()); @@ -257,25 +296,24 @@ QCMakePropertyList QCMake::properties() const cmState* state = this->CMakeInstance->GetState(); std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); - for (std::vector<std::string>::const_iterator i = cacheKeys.begin(); - i != cacheKeys.end(); ++i) { - cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i); + for (std::string const& key : cacheKeys) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key); if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC || t == cmStateEnums::UNINITIALIZED) { continue; } - const char* cachedValue = state->GetCacheEntryValue(*i); + const char* cachedValue = state->GetCacheEntryValue(key); QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i->c_str()); + prop.Key = QString::fromLocal8Bit(key.c_str()); prop.Help = - QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING")); + QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING")); prop.Value = QString::fromLocal8Bit(cachedValue); - prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED"); + prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED"); if (t == cmStateEnums::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(cachedValue); + prop.Value = cmIsOn(cachedValue); } else if (t == cmStateEnums::PATH) { prop.Type = QCMakeProperty::PATH; } else if (t == cmStateEnums::FILEPATH) { @@ -283,7 +321,7 @@ QCMakePropertyList QCMake::properties() const } else if (t == cmStateEnums::STRING) { prop.Type = QCMakeProperty::STRING; const char* stringsProperty = - state->GetCacheEntryProperty(*i, "STRINGS"); + state->GetCacheEntryProperty(key, "STRINGS"); if (stringsProperty) { prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";"); } @@ -300,46 +338,40 @@ void QCMake::interrupt() this->InterruptFlag.ref(); } -bool QCMake::interruptCallback(void* cd) +bool QCMake::interruptCallback() { - QCMake* self = reinterpret_cast<QCMake*>(cd); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - return self->InterruptFlag; + return this->InterruptFlag; #else - return self->InterruptFlag.load(); + return this->InterruptFlag.load(); #endif } -void QCMake::progressCallback(const char* msg, float percent, void* cd) +void QCMake::progressCallback(const std::string& msg, float percent) { - QCMake* self = reinterpret_cast<QCMake*>(cd); if (percent >= 0) { - emit self->progressChanged(QString::fromLocal8Bit(msg), percent); + emit this->progressChanged(QString::fromStdString(msg), percent); } else { - emit self->outputMessage(QString::fromLocal8Bit(msg)); + emit this->outputMessage(QString::fromStdString(msg)); } QCoreApplication::processEvents(); } -void QCMake::messageCallback(const char* msg, const char* /*title*/, - bool& /*stop*/, void* cd) +void QCMake::messageCallback(std::string const& msg, const char* /*title*/) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->errorMessage(QString::fromLocal8Bit(msg)); + emit this->errorMessage(QString::fromStdString(msg)); QCoreApplication::processEvents(); } -void QCMake::stdoutCallback(const char* msg, size_t len, void* cd) +void QCMake::stdoutCallback(std::string const& msg) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromStdString(msg)); QCoreApplication::processEvents(); } -void QCMake::stderrCallback(const char* msg, size_t len, void* cd) +void QCMake::stderrCallback(std::string const& msg) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromStdString(msg)); QCoreApplication::processEvents(); } @@ -450,3 +482,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); +} diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index e14cdf2c9..fa4451bc2 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -3,13 +3,13 @@ #ifndef QCMake_h #define QCMake_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmake.h" #ifdef _MSC_VER -#pragma warning(disable : 4127) -#pragma warning(disable : 4512) +# pragma warning(disable : 4127) +# pragma warning(disable : 4512) #endif #include <vector> @@ -50,7 +50,7 @@ struct QCMakeProperty }; // list of properties -typedef QList<QCMakeProperty> QCMakePropertyList; +using QCMakePropertyList = QList<QCMakeProperty>; // allow QVariant to be a property or list of properties Q_DECLARE_METATYPE(QCMakeProperty) @@ -63,7 +63,7 @@ class QCMake : public QObject { Q_OBJECT public: - QCMake(QObject* p = CM_NULLPTR); + QCMake(QObject* p = nullptr); ~QCMake(); public slots: /// load the cache file in a directory @@ -75,11 +75,15 @@ public slots: /// set the desired generator to use void setGenerator(const QString& generator); /// set the desired generator to use + void setPlatform(const QString& platform); + /// set the desired generator to use void setToolset(const QString& toolset); /// do the configure step 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 +115,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,22 +157,29 @@ signals: void debugOutputChanged(bool); /// signal when the toolset changes void toolsetChanged(const QString& toolset); + /// signal when the platform changes + void platformChanged(const QString& platform); + /// signal when open is done + void openDone(bool successful); + /// signal when open is done + void openPossible(bool possible); protected: cmake* CMakeInstance; - static bool interruptCallback(void*); - static void progressCallback(const char* msg, float percent, void* cd); - static void messageCallback(const char* msg, const char* title, bool&, - void* cd); - static void stdoutCallback(const char* msg, size_t len, void* cd); - static void stderrCallback(const char* msg, size_t len, void* cd); + bool interruptCallback(); + void progressCallback(std::string const& msg, float percent); + void messageCallback(std::string const& msg, const char* title); + void stdoutCallback(std::string const& msg); + void stderrCallback(std::string const& msg); + bool WarnUninitializedMode; bool WarnUnusedMode; bool WarnUnusedAllMode; QString SourceDirectory; QString BinaryDirectory; QString Generator; + QString Platform; QString Toolset; std::vector<cmake::GeneratorInfo> AvailableGenerators; QString CMakeExecutable; diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 08c2d58d5..3e6a49e09 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "QCMakeCacheView.h" +#include "QCMakeWidgets.h" #include <QApplication> #include <QEvent> #include <QHBoxLayout> @@ -11,8 +12,6 @@ #include <QSortFilterProxyModel> #include <QStyle> -#include "QCMakeWidgets.h" - // filter for searches class QCMakeSearchFilter : public QSortFilterProxyModel { @@ -23,7 +22,7 @@ public: } protected: - bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE + bool filterAcceptsRow(int row, const QModelIndex& p) const override { QStringList strs; const QAbstractItemModel* m = this->sourceModel(); @@ -77,7 +76,7 @@ public: protected: bool ShowAdvanced; - bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE + bool filterAcceptsRow(int row, const QModelIndex& p) const override { const QAbstractItemModel* m = this->sourceModel(); QModelIndex idx = m->index(row, 0, p); @@ -186,9 +185,7 @@ QCMakeCacheModel::QCMakeCacheModel(QObject* p) this->setHorizontalHeaderLabels(labels); } -QCMakeCacheModel::~QCMakeCacheModel() -{ -} +QCMakeCacheModel::~QCMakeCacheModel() = default; static uint qHash(const QCMakeProperty& p) { @@ -212,7 +209,8 @@ void QCMakeCacheModel::clear() void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) { - QSet<QCMakeProperty> newProps, newProps2; + QSet<QCMakeProperty> newProps; + QSet<QCMakeProperty> newProps2; if (this->ShowNewProperties) { newProps = props.toSet(); @@ -248,9 +246,9 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) } } else if (this->View == GroupView) { QMap<QString, QCMakePropertyList> newPropsTree; - this->breakProperties(newProps, newPropsTree); + QCMakeCacheModel::breakProperties(newProps, newPropsTree); QMap<QString, QCMakePropertyList> newPropsTree2; - this->breakProperties(newProps2, newPropsTree2); + QCMakeCacheModel::breakProperties(newProps2, newPropsTree2); QStandardItem* root = this->invisibleRootItem(); @@ -539,7 +537,7 @@ QWidget* QCMakeCacheModelDelegate::createEditor( QModelIndex var = idx.sibling(idx.row(), 0); int type = var.data(QCMakeCacheModel::TypeRole).toInt(); if (type == QCMakeProperty::BOOL) { - return CM_NULLPTR; + return nullptr; } if (type == QCMakeProperty::PATH) { QCMakePathEditor* editor = @@ -614,7 +612,7 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, // Can remove this function and FileDialogFlag when minimum Qt version is 4.5 bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt) { - // workaround for what looks like a bug in Qt on Mac OS X + // workaround for what looks like a bug in Qt on macOS // where it doesn't create a QWidget wrapper for the native file dialog // so the Qt library ends up assuming the focus was lost to something else @@ -642,7 +640,7 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, QStyleOptionButton opt; opt.QStyleOption::operator=(option); sz = sz.expandedTo( - style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, CM_NULLPTR) + style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, nullptr) .size()); return sz; diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index c1debf590..bea196586 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -4,7 +4,6 @@ #define QCMakeCacheView_h #include "QCMake.h" - #include <QItemDelegate> #include <QSet> #include <QStandardItemModel> diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 7f0cafa37..332a770ef 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -2,15 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "QCMakeWidgets.h" +#include <utility> + #include <QDirModel> #include <QFileDialog> #include <QFileInfo> #include <QResizeEvent> #include <QToolButton> -QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var) +QCMakeFileEditor::QCMakeFileEditor(QWidget* p, QString var) : QLineEdit(p) - , Variable(var) + , Variable(std::move(var)) { this->ToolButton = new QToolButton(this); this->ToolButton->setText("..."); @@ -57,7 +59,7 @@ void QCMakeFilePathEditor::chooseFile() emit this->fileDialogExists(true); path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(), - CM_NULLPTR, QFileDialog::DontResolveSymlinks); + nullptr, QFileDialog::DontResolveSymlinks); emit this->fileDialogExists(false); if (!path.isEmpty()) { @@ -89,7 +91,7 @@ void QCMakePathEditor::chooseFile() // use same QDirModel for all completers static QDirModel* fileDirModel() { - static QDirModel* m = CM_NULLPTR; + static QDirModel* m = nullptr; if (!m) { m = new QDirModel(); } @@ -97,7 +99,7 @@ static QDirModel* fileDirModel() } static QDirModel* pathDirModel() { - static QDirModel* m = CM_NULLPTR; + static QDirModel* m = nullptr; if (!m) { m = new QDirModel(); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h index 1ec666ff6..5d2368eab 100644 --- a/Source/QtDialog/QCMakeWidgets.h +++ b/Source/QtDialog/QCMakeWidgets.h @@ -3,7 +3,7 @@ #ifndef QCMakeWidgets_h #define QCMakeWidgets_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include <QComboBox> #include <QCompleter> @@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit { Q_OBJECT public: - QCMakeFileEditor(QWidget* p, const QString& var); + QCMakeFileEditor(QWidget* p, QString var); protected slots: virtual void chooseFile() = 0; signals: @@ -35,7 +35,7 @@ class QCMakePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakePathEditor(QWidget* p = CM_NULLPTR, const QString& var = QString()); + QCMakePathEditor(QWidget* p = nullptr, const QString& var = QString()); void chooseFile(); }; @@ -44,8 +44,7 @@ class QCMakeFilePathEditor : public QCMakeFileEditor { Q_OBJECT public: - QCMakeFilePathEditor(QWidget* p = CM_NULLPTR, - const QString& var = QString()); + QCMakeFilePathEditor(QWidget* p = nullptr, const QString& var = QString()); void chooseFile(); }; diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx index abed70e90..746fd8af2 100644 --- a/Source/QtDialog/RegexExplorer.cxx +++ b/Source/QtDialog/RegexExplorer.cxx @@ -8,7 +8,7 @@ RegexExplorer::RegexExplorer(QWidget* p) { this->setupUi(this); - for (int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i) { + for (int i = 1; i < cmsys::RegularExpressionMatch::NSUBEXP; ++i) { matchNumber->addItem(QString("Match %1").arg(QString::number(i)), QVariant(i)); } @@ -20,7 +20,7 @@ void RegexExplorer::setStatusColor(QWidget* widget, bool successful) QColor color = successful ? QColor(0, 127, 0) : Qt::red; QPalette palette = widget->palette(); - palette.setColor(QPalette::Foreground, color); + palette.setColor(QPalette::WindowText, color); widget->setPalette(palette); } @@ -105,7 +105,7 @@ void RegexExplorer::on_matchNumber_currentIndexChanged(int index) QVariant itemData = matchNumber->itemData(index); int idx = itemData.toInt(); - if (idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP) { + if (idx < 1 || idx >= cmsys::RegularExpressionMatch::NSUBEXP) { return; } diff --git a/Source/QtDialog/RegexExplorer.h b/Source/QtDialog/RegexExplorer.h index 867989279..1a1d7700f 100644 --- a/Source/QtDialog/RegexExplorer.h +++ b/Source/QtDialog/RegexExplorer.h @@ -3,16 +3,20 @@ #ifndef RegexExplorer_h #define RegexExplorer_h -#include "cmsys/RegularExpression.hxx" -#include <QDialog> #include <string> +#include <QDialog> + +#include "cmsys/RegularExpression.hxx" + #include "ui_RegexExplorer.h" class QString; class QWidget; -class RegexExplorer : public QDialog, public Ui::RegexExplorer +class RegexExplorer + : public QDialog + , public Ui::RegexExplorer { Q_OBJECT public: diff --git a/Source/QtDialog/WarningMessagesDialog.h b/Source/QtDialog/WarningMessagesDialog.h index acb830d85..f209dbdb3 100644 --- a/Source/QtDialog/WarningMessagesDialog.h +++ b/Source/QtDialog/WarningMessagesDialog.h @@ -3,16 +3,18 @@ #ifndef WarningMessagesDialog_h #define WarningMessagesDialog_h +#include "QCMake.h" #include <QDialog> #include <QWidget> -#include "QCMake.h" #include "ui_WarningMessagesDialog.h" /** * Dialog window for setting the warning message related options. */ -class WarningMessagesDialog : public QDialog, public Ui_MessagesDialog +class WarningMessagesDialog + : public QDialog + , public Ui_MessagesDialog { Q_OBJECT |