On Tuesday 11 November 2008, Aaron J. Seigo wrote:
> On Tuesday 11 November 2008, Davide Bettio wrote:
> > Are we going to put use it as default for KDE 4.2? I hope no.
>
> i'm not a fan of it either. nor is it really what i was hoping for. =/

just to consider all available options, here is an attempt of using different 
colors in different places for now based on formfactor (could be also 
something else like a new enum)

problem is would require changing pretty much every applet around there and 
all places where theme::color is used should be available something like the 
applet, the containment or at least something that can make context, 
inaccessible from widgets

Cheers,
Marco Martin
Index: theme.h
===================================================================
--- theme.h	(revision 883112)
+++ theme.h	(working copy)
@@ -26,6 +26,7 @@
 
 #include <ksharedconfig.h>
 
+#include <plasma/plasma.h>
 #include <plasma/plasma_export.h>
 #include <plasma/packagestructure.h>
 
@@ -137,7 +138,7 @@
          *
          * @arg role which role (usage pattern) to get the color for
          */
-        Q_INVOKABLE QColor color(ColorRole role) const;
+        Q_INVOKABLE QColor color(ColorRole role, Plasma::FormFactor context = Plasma::Planar) const;
 
         /**
          * Sets the default font to be used with themed items. Defaults to
Index: theme.cpp
===================================================================
--- theme.cpp	(revision 883112)
+++ theme.cpp	(working copy)
@@ -55,6 +55,8 @@
         : q(theme),
           colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)),
           buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(0)),
+          panelColorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)),
+          panelButtonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(0)),
           defaultWallpaperTheme(DEFAULT_WALLPAPER_THEME),
           defaultWallpaperSuffix(DEFAULT_WALLPAPER_SUFFIX),
           defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH),
@@ -109,8 +111,11 @@
     Theme *q;
     QString themeName;
     KSharedConfigPtr colors;
+    KSharedConfigPtr panelColors;
     KColorScheme colorScheme;
     KColorScheme buttonColorScheme;
+    KColorScheme panelColorScheme;
+    KColorScheme panelButtonColorScheme;
     KConfigGroup cfg;
     QFont generalFont;
     QString defaultWallpaperTheme;
@@ -263,6 +268,7 @@
     // load the color scheme config
     QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + "/colors");
     //kDebug() << "we're going for..." << colorsFile << "*******************";
+    QString panelColorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + "/panelcolors");
 
     // load the wallpaper settings, if any
     QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" + theme + "/metadata.desktop"));
@@ -292,9 +298,17 @@
     } else {
         d->colors = KSharedConfig::openConfig(colorsFile);
     }
+    if (panelColorsFile.isEmpty()) {
+        d->panelColors = d->colors;
+    } else {
+        d->panelColors = KSharedConfig::openConfig(panelColorsFile);
+    }
 
     d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->colors);
     d->buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, d->colors);
+    d->panelColorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->panelColors);
+    d->panelButtonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, d->panelColors);
+
     d->hasWallpapers =
         !KStandardDirs::locate("data", "desktoptheme/" + theme + "/wallpapers").isEmpty();
 
@@ -432,27 +446,44 @@
     return d->colors;
 }
 
-QColor Theme::color(ColorRole role) const
+QColor Theme::color(ColorRole role, Plasma::FormFactor context) const
 {
+    KColorScheme *scheme;
+    KColorScheme *buttonScheme;
+
+    //probably we would need a new type ColorContext
+    switch (context) {
+    case Plasma::Vertical:
+    case Plasma::Horizontal:
+        scheme = &d->panelColorScheme;
+        buttonScheme = &d->panelButtonColorScheme;
+        break;
+    case Plasma::Planar:
+    default:
+        scheme = &d->colorScheme;
+        buttonScheme = &d->buttonColorScheme;
+        break;
+    }
+
     switch (role) {
         case TextColor:
-            return d->colorScheme.foreground(KColorScheme::NormalText).color();
+            return scheme->foreground(KColorScheme::NormalText).color();
             break;
 
         case HighlightColor:
-            return d->colorScheme.background(KColorScheme::ActiveBackground).color();
+            return scheme->background(KColorScheme::ActiveBackground).color();
             break;
 
         case BackgroundColor:
-            return d->colorScheme.background().color();
+            return scheme->background().color();
             break;
 
         case ButtonTextColor:
-            return d->buttonColorScheme.foreground(KColorScheme::NormalText).color();
+            return buttonScheme->foreground(KColorScheme::NormalText).color();
             break;
 
         case ButtonBackgroundColor:
-            return d->buttonColorScheme.background(KColorScheme::ActiveBackground).color();
+            return buttonScheme->background(KColorScheme::ActiveBackground).color();
             break;
     }
 
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to