From c584380c6901b1bcd9f8100fa1087b09d3cb023d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jan 2020 13:20:42 +0100 Subject: Windows QPA: Update documentation on command line options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort alphabetically and add recent relevant options with version information. Change-Id: I10c8cc82ce357775ed68cb811a0c906cd38633a5 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/gui/kernel/qguiapplication.cpp') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bdcea275c3..2b3299f745 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -605,8 +605,13 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME The following parameters are available for \c {-platform windows}: \list + \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as + Qt::GroupSwitchModifier (since Qt 5.12). \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. + + \li \c {dpiawareness=[0|1|2} Sets the DPI awareness of the process + (see \l{High DPI Displays}, since Qt 5.4). \li \c {fontengine=freetype}, uses the FreeType font engine. \li \c {menus=[native|none]}, controls the use of native menus. @@ -616,10 +621,23 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME provide hover signals. They are mainly intended for Qt Quick. By default, they will be used if the application is not an instance of QApplication or for Qt Quick Controls 2 - applications. + applications (since Qt 5.10). - \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as - Qt::GroupSwitchModifier. + \li \c {nocolorfonts} Turn off DirectWrite Color fonts + (since Qt 5.8). + + \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). + + \li \c {nomousefromtouch} Ignores mouse events synthesized + from touch events by the operating system. + + \li \c {nowmpointer} Switches from Pointer Input Messages handling + to legacy mouse handling (since Qt 5.12). + \li \c {reverse} Activates Right-to-left mode (experimental). + Windows title bars will be shown accordingly in Right-to-left locales + (since Qt 5.13). + \li \c {tabletabsoluterange=} Sets a value for mouse mode detection + of WinTab tablets (Legacy, since Qt 5.3). \endlist The following parameter is available for \c {-platform cocoa} (on macOS): -- cgit v1.2.3 From 0a93db4d82c051164923a10e4382b12de9049b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Jan 2020 17:48:58 +0100 Subject: Unify application palette handling between QGuiApplication and QApplication The logic is now mostly handled in QGuiApplication, with QApplication only dealing with the widget-specific palettes and interaction between the style and the palette. The application now picks up changes to the platform theme and will re-resolve the current application palette appropriately. This also works even if an explicit application palette has been set, in which case any missing roles are filled in by the theme. The palette can now also be reset back to the default application palette that's fully based on the theme, by passing in the default constructed palette (or any palette that doesn't have any roles set). This is also correctly reflected in the Qt::AA_SetPalette attribute. Conceptually this means QGuiApplication and QApplication follow the same behavior as QWidget, where the palette falls back to a base or inherited palette for roles that are not set, in this case the theme. Behavior-wise this means that the default application palette of the application does not have any roles set, but clients should not have relied on this, nor does QWidget rely on that internally. It also means that setting a palette on the application and then getting it back again will not produce the same palette as set, since the palette was resolved against the theme in the meantime. This is the same behavior as for QWidget, and although it's a behavior change it's one towards a more sane behavior, so we accept it. [ChangeLog] Application palettes are now resolved against the platform's theme palette, the same way widget palettes are resolved against their parents, and the application palette. This means the application palette reflected through QGuiApplication::palette() may not be exactly the same palette as set via QGuiApplication::setPalette(). Change-Id: I76b99fcd27285e564899548349aa2a5713e5965d Reviewed-by: Vitaly Fanaskov Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 117 +++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 49 deletions(-) (limited to 'src/gui/kernel/qguiapplication.cpp') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ffd5b04276..445ad6b835 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -236,21 +236,6 @@ static bool qt_detectRTLLanguage() " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); } -static void initPalette() -{ - if (!QGuiApplicationPrivate::app_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); -} - -static inline void clearPalette() -{ - delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = nullptr; -} - static void initFontUnlocked() { if (!QGuiApplicationPrivate::app_font) { @@ -691,7 +676,7 @@ QGuiApplication::~QGuiApplication() d->session_manager = nullptr; #endif //QT_NO_SESSIONMANAGER - clearPalette(); + QGuiApplicationPrivate::clearPalette(); QFontDatabase::removeAllApplicationFonts(); #ifndef QT_NO_CURSOR @@ -1611,7 +1596,7 @@ void QGuiApplicationPrivate::init() if (platform_integration == nullptr) createPlatformIntegration(); - initPalette(); + updatePalette(); QFont::initialize(); initThemeHints(); @@ -3289,46 +3274,97 @@ QClipboard * QGuiApplication::clipboard() */ /*! - Returns the default application palette. + Returns the current application palette. + + Roles that have not been explicitly set will reflect the system's platform theme. \sa setPalette() */ QPalette QGuiApplication::palette() { - initPalette(); + if (!QGuiApplicationPrivate::app_pal) + QGuiApplicationPrivate::updatePalette(); + return *QGuiApplicationPrivate::app_pal; } +void QGuiApplicationPrivate::updatePalette() +{ + if (app_pal) { + if (setPalette(*app_pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); + } else { + setPalette(QPalette()); + } +} + +void QGuiApplicationPrivate::clearPalette() +{ + delete app_pal; + app_pal = nullptr; +} + /*! - Changes the default application palette to \a pal. + Changes the application palette to \a pal. + + The color roles from this palette are combined with the system's platform + theme to form the application's final palette. \sa palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (!QGuiApplicationPrivate::setPalette(pal)) - return; - - QCoreApplication::setAttribute(Qt::AA_SetPalette); - - if (qGuiApp) - qGuiApp->d_func()->sendApplicationPaletteChange(); + if (QGuiApplicationPrivate::setPalette(pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); } bool QGuiApplicationPrivate::setPalette(const QPalette &palette) { - if (app_pal && palette.isCopyOf(*app_pal)) + // Resolve the palette against the theme palette, filling in + // any missing roles, while keeping the original resolve mask. + QPalette basePalette = qGuiApp ? qGuiApp->d_func()->basePalette() : Qt::gray; + basePalette.resolve(0); // The base palette only contributes missing colors roles + QPalette resolvedPalette = palette.resolve(basePalette); + + if (app_pal && resolvedPalette == *app_pal && resolvedPalette.resolve() == app_pal->resolve()) return false; if (!app_pal) - app_pal = new QPalette(palette); + app_pal = new QPalette(resolvedPalette); else - *app_pal = palette; + *app_pal = resolvedPalette; + + QCoreApplication::setAttribute(Qt::AA_SetPalette, app_pal->resolve() != 0); return true; } +/* + Returns the base palette used to fill in missing roles in + the current application palette. + + Normally this is the theme palette, but QApplication + overrides this for compatibility reasons. +*/ +QPalette QGuiApplicationPrivate::basePalette() const +{ + return platformTheme() ? *platformTheme()->palette() : Qt::gray; +} + +void QGuiApplicationPrivate::handlePaletteChanged(const char *className) +{ + if (!className) { + Q_ASSERT(app_pal); + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + } + + if (is_app_running && !is_app_closing) { + QEvent event(QEvent::ApplicationPaletteChange); + QGuiApplication::sendEvent(qGuiApp, &event); + } +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); @@ -4127,11 +4163,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!testAttribute(Qt::AA_SetPalette)) { - clearPalette(); - initPalette(); - sendApplicationPaletteChange(); - } + updatePalette(); + if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); clearFontUnlocked(); @@ -4140,20 +4173,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() initThemeHints(); } -void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) -{ - Q_UNUSED(toAllWidgets) - - if (!className) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); - - if (!is_app_running || is_app_closing) - return; - - QEvent event(QEvent::ApplicationPaletteChange); - QGuiApplication::sendEvent(QGuiApplication::instance(), &event); -} - #if QT_CONFIG(draganddrop) void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) { -- cgit v1.2.3