forked from qt-creator/qt-creator
Utils: Unify and simplify Details(Button|Widget) and ExpandButton
This replaces lots of custom painting/animating code with a simplified implementation and cross-platform visual unification. Task-number: QTCREATORBUG-27801 Change-Id: I18b12e8c7f0bba4ba5d8a05271ab1e757769dc5f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -399,11 +399,6 @@ ToolBarIconShadow=true
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=true
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
[ImageFiles]
|
||||
IconOverlayCSource=:/cppeditor/images/dark_qt_c.png
|
||||
IconOverlayCppHeader=:/cppeditor/images/dark_qt_h.png
|
||||
|
||||
@@ -366,8 +366,3 @@ FlatMenuBar=false
|
||||
ToolBarIconShadow=true
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=false
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=ffffffff
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -410,8 +410,3 @@ FlatMenuBar=true
|
||||
ToolBarIconShadow=false
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=false
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -510,8 +510,3 @@ FlatMenuBar=true
|
||||
ToolBarIconShadow=true
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=true
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -402,8 +402,3 @@ FlatMenuBar=true
|
||||
ToolBarIconShadow=true
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=true
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -375,8 +375,3 @@ FlatMenuBar=false
|
||||
ToolBarIconShadow=false
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=false
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -373,8 +373,3 @@ FlatMenuBar=false
|
||||
ToolBarIconShadow=true
|
||||
WindowColorAsBase=false
|
||||
DarkUserInterface=false
|
||||
|
||||
[Gradients]
|
||||
DetailsWidgetHeaderGradient\1\color=00000000
|
||||
DetailsWidgetHeaderGradient\1\pos=1
|
||||
DetailsWidgetHeaderGradient\size=1
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "detailsbutton.h"
|
||||
|
||||
#include "hostosinfo.h"
|
||||
#include "theme/theme.h"
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/icon.h>
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include <qdrawutil.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
FadingWidget::FadingWidget(QWidget *parent) :
|
||||
@@ -47,200 +49,52 @@ qreal FadingWidget::opacity()
|
||||
return m_opacityEffect->opacity();
|
||||
}
|
||||
|
||||
DetailsButton::DetailsButton(QWidget *parent) : QAbstractButton(parent), m_fader(0)
|
||||
ExpandButton::ExpandButton(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
{
|
||||
setCheckable(true);
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
auto updateArrow = [this] (bool checked) {
|
||||
static const QIcon expand =
|
||||
Icon({{":/utils/images/arrowdown.png", Theme::PanelTextColorDark}}, Icon::Tint).icon();
|
||||
static const QIcon collapse =
|
||||
Icon({{":/utils/images/arrowup.png", Theme::PanelTextColorDark}}, Icon::Tint).icon();
|
||||
setIcon(checked ? collapse : expand);
|
||||
};
|
||||
updateArrow(false);
|
||||
connect(this, &QToolButton::toggled, this, updateArrow);
|
||||
}
|
||||
|
||||
DetailsButton::DetailsButton(QWidget *parent)
|
||||
: ExpandButton(parent)
|
||||
{
|
||||
setText(tr("Details"));
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
}
|
||||
|
||||
QSize DetailsButton::sizeHint() const
|
||||
{
|
||||
// TODO: Adjust this when icons become available!
|
||||
const int w = fontMetrics().horizontalAdvance(text()) + 32;
|
||||
if (HostOsInfo::isMacHost())
|
||||
return QSize(w, 34);
|
||||
return QSize(w, 22);
|
||||
}
|
||||
|
||||
bool DetailsButton::event(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::Enter:
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(200);
|
||||
animation->setEndValue(1.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
break;
|
||||
case QEvent::Leave:
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(200);
|
||||
animation->setEndValue(0.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QAbstractButton::event(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DetailsButton::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::EnabledChange) {
|
||||
m_checkedPixmap = QPixmap();
|
||||
m_uncheckedPixmap = QPixmap();
|
||||
}
|
||||
const QSize textSize = fontMetrics().size(Qt::TextSingleLine, text());
|
||||
return QSize(spacing + textSize.width() + spacing + 16 + spacing,
|
||||
spacing + fontMetrics().height() + spacing);
|
||||
}
|
||||
|
||||
void DetailsButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
Q_UNUSED(e)
|
||||
|
||||
QPainter p(this);
|
||||
if (isChecked() || (!HostOsInfo::isMacHost() && underMouse())) {
|
||||
p.save();
|
||||
p.setOpacity(0.125);
|
||||
p.fillRect(rect(), palette().color(QPalette::Text));
|
||||
p.restore();
|
||||
}
|
||||
|
||||
// draw hover animation
|
||||
if (!HostOsInfo::isMacHost() && !isDown() && m_fader > 0) {
|
||||
QColor c = creatorTheme()->color(Theme::DetailsButtonBackgroundColorHover);
|
||||
c.setAlpha (int(m_fader * c.alpha()));
|
||||
|
||||
QRect r = rect();
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||
r.adjust(1, 1, -2, -2);
|
||||
p.fillRect(r, c);
|
||||
}
|
||||
|
||||
if (isChecked()) {
|
||||
if (m_checkedPixmap.isNull() || m_checkedPixmap.size() / m_checkedPixmap.devicePixelRatio() != contentsRect().size())
|
||||
m_checkedPixmap = cacheRendering(contentsRect().size(), true);
|
||||
p.drawPixmap(contentsRect(), m_checkedPixmap);
|
||||
} else {
|
||||
if (m_uncheckedPixmap.isNull() || m_uncheckedPixmap.size() / m_uncheckedPixmap.devicePixelRatio() != contentsRect().size())
|
||||
m_uncheckedPixmap = cacheRendering(contentsRect().size(), false);
|
||||
p.drawPixmap(contentsRect(), m_uncheckedPixmap);
|
||||
}
|
||||
if (isDown()) {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(QColor(0, 0, 0, 20));
|
||||
p.drawRoundedRect(rect().adjusted(1, 1, -1, -1), 1, 1);
|
||||
}
|
||||
if (hasFocus()) {
|
||||
QStyleOptionFocusRect option;
|
||||
option.initFrom(this);
|
||||
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap DetailsButton::cacheRendering(const QSize &size, bool checked)
|
||||
{
|
||||
const qreal pixelRatio = devicePixelRatio();
|
||||
QPixmap pixmap(size * pixelRatio);
|
||||
pixmap.setDevicePixelRatio(pixelRatio);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.translate(0.5, 0.5);
|
||||
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
||||
QLinearGradient lg;
|
||||
lg.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
lg.setFinalStop(0, 1);
|
||||
if (!checked) {
|
||||
lg.setColorAt(0, QColor(0, 0, 0, 10));
|
||||
lg.setColorAt(1, QColor(0, 0, 0, 16));
|
||||
} else {
|
||||
lg.setColorAt(0, QColor(255, 255, 255, 0));
|
||||
lg.setColorAt(1, QColor(255, 255, 255, 50));
|
||||
}
|
||||
p.setBrush(lg);
|
||||
p.setPen(QColor(255,255,255,140));
|
||||
p.drawRoundedRect(1, 1, size.width()-3, size.height()-3, 1, 1);
|
||||
p.setPen(QPen(QColor(0, 0, 0, 40)));
|
||||
p.drawLine(0, 1, 0, size.height() - 2);
|
||||
if (checked)
|
||||
p.drawLine(1, size.height() - 1, size.width() - 1, size.height() - 1);
|
||||
} else {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(0, 0, size.width(), size.height(), 1, 1);
|
||||
}
|
||||
|
||||
p.setPen(palette().color(QPalette::Text));
|
||||
|
||||
QRect textRect = p.fontMetrics().boundingRect(text());
|
||||
textRect.setWidth(textRect.width() + 15);
|
||||
textRect.setHeight(textRect.height() + 4);
|
||||
textRect.moveCenter(rect().center());
|
||||
qDrawPlainRect(&p, rect(), palette().color(QPalette::Mid));
|
||||
|
||||
const QRect textRect(spacing, 0, width(), height());
|
||||
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());
|
||||
|
||||
int arrowsize = 15;
|
||||
QStyleOption arrowOpt;
|
||||
arrowOpt.initFrom(this);
|
||||
QPalette pal = arrowOpt.palette;
|
||||
pal.setBrush(QPalette::All, QPalette::Text, QColor(0, 0, 0));
|
||||
arrowOpt.rect = QRect(size.width() - arrowsize - 6, height()/2-arrowsize/2, arrowsize, arrowsize);
|
||||
arrowOpt.palette = pal;
|
||||
style()->drawPrimitive(checked ? QStyle::PE_IndicatorArrowUp : QStyle::PE_IndicatorArrowDown, &arrowOpt, &p, this);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
ExpandButton::ExpandButton(QWidget *parent) : QAbstractButton(parent)
|
||||
{
|
||||
setCheckable(true);
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
}
|
||||
|
||||
QSize ExpandButton::sizeHint() const
|
||||
{
|
||||
return {fontMetrics().horizontalAdvance(text()) + 26, HostOsInfo::isMacHost() ? 34 : 22};
|
||||
}
|
||||
|
||||
void ExpandButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
QPainter p(this);
|
||||
|
||||
QPixmap &pixmap = isChecked() ? m_checkedPixmap : m_uncheckedPixmap;
|
||||
if (pixmap.isNull() || pixmap.size() / pixmap.devicePixelRatio() != contentsRect().size())
|
||||
pixmap = cacheRendering();
|
||||
p.drawPixmap(contentsRect(), pixmap);
|
||||
|
||||
if (isDown()) {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(QColor(0, 0, 0, 20));
|
||||
p.drawRoundedRect(rect().adjusted(1, 1, -1, -1), 1, 1);
|
||||
}
|
||||
if (hasFocus()) {
|
||||
QStyleOptionFocusRect option;
|
||||
option.initFrom(this);
|
||||
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap ExpandButton::cacheRendering()
|
||||
{
|
||||
const QSize size = contentsRect().size();
|
||||
const qreal pixelRatio = devicePixelRatio();
|
||||
QPixmap pixmap(size * pixelRatio);
|
||||
pixmap.setDevicePixelRatio(pixelRatio);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.translate(0.5, 0.5);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(0, 0, size.width(), size.height(), 1, 1);
|
||||
int arrowsize = 15;
|
||||
QStyleOption arrowOpt;
|
||||
arrowOpt.initFrom(this);
|
||||
QPalette pal = arrowOpt.palette;
|
||||
pal.setBrush(QPalette::All, QPalette::Text, QColor(0, 0, 0));
|
||||
arrowOpt.rect = QRect(size.width() - arrowsize - 6, height() / 2 - arrowsize / 2,
|
||||
arrowsize, arrowsize);
|
||||
arrowOpt.palette = pal;
|
||||
style()->drawPrimitive(isChecked() ? QStyle::PE_IndicatorArrowUp
|
||||
: QStyle::PE_IndicatorArrowDown, &arrowOpt, &p, this);
|
||||
return pixmap;
|
||||
const QRect iconRect(width() - spacing - 16, 0, 16, height());
|
||||
icon().paint(&p, iconRect);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QToolButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsOpacityEffect;
|
||||
@@ -36,45 +36,21 @@ protected:
|
||||
QGraphicsOpacityEffect *m_opacityEffect;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT DetailsButton : public QAbstractButton
|
||||
class QTCREATOR_UTILS_EXPORT ExpandButton : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
|
||||
public:
|
||||
DetailsButton(QWidget *parent = nullptr);
|
||||
|
||||
QSize sizeHint() const override;
|
||||
float fader() { return m_fader; }
|
||||
void setFader(float value) { m_fader = value; update(); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
bool event(QEvent *e) override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
QPixmap cacheRendering(const QSize &size, bool checked);
|
||||
QPixmap m_checkedPixmap;
|
||||
QPixmap m_uncheckedPixmap;
|
||||
float m_fader;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT ExpandButton : public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExpandButton(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT DetailsButton : public ExpandButton
|
||||
{
|
||||
public:
|
||||
DetailsButton(QWidget *parent = nullptr);
|
||||
QSize sizeHint() const override;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
QSize sizeHint() const override;
|
||||
|
||||
QPixmap cacheRendering();
|
||||
|
||||
QPixmap m_checkedPixmap;
|
||||
QPixmap m_uncheckedPixmap;
|
||||
const int spacing = 6;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "detailsbutton.h"
|
||||
#include "hostosinfo.h"
|
||||
#include "stylehelper.h"
|
||||
#include "theme/theme.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
@@ -15,6 +16,8 @@
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
#include <qdrawutil.h>
|
||||
|
||||
/*!
|
||||
\class Utils::DetailsWidget
|
||||
|
||||
@@ -57,9 +60,6 @@ public:
|
||||
FadingPanel *m_toolWidget;
|
||||
QWidget *m_widget;
|
||||
|
||||
QPixmap m_collapsedPixmap;
|
||||
QPixmap m_expandedPixmap;
|
||||
|
||||
DetailsWidget::State m_state;
|
||||
bool m_hovered;
|
||||
bool m_useCheckBox;
|
||||
@@ -112,37 +112,6 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget *parent) :
|
||||
m_grid->addWidget(m_additionalSummaryLabel, 1, 0, 1, 3);
|
||||
}
|
||||
|
||||
QPixmap DetailsWidget::createBackground(const QSize &size, int topHeight, QWidget *widget)
|
||||
{
|
||||
QPixmap pixmap(size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter p(&pixmap);
|
||||
|
||||
QRect topRect(0, 0, size.width(), topHeight);
|
||||
QRect fullRect(0, 0, size.width(), size.height());
|
||||
if (HostOsInfo::isMacHost())
|
||||
p.fillRect(fullRect, QApplication::palette().window().color());
|
||||
else
|
||||
p.fillRect(fullRect, creatorTheme()->color(Theme::DetailsWidgetBackgroundColor));
|
||||
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
||||
QLinearGradient lg(topRect.topLeft(), topRect.bottomLeft());
|
||||
lg.setStops(creatorTheme()->gradient(Theme::DetailsWidgetHeaderGradient));
|
||||
p.fillRect(topRect, lg);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.translate(0.5, 0.5);
|
||||
p.setPen(QColor(0, 0, 0, 40));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.drawRoundedRect(fullRect.adjusted(0, 0, -1, -1), 2, 2);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(QColor(255,255,255,140));
|
||||
p.drawRoundedRect(fullRect.adjusted(1, 1, -2, -2), 2, 2);
|
||||
p.setPen(QPen(widget->palette().color(QPalette::Mid)));
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void DetailsWidgetPrivate::updateControls()
|
||||
{
|
||||
if (m_widget)
|
||||
@@ -248,27 +217,14 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
|
||||
{
|
||||
QWidget::paintEvent(paintEvent);
|
||||
|
||||
const QColor bgColor = creatorTheme()->flag(Theme::FlatProjectsMode) ?
|
||||
creatorTheme()->color(Theme::DetailsWidgetBackgroundColor)
|
||||
: palette().color(QPalette::Window);
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
QWidget *topLeftWidget = d->m_useCheckBox ? static_cast<QWidget *>(d->m_summaryCheckBox) : static_cast<QWidget *>(d->m_summaryLabelIcon);
|
||||
QPoint topLeft(topLeftWidget->geometry().left() - MARGIN, contentsRect().top());
|
||||
const QRect paintArea(topLeft, contentsRect().bottomRight());
|
||||
|
||||
int topHeight = d->m_useCheckBox ? d->m_summaryCheckBox->height() : d->m_summaryLabel->height();
|
||||
if (d->m_state == DetailsWidget::Expanded || d->m_state == DetailsWidget::Collapsed) // Details Button is shown
|
||||
topHeight = qMax(d->m_detailsButton->height(), topHeight);
|
||||
|
||||
if (d->m_state == Collapsed) {
|
||||
if (d->m_collapsedPixmap.isNull() ||
|
||||
d->m_collapsedPixmap.size() != size())
|
||||
d->m_collapsedPixmap = createBackground(paintArea.size(), topHeight, this);
|
||||
p.drawPixmap(paintArea, d->m_collapsedPixmap);
|
||||
} else {
|
||||
if (d->m_expandedPixmap.isNull() ||
|
||||
d->m_expandedPixmap.size() != size())
|
||||
d->m_expandedPixmap = createBackground(paintArea.size(), topHeight, this);
|
||||
p.drawPixmap(paintArea, d->m_expandedPixmap);
|
||||
}
|
||||
p.fillRect(rect(), bgColor);
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||
qDrawPlainRect(&p, rect(), palette().color(QPalette::Mid));
|
||||
}
|
||||
|
||||
void DetailsWidget::enterEvent(QEnterEvent *event)
|
||||
|
||||
@@ -60,8 +60,6 @@ public:
|
||||
void setExpandable(bool b);
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
static QPixmap createBackground(const QSize &size, int topHeight, QWidget *widget);
|
||||
|
||||
signals:
|
||||
void checked(bool);
|
||||
void linkActivated(const QString &link);
|
||||
|
||||
@@ -25,7 +25,6 @@ ThemePrivate::ThemePrivate()
|
||||
const QMetaObject &m = Theme::staticMetaObject;
|
||||
colors.resize (m.enumerator(m.indexOfEnumerator("Color")).keyCount());
|
||||
imageFiles.resize (m.enumerator(m.indexOfEnumerator("ImageFile")).keyCount());
|
||||
gradients.resize (m.enumerator(m.indexOfEnumerator("Gradient")).keyCount());
|
||||
flags.resize (m.enumerator(m.indexOfEnumerator("Flag")).keyCount());
|
||||
}
|
||||
|
||||
@@ -132,11 +131,6 @@ QString Theme::imageFile(Theme::ImageFile imageFile, const QString &fallBack) co
|
||||
return file.isEmpty() ? fallBack : file;
|
||||
}
|
||||
|
||||
QGradientStops Theme::gradient(Theme::Gradient role) const
|
||||
{
|
||||
return d->gradients[role];
|
||||
}
|
||||
|
||||
QPair<QColor, QString> Theme::readNamedColor(const QString &color) const
|
||||
{
|
||||
if (d->palette.contains(color))
|
||||
@@ -210,26 +204,6 @@ void Theme::readSettings(QSettings &settings)
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
{
|
||||
settings.beginGroup(QLatin1String("Gradients"));
|
||||
QMetaEnum e = m.enumerator(m.indexOfEnumerator("Gradient"));
|
||||
for (int i = 0, total = e.keyCount(); i < total; ++i) {
|
||||
const QString key = QLatin1String(e.key(i));
|
||||
QGradientStops stops;
|
||||
int size = settings.beginReadArray(key);
|
||||
for (int j = 0; j < size; ++j) {
|
||||
settings.setArrayIndex(j);
|
||||
QTC_ASSERT(settings.contains(QLatin1String("pos")), return);
|
||||
const double pos = settings.value(QLatin1String("pos")).toDouble();
|
||||
QTC_ASSERT(settings.contains(QLatin1String("color")), return);
|
||||
const QColor c('#' + settings.value(QLatin1String("color")).toString());
|
||||
stops.append(qMakePair(pos, c));
|
||||
}
|
||||
settings.endArray();
|
||||
d->gradients[i] = stops;
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
{
|
||||
settings.beginGroup(QLatin1String("Flags"));
|
||||
QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag"));
|
||||
|
||||
@@ -418,10 +418,6 @@ public:
|
||||
DSredLight,
|
||||
};
|
||||
|
||||
enum Gradient {
|
||||
DetailsWidgetHeaderGradient,
|
||||
};
|
||||
|
||||
enum ImageFile {
|
||||
IconOverlayCSource,
|
||||
IconOverlayCppHeader,
|
||||
@@ -453,13 +449,11 @@ public:
|
||||
|
||||
Q_ENUM(Color)
|
||||
Q_ENUM(ImageFile)
|
||||
Q_ENUM(Gradient)
|
||||
Q_ENUM(Flag)
|
||||
|
||||
Q_INVOKABLE bool flag(Utils::Theme::Flag f) const;
|
||||
Q_INVOKABLE QColor color(Utils::Theme::Color role) const;
|
||||
QString imageFile(ImageFile imageFile, const QString &fallBack) const;
|
||||
QGradientStops gradient(Gradient role) const;
|
||||
QPalette palette() const;
|
||||
QStringList preferredStyles() const;
|
||||
QString defaultTextEditorColorScheme() const;
|
||||
|
||||
@@ -24,7 +24,6 @@ public:
|
||||
QString defaultTextEditorColorScheme;
|
||||
QVector<QPair<QColor, QString> > colors;
|
||||
QVector<QString> imageFiles;
|
||||
QVector<QGradientStops> gradients;
|
||||
QVector<bool> flags;
|
||||
QMap<QString, QColor> palette;
|
||||
};
|
||||
|
||||
@@ -158,7 +158,7 @@ BuildStepsWidgetData::BuildStepsWidgetData(BuildStep *s) :
|
||||
toolWidget->setBuildStepEnabled(step->enabled());
|
||||
|
||||
detailsWidget->setToolWidget(toolWidget);
|
||||
detailsWidget->setContentsMargins(0, 0, 0, 1);
|
||||
detailsWidget->setContentsMargins(0, 0, 0, 0);
|
||||
detailsWidget->setSummaryText(s->summaryText());
|
||||
}
|
||||
|
||||
@@ -284,7 +284,6 @@ void BuildStepListWidget::setupUi()
|
||||
|
||||
m_vbox = new QVBoxLayout(this);
|
||||
m_vbox->setContentsMargins(0, 0, 0, 0);
|
||||
m_vbox->setSpacing(0);
|
||||
|
||||
m_noStepsLabel = new QLabel(tr("No Build Steps"), this);
|
||||
m_noStepsLabel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user