From 021d8e4823b9b234cf3d19b66379c9bbae555aa2 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 20 Oct 2010 10:07:40 +0000 Subject: [PATCH] * don't set the font on the native widget in change events * don't set the palette on the native widget in change events * reset the value of customFont when it is set specifically because !customFont (allowing future theme changes to take effect as a result) svn path=/trunk/KDE/kdelibs/; revision=1187721 --- widgets/checkbox.cpp | 2 +- widgets/combobox.cpp | 7 +++---- widgets/groupbox.cpp | 2 +- widgets/label.cpp | 5 ++--- widgets/lineedit.cpp | 2 +- widgets/radiobutton.cpp | 2 +- widgets/spinbox.cpp | 2 +- widgets/tabbar.cpp | 2 +- widgets/textbrowser.cpp | 2 +- widgets/textedit.cpp | 2 +- widgets/toolbutton.cpp | 10 ++-------- 11 files changed, 15 insertions(+), 23 deletions(-) diff --git a/widgets/checkbox.cpp b/widgets/checkbox.cpp index a2432a571..ac0d21b4e 100644 --- a/widgets/checkbox.cpp +++ b/widgets/checkbox.cpp @@ -85,6 +85,7 @@ public: q->setPalette(p); if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -191,7 +192,6 @@ void CheckBox::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/combobox.cpp b/widgets/combobox.cpp index 968b5bcfa..2fafdcdbc 100644 --- a/widgets/combobox.cpp +++ b/widgets/combobox.cpp @@ -98,11 +98,11 @@ void ComboBoxPrivate::syncBorders() //calc the rect for the over effect syncActiveRect(); - KComboBox *native = q->nativeWidget(); if (customFont) { - native->setFont(q->font()); + q->setFont(q->font()); } else { - native->setFont(Theme::defaultTheme()->font(Theme::DefaultFont)); + q->setFont(Theme::defaultTheme()->font(Theme::DefaultFont)); + customFont = false; } } @@ -300,7 +300,6 @@ void ComboBox::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/groupbox.cpp b/widgets/groupbox.cpp index e92d513a9..1a65c0353 100644 --- a/widgets/groupbox.cpp +++ b/widgets/groupbox.cpp @@ -54,6 +54,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -111,7 +112,6 @@ void GroupBox::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/label.cpp b/widgets/label.cpp index 9e6f82e63..c8bcefde1 100644 --- a/widgets/label.cpp +++ b/widgets/label.cpp @@ -103,6 +103,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -341,13 +342,11 @@ void Label::changeEvent(QEvent *event) case QEvent::FontChange: if (font() != QApplication::font()) { d->customFont = true; - nativeWidget()->setFont(font()); } break; case QEvent::PaletteChange: d->customPalette = true; - nativeWidget()->setPalette(palette()); break; default: @@ -361,8 +360,8 @@ bool Label::event(QEvent *event) { if (event->type() == QEvent::Show && font() != QApplication::font()) { d->customFont = true; - nativeWidget()->setFont(font()); } + return QGraphicsProxyWidget::event(event); } diff --git a/widgets/lineedit.cpp b/widgets/lineedit.cpp index b93227da0..c54a83f03 100644 --- a/widgets/lineedit.cpp +++ b/widgets/lineedit.cpp @@ -61,6 +61,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -181,7 +182,6 @@ void LineEdit::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/radiobutton.cpp b/widgets/radiobutton.cpp index 4cbaf4a45..ce7c7ec43 100644 --- a/widgets/radiobutton.cpp +++ b/widgets/radiobutton.cpp @@ -77,6 +77,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -182,7 +183,6 @@ void RadioButton::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/spinbox.cpp b/widgets/spinbox.cpp index c9813891e..b72ef5783 100644 --- a/widgets/spinbox.cpp +++ b/widgets/spinbox.cpp @@ -65,6 +65,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -162,7 +163,6 @@ void SpinBox::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/tabbar.cpp b/widgets/tabbar.cpp index 9f74a4f51..d6fb518a7 100644 --- a/widgets/tabbar.cpp +++ b/widgets/tabbar.cpp @@ -236,6 +236,7 @@ void TabBarPrivate::setPalette() if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -626,7 +627,6 @@ void TabBar::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsWidget::changeEvent(event); diff --git a/widgets/textbrowser.cpp b/widgets/textbrowser.cpp index 70f202edd..c72080bb9 100644 --- a/widgets/textbrowser.cpp +++ b/widgets/textbrowser.cpp @@ -83,6 +83,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -207,7 +208,6 @@ void TextBrowser::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/textedit.cpp b/widgets/textedit.cpp index ff83dca9c..d96f404b7 100644 --- a/widgets/textedit.cpp +++ b/widgets/textedit.cpp @@ -63,6 +63,7 @@ public: if (!customFont) { q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); + customFont = false; } } @@ -179,7 +180,6 @@ void TextEdit::changeEvent(QEvent *event) { if (event->type() == QEvent::FontChange) { d->customFont = true; - nativeWidget()->setFont(font()); } QGraphicsProxyWidget::changeEvent(event); diff --git a/widgets/toolbutton.cpp b/widgets/toolbutton.cpp index 0e4f74b18..d3f2074e6 100644 --- a/widgets/toolbutton.cpp +++ b/widgets/toolbutton.cpp @@ -380,15 +380,9 @@ void ToolButton::paint(QPainter *painter, buttonOpt.palette.setColor(QPalette::ButtonText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor)); } - QFont widgetFont; - if (d->customFont) { - widgetFont = font(); - } else { - widgetFont = Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont); - } - buttonOpt.font = widgetFont; + buttonOpt.font = d->customFont ? font() : Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont); - painter->setFont(widgetFont); + painter->setFont(buttonOpt.font); button->style()->drawControl(QStyle::CE_ToolButtonLabel, &buttonOpt, painter, button); }