forked from qt-creator/qt-creator
Optionaly disable buildsteps
Task-number: QTCREATORBUG-6713 Change-Id: Ief7f8509572cfa2008209083e5ae9c7763eba42a Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -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);
|
||||
toolWidget->setBuildStepEnabled(step->enabled());
|
||||
|
||||
detailsWidget->setToolWidget(toolWidget);
|
||||
|
||||
detailsWidget->setContentsMargins(0, 0, 0, 1);
|
||||
|
||||
detailsWidget->setSummaryText(widget->summaryText());
|
||||
detailsWidget->setAdditionalSummaryText(widget->additionalSummaryText());
|
||||
}
|
||||
@@ -153,6 +278,19 @@ void BuildStepListWidget::updateAdditionalSummary()
|
||||
}
|
||||
}
|
||||
|
||||
void BuildStepListWidget::updateEnabledState()
|
||||
{
|
||||
BuildStep *step = qobject_cast<BuildStep *>(sender());
|
||||
if (step) {
|
||||
foreach (const BuildStepsWidgetData *s, m_buildStepsData) {
|
||||
if (s->step == step) {
|
||||
s->toolWidget->setBuildStepEnabled(step->enabled());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BuildStepListWidget::init(BuildStepList *bsl)
|
||||
{
|
||||
Q_ASSERT(bsl);
|
||||
@@ -240,11 +378,16 @@ void BuildStepListWidget::addBuildStepWidget(int pos, BuildStep *step)
|
||||
connect(s->widget, SIGNAL(updateAdditionalSummary()),
|
||||
this, SLOT(updateAdditionalSummary()));
|
||||
|
||||
connect(s->upButton, SIGNAL(clicked()),
|
||||
connect(s->step, SIGNAL(enabledChanged()),
|
||||
this, SLOT(updateEnabledState()));
|
||||
|
||||
connect(s->toolWidget, SIGNAL(disabledClicked()),
|
||||
m_disableMapper, SLOT(map()));
|
||||
connect(s->toolWidget, SIGNAL(upClicked()),
|
||||
m_upMapper, SLOT(map()));
|
||||
connect(s->downButton, SIGNAL(clicked()),
|
||||
connect(s->toolWidget, SIGNAL(downClicked()),
|
||||
m_downMapper, SLOT(map()));
|
||||
connect(s->removeButton, SIGNAL(clicked()),
|
||||
connect(s->toolWidget, SIGNAL(removeClicked()),
|
||||
m_removeMapper, SLOT(map()));
|
||||
}
|
||||
|
||||
@@ -314,11 +457,21 @@ void BuildStepListWidget::removeBuildStep(int pos)
|
||||
m_noStepsLabel->setVisible(hasSteps);
|
||||
}
|
||||
|
||||
void BuildStepListWidget::triggerDisable(int pos)
|
||||
{
|
||||
BuildStep *bs = m_buildStepsData.at(pos)->step;
|
||||
bs->setEnabled(!bs->enabled());
|
||||
m_buildStepsData.at(pos)->toolWidget->setBuildStepEnabled(bs->enabled());
|
||||
}
|
||||
|
||||
void BuildStepListWidget::setupUi()
|
||||
{
|
||||
if (0 != m_addButton)
|
||||
return;
|
||||
|
||||
m_disableMapper = new QSignalMapper(this);
|
||||
connect(m_disableMapper, SIGNAL(mapped(int)),
|
||||
this, SLOT(triggerDisable(int)));
|
||||
m_upMapper = new QSignalMapper(this);
|
||||
connect(m_upMapper, SIGNAL(mapped(int)),
|
||||
this, SLOT(triggerStepMoveUp(int)));
|
||||
@@ -361,21 +514,22 @@ void BuildStepListWidget::updateBuildStepButtonsState()
|
||||
return;
|
||||
for (int i = 0; i < m_buildStepsData.count(); ++i) {
|
||||
BuildStepsWidgetData *s = m_buildStepsData.at(i);
|
||||
s->removeButton->setEnabled(!m_buildStepList->at(i)->immutable());
|
||||
m_removeMapper->setMapping(s->removeButton, i);
|
||||
m_disableMapper->setMapping(s->toolWidget, i);
|
||||
s->toolWidget->setRemoveEnabled(!m_buildStepList->at(i)->immutable());
|
||||
m_removeMapper->setMapping(s->toolWidget, i);
|
||||
|
||||
s->upButton->setEnabled((i > 0)
|
||||
&& !(m_buildStepList->at(i)->immutable()
|
||||
&& m_buildStepList->at(i - 1)));
|
||||
m_upMapper->setMapping(s->upButton, i);
|
||||
s->downButton->setEnabled((i + 1 < m_buildStepList->count())
|
||||
&& !(m_buildStepList->at(i)->immutable()
|
||||
&& m_buildStepList->at(i + 1)->immutable()));
|
||||
m_downMapper->setMapping(s->downButton, i);
|
||||
s->toolWidget->setUpEnabled((i > 0)
|
||||
&& !(m_buildStepList->at(i)->immutable()
|
||||
&& m_buildStepList->at(i - 1)));
|
||||
m_upMapper->setMapping(s->toolWidget, i);
|
||||
s->toolWidget->setDownEnabled((i + 1 < m_buildStepList->count())
|
||||
&& !(m_buildStepList->at(i)->immutable()
|
||||
&& m_buildStepList->at(i + 1)->immutable()));
|
||||
m_downMapper->setMapping(s->toolWidget, i);
|
||||
|
||||
// Only show buttons when needed
|
||||
s->downButton->setVisible(m_buildStepList->count() != 1);
|
||||
s->upButton->setVisible(m_buildStepList->count() != 1);
|
||||
s->toolWidget->setDownVisible(m_buildStepList->count() != 1);
|
||||
s->toolWidget->setUpVisible(m_buildStepList->count() != 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user