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

List:       kde-commits
Subject:    [osx-integration] /: merge branch 'qt590' (v5.11.2-43-g215f32d) into master preserving the Qt 5.8.0 
From:       René J.V. Bertin <null () kde ! org>
Date:       2018-02-06 11:03:36
Message-ID: E1ej12G-00022O-4K () code ! kde ! org
[Download RAW message or body]

Git commit 0a18eb16df45fb71215de055d6b5683ddeb4e6da by René J.V. Bertin.
Committed on 06/02/2018 at 10:56.
Pushed by rjvbb into branch 'master'.

merge branch 'qt590' (v5.11.2-43-g215f32d) into master preserving the Qt 5.8.0 QPA \
and Mac style

commit 215f32d20194503a8a3ff0ea4c7578ad45a310b8
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 29 16:43:13 2018 +0100

    platformtheme : unload protection

    This prevents a recent (?) regression where opening a KDE file dialog in
    a "pure Qt" app (= not linking itself to KF5KIOWidgets) would cause a
    crash on exit, apparently because the QRegExpEngine globalEngineCache
    contained references to objects belonging to KF5KIOWidgets (which would
    already be unloaded).
    The unload protection postpones the unloading of the platform theme
    plugin, and thus of any libraries on which it depends.

    Committed from host : Portia.local

commit 627f292633a8d0618c47f000ad9a1ab2aa5ebc61
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 29 16:38:47 2018 +0100

    platformtheme: selective merge of plasma-integration v5.11.95-3-gd4d0bc3

    Committed from host : Portia.local

commit 9670bd82bcbe4592da106788b165cb458f44e07e
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sun Jan 28 12:49:07 2018 +0100

    QAltCocoa : sync with upstream v5.9.4-70-g5a05348fb6

    Committed from host : Portia.local

commit a9db5f76d631cef1a37a95eecc3eb26b606a628e
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sun Jan 28 12:33:54 2018 +0100

    QAltMacStyle : sync with upstream v5.9.4-70-g5a05348fb6

    Committed from host : Portia.local

commit 5c5c5aac9ebb5b50d84bc3ec2c61d2efca0135db
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Fri Jan 26 23:10:09 2018 +0100

    platformtheme: should still set the stylehint in CoreText mode!

    Committed from host : Portia.local

commit 32c31fbfb8bb86c8d22f5fd0dc941cce08eb79a4
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Jan 25 23:23:44 2018 +0100

    platformtheme: also force QFont::ForceOutline mode in non-cocoa mode...

    Committed from host : Portia.local

commit bca926fd4a8dfc99eeb42cadfefca74757d248fd
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Jan 25 23:20:19 2018 +0100

    platformtheme: force QFont::ForceOutline mode when using the FreeType engine

    Committed from host : Portia.local

commit f7a831a276cac586323e331a6518b701ad9a9556
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 22 21:45:16 2018 +0100

    platformtheme: don't base isSystemTrayAvailable() on the presence of a DBus \
StatusNotifierHost

    Do this when NOT using the Cocoa platform, and fall back to
    QSystemTrayIcon::isSystemTrayAvailable().

    Committed from host : Portia.local

commit 3d399c7f7217af2f39b539b7e701786c64e91dd7
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sun Jan 21 18:16:26 2018 +0100

    make now redundant debug message verbose-mode only

    Committed from host : Portia.local

commit 06a0093268e9cd70d60db23a7cc7d6201519e3a6
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sun Jan 21 15:54:52 2018 +0100

    create the appropriate platform theme for proxying, even under X11

    Committed from host : Portia.local

commit c5f2c1483dc1fde2b727cab8798171797ab9e6b5
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Jan 10 20:11:46 2018 +0100

    QAltCocoa : sync with upstream v5.9.3-191-g1df2906

    Committed from host : Portia.local

commit 4834cd69b4efce95e91aaa612b04385f16428f9f
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Jan 4 13:11:25 2018 +0100

    QAltCocoa : printing with the FreeType fontengine: use the existing fallback

    Committed from host : Portia.local

commit d7831663d9838150bb0ec214f3a2e1999f88aaf7
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Jan 4 01:56:48 2018 +0100

    QAltCocoa : use __has_builtin to check for __builtin_available .

    Committed from host : Portia.local

commit 066018f678b515b7b43a50edc3ca313cbe5cb4f3
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Jan 3 18:56:06 2018 +0100

    QAltCocoa : enable printing with the FreeType fontengine

    Committed from host : Portia.local

commit 7c5aec4f0e7444f016c8ea140ee8e60d6c156dc9
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 1 18:29:10 2018 +0100

    CMake polish

    Committed from host : Portia.local

commit 28d6f1875849af0b85609338e908e4efafbf0079
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 1 18:07:19 2018 +0100

    QAltCocoa: fix typo

    Committed from host : Portia.local

commit 2ed0575393331fa24e2a0f65683632491c622243
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 1 01:48:56 2018 +0100

    platformtheme : only try to change the fontengine when there's an instruction to \
do so in the environment or kdeglobals file

    Committed from host : Portia.local

commit bf3fb7b7a3cb4df3e3314f331f30c301f12e4eff
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Mon Jan 1 00:27:11 2018 +0100

    platformtheme : allow QT_MAC_FONTENGINE env. variable to override kdeglobals \
settings

    Committed from host : Portia.local

commit 19c5c440b08937a3e3c1ebd09150bfd31266554f
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sun Dec 31 23:57:45 2017 +0100

    QAltCocoa: QT_MAC_USE_FREETYPE/QT_MAC_USE_FONTCONFIG -> \
QT_MAC_FONTENGINE=[FREETYPE|FONTCONFIG]

    Committed from host : Portia.local

commit 084a44d4ccb9511a4772400cec2b1d3272b1a83f
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sat Dec 30 23:23:17 2017 +0100

    QAltCocoa: build option for the default font smoothing gamma

    Committed from host : Portia.local

commit 5ef806d6081f0993a6bc2d849da82a5256b08371
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sat Dec 30 23:14:10 2017 +0100

    Add a CMake option to indicate that Infinality patches have been applied to the \
local FreeType *and* FontConfig install

    Committed from host : Portia.local

commit d992880465e8f8d5b1fdcab93dc538fd0e2d09c8
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sat Dec 30 22:50:32 2017 +0100

    platform theme: add support for a "fontEngine=FontConfig" in the \
                kdeglobals/General group
    .

    Committed from host : Portia.local

commit 69e14f211060466b45487f0afaae3b1d36078a73
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sat Dec 30 17:26:03 2017 +0100

    support for using FontConfig+FreeType instead of CoreText.

    Feature-complete but still experimental.

    Committed from host : Portia.local

commit 942c2f1a4b77b95996a631704aa40bf1f8cf3259
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Fri Dec 29 23:12:18 2017 +0100

    WIP experimental support for using FontConfig+FreeType instead of CoreText

    Committed from host : Portia.local

commit 79f2124bada1f371a8f8341b110962c8d7d19362
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Fri Dec 29 22:33:38 2017 +0100

    initial, experimental support for using FontConfig+FreeType instead of CoreText

    Committed from host : Portia.local

commit 2af8f111a0b8d8b11282b467273335e204735d86
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Fri Dec 29 19:53:04 2017 +0100

    platform theme: reduce icon verbosity and let KDEMACTHEME_PREFER_NATIVE_DIALOGS \
apply only to Cocoa mode

    Committed from host : Portia.local

commit 9a52f5e462bbd14081fa3d228e0d8bd681b21a44
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Dec 28 20:40:19 2017 +0100

    platform theme: use QT_QPA_PLATFORMTHEME_DISABLED to disable

    Committed from host : Portia.local

commit 777276d1edc9ce74f6d856ffc7e3c92e0fc2d320
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Dec 28 19:39:42 2017 +0100

    README update

    Committed from host : Portia.local

commit fd31276a06de707bf8a28d2749fc1506df99106f
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Dec 28 19:21:34 2017 +0100

    platform theme: support a "fontEngine" key in the kdeglobals/General group

    Toggles to and from FreeType.

    Committed from host : Portia.local

commit 63ce564956d7d8e8d2676d43d5396df644bbf458
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Thu Dec 28 19:07:45 2017 +0100

    QAltCocoa : modify the FreeType integration function: now toggles

    Committed from host : Portia.local

commit c7452a0ccf14b687e4a74848b8c527aa2013c08a
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 18:36:41 2017 +0100

    platform theme: add hooks into the platform native interface

    Committed from host : Portia.local

commit 06904bc6e8f97b7b8cc2a919a57dc43a08f90d4a
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 18:35:56 2017 +0100

    QAltCocoa : add an integration function that signals QT_MAC_USE_FREETYPE is \
supported

    Committed from host : Portia.local

commit 1b1b73cd59160640efb610a1f37fceb86f39e07f
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 17:12:00 2017 +0100

    platform theme plugin : more plugin metadata

    Committed from host : Portia.local

commit 44a9dd52fa6121a162bbaa5bf83447e37c434787
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 17:02:30 2017 +0100

    QAltMacStyle : more plugin metadata

    Committed from host : Portia.local

commit c4075fb561130139ca0db327d7179058c2ba02b1
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 16:55:20 2017 +0100

    QAltCocoa : allow to select the Freetype fontengine via QT_MAC_USE_FREETYPE=1

    Committed from host : Portia.local

commit c7305045621425a8c7509287089851255a962e54
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Wed Dec 27 16:14:05 2017 +0100

    Make QT_QPA_PLATFORMTHEME_CONFIG_FILE work a bit more as expected

    Also improve verbose mode logging.

    Committed from host : Portia.local

commit 662ba1a227fcbf0dab0e4e52b1d6a8a1b3d7f8d3
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Tue Dec 19 19:52:01 2017 +0100

    QAltCocoa: compensate for apparent changes in the fontSmoothingGamma effect

commit 554e95e4346dfe020914f2d667aed90f17e52a21
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Tue Dec 19 13:07:19 2017 +0100

    include qglobal.h header

    Committed from host : Portia.local

commit 86a940247eaf86135a0f1effebd61db8ec80aa6c
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Tue Dec 19 13:04:39 2017 +0100

    QAltCocoa: merge upstream v5.9.3-150-gb0938cb

    Committed from host : Portia.local

commit 17fcd7155e10035c75c98d6414c0a1ebd433aeb5
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Tue Dec 19 12:58:06 2017 +0100

    QAltMacStyle: merge upstream v5.9.3-150-gb0938cb

    Committed from host : Portia.local

commit 06ffeec3f0edd641ec2d44697a8c4ef2ab180e43
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Tue Dec 12 14:26:03 2017 +0100

    print the OS X deployment target and selected SDK after the feature_summary.

    Committed from host : Portia.local

commit 4ec9baf558e3cfc84b3ace0276d5aa0efd147fb9
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Sat Dec 2 23:30:26 2017 +0100

    handle NSWindow.titlebarAppearsTransparent in a cleaner way

    Committed from host : Portia.local

commit f7bf0406d80bb2f258688de79954f52d7c2094d9
Author: R.J.V. Bertin <rjvbertin@gmail.com>
Date:   Fri Dec 1 18:46:12 2017 +0100

    fix the build against 5.9+ on 10.9

    Committed from host : Portia.local

Committed from host : Bola

M  +27   -2    CMakeLists.txt
M  +21   -1    README.md
M  +5    -0    qtplugins.pro
M  +9    -1    src/platformtheme/cocoaplatformtheme.json
M  +1    -0    src/platformtheme/config-platformtheme.h.cmake
M  +10   -0    src/platformtheme/kdemactheme.h
M  +46   -7    src/platformtheme/kdemactheme.mm
M  +12   -0    src/platformtheme/kdeplatformfiledialoghelper.cpp
M  +1    -0    src/platformtheme/kdeplatformfiledialoghelper.h
M  +28   -5    src/platformtheme/kdeplatformsystemtrayicon.cpp
M  +3    -1    src/platformtheme/kdeplatformsystemtrayicon.h
M  +4    -3    src/platformtheme/kdeplatformtheme.cpp
M  +10   -1    src/platformtheme/kdeplatformtheme.json
M  +3    -0    src/platformtheme/kdirselectdialog.cpp
M  +3    -0    src/platformtheme/kfiletreeview.cpp
M  +10   -2    src/platformtheme/kfontsettingsdata.cpp
M  +12   -1    src/platformtheme/kfontsettingsdatamac.h
M  +84   -10   src/platformtheme/kfontsettingsdatamac.mm
M  +25   -2    src/platformtheme/khintssettings.cpp
M  +4    -0    src/platformtheme/khintssettings.h
M  +5    -1    src/platformtheme/khintssettingsmac.h
M  +52   -4    src/platformtheme/khintssettingsmac.mm
M  +34   -1    src/platformtheme/main_cocoa.cpp
M  +28   -1    src/platformtheme/main_kde.cpp
R  +0    -0    src/platformtheme/plintegration-cumpatch1.diff [from: \
plintegration-cumpatch1.diff - 100% similarity]

https://commits.kde.org/osx-integration/0a18eb16df45fb71215de055d6b5683ddeb4e6da

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47708ff..6158082 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ option(BUILD_KDE_THEME_PLUGIN
         "Should the KDE theme plugin be built?"
         ON)
 option(BUILD_QT_PLUGINS
-        "Should the Qt QPA and style plugins be built (they don't depend on KDE but \
become optional when the KDE theme plugin is built)" +        "Should the Qt Cocoa \
QPA and Aqua style plugins be built (they don't depend on KDE but become optional \
when the KDE theme plugin is built)"  ON)
 
 option(DEFINE_ICONTHEME_SETTINGS
@@ -19,7 +19,7 @@ option(NEVER_NATIVE_DIALOGS
         "Should native dialogs never be used (when not already preferred)?"
         OFF)
 option(OVERRIDE_NATIVE_THEME
-        "Should the platform theme plugin replace the native theme? If OFF it \
installs as the \"kde\" theme." +        "Should the platform theme plugin override \
the native theme? If ON it installs as the \"Cocoa\" instead of as the \"kde\" \
theme."  OFF)
 option(DISABLE_DBUS_SUPPORT
         "Don't build the D-Bus functionality. Experimental!"
@@ -28,12 +28,31 @@ option(EMULATE_MENU_KEY
         "Emulate the presence of a Menu key as on PC keyboards when the right \
Command+Option keys are pressed.  BUILD_QT_PLUGINS must be set for this to have any \
effect."  OFF)
+option(HAVE_INFINALITY
+        "The Infinality+Ultimate patch set has been applied to FreeType and \
FontConfig. +        (the FontConfig patches are determining). See \
https://github.com/archfan/infinality_bundle" +        OFF)
 
 option(USE_PLCRASHREPORTER
         "Use the Plausible CrashReporter (https://www.plcrashreporter.org)"
         OFF)
 
 include(FeatureSummary)
+add_feature_info("KDE platform theme plugin" BUILD_KDE_THEME_PLUGIN "")
+add_feature_info("Build the Qt plugins" BUILD_QT_PLUGINS
+        "Should the Qt Cocoa QPA and Aqua style plugins be built")
+add_feature_info("Override the Cocoa platform" OVERRIDE_NATIVE_THEME
+        "Install the platform theme plugin so it overrides the native \"Cocoa\" \
platform") +add_feature_info("Icon theme settings" DEFINE_ICONTHEME_SETTINGS
+        "Should the theme plugin define a standard theme and add the standard \
locations for icon themes to the search path?") +add_feature_info("Prefer native \
dialogs" PREFER_NATIVE_DIALOGS "") +add_feature_info("Never use native dialogs" \
NEVER_NATIVE_DIALOGS "") +add_feature_info("No DBus" DISABLE_DBUS_SUPPORT
+        "Don't build the D-Bus functionality. Experimental!")
+add_feature_info("Emulate a Menu key" EMULATE_MENU_KEY
+        "Emulate the presence of a Menu key as on PC keyboards when the right \
Command+Option keys are pressed.") +add_feature_info("Build for use with the \
Infinality+Ultimate patch-set" HAVE_INFINALITY "") +
 find_package(ECM 5.20.0  NO_MODULE)
 set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake \
Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")  # \
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) \
@@ -119,3 +138,9 @@ if(BUILD_KDE_THEME_PLUGIN)  endif()
 
 feature_summary(WHAT ALL   FATAL_ON_MISSING_REQUIRED_PACKAGES)
+if(CMAKE_OSX_DEPLOYMENT_TARGET)
+    message(STATUS "OS X Deployment target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
+endif()
+if(CMAKE_OSX_SYSROOT)
+    message(STATUS "OS X SDK sysroot: ${CMAKE_OSX_SYSROOT}")
+endif()
diff --git a/README.md b/README.md
index 1933a9d..7b580bb 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,15 @@ and the plugin can now also be built to override the native Cocoa \
QPA plugin  (OVERRIDE_NATIVE_THEME CMake option). The Menu key emulation still \
requires  a Qt patch (or a dedicated event handler) to do anything useful though.
 
+* Other useful env. variables:
+- QT_QPA_PLATFORMTHEME_VERBOSE : activate verbose mode (logging category
+  CocoaPlatformTheme or KDEPlatformTheme).
+- QT_QPA_PLATFORMTHEME_CONFIG_FILE : load a different file instead of "kdeglobals"
+  from ~/.config or ~/Library/Preferences
+- QT_QPA_PLATFORMTHEME_DISABLED : disable the plugin completely.
+- PREFER_KDE_DIALOGS : force KDE dialogs even when configured to prefer native
+  file dialogs.
+
 This component should still build against Qt 5.5.x; the other components need at
 least Qt 5.8 .
 
@@ -41,7 +50,13 @@ and also reintroduces a basic fullscreen mode that works \
consistently across  Mission Control settings and platforms - i.e. it never blackens \
out other  attached monitors but keeps their content visible and accessible. It's \
also a  lot faster and supports opening new windows without side-effects when in
-fullscreen mode.
+fullscreen mode. Selecting the FreeType engine has been made easier via an env.
+variable (QT_MAC_USE_FREETYPE) as well as an integration function that can be
+called from application code (see kfontsettingsdatamac.mm). There's also support
+for activating the FontConfig fontengine/database (QT_MAC_USE_FONTCONFIG) but
+this requires a patched QtBase configured to use FontConfig. Both use a font
+gamma setting that determines font darkness and can be set via the env. var
+QT_MAC_FREETYPE_FONT_GAMMA .
 This plugin installs next to and will be loaded instead of the stock plugin; it
 will then give priority to the modified QMacStyle if that is installed. If the
 KDE platform theme plugin is built in override mode (see above) this plugin is
@@ -70,3 +85,8 @@ this is also the only way to build the KDE platform theme plugin \
                component.
 - DISABLE_DBUS_SUPPORT : Don't build the D-Bus functionality. Experimental!
 - EMULATE_MENU_KEY : emulate a Menu key (right Command+Option key-combo); requires
   BUILD_QT_PLUGINS to be set in order for that keypress to open the context menu.
+
+* CMake options for QCocoaQPA :
+- HAVE_INFINALITY : should be enabled when you have the Infinality+Ultimate \
patch-set +  applied to FreeType *and* FontConfig. Without this option fonts will \
probably look +  washed out.
diff --git a/qtplugins.pro b/qtplugins.pro
index 25cf7f4..4571366 100644
--- a/qtplugins.pro
+++ b/qtplugins.pro
@@ -1,4 +1,9 @@
 TEMPLATE = subdirs
 
+contains(QT_VERSION, ^5\\.[0-7]\\..*) {
+    message("Need at least Qt 5.8.0 to build QAltCocoa and QAltMacStyle")
+    error("Qt 5.8.0 or higher is required")
+}
+
 SUBDIRS += src/qcocoa-qpa/qcocoa-standalone.pro \
            src/qmacstyle/macstyle.pro
diff --git a/src/platformtheme/cocoaplatformtheme.json \
b/src/platformtheme/cocoaplatformtheme.json index 520c4f5..ef2a3b1 100644
--- a/src/platformtheme/cocoaplatformtheme.json
+++ b/src/platformtheme/cocoaplatformtheme.json
@@ -1,3 +1,11 @@
 {
-    "Keys": [ "cocoa" ]
+    "Keys": [ "cocoa" ],
+    "Name": "Kokoa",
+    "Copyright": "(C) 2015-17 René J.V. Bertin",
+    "Description": [
+        "KDE platform integration plugin for Mac OS X/macOS",
+        "Based on the Plasma Integration plugin.",
+        "This version replaces and proxies the original Qt Cocoa and/or RJVB's \
QAltCocoa QPA plugins" +    ],
+    "Url": [ "https://github.com/RJVB/osx-integration" ]
 }
diff --git a/src/platformtheme/config-platformtheme.h.cmake \
b/src/platformtheme/config-platformtheme.h.cmake index aee7975..f302837 100644
--- a/src/platformtheme/config-platformtheme.h.cmake
+++ b/src/platformtheme/config-platformtheme.h.cmake
@@ -2,3 +2,4 @@
 #define BREEZE_STYLE_NAME "${BREEZE_STYLE_NAME}"
 
 #define PLATFORM_PLUGIN_THEME_NAME  "${PLATFORM_PLUGIN_THEME_NAME}"
+#define PLATFORM_PLUGIN_FILE_NAME  "${PLUGIN_FILENAME}"
diff --git a/src/platformtheme/kdemactheme.h b/src/platformtheme/kdemactheme.h
index 08fafa4..dfea02d 100644
--- a/src/platformtheme/kdemactheme.h
+++ b/src/platformtheme/kdemactheme.h
@@ -32,6 +32,7 @@
 class KHintsSettingsMac;
 class QIconEngine;
 class KdeMacThemeEventFilter;
+class QPlatformNativeInterface;
 
 class KdeMacTheme : public KdePlatformTheme
 {
@@ -56,6 +57,12 @@ public:
 
     QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override;
 
+    QPlatformNativeInterface *nativeInterface();
+    typedef void * (*PlatformFunctionPtr)();
+    PlatformFunctionPtr platformFunction(const QByteArray &functionName);
+
+    bool verbose;
+
 protected:
     void loadSettings();
     KFontSettingsDataMac::FontTypes fontType(Font type) const;
@@ -68,6 +75,9 @@ private:
 
     // this will hold an instance of a class with Qt and/or native event filters:
     KdeMacThemeEventFilter *m_eventFilter;
+    QPlatformNativeInterface *m_nativeInterface;
+
+    bool m_isCocoa;
 };
 
 #endif // KDEMACTHEME_H
diff --git a/src/platformtheme/kdemactheme.mm b/src/platformtheme/kdemactheme.mm
index 98d9195..6e213b0 100644
--- a/src/platformtheme/kdemactheme.mm
+++ b/src/platformtheme/kdemactheme.mm
@@ -31,6 +31,7 @@
 #include "kdeplatformsystemtrayicon.h"
 #include "platformtheme_logging.h"
 
+#include <qglobal.h>
 #include <QObject>
 #include <QCoreApplication>
 #include <QGuiApplication>
@@ -64,6 +65,7 @@
 // instantiating the native platform theme requires the use of private APIs
 #include <QtGui/private/qguiapplication_p.h>
 #include <QtGui/qpa/qplatformintegration.h>
+#include <QtGui/qpa/qplatformnativeinterface.h>
 
 
 #include <kiconengine.h>
@@ -409,6 +411,8 @@ How we get here:
 ============ */
 
 KdeMacTheme::KdeMacTheme()
+    : m_nativeInterface(nullptr)
+    , verbose(qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE"))
 {
     if (strcasecmp(QT_VERSION_STR, qVersion())) {
         NSLog(@"Warning: the %s platform theme plugin for Mac was built against Qt \
%s but is running with Qt %s!", @@ -417,19 +421,27 @@ KdeMacTheme::KdeMacTheme()
     // first things first: instruct Qt not to use the Mac-style toplevel menubar
     // if we are not using the Cocoa QPA plugin (but the XCB QPA instead).
     platformName = QGuiApplication::platformName();
+    QString platformThemeName;
     if (!platformName.contains(QLatin1String("cocoa"))) {
         QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
         QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);
+        m_isCocoa = false;
+        // we will almost certainly be using the xcb QPA ("X11"). We'll proxy
+        // the generic Unix theme, *not* the KDE theme. That'd be redundant.
+        platformThemeName = QStringLiteral("generic");
+    } else {
+        m_isCocoa = true;
+        platformThemeName = platformName;
     }
     QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
     if (pi) {
-        nativeTheme = pi->createPlatformTheme(platformName);
+        nativeTheme = pi->createPlatformTheme(platformThemeName);
     } else {
         nativeTheme = Q_NULLPTR;
     }
     if (!nativeTheme) {
         warnNoNativeTheme();
-    } else if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) {
+    } else if (verbose) {
         qCWarning(PLATFORMTHEME) << Q_FUNC_INFO
             << "loading platform theme plugin" << \
QLatin1String(PLATFORM_PLUGIN_THEME_NAME) << "for platform" << platformName;  }
@@ -539,9 +551,15 @@ QVariant KdeMacTheme::themeHint(QPlatformTheme::ThemeHint \
hintType) const  {
     QVariant hint = m_hints->hint(hintType);
     if (hint.isValid()) {
+        if (verbose) {
+            qCWarning(PLATFORMTHEME) << "themeHint" << hintType << ":" << hint;
+        }
         return hint;
     } else {
         if (nativeTheme) {
+            if (verbose) {
+                qCWarning(PLATFORMTHEME) << "Using native theme for themeHint" << \
hintType << ":" << nativeTheme->themeHint(hintType); +            }
             return nativeTheme->themeHint(hintType);
         }
         return QPlatformTheme::themeHint(hintType);
@@ -594,10 +612,10 @@ const QFont *KdeMacTheme::font(Font type) const
 void KdeMacTheme::loadSettings()
 {
     if (!m_fontsData) {
-        m_fontsData = new KFontSettingsDataMac;
+        m_fontsData = new KFontSettingsDataMac(this);
     }
     if (!m_hints) {
-        m_hints = new KHintsSettingsMac;
+        m_hints = new KHintsSettingsMac(this);
     }
 }
 
@@ -685,11 +703,12 @@ QString KdeMacTheme::standardButtonText(int button) const
 QPlatformDialogHelper \
*KdeMacTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const  {
 #ifdef KDEMACTHEME_PREFER_NATIVE_DIALOGS
-    // always prefer native dialogs
+    // always prefer native dialogs - when using the Cocoa QPA.
     // NOTE: somehow, the "don't use native dialog" option that Qt's example \
                "standarddialogs"
     // provides does not modify our usePlatformNativeDialog() return value, but \
*does* cause  // a Qt dialog to be created instead of the native one. Weird.
-    if (nativeTheme && !qEnvironmentVariableIsSet("PREFER_KDE_DIALOGS")) {
+    if (nativeTheme && m_isCocoa
+            && (!qEnvironmentVariableIsSet("PREFER_KDE_DIALOGS") || \
qEnvironmentVariableIsEmpty("PREFER_KDE_DIALOGS"))) {  return \
nativeTheme->createPlatformDialogHelper(type);  }
 #endif
@@ -707,11 +726,31 @@ QPlatformDialogHelper \
*KdeMacTheme::createPlatformDialogHelper(QPlatformTheme::D  QPlatformSystemTrayIcon \
*KdeMacTheme::createPlatformSystemTrayIcon() const  {
     if (nativeTheme) {
-        return nativeTheme->createPlatformSystemTrayIcon();
+        const auto systray = nativeTheme->createPlatformSystemTrayIcon();
+        if (!m_isCocoa && verbose) {
+            qCWarning(PLATFORMTHEME) << "Created native systray icon" << systray << \
"for platform" << platformName; +        }
+        return systray;
     }
     // TODO: figure out if it makes sense to return something other than 
     // nativeTheme->createPlatformSystemTrayIcon() or even NULL
     return KdePlatformTheme::createPlatformSystemTrayIcon();
 }
 
+QPlatformNativeInterface *KdeMacTheme::nativeInterface()
+{
+    if (!m_nativeInterface) {
+        m_nativeInterface = QGuiApplication::platformNativeInterface();
+    }
+    return m_nativeInterface;
+}
+
+KdeMacTheme::PlatformFunctionPtr KdeMacTheme::platformFunction(const QByteArray \
&functionName) +{
+    if (nativeInterface()) {
+        return m_nativeInterface->nativeResourceFunctionForIntegration(functionName);
 +    }
+    return nullptr;
+}
+
 #include "kdemactheme.moc"
diff --git a/src/platformtheme/kdeplatformfiledialoghelper.cpp \
b/src/platformtheme/kdeplatformfiledialoghelper.cpp index 21fe7ff..4c924dc 100644
--- a/src/platformtheme/kdeplatformfiledialoghelper.cpp
+++ b/src/platformtheme/kdeplatformfiledialoghelper.cpp
@@ -22,6 +22,7 @@
 #include "kdeplatformfiledialoghelper.h"
 #include "kdeplatformfiledialogbase_p.h"
 #include "kdirselectdialog_p.h"
+#include "platformtheme_logging.h"
 
 #include <kfilefiltercombo.h>
 #include <kfilewidget.h>
@@ -113,6 +114,12 @@ KDEPlatformFileDialog::KDEPlatformFileDialog()
     layout()->addWidget(m_buttons);
 }
 
+KDEPlatformFileDialog::~KDEPlatformFileDialog()
+{
+    delete m_fileWidget;
+    delete m_buttons;
+}
+
 QUrl KDEPlatformFileDialog::directory()
 {
     return m_fileWidget->baseUrl();
@@ -416,6 +423,11 @@ QUrl KDEPlatformFileDialogHelper::directory() const
 void KDEPlatformFileDialogHelper::selectFile(const QUrl &filename)
 {
     m_dialog->selectFile(filename);
+
+    // Qt 5 at least <= 5.8.0 does not derive the directory from the passed url
+    // and set the initialDirectory option accordingly, also not for known schemes
+    // like file://, so we have to do it ourselves
+    options()->setInitialDirectory(m_dialog->directory());
 }
 
 void KDEPlatformFileDialogHelper::setDirectory(const QUrl &directory)
diff --git a/src/platformtheme/kdeplatformfiledialoghelper.h \
b/src/platformtheme/kdeplatformfiledialoghelper.h index 24cf561..c5420bb 100644
--- a/src/platformtheme/kdeplatformfiledialoghelper.h
+++ b/src/platformtheme/kdeplatformfiledialoghelper.h
@@ -33,6 +33,7 @@ public:
     friend class KDEPlatformFileDialogHelper;
 
     explicit KDEPlatformFileDialog();
+    virtual ~KDEPlatformFileDialog();
     QUrl directory() override;
     void selectMimeTypeFilter(const QString &filter) override;
     void selectNameFilter(const QString &filter) override;
diff --git a/src/platformtheme/kdeplatformsystemtrayicon.cpp \
b/src/platformtheme/kdeplatformsystemtrayicon.cpp index 3c0b215..ca670af 100644
--- a/src/platformtheme/kdeplatformsystemtrayicon.cpp
+++ b/src/platformtheme/kdeplatformsystemtrayicon.cpp
@@ -1,5 +1,5 @@
 /*  This file is part of the KDE libraries
- *  Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+ *  Copyright 2014 Martin Gr��lin <mgraesslin@kde.org>
  *
  *  This library is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Lesser General Public License as published by
@@ -27,6 +27,7 @@
 #ifdef DBUS_SUPPORT_ENABLED
 #include <QDBusInterface>
 #endif
+#include <QSystemTrayIcon>
 
 SystemTrayMenu::SystemTrayMenu()
     : QPlatformMenu()
@@ -49,6 +50,11 @@ QPlatformMenuItem *SystemTrayMenu::createMenuItem() const
     return new SystemTrayMenuItem();
 }
 
+QPlatformMenu *SystemTrayMenu::createSubMenu() const
+{
+    return new SystemTrayMenu();
+}
+
 void SystemTrayMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem \
*before)  {
     if (SystemTrayMenuItem *ours = qobject_cast<SystemTrayMenuItem*>(menuItem)) {
@@ -244,6 +250,21 @@ void SystemTrayMenuItem::setIconSize(int size)
     Q_UNUSED(size);
 }
 
+void SystemTrayMenuItem::setHasExclusiveGroup(bool hasExclusiveGroup)
+{
+    if (hasExclusiveGroup) {
+        if (!m_action->actionGroup()) {
+            m_action->setActionGroup(new QActionGroup(m_action));
+        }
+    } else {
+        QActionGroup *actionGroup = m_action->actionGroup();
+        if (actionGroup) {
+            m_action->setActionGroup(nullptr);
+            delete actionGroup;
+        }
+    }
+}
+
 quintptr SystemTrayMenuItem::tag() const
 {
     return m_tag;
@@ -344,13 +365,15 @@ void KDEPlatformSystemTrayIcon::showMessage(const QString \
&title, const QString  bool KDEPlatformSystemTrayIcon::isSystemTrayAvailable() const
 {
 #ifdef DBUS_SUPPORT_ENABLED
-    QDBusInterface systrayHost(QStringLiteral("org.kde.StatusNotifierWatcher"), \
QStringLiteral("/StatusNotifierWatcher"), \
                QStringLiteral("org.kde.StatusNotifierWatcher"));
-    if (systrayHost.isValid()) {
-        return systrayHost.property("IsStatusNotifierHostRegistered").toBool();
+    if (QGuiApplication::platformName().compare(QStringLiteral("cocoa"), \
Qt::CaseInsensitive)) { +        QDBusInterface \
systrayHost(QStringLiteral("org.kde.StatusNotifierWatcher"), \
QStringLiteral("/StatusNotifierWatcher"), \
QStringLiteral("org.kde.StatusNotifierWatcher")); +        if (systrayHost.isValid()) \
{ +            return \
systrayHost.property("IsStatusNotifierHostRegistered").toBool(); +        }
     }
 #endif
 
-    return false;
+    return QSystemTrayIcon::isSystemTrayAvailable();
 }
 
 bool KDEPlatformSystemTrayIcon::supportsMessages() const
diff --git a/src/platformtheme/kdeplatformsystemtrayicon.h \
b/src/platformtheme/kdeplatformsystemtrayicon.h index c8a7b96..8847fa1 100644
--- a/src/platformtheme/kdeplatformsystemtrayicon.h
+++ b/src/platformtheme/kdeplatformsystemtrayicon.h
@@ -1,5 +1,5 @@
 /*  This file is part of the KDE libraries
- *  Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+ *  Copyright 2014 Martin Gr��lin <mgraesslin@kde.org>
  *
  *  This library is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Lesser General Public License as published by
@@ -47,6 +47,7 @@ public:
     void syncSeparatorsCollapsible(bool enable) override;
     quintptr tag() const override;
     QPlatformMenuItem *createMenuItem() const override;
+    QPlatformMenu *createSubMenu() const override;
 
     QMenu *menu() const;
 
@@ -76,6 +77,7 @@ public:
     void setVisible(bool isVisible) override;
     quintptr tag() const override;
     void setIconSize(int size) override;
+    void setHasExclusiveGroup(bool hasExclusiveGroup) override;
 
     QAction *action() const;
 
diff --git a/src/platformtheme/kdeplatformtheme.cpp \
b/src/platformtheme/kdeplatformtheme.cpp index 1377679..5069b76 100644
--- a/src/platformtheme/kdeplatformtheme.cpp
+++ b/src/platformtheme/kdeplatformtheme.cpp
@@ -77,7 +77,7 @@ QIcon KdePlatformTheme::fileIcon(const QFileInfo &fileInfo, \
QPlatformTheme::Icon  return QIcon::fromTheme(QLatin1String("inode-directory"));
     }
 
-    qCWarning(PLATFORMTHEME) << Q_FUNC_INFO
+    qCDebug(PLATFORMTHEME) << Q_FUNC_INFO
         << "file:" << fileInfo.absoluteFilePath()
         << "icon:" << \
                KIO::iconNameForUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
                
     return QIcon::fromTheme(KIO::iconNameForUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())));
 @@ -246,7 +246,7 @@ QList<QKeySequence> \
KdePlatformTheme::keyBindings(QKeySequence::StandardKey key)  
 bool KdePlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) \
const  {
-    return type == QPlatformTheme::FileDialog;
+    return type == QPlatformTheme::FileDialog && \
qobject_cast<QApplication*>(QCoreApplication::instance());  }
 
 QString KdePlatformTheme::standardButtonText(int button) const
@@ -318,7 +318,8 @@ QPlatformSystemTrayIcon \
*KdePlatformTheme::createPlatformSystemTrayIcon() const  //force QtQuickControls2 to \
use the desktop theme as default  void KdePlatformTheme::setQtQuickControlsTheme()
 {
-    //if the user is running only a QGuiApplication. Abort as this style is all \
about QWidgets and we know setting this will make it crash +    //if the user is \
running only a QGuiApplication, explicitely unset the QQC1 desktop style and abort +  \
//as this style is all about QWidgets and we know setting this will make it crash  if \
(!qobject_cast<QApplication*>(qApp)) {  if \
(qgetenv("QT_QUICK_CONTROLS_1_STYLE").right(7) == "Desktop") {  \
                qunsetenv("QT_QUICK_CONTROLS_1_STYLE");
diff --git a/src/platformtheme/kdeplatformtheme.json \
b/src/platformtheme/kdeplatformtheme.json index 5d250cc..0e48a74 100644
--- a/src/platformtheme/kdeplatformtheme.json
+++ b/src/platformtheme/kdeplatformtheme.json
@@ -1,3 +1,12 @@
 {
-    "Keys": [ "kde" ]
+    "Keys": [ "kde" ],
+    "Name": "KDEPlatformTheme",
+    "Copyright": "(C) 2015-17 René J.V. Bertin",
+    "Description": [
+        "KDE platform integration plugin for Mac OS X/macOS",
+        "Based on the Plasma Integration plugin.",
+        "This version only proxies the original Qt Cocoa and/or RJVB's QAltCocoa QPA \
plugins;", +        "Set QT_QPA_PLATFORMTHEME=kde to use it instead of the Cocoa \
plugin." +    ],
+    "Url": [ "https://github.com/RJVB/osx-integration" ]
 }
diff --git a/src/platformtheme/kdirselectdialog.cpp \
b/src/platformtheme/kdirselectdialog.cpp index 9d13ec4..3bf1b78 100644
--- a/src/platformtheme/kdirselectdialog.cpp
+++ b/src/platformtheme/kdirselectdialog.cpp
@@ -411,6 +411,9 @@ KDirSelectDialog::KDirSelectDialog(const QUrl &startDir, bool \
localOnly, QWidget  
 KDirSelectDialog::~KDirSelectDialog()
 {
+    delete d->m_placesView;
+    delete d->m_treeView;
+    delete d->m_urlCombo;
     delete d;
 }
 
diff --git a/src/platformtheme/kfiletreeview.cpp \
b/src/platformtheme/kfiletreeview.cpp index 77b128d..69ba3bb 100644
--- a/src/platformtheme/kfiletreeview.cpp
+++ b/src/platformtheme/kfiletreeview.cpp
@@ -79,6 +79,7 @@ void KFileTreeView::Private::_k_expanded(const QModelIndex \
&baseIndex)  {
     QModelIndex index = mProxyModel->mapFromSource(baseIndex);
 
+    q->setExpanded(index, true);
     q->selectionModel()->clearSelection();
     q->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
     q->scrollTo(index);
@@ -108,6 +109,8 @@ KFileTreeView::KFileTreeView(QWidget *parent)
 
 KFileTreeView::~KFileTreeView()
 {
+    delete d->mSourceModel;
+    delete d->mProxyModel;
     delete d;
 }
 
diff --git a/src/platformtheme/kfontsettingsdata.cpp \
b/src/platformtheme/kfontsettingsdata.cpp index c2eec44..6e43edd 100644
--- a/src/platformtheme/kfontsettingsdata.cpp
+++ b/src/platformtheme/kfontsettingsdata.cpp
@@ -21,6 +21,8 @@
 #undef QT_NO_CAST_FROM_ASCII
 
 #include "kfontsettingsdata.h"
+#include "platformtheme_logging.h"
+
 #include <QCoreApplication>
 #include <QString>
 #include <QVariant>
@@ -35,7 +37,7 @@
 #include <kconfiggroup.h>
 
 KFontSettingsData::KFontSettingsData()
-    : QObject(0)
+    : QObject(nullptr)
 {
 #ifdef DBUS_SUPPORT_ENABLED
     QMetaObject::invokeMethod(this, "delayedDBusConnects", Qt::QueuedConnection);
@@ -71,7 +73,13 @@ KSharedConfigPtr &KFontSettingsData::kdeGlobals()
 {
     if (!mKdeGlobals) {
         if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_CONFIG_FILE")) {
-            mKdeGlobals = \
KSharedConfig::openConfig(qgetenv("QT_QPA_PLATFORMTHEME_CONFIG_FILE"), \
KConfig::NoGlobals); +            const auto \
fname(qgetenv("QT_QPA_PLATFORMTHEME_CONFIG_FILE")); +            mKdeGlobals = \
KSharedConfig::openConfig(fname, KConfig::NoGlobals); +            const auto \
foundFile = QStandardPaths::locate(mKdeGlobals->locationType(), mKdeGlobals->name()); \
+            if (foundFile.isEmpty()) { +                qCWarning(PLATFORMTHEME) << \
"WARNING: could not open config file" << fname +                    << "in" << \
QStandardPaths::standardLocations(mKdeGlobals->locationType()); +            }
         } else {
             mKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), \
KConfig::NoGlobals);  }
diff --git a/src/platformtheme/kfontsettingsdatamac.h \
b/src/platformtheme/kfontsettingsdatamac.h index ee99919..91e4450 100644
--- a/src/platformtheme/kfontsettingsdatamac.h
+++ b/src/platformtheme/kfontsettingsdatamac.h
@@ -23,6 +23,9 @@
 #define KFONTSETTINGSDATAMAC_H
 
 #include "kfontsettingsdata.h"
+#include <QFontDatabase>
+
+class KdeMacTheme;
 
 class KFontSettingsDataMac : public KFontSettingsData
 {
@@ -41,9 +44,11 @@ public:
         FontTypesCount
     };
 
-    KFontSettingsDataMac();
+    KFontSettingsDataMac(KdeMacTheme *theme);
     ~KFontSettingsDataMac();
 
+    const char *fontNameFor(QFontDatabase::SystemFont role) const;
+
 public Q_SLOTS:
     void dropFontSettingsCache();
 
@@ -52,8 +57,14 @@ protected Q_SLOTS:
 
 public:
     QFont *font(FontTypes fontType);
+    bool usingCoreText();
+
 private:
+    KFontSettingsDataMac();
+
     QFont *mFonts[FontTypesCount];
+    KdeMacTheme *mTheme;
+    bool mUseCoreText;
 };
 
 #endif // KFONTSETTINGSDATAMAC_H
diff --git a/src/platformtheme/kfontsettingsdatamac.mm \
b/src/platformtheme/kfontsettingsdatamac.mm index ebbd1c1..3c7606c 100644
--- a/src/platformtheme/kfontsettingsdatamac.mm
+++ b/src/platformtheme/kfontsettingsdatamac.mm
@@ -20,6 +20,7 @@
 */
 
 #include "kfontsettingsdatamac.h"
+#include "kdemactheme.h"
 #include "platformtheme_logging.h"
 
 #include <QDebug>
@@ -62,7 +63,7 @@ KFontData DefaultFontData[KFontSettingsDataMac::FontTypesCount] = {
     { GeneralId, "messageBoxFont",       DefaultFont,       13, QFont::Bold, \
QFont::SansSerif, "Bold" }  };
 
-static const char *fontNameFor(QFontDatabase::SystemFont role)
+const char *KFontSettingsDataMac::fontNameFor(QFontDatabase::SystemFont role) const
 {
     QFont qf = QFontDatabase::systemFont(role);
     if (!qf.defaultFamily().isEmpty()) {
@@ -74,7 +75,7 @@ static const char *fontNameFor(QFontDatabase::SystemFont role)
         } else {
             fn = strdup(qf.defaultFamily().toLocal8Bit().data());
         }
-        if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) {
+        if (mTheme->verbose) {
             qCWarning(PLATFORMTHEME) << "fontNameFor" << role << "font:" << qf << \
"name:" << fn;  }
         return fn;
@@ -83,7 +84,7 @@ static const char *fontNameFor(QFontDatabase::SystemFont role)
     }
 }
 
-void initDefaultFonts()
+void initDefaultFonts(KFontSettingsDataMac *instance)
 {
     const char *fn;
     static bool active = false;
@@ -95,19 +96,19 @@ void initDefaultFonts()
     active = true;
 
     if (!LocalDefaultFont) {
-        fn = fontNameFor(QFontDatabase::GeneralFont);
+        fn = instance->fontNameFor(QFontDatabase::GeneralFont);
         LocalDefaultFont = fn;
     }
     for (int i = 0 ; i < KFontSettingsDataMac::FontTypesCount ; ++i) {
         switch(i) {
             case KFontSettingsDataMac::FixedFont:
-                fn = fontNameFor(QFontDatabase::FixedFont);
+                fn = instance->fontNameFor(QFontDatabase::FixedFont);
                 break;
             case KFontSettingsDataMac::WindowTitleFont:
-                fn = fontNameFor(QFontDatabase::TitleFont);
+                fn = instance->fontNameFor(QFontDatabase::TitleFont);
                 break;
             case KFontSettingsDataMac::SmallestReadableFont:
-                fn = fontNameFor(QFontDatabase::SmallestReadableFont);
+                fn = instance->fontNameFor(QFontDatabase::SmallestReadableFont);
                 break;
             default:
                 fn = LocalDefaultFont;
@@ -129,7 +130,8 @@ void initDefaultFonts()
     active = false;
 }
 
-KFontSettingsDataMac::KFontSettingsDataMac()
+KFontSettingsDataMac::KFontSettingsDataMac(KdeMacTheme *theme)
+    : mTheme(theme)
 {
 #ifdef DBUS_SUPPORT_ENABLED
     QMetaObject::invokeMethod(this, "delayedDBusConnects", Qt::QueuedConnection);
@@ -140,6 +142,72 @@ KFontSettingsDataMac::KFontSettingsDataMac()
         // delete mFonts[i];
         mFonts[i] = 0;
     }
+
+    if (QGuiApplication::platformName().contains(QLatin1String("cocoa"))) {
+        KConfigGroup general(kdeGlobals(), "General");
+        const QString fontEngine = general.readEntry("fontEngine", QString());
+        // don't do anything if no instructions are given in kdeglobals or the \
environment +        bool useFreeType = false, useFontConfig = false;
+        mUseCoreText = false;
+        if (!fontEngine.isEmpty()) {
+            useFreeType = fontEngine.compare(QLatin1String("FreeType"), \
Qt::CaseInsensitive) == 0; +            useFontConfig = \
fontEngine.compare(QLatin1String("FontConfig"), Qt::CaseInsensitive) == 0; +          \
// fontEngine=CoreText is the default and only handled so we can warn appropriately + \
// when the user tries to activate another, unknown font engine. +            \
mUseCoreText = fontEngine.compare(QLatin1String("CoreText"), Qt::CaseInsensitive) == \
0; +        }
+        if (qgetenv("QT_MAC_FONTENGINE").toLower() == "freetype") {
+            useFontConfig = false;
+            useFreeType = true;
+        }
+        if (qgetenv("QT_MAC_FONTENGINE").toLower() == "fontconfig") {
+            useFreeType = false;
+            useFontConfig = true;
+        }
+        if (qgetenv("QT_MAC_FONTENGINE").toLower() == "coretext") {
+            // CoreText overrides all
+            mUseCoreText = true;
+        }
+        QString desired;
+        bool result = false;
+        const auto ftptr = mTheme->platformFunction("qt_mac_use_freetype");
+        const auto fcptr = mTheme->platformFunction("qt_mac_use_fontconfig");
+        typedef bool (*fontengineEnabler)(bool enabled);
+        if (mUseCoreText) {
+            desired = QStringLiteral("CoreText");
+            if (fcptr) {
+                reinterpret_cast<fontengineEnabler>(fcptr)(false);
+            }
+            if (ftptr) {
+                result = reinterpret_cast<fontengineEnabler>(ftptr)(false);
+                if (!result) {
+                    // at this point failure *probably* means that:
+                    qCWarning(PLATFORMTHEME) << "The" << desired << "fontengine was \
probably still enabled"; +                }
+            }
+        } else if (useFontConfig) {
+            desired = QStringLiteral("FontConfig");
+            if (fcptr) {
+                result = reinterpret_cast<fontengineEnabler>(fcptr)(useFontConfig);
+            } else {
+                qCWarning(PLATFORMTHEME) << "Cannot use the FontConfig \
fontengine/fontdatabase:\n" +                    "\tthis probably means Qt was built \
without FontConfig support or\n" +                    "\tthat you're not using the \
QAltCocoa QPA plugin."; +            }
+        } else if (useFreeType) {
+            desired = QStringLiteral("FreeType");
+            if (ftptr) {
+                result = reinterpret_cast<fontengineEnabler>(ftptr)(useFreeType);
+            } else {
+                qCWarning(PLATFORMTHEME) << "Cannot use the FreeType \
fontdatabase:\n" +                    "\tthis probably means Qt was built without \
FreeType support or\n" +                    "\tthat you're not using the QAltCocoa \
QPA plugin."; +            }
+        }
+    } else {
+        mUseCoreText = false;
+    }
+
 }
 
 KFontSettingsDataMac::~KFontSettingsDataMac()
@@ -178,7 +246,7 @@ QFont *KFontSettingsDataMac::font(FontTypes fontType)
             // we prefer to return NULL if called through recursively.
             if (!active) {
                 active = true;
-                initDefaultFonts();
+                initDefaultFonts(this);
                 active = false;
             } else {
                 // our caller must handle NULL, preferably by relaying the font \
request @@ -207,7 +275,6 @@ QFont *KFontSettingsDataMac::font(FontTypes fontType)
         const KFontData &fontData = DefaultFontData[fontType];
 
         cachedFont = new QFont(QLatin1String(fontData.FontName), fontData.Size, \
                forceBold? QFont::Bold : fontData.Weight);
-        cachedFont->setStyleHint(fontData.StyleHint);
         // ignore the default stylehint; works better converting medium -> bold
 //         cachedFont->setStyleName(QLatin1String(fontData.StyleName));
 //         if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) {
@@ -230,6 +297,13 @@ QFont *KFontSettingsDataMac::font(FontTypes fontType)
             }
         }
 
+        // experimental: force outline mode when not using CoreText. This should \
prevent the FreeType +        // font engine from picking up and using X11 bitmap \
fonts, should those be installed. +        if (mUseCoreText) {
+            cachedFont->setStyleHint(fontData.StyleHint);
+        } else {
+            cachedFont->setStyleHint(fontData.StyleHint, QFont::ForceOutline);
+        }
         mFonts[fontType] = cachedFont;
     }
     return cachedFont;
diff --git a/src/platformtheme/khintssettings.cpp \
b/src/platformtheme/khintssettings.cpp index ae63e83..d450476 100644
--- a/src/platformtheme/khintssettings.cpp
+++ b/src/platformtheme/khintssettings.cpp
@@ -59,13 +59,20 @@
 #include <X11/Xcursor/Xcursor.h>
 #endif
 
-static const QString defaultLookAndFeelPackage = \
QStringLiteral("org.kde.breeze.desktop"); +static const QString \
defaultLookAndFeelPackage = QStringLiteral("com.apple.macintosh.desktop");  
 KSharedConfigPtr &KHintsSettings::kdeGlobals()
 {
     if (!mKdeGlobals) {
+        verbose = qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE");
         if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_CONFIG_FILE")) {
-            mKdeGlobals = \
KSharedConfig::openConfig(qgetenv("QT_QPA_PLATFORMTHEME_CONFIG_FILE"), \
KConfig::NoGlobals); +            const auto \
fname(qgetenv("QT_QPA_PLATFORMTHEME_CONFIG_FILE")); +            mKdeGlobals = \
KSharedConfig::openConfig(fname, KConfig::NoGlobals); +            const auto \
foundFile = QStandardPaths::locate(mKdeGlobals->locationType(), mKdeGlobals->name()); \
+            if (foundFile.isEmpty()) { +                qCWarning(PLATFORMTHEME) << \
"WARNING: could not open config file" << fname +                    << "in" << \
QStandardPaths::standardLocations(mKdeGlobals->locationType()); +            }
         } else {
             mKdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), \
KConfig::NoGlobals);  }
@@ -73,6 +80,16 @@ KSharedConfigPtr &KHintsSettings::kdeGlobals()
     return mKdeGlobals;
 }
 
+KSharedConfigPtr &KHintsSettings::LnfConfig()
+{
+    return mLnfConfig;
+}
+
+KSharedConfigPtr &KHintsSettings::DefaultLnfConfig()
+{
+    return mDefaultLnfConfig;
+}
+
 KHintsSettings::KHintsSettings() : QObject(0)
 {
     kdeGlobals();
@@ -83,6 +100,10 @@ KHintsSettings::KHintsSettings() : QObject(0)
     mDefaultLnfConfig = \
KSharedConfig::openConfig(QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("plasma/look-and-feel/") + looknfeel + \
QStringLiteral("/contents/defaults")));  if (looknfeel != defaultLookAndFeelPackage) \
{  mLnfConfig = KSharedConfig::openConfig(QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("plasma/look-and-feel/") + defaultLookAndFeelPackage + \
QStringLiteral("/contents/defaults"))); +        if (verbose) {
+            qCWarning(PLATFORMTHEME) << "User-selected look-and-feel:" << looknfeel \
<< mDefaultLnfConfig->name(); +            qCWarning(PLATFORMTHEME) << "Default \
look-and-feel:" << defaultLookAndFeelPackage << mLnfConfig->name(); +        }
     }
 
     const auto cursorBlinkRate = cg.readEntry("CursorBlinkRate", 1000);
@@ -172,10 +193,12 @@ QVariant KHintsSettings::readConfigValue(const QString &group, \
const QString &ke  }
     }
 
+#ifndef Q_OS_MACOS
     KConfigGroup lnfCg(mDefaultLnfConfig, group);
     if (lnfCg.isValid()) {
         return lnfCg.readEntry(key, defaultValue);
     }
+#endif
 
     return defaultValue;
 }
diff --git a/src/platformtheme/khintssettings.h b/src/platformtheme/khintssettings.h
index 8cc58dd..bdd2ec6 100644
--- a/src/platformtheme/khintssettings.h
+++ b/src/platformtheme/khintssettings.h
@@ -74,6 +74,9 @@ protected Q_SLOTS:
 
 protected:
     KSharedConfigPtr &kdeGlobals();
+    KSharedConfigPtr &LnfConfig();
+    KSharedConfigPtr &DefaultLnfConfig();
+
     QVariant readConfigValue(const QString &group, const QString &key, const \
QVariant &defaultValue);  void loadPalettes();
     void iconChanged(int group);
@@ -97,6 +100,7 @@ private:
     KSharedConfigPtr mKdeGlobals;
     KSharedConfigPtr mDefaultLnfConfig;
     KSharedConfigPtr mLnfConfig;
+    bool verbose;
 };
 
 #endif //KHINTS_SETTINGS_H
diff --git a/src/platformtheme/khintssettingsmac.h \
b/src/platformtheme/khintssettingsmac.h index 57f00ff..71e17c0 100644
--- a/src/platformtheme/khintssettingsmac.h
+++ b/src/platformtheme/khintssettingsmac.h
@@ -28,12 +28,13 @@ class KConfigGroup;
 
 class QPalette;
 class KdeProxyStyle;
+class KdeMacTheme;
 
 class KHintsSettingsMac : public KHintsSettings
 {
     Q_OBJECT
 public:
-    explicit KHintsSettingsMac();
+    explicit KHintsSettingsMac(KdeMacTheme *theme);
     virtual ~KHintsSettingsMac();
 
     QStringList xdgIconThemePaths() const;
@@ -49,6 +50,9 @@ protected:
     void updateCursorTheme();
     void checkNativeTheme(const QString &theme);
 private:
+    KHintsSettingsMac();
+
+    KdeMacTheme *mTheme;
     KdeProxyStyle *styleProxy;
 };
 
diff --git a/src/platformtheme/khintssettingsmac.mm \
b/src/platformtheme/khintssettingsmac.mm index 0d98222..4591be8 100644
--- a/src/platformtheme/khintssettingsmac.mm
+++ b/src/platformtheme/khintssettingsmac.mm
@@ -22,6 +22,7 @@
  */
 
 #include "khintssettingsmac.h"
+#include "kdemactheme.h"
 #include "platformtheme_logging.h"
 
 #include <QDebug>
@@ -72,26 +73,50 @@ public:
     }
 };
 
-KHintsSettingsMac::KHintsSettingsMac()
-    : styleProxy(0)
+KHintsSettingsMac::KHintsSettingsMac(KdeMacTheme *theme)
+    : mTheme(theme)
+    , styleProxy(0)
 {
     KSharedConfigPtr mKdeGlobals = kdeGlobals();
-    if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) {
+    if (mTheme->verbose) {
         if (!mKdeGlobals->name().isEmpty()) {
             qCWarning(PLATFORMTHEME) << Q_FUNC_INFO << "config file:" << \
                mKdeGlobals->name()
                 << "(" << QStandardPaths::locate(mKdeGlobals->locationType(), \
mKdeGlobals->name()) << ")"; +        } else {
+            qCWarning(PLATFORMTHEME) << Q_FUNC_INFO << "config file:" << mKdeGlobals \
<< "has no known name";  }
     }
 
     KConfigGroup cg(mKdeGlobals, "KDE");
+    if (mTheme->verbose) {
+        qCWarning(PLATFORMTHEME) << "config group" << mKdeGlobals->name() << "." << \
cg.name() +            << "exists=" << cg.exists()
+            << "valid=" << cg.isValid()
+            << "groups=" << cg.groupList()
+            << "keys=" << cg.keyList();
+    }
 
     // we're overriding whatever the parent class configured
     hints().clear();
 
     KConfigGroup cgToolbar(mKdeGlobals, "Toolbar style");
+    if (mTheme->verbose) {
+        qCWarning(PLATFORMTHEME) << "config group" << mKdeGlobals->name() << "." << \
cgToolbar.name() +            << "exists=" << cgToolbar.exists()
+            << "valid=" << cgToolbar.isValid()
+            << "groups=" << cgToolbar.groupList()
+            << "keys=" << cgToolbar.keyList();
+    }
     hints()[QPlatformTheme::ToolButtonStyle] = toolButtonStyle(cgToolbar);
 
     KConfigGroup cgToolbarIcon(mKdeGlobals, "MainToolbarIcons");
+    if (mTheme->verbose) {
+        qCWarning(PLATFORMTHEME) << "config group" << mKdeGlobals->name() << "." << \
cgToolbarIcon.name() +            << "exists=" << cgToolbarIcon.exists()
+            << "valid=" << cgToolbarIcon.isValid()
+            << "groups=" << cgToolbarIcon.groupList()
+            << "keys=" << cgToolbarIcon.keyList();
+    }
     hints()[QPlatformTheme::ToolBarIconSize] = cgToolbarIcon.readEntry("Size", 22);
 
     hints()[QPlatformTheme::ItemViewActivateItemOnSingleClick] = \
cg.readEntry("SingleClick", true); @@ -108,15 +133,28 @@ \
KHintsSettingsMac::KHintsSettingsMac()  << QStringLiteral("macintosh")
                << QStringLiteral("fusion")
                << QStringLiteral("windows");
+    if (mTheme->verbose) {
+        qCWarning(PLATFORMTHEME) << "initial widget style list:" << styleNames;
+    }
     const QString configuredStyle = cg.readEntry("widgetStyle", QString());
     if (!configuredStyle.isEmpty()) {
         styleNames.removeOne(configuredStyle);
         styleNames.prepend(configuredStyle);
+        if (mTheme->verbose) {
+            qCWarning(PLATFORMTHEME) << "Found widgetStyle" << configuredStyle << \
"in config file"; +        }
     }
     const QString lnfStyle = readConfigValue(QStringLiteral("KDE"), \
                QStringLiteral("widgetStyle"), QString()).toString();
-    if (!lnfStyle.isEmpty()) {
+    if (!lnfStyle.isEmpty() && lnfStyle != configuredStyle) {
         styleNames.removeOne(lnfStyle);
         styleNames.prepend(lnfStyle);
+        if (mTheme->verbose) {
+            qCWarning(PLATFORMTHEME) << "Found widgetStyle" << lnfStyle << \
"look-and-feel definition" +                << (LnfConfig() ? LnfConfig()->name() : \
QStringLiteral("???")); +        }
+    }
+    if (mTheme->verbose) {
+        qCWarning(PLATFORMTHEME) << "final widget style list:" << styleNames;
     }
     hints()[QPlatformTheme::StyleNames] = styleNames;
     checkNativeTheme(configuredStyle);
@@ -257,9 +295,19 @@ void KHintsSettingsMac::slotNotifyChange(int type, int arg)
                 << QStringLiteral("macintosh")
                 << QStringLiteral("fusion")
                 << QStringLiteral("windows");
+        if (mTheme->verbose) {
+            qCWarning(PLATFORMTHEME) << "initial widget style list:" << styleNames;
+        }
         const QString lnfStyle = readConfigValue(QStringLiteral("KDE"), \
QStringLiteral("widgetStyle"), QString()).toString();  if (!lnfStyle.isEmpty() && \
!styleNames.contains(lnfStyle)) {  styleNames.prepend(lnfStyle);
+            if (mTheme->verbose) {
+                qCWarning(PLATFORMTHEME) << "Found widgetStyle" << lnfStyle << \
"look-and-feel definition" +                    << (LnfConfig() ? LnfConfig()->name() \
: QStringLiteral("???")); +            }
+        }
+        if (mTheme->verbose) {
+            qCWarning(PLATFORMTHEME) << "final widget style list:" << styleNames;
         }
         hints()[QPlatformTheme::StyleNames] = styleNames;
 
diff --git a/src/platformtheme/main_cocoa.cpp b/src/platformtheme/main_cocoa.cpp
index 41c4084..ac1ff0e 100644
--- a/src/platformtheme/main_cocoa.cpp
+++ b/src/platformtheme/main_cocoa.cpp
@@ -24,8 +24,10 @@
 #include <QWidget>
 #include <QApplication>
 #include <QDebug>
+#include <QPluginLoader>
 
 #include "kdemactheme.h"
+#include "platformtheme_logging.h"
 
 #include <config-platformtheme.h>
 
@@ -39,6 +41,8 @@
 // This file should be kept in sync with main_kde.cpp !!
 // NB NB
 
+static QPluginLoader unloadProtection;
+
 class CocoaPlatformThemePlugin : public QPlatformThemePlugin
 {
     Q_OBJECT
@@ -47,16 +51,45 @@ public:
     CocoaPlatformThemePlugin(QObject *parent = Q_NULLPTR)
         : QPlatformThemePlugin(parent)
     {
+        if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) {
+            qCWarning(PLATFORMTHEME) << "The Cocoa platform theme plugin has been \
disabled because of QT_QPA_PLATFORMTHEME_DISABLED"; +        }
         if (qEnvironmentVariableIsSet("KDE_LAYOUT_USES_WIDGET_RECT")) {
             qApp->installEventFilter(this);
         }
     }
+    ~CocoaPlatformThemePlugin()
+    {
+        if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) {
+            qCWarning(PLATFORMTHEME) << Q_FUNC_INFO;
+        }
+    }
 
     QPlatformTheme *create(const QString &key, const QStringList &paramList) \
override  {
         Q_UNUSED(key)
         Q_UNUSED(paramList)
-        return new KdeMacTheme;
+        if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) {
+            if (unloadProtection.fileName().isEmpty()) {
+                unloadProtection.setFileName(QStringLiteral("platformthemes/" \
PLATFORM_PLUGIN_FILE_NAME)); +                if \
(unloadProtection.fileName().isEmpty()) { +                    // try with the \
non-standard extension - probably redundant but I won't +                    // count \
on Qt to try the .so extension on Mac forever. +                    \
unloadProtection.setFileName(QStringLiteral("platformthemes/" \
PLATFORM_PLUGIN_FILE_NAME ".so")); +                }
+                // using a global static loader instance should already prevent us \
from being unloaded +                // too early; add an additional layer of \
protection: +                \
unloadProtection.setLoadHints(QLibrary::PreventUnloadHint); +                bool \
success = unloadProtection.load(); +                if \
(qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) { +                    \
qCWarning(PLATFORMTHEME) << "loaded from:" +                        << \
unloadProtection.fileName() << "unload protection:" << success; +                }
+            }
+            return new KdeMacTheme;
+        } else {
+            return nullptr;
+        }
     }
 protected:
     bool eventFilter(QObject *object, QEvent *event) override
diff --git a/src/platformtheme/main_kde.cpp b/src/platformtheme/main_kde.cpp
index 3de5d18..4ff3dcc 100644
--- a/src/platformtheme/main_kde.cpp
+++ b/src/platformtheme/main_kde.cpp
@@ -24,8 +24,10 @@
 #include <QWidget>
 #include <QApplication>
 #include <QDebug>
+#include <QPluginLoader>
 
 #include "kdemactheme.h"
+#include "platformtheme_logging.h"
 
 #include <config-platformtheme.h>
 
@@ -37,6 +39,8 @@
 // This file should be kept in sync with main_kde.cpp !!
 // NB NB
 
+static QPluginLoader unloadProtection;
+
 class KdePlatformThemePlugin : public QPlatformThemePlugin
 {
     Q_OBJECT
@@ -45,6 +49,10 @@ public:
     KdePlatformThemePlugin(QObject *parent = Q_NULLPTR)
         : QPlatformThemePlugin(parent)
     {
+        if (qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) {
+            qCWarning(PLATFORMTHEME) << "The KDE platform theme plugin has been \
disabled because of QT_QPA_PLATFORMTHEME_DISABLED"; +            return;
+        }
         if (qEnvironmentVariableIsSet("KDE_LAYOUT_USES_WIDGET_RECT")) {
             qApp->installEventFilter(this);
         }
@@ -54,7 +62,26 @@ public:
     {
         Q_UNUSED(key)
         Q_UNUSED(paramList)
-        return new KdeMacTheme;
+        if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) {
+            if (unloadProtection.fileName().isEmpty()) {
+                unloadProtection.setFileName(QStringLiteral("platformthemes/" \
PLATFORM_PLUGIN_FILE_NAME)); +                if \
(unloadProtection.fileName().isEmpty()) { +                    // try with the \
non-standard extension +                    \
unloadProtection.setFileName(QStringLiteral("platformthemes/" \
PLATFORM_PLUGIN_FILE_NAME ".so")); +                }
+                // using a global static loader instance should already prevent us \
from being unloaded +                // too early; add an additional layer of \
protection: +                \
unloadProtection.setLoadHints(QLibrary::PreventUnloadHint); +                bool \
success = unloadProtection.load(); +                if \
(qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_VERBOSE")) { +                    \
qCWarning(PLATFORMTHEME) << "loaded from:" +                        << \
unloadProtection.fileName() << "unload protection:" << success; +                }
+            }
+            return new KdeMacTheme;
+        } else {
+            return nullptr;
+        }
     }
 protected:
     bool eventFilter(QObject *object, QEvent *event)
diff --git a/plintegration-cumpatch1.diff \
b/src/platformtheme/plintegration-cumpatch1.diff similarity index 100%
rename from plintegration-cumpatch1.diff
rename to src/platformtheme/plintegration-cumpatch1.diff


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

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