[Kstars-devel] Kstars-devel] switching to night vision

Heiko Evermann Heiko.Evermann at gmx.de
Wed Feb 18 23:42:48 CET 2004


Hi Jason, hi everyone,

>We *can* modify the window colors of just the window(s) that belong to KStars 
>using QApplication::setPalette().  Thus, if the user chooses night vision 
>colors and uses full-screen mode, they'll have a fully night-vision friendly 
>desktop (except for the kicker panel).
>
I just tried it:

//Help Menu
void KStars::slotTipOfDay() {
//    KTipDialog::showTip("kstars/tips", true);
// let's build some palette
        QPalette p( QColor( 75, 123, 130 ) );

        // active block
        p.setColor( QPalette::Active, QColorGroup::Foreground, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Button, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Light, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Midlight, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Dark, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Mid,Qt::white );
            p.setColor( QPalette::Active, QColorGroup::Text, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::BrightText, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::ButtonText, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Base, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Background, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Shadow,Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Highlight, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::HighlightedText, 
Qt::white );
        p.setColor( QPalette::Active, QColorGroup::Link, Qt::white );
        p.setColor( QPalette::Active, QColorGroup::LinkVisited,Qt::white );
        // inactive block
        p.setColor( QPalette::Inactive, QColorGroup::Foreground, 
Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Button, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Light, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Midlight, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Dark, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Mid,Qt::white );
            p.setColor( QPalette::Inactive, QColorGroup::Text, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::BrightText, 
Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::ButtonText, 
Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Base, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Background, 
Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Shadow,Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Highlight, Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::HighlightedText, 
Qt::white );
        p.setColor( QPalette::Inactive, QColorGroup::Link, Qt::white );
        p.setColor( QPalette::Inactive, 
QColorGroup::LinkVisited,Qt::white );
       
        // disabled block
        p.setColor( QPalette::Disabled, QColorGroup::Foreground, 
Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Button, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Light, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Midlight, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Dark, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Mid,Qt::white );
            p.setColor( QPalette::Disabled, QColorGroup::Text, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::BrightText, 
Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::ButtonText, 
Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Base, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Background, 
Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Shadow,Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Highlight, Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::HighlightedText, 
Qt::white );
        p.setColor( QPalette::Disabled, QColorGroup::Link, Qt::white );
        p.setColor( QPalette::Disabled, 
QColorGroup::LinkVisited,Qt::white );

        kapp->setPalette( p, TRUE /* inform widgets*/  );
   
}
This is based on qt/examples/themes/themes.cpp. But in the example some 
entries are missing, so that not all is white. The list above is quite 
efficient. I then tried Qt::black. Here one can still see some 
differences of black. So maybe there is some adjustment code hidden 
somewhere in KDE or QT to force a minimum contrast. But whith this 
knowledge, it should be possible to define a night vision color scheme 
for menu, toolbar etc.

I think it is not feasable to offer the user the possibility to edit 
each color. That would be overkill. Perhaps this could be grouped and 
limited to just about 4 colors for menus etc, plus the different star 
colours from the night view color scheme. Any ideas how the options 
dialogs should look like?

We should also offer a toggle button to access night view.

If you try full screen and the code above, you get a screen in black and 
red. And if you then switch to other applications using ALT-Tab, you can 
see that only kstars is affected.

One would have to save the current palette before overwriting it, to be 
able to change back.

So much for today.

Try it and tell me what you think.

Kind regards,

Heiko



More information about the Kstars-devel mailing list