[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Sun Mar 21 08:39:14 CET 2004


CVS commit by harris: 

Improved Night Vision color scheme (wish #43595).  Now when Night Vision 
is selected as the color scheme, the color scheme of the GUI widgets in 
KStars windows is adjusted as well.  Thus, in fullscreen mode, KStars is 
now completely friendly to dark-adapted vision.  The original UI colors 
are restored when you change to a different scheme.

Caveats:

+ We will not be adjusting the colors of the entire desktop, just the 
KStars windows.  Nor will we be adjusting the user's 
background/wallpaper.  We decided this was just a rude thing to do.  We 
will, however, provide a KDE color scheme for dark-adapted vision, that 
the user may activate themselves if they wish.  (Although even this 
solution has some problems; some apps don't respect the global color 
scheme: i.e., kate). 

+ icons are still bright colors.  I guess there is nothing to be done 
about this either.

+ What about window decorations?  I don't know if their colors can be 
adjusted for only a single app's windows.  Indeed, I don't know anything 
about adjusting decorations programatically!  ANyone have a clue-bat? :)

CCMAIL: 43595-done at bugs.kde.org
CCMAIL: kstars-devel at kde.org


  M +13 -0     kstars.cpp   1.79
  M +2 -0      kstars.h   1.67
  M +5 -0      kstars.kcfg   1.7
  M +18 -0     kstarsactions.cpp   1.90


--- kdeedu/kstars/kstars/kstars.cpp  #1.78:1.79
@@ -25,4 +25,5 @@
 //#include <iostream.h>
 #include <kdebug.h>
+#include <qpalette.h>
 
 #include "finddialog.h"
@@ -65,5 +66,17 @@ KStars::KStars( bool doSplash ) :
                         Options::timeZone(), &(it.data()), 4, Options::elevation() ) );
 
+        //set up Dark color scheme for application windows
+        DarkPalette = QPalette(QColor("red4"), QColor("DarkRed"));
+        DarkPalette.setColor( QPalette::Normal, QColorGroup::Base, QColor( "black" ) );
+        DarkPalette.setColor( QPalette::Normal, QColorGroup::Text, QColor( "red2" ) );
+        DarkPalette.setColor( QPalette::Normal, QColorGroup::Highlight, QColor( "red2" ) );
+        DarkPalette.setColor( QPalette::Normal, QColorGroup::HighlightedText, QColor( "black" ) );
+        
+        //set color scheme
+        OriginalPalette = QApplication::palette();
         pd->kstarsData->colorScheme()->loadFromConfig( kapp->config() );
+        if ( Options::darkAppColors() ) {
+                QApplication::setPalette( DarkPalette, true );
+        }
 
         #if ( __GLIBC__ >= 2 &&__GLIBC_MINOR__ >= 1 )

--- kdeedu/kstars/kstars/kstars.h  #1.66:1.67
@@ -57,4 +57,5 @@
 
 // forward declaration is enough. We only need pointers
+class QPalette;
 class KDialogBase;
 class KKey;
@@ -407,4 +408,5 @@ class KStars : public KMainWindow, virtu
                 int idSpinBox;
                 bool DialogIsObsolete;
+                QPalette OriginalPalette, DarkPalette;
 
                 class privatedata;

--- kdeedu/kstars/kstars/kstars.kcfg  #1.6:1.7
@@ -602,4 +602,9 @@
 
         <group name="Colors">
+                <entry name="DarkAppColors" type="Bool">
+                        <label>Use Dark colors for KStars windows?</label>
+                        <default>false</default>
+                        <whatsthis>If true, then the aplication window colors will be switched to a dark red theme, for better night vision.</whatsthis>
+                </entry>
                 <entry name="AngularRulerColor" type="Color">
                         <label>Color of angular distance ruler</label>

--- kdeedu/kstars/kstars/kstarsactions.cpp  #1.89:1.90
@@ -740,4 +740,22 @@ void KStars::slotColorScheme() {
         QString filename = QString( sender()->name() ).mid(3) + ".colors";
         map()->setColors( filename );
+
+        //set the application colors for the Night Vision scheme
+        if ( Options::darkAppColors() == false && QString( sender()->name() ) == "cs_night" ) {
+                //DEBUG
+                kdDebug() << i18n("Setting Dark window colors...") << endl;
+
+                Options::setDarkAppColors( true );
+                OriginalPalette = QApplication::palette();
+                QApplication::setPalette( DarkPalette, true );
+        }
+        
+        if ( Options::darkAppColors() && QString( sender()->name() ) != "cs_night" ) {
+                //DEBUG
+                kdDebug() << i18n("Restoring original window colors...") << endl;
+
+                Options::setDarkAppColors( false );
+                QApplication::setPalette( OriginalPalette, true );
+        }
 }
 




More information about the Kstars-devel mailing list