[KDE/Mac] Review Request 126198: [OS X] adaptations for the KdePlatformTheme

René J.V. Bertin rjvbertin at gmail.com
Sat Dec 12 18:08:39 UTC 2015

This is an automatically generated e-mail. To reply, visit:

(Updated Dec. 12, 2015, 7:08 p.m.)

Review request for KDE Software on Mac OS X, KDE Frameworks and Valorie Zimmerman.


I've finally gotten around to building Kate, and wanted to show some comparisons, alas not completely working to my advantage.

For some reason, Christoph Cullman's own standalone app bundle build puts up an interface that has less glitches than the purely native interface I get when I deactivate (move aside) the frameworkintegration port with its KdeMacTheme plugin. The glitches I see with my own build are very much like what we used to see in KDE4/MacPorts. MacPorts never patched Qt's Mac platform theme, and Qt4 had no QStandardPaths that we could (had to) patch. So what I'm seeing in my kate5 build is unlikely to be a direct result of using XDG compliant paths on OS X. Maybe the fact that those XDG compliant paths do contain all kinds of stuff that's not present in the standalone app bundle has something to do with it.
BTW, note that my build is an app bundle too, except that it contains only the strictly necessary files (executable, info dict and app icon).
Sadly for me, using the macintosh style with the KdeMacTheme plugin does not fix all the glitches though it does make the interface look less overdimensioned.

I hesitated to add a snap of kate running under X11 (with the macintosh style) but didn't to avoid confusion. However, it could have served to underline one tidbit that I didn't know myself until very recently:

> QWidgets (and QML) don't use native UI views. They draw everything themself. The drawing is done in the style.

In other words, there is no native NSButton "behind" a QPushButton, no NSTabBar behind a QTabBar, etc. The mac style undoubtedly uses APIs that exist only on OS X to draw "everything", but it'll happily draw onto an X11 window (and create an almost identical result). This probably explains in part why we're seeing the glitches we're seeing, but as far as I'm concerned it also gives the native style less of a "it's native and thus better" status.

Repository: frameworkintegration


The KdePlatformTheme plugin can be enabled on OS X with a minimal patch to Qt5; all that is required is to include the `qgenericunixservices` and `qgenericunixthemes` components in the build, and to append `"kde"` to the list returned by `QCocoaIntegration::themeNames()` for instance under the condition that `KDE_SESSION_VERSION` is set to a suitable value in the environment.

This will allow KF5 and Qt5 applications to use the theme selected through KDE if FrameworkIntegration is installed and KDE_SESSION_VERSION is set, which seems like a sufficiently specific set of conditions that is easy to avoid by users who prefer to use the Mac native theme.

While requestion the KDE theme is also possible through `-style kde` or `env QT_STYLE_OVERRIDE=kde` the use of the KdePlatformTheme plugin appears to be the only way to get the full theme, including the font and colour selection. In my opinion it is above all the font customisation which is a very welcome feature for Qt/Mac; by default Qt applications use the default system font (Lucida Grande 13pt or even 14pt) throughout. This is a good UI font, but not at that size (and most "native" OS X applications indeed use a range of smaller sizes, depending on role.

It does have introduce a number of regressions, which the current patch aims to address. The most visible and problematic of these regressions is the loss of the Mac-style menu bar and thus of all menu items (actions).

The fix is straightforward : on OS X (and similarly affected platforms?), an instance of the native Cocoa platform theme is created through the private API, and used as a fallback rather than immediately falling back to the default implementations from `QPlatformTheme`. In addition, methods missing from (not overridden by) `KdePlatformTheme` are provided on OS X and call the corresponding methods from the native theme. It is this change which restores the menubar and even the Dock menu functionality.
One minor regression remains but should be easy to fix (elsewhere?): the Preferences menu loses its keyboard shortcut (Command-,).

Given the fallback nature of the native platform instance I have preferred to print a warning rather than using something like `qFatal`, above all because the message printed by qFatal tends to get lost on OS X. I can replace my use of `qWarning` with a dialog giving the choice between continuing or exiting the application - code that would be called in the menu methods because only there is it certain that the application actually needs a menubar.

In line with experience and feedback from the KDE(4)-Mac community I have decided to force the use of native dialogs rather than the ones from the KdePlatformPlugin.

In addition I set the fallback value for `ShowIconsOnPushButtons` to false in line with platform guidelines, and ensure that the autotests are not built as app bundles.


  src/platformtheme/kfontsettingsdatamac.h PRE-CREATION 
  src/platformtheme/kfontsettingsdatamac.mm PRE-CREATION 
  src/platformtheme/CMakeLists.txt 23f590e 
  src/platformtheme/kdemactheme.h PRE-CREATION 
  src/platformtheme/kdemactheme.mm PRE-CREATION 
  src/platformtheme/kdeplatformtheme.h 97d09df 
  src/platformtheme/kdeplatformtheme.cpp 80dbcb7 
  src/platformtheme/kfontsettingsdata.h 4b92c7d 
  src/platformtheme/kfontsettingsdata.cpp b0a4bbf 
  src/platformtheme/khintssettings.h ec064d3 
  src/platformtheme/khintssettings.cpp 8adf6c5 
  src/platformtheme/khintssettingsmac.h PRE-CREATION 
  src/platformtheme/khintssettingsmac.mm PRE-CREATION 
  src/platformtheme/main_mac.cpp PRE-CREATION 

Diff: https://git.reviewboard.kde.org/r/126198/diff/


On Mac OS X with Qt 5.5.1, KF5 frameworks 5.16.0 and QtCurve git/head.

I have not verified to what extent my use of a private `QGuiApplication` API links builds to a specific Qt version (I consider that nothing shocking and a minor price to pay).
>>> Do I need to add some glue to the CMake file so that it will warn if the private headerfiles are not available? Apparently no changes were required to find them.

File Attachments (updated)

purely native OS X theme
native theme but with `-style kde`
using the KDEPlatformTheme
on Linux, using a purely "native" theme
KDEPlatformTheme with the "macintosh" native theme selected
kate built by Christoph Cullman as a completely standalone app bundle
kate/MacPorts in fully native Mac mode (but using XDG-compliant QSPs).
kate/MacPorts using the QtCurve style (but the native platform plugin)
kate/MacPorts using the KdeMacTheme plugin and the macintosh style
kate/MacPorts using the KdeMacTheme plugin and the QtCurve style


René J.V. Bertin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-mac/attachments/20151212/fb7644c9/attachment-0001.html>

More information about the kde-mac mailing list