[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: KDE/kdelibs/kdeui/colors
From: Matthew Woehlke <mw_triad () users ! sourceforge ! net>
Date: 2007-08-28 1:23:53
Message-ID: 1188264233.009462.11345.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 705482 by mwoehlke:
As Casper boemann pointed out, we need to allow Active and Inactive color states (see \
QPalette::ColorGroup) to be different in KDE4. This means that KColorScheme needs to \
consider the color state. To that end, the previous constructor is deprecated in \
preference of a new one that takes a QPalette::ColorGroup.
(QPalette is currently missing Inactive+Disabled, but until Qt adds it there isn't a \
lot of point in us trying to support it. By using QPalette's enum, we can track Qt \
changes more easily, and we also make the API simpler to use.)
Currently the parameter is ignored; the KCS guts need some refactoring to be able to \
use it effectively for what I have in mind.
Probably coming soon: convenience overloads that get the current color group from a \
QPalette or QWidget (shout if you know you want one or both... use cases please!).
CCMAIL: kde-core-devel@kde.org
CCMAIL: kde-devel@kde.org
M +37 -7 kcolorscheme.cpp
M +15 -1 kcolorscheme.h
--- trunk/KDE/kdelibs/kdeui/colors/kcolorscheme.cpp #705481:705482
@@ -74,7 +74,7 @@
class KColorSchemePrivate : public QSharedData
{
public:
- explicit KColorSchemePrivate(const KSharedConfigPtr&, const char*, \
DefaultColors); + explicit KColorSchemePrivate(const KSharedConfigPtr&, \
QPalette::ColorGroup, const char*, DefaultColors);
QColor background(KColorScheme::BackgroundRole) const;
QColor foreground(KColorScheme::ForegroundRole) const;
@@ -86,10 +86,16 @@
qreal _contrast;
};
-KColorSchemePrivate::KColorSchemePrivate(const KSharedConfigPtr &config, const char \
*group, DefaultColors defaults) +KColorSchemePrivate::KColorSchemePrivate(const \
KSharedConfigPtr &config, + \
QPalette::ColorGroup state, + const char \
*group, + DefaultColors defaults)
: _config( config, group ), _defaults( defaults )
{
_contrast = KGlobalSettings::contrastF( config );
+
+ // TODO do something with state, means we need to cache the config values
+ // up-front so we can fiddle with them
}
#define DEFAULT(a) QColor( _defaults.a[0], _defaults.a[1], _defaults.a[2] )
@@ -176,27 +182,51 @@
KColorScheme::KColorScheme(ColorSet set, KSharedConfigPtr config)
{
+ // bleh, copied code, a good reason for this ctor to go away
if (!config) {
config = KGlobal::config();
}
switch (set) {
case Window:
- d = new KColorSchemePrivate(config, "Colors:Window", \
defaultWindowColors); + d = new KColorSchemePrivate(config, \
QPalette::Active, "Colors:Window", defaultWindowColors); break;
case Button:
- d = new KColorSchemePrivate(config, "Colors:Button", \
defaultButtonColors); + d = new KColorSchemePrivate(config, \
QPalette::Active, "Colors:Button", defaultButtonColors); break;
case Selection:
- d = new KColorSchemePrivate(config, "Colors:Selection", \
defaultSelectionColors); + d = new KColorSchemePrivate(config, \
QPalette::Active, "Colors:Selection", defaultSelectionColors); break;
case Tooltip:
- d = new KColorSchemePrivate(config, "Colors:Tooltip", \
defaultTooltipColors); + d = new KColorSchemePrivate(config, \
QPalette::Active, "Colors:Tooltip", defaultTooltipColors); break;
default:
- d = new KColorSchemePrivate(config, "Colors:View", defaultViewColors);
+ d = new KColorSchemePrivate(config, QPalette::Active, "Colors:View", \
defaultViewColors); }
}
+KColorScheme::KColorScheme(QPalette::ColorGroup state, ColorSet set, \
KSharedConfigPtr config) +{
+ if (!config) {
+ config = KGlobal::config();
+ }
+ switch (set) {
+ case Window:
+ d = new KColorSchemePrivate(config, state, "Colors:Window", \
defaultWindowColors); + break;
+ case Button:
+ d = new KColorSchemePrivate(config, state, "Colors:Button", \
defaultButtonColors); + break;
+ case Selection:
+ d = new KColorSchemePrivate(config, state, "Colors:Selection", \
defaultSelectionColors); + break;
+ case Tooltip:
+ d = new KColorSchemePrivate(config, state, "Colors:Tooltip", \
defaultTooltipColors); + break;
+ default:
+ d = new KColorSchemePrivate(config, state, "Colors:View", \
defaultViewColors); + }
+}
+
QBrush KColorScheme::background(BackgroundRole role) const
{
return QBrush( d->background( role ) );
--- trunk/KDE/kdelibs/kdeui/colors/kcolorscheme.h #705481:705482
@@ -25,6 +25,8 @@
#include <QtCore/QExplicitlySharedDataPointer>
+#include <QtGui/QPalette>
+
class KConfigBase;
class QColor;
class QBrush;
@@ -257,10 +259,22 @@
/**
* Construct a palette from given color set, using the colors from the
* given KConfig (if null, the system colors are used).
+ *
+ * @deprecated Use the other constructor that takes a state.
+ * In KDE4 it will not be safe to assume that the palette for different
+ * states (Active, Inactive, Disabled as of Qt 4.3) are identical.
+ * Therefore users <i>really should</i> specify a state. This constructor
+ * will most likely be removed before 4.0 final.
*/
- explicit KColorScheme(ColorSet = View, KSharedConfigPtr = KSharedConfigPtr());
+ explicit KDE_CONSTRUCTOR_DEPRECATED KColorScheme(ColorSet = View, \
KSharedConfigPtr = KSharedConfigPtr());
/**
+ * Construct a palette from given color set and state, using the colors
+ * from the given KConfig (if null, the system colors are used).
+ */
+ explicit KDE_CONSTRUCTOR_DEPRECATED KColorScheme(QPalette::ColorGroup, ColorSet \
= View, KSharedConfigPtr = KSharedConfigPtr()); +
+ /**
* Retrieve the requested background brush.
*/
QBrush background(BackgroundRole = NormalBackground) const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic