summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting/shared/arthurstyle.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2012-11-27 10:14:15 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-30 00:53:07 +0100
commitc3b4f276033ad024b649fae9a25a0a1fc2d6ea65 (patch)
tree2ac6df5e597a0c62a6a3be808caf50795b807781 /examples/widgets/painting/shared/arthurstyle.cpp
parentf52177829a20b55624168870498947b28b82d220 (diff)
QtBase: Fix painting example arthur background color
The arthur style set the background color to a bright color and leave the foregroud color, for example for text, untouched. If you are using a color theme with bright foregroundcolors on your system this will result in unreadable text on push- and radio-buttons. The function drawControl is now reimplemented and the labels with text are drawn with an appropriate color. Change-Id: Ifd7f3a2b1c0305130255009c7733e0966830171a Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'examples/widgets/painting/shared/arthurstyle.cpp')
-rw-r--r--examples/widgets/painting/shared/arthurstyle.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp
index 7d56e55b9d..78b48ccfe4 100644
--- a/examples/widgets/painting/shared/arthurstyle.cpp
+++ b/examples/widgets/painting/shared/arthurstyle.cpp
@@ -311,6 +311,44 @@ void ArthurStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
return;
}
+void ArthurStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ switch (element) {
+ case CE_RadioButtonLabel:
+ if (const QStyleOptionButton *button
+ = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+
+ if (button->text.isEmpty()) {
+ QCommonStyle::drawControl(element, option, painter, widget);
+ } else {
+ painter->save();
+ painter->setPen(Qt::black);
+ painter->drawText(button->rect, Qt::AlignVCenter, button->text);
+ painter->restore();
+ }
+ }
+ break;
+ case CE_PushButtonLabel:
+ if (const QStyleOptionButton *button
+ = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+
+ if (button->text.isEmpty()) {
+ QCommonStyle::drawControl(element, option, painter, widget);
+ } else {
+ painter->save();
+ painter->setPen(Qt::black);
+ painter->drawText(button->rect, Qt::AlignVCenter | Qt::AlignHCenter, button->text);
+ painter->restore();
+ }
+ }
+ break;
+ default:
+ QCommonStyle::drawControl(element, option, painter, widget);
+ break;
+ }
+}
+
QRect ArthurStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
SubControl subControl, const QWidget *widget) const
{