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

List:       kde-core-devel
Subject:    Re: Using the selected text color in the date picker
From:       Reinhold Kainhofer <reinhold () kainhofer ! com>
Date:       2004-03-30 22:06:17
Message-ID: 200403310006.17974.reinhold () kainhofer ! com
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maks Orlovich wrote:

> On Thursday 25 March 2004 06:17 am, Reinhold Kainhofer wrote:
>> Attached is a patch that fixes the KDateTable to use the correct text
>> color for the selected text. So far, it always used white (hardcoded) for
>> the selected day, even if the system-wide color setting used a light
>> selection color and a dark selected text color. This was reported as bug
>> 78162 for korganizer, but is a general date picker bug.
>>
>> Okay to apply the patch and close the report?
[...] 
> There is actually more stuff broken than that --- thinks like:
>      painter->setPen(KGlobalSettings::highlightColor());
>      painter->setBrush(KGlobalSettings::highlightColor());
> 
> are technically wrong, as they breaks palette inheritance (and for that
> matter disabling); this should not be using KGlobalSettings but rather
> colorGroup().highlight(), etc.

Okay, so here is another patch that tries to implement using the color scheme 
in the date table. Now disabling also works (although the background color 
stays white, I'd prefer a light gray like with line edits).
The only problem is the use of KGlobalSettings::activeTitleColor() in the 
header row of the table. I didn't find any other way to get the color of the 
window title bars.
Also, the days of the previous/next months are now printed in 
colorGroup()->mid(), so that it looks lighter then colorGroup()->text(), but 
is still readable on white (brightText() is not readable, as it prints in 
white). Is there any way to get the color of disabled texts (like of a 
disabled line edit)?

Okay to commit, or do you have any objections?

Reinhold
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAae9ZTqjEwhXvPN0RAhOrAJ90qel9TMpgmN/Uf3JB7PNu0fTRDwCbBQnn
K5zxIbL4unildyCcgWxahhw=
=BrT5
-----END PGP SIGNATURE-----

["2004-03-30_DateTableUseColorScheme.patch" (text/x-diff)]

? 2004-03-30_DateTableUseColorScheme.patch
Index: kdatetbl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kdatetbl.cpp,v
retrieving revision 1.76
diff -u -p -3 -r1.76 kdatetbl.cpp
--- kdatetbl.cpp	20 Oct 2003 11:22:06 -0000	1.76
+++ kdatetbl.cpp	30 Mar 2004 21:57:43 -0000
@@ -172,7 +172,7 @@ KDateTable::paintCell(QPainter *painter,
   int w=cellWidth();
   int h=cellHeight();
   QBrush brushBlue(KGlobalSettings::activeTitleColor());
-  QBrush brushLightblue(KGlobalSettings::baseColor());
+  QBrush brushLightblue(colorGroup().base());
   QFont font=KGlobalSettings::generalFont();
   // -----
 
@@ -190,7 +190,7 @@ KDateTable::paintCell(QPainter *painter,
 
       if (!normalday)
         {
-          painter->setPen(KGlobalSettings::baseColor());
+          painter->setPen(colorGroup().base());
           painter->setBrush(brushLightblue);
           painter->drawRect(0, 0, w, h);
           painter->setPen(KGlobalSettings::activeTitleColor());
@@ -198,11 +198,11 @@ KDateTable::paintCell(QPainter *painter,
           painter->setPen(KGlobalSettings::activeTitleColor());
           painter->setBrush(brushBlue);
           painter->drawRect(0, 0, w, h);
-          painter->setPen(KGlobalSettings::activeTextColor());
+          painter->setPen(colorGroup().base());
         }
       painter->drawText(0, 0, w, h-1, AlignCenter,
                         calendar->weekDayName(daynum, true), -1, &rect);
-      painter->setPen(KGlobalSettings::textColor());
+      painter->setPen(colorGroup().text());
       painter->moveTo(0, h-1);
       painter->lineTo(w-1, h-1);
       // ----- draw the weekday:
@@ -218,7 +218,9 @@ KDateTable::paintCell(QPainter *painter,
         { // we are either
           // ° painting a day of the previous month or
           // ° painting a day of the following month
-          painter->setPen(gray);
+          // TODO: don't hardcode gray here! Use a color with less contrast to the \
background than normal text. +          painter->setPen( colorGroup().mid() );
+//          painter->setPen(gray);
         } else { // paint a day of the current month
           if ( d->useCustomColors )
           {
@@ -242,9 +244,9 @@ KDateTable::paintCell(QPainter *painter,
               }
               painter->setPen( mode->fgColor );
             } else
-              painter->setPen(KGlobalSettings::textColor());
+              painter->setPen(colorGroup().text());
           } else //if ( firstWeekDay < 4 ) // <- this doesn' make sense at all!
-          painter->setPen(KGlobalSettings::textColor());
+          painter->setPen(colorGroup().text());
         }
 
       pen=painter->pen();
@@ -253,26 +255,22 @@ KDateTable::paintCell(QPainter *painter,
       if(offset<1)
         offset+=7;
       int d = calendar->day(date);
-      if( (offset+d) == (pos+1) )
+      if( ((offset+d) == (pos+1)) && hasFocus())
         {
-          if(hasFocus())
-            { // draw the currently selected date
-              painter->setPen(KGlobalSettings::highlightColor());
-              painter->setBrush(KGlobalSettings::highlightColor());
-              pen=white;
-            } else {
-              painter->setPen(KGlobalSettings::calculateAlternateBackgroundColor(KGlobalSettings::highlightColor()));
                
-              painter->setBrush(KGlobalSettings::calculateAlternateBackgroundColor(KGlobalSettings::highlightColor()));
                
-              pen=white;
-            }
+           // draw the currently selected date
+           painter->setPen(colorGroup().highlight());
+           painter->setBrush(colorGroup().highlight());
+           pen=colorGroup().highlightedText();
         } else {
-          painter->setBrush(KGlobalSettings::baseColor());
-          painter->setPen(KGlobalSettings::baseColor());
+          painter->setBrush(paletteBackgroundColor());
+          painter->setPen(paletteBackgroundColor());
+//          painter->setBrush(colorGroup().base());
+//          painter->setPen(colorGroup().base());
         }
 
       if ( pCellDate == QDate::currentDate() )
       {
-         painter->setPen(KGlobalSettings::textColor());
+         painter->setPen(colorGroup().text());
       }
 
       if ( paintRect ) painter->drawRect(0, 0, w, h);



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

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