mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
drop support for QConicalGradient [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
230dc75475
commit
2a81a8a477
42 changed files with 182 additions and 1097 deletions
|
@ -584,7 +584,6 @@ katie_generate_obsolete(QCharRef QtCore qstring.h)
|
|||
katie_generate_obsolete(QChildEvent QtCore qcoreevent.h)
|
||||
katie_generate_obsolete(QClipboardEvent QtGui qevent.h)
|
||||
katie_generate_obsolete(QCloseEvent QtGui qevent.h)
|
||||
katie_generate_obsolete(QConicalGradient QtGui qbrush.h)
|
||||
katie_generate_obsolete(QContextMenuEvent QtGui qevent.h)
|
||||
katie_generate_obsolete(QContiguousCacheData QtCore qcontiguouscache.h)
|
||||
katie_generate_obsolete(QContiguousCacheTypedData QtCore qcontiguouscache.h)
|
||||
|
|
|
@ -637,7 +637,6 @@ include/katie/QtGui/QComboBox
|
|||
include/katie/QtGui/QCommandLinkButton
|
||||
include/katie/QtGui/QCommonStyle
|
||||
include/katie/QtGui/QCompleter
|
||||
include/katie/QtGui/QConicalGradient
|
||||
include/katie/QtGui/QContextMenuEvent
|
||||
include/katie/QtGui/QCursor
|
||||
include/katie/QtGui/QDataWidgetMapper
|
||||
|
|
|
@ -640,7 +640,6 @@ include/katie/QtGui/QComboBox
|
|||
include/katie/QtGui/QCommandLinkButton
|
||||
include/katie/QtGui/QCommonStyle
|
||||
include/katie/QtGui/QCompleter
|
||||
include/katie/QtGui/QConicalGradient
|
||||
include/katie/QtGui/QContextMenuEvent
|
||||
include/katie/QtGui/QCursor
|
||||
include/katie/QtGui/QDataWidgetMapper
|
||||
|
|
|
@ -645,7 +645,6 @@ include/katie/QtGui/QComboBox
|
|||
include/katie/QtGui/QCommandLinkButton
|
||||
include/katie/QtGui/QCommonStyle
|
||||
include/katie/QtGui/QCompleter
|
||||
include/katie/QtGui/QConicalGradient
|
||||
include/katie/QtGui/QContextMenuEvent
|
||||
include/katie/QtGui/QCursor
|
||||
include/katie/QtGui/QDataWidgetMapper
|
||||
|
|
|
@ -194,7 +194,6 @@ incmap = {
|
|||
'QBrushData': 'qbrush.h',
|
||||
'QClipboardEvent': 'qevent.h',
|
||||
'QCloseEvent': 'qevent.h',
|
||||
'QConicalGradient': 'qbrush.h',
|
||||
'QContextMenuEvent': 'qevent.h',
|
||||
'QDateEdit': 'qdatetimeedit.h',
|
||||
'QDoubleSpinBox': 'qspinbox.h',
|
||||
|
|
|
@ -95,7 +95,6 @@ classlist = [
|
|||
"QCommandLinkButton",
|
||||
"QCommonStyle",
|
||||
"QCompleter",
|
||||
"QConicalGradient",
|
||||
"QContextMenuEvent",
|
||||
"QContiguousCache",
|
||||
"QContiguousCacheData",
|
||||
|
|
|
@ -935,7 +935,6 @@ public:
|
|||
DiagCrossPattern,
|
||||
LinearGradientPattern,
|
||||
RadialGradientPattern,
|
||||
ConicalGradientPattern,
|
||||
TexturePattern
|
||||
};
|
||||
|
||||
|
|
|
@ -324,7 +324,6 @@
|
|||
\value FDiagPattern Forward diagonal lines.
|
||||
\value DiagCrossPattern Crossing diagonal lines.
|
||||
\value LinearGradientPattern Linear gradient (set using a dedicated QBrush constructor).
|
||||
\value ConicalGradientPattern Conical gradient (set using a dedicated QBrush constructor).
|
||||
\value RadialGradientPattern Radial gradient (set using a dedicated QBrush constructor).
|
||||
\value TexturePattern Custom pattern (see QBrush::setTexture()).
|
||||
|
||||
|
|
|
@ -554,9 +554,7 @@ void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt,
|
|||
option.font.setBold(true);
|
||||
}
|
||||
QBrush br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
|
||||
if (br.style() == Qt::LinearGradientPattern ||
|
||||
br.style() == Qt::RadialGradientPattern ||
|
||||
br.style() == Qt::ConicalGradientPattern) {
|
||||
if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern) {
|
||||
painter->save();
|
||||
painter->translate(option.rect.x(), option.rect.y());
|
||||
painter->scale(option.rect.width(), option.rect.height());
|
||||
|
|
|
@ -295,7 +295,6 @@
|
|||
<xs:attribute name="focalx" type="xs:double" use="required" />
|
||||
<xs:attribute name="focaly" type="xs:double" use="required" />
|
||||
<xs:attribute name="radius" type="xs:double" use="required" />
|
||||
<xs:attribute name="angle" type="xs:double" use="required" />
|
||||
<xs:attribute name="type" type="xs:string" use="required" />
|
||||
<xs:attribute name="spread" type="xs:string" use="required" />
|
||||
<xs:attribute name="coordinatemode" type="xs:string" use="required" />
|
||||
|
|
|
@ -9,28 +9,6 @@
|
|||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Czech" >
|
||||
<gradientData centerX="0.5" centerY="0.5" spread="RepeatSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.373978669201521" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.3739913434727503" >
|
||||
<colorData g="30" r="33" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6240176679340937" >
|
||||
<colorData g="30" r="33" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6240430164765525" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Dutch" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="0" endY="1" >
|
||||
<stopData position="0" >
|
||||
|
@ -181,55 +159,6 @@
|
|||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Golden" >
|
||||
<gradientData centerX="0.5" centerY="0.5" spread="PadSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="40" r="35" a="255" b="3" />
|
||||
</stopData>
|
||||
<stopData position="0.16" >
|
||||
<colorData g="106" r="136" a="255" b="22" />
|
||||
</stopData>
|
||||
<stopData position="0.225" >
|
||||
<colorData g="140" r="166" a="255" b="41" />
|
||||
</stopData>
|
||||
<stopData position="0.285" >
|
||||
<colorData g="181" r="204" a="255" b="74" />
|
||||
</stopData>
|
||||
<stopData position="0.345" >
|
||||
<colorData g="219" r="235" a="255" b="102" />
|
||||
</stopData>
|
||||
<stopData position="0.415" >
|
||||
<colorData g="236" r="245" a="255" b="112" />
|
||||
</stopData>
|
||||
<stopData position="0.52" >
|
||||
<colorData g="190" r="209" a="255" b="76" />
|
||||
</stopData>
|
||||
<stopData position="0.57" >
|
||||
<colorData g="156" r="187" a="255" b="51" />
|
||||
</stopData>
|
||||
<stopData position="0.635" >
|
||||
<colorData g="142" r="168" a="255" b="42" />
|
||||
</stopData>
|
||||
<stopData position="0.695" >
|
||||
<colorData g="174" r="202" a="255" b="68" />
|
||||
</stopData>
|
||||
<stopData position="0.75" >
|
||||
<colorData g="202" r="218" a="255" b="86" />
|
||||
</stopData>
|
||||
<stopData position="0.8149999999999999" >
|
||||
<colorData g="187" r="208" a="255" b="73" />
|
||||
</stopData>
|
||||
<stopData position="0.88" >
|
||||
<colorData g="156" r="187" a="255" b="51" />
|
||||
</stopData>
|
||||
<stopData position="0.9350000000000001" >
|
||||
<colorData g="108" r="137" a="255" b="26" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="40" r="35" a="255" b="3" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Japanese" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
|
@ -398,40 +327,6 @@
|
|||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="SunRay" >
|
||||
<gradientData centerX="0" centerY="0" spread="RepeatSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="135" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.375" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4235329090018885" >
|
||||
<colorData g="255" r="251" a="145" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.45" >
|
||||
<colorData g="255" r="247" a="208" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4775811200061043" >
|
||||
<colorData g="244" r="255" a="130" b="71" />
|
||||
</stopData>
|
||||
<stopData position="0.5187165775401069" >
|
||||
<colorData g="218" r="255" a="130" b="71" />
|
||||
</stopData>
|
||||
<stopData position="0.55" >
|
||||
<colorData g="255" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5775401069518716" >
|
||||
<colorData g="203" r="255" a="130" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.625" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Tropical" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
|
|
|
@ -170,12 +170,11 @@ struct QGradientBrushData : public QBrushData
|
|||
respectively.
|
||||
|
||||
The gradient() defines the gradient fill used when the current
|
||||
style is either Qt::LinearGradientPattern,
|
||||
Qt::RadialGradientPattern or Qt::ConicalGradientPattern. Gradient
|
||||
brushes are created by giving a QGradient as a constructor
|
||||
argument when creating the QBrush. Qt provides three different
|
||||
gradients: QLinearGradient, QConicalGradient, and QRadialGradient
|
||||
- all of which inherit QGradient.
|
||||
style is either Qt::LinearGradientPattern or
|
||||
Qt::RadialGradientPattern. Gradient brushes are created by
|
||||
giving a QGradient as a constructor argument when creating the
|
||||
QBrush. Qt provides three different gradients: QLinearGradient
|
||||
and QRadialGradient - all of which inherit QGradient.
|
||||
|
||||
\snippet doc/src/snippets/brush/gradientcreationsnippet.cpp 0
|
||||
|
||||
|
@ -224,16 +223,18 @@ struct QGradientBrushData : public QBrushData
|
|||
|
||||
static bool qbrush_check_type(Qt::BrushStyle style) {
|
||||
switch (style) {
|
||||
case Qt::TexturePattern:
|
||||
qWarning("QBrush: Incorrect use of TexturePattern");
|
||||
break;
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
qWarning("QBrush: Wrong use of a gradient pattern");
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
case Qt::TexturePattern: {
|
||||
qWarning("QBrush: Incorrect use of TexturePattern");
|
||||
break;
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern: {
|
||||
qWarning("QBrush: Wrong use of a gradient pattern");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -249,21 +250,24 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
|
|||
// Q_ASSERT(!d);
|
||||
|
||||
switch(style) {
|
||||
case Qt::NoBrush:
|
||||
d = new QBrushData();
|
||||
if (d->color != color) setColor(color);
|
||||
return;
|
||||
case Qt::TexturePattern:
|
||||
d = new QTexturedBrushData();
|
||||
break;
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
d = new QGradientBrushData();
|
||||
break;
|
||||
default:
|
||||
d = new QBrushData();
|
||||
break;
|
||||
case Qt::NoBrush: {
|
||||
d = new QBrushData();
|
||||
if (d->color != color) setColor(color);
|
||||
return;
|
||||
}
|
||||
case Qt::TexturePattern: {
|
||||
d = new QTexturedBrushData();
|
||||
break;
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern: {
|
||||
d = new QGradientBrushData();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
d = new QBrushData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
d->style = style;
|
||||
d->color = color;
|
||||
|
@ -396,19 +400,17 @@ QBrush::QBrush(const QBrush &other)
|
|||
Constructs a brush based on the given \a gradient.
|
||||
|
||||
The brush style is set to the corresponding gradient style (either
|
||||
Qt::LinearGradientPattern, Qt::RadialGradientPattern or
|
||||
Qt::ConicalGradientPattern).
|
||||
Qt::LinearGradientPattern or Qt::RadialGradientPattern).
|
||||
*/
|
||||
QBrush::QBrush(const QGradient &gradient)
|
||||
{
|
||||
Q_ASSERT_X(gradient.type() != QGradient::NoGradient, "QBrush::QBrush",
|
||||
"QGradient should not be used directly, use the linear, radial\n"
|
||||
"or conical gradients instead");
|
||||
"QGradient should not be used directly, use the linear or radial\n"
|
||||
"gradients instead");
|
||||
|
||||
static const Qt::BrushStyle enumTbl[] = {
|
||||
Qt::LinearGradientPattern,
|
||||
Qt::RadialGradientPattern,
|
||||
Qt::ConicalGradientPattern
|
||||
Qt::RadialGradientPattern
|
||||
};
|
||||
|
||||
init(QColor(), enumTbl[gradient.type()]);
|
||||
|
@ -424,16 +426,19 @@ QBrush::~QBrush()
|
|||
{
|
||||
if (d && !d->ref.deref()) {
|
||||
switch (d->style) {
|
||||
case Qt::TexturePattern:
|
||||
case Qt::TexturePattern: {
|
||||
delete static_cast<QTexturedBrushData*>(d);
|
||||
break;
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
case Qt::RadialGradientPattern: {
|
||||
delete static_cast<QGradientBrushData*>(d);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
delete d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,28 +450,29 @@ void QBrush::detach(Qt::BrushStyle newStyle)
|
|||
|
||||
QScopedPointer<QBrushData> x;
|
||||
switch(newStyle) {
|
||||
case Qt::TexturePattern: {
|
||||
QTexturedBrushData *tbd = new QTexturedBrushData;
|
||||
if (d->style == Qt::TexturePattern) {
|
||||
QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
|
||||
if (data->m_has_pixmap_texture)
|
||||
tbd->setPixmap(data->pixmap());
|
||||
else
|
||||
tbd->setImage(data->image());
|
||||
case Qt::TexturePattern: {
|
||||
QTexturedBrushData *tbd = new QTexturedBrushData;
|
||||
if (d->style == Qt::TexturePattern) {
|
||||
QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
|
||||
if (data->m_has_pixmap_texture)
|
||||
tbd->setPixmap(data->pixmap());
|
||||
else
|
||||
tbd->setImage(data->image());
|
||||
}
|
||||
x.reset(tbd);
|
||||
break;
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern: {
|
||||
x.reset(new QGradientBrushData);
|
||||
static_cast<QGradientBrushData *>(x.data())->gradient =
|
||||
static_cast<QGradientBrushData *>(d)->gradient;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
x.reset(new QBrushData());
|
||||
break;
|
||||
}
|
||||
x.reset(tbd);
|
||||
break;
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
x.reset(new QGradientBrushData);
|
||||
static_cast<QGradientBrushData *>(x.data())->gradient =
|
||||
static_cast<QGradientBrushData *>(d)->gradient;
|
||||
break;
|
||||
default:
|
||||
x.reset(new QBrushData());
|
||||
break;
|
||||
}
|
||||
x->style = newStyle;
|
||||
x->color = d->color;
|
||||
|
@ -659,8 +665,7 @@ void QBrush::setTextureImage(const QImage &image)
|
|||
const QGradient *QBrush::gradient() const
|
||||
{
|
||||
if (d->style == Qt::LinearGradientPattern
|
||||
|| d->style == Qt::RadialGradientPattern
|
||||
|| d->style == Qt::ConicalGradientPattern) {
|
||||
|| d->style == Qt::RadialGradientPattern) {
|
||||
return &static_cast<const QGradientBrushData *>(d)->gradient;
|
||||
}
|
||||
return 0;
|
||||
|
@ -695,8 +700,7 @@ bool QBrush::isOpaque() const
|
|||
}
|
||||
|
||||
if (d->style == Qt::LinearGradientPattern
|
||||
|| d->style == Qt::RadialGradientPattern
|
||||
|| d->style == Qt::ConicalGradientPattern) {
|
||||
|| d->style == Qt::RadialGradientPattern) {
|
||||
foreach (const QGradientStop &stop, gradient()->stops()) {
|
||||
if (stop.second.alpha() != 255)
|
||||
return false;
|
||||
|
@ -783,22 +787,20 @@ bool QBrush::operator==(const QBrush &other) const
|
|||
if (other.d->style != d->style || other.d->color != d->color || other.d->transform != d->transform)
|
||||
return false;
|
||||
switch (d->style) {
|
||||
case Qt::TexturePattern:
|
||||
{
|
||||
case Qt::TexturePattern: {
|
||||
const QPixmap &us = (static_cast<QTexturedBrushData *>(d))->pixmap();
|
||||
const QPixmap &them = (static_cast<QTexturedBrushData *>(other.d))->pixmap();
|
||||
return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey());
|
||||
}
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
{
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern: {
|
||||
const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d);
|
||||
const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(other.d);
|
||||
return d1->gradient == d2->gradient;
|
||||
}
|
||||
default:
|
||||
return true;
|
||||
default: {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -835,7 +837,6 @@ QDebug operator<<(QDebug dbg, const QBrush &b)
|
|||
"DiagCrossPattern",
|
||||
"LinearGradientPattern",
|
||||
"RadialGradientPattern",
|
||||
"ConicalGradientPattern",
|
||||
"TexturePattern"
|
||||
};
|
||||
|
||||
|
@ -870,8 +871,7 @@ QDataStream &operator<<(QDataStream &s, const QBrush &b)
|
|||
s << style << b.color();
|
||||
if (b.style() == Qt::TexturePattern) {
|
||||
s << b.texture();
|
||||
} else if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern
|
||||
|| style == Qt::ConicalGradientPattern) {
|
||||
} else if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern) {
|
||||
const QGradient *gradient = b.gradient();
|
||||
int type_as_int = int(gradient->type());
|
||||
s << type_as_int;
|
||||
|
@ -894,16 +894,18 @@ QDataStream &operator<<(QDataStream &s, const QBrush &b)
|
|||
s << gradient->stops();
|
||||
#endif
|
||||
|
||||
if (gradient->type() == QGradient::LinearGradient) {
|
||||
s << static_cast<const QLinearGradient *>(gradient)->start();
|
||||
s << static_cast<const QLinearGradient *>(gradient)->finalStop();
|
||||
} else if (gradient->type() == QGradient::RadialGradient) {
|
||||
s << static_cast<const QRadialGradient *>(gradient)->center();
|
||||
s << static_cast<const QRadialGradient *>(gradient)->focalPoint();
|
||||
s << (double) static_cast<const QRadialGradient *>(gradient)->radius();
|
||||
} else { // type == Conical
|
||||
s << static_cast<const QConicalGradient *>(gradient)->center();
|
||||
s << (double) static_cast<const QConicalGradient *>(gradient)->angle();
|
||||
switch (gradient->type()) {
|
||||
case QGradient::LinearGradient: {
|
||||
s << static_cast<const QLinearGradient *>(gradient)->start();
|
||||
s << static_cast<const QLinearGradient *>(gradient)->finalStop();
|
||||
break;
|
||||
}
|
||||
case QGradient::RadialGradient: {
|
||||
s << static_cast<const QRadialGradient *>(gradient)->center();
|
||||
s << static_cast<const QRadialGradient *>(gradient)->focalPoint();
|
||||
s << (double) static_cast<const QRadialGradient *>(gradient)->radius();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
s << b.transform();
|
||||
|
@ -931,8 +933,7 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
|
|||
s >> pm;
|
||||
b = QBrush(color, pm);
|
||||
} else if (style == Qt::LinearGradientPattern
|
||||
|| style == Qt::RadialGradientPattern
|
||||
|| style == Qt::ConicalGradientPattern) {
|
||||
|| style == Qt::RadialGradientPattern) {
|
||||
|
||||
int type_as_int;
|
||||
QGradient::Type type;
|
||||
|
@ -987,17 +988,6 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
|
|||
rg.setCoordinateMode(cmode);
|
||||
rg.setInterpolationMode(imode);
|
||||
b = QBrush(rg);
|
||||
} else { // type == QGradient::ConicalGradient
|
||||
QPointF center;
|
||||
double angle;
|
||||
s >> center;
|
||||
s >> angle;
|
||||
QConicalGradient cg(center, angle);
|
||||
cg.setStops(stops);
|
||||
cg.setSpread(spread);
|
||||
cg.setCoordinateMode(cmode);
|
||||
cg.setInterpolationMode(imode);
|
||||
b = QBrush(cg);
|
||||
}
|
||||
} else {
|
||||
b = QBrush(color, (Qt::BrushStyle)style);
|
||||
|
@ -1030,7 +1020,6 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
|
|||
and end points on a circle surrounding it.
|
||||
\o \e Extended radial gradients interpolate colors between a center and
|
||||
a focal circle.
|
||||
\o \e Conical gradients interpolate colors around a center point.
|
||||
\endlist
|
||||
|
||||
A gradient's type can be retrieved using the type() function.
|
||||
|
@ -1040,11 +1029,9 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
|
|||
\header
|
||||
\o QLinearGradient
|
||||
\o QRadialGradient
|
||||
\o QConicalGradient
|
||||
\row
|
||||
\o \inlineimage qgradient-linear.png
|
||||
\o \inlineimage qgradient-radial.png
|
||||
\o \inlineimage qgradient-conical.png
|
||||
\endtable
|
||||
|
||||
The colors in a gradient are defined using stop points of the
|
||||
|
@ -1088,13 +1075,6 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
|
|||
\o \l {QGradient::ReflectSpread}{ReflectSpread}
|
||||
\endtable
|
||||
|
||||
Note that the setSpread() function only has effect for linear and
|
||||
radial gradients. The reason is that the conical gradient is
|
||||
closed by definition, i.e. the \e conical gradient fills the
|
||||
entire circle from 0 - 360 degrees, while the boundary of a radial
|
||||
or a linear gradient can be specified through its radius or final
|
||||
stop points, respectively.
|
||||
|
||||
The gradient coordinates can be specified in logical coordinates,
|
||||
relative to device coordinates, or relative to object bounding box coordinates.
|
||||
The \l {QGradient::CoordinateMode}{coordinate mode} can be set using the
|
||||
|
@ -1128,7 +1108,6 @@ QGradient::QGradient()
|
|||
\value RadialGradient Interpolate colors between a focal point and end
|
||||
points on a circle surrounding it (QRadialGradient).
|
||||
|
||||
\value ConicalGradient Interpolate colors around a center point (QConicalGradient).
|
||||
\value NoGradient No gradient is used.
|
||||
|
||||
\sa type()
|
||||
|
@ -1350,11 +1329,6 @@ bool QGradient::operator==(const QGradient &gradient) const
|
|||
|| m_data.radial.fy != gradient.m_data.radial.fy
|
||||
|| m_data.radial.cradius != gradient.m_data.radial.cradius)
|
||||
return false;
|
||||
} else { // m_type == ConicalGradient
|
||||
if (m_data.conical.cx != gradient.m_data.conical.cx
|
||||
|| m_data.conical.cy != gradient.m_data.conical.cy
|
||||
|| m_data.conical.angle != gradient.m_data.conical.angle)
|
||||
return false;
|
||||
}
|
||||
|
||||
return stops() == gradient.stops();
|
||||
|
@ -1396,8 +1370,7 @@ bool QGradient::operator==(const QGradient &gradient) const
|
|||
returns the final stop point of the gradient, and the start()
|
||||
function returning the start point of the gradient.
|
||||
|
||||
\sa QRadialGradient, QConicalGradient, {demos/gradients}{The
|
||||
Gradients Demo}
|
||||
\sa QRadialGradient, {demos/gradients}{The Gradients Demo}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1577,8 +1550,7 @@ void QLinearGradient::setFinalStop(const QPointF &stop)
|
|||
radius() functions returning the gradient's center, focal point
|
||||
and radius respectively.
|
||||
|
||||
\sa QLinearGradient, QConicalGradient, {demos/gradients}{The
|
||||
Gradients Demo}
|
||||
\sa QLinearGradient, {demos/gradients}{The Gradients Demo}
|
||||
*/
|
||||
|
||||
static QPointF qt_radial_gradient_adapt_focal_point(const QPointF ¢er,
|
||||
|
@ -1893,161 +1865,6 @@ void QRadialGradient::setFocalPoint(const QPointF &focalPoint)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\class QConicalGradient
|
||||
\ingroup painting
|
||||
|
||||
\brief The QConicalGradient class is used in combination with QBrush to
|
||||
specify a conical gradient brush.
|
||||
|
||||
Conical gradients interpolate interpolate colors counter-clockwise
|
||||
around a center point.
|
||||
|
||||
\image qconicalgradient.png
|
||||
|
||||
The colors in a gradient is defined using stop points of the
|
||||
QGradientStop type, i.e. a position and a color. Use the
|
||||
QGradient::setColorAt() or the QGradient::setStops() function to
|
||||
define the stop points. It is the gradient's complete set of stop
|
||||
points that describes how the gradient area should be filled. If
|
||||
no stop points have been specified, a gradient of black at 0 to
|
||||
white at 1 is used.
|
||||
|
||||
In addition to the functions inherited from QGradient, the
|
||||
QConicalGradient class provides the angle() and center() functions
|
||||
returning the start angle and center of the gradient.
|
||||
|
||||
Note that the setSpread() function has no effect for conical
|
||||
gradients. The reason is that the conical gradient is closed by
|
||||
definition, i.e. the conical gradient fills the entire circle from
|
||||
0 - 360 degrees, while the boundary of a radial or a linear
|
||||
gradient can be specified through its radius or final stop points,
|
||||
respectively.
|
||||
|
||||
\sa QLinearGradient, QRadialGradient, {demos/gradients}{The
|
||||
Gradients Demo}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a conical gradient with the given \a center, starting
|
||||
the interpolation at the given \a angle. The \a angle must be
|
||||
specified in degrees between 0 and 360.
|
||||
|
||||
\sa QGradient::setColorAt(), QGradient::setStops()
|
||||
*/
|
||||
|
||||
QConicalGradient::QConicalGradient(const QPointF ¢er, qreal angle)
|
||||
{
|
||||
m_type = ConicalGradient;
|
||||
m_data.conical.cx = center.x();
|
||||
m_data.conical.cy = center.y();
|
||||
m_data.conical.angle = angle;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a conical gradient with the given center (\a cx, \a
|
||||
cy), starting the interpolation at the given \a angle. The angle
|
||||
must be specified in degrees between 0 and 360.
|
||||
|
||||
\sa QGradient::setColorAt(), QGradient::setStops()
|
||||
*/
|
||||
|
||||
QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle)
|
||||
{
|
||||
m_type = ConicalGradient;
|
||||
m_data.conical.cx = cx;
|
||||
m_data.conical.cy = cy;
|
||||
m_data.conical.angle = angle;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a conical with center at (0, 0) starting the
|
||||
interpolation at angle 0.
|
||||
|
||||
\sa QGradient::setColorAt(), setCenter(), setAngle()
|
||||
*/
|
||||
|
||||
QConicalGradient::QConicalGradient()
|
||||
{
|
||||
m_type = ConicalGradient;
|
||||
m_data.conical.cx = 0;
|
||||
m_data.conical.cy = 0;
|
||||
m_data.conical.angle = 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the center of the conical gradient in logical
|
||||
coordinates.
|
||||
|
||||
\sa stops()
|
||||
*/
|
||||
|
||||
QPointF QConicalGradient::center() const
|
||||
{
|
||||
Q_ASSERT(m_type == ConicalGradient);
|
||||
return QPointF(m_data.conical.cx, m_data.conical.cy);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QConicalGradient::setCenter(qreal x, qreal y)
|
||||
|
||||
\overload
|
||||
|
||||
Sets the center of this conical gradient in logical coordinates to
|
||||
(\a x, \a y).
|
||||
|
||||
\sa center()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Sets the center of this conical gradient in logical coordinates to
|
||||
\a center.
|
||||
|
||||
\sa center()
|
||||
*/
|
||||
|
||||
void QConicalGradient::setCenter(const QPointF ¢er)
|
||||
{
|
||||
Q_ASSERT(m_type == ConicalGradient);
|
||||
m_data.conical.cx = center.x();
|
||||
m_data.conical.cy = center.y();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the start angle of the conical gradient in logical
|
||||
coordinates.
|
||||
|
||||
\sa stops()
|
||||
*/
|
||||
|
||||
qreal QConicalGradient::angle() const
|
||||
{
|
||||
Q_ASSERT(m_type == ConicalGradient);
|
||||
return m_data.conical.angle;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Sets \a angle to be the start angle for this conical gradient in
|
||||
logical coordinates.
|
||||
|
||||
\sa angle()
|
||||
*/
|
||||
|
||||
void QConicalGradient::setAngle(qreal angle)
|
||||
{
|
||||
Q_ASSERT(m_type == ConicalGradient);
|
||||
m_data.conical.angle = angle;
|
||||
}
|
||||
|
||||
/*!
|
||||
\typedef QGradientStop
|
||||
\relates QGradient
|
||||
|
|
|
@ -136,7 +136,6 @@ public:
|
|||
enum Type {
|
||||
LinearGradient,
|
||||
RadialGradient,
|
||||
ConicalGradient,
|
||||
NoGradient
|
||||
};
|
||||
|
||||
|
@ -182,7 +181,6 @@ public:
|
|||
private:
|
||||
friend class QLinearGradient;
|
||||
friend class QRadialGradient;
|
||||
friend class QConicalGradient;
|
||||
friend class QBrush;
|
||||
|
||||
Type m_type;
|
||||
|
@ -198,9 +196,6 @@ private:
|
|||
struct {
|
||||
qreal cx, cy, fx, fy, cradius;
|
||||
} radial;
|
||||
struct {
|
||||
qreal cx, cy, angle;
|
||||
} conical;
|
||||
} m_data;
|
||||
};
|
||||
|
||||
|
@ -255,23 +250,6 @@ public:
|
|||
void setFocalRadius(qreal radius);
|
||||
};
|
||||
|
||||
|
||||
class Q_GUI_EXPORT QConicalGradient : public QGradient
|
||||
{
|
||||
public:
|
||||
QConicalGradient();
|
||||
QConicalGradient(const QPointF ¢er, qreal startAngle);
|
||||
QConicalGradient(qreal cx, qreal cy, qreal startAngle);
|
||||
|
||||
QPointF center() const;
|
||||
void setCenter(const QPointF ¢er);
|
||||
inline void setCenter(qreal x, qreal y) { setCenter(QPointF(x, y)); }
|
||||
|
||||
qreal angle() const;
|
||||
void setAngle(qreal angle);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // QBRUSH_H
|
||||
|
|
|
@ -1039,53 +1039,6 @@ static const uint * QT_FASTCALL qt_fetch_radial_gradient(uint *buffer, const Ope
|
|||
return b;
|
||||
}
|
||||
|
||||
static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Operator *, const QSpanData *data,
|
||||
int y, int x, int length)
|
||||
{
|
||||
const uint *b = buffer;
|
||||
qreal rx = data->m21 * (y + qreal(0.5))
|
||||
+ data->dx + data->m11 * (x + qreal(0.5));
|
||||
qreal ry = data->m22 * (y + qreal(0.5))
|
||||
+ data->dy + data->m12 * (x + qreal(0.5));
|
||||
bool affine = !data->m13 && !data->m23;
|
||||
|
||||
const uint *end = buffer + length;
|
||||
if (affine) {
|
||||
rx -= data->gradient.conical.center.x;
|
||||
ry -= data->gradient.conical.center.y;
|
||||
while (buffer < end) {
|
||||
qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle;
|
||||
|
||||
*buffer = qt_gradient_pixel(&data->gradient, 1 - angle / (2*M_PI));
|
||||
|
||||
rx += data->m11;
|
||||
ry += data->m12;
|
||||
++buffer;
|
||||
}
|
||||
} else {
|
||||
qreal rw = data->m23 * (y + qreal(0.5))
|
||||
+ data->m33 + data->m13 * (x + qreal(0.5));
|
||||
if (!rw)
|
||||
rw = 1;
|
||||
while (buffer < end) {
|
||||
qreal angle = qAtan2(ry/rw - data->gradient.conical.center.x,
|
||||
rx/rw - data->gradient.conical.center.y)
|
||||
+ data->gradient.conical.angle;
|
||||
|
||||
*buffer = qt_gradient_pixel(&data->gradient, 1. - angle / (2*M_PI));
|
||||
|
||||
rx += data->m11;
|
||||
ry += data->m12;
|
||||
rw += data->m13;
|
||||
if (!rw) {
|
||||
rw += data->m13;
|
||||
}
|
||||
++buffer;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/* The constant alpha factor describes an alpha factor that gets applied
|
||||
to the result of the composition operation combining it with the destination.
|
||||
|
||||
|
@ -2594,10 +2547,6 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in
|
|||
getRadialGradientValues(&op.radial, data);
|
||||
op.src_fetch = qt_fetch_radial_gradient;
|
||||
break;
|
||||
case QSpanData::ConicalGradient:
|
||||
solidSource = !data->gradient.alphaColor;
|
||||
op.src_fetch = qt_fetch_conical_gradient;
|
||||
break;
|
||||
case QSpanData::Texture:
|
||||
solidSource = !data->texture.hasAlpha;
|
||||
op.src_fetch = sourceFetch[getBlendType(data)][data->texture.format];
|
||||
|
|
|
@ -160,15 +160,6 @@ struct QRadialGradientData
|
|||
} focal;
|
||||
};
|
||||
|
||||
struct QConicalGradientData
|
||||
{
|
||||
struct {
|
||||
qreal x;
|
||||
qreal y;
|
||||
} center;
|
||||
qreal angle;
|
||||
};
|
||||
|
||||
struct QGradientData
|
||||
{
|
||||
QGradient::Spread spread;
|
||||
|
@ -176,7 +167,6 @@ struct QGradientData
|
|||
union {
|
||||
QLinearGradientData linear;
|
||||
QRadialGradientData radial;
|
||||
QConicalGradientData conical;
|
||||
};
|
||||
|
||||
#define GRADIENT_STOPTABLE_SIZE 1024
|
||||
|
@ -232,7 +222,6 @@ public:
|
|||
Solid,
|
||||
LinearGradient,
|
||||
RadialGradient,
|
||||
ConicalGradient,
|
||||
Texture
|
||||
} type;
|
||||
QTransform::TransformationType txop;
|
||||
|
|
|
@ -3203,20 +3203,19 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
|
|||
{
|
||||
Qt::BrushStyle brushStyle = brush.style();
|
||||
switch (brushStyle) {
|
||||
case Qt::SolidPattern: {
|
||||
type = Solid;
|
||||
const QColor c = brush.color();
|
||||
const QRgb rgba = c.rgba();
|
||||
solid.color = PREMUL(ARGB_COMBINE_ALPHA(rgba, alpha));
|
||||
if ((solid.color & 0xff000000) == 0
|
||||
&& compositionMode == QPainter::CompositionMode_SourceOver) {
|
||||
type = None;
|
||||
case Qt::SolidPattern: {
|
||||
type = Solid;
|
||||
const QColor c = brush.color();
|
||||
const QRgb rgba = c.rgba();
|
||||
solid.color = PREMUL(ARGB_COMBINE_ALPHA(rgba, alpha));
|
||||
if ((solid.color & 0xff000000) == 0
|
||||
&& compositionMode == QPainter::CompositionMode_SourceOver) {
|
||||
type = None;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::LinearGradientPattern:
|
||||
{
|
||||
case Qt::LinearGradientPattern: {
|
||||
type = LinearGradient;
|
||||
const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient());
|
||||
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
|
||||
|
@ -3232,8 +3231,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
|
|||
break;
|
||||
}
|
||||
|
||||
case Qt::RadialGradientPattern:
|
||||
{
|
||||
case Qt::RadialGradientPattern: {
|
||||
type = RadialGradient;
|
||||
const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient());
|
||||
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
|
||||
|
@ -3250,60 +3248,47 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
|
|||
radialData.focal.x = focal.x();
|
||||
radialData.focal.y = focal.y();
|
||||
radialData.focal.radius = g->focalRadius();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::ConicalGradientPattern:
|
||||
{
|
||||
type = ConicalGradient;
|
||||
const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient());
|
||||
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
|
||||
gradient.generateGradientColorTable(*g, alpha);
|
||||
gradient.spread = QGradient::RepeatSpread;
|
||||
|
||||
QConicalGradientData &conicalData = gradient.conical;
|
||||
|
||||
QPointF center = g->center();
|
||||
conicalData.center.x = center.x();
|
||||
conicalData.center.y = center.y();
|
||||
conicalData.angle = g->angle() * 2 * M_PI / 360.0;
|
||||
case Qt::Dense1Pattern:
|
||||
case Qt::Dense2Pattern:
|
||||
case Qt::Dense3Pattern:
|
||||
case Qt::Dense4Pattern:
|
||||
case Qt::Dense5Pattern:
|
||||
case Qt::Dense6Pattern:
|
||||
case Qt::Dense7Pattern:
|
||||
case Qt::HorPattern:
|
||||
case Qt::VerPattern:
|
||||
case Qt::CrossPattern:
|
||||
case Qt::BDiagPattern:
|
||||
case Qt::FDiagPattern:
|
||||
case Qt::DiagCrossPattern: {
|
||||
type = Texture;
|
||||
if (!tempImage)
|
||||
tempImage = new QImage();
|
||||
*tempImage = rasterBuffer->colorizeBitmap(qt_imageForBrush(brushStyle), brush.color());
|
||||
initTexture(tempImage, alpha, QTextureData::Tiled);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Dense1Pattern:
|
||||
case Qt::Dense2Pattern:
|
||||
case Qt::Dense3Pattern:
|
||||
case Qt::Dense4Pattern:
|
||||
case Qt::Dense5Pattern:
|
||||
case Qt::Dense6Pattern:
|
||||
case Qt::Dense7Pattern:
|
||||
case Qt::HorPattern:
|
||||
case Qt::VerPattern:
|
||||
case Qt::CrossPattern:
|
||||
case Qt::BDiagPattern:
|
||||
case Qt::FDiagPattern:
|
||||
case Qt::DiagCrossPattern:
|
||||
type = Texture;
|
||||
if (!tempImage)
|
||||
tempImage = new QImage();
|
||||
*tempImage = rasterBuffer->colorizeBitmap(qt_imageForBrush(brushStyle), brush.color());
|
||||
initTexture(tempImage, alpha, QTextureData::Tiled);
|
||||
break;
|
||||
case Qt::TexturePattern:
|
||||
type = Texture;
|
||||
if (!tempImage)
|
||||
tempImage = new QImage();
|
||||
case Qt::TexturePattern: {
|
||||
type = Texture;
|
||||
if (!tempImage)
|
||||
tempImage = new QImage();
|
||||
|
||||
if (qHasPixmapTexture(brush) && brush.texture().isQBitmap())
|
||||
*tempImage = rasterBuffer->colorizeBitmap(brush.textureImage(), brush.color());
|
||||
else
|
||||
*tempImage = brush.textureImage();
|
||||
initTexture(tempImage, alpha, QTextureData::Tiled, tempImage->rect());
|
||||
break;
|
||||
if (qHasPixmapTexture(brush) && brush.texture().isQBitmap())
|
||||
*tempImage = rasterBuffer->colorizeBitmap(brush.textureImage(), brush.color());
|
||||
else
|
||||
*tempImage = brush.textureImage();
|
||||
initTexture(tempImage, alpha, QTextureData::Tiled, tempImage->rect());
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::NoBrush:
|
||||
type = None;
|
||||
break;
|
||||
case Qt::NoBrush: {
|
||||
type = None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
adjustSpanMethods();
|
||||
}
|
||||
|
@ -3329,7 +3314,6 @@ void QSpanData::adjustSpanMethods()
|
|||
break;
|
||||
case LinearGradient:
|
||||
case RadialGradient:
|
||||
case ConicalGradient:
|
||||
unclipped_blend = rasterBuffer->drawHelper->blendGradient;
|
||||
break;
|
||||
case Texture:
|
||||
|
|
|
@ -67,12 +67,11 @@ static void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyp
|
|||
static inline QGradient::CoordinateMode coordinateMode(const QBrush &brush)
|
||||
{
|
||||
switch (brush.style()) {
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
case Qt::ConicalGradientPattern:
|
||||
return brush.gradient()->coordinateMode();
|
||||
default:
|
||||
;
|
||||
case Qt::LinearGradientPattern:
|
||||
case Qt::RadialGradientPattern:
|
||||
return brush.gradient()->coordinateMode();
|
||||
default:
|
||||
;
|
||||
}
|
||||
return QGradient::LogicalMode;
|
||||
}
|
||||
|
@ -385,8 +384,8 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath)
|
|||
|
||||
static inline QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect)
|
||||
{
|
||||
Q_ASSERT(brush.style() >= Qt::LinearGradientPattern
|
||||
&& brush.style() <= Qt::ConicalGradientPattern);
|
||||
Q_ASSERT(brush.style() == Qt::LinearGradientPattern
|
||||
|| brush.style() == Qt::RadialGradientPattern);
|
||||
|
||||
QTransform gradientToUser(boundingRect.width(), 0, 0, boundingRect.height(),
|
||||
boundingRect.x(), boundingRect.y());
|
||||
|
@ -5807,8 +5806,7 @@ void QPainter::eraseRect(const QRectF &r)
|
|||
static inline bool needsResolving(const QBrush &brush)
|
||||
{
|
||||
Qt::BrushStyle s = brush.style();
|
||||
return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern ||
|
||||
s == Qt::ConicalGradientPattern) &&
|
||||
return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern) &&
|
||||
brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode);
|
||||
}
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
|
|||
//qDebug() << brushOrigin << matrix;
|
||||
|
||||
Qt::BrushStyle style = brush.style();
|
||||
if (style == Qt::LinearGradientPattern) {// && style <= Qt::ConicalGradientPattern) {
|
||||
if (style == Qt::LinearGradientPattern) {
|
||||
#ifdef USE_NATIVE_GRADIENTS
|
||||
*specifyColor = false;
|
||||
return gradientBrush(b, matrix, gStateObject);
|
||||
|
|
|
@ -445,12 +445,6 @@ static void qBrushSetAlphaF(QBrush *brush, qreal alpha)
|
|||
*brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
case QGradient::ConicalGradient: {
|
||||
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);
|
||||
grad.setStops(stops);
|
||||
*brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type"
|
||||
" - falling back to QLinearGradient");
|
||||
|
@ -508,12 +502,6 @@ static QBrush qBrushLight(QBrush brush, int light)
|
|||
brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
case QGradient::ConicalGradient: {
|
||||
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);
|
||||
grad.setStops(stops);
|
||||
brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type"
|
||||
" - falling back to QLinearGradient");
|
||||
|
@ -570,12 +558,6 @@ static QBrush qBrushDark(QBrush brush, int dark)
|
|||
brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
case QGradient::ConicalGradient: {
|
||||
QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);
|
||||
grad.setStops(stops);
|
||||
brush = QBrush(grad);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning("QPlastiqueStyle::qBrushDark() - unknown gradient type"
|
||||
" - falling back to QLinearGradient");
|
||||
|
|
|
@ -483,7 +483,7 @@ public:
|
|||
bool hasPalette() const { return pal != 0; }
|
||||
bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
|
||||
bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern
|
||||
&& bg->brush.style() <= Qt::ConicalGradientPattern; }
|
||||
&& bg->brush.style() <= Qt::RadialGradientPattern; }
|
||||
|
||||
bool hasNativeBorder() const {
|
||||
return bd == 0
|
||||
|
|
|
@ -724,7 +724,6 @@ static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
|
|||
static const QStringList gradFuncs = QStringList()
|
||||
<< QLatin1String("qlineargradient")
|
||||
<< QLatin1String("qradialgradient")
|
||||
<< QLatin1String("qconicalgradient")
|
||||
<< QLatin1String("qgradient");
|
||||
int gradType = -1;
|
||||
|
||||
|
@ -803,19 +802,6 @@ static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
|
|||
return bd;
|
||||
}
|
||||
|
||||
if (gradType == 2) {
|
||||
QConicalGradient cg(vars.value(QLatin1String("cx")), vars.value(QLatin1String("cy")),
|
||||
vars.value(QLatin1String("angle")));
|
||||
cg.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
cg.setStops(stops);
|
||||
if (spread != -1)
|
||||
cg.setSpread(QGradient::Spread(spread));
|
||||
BrushData bd = QBrush(cg);
|
||||
if (dependsOnThePalette)
|
||||
bd.type = BrushData::DependsOnThePalette;
|
||||
return bd;
|
||||
}
|
||||
|
||||
return BrushData();
|
||||
}
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ static inline bool operator<(const QCheckPoint &checkPoint, int pos)
|
|||
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect = QRectF())
|
||||
{
|
||||
p->save();
|
||||
if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) {
|
||||
if (brush.style() == Qt::LinearGradientPattern || brush.style() == Qt::RadialGradientPattern) {
|
||||
if (!gradientRect.isNull()) {
|
||||
QTransform m;
|
||||
m.translate(gradientRect.left(), gradientRect.top());
|
||||
|
|
|
@ -1624,7 +1624,7 @@ void QPlainTextEditPrivate::relayoutDocument()
|
|||
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF())
|
||||
{
|
||||
p->save();
|
||||
if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) {
|
||||
if (brush.style() == Qt::LinearGradientPattern || brush.style() == Qt::RadialGradientPattern) {
|
||||
if (!gradientRect.isNull()) {
|
||||
QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top());
|
||||
m.scale(gradientRect.width(), gradientRect.height());
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 937 B |
|
@ -83,11 +83,9 @@ void QtGradientDialogPrivate::slotAboutToShowDetails(bool details, int extension
|
|||
\row
|
||||
\o \inlineimage qtgradientdialoglineareditor.png
|
||||
\o \inlineimage qtgradientdialogradialeditor.png
|
||||
\o \inlineimage qtgradientdialogconicaleditor.png
|
||||
\header
|
||||
\o Editing linear type
|
||||
\o Editing radial type
|
||||
\o Editing conical type
|
||||
\row
|
||||
\o The user can change the start and final point positions by dragging the circular handles.
|
||||
\o The user can change the center and focal point positions by dragging the circular handles
|
||||
|
|
|
@ -44,9 +44,6 @@ public:
|
|||
void slotFocalRadialXChanged(double value);
|
||||
void slotFocalRadialYChanged(double value);
|
||||
void slotRadiusRadialChanged(double value);
|
||||
void slotCentralConicalXChanged(double value);
|
||||
void slotCentralConicalYChanged(double value);
|
||||
void slotAngleConicalChanged(double value);
|
||||
|
||||
void slotDetailsChanged(bool details);
|
||||
|
||||
|
@ -55,16 +52,12 @@ public:
|
|||
void centralRadialChanged(const QPointF &point);
|
||||
void focalRadialChanged(const QPointF &point);
|
||||
void radiusRadialChanged(qreal radius);
|
||||
void centralConicalChanged(const QPointF &point);
|
||||
void angleConicalChanged(qreal angle);
|
||||
|
||||
void setStartLinear(const QPointF &point);
|
||||
void setEndLinear(const QPointF &point);
|
||||
void setCentralRadial(const QPointF &point);
|
||||
void setFocalRadial(const QPointF &point);
|
||||
void setRadiusRadial(qreal radius);
|
||||
void setCentralConical(const QPointF &point);
|
||||
void setAngleConical(qreal angle);
|
||||
|
||||
void setType(QGradient::Type type);
|
||||
void showDetails(bool details);
|
||||
|
@ -73,7 +66,6 @@ public:
|
|||
void reset();
|
||||
void setLayout(bool details);
|
||||
void layoutDetails(bool details);
|
||||
bool row4Visible() const;
|
||||
bool row5Visible() const;
|
||||
int extensionWidthHint() const;
|
||||
|
||||
|
@ -94,9 +86,6 @@ public:
|
|||
QDoubleSpinBox *focalRadialXSpinBox;
|
||||
QDoubleSpinBox *focalRadialYSpinBox;
|
||||
QDoubleSpinBox *radiusRadialSpinBox;
|
||||
QDoubleSpinBox *centralConicalXSpinBox;
|
||||
QDoubleSpinBox *centralConicalYSpinBox;
|
||||
QDoubleSpinBox *angleConicalSpinBox;
|
||||
|
||||
QButtonGroup *m_typeGroup;
|
||||
QButtonGroup *m_spreadGroup;
|
||||
|
@ -128,10 +117,6 @@ QGradient QtGradientEditorPrivate::gradient() const
|
|||
m_ui.gradientWidget->radiusRadial(),
|
||||
m_ui.gradientWidget->focalRadial());
|
||||
break;
|
||||
case QGradient::ConicalGradient:
|
||||
gradient = new QConicalGradient(m_ui.gradientWidget->centralConical(),
|
||||
m_ui.gradientWidget->angleConical());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -164,7 +149,6 @@ void QtGradientEditorPrivate::setCombos(bool combos)
|
|||
m_combos = combos;
|
||||
m_ui.linearButton->setVisible(!m_combos);
|
||||
m_ui.radialButton->setVisible(!m_combos);
|
||||
m_ui.conicalButton->setVisible(!m_combos);
|
||||
m_ui.padButton->setVisible(!m_combos);
|
||||
m_ui.repeatButton->setVisible(!m_combos);
|
||||
m_ui.reflectButton->setVisible(!m_combos);
|
||||
|
@ -182,7 +166,6 @@ void QtGradientEditorPrivate::setLayout(bool details)
|
|||
typeLayout->setSpacing(0);
|
||||
typeLayout->addWidget(m_ui.linearButton);
|
||||
typeLayout->addWidget(m_ui.radialButton);
|
||||
typeLayout->addWidget(m_ui.conicalButton);
|
||||
hboxLayout->addLayout(typeLayout);
|
||||
QHBoxLayout *spreadLayout = new QHBoxLayout();
|
||||
spreadLayout->setSpacing(0);
|
||||
|
@ -298,13 +281,6 @@ void QtGradientEditorPrivate::slotDetailsChanged(bool details)
|
|||
showDetails(details);
|
||||
}
|
||||
|
||||
bool QtGradientEditorPrivate::row4Visible() const
|
||||
{
|
||||
if (m_type == QGradient::ConicalGradient)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QtGradientEditorPrivate::row5Visible() const
|
||||
{
|
||||
if (m_type == QGradient::RadialGradient)
|
||||
|
@ -343,9 +319,9 @@ void QtGradientEditorPrivate::showDetails(bool details)
|
|||
m_gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||
m_gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_ui.label4->setVisible(row4Visible());
|
||||
m_ui.label4->setVisible(true);
|
||||
m_ui.label5->setVisible(row5Visible());
|
||||
m_ui.spinBox4->setVisible(row4Visible());
|
||||
m_ui.spinBox4->setVisible(true);
|
||||
m_ui.spinBox5->setVisible(row5Visible());
|
||||
|
||||
setLayout(details);
|
||||
|
@ -377,9 +353,6 @@ void QtGradientEditorPrivate::reset()
|
|||
focalRadialXSpinBox = 0;
|
||||
focalRadialYSpinBox = 0;
|
||||
radiusRadialSpinBox = 0;
|
||||
centralConicalXSpinBox = 0;
|
||||
centralConicalYSpinBox = 0;
|
||||
angleConicalSpinBox = 0;
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::setType(QGradient::Type type)
|
||||
|
@ -403,8 +376,6 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
|
|||
m_gridLayout->setEnabled(false);
|
||||
}
|
||||
|
||||
bool spreadEnabled = true;
|
||||
|
||||
if (type == QGradient::LinearGradient) {
|
||||
startLinearXSpinBox = m_ui.spinBox1;
|
||||
setSpinBox(startLinearXSpinBox, SLOT(slotStartLinearXChanged(double)));
|
||||
|
@ -448,31 +419,14 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
|
|||
setCentralRadial(m_ui.gradientWidget->centralRadial());
|
||||
setFocalRadial(m_ui.gradientWidget->focalRadial());
|
||||
setRadiusRadial(m_ui.gradientWidget->radiusRadial());
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
centralConicalXSpinBox = m_ui.spinBox1;
|
||||
setSpinBox(centralConicalXSpinBox, SLOT(slotCentralConicalXChanged(double)));
|
||||
m_ui.label1->setText(QApplication::translate("QtGradientEditor", "Central X", QApplication::UnicodeUTF8));
|
||||
|
||||
centralConicalYSpinBox = m_ui.spinBox2;
|
||||
setSpinBox(centralConicalYSpinBox, SLOT(slotCentralConicalYChanged(double)));
|
||||
m_ui.label2->setText(QApplication::translate("QtGradientEditor", "Central Y", QApplication::UnicodeUTF8));
|
||||
|
||||
angleConicalSpinBox = m_ui.spinBox3;
|
||||
setSpinBox(angleConicalSpinBox, SLOT(slotAngleConicalChanged(double)), 360.0, 1.0, 1);
|
||||
m_ui.label3->setText(QApplication::translate("QtGradientEditor", "Angle", QApplication::UnicodeUTF8));
|
||||
|
||||
setCentralConical(m_ui.gradientWidget->centralConical());
|
||||
setAngleConical(m_ui.gradientWidget->angleConical());
|
||||
|
||||
spreadEnabled = false;
|
||||
}
|
||||
m_ui.spreadComboBox->setEnabled(spreadEnabled);
|
||||
m_ui.padButton->setEnabled(spreadEnabled);
|
||||
m_ui.repeatButton->setEnabled(spreadEnabled);
|
||||
m_ui.reflectButton->setEnabled(spreadEnabled);
|
||||
m_ui.spreadComboBox->setEnabled(true);
|
||||
m_ui.padButton->setEnabled(true);
|
||||
m_ui.repeatButton->setEnabled(true);
|
||||
m_ui.reflectButton->setEnabled(true);
|
||||
|
||||
m_ui.label4->setVisible(row4Visible());
|
||||
m_ui.spinBox4->setVisible(row4Visible());
|
||||
m_ui.label4->setVisible(true);
|
||||
m_ui.spinBox4->setVisible(true);
|
||||
m_ui.label5->setVisible(row5Visible());
|
||||
m_ui.spinBox5->setVisible(row5Visible());
|
||||
|
||||
|
@ -494,8 +448,6 @@ void QtGradientEditorPrivate::slotTypeChanged(int idx)
|
|||
type = QGradient::LinearGradient;
|
||||
else if (idx == 1)
|
||||
type = QGradient::RadialGradient;
|
||||
else if (idx == 2)
|
||||
type = QGradient::ConicalGradient;
|
||||
setType(type);
|
||||
m_ui.typeComboBox->setCurrentIndex(idx);
|
||||
m_typeGroup->button(idx)->setChecked(true);
|
||||
|
@ -586,28 +538,6 @@ void QtGradientEditorPrivate::slotRadiusRadialChanged(double value)
|
|||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::slotCentralConicalXChanged(double value)
|
||||
{
|
||||
QPointF point = m_ui.gradientWidget->centralConical();
|
||||
point.setX(value);
|
||||
m_ui.gradientWidget->setCentralConical(point);
|
||||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::slotCentralConicalYChanged(double value)
|
||||
{
|
||||
QPointF point = m_ui.gradientWidget->centralConical();
|
||||
point.setY(value);
|
||||
m_ui.gradientWidget->setCentralConical(point);
|
||||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::slotAngleConicalChanged(double value)
|
||||
{
|
||||
m_ui.gradientWidget->setAngleConical(value);
|
||||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::startLinearChanged(const QPointF &point)
|
||||
{
|
||||
setStartLinear(point);
|
||||
|
@ -638,18 +568,6 @@ void QtGradientEditorPrivate::radiusRadialChanged(qreal radius)
|
|||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::centralConicalChanged(const QPointF &point)
|
||||
{
|
||||
setCentralConical(point);
|
||||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::angleConicalChanged(qreal angle)
|
||||
{
|
||||
setAngleConical(angle);
|
||||
updateGradient(true);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::setStartLinear(const QPointF &point)
|
||||
{
|
||||
if (startLinearXSpinBox)
|
||||
|
@ -688,20 +606,6 @@ void QtGradientEditorPrivate::setRadiusRadial(qreal radius)
|
|||
radiusRadialSpinBox->setValue(radius);
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::setCentralConical(const QPointF &point)
|
||||
{
|
||||
if (centralConicalXSpinBox)
|
||||
centralConicalXSpinBox->setValue(point.x());
|
||||
if (centralConicalYSpinBox)
|
||||
centralConicalYSpinBox->setValue(point.y());
|
||||
}
|
||||
|
||||
void QtGradientEditorPrivate::setAngleConical(qreal angle)
|
||||
{
|
||||
if (angleConicalSpinBox)
|
||||
angleConicalSpinBox->setValue(angle);
|
||||
}
|
||||
|
||||
QtGradientEditor::QtGradientEditor(QWidget *parent)
|
||||
: QWidget(parent), d_ptr(new QtGradientEditorPrivate())
|
||||
{
|
||||
|
@ -731,8 +635,6 @@ QtGradientEditor::QtGradientEditor(QWidget *parent)
|
|||
d_ptr->setCentralRadial(QPointF(0.5, 0.5));
|
||||
d_ptr->setFocalRadial(QPointF(0.5, 0.5));
|
||||
d_ptr->setRadiusRadial(0.5);
|
||||
d_ptr->setCentralConical(QPointF(0.5, 0.5));
|
||||
d_ptr->setAngleConical(0);
|
||||
|
||||
QIcon icon;
|
||||
icon.addPixmap(style()->standardPixmap(QStyle::SP_ArrowRight), QIcon::Normal, QIcon::Off);
|
||||
|
@ -745,20 +647,16 @@ QtGradientEditor::QtGradientEditor(QWidget *parent)
|
|||
|
||||
QIcon iconLinear(QLatin1String(":/trolltech/qtgradienteditor/images/typelinear.png"));
|
||||
QIcon iconRadial(QLatin1String(":/trolltech/qtgradienteditor/images/typeradial.png"));
|
||||
QIcon iconConical(QLatin1String(":/trolltech/qtgradienteditor/images/typeconical.png"));
|
||||
|
||||
d_ptr->m_ui.typeComboBox->addItem(iconLinear, tr("Linear"));
|
||||
d_ptr->m_ui.typeComboBox->addItem(iconRadial, tr("Radial"));
|
||||
d_ptr->m_ui.typeComboBox->addItem(iconConical, tr("Conical"));
|
||||
|
||||
d_ptr->m_ui.linearButton->setIcon(iconLinear);
|
||||
d_ptr->m_ui.radialButton->setIcon(iconRadial);
|
||||
d_ptr->m_ui.conicalButton->setIcon(iconConical);
|
||||
|
||||
d_ptr->m_typeGroup = new QButtonGroup(this);
|
||||
d_ptr->m_typeGroup->addButton(d_ptr->m_ui.linearButton, 0);
|
||||
d_ptr->m_typeGroup->addButton(d_ptr->m_ui.radialButton, 1);
|
||||
d_ptr->m_typeGroup->addButton(d_ptr->m_ui.conicalButton, 2);
|
||||
|
||||
connect(d_ptr->m_typeGroup, SIGNAL(buttonClicked(int)),
|
||||
this, SLOT(slotTypeChanged(int)));
|
||||
|
@ -796,10 +694,6 @@ QtGradientEditor::QtGradientEditor(QWidget *parent)
|
|||
this, SLOT(focalRadialChanged(QPointF)));
|
||||
connect(d_ptr->m_ui.gradientWidget, SIGNAL(radiusRadialChanged(qreal)),
|
||||
this, SLOT(radiusRadialChanged(qreal)));
|
||||
connect(d_ptr->m_ui.gradientWidget, SIGNAL(centralConicalChanged(QPointF)),
|
||||
this, SLOT(centralConicalChanged(QPointF)));
|
||||
connect(d_ptr->m_ui.gradientWidget, SIGNAL(angleConicalChanged(qreal)),
|
||||
this, SLOT(angleConicalChanged(qreal)));
|
||||
|
||||
QGradientStops stops = gradient().stops();
|
||||
d_ptr->m_gradientStopsController->setGradientStops(stops);
|
||||
|
@ -822,7 +716,6 @@ void QtGradientEditor::setGradient(const QGradient &grad)
|
|||
switch (type) {
|
||||
case QGradient::LinearGradient: idx = 0; break;
|
||||
case QGradient::RadialGradient: idx = 1; break;
|
||||
case QGradient::ConicalGradient: idx = 2; break;
|
||||
default: return;
|
||||
}
|
||||
d_ptr->setType(type);
|
||||
|
@ -855,12 +748,6 @@ void QtGradientEditor::setGradient(const QGradient &grad)
|
|||
d_ptr->m_ui.gradientWidget->setCentralRadial(gr->center());
|
||||
d_ptr->m_ui.gradientWidget->setFocalRadial(gr->focalPoint());
|
||||
d_ptr->m_ui.gradientWidget->setRadiusRadial(gr->radius());
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
QConicalGradient *gr = (QConicalGradient *)(&grad);
|
||||
d_ptr->setCentralConical(gr->center());
|
||||
d_ptr->setAngleConical(gr->angle());
|
||||
d_ptr->m_ui.gradientWidget->setCentralConical(gr->center());
|
||||
d_ptr->m_ui.gradientWidget->setAngleConical(gr->angle());
|
||||
}
|
||||
|
||||
d_ptr->m_gradientStopsController->setGradientStops(grad.stops());
|
||||
|
|
|
@ -73,17 +73,12 @@ private:
|
|||
Q_PRIVATE_SLOT(d_func(), void slotFocalRadialXChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotFocalRadialYChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotRadiusRadialChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotCentralConicalXChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotCentralConicalYChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotAngleConicalChanged(double value))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotDetailsChanged(bool details))
|
||||
Q_PRIVATE_SLOT(d_func(), void startLinearChanged(const QPointF &))
|
||||
Q_PRIVATE_SLOT(d_func(), void endLinearChanged(const QPointF &))
|
||||
Q_PRIVATE_SLOT(d_func(), void centralRadialChanged(const QPointF &))
|
||||
Q_PRIVATE_SLOT(d_func(), void focalRadialChanged(const QPointF &))
|
||||
Q_PRIVATE_SLOT(d_func(), void radiusRadialChanged(qreal))
|
||||
Q_PRIVATE_SLOT(d_func(), void centralConicalChanged(const QPointF &))
|
||||
Q_PRIVATE_SLOT(d_func(), void angleConicalChanged(qreal))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -13,6 +13,5 @@
|
|||
<file>images/spreadreflect.png</file>
|
||||
<file>images/typelinear.png</file>
|
||||
<file>images/typeradial.png</file>
|
||||
<file>images/typeconical.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1216,28 +1216,6 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="conicalButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>10</y>
|
||||
<width>30</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Conical Type</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="padButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
|
|
|
@ -33,8 +33,6 @@ static QString gradientTypeToString(QGradient::Type type)
|
|||
return QLatin1String("LinearGradient");
|
||||
if (type == QGradient::RadialGradient)
|
||||
return QLatin1String("RadialGradient");
|
||||
if (type == QGradient::ConicalGradient)
|
||||
return QLatin1String("ConicalGradient");
|
||||
return QLatin1String("NoGradient");
|
||||
}
|
||||
|
||||
|
@ -44,8 +42,6 @@ static QGradient::Type stringToGradientType(const QString &name)
|
|||
return QGradient::LinearGradient;
|
||||
if (name == QLatin1String("RadialGradient"))
|
||||
return QGradient::RadialGradient;
|
||||
if (name == QLatin1String("ConicalGradient"))
|
||||
return QGradient::ConicalGradient;
|
||||
return QGradient::NoGradient;
|
||||
}
|
||||
|
||||
|
@ -144,11 +140,6 @@ static QDomElement saveGradient(QDomDocument &doc, const QGradient &gradient)
|
|||
gradElem.setAttribute(QLatin1String("focalX"), QString::number(g.focalPoint().x()));
|
||||
gradElem.setAttribute(QLatin1String("focalY"), QString::number(g.focalPoint().y()));
|
||||
gradElem.setAttribute(QLatin1String("radius"), QString::number(g.radius()));
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
const QConicalGradient &g = *static_cast<const QConicalGradient*>(&gradient);
|
||||
gradElem.setAttribute(QLatin1String("centerX"), QString::number(g.center().x()));
|
||||
gradElem.setAttribute(QLatin1String("centerY"), QString::number(g.center().y()));
|
||||
gradElem.setAttribute(QLatin1String("angle"), QString::number(g.angle()));
|
||||
}
|
||||
|
||||
return gradElem;
|
||||
|
@ -196,11 +187,6 @@ static QGradient loadGradient(const QDomElement &elem)
|
|||
g.setFocalPoint(elem.attribute(QLatin1String("focalX")).toDouble(), elem.attribute(QLatin1String("focalY")).toDouble());
|
||||
g.setRadius(elem.attribute(QLatin1String("radius")).toDouble());
|
||||
gradient = g;
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
QConicalGradient g;
|
||||
g.setCenter(elem.attribute(QLatin1String("centerX")).toDouble(), elem.attribute(QLatin1String("centerY")).toDouble());
|
||||
g.setAngle(elem.attribute(QLatin1String("angle")).toDouble());
|
||||
gradient = g;
|
||||
}
|
||||
|
||||
QDomElement stopElem = elem.firstChildElement();
|
||||
|
@ -303,9 +289,6 @@ static QString styleSheetFillName(const QGradient &gradient)
|
|||
case QGradient::RadialGradient:
|
||||
result += QLatin1String("qradialgradient");
|
||||
break;
|
||||
case QGradient::ConicalGradient:
|
||||
result += QLatin1String("qconicalgradient");
|
||||
break;
|
||||
default:
|
||||
qWarning() << "QtGradientUtils::styleSheetFillName(): gradient type" << gradient.type() << "not supported!";
|
||||
break;
|
||||
|
@ -318,24 +301,22 @@ static QStringList styleSheetParameters(const QGradient &gradient)
|
|||
{
|
||||
QStringList result;
|
||||
|
||||
if (gradient.type() != QGradient::ConicalGradient) {
|
||||
QString spread;
|
||||
switch (gradient.spread()) {
|
||||
case QGradient::PadSpread:
|
||||
spread = QLatin1String("pad");
|
||||
break;
|
||||
case QGradient::ReflectSpread:
|
||||
spread = QLatin1String("reflect");
|
||||
break;
|
||||
case QGradient::RepeatSpread:
|
||||
spread = QLatin1String("repeat");
|
||||
break;
|
||||
default:
|
||||
qWarning() << "QtGradientUtils::styleSheetParameters(): gradient spread" << gradient.spread() << "not supported!";
|
||||
break;
|
||||
}
|
||||
result << QLatin1String("spread:") + spread;
|
||||
QString spread;
|
||||
switch (gradient.spread()) {
|
||||
case QGradient::PadSpread:
|
||||
spread = QLatin1String("pad");
|
||||
break;
|
||||
case QGradient::ReflectSpread:
|
||||
spread = QLatin1String("reflect");
|
||||
break;
|
||||
case QGradient::RepeatSpread:
|
||||
spread = QLatin1String("repeat");
|
||||
break;
|
||||
default:
|
||||
qWarning() << "QtGradientUtils::styleSheetParameters(): gradient spread" << gradient.spread() << "not supported!";
|
||||
break;
|
||||
}
|
||||
result << QLatin1String("spread:") + spread;
|
||||
|
||||
switch (gradient.type()) {
|
||||
case QGradient::LinearGradient: {
|
||||
|
@ -355,13 +336,6 @@ static QStringList styleSheetParameters(const QGradient &gradient)
|
|||
<< QLatin1String("fy:") + QString::number(radialGradient->focalPoint().y());
|
||||
break;
|
||||
}
|
||||
case QGradient::ConicalGradient: {
|
||||
const QConicalGradient *conicalGradient = static_cast<const QConicalGradient*>(&gradient);
|
||||
result << QLatin1String("cx:") + QString::number(conicalGradient->center().x())
|
||||
<< QLatin1String("cy:") + QString::number(conicalGradient->center().y())
|
||||
<< QLatin1String("angle:") + QString::number(conicalGradient->angle());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << "QtGradientUtils::styleSheetParameters(): gradient type" << gradient.type() << "not supported!";
|
||||
break;
|
||||
|
|
|
@ -42,9 +42,6 @@ public:
|
|||
QPointF checkRange(const QPointF &point) const;
|
||||
QRectF pointRect(const QPointF &point, double size) const;
|
||||
|
||||
double correctAngle(double angle) const;
|
||||
void setAngleConical(double angle);
|
||||
|
||||
void paintPoint(QPainter *painter, const QPointF &point, double size) const;
|
||||
|
||||
double m_handleSize;
|
||||
|
@ -58,8 +55,6 @@ public:
|
|||
QPointF m_centralRadial;
|
||||
QPointF m_focalRadial;
|
||||
qreal m_radiusRadial;
|
||||
QPointF m_centralConical;
|
||||
qreal m_angleConical;
|
||||
|
||||
enum Handle {
|
||||
NoHandle,
|
||||
|
@ -67,9 +62,7 @@ public:
|
|||
EndLinearHandle,
|
||||
CentralRadialHandle,
|
||||
FocalRadialHandle,
|
||||
RadiusRadialHandle,
|
||||
CentralConicalHandle,
|
||||
AngleConicalHandle
|
||||
RadiusRadialHandle
|
||||
};
|
||||
|
||||
Handle m_dragHandle;
|
||||
|
@ -81,25 +74,6 @@ public:
|
|||
double m_dragAngle;
|
||||
};
|
||||
|
||||
double QtGradientWidgetPrivate::correctAngle(double angle) const
|
||||
{
|
||||
double a = angle;
|
||||
while (a >= 360)
|
||||
a -= 360;
|
||||
while (a < 0)
|
||||
a += 360;
|
||||
return a;
|
||||
}
|
||||
|
||||
void QtGradientWidgetPrivate::setAngleConical(double angle)
|
||||
{
|
||||
double a = correctAngle(angle);
|
||||
if (m_angleConical == a)
|
||||
return;
|
||||
m_angleConical = a;
|
||||
emit q_ptr->angleConicalChanged(m_angleConical);
|
||||
}
|
||||
|
||||
QRectF QtGradientWidgetPrivate::pointRect(const QPointF &point, double size) const
|
||||
{
|
||||
return QRectF(point.x() - size / 2, point.y() - size / 2, size, size);
|
||||
|
@ -216,8 +190,6 @@ QtGradientWidget::QtGradientWidget(QWidget *parent)
|
|||
d_ptr->m_centralRadial = QPointF(0.5, 0.5);
|
||||
d_ptr->m_focalRadial = QPointF(0.5, 0.5);
|
||||
d_ptr->m_radiusRadial = 0.5;
|
||||
d_ptr->m_centralConical = QPointF(0.5, 0.5);
|
||||
d_ptr->m_angleConical = 0;
|
||||
d_ptr->m_dragHandle = QtGradientWidgetPrivate::NoHandle;
|
||||
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
|
@ -326,50 +298,6 @@ void QtGradientWidget::mousePressEvent(QMouseEvent *e)
|
|||
update();
|
||||
return;
|
||||
}
|
||||
} else if (d_ptr->m_gradientType == QGradient::ConicalGradient) {
|
||||
QPointF centralPoint = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
double x = p.x() - centralPoint.x();
|
||||
double y = p.y() - centralPoint.y();
|
||||
|
||||
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
|
||||
d_ptr->m_dragHandle = QtGradientWidgetPrivate::CentralConicalHandle;
|
||||
d_ptr->m_dragOffset = QPointF(x, y);
|
||||
update();
|
||||
return;
|
||||
}
|
||||
double radius = size().width();
|
||||
if (size().height() < radius)
|
||||
radius = size().height();
|
||||
radius /= 2;
|
||||
double corr = d_ptr->m_handleSize / 3;
|
||||
radius -= corr;
|
||||
QPointF vp = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
x = p.x() - vp.x();
|
||||
y = p.y() - vp.y();
|
||||
if (((radius - corr) * (radius - corr) < (x * x + y * y)) &&
|
||||
((radius + corr) * (radius + corr) > (x * x + y * y))) {
|
||||
QPointF central = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
QPointF current(e->pos().x(), e->pos().y());
|
||||
x = current.x() - central.x();
|
||||
y = current.y() - central.y();
|
||||
x /= size().width() / 2;
|
||||
y /= size().height() / 2;
|
||||
double r = sqrt(x * x + y * y);
|
||||
|
||||
double arcSin = asin(y / r);
|
||||
double arcCos = acos(x / r);
|
||||
|
||||
double angle = arcCos * 180 / M_PI;
|
||||
if (arcSin > 0) {
|
||||
angle = -angle;
|
||||
}
|
||||
|
||||
d_ptr->m_angleOffset = d_ptr->m_angleConical - angle;
|
||||
d_ptr->m_dragAngle = d_ptr->m_angleConical;
|
||||
d_ptr->m_dragHandle = QtGradientWidgetPrivate::AngleConicalHandle;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,41 +359,6 @@ void QtGradientWidget::mouseMoveEvent(QMouseEvent *e)
|
|||
d_ptr->m_radiusRadial = newRadius;
|
||||
emit radiusRadialChanged(d_ptr->m_radiusRadial);
|
||||
}
|
||||
} else if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::CentralConicalHandle) {
|
||||
d_ptr->m_centralConical = newPoint;
|
||||
emit centralConicalChanged(newPoint);
|
||||
} else if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::AngleConicalHandle) {
|
||||
QPointF centralPoint = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
QPointF pF(e->pos().x(), e->pos().y());
|
||||
double x = pF.x() - centralPoint.x();
|
||||
double y = pF.y() - centralPoint.y();
|
||||
|
||||
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
|
||||
if (d_ptr->m_angleConical != d_ptr->m_dragAngle) {
|
||||
d_ptr->m_angleConical = d_ptr->m_dragAngle;
|
||||
emit angleConicalChanged(d_ptr->m_angleConical);
|
||||
}
|
||||
} else {
|
||||
QPointF central = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
QPointF current = pF;
|
||||
x = current.x() - central.x();
|
||||
y = current.y() - central.y();
|
||||
x /= size().width() / 2;
|
||||
y /= size().height() / 2;
|
||||
double r = sqrt(x * x + y * y);
|
||||
|
||||
double arcSin = asin(y / r);
|
||||
double arcCos = acos(x / r);
|
||||
|
||||
double angle = arcCos * 180 / M_PI;
|
||||
if (arcSin > 0) {
|
||||
angle = -angle;
|
||||
}
|
||||
|
||||
angle += d_ptr->m_angleOffset;
|
||||
|
||||
d_ptr->setAngleConical(angle);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
@ -504,9 +397,6 @@ void QtGradientWidget::paintEvent(QPaintEvent *e)
|
|||
case QGradient::RadialGradient:
|
||||
gradient = new QRadialGradient(d_ptr->m_centralRadial, d_ptr->m_radiusRadial, d_ptr->m_focalRadial);
|
||||
break;
|
||||
case QGradient::ConicalGradient:
|
||||
gradient = new QConicalGradient(d_ptr->m_centralConical, d_ptr->m_angleConical);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -587,60 +477,6 @@ void QtGradientWidget::paintEvent(QPaintEvent *e)
|
|||
p.setPen(dragPen);
|
||||
d_ptr->paintPoint(&p, d_ptr->m_focalRadial, 2 * d_ptr->m_handleSize / 3);
|
||||
p.restore();
|
||||
} else if (d_ptr->m_gradientType == QGradient::ConicalGradient) {
|
||||
double radius = size().width();
|
||||
if (size().height() < radius)
|
||||
radius = size().height();
|
||||
radius /= 2;
|
||||
double corr = d_ptr->m_handleSize / 3;
|
||||
radius -= corr;
|
||||
QPointF central = d_ptr->toViewport(d_ptr->m_centralConical);
|
||||
|
||||
p.save();
|
||||
p.setBrush(Qt::NoBrush);
|
||||
QPen pen2(c);
|
||||
pen2.setWidthF(2 * d_ptr->m_handleSize / 3);
|
||||
p.setPen(pen2);
|
||||
p.drawEllipse(d_ptr->pointRect(central, 2 * radius));
|
||||
p.restore();
|
||||
|
||||
p.save();
|
||||
p.setBrush(Qt::NoBrush);
|
||||
int pointCount = 2;
|
||||
for (int i = 0; i < pointCount; i++) {
|
||||
QPointF ang(cos(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().width() / 2,
|
||||
-sin(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().height() / 2);
|
||||
double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y());
|
||||
p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod,
|
||||
central.y() + ang.y() * (radius - corr) / mod),
|
||||
QPointF(central.x() + ang.x() * (radius + corr) / mod,
|
||||
central.y() + ang.y() * (radius + corr) / mod));
|
||||
p.drawLine(QPointF(central.x() - ang.x() * (radius - corr) / mod,
|
||||
central.y() - ang.y() * (radius - corr) / mod),
|
||||
QPointF(central.x() - ang.x() * (radius + corr) / mod,
|
||||
central.y() - ang.y() * (radius + corr) / mod));
|
||||
}
|
||||
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::AngleConicalHandle) {
|
||||
p.save();
|
||||
p.setPen(dragPen);
|
||||
QPointF ang(cos(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().width() / 2,
|
||||
-sin(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().height() / 2);
|
||||
double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y());
|
||||
p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod,
|
||||
central.y() + ang.y() * (radius - corr) / mod),
|
||||
QPointF(central.x() + ang.x() * (radius + corr) / mod,
|
||||
central.y() + ang.y() * (radius + corr) / mod));
|
||||
p.restore();
|
||||
}
|
||||
|
||||
p.restore();
|
||||
|
||||
p.save();
|
||||
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::CentralConicalHandle)
|
||||
p.setPen(dragPen);
|
||||
d_ptr->paintPoint(&p, d_ptr->m_centralConical, d_ptr->m_handleSize);
|
||||
p.restore();
|
||||
|
||||
}
|
||||
|
||||
delete gradient;
|
||||
|
@ -757,33 +593,6 @@ qreal QtGradientWidget::radiusRadial() const
|
|||
return d_ptr->m_radiusRadial;
|
||||
}
|
||||
|
||||
void QtGradientWidget::setCentralConical(const QPointF &point)
|
||||
{
|
||||
if (d_ptr->m_centralConical == point)
|
||||
return;
|
||||
|
||||
d_ptr->m_centralConical = point;
|
||||
update();
|
||||
}
|
||||
|
||||
QPointF QtGradientWidget::centralConical() const
|
||||
{
|
||||
return d_ptr->m_centralConical;
|
||||
}
|
||||
|
||||
void QtGradientWidget::setAngleConical(qreal angle)
|
||||
{
|
||||
if (d_ptr->m_angleConical == angle)
|
||||
return;
|
||||
|
||||
d_ptr->m_angleConical = angle;
|
||||
update();
|
||||
}
|
||||
|
||||
qreal QtGradientWidget::angleConical() const
|
||||
{
|
||||
return d_ptr->m_angleConical;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qtgradientwidget.h"
|
||||
|
|
|
@ -64,12 +64,6 @@ public:
|
|||
void setRadiusRadial(qreal radius);
|
||||
qreal radiusRadial() const;
|
||||
|
||||
void setCentralConical(const QPointF &point);
|
||||
QPointF centralConical() const;
|
||||
|
||||
void setAngleConical(qreal angle);
|
||||
qreal angleConical() const;
|
||||
|
||||
public slots:
|
||||
void setGradientStops(const QGradientStops &stops);
|
||||
signals:
|
||||
|
@ -79,8 +73,6 @@ signals:
|
|||
void centralRadialChanged(const QPointF &point);
|
||||
void focalRadialChanged(const QPointF &point);
|
||||
void radiusRadialChanged(qreal radius);
|
||||
void centralConicalChanged(const QPointF &point);
|
||||
void angleConicalChanged(qreal angle);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
|
|
@ -217,10 +217,6 @@ public:
|
|||
saveGradientStops(str, g);
|
||||
str << QLatin1String("</radialGradient>") << endl;
|
||||
}
|
||||
void saveConicalGradientBrush(const QGradient *)
|
||||
{
|
||||
qWarning("svg's don't support conical gradients!");
|
||||
}
|
||||
|
||||
void saveGradientStops(QTextStream &str, const QGradient *g) {
|
||||
QGradientStops stops = g->stops();
|
||||
|
@ -404,12 +400,6 @@ public:
|
|||
d_func()->attributes.fillOpacity = QString();
|
||||
stream() << QLatin1String("fill=\"url(#") << d_func()->currentGradientName << QLatin1String(")\" ");
|
||||
break;
|
||||
case Qt::ConicalGradientPattern:
|
||||
saveConicalGradientBrush(sbrush.gradient());
|
||||
d_func()->attributes.fill = QString::fromLatin1("url(#%1)").arg(d_func()->currentGradientName);
|
||||
d_func()->attributes.fillOpacity = QString();
|
||||
stream() << QLatin1String("fill=\"url(#") << d_func()->currentGradientName << QLatin1String(")\" ");
|
||||
break;
|
||||
case Qt::NoBrush:
|
||||
stream() << QLatin1String("fill=\"none\" ");
|
||||
d_func()->attributes.fill = QLatin1String("none");
|
||||
|
|
|
@ -140,7 +140,6 @@ static const struct ClassTblData {
|
|||
{ QLatin1String("QCommandLinkButton"), QLatin1String("QtGui/qcommandlinkbutton.h") },
|
||||
{ QLatin1String("QCommonStyle"), QLatin1String("QtGui/qcommonstyle.h") },
|
||||
{ QLatin1String("QCompleter"), QLatin1String("QtGui/qcompleter.h") },
|
||||
{ QLatin1String("QConicalGradient"), QLatin1String("QtGui/qbrush.h") },
|
||||
{ QLatin1String("QContextMenuEvent"), QLatin1String("QtGui/qevent.h") },
|
||||
{ QLatin1String("QContiguousCache"), QLatin1String("QtCore/qcontiguouscache.h") },
|
||||
{ QLatin1String("QContiguousCacheData"), QLatin1String("QtCore/qcontiguouscache.h") },
|
||||
|
|
|
@ -1687,8 +1687,7 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush
|
|||
style = brush->attributeBrushStyle();
|
||||
|
||||
if (style == QLatin1String("LinearGradientPattern") ||
|
||||
style == QLatin1String("RadialGradientPattern") ||
|
||||
style == QLatin1String("ConicalGradientPattern")) {
|
||||
style == QLatin1String("RadialGradientPattern")) {
|
||||
const DomGradient *gradient = brush->elementGradient();
|
||||
const QString gradientType = gradient->attributeType();
|
||||
const QString gradientName = m_driver->unique(QLatin1String("gradient"));
|
||||
|
@ -1705,11 +1704,6 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush
|
|||
<< ", " << gradient->attributeRadius()
|
||||
<< ", " << gradient->attributeFocalX()
|
||||
<< ", " << gradient->attributeFocalY() << ");\n";
|
||||
} else if (gradientType == QLatin1String("ConicalGradient")) {
|
||||
m_output << m_indent << "QConicalGradient " << gradientName
|
||||
<< '(' << gradient->attributeCentralX()
|
||||
<< ", " << gradient->attributeCentralY()
|
||||
<< ", " << gradient->attributeAngle() << ");\n";
|
||||
}
|
||||
|
||||
m_output << m_indent << gradientName << ".setSpread(QGradient::"
|
||||
|
|
|
@ -4101,8 +4101,6 @@ void DomGradient::clear(bool clear_all)
|
|||
m_attr_focalY = 0.0;
|
||||
m_has_attr_radius = false;
|
||||
m_attr_radius = 0.0;
|
||||
m_has_attr_angle = false;
|
||||
m_attr_angle = 0.0;
|
||||
m_has_attr_type = false;
|
||||
m_has_attr_spread = false;
|
||||
m_has_attr_coordinateMode = false;
|
||||
|
@ -4132,8 +4130,6 @@ DomGradient::DomGradient()
|
|||
m_attr_focalY = 0.0;
|
||||
m_has_attr_radius = false;
|
||||
m_attr_radius = 0.0;
|
||||
m_has_attr_angle = false;
|
||||
m_attr_angle = 0.0;
|
||||
m_has_attr_type = false;
|
||||
m_has_attr_spread = false;
|
||||
m_has_attr_coordinateMode = false;
|
||||
|
@ -4186,10 +4182,6 @@ void DomGradient::read(QXmlStreamReader &reader)
|
|||
setAttributeRadius(attribute.value().toString().toDouble());
|
||||
continue;
|
||||
}
|
||||
if (name == QLatin1String("angle")) {
|
||||
setAttributeAngle(attribute.value().toString().toDouble());
|
||||
continue;
|
||||
}
|
||||
if (name == QLatin1String("type")) {
|
||||
setAttributeType(attribute.value().toString());
|
||||
continue;
|
||||
|
@ -4263,9 +4255,6 @@ void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const
|
|||
if (hasAttributeRadius())
|
||||
writer.writeAttribute(QLatin1String("radius"), QString::number(attributeRadius(), 'f', 15));
|
||||
|
||||
if (hasAttributeAngle())
|
||||
writer.writeAttribute(QLatin1String("angle"), QString::number(attributeAngle(), 'f', 15));
|
||||
|
||||
if (hasAttributeType())
|
||||
writer.writeAttribute(QLatin1String("type"), attributeType());
|
||||
|
||||
|
|
|
@ -1788,11 +1788,6 @@ public:
|
|||
inline void setAttributeRadius(double a) { m_attr_radius = a; m_has_attr_radius = true; }
|
||||
inline void clearAttributeRadius() { m_has_attr_radius = false; }
|
||||
|
||||
inline bool hasAttributeAngle() const { return m_has_attr_angle; }
|
||||
inline double attributeAngle() const { return m_attr_angle; }
|
||||
inline void setAttributeAngle(double a) { m_attr_angle = a; m_has_attr_angle = true; }
|
||||
inline void clearAttributeAngle() { m_has_attr_angle = false; }
|
||||
|
||||
inline bool hasAttributeType() const { return m_has_attr_type; }
|
||||
inline QString attributeType() const { return m_attr_type; }
|
||||
inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; }
|
||||
|
@ -1844,9 +1839,6 @@ private:
|
|||
double m_attr_radius;
|
||||
bool m_has_attr_radius;
|
||||
|
||||
double m_attr_angle;
|
||||
bool m_has_attr_angle;
|
||||
|
||||
QString m_attr_type;
|
||||
bool m_has_attr_type;
|
||||
|
||||
|
|
|
@ -1012,9 +1012,7 @@ QBrush QAbstractFormBuilder::setupBrush(DomBrush *brush)
|
|||
|
||||
const Qt::BrushStyle style = enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::BrushStyle>("brushStyle", brush->attributeBrushStyle().toLatin1());
|
||||
|
||||
if (style == Qt::LinearGradientPattern ||
|
||||
style == Qt::RadialGradientPattern ||
|
||||
style == Qt::ConicalGradientPattern) {
|
||||
if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern) {
|
||||
const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType");
|
||||
const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread");
|
||||
const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate");
|
||||
|
@ -1032,9 +1030,6 @@ QBrush QAbstractFormBuilder::setupBrush(DomBrush *brush)
|
|||
gr = new QRadialGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()),
|
||||
gradient->attributeRadius(),
|
||||
QPointF(gradient->attributeFocalX(), gradient->attributeFocalY()));
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
gr = new QConicalGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()),
|
||||
gradient->attributeAngle());
|
||||
}
|
||||
if (!gr)
|
||||
return br;
|
||||
|
@ -1076,9 +1071,7 @@ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br)
|
|||
DomBrush *brush = new DomBrush();
|
||||
const Qt::BrushStyle style = br.style();
|
||||
brush->setAttributeBrushStyle(QString::fromLatin1(brushStyle_enum.valueToKey(style)));
|
||||
if (style == Qt::LinearGradientPattern ||
|
||||
style == Qt::RadialGradientPattern ||
|
||||
style == Qt::ConicalGradientPattern) {
|
||||
if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern) {
|
||||
const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType");
|
||||
const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread");
|
||||
const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate");
|
||||
|
@ -1118,11 +1111,6 @@ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br)
|
|||
gradient->setAttributeFocalX(rgr->focalPoint().x());
|
||||
gradient->setAttributeFocalY(rgr->focalPoint().y());
|
||||
gradient->setAttributeRadius(rgr->radius());
|
||||
} else if (type == QGradient::ConicalGradient) {
|
||||
QConicalGradient *cgr = (QConicalGradient *)(gr);
|
||||
gradient->setAttributeCentralX(cgr->center().x());
|
||||
gradient->setAttributeCentralY(cgr->center().y());
|
||||
gradient->setAttributeAngle(cgr->angle());
|
||||
}
|
||||
|
||||
brush->setElementGradient(gradient);
|
||||
|
|
|
@ -49,7 +49,6 @@ private slots:
|
|||
|
||||
void testQLinearGradientSetters();
|
||||
void testQRadialGradientSetters();
|
||||
void testQConicalGradientSetters();
|
||||
void testQGradientCopyConstructor();
|
||||
|
||||
void gradientStops();
|
||||
|
@ -89,8 +88,6 @@ void tst_QBrush::operator_eq_eq_data()
|
|||
QTest::newRow("lg vs diff lg") << QBrush(lg) << QBrush(QLinearGradient(QPoint(0, 0), QPoint(1, 1)))
|
||||
<< false;
|
||||
|
||||
QTest::newRow("rad vs con") << QBrush(QRadialGradient(0, 0, 0, 0, 0)) << QBrush(QConicalGradient(0, 0, 0)) << false;
|
||||
|
||||
QBrush b1(lg);
|
||||
QBrush b2(lg);
|
||||
b1.setTransform(QTransform().scale(2, 2));
|
||||
|
@ -123,7 +120,6 @@ void tst_QBrush::stream_data()
|
|||
QTest::newRow("no") << QBrush(Qt::NoBrush);
|
||||
QTest::newRow("lg") << QBrush(lg);
|
||||
QTest::newRow("rad") << QBrush(QRadialGradient(0, 0, 0, 0, 0));
|
||||
QTest::newRow("con") << QBrush(QConicalGradient(0, 0, 0));
|
||||
}
|
||||
|
||||
void tst_QBrush::stream()
|
||||
|
@ -192,23 +188,6 @@ void tst_QBrush::testQRadialGradientSetters()
|
|||
QCOMPARE(rg.focalPoint(), QPointF(203, 204));
|
||||
}
|
||||
|
||||
void tst_QBrush::testQConicalGradientSetters()
|
||||
{
|
||||
QConicalGradient cg;
|
||||
|
||||
QCOMPARE(cg.angle(), qreal(0.0));
|
||||
QCOMPARE(cg.center(), QPointF(0, 0));
|
||||
|
||||
cg.setAngle(100);
|
||||
QCOMPARE(cg.angle(), qreal(100.0));
|
||||
|
||||
cg.setCenter(102, 103);
|
||||
QCOMPARE(cg.center(), QPointF(102, 103));
|
||||
|
||||
cg.setCenter(QPointF(202, 203));
|
||||
QCOMPARE(cg.center(), QPointF(202, 203));
|
||||
}
|
||||
|
||||
void tst_QBrush::testQGradientCopyConstructor()
|
||||
{
|
||||
{
|
||||
|
@ -236,19 +215,6 @@ void tst_QBrush::testQGradientCopyConstructor()
|
|||
QCOMPARE(((QRadialGradient *) &g)->focalPoint(), rg1.focalPoint());
|
||||
QCOMPARE(((QRadialGradient *) &g)->radius(), rg1.radius());
|
||||
}
|
||||
|
||||
{
|
||||
QConicalGradient cg1(101, 102, 103);
|
||||
|
||||
QConicalGradient cg2 = cg1;
|
||||
QCOMPARE(cg1.center(), cg2.center());
|
||||
QCOMPARE(cg1.angle(), cg2.angle());
|
||||
|
||||
QGradient g = cg1;
|
||||
QCOMPARE(((QConicalGradient *) &g)->center(), cg1.center());
|
||||
QCOMPARE(((QConicalGradient *) &g)->angle(), cg1.angle());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tst_QBrush::badStyles()
|
||||
|
@ -256,19 +222,16 @@ void tst_QBrush::badStyles()
|
|||
// QBrush(Qt::BrushStyle) constructor
|
||||
QCOMPARE(QBrush(Qt::LinearGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::RadialGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::ConicalGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::TexturePattern).style(), Qt::NoBrush);
|
||||
|
||||
// QBrush(QColor, Qt::BrushStyle) constructor
|
||||
QCOMPARE(QBrush(QColor(0, 0, 0), Qt::LinearGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(QColor(0, 0, 0), Qt::RadialGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(QColor(0, 0, 0), Qt::ConicalGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(QColor(0, 0, 0), Qt::TexturePattern).style(), Qt::NoBrush);
|
||||
|
||||
// QBrush(Qt::GlobalColor, Qt::BrushStyle) constructor
|
||||
QCOMPARE(QBrush(Qt::black, Qt::LinearGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::black, Qt::RadialGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::black, Qt::ConicalGradientPattern).style(), Qt::NoBrush);
|
||||
QCOMPARE(QBrush(Qt::black, Qt::TexturePattern).style(), Qt::NoBrush);
|
||||
|
||||
// Set style...
|
||||
|
@ -280,9 +243,6 @@ void tst_QBrush::badStyles()
|
|||
brush.setStyle(Qt::RadialGradientPattern);
|
||||
QCOMPARE(brush.style(), Qt::SolidPattern);
|
||||
|
||||
brush.setStyle(Qt::ConicalGradientPattern);
|
||||
QCOMPARE(brush.style(), Qt::SolidPattern);
|
||||
|
||||
brush.setStyle(Qt::TexturePattern);
|
||||
QCOMPARE(brush.style(), Qt::SolidPattern);
|
||||
|
||||
|
|
|
@ -1443,11 +1443,6 @@ void tst_QCssParser::gradient_data()
|
|||
"spread: reflect, stop:0.2 rgb(1, 2, 3), stop: 0.5 rgba(1, 2, 3, 4))" << "linear" << QPointF(0, 0) << QPointF(0, 1)
|
||||
<< 1 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
|
||||
|
||||
QTest::newRow("conical gradient") <<
|
||||
"selection-background-color: qconicalgradient(cx: 4, cy : 2, angle: 23, "
|
||||
"spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF()
|
||||
<< 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
|
||||
|
||||
/* wont pass: stop values are expected to be sorted
|
||||
QTest::newRow("unsorted-stop") <<
|
||||
"selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, "
|
||||
|
@ -1491,10 +1486,6 @@ void tst_QCssParser::gradient()
|
|||
const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
|
||||
QCOMPARE(lg->start(), start);
|
||||
QCOMPARE(lg->finalStop(), finalStop);
|
||||
} else if (type == "conical") {
|
||||
QVERIFY(sbg.style() == Qt::ConicalGradientPattern);
|
||||
const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
|
||||
QCOMPARE(cg->center(), start);
|
||||
}
|
||||
const QGradient *g = sbg.gradient();
|
||||
QCOMPARE(g->spread(), QGradient::Spread(spread));
|
||||
|
|
|
@ -2901,8 +2901,6 @@ void tst_QDataStream::streamRealDataTypes()
|
|||
color.setAlphaF(0.5);
|
||||
QRadialGradient radialGradient(5, 6, 7, 8, 9);
|
||||
QBrush radialBrush(radialGradient);
|
||||
QConicalGradient conicalGradient(5, 6, 7);
|
||||
QBrush conicalBrush(conicalGradient);
|
||||
|
||||
QFile file("datastream.tmp");
|
||||
|
||||
|
@ -2917,7 +2915,7 @@ void tst_QDataStream::streamRealDataTypes()
|
|||
stream << picture;
|
||||
stream << QTextLength(QTextLength::VariableLength, 1.5);
|
||||
stream << color;
|
||||
stream << radialBrush << conicalBrush;
|
||||
stream << radialBrush;
|
||||
stream << QPen(QBrush(Qt::red), 1.5);
|
||||
|
||||
file.close();
|
||||
|
@ -2932,7 +2930,6 @@ void tst_QDataStream::streamRealDataTypes()
|
|||
QTextLength textLength;
|
||||
QColor col;
|
||||
QBrush rGrad;
|
||||
QBrush cGrad;
|
||||
QPen pen;
|
||||
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
|
@ -2987,16 +2984,8 @@ void tst_QDataStream::streamRealDataTypes()
|
|||
QCOMPARE(((QRadialGradient *)rGrad.gradient())->center(), ((QRadialGradient *)radialBrush.gradient())->center());
|
||||
QCOMPARE(((QRadialGradient *)rGrad.gradient())->focalPoint(), ((QRadialGradient *)radialBrush.gradient())->focalPoint());
|
||||
QCOMPARE(((QRadialGradient *)rGrad.gradient())->radius(), ((QRadialGradient *)radialBrush.gradient())->radius());
|
||||
stream >> cGrad;
|
||||
QCOMPARE(cGrad.style(), conicalBrush.style());
|
||||
QCOMPARE(cGrad.matrix(), conicalBrush.matrix());
|
||||
QCOMPARE(cGrad.gradient()->type(), conicalBrush.gradient()->type());
|
||||
QCOMPARE(cGrad.gradient()->stops(), conicalBrush.gradient()->stops());
|
||||
QCOMPARE(cGrad.gradient()->spread(), conicalBrush.gradient()->spread());
|
||||
QCOMPARE(((QConicalGradient *)cGrad.gradient())->center(), ((QConicalGradient *)conicalBrush.gradient())->center());
|
||||
QCOMPARE(((QConicalGradient *)cGrad.gradient())->angle(), ((QConicalGradient *)conicalBrush.gradient())->angle());
|
||||
// TODO: QLinearGradient test
|
||||
|
||||
QCOMPARE(cGrad, conicalBrush);
|
||||
stream >> pen;
|
||||
QCOMPARE(pen.widthF(), qreal(1.5));
|
||||
|
||||
|
|
|
@ -406,7 +406,6 @@ void tst_QPainter::setupBrushes()
|
|||
lg.setStart(0, 0);
|
||||
|
||||
QRadialGradient rg;
|
||||
QConicalGradient cg;
|
||||
|
||||
QGradientStops stops;
|
||||
if (j == 0) stops = gradient_white_black;
|
||||
|
@ -415,7 +414,6 @@ void tst_QPainter::setupBrushes()
|
|||
else if (j == 3) stops = gradient_white_alpha10;
|
||||
lg.setStops(stops);
|
||||
rg.setStops(stops);
|
||||
cg.setStops(stops);
|
||||
|
||||
for (int i=0; i<6; ++i) {
|
||||
lg.setSpread((QGradient::Spread) (i % 3));
|
||||
|
@ -438,10 +436,6 @@ void tst_QPainter::setupBrushes()
|
|||
rg.setCenter(0, 0);
|
||||
rg.setFocalPoint(50, 50);
|
||||
m_brushes[QLatin1String("radgrad-brush") + name] = QBrush(rg);
|
||||
|
||||
cg.setCenter(0, 0);
|
||||
cg.setAngle(40);
|
||||
m_brushes[QLatin1String("congrad-brush") + name] = QBrush(cg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue