QCssParser: Remove temporary structure storing QIcon data.
This is no longer needed after QIcon moved to QtGui. It is a
revert of 5a0eb4e768, compile
fixes and uncommenting of commented-out code.
Change-Id: I6cfe6d2582b3e37161862a28e55cc3b010e18a8b
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
bb10
parent
061968d082
commit
33fb856a6d
|
|
@ -42,6 +42,7 @@
|
|||
#include "qcssparser_p.h"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qicon.h>
|
||||
#include <qcolor.h>
|
||||
#include <qfont.h>
|
||||
#include <qfileinfo.h>
|
||||
|
|
@ -1272,7 +1273,7 @@ void ValueExtractor::extractFont()
|
|||
extractFont(&f, &dummy);
|
||||
}
|
||||
|
||||
bool ValueExtractor::extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size)
|
||||
bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
|
||||
{
|
||||
bool hit = false;
|
||||
for (int i = 0; i < declarations.count(); ++i) {
|
||||
|
|
@ -1643,27 +1644,28 @@ void Declaration::borderImageValue(QString *image, int *cuts,
|
|||
*h = *v;
|
||||
}
|
||||
|
||||
IconValue Declaration::iconValue() const
|
||||
QIcon Declaration::iconValue() const
|
||||
{
|
||||
if (d->parsed.isValid())
|
||||
return qvariant_cast<IconValue>(d->parsed);
|
||||
return qvariant_cast<QIcon>(d->parsed);
|
||||
|
||||
IconValue icon;
|
||||
QIcon icon;
|
||||
for (int i = 0; i < d->values.count();) {
|
||||
const Value &value = d->values.at(i++);
|
||||
if (value.type != Value::Uri)
|
||||
break;
|
||||
IconValue::IconEntry entry;
|
||||
entry.uri = value.variant.toString();
|
||||
QString uri = value.variant.toString();
|
||||
QIcon::Mode mode = QIcon::Normal;
|
||||
QIcon::State state = QIcon::Off;
|
||||
for (int j = 0; j < 2; j++) {
|
||||
if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) {
|
||||
switch (d->values.at(i).variant.toInt()) {
|
||||
case Value_Disabled: entry.mode = IconValue::Disabled; break;
|
||||
case Value_Active: entry.mode = IconValue::Active; break;
|
||||
case Value_Selected: entry.mode = IconValue::Selected; break;
|
||||
case Value_Normal: entry.mode = IconValue::Normal; break;
|
||||
case Value_On: entry.state = IconValue::On; break;
|
||||
case Value_Off: entry.state = IconValue::Off; break;
|
||||
case Value_Disabled: mode = QIcon::Disabled; break;
|
||||
case Value_Active: mode = QIcon::Active; break;
|
||||
case Value_Selected: mode = QIcon::Selected; break;
|
||||
case Value_Normal: mode = QIcon::Normal; break;
|
||||
case Value_On: state = QIcon::On; break;
|
||||
case Value_Off: state = QIcon::Off; break;
|
||||
default: break;
|
||||
}
|
||||
++i;
|
||||
|
|
@ -1671,7 +1673,12 @@ IconValue Declaration::iconValue() const
|
|||
break;
|
||||
}
|
||||
}
|
||||
icon.entries.push_back(entry);
|
||||
|
||||
// QIcon is soo broken
|
||||
if (icon.isNull())
|
||||
icon = QIcon(uri);
|
||||
else
|
||||
icon.addPixmap(uri, mode, state);
|
||||
|
||||
if (i == d->values.count())
|
||||
break;
|
||||
|
|
@ -1680,7 +1687,7 @@ IconValue Declaration::iconValue() const
|
|||
i++;
|
||||
}
|
||||
|
||||
d->parsed = QVariant::fromValue<QCss::IconValue>(icon);
|
||||
d->parsed = QVariant::fromValue<QIcon>(icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -411,22 +411,6 @@ struct BorderData {
|
|||
BrushData color;
|
||||
};
|
||||
|
||||
struct Q_GUI_EXPORT IconValue
|
||||
{
|
||||
enum Mode { Normal, Disabled, Active, Selected }; // In sync with QIcon.
|
||||
enum State { On, Off };
|
||||
|
||||
struct Q_GUI_EXPORT IconEntry
|
||||
{
|
||||
IconEntry() : mode(Normal) , state(On) {}
|
||||
|
||||
Mode mode;
|
||||
State state;
|
||||
QString uri;
|
||||
};
|
||||
|
||||
QList<IconEntry> entries;
|
||||
};
|
||||
|
||||
// 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; }
|
||||
// 2. QVector<Selector> - x:hover, y:clicked z:checked
|
||||
|
|
@ -471,7 +455,7 @@ struct Q_GUI_EXPORT Declaration
|
|||
QSize sizeValue() const;
|
||||
QRect rectValue() const;
|
||||
QString uriValue() const;
|
||||
IconValue iconValue() const;
|
||||
QIcon iconValue() const;
|
||||
|
||||
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;
|
||||
};
|
||||
|
|
@ -598,7 +582,7 @@ struct Q_GUI_EXPORT ValueExtractor
|
|||
bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
|
||||
bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
|
||||
int extractStyleFeatures();
|
||||
bool extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size);
|
||||
bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
|
||||
|
||||
int lengthValue(const Declaration &decl);
|
||||
|
||||
|
|
@ -858,7 +842,6 @@ QT_END_NAMESPACE
|
|||
Q_DECLARE_METATYPE( QCss::BackgroundData )
|
||||
Q_DECLARE_METATYPE( QCss::LengthData )
|
||||
Q_DECLARE_METATYPE( QCss::BorderData )
|
||||
Q_DECLARE_METATYPE( QCss::IconValue )
|
||||
|
||||
|
||||
#endif // QT_NO_CSSPARSER
|
||||
|
|
|
|||
|
|
@ -860,19 +860,6 @@ static QStyle::StandardPixmap subControlIcon(int pe)
|
|||
return QStyle::SP_CustomBase;
|
||||
}
|
||||
|
||||
static inline QIcon cssIconValueToIcon(const QCss::IconValue &iconValue)
|
||||
{
|
||||
if (iconValue.entries.isEmpty())
|
||||
return QIcon();
|
||||
QIcon icon = QIcon(iconValue.entries.first().uri);
|
||||
for (int i = 1; i < iconValue.entries.size(); ++i) {
|
||||
const QCss::IconValue::IconEntry &entry = iconValue.entries.at(i);
|
||||
icon.addPixmap(entry.uri, static_cast<QIcon::Mode>(entry.mode),
|
||||
static_cast<QIcon::State>(entry.state));
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget *widget)
|
||||
: features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0)
|
||||
{
|
||||
|
|
@ -932,11 +919,11 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget
|
|||
if (v.extractPalette(&fg, &sfg, &sbg, &abg))
|
||||
pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
|
||||
|
||||
QIcon icon;
|
||||
alignment = Qt::AlignCenter;
|
||||
QSize size;
|
||||
QCss::IconValue iconValue;
|
||||
if (v.extractImage(&iconValue, &alignment, &size))
|
||||
img = new QStyleSheetImageData(cssIconValueToIcon(iconValue), alignment, size);
|
||||
if (v.extractImage(&icon, &alignment, &size))
|
||||
img = new QStyleSheetImageData(icon, alignment, size);
|
||||
|
||||
int adj = -255;
|
||||
hasFont = v.extractFont(&font, &adj);
|
||||
|
|
@ -992,7 +979,7 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget
|
|||
} else if (hintName.endsWith(QLatin1String("size"))) {
|
||||
hintValue = decl.sizeValue();
|
||||
} else if (hintName.endsWith(QLatin1String("icon"))) {
|
||||
hintValue = cssIconValueToIcon(decl.iconValue());
|
||||
hintValue = decl.iconValue();
|
||||
} else if (hintName == QLatin1String("button-layout")
|
||||
&& decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) {
|
||||
hintValue = subControlLayout(decl.d->values.at(0).variant.toString());
|
||||
|
|
@ -2538,7 +2525,7 @@ void QStyleSheetStyle::setProperties(QWidget *w)
|
|||
QVariant v;
|
||||
const QVariant value = w->property(property.toLatin1());
|
||||
switch (value.type()) {
|
||||
case QVariant::Icon: v = cssIconValueToIcon(decl.iconValue()); break;
|
||||
case QVariant::Icon: v = decl.iconValue(); break;
|
||||
case QVariant::Image: v = QImage(decl.uriValue()); break;
|
||||
case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
|
||||
case QVariant::Rect: v = decl.rectValue(); break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue