[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkdelibs/whiting/createpalettefix=5D_kdeui/kernel=3A?=
From: Jeremy Whiting <jpwhiting () kde ! org>
Date: 2011-04-07 14:56:51
Message-ID: 20110407145651.BAA38A609B () git ! kde ! org
[Download RAW message or body]
Git commit bb133ad4464205d8be1201bb26d53407dadd2818 by Jeremy Whiting.
Committed on 07/04/2011 at 15:08.
Pushed by whiting into branch 'whiting/createpalettefix'.
Added KGlobalSettings::createNewApplicationPalette that doesn't cache.
M +48 -38 kdeui/kernel/kglobalsettings.cpp
M +14 -0 kdeui/kernel/kglobalsettings.h
http://commits.kde.org/kdelibs/bb133ad4464205d8be1201bb26d53407dadd2818
diff --git a/kdeui/kernel/kglobalsettings.cpp b/kdeui/kernel/kglobalsettings.cpp
index 21f63a9..6a0dca8 100644
--- a/kdeui/kernel/kglobalsettings.cpp
+++ b/kdeui/kernel/kglobalsettings.cpp
@@ -154,6 +154,7 @@ class KGlobalSettings::Private
}
QPalette createApplicationPalette(const KSharedConfigPtr &config);
+ QPalette createNewApplicationPalette(const KSharedConfigPtr &config);
void _k_slotNotifyChange(int, int);
void propagateQtSettings();
@@ -962,55 +963,64 @@ QPalette KGlobalSettings::createApplicationPalette(const \
KSharedConfigPtr &confi return self()->d->createApplicationPalette(config);
}
+QPalette KGlobalSettings::createNewApplicationPalette(const KSharedConfigPtr \
&config) +{
+ return self()->d->createNewApplicationPalette(config);
+}
+
QPalette KGlobalSettings::Private::createApplicationPalette(const KSharedConfigPtr \
&config) {
// This method is typically called once by KQGuiPlatformPlugin::palette and once \
again // by kdisplaySetPalette(), so we cache the palette to save time.
if (!paletteCreated) {
paletteCreated = true;
-
- QPalette palette;
-
- QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
- QPalette::Disabled };
-
- // TT thinks tooltips shouldn't use active, so we use our active colors for \
all states
- KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
-
- for ( int i = 0; i < 3 ; i++ ) {
- QPalette::ColorGroup state = states[i];
- KColorScheme schemeView(state, KColorScheme::View, config);
- KColorScheme schemeWindow(state, KColorScheme::Window, config);
- KColorScheme schemeButton(state, KColorScheme::Button, config);
- KColorScheme schemeSelection(state, KColorScheme::Selection, config);
-
- palette.setBrush( state, QPalette::WindowText, schemeWindow.foreground() \
);
- palette.setBrush( state, QPalette::Window, schemeWindow.background() );
- palette.setBrush( state, QPalette::Base, schemeView.background() );
- palette.setBrush( state, QPalette::Text, schemeView.foreground() );
- palette.setBrush( state, QPalette::Button, schemeButton.background() );
- palette.setBrush( state, QPalette::ButtonText, schemeButton.foreground() \
);
- palette.setBrush( state, QPalette::Highlight, \
schemeSelection.background() );
- palette.setBrush( state, QPalette::HighlightedText, \
schemeSelection.foreground() );
- palette.setBrush( state, QPalette::ToolTipBase, \
schemeTooltip.background() );
- palette.setBrush( state, QPalette::ToolTipText, \
schemeTooltip.foreground() );
-
- palette.setColor( state, QPalette::Light, schemeWindow.shade( \
KColorScheme::LightShade ) );
- palette.setColor( state, QPalette::Midlight, schemeWindow.shade( \
KColorScheme::MidlightShade ) );
- palette.setColor( state, QPalette::Mid, schemeWindow.shade( \
KColorScheme::MidShade ) );
- palette.setColor( state, QPalette::Dark, schemeWindow.shade( \
KColorScheme::DarkShade ) );
- palette.setColor( state, QPalette::Shadow, schemeWindow.shade( \
KColorScheme::ShadowShade ) );
-
- palette.setBrush( state, QPalette::AlternateBase, schemeView.background( \
KColorScheme::AlternateBackground) );
- palette.setBrush( state, QPalette::Link, schemeView.foreground( \
KColorScheme::LinkText ) );
- palette.setBrush( state, QPalette::LinkVisited, schemeView.foreground( \
KColorScheme::VisitedText ) );
- }
- applicationPalette = palette;
+ applicationPalette = createApplicationPalette(config);
}
return applicationPalette;
}
+QPalette KGlobalSettings::Private::createNewApplicationPalette(const \
KSharedConfigPtr &config) +{
+ QPalette palette;
+
+ QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
+ QPalette::Disabled };
+
+ // TT thinks tooltips shouldn't use active, so we use our active colors for all \
states + KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, \
config); +
+ for ( int i = 0; i < 3 ; i++ ) {
+ QPalette::ColorGroup state = states[i];
+ KColorScheme schemeView(state, KColorScheme::View, config);
+ KColorScheme schemeWindow(state, KColorScheme::Window, config);
+ KColorScheme schemeButton(state, KColorScheme::Button, config);
+ KColorScheme schemeSelection(state, KColorScheme::Selection, config);
+
+ palette.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
+ palette.setBrush( state, QPalette::Window, schemeWindow.background() );
+ palette.setBrush( state, QPalette::Base, schemeView.background() );
+ palette.setBrush( state, QPalette::Text, schemeView.foreground() );
+ palette.setBrush( state, QPalette::Button, schemeButton.background() );
+ palette.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
+ palette.setBrush( state, QPalette::Highlight, schemeSelection.background() \
); + palette.setBrush( state, QPalette::HighlightedText, \
schemeSelection.foreground() ); + palette.setBrush( state, \
QPalette::ToolTipBase, schemeTooltip.background() ); + palette.setBrush( \
state, QPalette::ToolTipText, schemeTooltip.foreground() ); +
+ palette.setColor( state, QPalette::Light, schemeWindow.shade( \
KColorScheme::LightShade ) ); + palette.setColor( state, QPalette::Midlight, \
schemeWindow.shade( KColorScheme::MidlightShade ) ); + palette.setColor( \
state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) ); + \
palette.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade \
) ); + palette.setColor( state, QPalette::Shadow, schemeWindow.shade( \
KColorScheme::ShadowShade ) ); +
+ palette.setBrush( state, QPalette::AlternateBase, schemeView.background( \
KColorScheme::AlternateBackground) ); + palette.setBrush( state, \
QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) ); + \
palette.setBrush( state, QPalette::LinkVisited, schemeView.foreground( \
KColorScheme::VisitedText ) ); + }
+ return palette;
+}
+
void KGlobalSettings::Private::kdisplaySetPalette()
{
// Added by Sam/Harald (TT) for Mac OS X initially, but why?
diff --git a/kdeui/kernel/kglobalsettings.h b/kdeui/kernel/kglobalsettings.h
index 2959feb..9130a8d 100644
--- a/kdeui/kernel/kglobalsettings.h
+++ b/kdeui/kernel/kglobalsettings.h
@@ -522,6 +522,20 @@ public:
static QPalette createApplicationPalette(const KSharedConfigPtr &config = \
KSharedConfigPtr());
/**
+ * Used to obtain the QPalette that will be used to set the application palette.
+ *
+ * This is only useful for configuration modules such as krdb and should not be
+ * used in normal circumstances.
+ * @param config KConfig from which to load the colors (passed as-is to
+ * ::KColorScheme).
+ *
+ * @note The difference between this and the previous is that this never caches.
+ *
+ * @return the QPalette
+ */
+ static QPalette createNewApplicationPalette(const KSharedConfigPtr &config = \
KSharedConfigPtr()); +
+ /**
* An identifier for change signals.
* \see emitChange
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic