summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-08-26 10:48:29 +0200
committerhjk <hjk@qt.io>2020-08-31 06:38:40 +0000
commitb3652da3acb6177115214341cf2793e1347602f7 (patch)
treecc7caca2455b32d8b45cf62f2da69439dc97f883 /src
parent53c763029b3321271d21f19a374bc1875b4b5f6b (diff)
downloadqt-creator-b3652da3acb6177115214341cf2793e1347602f7.tar.gz
Nim: Inline nimcompilerbuildstepconfigwidget.*
Step towards aspectification. The new position of the method implementation are intentional to keep the follow-up patch small. Change-Id: I89c6982c8380c2a6b0e2bc50fb10f48d5413fc51 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/nim/CMakeLists.txt1
-rw-r--r--src/plugins/nim/nim.pro3
-rw-r--r--src/plugins/nim/nim.qbs1
-rw-r--r--src/plugins/nim/project/nimcompilerbuildstep.cpp153
-rw-r--r--src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp146
-rw-r--r--src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h59
-rw-r--r--src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui100
7 files changed, 151 insertions, 312 deletions
diff --git a/src/plugins/nim/CMakeLists.txt b/src/plugins/nim/CMakeLists.txt
index d01c9bc908..739cbf27a9 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 92866bff1c..1f19d4b631 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 1075487d1b..fe939465d0 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 2e8a53ee3f..bafdb631e5 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 <projectexplorer/processparameters.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/ioutputparser.h>
#include <projectexplorer/kitinformation.h>
-#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h>
+
#include <utils/qtcassert.h>
+#include <utils/qtcprocess.h>
+#include <QApplication>
+#include <QComboBox>
#include <QDir>
+#include <QFormLayout>
+#include <QLabel>
+#include <QLineEdit>
#include <QRegularExpression>
+#include <QTextEdit>
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<int>::of(&QComboBox::activated),
+ this, &NimCompilerBuildStepConfigWidget::onTargetChanged);
+ connect(m_additionalArgumentsLineEdit, &QLineEdit::textEdited,
+ this, &NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited);
+ connect(m_defaultArgumentsComboBox, QOverload<int>::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<NimCompilerBuildStep::DefaultBuildOptions>(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 fb8f891614..0000000000
--- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
-** 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 <projectexplorer/processparameters.h>
-
-#include <utils/qtcassert.h>
-#include <utils/qtcprocess.h>
-
-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<int>::of(&QComboBox::activated),
- this, &NimCompilerBuildStepConfigWidget::onTargetChanged);
- connect(m_ui->additionalArgumentsLineEdit, &QLineEdit::textEdited,
- this, &NimCompilerBuildStepConfigWidget::onAdditionalArgumentsTextEdited);
- connect(m_ui->defaultArgumentsComboBox, QOverload<int>::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<NimCompilerBuildStep::DefaultBuildOptions>(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 4c7d1e8d8b..0000000000
--- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
-** 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 <projectexplorer/buildstep.h>
-
-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<Ui::NimCompilerBuildStepConfigWidget> m_ui;
-};
-
-}
diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui
deleted file mode 100644
index fc46ae3546..0000000000
--- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.ui
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Nim::NimCompilerBuildStepConfigWidget</class>
- <widget class="QWidget" name="Nim::NimCompilerBuildStepConfigWidget">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>497</width>
- <height>283</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string/>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="targetLabel">
- <property name="text">
- <string>Target:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="targetComboBox"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="additionalArgumentsLabel">
- <property name="text">
- <string>Extra arguments:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="additionalArgumentsLineEdit"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="commandLabel">
- <property name="text">
- <string>Command:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QTextEdit" name="commandTextEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="defaultArgumentsLabel">
- <property name="text">
- <string>Default arguments:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="defaultArgumentsComboBox">
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Debug</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Release</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <tabstops>
- <tabstop>targetComboBox</tabstop>
- <tabstop>defaultArgumentsComboBox</tabstop>
- <tabstop>additionalArgumentsLineEdit</tabstop>
- <tabstop>commandTextEdit</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>