BareMetal: Some consolidation of RunConfiguration related classes

Purely mechanical, no visible/functional changes intended or expected.

- have one file pair for each set of config/factory/widget
- de-pimpl BareMetalRunConfigWidget, it's very local now
- use new wrapWidget convenience function for run config widget setup

Change-Id: Icd0df2bc7e206d6bf15d722f7eaa3b9fbee0b0fa
Reviewed-by: Alexander Drozdov <adrozdoff@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2018-03-20 17:00:19 +01:00
parent afbeefba86
commit 71501a3bf7
11 changed files with 87 additions and 305 deletions

View File

@@ -6,9 +6,7 @@ include(../../qtcreatorplugin.pri)
SOURCES += baremetalplugin.cpp \
baremetalcustomrunconfiguration.cpp\
baremetaldevice.cpp \
baremetalrunconfigurationfactory.cpp \
baremetalrunconfiguration.cpp \
baremetalrunconfigurationwidget.cpp \
baremetalgdbcommandsdeploystep.cpp \
baremetaldeviceconfigurationwizardpages.cpp \
baremetaldeviceconfigurationwizard.cpp \
@@ -28,9 +26,7 @@ HEADERS += baremetalplugin.h \
baremetalconstants.h \
baremetalcustomrunconfiguration.h \
baremetaldevice.h \
baremetalrunconfigurationfactory.h \
baremetalrunconfiguration.h \
baremetalrunconfigurationwidget.h \
baremetalgdbcommandsdeploystep.h \
baremetaldeviceconfigurationfactory.h \
baremetaldeviceconfigurationwidget.h \

View File

@@ -24,8 +24,6 @@ QtcPlugin {
"baremetalgdbcommandsdeploystep.cpp", "baremetalgdbcommandsdeploystep.h",
"baremetalplugin.cpp", "baremetalplugin.h",
"baremetalrunconfiguration.cpp", "baremetalrunconfiguration.h",
"baremetalrunconfigurationfactory.cpp", "baremetalrunconfigurationfactory.h",
"baremetalrunconfigurationwidget.cpp", "baremetalrunconfigurationwidget.h",
"baremetaldebugsupport.cpp", "baremetaldebugsupport.h",
"gdbserverproviderprocess.cpp", "gdbserverproviderprocess.h",
"gdbserverproviderssettingspage.cpp", "gdbserverproviderssettingspage.h",

View File

@@ -25,20 +25,14 @@
#include "baremetalcustomrunconfiguration.h"
#include "baremetalconstants.h"
#include <projectexplorer/target.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <qtsupport/qtoutputformatter.h>
#include <utils/detailswidget.h>
#include <utils/qtcprocess.h>
#include <utils/pathchooser.h>
#include <QDir>
#include <QFileInfo>
#include <QFormLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QString>
#include <QLineEdit>
using namespace Utils;
using namespace ProjectExplorer;
@@ -48,29 +42,17 @@ namespace Internal {
class BareMetalCustomRunConfigWidget : public RunConfigWidget
{
Q_OBJECT
public:
BareMetalCustomRunConfigWidget(BareMetalCustomRunConfiguration *runConfig)
: m_runConfig(runConfig)
{
auto const mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
auto const detailsContainer = new DetailsWidget(this);
mainLayout->addWidget(detailsContainer);
detailsContainer->setState(DetailsWidget::NoSummary);
auto const detailsWidget = new QWidget(this);
detailsContainer->setWidget(detailsWidget);
auto exeLabel = new QLabel(tr("Executable:"));
auto executableChooser = new PathChooser;
executableChooser->setExpectedKind(PathChooser::File);
executableChooser->setPath(m_runConfig->localExecutableFilePath());
auto clayout = new QFormLayout(this);
detailsWidget->setLayout(clayout);
clayout->addRow(BareMetalCustomRunConfiguration::tr("Executable:"), executableChooser);
clayout->addRow(exeLabel, executableChooser);
runConfig->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, clayout);
runConfig->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, clayout);
@@ -89,7 +71,7 @@ private:
BareMetalCustomRunConfiguration * const m_runConfig;
};
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent)
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *parent)
: BareMetalRunConfiguration(parent)
{
}
@@ -99,7 +81,7 @@ bool BareMetalCustomRunConfiguration::isConfigured() const
return !m_localExecutable.isEmpty();
}
ProjectExplorer::RunConfiguration::ConfigurationState
RunConfiguration::ConfigurationState
BareMetalCustomRunConfiguration::ensureConfigured(QString *errorMessage)
{
if (!isConfigured()) {
@@ -114,7 +96,7 @@ BareMetalCustomRunConfiguration::ensureConfigured(QString *errorMessage)
QWidget *BareMetalCustomRunConfiguration::createConfigurationWidget()
{
return new BareMetalCustomRunConfigWidget(this);
return wrapWidget(new BareMetalCustomRunConfigWidget(this));
}
Utils::OutputFormatter *BareMetalCustomRunConfiguration::createOutputFormatter() const
@@ -142,7 +124,15 @@ QVariantMap BareMetalCustomRunConfiguration::toMap() const
return map;
}
// BareMetalCustomRunConfigurationFactory
BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory() :
FixedRunConfigurationFactory(BareMetalCustomRunConfiguration::tr("Custom Executable"), true)
{
registerRunConfiguration<BareMetalCustomRunConfiguration>("BareMetal.CustomRunConfig");
setDecorateDisplayNames(true);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}
} // namespace Internal
} // namespace BareMetal
#include "baremetalcustomrunconfiguration.moc"

View File

@@ -27,8 +27,6 @@
#include "baremetalrunconfiguration.h"
namespace Utils { class Environment; }
namespace BareMetal {
namespace Internal {
@@ -54,5 +52,11 @@ private:
QString m_localExecutable;
};
class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::FixedRunConfigurationFactory
{
public:
BareMetalCustomRunConfigurationFactory();
};
} // namespace Internal
} // namespace BareMetal

View File

@@ -26,10 +26,10 @@
#include "baremetalplugin.h"
#include "baremetalconstants.h"
#include "baremetalcustomrunconfiguration.h"
#include "baremetaldeviceconfigurationfactory.h"
#include "baremetaldebugsupport.h"
#include "baremetalrunconfiguration.h"
#include "baremetalrunconfigurationfactory.h"
#include "gdbserverproviderssettingspage.h"
#include "gdbserverprovidermanager.h"

View File

@@ -25,8 +25,7 @@
#include "baremetalrunconfiguration.h"
#include "baremetalcustomrunconfiguration.h"
#include "baremetalrunconfigurationwidget.h"
#include "baremetalconstants.h"
#include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/project.h>
@@ -34,12 +33,58 @@
#include <projectexplorer/target.h>
#include <qtsupport/qtoutputformatter.h>
#include <QFormLayout>
#include <QLabel>
#include <QDir>
using namespace ProjectExplorer;
using namespace Utils;
namespace BareMetal {
namespace Internal {
// BareMetalRunConfigurationWidget
class BareMetalRunConfigurationWidget : public QWidget
{
public:
explicit BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration);
private:
void updateTargetInformation();
BareMetalRunConfiguration * const m_runConfiguration;
QLabel m_localExecutableLabel;
};
BareMetalRunConfigurationWidget::BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration)
: m_runConfiguration(runConfiguration)
{
auto formLayout = new QFormLayout(this);
formLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter);
m_localExecutableLabel.setText(m_runConfiguration->localExecutableFilePath());
formLayout->addRow(BareMetalRunConfiguration::tr("Executable:"), &m_localExecutableLabel);
//d->genericWidgetsLayout.addRow(tr("Debugger host:"),d->runConfiguration);
//d->genericWidgetsLayout.addRow(tr("Debugger port:"),d->runConfiguration);
runConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, formLayout);
runConfiguration->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, formLayout);
connect(m_runConfiguration, &BareMetalRunConfiguration::targetInformationChanged,
this, &BareMetalRunConfigurationWidget::updateTargetInformation);
}
void BareMetalRunConfigurationWidget::updateTargetInformation()
{
const QString regularText = QDir::toNativeSeparators(m_runConfiguration->localExecutableFilePath());
const QString errorMessage = "<font color=\"red\">" + tr("Unknown") + "</font>";
m_localExecutableLabel.setText(regularText.isEmpty() ? errorMessage : regularText);
}
// BareMetalRunConfiguration
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target)
: RunConfiguration(target, IdPrefix)
{
@@ -67,7 +112,7 @@ void BareMetalRunConfiguration::doAdditionalSetup(const RunConfigurationCreation
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
{
return new BareMetalRunConfigurationWidget(this);
return wrapWidget(new BareMetalRunConfigurationWidget(this));
}
OutputFormatter *BareMetalRunConfiguration::createOutputFormatter() const
@@ -110,6 +155,16 @@ void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
const char *BareMetalRunConfiguration::IdPrefix = "BareMetal";
// BareMetalRunConfigurationFactory
BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
{
registerRunConfiguration<BareMetalRunConfiguration>(BareMetalRunConfiguration::IdPrefix);
setDecorateDisplayNames(true);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}
} // namespace Internal
} // namespace BareMetal

View File

@@ -35,10 +35,6 @@ class BareMetalRunConfigurationWidget;
class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
Q_DISABLE_COPY(BareMetalRunConfiguration)
friend class ProjectExplorer::RunConfigurationFactory;
friend class BareMetalRunConfigurationWidget;
public:
explicit BareMetalRunConfiguration(ProjectExplorer::Target *target);
@@ -66,5 +62,11 @@ private:
QString m_buildKey;
};
class BareMetalRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
{
public:
BareMetalRunConfigurationFactory();
};
} // namespace Internal
} // namespace BareMetal

View File

@@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** 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 "baremetalrunconfigurationfactory.h"
#include "baremetalconstants.h"
#include "baremetalcustomrunconfiguration.h"
#include "baremetalrunconfiguration.h"
#include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
// BareMetalRunConfigurationFactory
BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
{
registerRunConfiguration<BareMetalRunConfiguration>(BareMetalRunConfiguration::IdPrefix);
setDecorateDisplayNames(true);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}
// BareMetalCustomRunConfigurationFactory
BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory() :
FixedRunConfigurationFactory(BareMetalCustomRunConfiguration::tr("Custom Executable"), true)
{
registerRunConfiguration<BareMetalCustomRunConfiguration>("BareMetal.CustomRunConfig");
setDecorateDisplayNames(true);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}
} // namespace Internal
} // namespace BareMetal

View File

@@ -1,50 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** 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/runconfiguration.h>
namespace BareMetal {
namespace Internal {
class BareMetalRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
{
Q_OBJECT
public:
BareMetalRunConfigurationFactory();
};
class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::FixedRunConfigurationFactory
{
Q_OBJECT
public:
BareMetalCustomRunConfigurationFactory();
};
} // namespace Internal
} // namespace RemoteLinux

View File

@@ -1,101 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** 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 "baremetalrunconfigurationwidget.h"
#include "baremetalrunconfiguration.h"
#include <projectexplorer/runconfigurationaspects.h>
#include <utils/detailswidget.h>
#include <utils/utilsicons.h>
#include <QLineEdit>
#include <QFormLayout>
#include <QLabel>
#include <QCoreApplication>
#include <QDir>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
class BareMetalRunConfigurationWidgetPrivate
{
public:
BareMetalRunConfigurationWidgetPrivate(BareMetalRunConfiguration *runConfig)
: runConfiguration(runConfig)
{ }
BareMetalRunConfiguration * const runConfiguration;
QLabel localExecutableLabel;
QFormLayout genericWidgetsLayout;
};
} // namespace Internal
using namespace Internal;
BareMetalRunConfigurationWidget::BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration)
: d(new BareMetalRunConfigurationWidgetPrivate(runConfiguration))
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
Utils::DetailsWidget *detailsContainer = new Utils::DetailsWidget(this);
detailsContainer->setState(Utils::DetailsWidget::NoSummary);
QWidget *details = new QWidget(this);
details->setLayout(&d->genericWidgetsLayout);
detailsContainer->setWidget(details);
mainLayout->addWidget(detailsContainer);
d->genericWidgetsLayout.setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter);
d->localExecutableLabel.setText(d->runConfiguration->localExecutableFilePath());
d->genericWidgetsLayout.addRow(tr("Executable:"),&d->localExecutableLabel);
//d->genericWidgetsLayout.addRow(tr("Debugger host:"),d->runConfiguration);
//d->genericWidgetsLayout.addRow(tr("Debugger port:"),d->runConfiguration);
runConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, &d->genericWidgetsLayout);
runConfiguration->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, &d->genericWidgetsLayout);
connect(d->runConfiguration, &BareMetalRunConfiguration::targetInformationChanged,
this, &BareMetalRunConfigurationWidget::updateTargetInformation);
}
BareMetalRunConfigurationWidget::~BareMetalRunConfigurationWidget()
{
delete d;
}
void BareMetalRunConfigurationWidget::updateTargetInformation()
{
const QString regularText = QDir::toNativeSeparators(d->runConfiguration->localExecutableFilePath());
const QString errorMessage = "<font color=\"red\">" + tr("Unknown") + "</font>";
d->localExecutableLabel.setText(regularText.isEmpty() ? errorMessage : regularText);
}
} // namespace BareMetal

View File

@@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** 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 <QWidget>
namespace BareMetal {
namespace Internal {
class BareMetalRunConfiguration;
class BareMetalRunConfigurationWidgetPrivate;
class BareMetalRunConfigurationWidget : public QWidget
{
Q_OBJECT
public:
explicit BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration);
~BareMetalRunConfigurationWidget();
private:
void updateTargetInformation();
BareMetalRunConfigurationWidgetPrivate * const d;
};
} // namespace Internal
} // namespace BareMetal