don't set the native widget's palette. since this now works in QGraphicsProxyWidget, it now causes new problems: setting the palette on the widget (not the nativeWidget()) doesn't work for users of Plasma::* widgets. love it when work arounds to bugs cause new bugs once the original bugs are fixed upstream. ;)

svn path=/trunk/KDE/kdelibs/; revision=1185467
This commit is contained in:
Aaron J. Seigo 2010-10-13 13:16:35 +00:00
parent bdcf7578ee
commit 4c5f141992
9 changed files with 52 additions and 45 deletions

View File

@ -78,14 +78,13 @@ public:
void setPalette() void setPalette()
{ {
QCheckBox *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::WindowText, color); p.setColor(QPalette::Normal, QPalette::WindowText, color);
p.setColor(QPalette::Inactive, QPalette::WindowText, color); p.setColor(QPalette::Inactive, QPalette::WindowText, color);
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -46,15 +46,14 @@ public:
void setPalette() void setPalette()
{ {
QGroupBox *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::WindowText, color); p.setColor(QPalette::Normal, QPalette::WindowText, color);
p.setColor(QPalette::Inactive, QPalette::WindowText, color); p.setColor(QPalette::Inactive, QPalette::WindowText, color);
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -43,7 +43,9 @@ public:
LabelPrivate(Label *label) LabelPrivate(Label *label)
: q(label), : q(label),
svg(0), svg(0),
customFont(false) textSelectable(false),
customFont(false),
customPalette(false)
{ {
} }
@ -84,9 +86,12 @@ public:
void setPalette() void setPalette()
{ {
QLabel *native = q->nativeWidget(); if (customPalette) {
return;
}
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::WindowText, color); p.setColor(QPalette::Normal, QPalette::WindowText, color);
p.setColor(QPalette::Inactive, QPalette::WindowText, color); p.setColor(QPalette::Inactive, QPalette::WindowText, color);
color.setAlphaF(0.6); color.setAlphaF(0.6);
@ -94,10 +99,10 @@ public:
p.setColor(QPalette::Normal, QPalette::Link, Theme::defaultTheme()->color(Theme::LinkColor)); p.setColor(QPalette::Normal, QPalette::Link, Theme::defaultTheme()->color(Theme::LinkColor));
p.setColor(QPalette::Normal, QPalette::LinkVisited, Theme::defaultTheme()->color(Theme::VisitedLinkColor)); p.setColor(QPalette::Normal, QPalette::LinkVisited, Theme::defaultTheme()->color(Theme::VisitedLinkColor));
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }
@ -105,8 +110,9 @@ public:
QString imagePath; QString imagePath;
QString absImagePath; QString absImagePath;
Svg *svg; Svg *svg;
bool textSelectable; bool textSelectable : 1;
bool customFont; bool customFont : 1;
bool customPalette : 1;
}; };
Label::Label(QGraphicsWidget *parent) Label::Label(QGraphicsWidget *parent)
@ -115,7 +121,6 @@ Label::Label(QGraphicsWidget *parent)
{ {
QLabel *native = new QLabel; QLabel *native = new QLabel;
native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget); native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget);
d->textSelectable = false;
connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString))); connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString)));
connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString))); connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString)));
@ -332,9 +337,21 @@ void Label::paint(QPainter *painter,
void Label::changeEvent(QEvent *event) void Label::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::FontChange && font() != QApplication::font()) { switch (event->type()) {
d->customFont = true; case QEvent::FontChange:
nativeWidget()->setFont(font()); if (font() != QApplication::font()) {
d->customFont = true;
nativeWidget()->setFont(font());
}
break;
case QEvent::PaletteChange:
d->customPalette = true;
nativeWidget()->setPalette(palette());
break;
default:
break;
} }
QGraphicsProxyWidget::changeEvent(event); QGraphicsProxyWidget::changeEvent(event);

View File

@ -52,17 +52,15 @@ public:
void setPalette() void setPalette()
{ {
KLineEdit *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::ButtonTextColor); QColor color = Theme::defaultTheme()->color(Theme::ButtonTextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
native->setPalette(p); q->setPalette(p);
native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -68,17 +68,15 @@ public:
void setPalette() void setPalette()
{ {
QRadioButton *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
native->setPalette(p); q->setPalette(p);
native->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -52,9 +52,8 @@ public:
void setPalette() void setPalette()
{ {
QSpinBox *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::ButtonTextColor); QColor color = Theme::defaultTheme()->color(Theme::ButtonTextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
@ -62,10 +61,10 @@ public:
p.setColor(QPalette::Inactive, QPalette::ButtonText, color); p.setColor(QPalette::Inactive, QPalette::ButtonText, color);
p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0));
p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0));
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -223,9 +223,8 @@ void TabBarPrivate::shapeChanged(const QTabBar::Shape shape)
void TabBarPrivate::setPalette() void TabBarPrivate::setPalette()
{ {
QTabBar *native = q->nativeWidget();
QColor color = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor); QColor color = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
@ -233,10 +232,10 @@ void TabBarPrivate::setPalette()
p.setColor(QPalette::Inactive, QPalette::ButtonText, color); p.setColor(QPalette::Inactive, QPalette::ButtonText, color);
p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0));
p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0));
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -70,9 +70,8 @@ public:
void setPalette() void setPalette()
{ {
KTextBrowser *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
@ -80,10 +79,10 @@ public:
p.setColor(QPalette::Inactive, QPalette::ButtonText, color); p.setColor(QPalette::Inactive, QPalette::ButtonText, color);
p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0));
p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0));
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }

View File

@ -50,9 +50,8 @@ public:
void setPalette() void setPalette()
{ {
KTextEdit *native = q->nativeWidget();
QColor color = Theme::defaultTheme()->color(Theme::TextColor); QColor color = Theme::defaultTheme()->color(Theme::TextColor);
QPalette p = native->palette(); QPalette p = q->palette();
p.setColor(QPalette::Normal, QPalette::Text, color); p.setColor(QPalette::Normal, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color); p.setColor(QPalette::Inactive, QPalette::Text, color);
@ -60,10 +59,10 @@ public:
p.setColor(QPalette::Inactive, QPalette::ButtonText, color); p.setColor(QPalette::Inactive, QPalette::ButtonText, color);
p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0));
p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0));
native->setPalette(p); q->setPalette(p);
if (!customFont) { if (!customFont) {
q->nativeWidget()->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont)); q->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
} }
} }