diff --git a/README.md b/README.md index 49d3bc1..a5338ea 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,81 @@ # OS X Integration Improved integration of Qt and KDE applications with the Mac OS X desktop ### KDEPlatformTheme The plugin Mac KDE platform theme plugin makes it possible to use KDE font specifications and colour palettes, so that themes like Breeze, Oxygen or QtCurve look like they should but above all that applications use the fonts and font roles for which they were designed. This plugin functions as a wrapper; any request it cannot handle authoritatively itself will be handed off to the platform plugin, which means things like native menubars and Dock menus continue to work. Newer versions of the plugin introduced build-time preferences for file dialog styles (native or KDE) and more generic convenience features like click-and-hold to trigger a contextmenu and emulation of a Menu key (right Command+Option key-combo). Originally a custom-built Qt with a simple patch was required that would let the plugin load automatically like in a KDE session (KDE_SESSION_VERSION set to 4 or 5). Setting QT_QPA_PLATFORMTHEME=kde will work with a stock Qt install, 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. + This component should still build against Qt 5.5.x; the other components need at least Qt 5.8 . ### QMacStyle A modified fork of the native macintosh style from Qt 5.9 (git) which doesn't impose the Mac standard font for QComboBox menu items and provides support for named menu sections in context menus and menus attached to a "non-native" menubar. Also builds against Qt 5.8.0 . A standalone build of this component can be done using the provided QMake file (qmacstyle/macstyle.pro). ### QCocoaQPA A modified fork of the Cocoa platform plugin from Qt 5.9 (git; builds against Qt 5.8.0) which provides support for named menu sections under the native menubar 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. 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). 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 loaded instead (and will then load the modified or the stock cocoa platform plugin). A standalone build of this component can be done using the provided QMake file (qcocoa-qpa/qcocoa-standalone.pro). ### Building The preferred way of building this project is using CMake, and requires KDE's Extra CMake Modules (http://projects.kde.org/projects/kdesupport/extra-cmake-modules) ; this is also the only way to build the KDE platform theme plugin component. * CMake options: - BUILD_KDE_THEME_PLUGIN : should the KDE platform theme plugin be built? - BUILD_QT_PLUGINS : should the Qt style and QPA plugin components be built? * CMake options for the KDE platform theme plugin: - DEFINE_ICONTHEME_SETTINGS : Should the theme plugin define a standard theme and add the standard locations for icon themes to the search path? - PREFER_NATIVE_DIALOGS : Should native dialogs be preferred over Qt's cross-platform dialogs? - NEVER_NATIVE_DIALOGS : Should native dialogs never be used (when not already preferred)? - OVERRIDE_NATIVE_THEME : see above. NB: the Macintosh/Aqua widget style remains the default style! - 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. diff --git a/src/platformtheme/main_cocoa.cpp b/src/platformtheme/main_cocoa.cpp index 41c4084..22a625a 100644 --- a/src/platformtheme/main_cocoa.cpp +++ b/src/platformtheme/main_cocoa.cpp @@ -1,77 +1,85 @@ /* This file is part of the KDE libraries * Copyright 2013 Kevin Ottens * Copyright 2015 RenĂ© J.V. Bertin * * 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 * the Free Software Foundation; either version 2 of the License or ( at * your option ) version 3 or, at the discretion of KDE e.V. ( which shall * act as a proxy as in section 14 of the GPLv3 ), any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include "kdemactheme.h" +#include "platformtheme_logging.h" #include // We call ourselves the "cocoa" platform theme plugin. Doing that means we replace // the native platform theme. That is not a problem because the KdeMacTheme class proxies // the native theme. It just means that the native theme inherits a number of KDE // extensions, which are loaded automatically without user intervention like setting // an env. variable. // NB NB // This file should be kept in sync with main_kde.cpp !! // NB NB class CocoaPlatformThemePlugin : public QPlatformThemePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "cocoaplatformtheme.json") 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); } } QPlatformTheme *create(const QString &key, const QStringList ¶mList) override { Q_UNUSED(key) Q_UNUSED(paramList) - return new KdeMacTheme; + if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) { + return new KdeMacTheme; + } else { + return nullptr; + } } protected: bool eventFilter(QObject *object, QEvent *event) override { switch (event->type()) { case QEvent::ChildAdded: { QChildEvent *childEvent = static_cast(event); if (childEvent->child()->isWidgetType()) { QWidget* theChildWidget = qobject_cast(childEvent->child()); theChildWidget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); } } } return qApp->eventFilter(object, event); } }; #include "main_cocoa.moc" diff --git a/src/platformtheme/main_kde.cpp b/src/platformtheme/main_kde.cpp index 3de5d18..9942049 100644 --- a/src/platformtheme/main_kde.cpp +++ b/src/platformtheme/main_kde.cpp @@ -1,75 +1,84 @@ /* This file is part of the KDE libraries * Copyright 2013 Kevin Ottens * Copyright 2015 RenĂ© J.V. Bertin * * 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 * the Free Software Foundation; either version 2 of the License or ( at * your option ) version 3 or, at the discretion of KDE e.V. ( which shall * act as a proxy as in section 14 of the GPLv3 ), any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include "kdemactheme.h" +#include "platformtheme_logging.h" #include // We use a different internal class name for the Mac KDE platform theme plugin, but it will still // identify itself as "KDE" to Qt. This ensures that it will also be picked up when using // the XCB platform plugin (without patching it). // NB NB // This file should be kept in sync with main_kde.cpp !! // NB NB class KdePlatformThemePlugin : public QPlatformThemePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "kdeplatformtheme.json") 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); } } QPlatformTheme *create(const QString &key, const QStringList ¶mList) override { Q_UNUSED(key) Q_UNUSED(paramList) - return new KdeMacTheme; + if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORMTHEME_DISABLED")) { + return new KdeMacTheme; + } else { + return nullptr; + } } protected: bool eventFilter(QObject *object, QEvent *event) { switch (event->type()) { case QEvent::ChildAdded: { QChildEvent *childEvent = static_cast(event); if (childEvent->child()->isWidgetType()) { QWidget* theChildWidget = qobject_cast(childEvent->child()); theChildWidget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); } } } return qApp->eventFilter(object, event); } }; #include "main_kde.moc"