[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdepim/korganizer
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2005-02-14 19:26:19
Message-ID: 20050214192619.3038D1CF33 () office ! kde ! org
[Download RAW message or body]

CVS commit by aseigo: 

don't create the colors in the ctor, as the palette may change during the
lifespan on this widget. instead just grab them from the palette when we
draw


  M +17 -18    kodaymatrix.cpp   1.60
  M +0 -16     kodaymatrix.h   1.24


--- kdepim/korganizer/kodaymatrix.h  #1.23:1.24
@@ -291,20 +291,4 @@ class KODayMatrix: public QFrame
     DynamicTip* mToolTip;
 
-
-    /** default background color of the matrix. */
-    QColor    mDefaultBackColor;
-
-    /** default text color of the matrix. */
-    QColor    mDefaultTextColor;
-
-    /** default text color for days not in the actual month. */
-    QColor    mDefaultTextColorShaded;
-
-    /** default text color for holidays not in the actual month. */
-    QColor    mHolidayColorShaded;
-
-    /** text color for selected days. */
-    QColor    mSelectedDaysColor;
-
     /** default width of the frame drawn around today if it is visible in the matrix. */
     int       mTodayMarginWidth;

--- kdepim/korganizer/kodaymatrix.cpp  #1.59:1.60
@@ -108,10 +108,4 @@ KODayMatrix::KODayMatrix( QWidget *paren
   mToolTip = new DynamicTip( this );
 
-  // set default values used for drawing the matrix
-  mDefaultBackColor = palette().active().base();
-  mDefaultTextColor = palette().active().foreground();
-  mDefaultTextColorShaded = getShadedColor( mDefaultTextColor );
-  mHolidayColorShaded = getShadedColor( KOPrefs::instance()->mHolidayColor );
-  mSelectedDaysColor = QColor( "white" );
   mTodayMarginWidth = 2;
   mSelEnd = mSelStart = NOSELECTION;
@@ -511,10 +505,12 @@ void KODayMatrix::paintEvent( QPaintEven
   bool isRTL = KOGlobals::self()->reverseLayout();
 
+  QColorGroup cg = palette().active();
+
   p.begin(  &pm, this );
-  pm.fill( mDefaultBackColor );
+  pm.fill( cg.base() );
 
   // draw topleft frame
-  p.setPen(mDefaultTextColor);
-  p.drawRect(0, 0, sz.width()+1, sz.height()+1);
+  p.setPen( cg.mid() );
+  p.drawRect(0, 0, sz.width()-1, sz.height()-1);
   // don't paint over borders
   p.translate(1,1);
@@ -548,5 +544,7 @@ void KODayMatrix::paintEvent( QPaintEven
 
   // iterate over all days in the matrix and draw the day label in appropriate colors
-  QColor actcol = mDefaultTextColorShaded;
+  QColor textColor = cg.text();
+  QColor textColorShaded = getShadedColor( textColor );
+  QColor actcol = textColorShaded;
   p.setPen(actcol);
   QPen tmppen;
@@ -557,8 +555,8 @@ void KODayMatrix::paintEvent( QPaintEven
     // if it is the first day of a month switch color from normal to shaded and vice versa
     if ( KOGlobals::self()->calendarSystem()->day( mDays[i] ) == 1) {
-      if (actcol == mDefaultTextColorShaded) {
-        actcol = mDefaultTextColor;
+      if (actcol == textColorShaded) {
+        actcol = textColor;
       } else {
-        actcol = mDefaultTextColorShaded;
+        actcol = textColorShaded;
       }
       p.setPen(actcol);
@@ -572,4 +570,5 @@ void KODayMatrix::paintEvent( QPaintEven
     bool holiday = ! KOGlobals::self()->isWorkDay( mDays[ i ] );
 
+    QColor holidayColorShaded = getShadedColor( KOPrefs::instance()->mHolidayColor );
     // if today then draw rectangle around day
     if (mToday == i) {
@@ -580,8 +579,8 @@ void KODayMatrix::paintEvent( QPaintEven
       //draw red rectangle for holidays
       if (holiday) {
-        if (actcol == mDefaultTextColor) {
+        if (actcol == textColor) {
           mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
         } else {
-          mTodayPen.setColor(mHolidayColorShaded);
+          mTodayPen.setColor(holidayColorShaded);
         }
       }
@@ -605,8 +604,8 @@ void KODayMatrix::paintEvent( QPaintEven
     // if it is a holiday then use the default holiday color
     if (holiday) {
-      if (actcol == mDefaultTextColor) {
+      if (actcol == textColor) {
         p.setPen(KOPrefs::instance()->mHolidayColor);
       } else {
-        p.setPen(mHolidayColorShaded);
+        p.setPen(holidayColorShaded);
       }
     }
@@ -615,5 +614,5 @@ void KODayMatrix::paintEvent( QPaintEven
     // DO NOT specially highlight holidays in selection !
     if (i >= mSelStart && i <= mSelEnd) {
-      p.setPen(mSelectedDaysColor);
+      p.setPen( QColor( "white" ) );
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic