diff --git a/src/plugins/nim/CMakeLists.txt b/src/plugins/nim/CMakeLists.txt index d01c9bc9087..739cbf27a97 100644 --- a/src/plugins/nim/CMakeLists.txt +++ b/src/plugins/nim/CMakeLists.txt @@ -18,7 +18,6 @@ add_qtc_plugin(Nim project/nimbuildsystem.cpp project/nimbuildsystem.h project/nimbuildconfiguration.cpp project/nimbuildconfiguration.h project/nimcompilerbuildstep.cpp project/nimcompilerbuildstep.h - project/nimcompilerbuildstepconfigwidget.cpp project/nimcompilerbuildstepconfigwidget.h project/nimcompilerbuildstepconfigwidget.ui project/nimcompilercleanstep.cpp project/nimcompilercleanstep.h project/nimproject.cpp project/nimproject.h project/nimprojectnode.cpp project/nimprojectnode.h diff --git a/src/plugins/nim/nim.pro b/src/plugins/nim/nim.pro index 92866bff1c8..1f19d4b6313 100644 --- a/src/plugins/nim/nim.pro +++ b/src/plugins/nim/nim.pro @@ -28,7 +28,6 @@ HEADERS += \ project/nimprojectnode.h \ project/nimbuildconfiguration.h \ project/nimcompilerbuildstep.h \ - project/nimcompilerbuildstepconfigwidget.h \ project/nimcompilercleanstep.h \ project/nimrunconfiguration.h \ editor/nimeditorfactory.h \ @@ -65,7 +64,6 @@ SOURCES += \ project/nimprojectnode.cpp \ project/nimbuildconfiguration.cpp \ project/nimcompilerbuildstep.cpp \ - project/nimcompilerbuildstepconfigwidget.cpp \ project/nimcompilercleanstep.cpp \ project/nimrunconfiguration.cpp \ editor/nimeditorfactory.cpp \ @@ -83,6 +81,5 @@ SOURCES += \ suggest/server.cpp FORMS += \ - project/nimcompilerbuildstepconfigwidget.ui \ settings/nimcodestylepreferenceswidget.ui \ settings/nimtoolssettingswidget.ui diff --git a/src/plugins/nim/nim.qbs b/src/plugins/nim/nim.qbs index 1075487d1b4..fe939465d09 100644 --- a/src/plugins/nim/nim.qbs +++ b/src/plugins/nim/nim.qbs @@ -40,7 +40,6 @@ QtcPlugin { "nimbuildsystem.cpp", "nimbuildsystem.h", "nimbuildconfiguration.h", "nimbuildconfiguration.cpp", "nimcompilerbuildstep.h", "nimcompilerbuildstep.cpp", - "nimcompilerbuildstepconfigwidget.h", "nimcompilerbuildstepconfigwidget.cpp", "nimcompilerbuildstepconfigwidget.ui", "nimcompilercleanstep.h", "nimcompilercleanstep.cpp", "nimproject.h", "nimproject.cpp", "nimprojectnode.h", "nimprojectnode.cpp", diff --git a/src/plugins/nim/project/nimcompilerbuildstep.cpp b/src/plugins/nim/project/nimcompilerbuildstep.cpp index 2e8a53ee3f1..bafdb631e5f 100644 --- a/src/plugins/nim/project/nimcompilerbuildstep.cpp +++ b/src/plugins/nim/project/nimcompilerbuildstep.cpp @@ -24,27 +24,62 @@ ****************************************************************************/ #include "nimcompilerbuildstep.h" + #include "nimbuildconfiguration.h" #include "nimbuildsystem.h" -#include "nimcompilerbuildstepconfigwidget.h" #include "nimconstants.h" #include "nimtoolchain.h" +#include #include #include #include -#include #include -#include +#include +#include + +#include +#include #include +#include +#include +#include #include +#include using namespace ProjectExplorer; using namespace Utils; namespace Nim { +class NimCompilerBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget +{ + Q_DECLARE_TR_FUNCTIONS(Nim::NimCompilerBuildStep) + +public: + explicit NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep); + +private: + void updateUi(); + void updateCommandLineText(); + void updateTargetComboBox(); + void updateAdditionalArgumentsLineEdit(); + void updateDefaultArgumentsComboBox(); + + void onAdditionalArgumentsTextEdited(const QString &text); + void onTargetChanged(int index); + void onDefaultArgumentsComboBoxIndexChanged(int index); + + NimCompilerBuildStep *m_buildStep; + QTextEdit *m_commandTextEdit; + QComboBox *m_defaultArgumentsComboBox; + QComboBox *m_targetComboBox; + QLineEdit *m_additionalArgumentsLineEdit; +}; + +// NimParser + class NimParser : public ProjectExplorer::OutputTaskParser { Result handleLine(const QString &lne, Utils::OutputFormat) override @@ -108,6 +143,53 @@ void NimCompilerBuildStep::setupOutputFormatter(OutputFormatter *formatter) AbstractProcessStep::setupOutputFormatter(formatter); } +NimCompilerBuildStepConfigWidget::NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep) + : BuildStepConfigWidget(buildStep) + , m_buildStep(buildStep) +{ + setDisplayName(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_DISPLAY)); + setSummaryText(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_SUMMARY)); + + m_targetComboBox = new QComboBox(this); + + m_additionalArgumentsLineEdit = new QLineEdit(this); + + m_commandTextEdit = new QTextEdit(this); + m_commandTextEdit->setEnabled(false); + m_commandTextEdit->setMinimumSize(QSize(0, 0)); + + m_defaultArgumentsComboBox = new QComboBox(this); + m_defaultArgumentsComboBox->addItem(tr("None")); + m_defaultArgumentsComboBox->addItem(tr("Debug")); + m_defaultArgumentsComboBox->addItem(tr("Release")); + + auto formLayout = new QFormLayout(this); + formLayout->addRow(tr("Target:"), m_targetComboBox); + formLayout->addRow(tr("Default arguments:"), m_defaultArgumentsComboBox); + formLayout->addRow(tr("Extra arguments:"), m_additionalArgumentsLineEdit); + formLayout->addRow(tr("Command:"), m_commandTextEdit); + + // Connect the project signals + connect(m_buildStep->project(), + &Project::fileListChanged, + this, + &NimCompilerBuildStepConfigWidget::updateUi); + + // Connect build step signals + connect(m_buildStep, &NimCompilerBuildStep::processParametersChanged, + this, &NimCompilerBuildStepConfigWidget::updateUi); + + // Connect UI signals + connect(m_targetComboBox, QOverload::of(&QComboBox::activated), + this, &NimCompilerBuildStepConfigWidget::onTargetChanged); + connect(m_additionalArgumentsLineEdit, &QLineEdit::textEdited, + this, &NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited); + connect(m_defaultArgumentsComboBox, QOverload::of(&QComboBox::activated), + this, &NimCompilerBuildStepConfigWidget::onDefaultArgumentsComboBoxIndexChanged); + + updateUi(); +} + BuildStepConfigWidget *NimCompilerBuildStep::createConfigWidget() { return new NimCompilerBuildStepConfigWidget(this); @@ -255,6 +337,73 @@ void NimCompilerBuildStep::updateTargetNimFile() setTargetNimFile(nimFiles.at(0)); } +void NimCompilerBuildStepConfigWidget::onTargetChanged(int index) +{ + Q_UNUSED(index) + auto data = m_targetComboBox->currentData(); + FilePath path = FilePath::fromString(data.toString()); + m_buildStep->setTargetNimFile(path); +} + +void NimCompilerBuildStepConfigWidget::onDefaultArgumentsComboBoxIndexChanged(int index) +{ + auto options = static_cast(index); + m_buildStep->setDefaultCompilerOptions(options); +} + +void NimCompilerBuildStepConfigWidget::updateUi() +{ + updateCommandLineText(); + updateTargetComboBox(); + updateAdditionalArgumentsLineEdit(); + updateDefaultArgumentsComboBox(); +} + +void NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited(const QString &text) +{ + m_buildStep->setUserCompilerOptions(text.split(QChar::Space)); +} + +void NimCompilerBuildStepConfigWidget::updateCommandLineText() +{ + ProcessParameters *parameters = m_buildStep->processParameters(); + + const CommandLine cmd = parameters->command(); + const QStringList parts = QtcProcess::splitArgs(cmd.toUserOutput()); + + m_commandTextEdit->setText(parts.join(QChar::LineFeed)); +} + +void NimCompilerBuildStepConfigWidget::updateTargetComboBox() +{ + QTC_ASSERT(m_buildStep, return ); + + // Re enter the files + m_targetComboBox->clear(); + + const FilePaths nimFiles = m_buildStep->project()->files([](const Node *n) { + return Project::AllFiles(n) && n->path().endsWith(".nim"); + }); + + for (const FilePath &file : nimFiles) + m_targetComboBox->addItem(file.fileName(), file.toString()); + + const int index = m_targetComboBox->findData(m_buildStep->targetNimFile().toString()); + m_targetComboBox->setCurrentIndex(index); +} + +void NimCompilerBuildStepConfigWidget::updateAdditionalArgumentsLineEdit() +{ + const QString text = m_buildStep->userCompilerOptions().join(QChar::Space); + m_additionalArgumentsLineEdit->setText(text); +} + +void NimCompilerBuildStepConfigWidget::updateDefaultArgumentsComboBox() +{ + const int index = m_buildStep->defaultCompilerOptions(); + m_defaultArgumentsComboBox->setCurrentIndex(index); +} + // NimCompilerBuildStepFactory NimCompilerBuildStepFactory::NimCompilerBuildStepFactory() diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp deleted file mode 100644 index fb8f891614c..00000000000 --- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) Filippo Cucchetto -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "nimcompilerbuildstepconfigwidget.h" -#include "nimbuildconfiguration.h" -#include "nimbuildsystem.h" -#include "nimcompilerbuildstep.h" - -#include "ui_nimcompilerbuildstepconfigwidget.h" - -#include "../nimconstants.h" - -#include - -#include -#include - -using namespace ProjectExplorer; -using namespace Utils; - -namespace Nim { - -NimCompilerBuildStepConfigWidget::NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep) - : BuildStepConfigWidget(buildStep) - , m_buildStep(buildStep) - , m_ui(new Ui::NimCompilerBuildStepConfigWidget()) -{ - m_ui->setupUi(this); - - setDisplayName(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_DISPLAY)); - setSummaryText(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_SUMMARY)); - - // Connect the project signals - connect(m_buildStep->project(), - &Project::fileListChanged, - this, - &NimCompilerBuildStepConfigWidget::updateUi); - - // Connect build step signals - connect(m_buildStep, &NimCompilerBuildStep::processParametersChanged, - this, &NimCompilerBuildStepConfigWidget::updateUi); - - // Connect UI signals - connect(m_ui->targetComboBox, QOverload::of(&QComboBox::activated), - this, &NimCompilerBuildStepConfigWidget::onTargetChanged); - connect(m_ui->additionalArgumentsLineEdit, &QLineEdit::textEdited, - this, &NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited); - connect(m_ui->defaultArgumentsComboBox, QOverload::of(&QComboBox::activated), - this, &NimCompilerBuildStepConfigWidget::onDefaultArgumentsComboBoxIndexChanged); - - updateUi(); -} - -NimCompilerBuildStepConfigWidget::~NimCompilerBuildStepConfigWidget() = default; - -void NimCompilerBuildStepConfigWidget::onTargetChanged(int index) -{ - Q_UNUSED(index) - auto data = m_ui->targetComboBox->currentData(); - FilePath path = FilePath::fromString(data.toString()); - m_buildStep->setTargetNimFile(path); -} - -void NimCompilerBuildStepConfigWidget::onDefaultArgumentsComboBoxIndexChanged(int index) -{ - auto options = static_cast(index); - m_buildStep->setDefaultCompilerOptions(options); -} - -void NimCompilerBuildStepConfigWidget::updateUi() -{ - updateCommandLineText(); - updateTargetComboBox(); - updateAdditionalArgumentsLineEdit(); - updateDefaultArgumentsComboBox(); -} - -void NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited(const QString &text) -{ - m_buildStep->setUserCompilerOptions(text.split(QChar::Space)); -} - -void NimCompilerBuildStepConfigWidget::updateCommandLineText() -{ - ProcessParameters *parameters = m_buildStep->processParameters(); - - const CommandLine cmd = parameters->command(); - const QStringList parts = QtcProcess::splitArgs(cmd.toUserOutput()); - - m_ui->commandTextEdit->setText(parts.join(QChar::LineFeed)); -} - -void NimCompilerBuildStepConfigWidget::updateTargetComboBox() -{ - QTC_ASSERT(m_buildStep, return ); - - // Re enter the files - m_ui->targetComboBox->clear(); - - const FilePaths nimFiles = m_buildStep->project()->files([](const Node *n) { - return Project::AllFiles(n) && n->path().endsWith(".nim"); - }); - - for (const FilePath &file : nimFiles) - m_ui->targetComboBox->addItem(file.fileName(), file.toString()); - - const int index = m_ui->targetComboBox->findData(m_buildStep->targetNimFile().toString()); - m_ui->targetComboBox->setCurrentIndex(index); -} - -void NimCompilerBuildStepConfigWidget::updateAdditionalArgumentsLineEdit() -{ - const QString text = m_buildStep->userCompilerOptions().join(QChar::Space); - m_ui->additionalArgumentsLineEdit->setText(text); -} - -void NimCompilerBuildStepConfigWidget::updateDefaultArgumentsComboBox() -{ - const int index = m_buildStep->defaultCompilerOptions(); - m_ui->defaultArgumentsComboBox->setCurrentIndex(index); -} - -} - diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h deleted file mode 100644 index 4c7d1e8d8b8..00000000000 --- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) Filippo Cucchetto -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -namespace Nim { - -class NimCompilerBuildStep; - -namespace Ui { class NimCompilerBuildStepConfigWidget; } - -class NimCompilerBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT - -public: - NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep); - ~NimCompilerBuildStepConfigWidget(); - -private: - void updateUi(); - void updateCommandLineText(); - void updateTargetComboBox(); - void updateAdditionalArgumentsLineEdit(); - void updateDefaultArgumentsComboBox(); - - void onAdditionalArgumentsTextEdited(const QString &text); - void onTargetChanged(int index); - void onDefaultArgumentsComboBoxIndexChanged(int index); - - NimCompilerBuildStep *m_buildStep; - QScopedPointer m_ui; -}; - -} diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui deleted file mode 100644 index fc46ae35463..00000000000 --- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - Nim::NimCompilerBuildStepConfigWidget - - - true - - - - 0 - 0 - 497 - 283 - - - - - - - - - - - - Target: - - - - - - - - - - Extra arguments: - - - - - - - - - - Command: - - - - - - - false - - - - 0 - 0 - - - - - - - - Default arguments: - - - - - - - - None - - - - - Debug - - - - - Release - - - - - - - - - - targetComboBox - defaultArgumentsComboBox - additionalArgumentsLineEdit - commandTextEdit - - - -