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

List:       kde-commits
Subject:    [kdelibs/frameworks] staging/frameworkintegration/src/platformtheme: Move all palette logic to
From:       Àlex_Fiestas <afiestas () kde ! org>
Date:       2013-08-31 17:09:42
Message-ID: E1VFogA-00080f-RU () scm ! kde ! org
[Download RAW message or body]

Git commit c06e978c21deea4362143ca98023df27b727a839 by Àlex Fiestas.
Committed on 31/08/2013 at 15:29.
Pushed by afiestas into branch 'frameworks'.

Move all palette logic to KHintsSettings

Palettes use the same system that we use for Hints, and in KHintsSettings
we do more than Hints already, so I will rename that class to something
more generic.

At the moment, just moving the palette logic to it.

M  +3    -15   staging/frameworkintegration/src/platformtheme/kdeplatformtheme.cpp
M  +0    -2    staging/frameworkintegration/src/platformtheme/kdeplatformtheme.h
M  +20   -0    staging/frameworkintegration/src/platformtheme/khintssettings.cpp
M  +11   -0    staging/frameworkintegration/src/platformtheme/khintssettings.h

http://commits.kde.org/kdelibs/c06e978c21deea4362143ca98023df27b727a839

diff --git a/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.cpp \
b/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.cpp index \
                8a76fe5..dd7cfef 100644
--- a/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.cpp
+++ b/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.cpp
@@ -45,7 +45,6 @@ KdePlatformTheme::~KdePlatformTheme()
 {
     delete m_fontsData;
     delete m_hints;
-    qDeleteAll(m_palettes);
 }
 
 QVariant KdePlatformTheme::themeHint(QPlatformTheme::ThemeHint hintType) const
@@ -60,9 +59,9 @@ QVariant KdePlatformTheme::themeHint(QPlatformTheme::ThemeHint \
hintType) const  
 const QPalette *KdePlatformTheme::palette(Palette type) const
 {
-    QHash<Palette, QPalette*>::const_iterator it = m_palettes.constFind(type);
-    if (it != m_palettes.constEnd())
-        return *it;
+    QPalette *palette = m_hints->palette(type);
+    if (palette)
+        return palette;
     else
         return QPlatformTheme::palette(type);
 }
@@ -111,17 +110,6 @@ QIconEngine *KdePlatformTheme::createIconEngine(const QString \
&iconName) const  
 void KdePlatformTheme::loadSettings()
 {
-    loadPalettes();
-
     m_fontsData = new KFontSettingsData;
     m_hints = new KHintsSettings;
 }
-
-void KdePlatformTheme::loadPalettes()
-{
-    qDeleteAll(m_palettes);
-    m_palettes.clear();
-
-    KSharedConfig::Ptr globals = KSharedConfig::openConfig("kdeglobals");
-    m_palettes[SystemPalette] = new \
                QPalette(KColorScheme::createApplicationPalette(globals));
-}
diff --git a/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.h \
b/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.h index \
                2d9d2af..381b07a 100644
--- a/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.h
+++ b/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.h
@@ -43,11 +43,9 @@ public:
 
 private:
     void loadSettings();
-    void loadPalettes();
     void iconChanged(int group);
 
     KHintsSettings *m_hints;
-    QHash<Palette, QPalette*> m_palettes;
     KFontSettingsData* m_fontsData;
 };
 
diff --git a/staging/frameworkintegration/src/platformtheme/khintssettings.cpp \
b/staging/frameworkintegration/src/platformtheme/khintssettings.cpp index \
                4774140..7c6d26c 100644
--- a/staging/frameworkintegration/src/platformtheme/khintssettings.cpp
+++ b/staging/frameworkintegration/src/platformtheme/khintssettings.cpp
@@ -27,6 +27,7 @@
 #include <QString>
 #include <QFileInfo>
 #include <QToolBar>
+#include <QPalette>
 #include <QToolButton>
 #include <QMainWindow>
 #include <QApplication>
@@ -83,6 +84,13 @@ KHintsSettings::KHintsSettings() : QObject(0)
                                                    QStringLiteral("notifyChange"), \
this, SLOT(slotNotifyChange(int, int)));  
     QMetaObject::invokeMethod(this, "setupIconLoader", Qt::QueuedConnection);
+
+    loadPalettes();
+}
+
+KHintsSettings::~KHintsSettings()
+{
+    qDeleteAll(m_palettes);
 }
 
 QStringList KHintsSettings::xdgIconThemePaths() const
@@ -118,6 +126,9 @@ void KHintsSettings::slotNotifyChange(int type, int arg)
     KConfigGroup cg(ptr, "KDE");
 
     switch(type) {
+    case PaletteChanged:
+        loadPalettes();
+        break;
     case SettingsChanged: {
 
         SettingsCategory category = static_cast<SettingsCategory>(arg);
@@ -235,3 +246,12 @@ Qt::ToolButtonStyle KHintsSettings::toolButtonStyle(const \
                KConfigGroup& cg) cons
                              : buttonStyle == "textonly" ? Qt::ToolButtonTextOnly
                              : Qt::ToolButtonIconOnly;
 }
+
+void KHintsSettings::loadPalettes()
+{
+    qDeleteAll(m_palettes);
+    m_palettes.clear();
+
+    KSharedConfig::Ptr globals = KSharedConfig::openConfig("kdeglobals");
+    m_palettes[QPlatformTheme::SystemPalette] = new \
QPalette(KColorScheme::createApplicationPalette(globals)); +}
\ No newline at end of file
diff --git a/staging/frameworkintegration/src/platformtheme/khintssettings.h \
b/staging/frameworkintegration/src/platformtheme/khintssettings.h index \
                36212bb..f02e59d 100644
--- a/staging/frameworkintegration/src/platformtheme/khintssettings.h
+++ b/staging/frameworkintegration/src/platformtheme/khintssettings.h
@@ -28,6 +28,7 @@
 
 #include <ksharedconfig.h>
 
+class QPalette;
 class KHintsSettings : public QObject
 {
     Q_OBJECT
@@ -48,22 +49,32 @@ class KHintsSettings : public QObject
                             SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS,
                             SETTINGS_LOCALE, SETTINGS_STYLE };
         explicit KHintsSettings();
+        virtual ~KHintsSettings();
 
         inline QVariant hint(QPlatformTheme::ThemeHint hint)
         {
             return m_hints[hint];
         }
+        inline QPalette* palette(QPlatformTheme::Palette type)
+        {
+            if (!m_palettes.contains(type)) {
+                return 0;
+            }
+            return m_palettes[type];
+        }
 
     private Q_SLOTS:
         void setupIconLoader();
         void slotNotifyChange(int type, int arg);
 
     private:
+        void loadPalettes();
         void iconChanged(int group);
         void updateQtSettings(KConfigGroup &cg);
         Qt::ToolButtonStyle toolButtonStyle(const KConfigGroup &cg) const;
 
         QStringList xdgIconThemePaths() const;
+        QHash<QPlatformTheme::Palette, QPalette*> m_palettes;
         QHash<QPlatformTheme::ThemeHint, QVariant> m_hints;
 };
 


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

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