summarylogtreecommitdiffstats
path: root/qt5ct-shenanigans.patch
blob: 48ea67f3ffbc253a431b781ab0d62bdff9d876d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Index: qt5ct/CMakeLists.txt
===================================================================
--- qt5ct/CMakeLists.txt	(revision 622)
+++ qt5ct/CMakeLists.txt	(working copy)
@@ -24,8 +24,11 @@
 
 ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=0x050C00 -DUSE_WIDGETS)
 
-find_package(Qt5 ${QT_MINIMUM_VERSION} COMPONENTS Widgets Concurrent LinguistTools DBus ThemeSupport REQUIRED)
+find_package(Qt5 ${QT_MINIMUM_VERSION} COMPONENTS Widgets Concurrent LinguistTools DBus QuickControls2 ThemeSupport REQUIRED)
 find_package(Qt5Gui ${QT_MINIMUM_VERSION} CONFIG REQUIRED Private)
+find_package(KF5Config REQUIRED)
+find_package(KF5ConfigWidgets REQUIRED)
+find_package(KF5IconThemes REQUIRED)
 
 get_target_property(QT_LRELEASE_EXECUTABLE Qt5::lrelease IMPORTED_LOCATION)
 
@@ -44,7 +47,9 @@
     message(FATAL_ERROR "Could NOT find qtpaths executable")
 endif()
 
-execute_process(COMMAND ${QT_QTPATHS_EXECUTABLE} --plugin-dir OUTPUT_VARIABLE PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(NOT PLUGINDIR)
+    execute_process(COMMAND ${QT_QTPATHS_EXECUTABLE} --plugin-dir OUTPUT_VARIABLE PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
 message(STATUS "Plugin path: " ${PLUGINDIR})
 
 message(STATUS "Generating translations ...")
Index: qt5ct/src/qt5ct/appearancepage.cpp
===================================================================
--- qt5ct/src/qt5ct/appearancepage.cpp	(revision 622)
+++ qt5ct/src/qt5ct/appearancepage.cpp	(working copy)
@@ -86,6 +86,8 @@
 #else
     keys = QPlatformThemeFactory::keys();
     m_ui->dialogComboBox->addItem(tr("Default"), "default");
+    if(keys.contains("xdgdesktopportal"))
+        m_ui->dialogComboBox->addItem("XDG Desktop Portal", "xdgdesktopportal");
     if(keys.contains("gtk2") || keys.contains("qt5gtk2"))
         m_ui->dialogComboBox->addItem("GTK2", "gtk2");
     else if(keys.contains("gtk3") || keys.contains("qt5gtk3"))
@@ -390,7 +392,7 @@
 {
     QDir dir(path);
     dir.setFilter(QDir::Files);
-    dir.setNameFilters(QStringList() << "*.conf");
+    dir.setNameFilters(QStringList() << "*.conf" << "*.colors");
 
     for(QFileInfo info : dir.entryInfoList())
     {
Index: qt5ct/src/qt5ct/qt5ct.cpp
===================================================================
--- qt5ct/src/qt5ct/qt5ct.cpp	(revision 622)
+++ qt5ct/src/qt5ct/qt5ct.cpp	(working copy)
@@ -111,6 +111,7 @@
     for(const QString &p : QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation))
     {
         paths << (p + QLatin1String("/qt5ct/colors"));
+        paths << (p + QLatin1String("/color-schemes"));
     }
     paths << QLatin1String(QT5CT_DATADIR"/qt5ct/colors");
     paths.removeDuplicates();
Index: qt5ct/src/qt5ct-qtplugin/CMakeLists.txt
===================================================================
--- qt5ct/src/qt5ct-qtplugin/CMakeLists.txt	(revision 622)
+++ qt5ct/src/qt5ct-qtplugin/CMakeLists.txt	(working copy)
@@ -10,5 +10,5 @@
 
 add_library(qt5ct-qtplugin MODULE ${app_SRCS})
 set_target_properties(qt5ct-qtplugin PROPERTIES OUTPUT_NAME qt5ct)
-target_link_libraries(qt5ct-qtplugin PRIVATE Qt5::Widgets Qt5::GuiPrivate Qt5::DBus Qt5::ThemeSupportPrivate)
+target_link_libraries(qt5ct-qtplugin PRIVATE Qt5::Widgets Qt5::GuiPrivate Qt5::DBus Qt5::QuickControls2 Qt5::ThemeSupportPrivate KF5::ConfigCore KF5::ConfigWidgets KF5::IconThemes)
 install(TARGETS qt5ct-qtplugin DESTINATION ${PLUGINDIR}/platformthemes)
Index: qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.cpp
===================================================================
--- qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.cpp	(revision 622)
+++ qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.cpp	(working copy)
@@ -45,6 +45,7 @@
 #endif
 #include <QFile>
 #include <QFileSystemWatcher>
+#include <QQuickStyle>
 
 #include <qt5ct/qt5ct.h>
 #include "qt5ctplatformtheme.h"
@@ -60,6 +61,11 @@
 #include <qpa/qplatformthemefactory_p.h>
 #endif
 
+#include <ksharedconfig.h>
+#include <kcolorscheme.h>
+#include <kiconengine.h>
+#include <kiconloader.h>
+
 Q_LOGGING_CATEGORY(lqt5ct, "qt5ct", QtWarningMsg)
 
 //QT_QPA_PLATFORMTHEME=qt5ct
@@ -75,6 +81,10 @@
         QMetaObject::invokeMethod(this, "createFSWatcher", Qt::QueuedConnection);
 #endif
         QGuiApplication::setFont(m_generalFont);
+        //if the user has explicitly set something else, don't meddle
+        if (QQuickStyle::name().isEmpty()) {
+            QQuickStyle::setStyle(QLatin1String("org.kde.desktop"));
+        }
     }
     qCDebug(lqt5ct) << "using qt5ct plugin";
 #ifdef QT_WIDGETS_LIB
@@ -81,6 +91,7 @@
     if(!QStyleFactory::keys().contains("qt5ct-style"))
         qCCritical(lqt5ct) << "unable to find qt5ct proxy style";
 #endif
+	QCoreApplication::instance()->installEventFilter(this);
 }
 
 Qt5CTPlatformTheme::~Qt5CTPlatformTheme()
@@ -195,6 +206,11 @@
 }
 #endif
 
+QIconEngine *Qt5CTPlatformTheme::createIconEngine(const QString &iconName) const
+{
+    return new KIconEngine(iconName, KIconLoader::global());
+}
+
 void Qt5CTPlatformTheme::applySettings()
 {
     if(!QGuiApplication::desktopSettingsAware() || m_isIgnored)
@@ -313,7 +329,15 @@
     if(!schemePath.isEmpty() && settings.value("custom_palette", false).toBool())
     {
         schemePath = Qt5CT::resolvePath(schemePath); //replace environment variables
-        m_palette = new QPalette(loadColorScheme(schemePath));
+        if(schemePath.endsWith(".colors"))
+        {
+            m_palette = new QPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(schemePath)));
+            qApp->setProperty("KDE_COLOR_SCHEME_PATH", schemePath);
+        }
+        else
+        {
+            m_palette = new QPalette(loadColorScheme(schemePath));
+        }
     }
     m_iconTheme = settings.value("icon_theme").toString();
     //load dialogs
@@ -480,3 +504,30 @@
 
     return customPalette;
 }
+
+bool Qt5CTPlatformTheme::eventFilter(QObject *obj, QEvent *e)
+{
+    if(obj == qApp && e->type() == QEvent::DynamicPropertyChange)
+    {
+        QDynamicPropertyChangeEvent *ee = static_cast<QDynamicPropertyChangeEvent*>(e);
+        if(ee->propertyName() == "KDE_COLOR_SCHEME_PATH")
+        {
+            if(qApp->property("KDE_COLOR_SCHEME_PATH").isNull())
+            {
+                QSettings settings(Qt5CT::configFile(), QSettings::IniFormat);
+                settings.beginGroup("Appearance");
+                QString schemePath = settings.value("color_scheme_path").toString();
+                if(!schemePath.isEmpty() && settings.value("custom_palette", false).toBool())
+                {
+                    schemePath = Qt5CT::resolvePath(schemePath); //replace environment variables
+                    if(schemePath.endsWith(".colors"))
+                    {
+                        qApp->setProperty("KDE_COLOR_SCHEME_PATH", schemePath);
+                        applySettings();
+                    }
+                }
+            }
+        }
+    }
+    return QObject::eventFilter(obj, e);
+}
Index: qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.h
===================================================================
--- qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.h	(revision 622)
+++ qt5ct/src/qt5ct-qtplugin/qt5ctplatformtheme.h	(working copy)
@@ -91,10 +91,13 @@
     //virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
     //                               QPlatformTheme::IconOptions iconOptions = 0) const;
 
-    //virtual QIconEngine *createIconEngine(const QString &iconName) const;
+    virtual QIconEngine *createIconEngine(const QString &iconName) const;
     //virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
     //virtual QString standardButtonText(int button) const;
 
+protected:
+	bool eventFilter(QObject *obj, QEvent *e) override;
+
 private slots:
     void applySettings();
 #ifdef QT_WIDGETS_LIB