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

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 :
......
......@@ -36,6 +36,7 @@
#include "buildstep.h"
#include "deployconfiguration.h"
#include "namedwidget.h"
#include <utils/detailsbutton.h>
QT_BEGIN_NAMESPACE
class QPushButton;
......@@ -43,6 +44,7 @@ class QToolButton;
class QLabel;
class QVBoxLayout;
class QSignalMapper;
class QGraphicsOpacityEffect;
QT_END_NAMESPACE
namespace Utils {
......@@ -55,6 +57,50 @@ class Target;
class BuildConfiguration;
namespace Internal {
class FadingWidget : public QWidget
{
Q_OBJECT
public:
FadingWidget(QWidget *parent = 0);
void fadeTo(qreal value);
qreal opacity();
void setOpacity(qreal value);
protected:
QGraphicsOpacityEffect *m_opacityEffect;
};
class ToolWidget : public Utils::FadingPanel
{
Q_OBJECT
public:
ToolWidget(QWidget *parent = 0);
void fadeTo(qreal value);
void setOpacity(qreal value);
void setBuildStepEnabled(bool b);
void setUpEnabled(bool b);
void setDownEnabled(bool b);
void setRemoveEnabled(bool b);
void setUpVisible(bool b);
void setDownVisible(bool b);
signals:
void disabledClicked();
void upClicked();
void downClicked();
void removeClicked();
private:
QToolButton *m_disableButton;
QToolButton *m_upButton;
QToolButton *m_downButton;
QToolButton *m_removeButton;
bool m_buildStepEnabled;
FadingWidget *m_firstWidget;
FadingWidget *m_secondWidget;
qreal m_targetOpacity;
};
class BuildStepsWidgetData
{
......@@ -65,9 +111,7 @@ public:
BuildStep *step;
BuildStepConfigWidget *widget;
Utils::DetailsWidget *detailsWidget;
QToolButton *upButton;
QToolButton *downButton;
QToolButton *removeButton;
ToolWidget *toolWidget;
};
class BuildStepListWidget : public NamedWidget
......@@ -86,11 +130,13 @@ private slots:
void addBuildStep(int pos);
void updateSummary();
void updateAdditionalSummary();
void updateEnabledState();
void triggerStepMoveUp(int pos);
void stepMoved(int from, int to);
void triggerStepMoveDown(int pos);
void triggerRemoveBuildStep(int pos);
void removeBuildStep(int pos);
void triggerDisable(int pos);
private:
void setupUi();
......@@ -107,6 +153,7 @@ private:
QLabel *m_noStepsLabel;
QPushButton *m_addButton;
QSignalMapper *m_disableMapper;
QSignalMapper *m_upMapper;
QSignalMapper *m_downMapper;
QSignalMapper *m_removeMapper;
......
......@@ -52,7 +52,6 @@ const char PROCESS_STEP_ID[] = "ProjectExplorer.ProcessStep";
const char PROCESS_COMMAND_KEY[] = "ProjectExplorer.ProcessStep.Command";
const char PROCESS_WORKINGDIRECTORY_KEY[] = "ProjectExplorer.ProcessStep.WorkingDirectory";
const char PROCESS_ARGUMENTS_KEY[] = "ProjectExplorer.ProcessStep.Arguments";
const char PROCESS_ENABLED_KEY[] = "ProjectExplorer.ProcessStep.Enabled";
}
ProcessStep::ProcessStep(BuildStepList *bsl) :
......@@ -71,8 +70,7 @@ ProcessStep::ProcessStep(BuildStepList *bsl, ProcessStep *bs) :
AbstractProcessStep(bsl, bs),
m_command(bs->m_command),
m_arguments(bs->m_arguments),
m_workingDirectory(bs->m_workingDirectory),
m_enabled(bs->m_enabled)
m_workingDirectory(bs->m_workingDirectory)
{
ctor();
}
......@@ -100,7 +98,6 @@ bool ProcessStep::init()
pp->setWorkingDirectory(workingDirectory());
pp->setCommand(m_command);
pp->setArguments(m_arguments);
AbstractProcessStep::setEnabled(m_enabled);
setOutputParser(bc->createOutputParser());
return AbstractProcessStep::init();
}
......@@ -130,11 +127,6 @@ QString ProcessStep::arguments() const
return m_arguments;
}
bool ProcessStep::enabled() const
{
return m_enabled;
}
QString ProcessStep::workingDirectory() const
{
return m_workingDirectory;
......@@ -150,11 +142,6 @@ void ProcessStep::setArguments(const QString &arguments)
m_arguments = arguments;
}
void ProcessStep::setEnabled(bool enabled)
{
m_enabled = enabled;
}
void ProcessStep::setWorkingDirectory(const QString &workingDirectory)
{
if (workingDirectory.isEmpty())
......@@ -169,8 +156,6 @@ QVariantMap ProcessStep::toMap() const
map.insert(QLatin1String(PROCESS_COMMAND_KEY), command());
map.insert(QLatin1String(PROCESS_ARGUMENTS_KEY), arguments());
map.insert(QLatin1String(PROCESS_WORKINGDIRECTORY_KEY), workingDirectory());
map.insert(QLatin1String(PROCESS_ENABLED_KEY), enabled());
return map;
}
......@@ -179,7 +164,6 @@ bool ProcessStep::fromMap(const QVariantMap &map)
setCommand(map.value(QLatin1String(PROCESS_COMMAND_KEY)).toString());
setArguments(map.value(QLatin1String(PROCESS_ARGUMENTS_KEY)).toString());
setWorkingDirectory(map.value(QLatin1String(PROCESS_WORKINGDIRECTORY_KEY)).toString());
setEnabled(map.value(QLatin1String(PROCESS_ENABLED_KEY), false).toBool());
return AbstractProcessStep::fromMap(map);
}
......@@ -271,7 +255,6 @@ ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step)
m_ui.workingDirectory->setPath(m_step->workingDirectory());
m_ui.commandArgumentsLineEdit->setText(m_step->arguments());
m_ui.enabledCheckBox->setChecked(m_step->enabled());
updateDetails();
......@@ -282,8 +265,6 @@ ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step)
connect(m_ui.commandArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
this, SLOT(commandArgumentsLineEditTextEdited()));
connect(m_ui.enabledCheckBox, SIGNAL(clicked(bool)),
this, SLOT(enabledCheckBoxClicked(bool)));
}
void ProcessStepConfigWidget::updateDetails()
......@@ -302,10 +283,6 @@ void ProcessStepConfigWidget::updateDetails()
param.setCommand(m_step->command());
param.setArguments(m_step->arguments());
m_summaryText = param.summary(displayName);
if (!m_step->enabled()) {
//: %1 is the custom process step summary
m_summaryText = tr("%1 (disabled)").arg(m_summaryText);
}
emit updateSummary();
}
......@@ -335,9 +312,3 @@ void ProcessStepConfigWidget::commandArgumentsLineEditTextEdited()
m_step->setArguments(m_ui.commandArgumentsLineEdit->text());
updateDetails();
}
void ProcessStepConfigWidget::enabledCheckBoxClicked(bool)
{
m_step->setEnabled(m_ui.enabledCheckBox->isChecked());
updateDetails();
}
......@@ -77,12 +77,10 @@ public:
QString command() const;
QString arguments() const;
bool enabled() const;
QString workingDirectory() const;
void setCommand(const QString &command);
void setArguments(const QString &arguments);
void setEnabled(bool enabled);
void setWorkingDirectory(const QString &workingDirectory);
QVariantMap toMap() const;
......@@ -99,7 +97,6 @@ private:
QString m_command;
QString m_arguments;
QString m_workingDirectory;
bool m_enabled;
};
class ProcessStepConfigWidget : public BuildStepConfigWidget
......@@ -113,7 +110,6 @@ private slots:
void commandLineEditTextEdited();
void workingDirectoryLineEditTextEdited();
void commandArgumentsLineEditTextEdited();
void enabledCheckBoxClicked(bool);
private:
void updateDetails();
ProcessStep *m_step;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>290</width>
<height>95</height>
<width>262</width>
<height>66</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
......@@ -15,47 +15,33 @@
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Enable custom process step</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="enabledCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="commandLabel">
<property name="text">
<string>Command:</string>
</property>
</widget>
</item>