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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/kernel
From:       David Faure <faure () kde ! org>
Date:       2010-09-22 16:56:17
Message-ID: 20100922165617.1DABFAC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1178294 by dfaure:

Don't create the app palette twice (due to the gui-platform-plugin also calling \
this), cache it.


 M  +21 -5     kglobalsettings.cpp  


--- trunk/KDE/kdelibs/kdeui/kernel/kglobalsettings.cpp #1178293:1178294
@@ -30,7 +30,6 @@
 #include <kprotocolinfo.h>
 #include <kcomponentdata.h>
 #include <kcolorscheme.h>
-#include <kapplication.h>
 
 #include <kstyle.h>
 
@@ -78,9 +77,11 @@
 //static QColor *_buttonBackground = 0;
 static KGlobalSettings::GraphicEffects _graphicEffects = KGlobalSettings::NoEffects;
 
-// KDE5: merge this with KGlobalSettings::Private
-// also think to make all methods static and not expose an object,
+// TODO: merge this with KGlobalSettings::Private
+//
+// F. Kossebau: KDE5: think to make all methods static and not expose an object,
 // making KGlobalSettings rather a namespace
+// D. Faure: how would people connect to signals, then?
 class KGlobalSettingsData
 {
   public:
@@ -148,10 +149,11 @@
 {
     public:
         Private(KGlobalSettings *q)
-            : q(q), activated(false)
+            : q(q), activated(false), paletteCreated(false)
         {
         }
 
+        QPalette createApplicationPalette(const KSharedConfigPtr &config);
         void _k_slotNotifyChange(int, int);
 
         void propagateQtSettings();
@@ -180,6 +182,8 @@
 
         KGlobalSettings *q;
         bool activated;
+        bool paletteCreated;
+        QPalette applicationPalette;
 };
 
 KGlobalSettings* KGlobalSettings::self()
@@ -952,6 +956,16 @@
 
 QPalette KGlobalSettings::createApplicationPalette(const KSharedConfigPtr &config)
 {
+    return self()->d->createApplicationPalette(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,
@@ -988,8 +1002,10 @@
         palette.setBrush( state, QPalette::Link, schemeView.foreground( \
                KColorScheme::LinkText ) );
         palette.setBrush( state, QPalette::LinkVisited, schemeView.foreground( \
KColorScheme::VisitedText ) );  }
+        applicationPalette = palette;
+    }
 
-    return palette;
+    return applicationPalette;
 }
 
 void KGlobalSettings::Private::kdisplaySetPalette()


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

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