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

List:       kde-commits
Subject:    [kdelibs/frameworks] staging/frameworkintegration: Notify about palette changes
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2013-10-07 17:12:14
Message-ID: E1VTELu-0003bR-6k () scm ! kde ! org
[Download RAW message or body]

Git commit 240b44cf8a47469bff502ba65ecaf248bb127cab by Aleix Pol.
Committed on 07/10/2013 at 12:20.
Pushed by apol into branch 'frameworks'.

Notify about palette changes

Make sure the application can react to changes in the application's
defaults regarding palette, when using the kde platform plugin.

REVIEW: 113112

M  +24   -9    staging/frameworkintegration/autotests/kdeplatformtheme_unittest.cpp
M  +5    -3    staging/frameworkintegration/src/platformtheme/khintssettings.cpp

http://commits.kde.org/kdelibs/240b44cf8a47469bff502ba65ecaf248bb127cab

diff --git a/staging/frameworkintegration/autotests/kdeplatformtheme_unittest.cpp \
b/staging/frameworkintegration/autotests/kdeplatformtheme_unittest.cpp index \
                417e9e1..f53c0a4c 100644
--- a/staging/frameworkintegration/autotests/kdeplatformtheme_unittest.cpp
+++ b/staging/frameworkintegration/autotests/kdeplatformtheme_unittest.cpp
@@ -53,22 +53,35 @@ static void prepareEnvironment()
 
 Q_COREAPP_STARTUP_FUNCTION(prepareEnvironment);
 
-class QTestToolButton : public QToolButton
+class EventTest : public QObject
 {
-    virtual bool event(QEvent* e)
+public:
+    EventTest(QObject* tested, QEvent::Type type)
+        : QObject(), gotEvent(false), m_type(type)
     {
-        if (e->type() == QEvent::StyleChange) {
+        tested->installEventFilter(this);
+
+    }
+
+    virtual bool eventFilter(QObject*, QEvent* e)
+    {
+        if (e->type() == m_type) {
             gotEvent = true;
         }
-        return QToolButton::event(e);
+        return false;
     }
-    public:
-        bool gotEvent;
+
+    bool gotEvent;
+    QEvent::Type m_type;
 };
 
 class KdePlatformTheme_UnitTest : public QObject
 {
     Q_OBJECT
+    public:
+        KdePlatformTheme_UnitTest()
+        {}
+
     private:
         void sendNotifyChange(KHintsSettings::ChangeType type, int arg = -1)
         {
@@ -83,13 +96,12 @@ class KdePlatformTheme_UnitTest : public QObject
         }
 
         QEventLoop m_loop;
-        QTestToolButton m_toolBtn;
+        QToolButton m_toolBtn;
         KdePlatformTheme *m_qpa;
     private Q_SLOTS:
         void initTestCase()
         {
             m_qpa = new KdePlatformTheme();
-            m_toolBtn.gotEvent = false;
             QDBusConnection::sessionBus().connect(QString(), "/KGlobalSettings", \
                "org.kde.KGlobalSettings",
                                                    "notifyChange",  &m_loop, \
SLOT(quit()));  }
@@ -179,6 +191,7 @@ class KdePlatformTheme_UnitTest : public QObject
 
         void testPlatformHintChanges()
         {
+            EventTest tester(&m_toolBtn, QEvent::StyleChange);
             sendNotifyChange(KHintsSettings::SettingsChanged, \
KHintsSettings::SETTINGS_QT);  m_loop.exec();
 
@@ -199,7 +212,7 @@ class KdePlatformTheme_UnitTest : public QObject
             m_loop.exec();
 
             QCOMPARE(m_qpa->themeHint(QPlatformTheme::ToolButtonStyle).toInt(), \
                (int) Qt::ToolButtonTextUnderIcon);
-            QCOMPARE(m_toolBtn.gotEvent, true);
+            QCOMPARE(tester.gotEvent, true);
 
             sendNotifyChange(KHintsSettings::StyleChanged, 2);
             m_loop.exec();
@@ -221,8 +234,10 @@ class KdePlatformTheme_UnitTest : public QObject
 
         void testPlatformPaletteChanges()
         {
+            EventTest tester(QGuiApplication::instance(), \
QEvent::ApplicationPaletteChange);  sendNotifyChange(KHintsSettings::PaletteChanged, \
0);  m_loop.exec();
+            QCOMPARE(tester.gotEvent, true);
 
             const QPalette *palette = m_qpa->palette();
             QPalette::ColorGroup states[3] = {QPalette::Active, QPalette::Inactive, \
                QPalette::Disabled};
diff --git a/staging/frameworkintegration/src/platformtheme/khintssettings.cpp \
b/staging/frameworkintegration/src/platformtheme/khintssettings.cpp index \
                5d5bf82..31e6430 100644
--- a/staging/frameworkintegration/src/platformtheme/khintssettings.cpp
+++ b/staging/frameworkintegration/src/platformtheme/khintssettings.cpp
@@ -126,9 +126,11 @@ void KHintsSettings::slotNotifyChange(int type, int arg)
     KConfigGroup cg(ptr, "KDE");
 
     switch(type) {
-    case PaletteChanged:
+    case PaletteChanged: {
         loadPalettes();
-        break;
+        QEvent ev(QEvent::ApplicationPaletteChange);
+        QGuiApplication::sendEvent(QGuiApplication::instance(), &ev);
+    }   break;
     case SettingsChanged: {
 
         SettingsCategory category = static_cast<SettingsCategory>(arg);
@@ -254,4 +256,4 @@ void KHintsSettings::loadPalettes()
 
     KSharedConfig::Ptr globals = KSharedConfig::openConfig("kdeglobals");
     m_palettes[QPlatformTheme::SystemPalette] = new \
                QPalette(KColorScheme::createApplicationPalette(globals));
-}
\ No newline at end of file
+}


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

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