GenericProject: Use the base BuildConfiguration config widget

Change-Id: I24abc4a8086b39e796b3a4146dbcdbda70c89ee3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-04-26 17:47:44 +02:00
parent 3941f0593b
commit e1b7de3479
2 changed files with 14 additions and 70 deletions

View File

@@ -29,25 +29,22 @@
#include "genericproject.h"
#include "genericprojectconstants.h"
#include <coreplugin/icore.h>
#include <projectexplorer/buildinfo.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectconfigurationaspects.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <QFormLayout>
#include <QInputDialog>
using namespace ProjectExplorer;
using namespace Utils;
namespace GenericProjectManager {
namespace Internal {
@@ -55,6 +52,16 @@ namespace Internal {
GenericBuildConfiguration::GenericBuildConfiguration(Target *parent, Core::Id id)
: BuildConfiguration(parent, id)
{
setConfigWidgetDisplayName(tr("Generic Manager"));
BaseStringAspect *bd = buildDirectoryAspect();
bd->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
bd->setExpectedKind(PathChooser::Directory);
bd->setHistoryCompleter("Generic.BuildDir.History");
bd->setLabelText(tr("Build directory:"));
bd->setBaseFileName(parent->project()->projectDirectory());
bd->setEnvironment(environment());
updateCacheAndEmitEnvironmentChanged();
}
@@ -71,10 +78,6 @@ void GenericBuildConfiguration::initialize(const BuildInfo &info)
updateCacheAndEmitEnvironmentChanged();
}
NamedWidget *GenericBuildConfiguration::createConfigWidget()
{
return new GenericBuildSettingsWidget(this);
}
/*!
\class GenericBuildConfigurationFactory
@@ -127,44 +130,5 @@ void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const
env.prependOrSetPath(qt->binPath().toString());
}
////////////////////////////////////////////////////////////////////////////////////
// GenericBuildSettingsWidget
////////////////////////////////////////////////////////////////////////////////////
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericBuildConfiguration *bc)
: m_buildConfiguration(nullptr)
{
auto fl = new QFormLayout(this);
fl->setContentsMargins(0, -1, 0, -1);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
// build directory
m_pathChooser = new Utils::PathChooser(this);
m_pathChooser->setHistoryCompleter("Generic.BuildDir.History");
m_pathChooser->setEnabled(true);
fl->addRow(tr("Build directory:"), m_pathChooser);
connect(m_pathChooser, &Utils::PathChooser::rawPathChanged,
this, &GenericBuildSettingsWidget::buildDirectoryChanged);
m_buildConfiguration = bc;
m_pathChooser->setBaseFileName(bc->target()->project()->projectDirectory());
m_pathChooser->setEnvironment(bc->environment());
m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory().toString());
setDisplayName(tr("Generic Manager"));
connect(bc, &GenericBuildConfiguration::environmentChanged,
this, &GenericBuildSettingsWidget::environmentHasChanged);
}
void GenericBuildSettingsWidget::buildDirectoryChanged()
{
m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(m_pathChooser->rawPath()));
}
void GenericBuildSettingsWidget::environmentHasChanged()
{
m_pathChooser->setEnvironment(m_buildConfiguration->environment());
}
} // namespace Internal
} // namespace GenericProjectManager