AutoTools: Use the base BuildConfiguration config widget

Change-Id: I928b9bc7adc3424008ead27fe8457d345e1bcda5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-04-26 17:06:23 +02:00
parent 6798cf0b9f
commit 3941f0593b
9 changed files with 29 additions and 161 deletions

View File

@@ -26,7 +26,6 @@
****************************************************************************/
#include "autotoolsbuildconfiguration.h"
#include "autotoolsbuildsettingswidget.h"
#include "makestep.h"
#include "autotoolsproject.h"
#include "autotoolsprojectconstants.h"
@@ -44,15 +43,13 @@
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
#include <QInputDialog>
using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Constants;
using namespace Internal;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Constants;
using namespace Utils;
namespace AutotoolsProjectManager {
namespace Internal {
// AutotoolsBuildConfiguration
@@ -62,6 +59,15 @@ AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent, Core::I
// /<foobar> is used so the un-changed check in setBuildDirectory() works correctly.
// The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory.
setBuildDirectory(Utils::FileName::fromString("/<foobar>"));
setConfigWidgetDisplayName(tr("Autotools Manager"));
BaseStringAspect *bd = buildDirectoryAspect();
bd->setLabelText(tr("Build directory:"));
bd->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
bd->setExpectedKind(PathChooser::Directory);
bd->setBaseFileName(parent->project()->projectDirectory());
bd->setEnvironment(environment());
bd->setHistoryCompleter("AutoTools.BuildDir.History");
}
void AutotoolsBuildConfiguration::initialize(const BuildInfo &info)
@@ -97,11 +103,6 @@ void AutotoolsBuildConfiguration::initialize(const BuildInfo &info)
cleanSteps->appendStep(cleanMakeStep);
}
NamedWidget *AutotoolsBuildConfiguration::createConfigWidget()
{
return new AutotoolsBuildSettingsWidget(this);
}
// AutotoolsBuildConfiguration class
@@ -143,3 +144,6 @@ BuildConfiguration::BuildType AutotoolsBuildConfiguration::buildType() const
// TODO: Should I return something different from Unknown?
return Unknown;
}
} // Internal
} // AutotoolsProjectManager

View File

@@ -42,7 +42,6 @@ class AutotoolsBuildConfiguration : public ProjectExplorer::BuildConfiguration
AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, Core::Id id);
void initialize(const ProjectExplorer::BuildInfo &info) override;
ProjectExplorer::NamedWidget *createConfigWidget() override;
BuildType buildType() const override;
};

View File

@@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Openismus GmbH.
** Author: Peter Penz (ppenz@openismus.com)
** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
** Contact: https://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 "autotoolsbuildsettingswidget.h"
#include "autotoolsproject.h"
#include "autotoolsbuildconfiguration.h"
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <utils/pathchooser.h>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QFormLayout>
#include <QComboBox>
#include <QPointer>
using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer;
AutotoolsBuildSettingsWidget::AutotoolsBuildSettingsWidget(AutotoolsBuildConfiguration *bc) :
m_pathChooser(new Utils::PathChooser),
m_buildConfiguration(bc)
{
auto fl = new QFormLayout(this);
fl->setContentsMargins(0, 0, 0, 0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
m_pathChooser->setEnabled(true);
m_pathChooser->setExpectedKind(Utils::PathChooser::Directory);
m_pathChooser->setBaseFileName(bc->target()->project()->projectDirectory());
m_pathChooser->setEnvironment(bc->environment());
m_pathChooser->setHistoryCompleter(QLatin1String("AutoTools.BuildDir.History"));
fl->addRow(tr("Build directory:"), m_pathChooser);
connect(m_pathChooser, &Utils::PathChooser::rawPathChanged,
this, &AutotoolsBuildSettingsWidget::buildDirectoryChanged);
m_pathChooser->setBaseFileName(bc->target()->project()->projectDirectory());
m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory().toString());
setDisplayName(tr("Autotools Manager"));
connect(bc, &BuildConfiguration::environmentChanged,
this, &AutotoolsBuildSettingsWidget::environmentHasChanged);
}
void AutotoolsBuildSettingsWidget::buildDirectoryChanged()
{
m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(m_pathChooser->rawPath()));
}
void AutotoolsBuildSettingsWidget::environmentHasChanged()
{
m_pathChooser->setEnvironment(m_buildConfiguration->environment());
}

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Openismus GmbH.
** Author: Peter Penz (ppenz@openismus.com)
** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
** Contact: https://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;
QT_END_NAMESPACE
namespace Utils { class PathChooser; }
namespace AutotoolsProjectManager {
namespace Internal {
class AutotoolsBuildConfiguration;
/**
* @brief Implementation of ProjectExplorer::BuildConfigWidget interface.
*
* Provides an editor to configure the build directory and build steps.
*/
class AutotoolsBuildSettingsWidget : public ProjectExplorer::NamedWidget
{
Q_OBJECT
public:
AutotoolsBuildSettingsWidget(AutotoolsBuildConfiguration *bc);
private:
void buildDirectoryChanged();
void environmentHasChanged();
Utils::PathChooser *m_pathChooser;
AutotoolsBuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
} // namespace AutotoolsProjectManager

View File

@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
HEADERS = autotoolsprojectplugin.h\
autotoolsopenprojectwizard.h\
autotoolsproject.h\
autotoolsbuildsettingswidget.h\
autotoolsbuildconfiguration.h\
autotoolsprojectconstants.h\
makestep.h\
@@ -16,7 +15,6 @@ HEADERS = autotoolsprojectplugin.h\
SOURCES = autotoolsprojectplugin.cpp\
autotoolsopenprojectwizard.cpp\
autotoolsproject.cpp\
autotoolsbuildsettingswidget.cpp\
autotoolsbuildconfiguration.cpp\
makestep.cpp\
autogenstep.cpp\

View File

@@ -18,8 +18,6 @@ QtcPlugin {
"autoreconfstep.h",
"autotoolsbuildconfiguration.cpp",
"autotoolsbuildconfiguration.h",
"autotoolsbuildsettingswidget.cpp",
"autotoolsbuildsettingswidget.h",
"autotoolsopenprojectwizard.cpp",
"autotoolsopenprojectwizard.h",
"autotoolsproject.cpp",

View File

@@ -88,6 +88,10 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id)
m_buildDirectoryAspect = addAspect<BaseStringAspect>();
m_buildDirectoryAspect->setSettingsKey(BUILDDIRECTORY_KEY);
connect(this, &BuildConfiguration::environmentChanged, this, [this] {
m_buildDirectoryAspect->setEnvironment(environment());
});
}
Utils::FileName BuildConfiguration::buildDirectory() const

View File

@@ -79,6 +79,7 @@ public:
QPointer<PathChooser> m_pathChooserDisplay;
QPointer<QTextEdit> m_textEditDisplay;
QPixmap m_labelPixmap;
Utils::FileName m_baseFileName;
};
class BaseIntegerAspectPrivate
@@ -213,6 +214,13 @@ void BaseStringAspect::setEnvironment(const Environment &env)
d->m_pathChooserDisplay->setEnvironment(env);
}
void BaseStringAspect::setBaseFileName(const FileName &baseFileName)
{
d->m_baseFileName = baseFileName;
if (d->m_pathChooserDisplay)
d->m_pathChooserDisplay->setBaseFileName(baseFileName);
}
void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout)
{
QTC_CHECK(!d->m_label);
@@ -231,6 +239,7 @@ void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout)
if (!d->m_historyCompleterKey.isEmpty())
d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey);
d->m_pathChooserDisplay->setEnvironment(d->m_environment);
d->m_pathChooserDisplay->setBaseFileName(d->m_baseFileName);
connect(d->m_pathChooserDisplay, &PathChooser::pathChanged,
this, &BaseStringAspect::setValue);
hbox->addWidget(d->m_pathChooserDisplay);

View File

@@ -89,6 +89,7 @@ public:
void setHistoryCompleter(const QString &historyCompleterKey);
void setExpectedKind(const Utils::PathChooser::Kind expectedKind);
void setEnvironment(const Utils::Environment &env);
void setBaseFileName(const Utils::FileName &baseFileName);
bool isChecked() const;
void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey);