summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-09-21 13:32:51 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-09-21 14:00:27 (GMT)
commit423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a (patch)
treefe3827e865c3bee03c41287d99ffffc474223cb6
parent5759ee3ef9eea0a1ea06efd4c349ef7ecc35ab5e (diff)
downloadQt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.zip
Qt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.tar.gz
Qt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.tar.bz2
When using Plastique style, changing the background style sheet property of a
spinbox wouldn't set the correct background for the embedded line edit. Reviewed-by: Olivier Task-number: 232085 Task-number: QTBUG-3013
-rw-r--r--src/gui/styles/qplastiquestyle.cpp3
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp51
3 files changed, 55 insertions, 1 deletions
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index 0b2d6a7..5052755 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -1056,7 +1056,8 @@ void QPlastiqueStylePrivate::drawPartialFrame(QPainter *painter, const QStyleOpt
frameOpt.rect.adjust(reverse ? -2 : 0, 0, reverse ? 0 : 2, 0);
frameOpt.lineWidth = q->pixelMetric(QStyle::PM_DefaultFrameWidth);
frameOpt.midLineWidth = 0;
- frameOpt.state |= QStyle::State_Sunken;
+ frameOpt.state = option->state | QStyle::State_Sunken;
+ frameOpt.palette = option->palette;
q->drawPrimitive(QStyle::PE_PanelLineEdit, &frameOpt, painter, widget);
painter->restore();
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 9f2d245..e33b255 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -2903,6 +2903,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleOptionSpinBox spinOpt(*spin);
rule.configurePalette(&spinOpt.palette, QPalette::ButtonText, QPalette::Button);
+ rule.configurePalette(&spinOpt.palette, QPalette::Text, QPalette::Base);
spinOpt.rect = rule.borderRect(opt->rect);
bool customUp = true, customDown = true;
QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
@@ -4169,6 +4170,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
return;
+ rule = spinboxRule;
}
#endif
if (rule.hasNativeBorder()) {
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 360e433..e7d804a 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -96,6 +96,7 @@ private slots:
void opaquePaintEvent_data();
void opaquePaintEvent();
void task188195_baseBackground();
+ void task232085_spinBoxLineEditBg();
//at the end because it mess with the style.
void widgetStyle();
@@ -1468,6 +1469,56 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
}
+void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
+{
+ // This test is a simplified version of the focusColors() test above.
+
+ // Tests if colors can be changed by altering the focus of the widget.
+ // To avoid messy pixel-by-pixel comparison, we assume that the goal
+ // is reached if at least ten pixels of the right color can be found in
+ // the image.
+ // For this reason, we use unusual and extremely ugly colors! :-)
+
+ QSpinBox *spinbox = new QSpinBox;
+ spinbox->setValue(8888);
+
+ QDialog frame;
+ QLayout* layout = new QGridLayout;
+
+ QLineEdit* dummy = new QLineEdit; // Avoids initial focus.
+
+ // We only want to test the line edit colors.
+ spinbox->setStyleSheet("QSpinBox:focus { background: #e8ff66; color: #ff0084 } "
+ "QSpinBox::up-button, QSpinBox::down-button { background: black; }");
+
+ layout->addWidget(dummy);
+ layout->addWidget(spinbox);
+ frame.setLayout(layout);
+
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QApplication::setActiveWindow(&frame);
+ spinbox->setFocus();
+ QApplication::processEvents();
+
+ QImage image(frame.width(), frame.height(), QImage::Format_ARGB32);
+ frame.render(&image);
+ if (image.depth() < 24) {
+ QSKIP("Test doesn't support color depth < 24", SkipAll);
+ }
+
+ QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
+ (QString::fromLatin1(spinbox->metaObject()->className())
+ + " did not contain background color #e8ff66, using style "
+ + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ .toLocal8Bit().constData());
+ QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
+ (QString::fromLatin1(spinbox->metaObject()->className())
+ + " did not contain text color #ff0084, using style "
+ + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ .toLocal8Bit().constData());
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"