diff options
Diffstat (limited to 'Source/QtDialog/FirstConfigure.cxx')
-rw-r--r-- | Source/QtDialog/FirstConfigure.cxx | 111 |
1 files changed, 88 insertions, 23 deletions
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(); |