background-color of the lyrics-applet
Thomas Lübking
thomas.luebking at web.de
Fri Oct 16 22:37:18 CEST 2009
Am Friday 16 October 2009 schrieb Martin:
> here's his code to get the background-color:
> > QColor bg = App::instance()->palette().highlight().color();
> > qreal value = bg.valueF() > 0.5 ? 1.0 : 0.1;
> > bg.setHsvF( bg.hueF(), 0.07, value, bg.alphaF() );
>
> whereas I used this as background-color:
> > App::instance()->palette().background().color();
by 99% chance this refers to QPalette::Window, the major flaw here is the
usage of
App::instance()->palette()
One should not use some random mystique code to paint a background (unless one
has 100% control about the fg as well, of course)
Therefore:
> QColor bg = App::instance()->palette().highlight().color();
> qreal value = bg.valueF() > 0.5 ? 1.0 : 0.1;
> bg.setHsvF( bg.hueF(), 0.07, value, bg.alphaF() );
...is bad.
It should be more like:
QWidget *myFancyWidget(parent);
QPalette pal = myFancyWidget->palette();
QColor bg = pal.color(QPalette::Highlight);
qreal value = bg.valueF() > 0.5 ? 1.0 : 0.1;
bg.setHsvF( bg.hueF(), 0.07, value, bg.alphaF() );
pal.setColor(QPalette::Highlight, bg);
myFancyWidget->setPalette(pal);
// and *especially*
myFancyWidget->setBackgroundRole(QPalette::Highlight);
myFancyWidget->setForegroundRole(QPalette::HighlightedText);
and just paint
myFancyWidget->palette().background().color();
This way the widget carries information about it's background for further
usage.
> maybe someone has an idea how to make it good-looking
> for both, light and dark color schemes
The above should fix /this/ color/palette issue (there're more, trust me) but
ähemm... to make it look /good/ one should just not bring in (an altered/the)
highlight color at all but just paint QPalette::Base / QPalette::Text ;-)
E.g. i run a pretty dark style on amarok, and i've got a big fat bright blue
square in my dark setup... ewww :-\
This makes the whole context area look dull - to avoid a the word c*** :-(
Regards,
Thomas
More information about the Amarok-devel
mailing list