Commit 5d0407ef authored by Daniel Teske's avatar Daniel Teske Committed by hjk
Browse files

Optionaly disable buildsteps



Task-number: QTCREATORBUG-6713
Change-Id: Ief7f8509572cfa2008209083e5ae9c7763eba42a
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 5b847a66
......@@ -34,42 +34,13 @@
#include <utils/stylehelper.h>
#include <QtCore/QPropertyAnimation>
#include <QtGui/QPaintEvent>
#include <QtGui/QPainter>
#include <QtGui/QStyleOption>
#include <QtGui/QGraphicsOpacityEffect>
#include <QtCore/QPropertyAnimation>
using namespace Utils;
FadingPanel::FadingPanel(QWidget *parent) :
QWidget(parent),
m_opacityEffect(new QGraphicsOpacityEffect)
{
m_opacityEffect->setOpacity(0);
setGraphicsEffect(m_opacityEffect);
// Workaround for issue with QGraphicsEffect. GraphicsEffect
// currently clears with Window color. Remove if flickering
// no longer occurs on fade-in
QPalette pal;
pal.setBrush(QPalette::All, QPalette::Window, Qt::transparent);
setPalette(pal);
}
void FadingPanel::setOpacity(qreal value)
{
m_opacityEffect->setOpacity(value);
}
void FadingPanel::fadeTo(qreal value)
{
QPropertyAnimation *animation = new QPropertyAnimation(m_opacityEffect, "opacity");
animation->setDuration(200);
animation->setEndValue(value);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
DetailsButton::DetailsButton(QWidget *parent) : QAbstractButton(parent), m_fader(0)
{
setCheckable(true);
......
......@@ -41,15 +41,14 @@
QT_FORWARD_DECLARE_CLASS(QGraphicsOpacityEffect)
namespace Utils {
class QTCREATOR_UTILS_EXPORT FadingPanel : public QWidget
{
public:
FadingPanel(QWidget *parent = 0);
void setOpacity(qreal value);
void fadeTo(qreal value);
protected:
QGraphicsOpacityEffect *m_opacityEffect;
FadingPanel(QWidget *parent = 0)
: QWidget(parent)
{}
virtual void fadeTo(qreal value) = 0;
virtual void setOpacity(qreal value) = 0;
};
class QTCREATOR_UTILS_EXPORT DetailsButton : public QAbstractButton
......
......@@ -196,7 +196,7 @@ void DetailsWidgetPrivate::changeHoverState(bool hovered)
if (!m_toolWidget)
return;
#ifdef Q_OS_MAC
m_toolWidget->setVisible(hovered);
m_toolWidget->setOpacity(hovered ? 1.0 : 0);
#else
m_toolWidget->fadeTo(hovered ? 1.0 : 0);
#endif
......
......@@ -163,8 +163,6 @@ bool AutogenStep::init()
{
AutotoolsBuildConfiguration *bc = autotoolsBuildConfiguration();
setEnabled(true);
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
......
......@@ -162,8 +162,6 @@ bool AutoreconfStep::init()
{
AutotoolsBuildConfiguration *bc = autotoolsBuildConfiguration();
setEnabled(true);
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
......
......@@ -163,8 +163,6 @@ bool ConfigureStep::init()
{
AutotoolsBuildConfiguration *bc = autotoolsBuildConfiguration();
setEnabled(true);
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
......
......@@ -177,7 +177,6 @@ bool MakeStep::init()
QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
setEnabled(true);
setIgnoreReturnValue(m_clean);
ProcessParameters *pp = processParameters();
......
......@@ -136,7 +136,6 @@ bool MakeStep::init()
QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
setEnabled(true);
setIgnoreReturnValue(m_clean);
ProcessParameters *pp = processParameters();
......
......@@ -111,7 +111,6 @@ bool GenericMakeStep::init()
{
GenericBuildConfiguration *bc = genericBuildConfiguration();
setEnabled(true);
ProjectExplorer::ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory());
......
......@@ -92,15 +92,15 @@ using namespace ProjectExplorer;
AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, const QString &id) :
BuildStep(bsl, id), m_timer(0), m_futureInterface(0),
m_enabled(true), m_ignoreReturnValue(false),
m_process(0), m_eventLoop(0), m_outputParserChain(0)
m_ignoreReturnValue(false), m_process(0),
m_eventLoop(0), m_outputParserChain(0)
{
}
AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl,
AbstractProcessStep *bs) :
BuildStep(bsl, bs), m_timer(0), m_futureInterface(0),
m_enabled(bs->m_enabled), m_ignoreReturnValue(bs->m_ignoreReturnValue),
m_ignoreReturnValue(bs->m_ignoreReturnValue),
m_process(0), m_eventLoop(0), m_outputParserChain(0)
{
}
......@@ -186,10 +186,6 @@ bool AbstractProcessStep::init()
void AbstractProcessStep::run(QFutureInterface<bool> &fi)
{
m_futureInterface = &fi;
if (!m_enabled) {
fi.reportResult(true);
return;
}
QDir wd(m_param.effectiveWorkingDirectory());
if (!wd.exists())
wd.mkpath(wd.absolutePath());
......
......@@ -64,8 +64,6 @@ public:
virtual BuildStepConfigWidget *createConfigWidget() = 0;
virtual bool immutable() const = 0;
void setEnabled(bool b) { m_enabled = b; }
ProcessParameters *processParameters() { return &m_param; }
bool ignoreReturnValue();
......@@ -99,7 +97,6 @@ private:
QTimer *m_timer;
QFutureInterface<bool> *m_futureInterface;
ProcessParameters m_param;
bool m_enabled;
bool m_ignoreReturnValue;
Utils::QtcProcess *m_process;
QEventLoop *m_eventLoop;
......
......@@ -80,6 +80,7 @@ struct BuildManagerPrivate {
Internal::TaskWindow *m_taskWindow;
QList<BuildStep *> m_buildQueue;
QList<bool> m_enabledState;
QStringList m_stepNames;
ProjectExplorerPlugin *m_projectExplorerPlugin;
bool m_running;
......@@ -93,6 +94,7 @@ struct BuildManagerPrivate {
QHash<ProjectConfiguration *, int> m_activeBuildStepsPerProjectConfiguration;
Project *m_previousBuildStepProject;
// is set to true while canceling, so that nextBuildStep knows that the BuildStep finished because of canceling
bool m_skipDisabled;
bool m_canceling;
bool m_doNotEnterEventLoop;
QEventLoop *m_eventLoop;
......@@ -108,6 +110,7 @@ struct BuildManagerPrivate {
BuildManagerPrivate::BuildManagerPrivate() :
m_running(false)
, m_previousBuildStepProject(0)
, m_skipDisabled(false)
, m_canceling(false)
, m_doNotEnterEventLoop(false)
, m_eventLoop(0)
......@@ -271,6 +274,7 @@ void BuildManager::clearBuildQueue()
d->m_stepNames.clear();
d->m_buildQueue.clear();
d->m_enabledState.clear();
d->m_running = false;
d->m_previousBuildStepProject = 0;
d->m_currentBuildStep = 0;
......@@ -400,7 +404,7 @@ void BuildManager::nextBuildQueue()
d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, msgProgress(d->m_progress, d->m_maxProgress));
decrementActiveBuildSteps(d->m_currentBuildStep);
bool result = d->m_watcher.result();
bool result = d->m_skipDisabled || d->m_watcher.result();
if (!result) {
// Build Failure
const QString projectName = d->m_currentBuildStep->project()->displayName();
......@@ -445,6 +449,7 @@ void BuildManager::nextStep()
d->m_currentBuildStep = d->m_buildQueue.front();
d->m_buildQueue.pop_front();
QString name = d->m_stepNames.takeFirst();
d->m_skipDisabled = !d->m_enabledState.takeFirst();
if (d->m_futureProgress)
d->m_futureProgress.data()->setTitle(name);
......@@ -454,6 +459,14 @@ void BuildManager::nextStep()
.arg(projectName), BuildStep::MessageOutput);
d->m_previousBuildStepProject = d->m_currentBuildStep->project();
}
if (d->m_skipDisabled) {
addToOutputWindow(tr("Skipping disabled step %1.")
.arg(d->m_currentBuildStep->displayName()), BuildStep::MessageOutput);
nextBuildQueue();
return;
}
if (d->m_currentBuildStep->runInGuiThread()) {
connect (d->m_currentBuildStep, SIGNAL(finished()),
this, SLOT(buildStepFinishedAsync()));
......@@ -475,7 +488,7 @@ void BuildManager::nextStep()
}
}
bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, const QStringList &names)
bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, QStringList names)
{
int count = steps.size();
bool init = true;
......@@ -486,9 +499,11 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, const QStringList
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
connect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting)));
init = bs->init();
if (!init)
break;
if (bs->enabled()) {
init = bs->init();
if (!init)
break;
}
}
if (!init) {
BuildStep *bs = steps.at(i);
......@@ -511,6 +526,7 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, const QStringList
++d->m_maxProgress;
d->m_buildQueue.append(steps.at(i));
d->m_stepNames.append(names.at(i));
d->m_enabledState.append(steps.at(i)->enabled());
incrementActiveBuildSteps(steps.at(i));
}
return true;
......
......@@ -106,7 +106,7 @@ private:
void startBuildQueue();
void nextStep();
void clearBuildQueue();
bool buildQueueAppend(QList<BuildStep *> steps, const QStringList &names);
bool buildQueueAppend(QList<BuildStep *> steps, QStringList names);
void incrementActiveBuildSteps(BuildStep *bs);
void decrementActiveBuildSteps(BuildStep *bs);
void disconnectOutput(BuildStep *bs);
......
......@@ -122,16 +122,18 @@
\brief This signal needs to be emitted if the BuildStep runs in the gui thread.
*/
static const char buildStepEnabledKey[] = "ProjectExplorer.BuildStep.Enabled";
using namespace ProjectExplorer;
BuildStep::BuildStep(BuildStepList *bsl, const QString &id) :
ProjectConfiguration(bsl, id)
ProjectConfiguration(bsl, id), m_enabled(true)
{
Q_ASSERT(bsl);
}
BuildStep::BuildStep(BuildStepList *bsl, BuildStep *bs) :
ProjectConfiguration(bsl, bs)
ProjectConfiguration(bsl, bs), m_enabled(bs->m_enabled)
{
Q_ASSERT(bsl);
}
......@@ -140,6 +142,19 @@ BuildStep::~BuildStep()
{
}
bool BuildStep::fromMap(const QVariantMap &map)
{
m_enabled = map.value(QLatin1String(buildStepEnabledKey), true).toBool();
return ProjectConfiguration::fromMap(map);
}
QVariantMap BuildStep::toMap() const
{
QVariantMap map = ProjectConfiguration::toMap();
map.insert(QLatin1String(buildStepEnabledKey), m_enabled);
return map;
}
BuildConfiguration *BuildStep::buildConfiguration() const
{
return qobject_cast<BuildConfiguration *>(parent()->parent());
......@@ -180,6 +195,19 @@ void BuildStep::cancel()
// Do nothing
}
void BuildStep::setEnabled(bool b)
{
if (m_enabled == b)
return;
m_enabled = b;
emit enabledChanged();
}
bool BuildStep::enabled() const
{
return m_enabled;
}
IBuildStepFactory::IBuildStepFactory(QObject *parent) :
QObject(parent)
{ }
......
......@@ -70,6 +70,12 @@ public:
virtual bool runInGuiThread() const;
virtual void cancel();
virtual bool fromMap(const QVariantMap &map);
virtual QVariantMap toMap() const;
bool enabled() const;
void setEnabled(bool b);
BuildConfiguration *buildConfiguration() const;
DeployConfiguration *deployConfiguration() const;
ProjectConfiguration *projectConfiguration() const;
......@@ -86,6 +92,10 @@ signals:
ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline) const;
void finished();
void enabledChanged();
private:
bool m_enabled;
};
class PROJECTEXPLORER_EXPORT IBuildStepFactory :
......
......@@ -34,7 +34,6 @@
#include "buildconfiguration.h"
#include "buildsteplist.h"
#include "detailsbutton.h"
#include "projectexplorerconstants.h"
#include <coreplugin/coreconstants.h>
......@@ -45,6 +44,7 @@
#include <QtCore/QSignalMapper>
#include <QtCore/QPropertyAnimation>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QMenu>
......@@ -53,12 +53,170 @@
#include <QtGui/QToolButton>
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
#include <QtGui/QGraphicsOpacityEffect>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
ToolWidget::ToolWidget(QWidget *parent)
: Utils::FadingPanel(parent), m_buildStepEnabled(true)
{
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(4);
layout->setSpacing(4);
setLayout(layout);
m_firstWidget = new FadingWidget(this);
m_firstWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QHBoxLayout *hbox = new QHBoxLayout();
hbox->setContentsMargins(0, 0, 0, 0);
hbox->setSpacing(0);
m_firstWidget->setLayout(hbox);
#ifdef Q_OS_MAC
QSize buttonSize(20, 20);
#else
QSize buttonSize(20, 26);
#endif
m_disableButton = new QToolButton(m_firstWidget);
m_disableButton->setAutoRaise(true);
m_disableButton->setToolTip(BuildStepListWidget::tr("Disable"));
m_disableButton->setFixedSize(buttonSize);
m_disableButton->setIcon(QIcon(QLatin1String(":/projectexplorer/images/disabledbuildstep.png")));
m_disableButton->setCheckable(true);
hbox->addWidget(m_disableButton);
layout->addWidget(m_firstWidget);
m_secondWidget = new FadingWidget(this);
m_secondWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
hbox = new QHBoxLayout();
hbox->setMargin(0);
hbox->setSpacing(4);
m_secondWidget->setLayout(hbox);
m_upButton = new QToolButton(m_secondWidget);
m_upButton->setAutoRaise(true);
m_upButton->setToolTip(BuildStepListWidget::tr("Move Up"));
m_upButton->setFixedSize(buttonSize);
m_upButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowup.png")));
hbox->addWidget(m_upButton);
m_downButton = new QToolButton(m_secondWidget);
m_downButton->setAutoRaise(true);
m_downButton->setToolTip(BuildStepListWidget::tr("Move Down"));
m_downButton->setFixedSize(buttonSize);
m_downButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowdown.png")));
hbox->addWidget(m_downButton);
m_removeButton = new QToolButton(m_secondWidget);
m_removeButton->setAutoRaise(true);
m_removeButton->setToolTip(BuildStepListWidget::tr("Remove Item"));
m_removeButton->setFixedSize(buttonSize);
m_removeButton->setIcon(QIcon(QLatin1String(":/core/images/darkclose.png")));
hbox->addWidget(m_removeButton);
layout->addWidget(m_secondWidget);
connect(m_disableButton, SIGNAL(clicked()), this, SIGNAL(disabledClicked()));
connect(m_upButton, SIGNAL(clicked()), this, SIGNAL(upClicked()));
connect(m_downButton, SIGNAL(clicked()), this, SIGNAL(downClicked()));
connect(m_removeButton, SIGNAL(clicked()), this, SIGNAL(removeClicked()));
}
void ToolWidget::setOpacity(qreal value)
{
m_targetOpacity = value;
if (m_buildStepEnabled)
m_firstWidget->setOpacity(value);
m_secondWidget->setOpacity(value);
}
void ToolWidget::fadeTo(qreal value)
{
m_targetOpacity = value;
if (m_buildStepEnabled)
m_firstWidget->fadeTo(value);
m_secondWidget->fadeTo(value);
}
void ToolWidget::setBuildStepEnabled(bool b)
{
m_buildStepEnabled = b;
if (m_buildStepEnabled) {
#ifdef Q_OS_MAC
m_firstWidget->setOpacity(m_targetOpacity);
#else
m_firstWidget->fadeTo(m_targetOpacity);
#endif
} else {
#ifdef Q_OS_MAC
m_firstWidget->setOpacity(1.0);
#else
m_firstWidget->fadeTo(1.0);
#endif
}
m_disableButton->setChecked(!b);
}
void ToolWidget::setUpEnabled(bool b)
{
m_upButton->setEnabled(b);
}
void ToolWidget::setDownEnabled(bool b)
{
m_downButton->setEnabled(b);
}
void ToolWidget::setRemoveEnabled(bool b)
{
m_removeButton->setEnabled(b);
}
void ToolWidget::setUpVisible(bool b)
{
m_upButton->setVisible(b);
}
void ToolWidget::setDownVisible(bool b)
{
m_downButton->setVisible(b);
}
FadingWidget::FadingWidget(QWidget *parent) :
QWidget(parent),
m_opacityEffect(new QGraphicsOpacityEffect)
{
m_opacityEffect->setOpacity(0);
setGraphicsEffect(m_opacityEffect);
// Workaround for issue with QGraphicsEffect. GraphicsEffect
// currently clears with Window color. Remove if flickering
// no longer occurs on fade-in
QPalette pal;
pal.setBrush(QPalette::All, QPalette::Window, Qt::transparent);
setPalette(pal);
}
void FadingWidget::setOpacity(qreal value)
{
m_opacityEffect->setOpacity(value);
}
void FadingWidget::fadeTo(qreal value)
{
QPropertyAnimation *animation = new QPropertyAnimation(m_opacityEffect, "opacity");
animation->setDuration(200);
animation->setEndValue(value);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
qreal FadingWidget::opacity()
{
return m_opacityEffect->opacity();
}
BuildStepsWidgetData::BuildStepsWidgetData(BuildStep *s) :
step(s), widget(0), detailsWidget(0), upButton(0), downButton(0), removeButton(0)
step(s), widget(0), detailsWidget(0)
{
widget = s->createConfigWidget();
Q_ASSERT(widget);
......@@ -66,44 +224,11 @@ BuildStepsWidgetData::BuildStepsWidgetData(BuildStep *s) :
detailsWidget = new Utils::DetailsWidget;
detailsWidget->setWidget(widget);
Utils::FadingPanel *toolWidget = new Utils::FadingPanel(detailsWidget);
#ifdef Q_OS_MAC
QSize buttonSize(20, 20);
#else
QSize buttonSize(20, 26);
#endif
upButton = new QToolButton(toolWidget);
upButton->setAutoRaise(true);
upButton->setToolTip(BuildStepListWidget::tr("Move Up"));
upButton->setFixedSize(buttonSize);
upButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowup.png")));
downButton = new QToolButton(toolWidget);
downButton->setAutoRaise(true);
downButton->setToolTip(BuildStepListWidget::tr("Move Down"));
downButton->setFixedSize(buttonSize);
downButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowdown.png")));
removeButton = new QToolButton(toolWidget);
removeButton->setAutoRaise(true);
removeButton->setToolTip(BuildStepListWidget::tr("Remove Item"));
removeButton->setFixedSize(buttonSize);
removeButton->setIcon(QIcon(QLatin1String(":/core/images/darkclose.png")));
toolWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
QHBoxLayout *hbox = new QHBoxLayout();
toolWidget->setLayout(hbox);
hbox->setMargin(4);
hbox->setSpacing(0);
hbox->addWidget(upButton);
hbox->addWidget(downButton);
hbox->addWidget(removeButton);
toolWidget = new ToolWidget(detailsWidget);