forked from qt-creator/qt-creator
Nim: Aspectify NimBuildConfiguration
Change-Id: Iccf81e3a089a6b6d756aace99c5051dc7349b6b9 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -24,7 +24,6 @@ HEADERS += \
|
||||
project/nimcompilercleanstep.h \
|
||||
project/nimcompilercleanstepconfigwidget.h \
|
||||
project/nimrunconfiguration.h \
|
||||
project/nimbuildconfigurationwidget.h \
|
||||
editor/nimeditorfactory.h \
|
||||
settings/nimcodestylesettingspage.h \
|
||||
settings/nimcodestylepreferencesfactory.h \
|
||||
@@ -55,7 +54,6 @@ SOURCES += \
|
||||
project/nimcompilercleanstep.cpp \
|
||||
project/nimcompilercleanstepconfigwidget.cpp \
|
||||
project/nimrunconfiguration.cpp \
|
||||
project/nimbuildconfigurationwidget.cpp \
|
||||
editor/nimeditorfactory.cpp \
|
||||
settings/nimcodestylesettingspage.cpp \
|
||||
settings/nimcodestylepreferencesfactory.cpp \
|
||||
|
||||
@@ -37,7 +37,6 @@ QtcPlugin {
|
||||
prefix: "project/"
|
||||
files: [
|
||||
"nimbuildconfiguration.h", "nimbuildconfiguration.cpp",
|
||||
"nimbuildconfigurationwidget.h", "nimbuildconfigurationwidget.cpp",
|
||||
"nimcompilerbuildstep.h", "nimcompilerbuildstep.cpp",
|
||||
"nimcompilerbuildstepconfigwidget.h", "nimcompilerbuildstepconfigwidget.cpp", "nimcompilerbuildstepconfigwidget.ui",
|
||||
"nimcompilercleanstep.h", "nimcompilercleanstep.cpp",
|
||||
|
||||
@@ -39,19 +39,11 @@ const char C_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Nim
|
||||
const char C_NIMTOOLCHAIN_TYPEID[] = "Nim.NimToolChain";
|
||||
const char C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY[] = "Nim.NimToolChain.CompilerCommand";
|
||||
|
||||
// NimRunConfiguration
|
||||
const QString C_NIMRUNCONFIGURATION_EXECUTABLE_KEY = QStringLiteral("Nim.NimRunConfiguration.Executable");
|
||||
|
||||
// NimProject
|
||||
const char C_NIMPROJECT_EXCLUDEDFILES[] = "Nim.NimProjectExcludedFiles";
|
||||
|
||||
// NimBuildConfiguration
|
||||
const char C_NIMBUILDCONFIGURATION_ID[] = "Nim.NimBuildConfiguration";
|
||||
const QString C_NIMBUILDCONFIGURATION_DISPLAY_KEY = QStringLiteral("Nim.NimBuildConfiguration.Display");
|
||||
const QString C_NIMBUILDCONFIGURATION_BUILDDIRECTORY_KEY = QStringLiteral("Nim.NimBuildConfiguration.BuildDirectory");
|
||||
|
||||
// NimBuildConfigurationWidget
|
||||
const char C_NIMBUILDCONFIGURATIONWIDGET_DISPLAY[] = QT_TRANSLATE_NOOP("NimBuildConfigurationWidget","General");
|
||||
|
||||
// NimCompilerBuildStep
|
||||
const char C_NIMCOMPILERBUILDSTEP_ID[] = "Nim.NimCompilerBuildStep";
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "nimbuildconfiguration.h"
|
||||
#include "nimbuildconfigurationwidget.h"
|
||||
#include "nimcompilerbuildstep.h"
|
||||
#include "nimproject.h"
|
||||
#include "nimbuildconfiguration.h"
|
||||
@@ -43,6 +42,7 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmacroexpander.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/projectconfigurationaspects.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -73,6 +73,9 @@ static FileName defaultBuildDirectory(const Kit *k,
|
||||
NimBuildConfiguration::NimBuildConfiguration(Target *target, Core::Id id)
|
||||
: BuildConfiguration(target, id)
|
||||
{
|
||||
setConfigWidgetDisplayName(tr("General"));
|
||||
setConfigWidgetHasFrame(true);
|
||||
setBuildDirectorySettingsKey("Nim.NimBuildConfiguration.BuildDirectory");
|
||||
}
|
||||
|
||||
void NimBuildConfiguration::initialize(const BuildInfo &info)
|
||||
@@ -118,39 +121,11 @@ void NimBuildConfiguration::initialize(const BuildInfo &info)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NamedWidget *NimBuildConfiguration::createConfigWidget()
|
||||
{
|
||||
return new NimBuildConfigurationWidget(this);
|
||||
}
|
||||
|
||||
BuildConfiguration::BuildType NimBuildConfiguration::buildType() const
|
||||
{
|
||||
return BuildConfiguration::Unknown;
|
||||
}
|
||||
|
||||
bool NimBuildConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!BuildConfiguration::fromMap(map))
|
||||
return false;
|
||||
|
||||
const QString displayName = map[Constants::C_NIMBUILDCONFIGURATION_DISPLAY_KEY].toString();
|
||||
const QString buildDirectory = map[Constants::C_NIMBUILDCONFIGURATION_BUILDDIRECTORY_KEY].toString();
|
||||
|
||||
setDisplayName(displayName);
|
||||
setBuildDirectory(FileName::fromString(buildDirectory));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap NimBuildConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap result = BuildConfiguration::toMap();
|
||||
result[Constants::C_NIMBUILDCONFIGURATION_DISPLAY_KEY] = displayName();
|
||||
result[Constants::C_NIMBUILDCONFIGURATION_BUILDDIRECTORY_KEY] = buildDirectory().toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
FileName NimBuildConfiguration::cacheDirectory() const
|
||||
{
|
||||
return buildDirectory().appendPath(QStringLiteral("nimcache"));
|
||||
|
||||
@@ -40,12 +40,8 @@ class NimBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
||||
NimBuildConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
void initialize(const ProjectExplorer::BuildInfo &info) override;
|
||||
ProjectExplorer::NamedWidget *createConfigWidget() override;
|
||||
ProjectExplorer::BuildConfiguration::BuildType buildType() const override;
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
public:
|
||||
Utils::FileName cacheDirectory() const;
|
||||
Utils::FileName outFilePath() const;
|
||||
|
||||
@@ -1,85 +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 "nimbuildconfigurationwidget.h"
|
||||
#include "nimbuildconfiguration.h"
|
||||
|
||||
#include "../nimconstants.h"
|
||||
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/detailswidget.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QComboBox>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Nim {
|
||||
|
||||
NimBuildConfigurationWidget::NimBuildConfigurationWidget(NimBuildConfiguration *bc)
|
||||
: NamedWidget(nullptr)
|
||||
, m_bc(bc)
|
||||
{
|
||||
// Build UI
|
||||
auto mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setMargin(0);
|
||||
|
||||
auto detailsWidget = new DetailsWidget();
|
||||
detailsWidget->setState(DetailsWidget::NoSummary);
|
||||
mainLayout->addWidget(detailsWidget);
|
||||
|
||||
auto detailsInnerWidget = new QWidget();
|
||||
auto formLayout = new QFormLayout(detailsInnerWidget);
|
||||
detailsWidget->setWidget(detailsInnerWidget);
|
||||
|
||||
m_buildDirectoryChooser = new PathChooser();
|
||||
formLayout->addRow(tr("Build directory:"), m_buildDirectoryChooser);
|
||||
|
||||
// Connect signals
|
||||
connect(bc, &NimBuildConfiguration::buildDirectoryChanged,
|
||||
this, &NimBuildConfigurationWidget::updateUi);
|
||||
connect(m_buildDirectoryChooser, &PathChooser::pathChanged,
|
||||
this, &NimBuildConfigurationWidget::onPathEdited);
|
||||
|
||||
setDisplayName(tr(Constants::C_NIMBUILDCONFIGURATIONWIDGET_DISPLAY));
|
||||
updateUi();
|
||||
}
|
||||
|
||||
NimBuildConfigurationWidget::~NimBuildConfigurationWidget() = default;
|
||||
|
||||
void NimBuildConfigurationWidget::updateUi()
|
||||
{
|
||||
m_buildDirectoryChooser->setPath(m_bc->buildDirectory().toUserOutput());
|
||||
}
|
||||
|
||||
void NimBuildConfigurationWidget::onPathEdited(const QString &path)
|
||||
{
|
||||
m_bc->setBuildDirectory(FileName::fromUserInput(path));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,58 +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/namedwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimBuildConfiguration;
|
||||
|
||||
class NimBuildConfigurationWidget : public ProjectExplorer::NamedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NimBuildConfigurationWidget(NimBuildConfiguration *bc);
|
||||
~NimBuildConfigurationWidget();
|
||||
|
||||
private:
|
||||
void updateUi();
|
||||
void onPathEdited(const QString &path);
|
||||
|
||||
NimBuildConfiguration *m_bc;
|
||||
Utils::PathChooser *m_buildDirectoryChooser;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -263,6 +263,11 @@ void BuildConfiguration::setConfigWidgetHasFrame(bool configWidgetHasFrame)
|
||||
m_configWidgetHasFrame = configWidgetHasFrame;
|
||||
}
|
||||
|
||||
void BuildConfiguration::setBuildDirectorySettingsKey(const QString &key)
|
||||
{
|
||||
m_buildDirectoryAspect->setSettingsKey(key);
|
||||
}
|
||||
|
||||
Target *BuildConfiguration::target() const
|
||||
{
|
||||
return static_cast<Target *>(parent());
|
||||
|
||||
@@ -103,6 +103,7 @@ public:
|
||||
void setConfigWidgetDisplayName(const QString &display);
|
||||
void setBuildDirectoryHistoryCompleter(const QString &history);
|
||||
void setConfigWidgetHasFrame(bool configWidgetHasFrame);
|
||||
void setBuildDirectorySettingsKey(const QString &key);
|
||||
|
||||
signals:
|
||||
void environmentChanged();
|
||||
|
||||
Reference in New Issue
Block a user