diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-09-23 12:52:08 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-09-23 13:22:19 (GMT) |
commit | e97b99f249ed65c6cedfc23f751a9834641271cb (patch) | |
tree | d8120b28fb710ccf4e687ad35659718709edaad7 | |
parent | 2966b2a95b0d7d161a6dc1a6edab3d6aa6edf004 (diff) | |
download | Qt-e97b99f249ed65c6cedfc23f751a9834641271cb.zip Qt-e97b99f249ed65c6cedfc23f751a9834641271cb.tar.gz Qt-e97b99f249ed65c6cedfc23f751a9834641271cb.tar.bz2 |
Added QSlider to tst_QStyleSheetStyle::complexWidgetFocus.
When using style sheets, QSlider::handle couldn't be customized if
QSlider::groove wasn't. QComboBox::down-arrow:focus wasn't properly drawn.
Reviewed-by: Olivier
-rw-r--r-- | src/gui/styles/qstylesheetstyle.cpp | 20 | ||||
-rw-r--r-- | src/gui/styles/qwindowsstyle.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 12 |
3 files changed, 18 insertions, 16 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index def82ae..0f3a88b 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3136,19 +3136,25 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { rule.drawRule(p, opt->rect); - QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove); - if (!subRule.hasDrawable()) { - baseStyle()->drawComplexControl(cc, slider, p, w); - return; + QRenderRule grooveSubRule = renderRule(w, opt, PseudoElement_SliderGroove); + QRenderRule handleSubRule = renderRule(w, opt, PseudoElement_SliderHandle); + if (!grooveSubRule.hasDrawable()) { + QStyleOptionSlider slOpt(*slider); + bool handleHasRule = handleSubRule.hasDrawable(); + // If the style specifies a different handler rule, draw the groove without the handler. + if (handleHasRule) + slOpt.subControls &= ~SC_SliderHandle; + baseStyle()->drawComplexControl(cc, &slOpt, p, w); + if (!handleHasRule) + return; } QRect gr = subControlRect(cc, opt, SC_SliderGroove, w); if (slider->subControls & SC_SliderGroove) { - subRule.drawRule(p, gr); + grooveSubRule.drawRule(p, gr); } if (slider->subControls & SC_SliderHandle) { - QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderHandle); QRect hr = subControlRect(cc, opt, SC_SliderHandle, w); QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage); @@ -3169,7 +3175,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC subRule2.drawRule(p, r); } - subRule.drawRule(p, subRule.boxRect(hr, Margin)); + handleSubRule.drawRule(p, grooveSubRule.boxRect(hr, Margin)); } if (slider->subControls & SC_SliderTickmarks) { diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 2ed9303..0f72440 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -3030,6 +3030,8 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp ar.adjust(2, 2, -2, -2); if (opt->state & State_Enabled) flags |= State_Enabled; + if (opt->state & State_HasFocus) + flags |= State_HasFocus; if (sunkenArrow) flags |= State_Sunken; diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index e8fbd86..50bb846 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1459,16 +1459,15 @@ void tst_QStyleSheetStyle::complexWidgetFocus() // For this reason, we use unusual and extremely ugly colors! :-) QDialog frame; - // We only want to test the buttons colors. frame.setStyleSheet("*:focus { background: black; color: black } " - "QSpinBox::up-button:focus, QSpinBox::down-button:focus { width: 15px; height: 15px; background: #e8ff66; color: #ff0084 } " "QSpinBox::up-arrow:focus, QSpinBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 } " - "QComboBox::drop-down:focus { background: #e8ff66; color: #ff0084 } " - "QComboBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084; color: #e8ff66 }"); + "QComboBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 }" + "QSlider::handle:horizontal:focus { width: 7px; height: 7px; background: #ff0084 } "); QList<QWidget *> widgets; widgets << new QSpinBox; widgets << new QComboBox; + widgets << new QSlider(Qt::Horizontal); QLayout* layout = new QGridLayout; layout->addWidget(new QLineEdit); // Avoids initial focus. @@ -1489,11 +1488,6 @@ void tst_QStyleSheetStyle::complexWidgetFocus() QSKIP("Test doesn't support color depth < 24", SkipAll); } - QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), - (QString::fromLatin1(widget->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(widget->metaObject()->className()) + " did not contain text color #ff0084, using style " |