QPalette::ColorGroup and KColorScheme

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Aug 13 20:42:01 BST 2007


On IRC, Casper Boemann pointed out that KColorScheme does not have any 
concept of widget state (active, inactive, disabled), and that the 
oxygen style will be making serious use of these. Well, this is news to 
me, possibly the first time anyone has ever really cared, but it's 
something that should be addressed.

Yes, this will mean more UI and more knobs for users to play with, and 
yes it means we will have 240 colors in out color schemes, although I do 
NOT intend to allow these to be set (as opposed to calculated); this 
does not change that most users only need to care about ~15 colors. 
Anyway I'm not even sure how much of the needed code will make 4.0 (IMO 
there are more important fish to fry) but this is all BC/SC stuff anyway.

More important is the SIC, which is that users really ought to say what 
QPalette::ColorGroup they are using (oh, and Qt seems to have forgotten 
about inactive+disabled). So I'm inclined to change the KColorScheme 
ctor to require an enum to specify this (alternatively it can be 
optional). Convenience ctors, e.g. taking a QPalette or even QWidget 
(assuming I can get the correct result from them) can be considered.

I talked to winterz, who told me to add this to 
http://techbase.kde.org/Projects/kdelibs (done); now I am asking for 
other thoughts on the best way to do this.

For people that like code, here is the proposal:

Index: kcolorscheme.h
===================================================================
--- kcolorscheme.h      (revision 699557)
+++ kcolorscheme.h      (working copy)
@@ -57,6 +57,14 @@
  class KDEUI_EXPORT KColorScheme {
  public:

+    enum ColorState {
+        ActiveState = 0x0,
+        InactiveState = 0x1,
+        DisabledState = 0x2,
+        InactiveDisabledState = InactiveState|DisabledState,
+        NormalState = ActiveState
+    };
+
      /**
       * This enumeration describes the color set for which a color is 
      * being selected.
@@ -258,7 +266,7 @@
       * Construct a palette from given color set, using the colors from
       * the given KConfig (if null, the system colors are used).
       */
-    explicit KColorScheme(ColorSet = View,
+    explicit KColorScheme(QPalette::ColorGroup, ColorSet = View,
                            KSharedConfigPtr = KSharedConfigPtr());

      /**
       * Retrieve the requested background brush.

Again, for the moment the extra param is going to be ignored, it is 
eventually needed (but not sure how quickly I can write code for it), 
but the point is that KCS users should think about what color state 
(normal/inactive/disabled) they are in.

-- 
Matthew
People say I'm going insane. I say, "what do you mean, 'going'?".





More information about the kde-core-devel mailing list