diff options
Diffstat (limited to 'src/gui')
40 files changed, 410 insertions, 70 deletions
diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in new file mode 100644 index 0000000000..d9313d4364 --- /dev/null +++ b/src/gui/Qt5GuiConfigExtras.cmake.in @@ -0,0 +1,20 @@ + +!!IF !contains(QT_CONFIG, angle) + +!!IF !isEmpty(CMAKE_GL_INCDIRS) + +find_path(_qt5gui_OPENGL_INCLUDE_DIR $$CMAKE_GL_HEADER_NAME + PATHS $$CMAKE_GL_INCDIRS + NO_DEFAULT_PATH) +if (NOT _qt5gui_OPENGL_INCLUDE_DIR) + message(FATAL_ERROR \"Failed to find \\\"$$CMAKE_GL_HEADER_NAME\\\" in \\\"$$CMAKE_GL_INCDIRS\\\", using the CMAKE_FIND_ROOT_PATH \\\"${CMAKE_FIND_ROOT_PATH}\\\".\") +endif() + +list(APPEND Qt5Gui_INCLUDE_DIRS ${_qt5gui_OPENGL_INCLUDE_DIR}) +set_property(TARGET Qt5::Gui APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5gui_OPENGL_INCLUDE_DIR}) + +unset(_qt5gui_OPENGL_INCLUDE_DIR CACHE) + +!!ENDIF + +!!ENDIF diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 4fd595ed5a..18157f8e2f 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -441,7 +441,6 @@ Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins); QAccessible::UpdateHandler QAccessible::updateHandler = 0; QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; -static bool accessibility_active = false; static bool cleanupAdded = false; #ifndef QT_NO_ACCESSIBILITY @@ -584,7 +583,6 @@ Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache) */ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) { - accessibility_active = true; if (!object) return 0; @@ -699,19 +697,26 @@ QAccessibleInterface *QAccessible::accessibleInterface(Id id) /*! - Returns true if an accessibility implementation has been requested - during the runtime of the application; otherwise returns false. + Returns true if the platform requested accessibility information. - Use this function to prevent potentially expensive notifications via - updateAccessibility(). + This function will return false until a tool such as a screen reader + accessed the accessibility framework. It is still possible to use + \l QAccessible::queryAccessibleInterface even if accessibility is not + active. But there will be no notifications sent to the platform. + + It is recommended to use this function to prevent expensive notifications + via updateAccessibility() when they are not needed. */ bool QAccessible::isActive() { - return accessibility_active; +#ifndef QT_NO_ACCESSIBILITY + if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) + return pfAccessibility->isActive(); +#endif + return false; } - /*! Sets the root object of the accessible objects of this application to \a object. All other accessible objects are reachable using object diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp index 2e36e5ac71..490fb7a407 100644 --- a/src/gui/accessible/qplatformaccessibility.cpp +++ b/src/gui/accessible/qplatformaccessibility.cpp @@ -73,6 +73,7 @@ Q_GLOBAL_STATIC(QVector<QAccessibleBridge *>, bridges) \sa QAccessible */ QPlatformAccessibility::QPlatformAccessibility() + : m_active(false) { } diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h index 26a22e492d..f86a9b6157 100644 --- a/src/gui/accessible/qplatformaccessibility.h +++ b/src/gui/accessible/qplatformaccessibility.h @@ -69,6 +69,11 @@ public: virtual void initialize(); virtual void cleanup(); + inline bool isActive() const { return m_active; } + inline void setActive(bool active) { m_active = active; } + +private: + bool m_active; }; QT_END_NAMESPACE diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 14c267df70..9238fd91a4 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -35,4 +35,20 @@ include(itemmodels/itemmodels.pri) QMAKE_LIBS += $$QMAKE_LIBS_GUI +load(cmake_functions) + +!contains(QT_CONFIG, angle) { + contains(QT_CONFIG, opengles1) { + CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES1) + CMAKE_GL_HEADER_NAME = GLES/gl.h + } else:contains(QT_CONFIG, opengles2) { + CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES2) + CMAKE_GL_HEADER_NAME = GLES2/gl2.h + } else { + CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL) + CMAKE_GL_HEADER_NAME = GL/gl.h + mac: CMAKE_GL_HEADER_NAME = gl.h + } +} + QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 7287f54e74..0efb9c2646 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4994,12 +4994,17 @@ int QImage::metric(PaintDeviceMetric metric) const break; case PdmPhysicalDpiX: - return qRound(d->dpmx * 0.0254 * d->devicePixelRatio); + return qRound(d->dpmx * 0.0254); break; case PdmPhysicalDpiY: - return qRound(d->dpmy * 0.0254 * d->devicePixelRatio); + return qRound(d->dpmy * 0.0254); break; + + case PdmDevicePixelRatio: + return d->devicePixelRatio; + break; + default: qWarning("QImage::metric(): Unhandled metric type %d", metric); break; diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index e612a2c374..5dd51843fb 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1513,9 +1513,9 @@ QList<QByteArray> QImageReader::supportedMimeTypes() for (int i = 0; i < _qt_NumFormats; ++i) mimeTypes << _qt_BuiltInFormats[i].mimeType; -#ifndef QT_NO_LIBRARY +#ifndef QT_NO_IMAGEFORMATPLUGIN supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanRead, &mimeTypes); -#endif // QT_NO_LIBRARY +#endif // QT_NO_IMAGEFORMATPLUGIN QList<QByteArray> sortedMimeTypes; for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 8823f9293d..a27dc9d16f 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -789,9 +789,9 @@ QList<QByteArray> QImageWriter::supportedMimeTypes() mimeTypes << "image/jpeg"; #endif -#ifndef QT_NO_LIBRARY +#ifndef QT_NO_IMAGEFORMATPLUGIN supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes); -#endif // QT_NO_LIBRARY +#endif // QT_NO_IMAGEFORMATPLUGIN QList<QByteArray> sortedMimeTypes; for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index f6de22851d..1071ed754b 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -956,6 +956,9 @@ int QPicture::metric(PaintDeviceMetric m) const case PdmDepth: val = 24; break; + case PdmDevicePixelRatio: + val = 1; + break; default: val = 0; qWarning("QPicture::metric: Invalid metric command"); diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 75b7a4ba06..4c1b30a6d8 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -120,6 +120,8 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con case QPaintDevice::PdmDpiY: // fall-through case QPaintDevice::PdmPhysicalDpiY: return qt_defaultDpiY(); + case QPaintDevice::PdmDevicePixelRatio: + return 1; default: qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 302945dbf8..f9a017c281 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -244,6 +244,7 @@ QImage QRasterPlatformPixmap::toImage(const QRect &rect) const QImage newImage(image.scanLine(clipped.y()) + clipped.x() * (du / 8), clipped.width(), clipped.height(), image.bytesPerLine(), image.format()); + newImage.setDevicePixelRatio(image.devicePixelRatio()); return newImage; } else { return image.copy(clipped); @@ -278,11 +279,13 @@ int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmDpiX: return qt_defaultDpiX(); case QPaintDevice::PdmPhysicalDpiX: - return qt_defaultDpiX() * image.devicePixelRatio(); + return qt_defaultDpiX(); case QPaintDevice::PdmDpiY: return qt_defaultDpiX(); case QPaintDevice::PdmPhysicalDpiY: - return qt_defaultDpiY() * image.devicePixelRatio(); + return qt_defaultDpiY(); + case QPaintDevice::PdmDevicePixelRatio: + return image.devicePixelRatio(); default: qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index eb87a8c31b..91374fe2dd 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -21,6 +21,7 @@ HEADERS += \ kernel/qplatformintegrationfactory_p.h \ kernel/qplatformintegrationplugin.h \ kernel/qplatformtheme.h\ + kernel/qplatformtheme_p.h \ kernel/qplatformthemefactory_p.h \ kernel/qplatformthemeplugin.h \ kernel/qplatformwindow.h \ diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 432929fec5..fba516c135 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -180,7 +180,7 @@ static void initPalette() if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(Qt::black); + QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); } static inline void clearPalette() @@ -1014,6 +1014,7 @@ void QGuiApplicationPrivate::init() // and QImage conversion functions qInitImageConversions(); + initPalette(); QFont::initialize(); #ifndef QT_NO_CURSOR @@ -1591,6 +1592,11 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (previous == newFocus) return; + if (newFocus) + if (QPlatformWindow *platformWindow = newFocus->handle()) + if (platformWindow->isAlertState()) + platformWindow->setAlertState(false); + QObject *previousFocusObject = previous ? previous->focusObject() : 0; if (previous) { diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 419fd541eb..bfdb8921af 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -101,7 +101,7 @@ private: QOpenGLVersionProfilePrivate* d; }; -inline uint qHash(const QOpenGLVersionProfile &v, uint seed) +inline uint qHash(const QOpenGLVersionProfile &v, uint seed = 0) { return qHash(static_cast<int>(v.profile() * 1000) + v.version().first * 100 + v.version().second * 10, seed); diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index f15559981b..df3d4dfef0 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -1096,6 +1096,40 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBru setBrush(cg, ToolTipText, toolTipText); } +Q_GUI_EXPORT QPalette qt_fusionPalette() +{ + QColor backGround(239, 235, 231); + QColor light = backGround.lighter(150); + QColor mid(backGround.darker(130)); + QColor midLight = mid.lighter(110); + QColor base = Qt::white; + QColor disabledBase(backGround); + QColor dark = backGround.darker(150); + QColor darkDisabled = QColor(209, 200, 191).darker(110); + QColor text = Qt::black; + QColor hightlightedText = Qt::white; + QColor disabledText = QColor(190, 190, 190); + QColor button = backGround; + QColor shadow = dark.darker(135); + QColor disabledShadow = shadow.lighter(150); + + QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base); + fusionPalette.setBrush(QPalette::Midlight, midLight); + fusionPalette.setBrush(QPalette::Button, button); + fusionPalette.setBrush(QPalette::Shadow, shadow); + fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText); + + fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); + + fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); + fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126)); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); + return fusionPalette; +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPalette &) { diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 70de75072c..e82e30df80 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -210,6 +210,11 @@ QPlatformServices *QPlatformIntegration::services() const \value ForeignWindows The platform allows creating QWindows which represent native windows created by other processes or anyway created by using native libraries. + + \value NonFullScreenWindows The platform supports top-level windows which do not + fill the screen. The default implementation returns true. Returning false for + this will cause all windows, including dialogs and popups, to be resized to fill the + screen. */ @@ -227,8 +232,7 @@ QPlatformServices *QPlatformIntegration::services() const bool QPlatformIntegration::hasCapability(Capability cap) const { - Q_UNUSED(cap); - return false; + return cap == NonFullScreenWindows; } QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const @@ -309,6 +313,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return false; case PasswordMaskDelay: return QPlatformTheme::defaultThemeHint(QPlatformTheme::PasswordMaskDelay); + case PasswordMaskCharacter: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::PasswordMaskCharacter); case FontSmoothingGamma: return qreal(1.7); case StartDragVelocity: diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index ddee6f05c8..b7a44b13de 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -90,7 +90,8 @@ public: WindowMasks, MultipleWindows, ApplicationState, - ForeignWindows + ForeignWindows, + NonFullScreenWindows }; virtual ~QPlatformIntegration() { } @@ -139,7 +140,8 @@ public: FontSmoothingGamma, StartDragVelocity, UseRtlExtensions, - SynthesizeMouseFromTouchEvents + SynthesizeMouseFromTouchEvents, + PasswordMaskCharacter }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 9f5c789a6e..02b69bcb4d 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -41,6 +41,8 @@ #include "qplatformtheme.h" +#include "qplatformtheme_p.h" + #include <QtCore/QVariant> #include <QtCore/QStringList> #include <QtCore/qfileinfo.h> @@ -137,6 +139,33 @@ QT_BEGIN_NAMESPACE \sa themeHint(), QStyle::pixelMetric() */ +QPlatformThemePrivate::QPlatformThemePrivate() + : systemPalette(0) +{ } + +QPlatformThemePrivate::~QPlatformThemePrivate() +{ + delete systemPalette; +} + +Q_GUI_EXPORT QPalette qt_fusionPalette(); + +void QPlatformThemePrivate::initializeSystemPalette() +{ + Q_ASSERT(!systemPalette); + systemPalette = new QPalette(qt_fusionPalette()); +} + +QPlatformTheme::QPlatformTheme() + : d_ptr(new QPlatformThemePrivate) +{ + +} + +QPlatformTheme::QPlatformTheme(QPlatformThemePrivate *priv) + : d_ptr(priv) +{ } + QPlatformTheme::~QPlatformTheme() { @@ -156,7 +185,12 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ const QPalette *QPlatformTheme::palette(Palette type) const { - Q_UNUSED(type) + Q_D(const QPlatformTheme); + if (type == QPlatformTheme::SystemPalette) { + if (!d->systemPalette) + const_cast<QPlatformTheme *>(this)->d_ptr->initializeSystemPalette(); + return d->systemPalette; + } return 0; } @@ -204,6 +238,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(500); case QPlatformTheme::PasswordMaskDelay: return QVariant(int(0)); + case QPlatformTheme::PasswordMaskCharacter: + return QVariant(QChar(0x25CF)); case QPlatformTheme::StartDragVelocity: return QVariant(int(0)); // no limit case QPlatformTheme::UseFullScreenForPopupMenu: diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 0e95321102..80ba29a028 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -52,6 +52,7 @@ // #include <QtCore/QtGlobal> +#include <QtCore/QScopedPointer> QT_BEGIN_NAMESPACE @@ -63,6 +64,7 @@ class QPlatformMenu; class QPlatformMenuBar; class QPlatformDialogHelper; class QPlatformSystemTrayIcon; +class QPlatformThemePrivate; class QVariant; class QPalette; class QFont; @@ -72,6 +74,7 @@ class QFileInfo; class Q_GUI_EXPORT QPlatformTheme { + Q_DECLARE_PRIVATE(QPlatformTheme) public: enum ThemeHint { CursorFlashTime, @@ -100,7 +103,8 @@ public: UiEffects, SpellCheckUnderlineStyle, TabAllWidgets, - IconPixmapSizes + IconPixmapSizes, + PasswordMaskCharacter }; enum DialogType { @@ -249,6 +253,7 @@ public: AnimateToolBoxUiEffect = 0x40 }; + explicit QPlatformTheme(); virtual ~QPlatformTheme(); virtual QPlatformMenuItem* createPlatformMenuItem() const; @@ -274,6 +279,12 @@ public: virtual QIconEngine *createIconEngine(const QString &iconName) const; static QVariant defaultThemeHint(ThemeHint hint); + +protected: + explicit QPlatformTheme(QPlatformThemePrivate *priv); + QScopedPointer<QPlatformThemePrivate> d_ptr; +private: + Q_DISABLE_COPY(QPlatformTheme) }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h new file mode 100644 index 0000000000..2b965819c6 --- /dev/null +++ b/src/gui/kernel/qplatformtheme_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMTHEME_P_H +#define QPLATFORMTHEME_P_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtCore/QtGlobal> + +QT_BEGIN_NAMESPACE + +class QPalette; + +class Q_GUI_EXPORT QPlatformThemePrivate +{ +public: + QPlatformThemePrivate(); + + virtual ~QPlatformThemePrivate(); + + void initializeSystemPalette(); + + QPalette *systemPalette; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMTHEME_P_H diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index bfb6ab5a68..1e8ac60cca 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -463,6 +463,32 @@ QString QPlatformWindow::formatWindowTitle(const QString &title, const QString & } /*! + Reimplement this method to set whether the window demands attention + (for example, by flashing the taskbar icon) depending on \a enabled. + + \sa isAlertState() + \since 5.1 +*/ + +void QPlatformWindow::setAlertState(bool enable) +{ + Q_UNUSED(enable) +} + +/*! + Reimplement this method return whether the window is in + an alert state. + + \sa setAlertState() + \since 5.1 +*/ + +bool QPlatformWindow::isAlertState() const +{ + return false; +} + +/*! Helper function to get initial geometry on windowing systems which do not do smart positioning and also do not provide a means of centering a transient window w.r.t. its parent. For example this is useful on Windows diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 7ade461890..7dfbae036f 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -128,6 +128,9 @@ public: virtual void setFrameStrutEventsEnabled(bool enabled); virtual bool frameStrutEventsEnabled() const; + virtual void setAlertState(bool enabled); + virtual bool isAlertState() const; + static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, int defaultWidth, int defaultHeight); diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 23bc165edd..30b12835f7 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -193,6 +193,15 @@ int QStyleHints::passwordMaskDelay() const } /*! + Returns the character used to mask the characters typed into text input + fields in password mode. +*/ +QChar QStyleHints::passwordMaskCharacter() const +{ + return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar(); +} + +/*! Returns the gamma value used in font smoothing. */ qreal QStyleHints::fontSmoothingGamma() const diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 7a447aae67..64ef182aab 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -62,6 +62,7 @@ public: int cursorFlashTime() const; bool showIsFullScreen() const; int passwordMaskDelay() const; + QChar passwordMaskCharacter() const; qreal fontSmoothingGamma() const; bool useRtlExtensions() const; diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2307df37ac..8c9bc575bd 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -58,6 +58,7 @@ #include <private/qevent_p.h> +#include <QtCore/QTimer> #include <QtCore/QDebug> #include <QStyleHints> @@ -2150,6 +2151,33 @@ QWindow *QWindow::fromWinId(WId id) return window; } +/*! + Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the + default), then the alert is shown indefinitely until the window becomes + active again. + + In alert state, the window indicates that it demands attention, for example by + flashing or bouncing the taskbar entry. + + \since 5.1 +*/ + +void QWindow::alert(int msec) +{ + Q_D(QWindow); + if (!d->platformWindow || d->platformWindow->isAlertState()) + return; + d->platformWindow->setAlertState(true); + if (d->platformWindow->isAlertState() && msec) + QTimer::singleShot(msec, this, SLOT(_q_clearAlert())); +} + +void QWindowPrivate::_q_clearAlert() +{ + if (platformWindow && platformWindow->isAlertState()) + platformWindow->setAlertState(false); +} + #ifndef QT_NO_CURSOR /*! \brief set the cursor shape for this window @@ -2233,3 +2261,5 @@ void QWindowPrivate::applyCursor() #endif // QT_NO_CURSOR QT_END_NAMESPACE + +#include "moc_qwindow.cpp" diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 1b63e185f8..9b1ed2c702 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -290,6 +290,8 @@ public Q_SLOTS: Q_REVISION(1) void setMaximumWidth(int w); Q_REVISION(1) void setMaximumHeight(int h); + void alert(int msec); + Q_SIGNALS: void screenChanged(QScreen *screen); void modalityChanged(Qt::WindowModality modality); @@ -346,6 +348,7 @@ protected: QWindow(QWindowPrivate &dd, QWindow *parent); private: + Q_PRIVATE_SLOT(d_func(), void _q_clearAlert()) QPlatformSurface *surfaceHandle() const; Q_DISABLE_COPY(QWindow) diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index e32d45acca..ea2cb722ab 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -125,6 +125,7 @@ public: virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; } void updateVisibility(); + void _q_clearAlert(); QWindow::SurfaceType surfaceType; Qt::WindowFlags windowFlags; diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 87cb4cd93d..d70f326415 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -316,6 +316,8 @@ void QOpenGLBuffer::destroy() d->guard->free(); d->guard = 0; } + delete d->funcs; + d->funcs = 0; } /*! diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index d55d6a91bf..f0e7e4953f 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -282,9 +282,11 @@ int QOpenGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case PdmDpiY: return qRound(d_ptr->dpmy * 0.0254); case PdmPhysicalDpiX: - return qRound(d_ptr->dpmx * 0.0254 * d_ptr->devicePixelRatio); + return qRound(d_ptr->dpmx * 0.0254); case PdmPhysicalDpiY: - return qRound(d_ptr->dpmy * 0.0254 * d_ptr->devicePixelRatio); + return qRound(d_ptr->dpmy * 0.0254); + case PdmDevicePixelRatio: + return d_ptr->devicePixelRatio; default: qWarning("QOpenGLPaintDevice::metric() - metric %d not known", metric); return 0; diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h index 833c5adf9f..304b944de8 100644 --- a/src/gui/opengl/qopenglversionfunctions.h +++ b/src/gui/opengl/qopenglversionfunctions.h @@ -91,7 +91,7 @@ struct QOpenGLVersionStatus OpenGLStatus status; }; -inline uint qHash(const QOpenGLVersionStatus &v, uint seed) +inline uint qHash(const QOpenGLVersionStatus &v, uint seed = 0) { return qHash(static_cast<int>(v.status * 1000) + v.version.first * 100 + v.version.second * 10, seed); diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp index f67037cc39..0387f0020f 100644 --- a/src/gui/painting/qpagedpaintdevice.cpp +++ b/src/gui/painting/qpagedpaintdevice.cpp @@ -169,7 +169,7 @@ void QPagedPaintDevice::setPageSize(PageSize size) if (size >= Custom) return; d->pageSize = size; - d->pageSizeMM = QSizeF(pageSizes[A4].width, pageSizes[A4].height); + d->pageSizeMM = QSizeF(pageSizes[size].width, pageSizes[size].height); } /*! diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 6ac288607d..81d2063039 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -95,6 +95,8 @@ int QPaintDevice::metric(PaintDeviceMetric m) const } else if (m == PdmNumColors) { // FIXME: does this need to be a real value? return 256; + } else if (m == PdmDevicePixelRatio) { + return 1; } else { qDebug("Unrecognised metric %d!",m); return 0; diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 1529b701cf..bb66f32b7f 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -65,7 +65,8 @@ public: PdmDpiX, PdmDpiY, PdmPhysicalDpiX, - PdmPhysicalDpiY + PdmPhysicalDpiY, + PdmDevicePixelRatio }; virtual ~QPaintDevice(); @@ -82,6 +83,7 @@ public: int logicalDpiY() const { return metric(PdmDpiY); } int physicalDpiX() const { return metric(PdmPhysicalDpiX); } int physicalDpiY() const { return metric(PdmPhysicalDpiY); } + int devicePixelRatio() const { return metric(PdmDevicePixelRatio); } int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc index 7397dc7fc2..993b23850e 100644 --- a/src/gui/painting/qpaintdevice.qdoc +++ b/src/gui/painting/qpaintdevice.qdoc @@ -114,6 +114,10 @@ \value PdmPhysicalDpiY The vertical resolution of the device in dots per inch. See also physicalDpiY(). + \value PdmDevicePixelRatio The device pixel ratio for device. Common + values are 1 for normal-dpi displays and 2 for high-dpi "retina" + displays. + \sa metric() */ @@ -273,3 +277,12 @@ \sa physicalDpiX(), logicalDpiY() */ + +/*! + \fn int QPaintDevice::devicePixelRatio() const + + Returns the device pixel ratio for device. + + Common values are 1 for normal-dpi displays and 2 for high-dpi + "retina" displays. +*/ diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index be77fffc7c..e42b70427c 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -225,17 +225,24 @@ QTransform QPainterPrivate::viewTransform() const return QTransform(); } -QTransform QPainterPrivate::hidpiScaleTransform() const +int QPainterPrivate::effectiveDevicePixelRatio() const { -#ifdef Q_OS_MAC // Limited feature introduction for Qt 5.0.0, remove ifdef in a later release. - if (device->devType() == QInternal::Printer || device->physicalDpiX() == 0 || device->logicalDpiX() == 0) - return QTransform(); - const qreal deviceScale = (device->physicalDpiX() / device->logicalDpiX()); - if (deviceScale > 1.0) - return QTransform::fromScale(deviceScale, deviceScale); +#ifdef Q_OS_MAC + // Special cases for devices that does not support PdmDevicePixelRatio go here: + if (device->devType() == QInternal::Printer) + return 1; + + return qMax(1, device->metric(QPaintDevice::PdmDevicePixelRatio)); +#else + return 1; #endif - return QTransform(); +} + +QTransform QPainterPrivate::hidpiScaleTransform() const +{ + int devicePixelRatio = effectiveDevicePixelRatio(); + return QTransform::fromScale(devicePixelRatio, devicePixelRatio); } /* @@ -1837,14 +1844,7 @@ bool QPainter::begin(QPaintDevice *pd) Q_ASSERT(d->engine->isActive()); -#ifdef Q_OS_MAC - // Limited feature introduction for Qt 5.0.0, remove ifdef in a later release. - const bool isHighDpi = (pd->devType() == QInternal::Printer || d->device->physicalDpiX() == 0 || d->device->logicalDpiX() == 0) ? - false : (d->device->physicalDpiX() / d->device->logicalDpiX() > 1); -#else - const bool isHighDpi = false; -#endif - if (!d->state->redirectionMatrix.isIdentity() || isHighDpi) + if (!d->state->redirectionMatrix.isIdentity() || d->effectiveDevicePixelRatio() > 1) d->updateMatrix(); Q_ASSERT(d->engine->isActive()); diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 36a73866e7..04772b3ec9 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -249,6 +249,7 @@ public: } QTransform viewTransform() const; + int effectiveDevicePixelRatio() const; QTransform hidpiScaleTransform() const; static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev); void detachPainterPrivate(QPainter *q); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index eed64180e5..5d9a743dac 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1455,6 +1455,9 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const case QPaintDevice::PdmDepth: val = 32; break; + case QPaintDevice::PdmDevicePixelRatio: + val = 1; + break; default: qWarning("QPdfWriter::metric: Invalid metric command"); return 0; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 1d6cf3ceca..9d603bb08d 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2639,18 +2639,6 @@ QFontCache::QFontCache() QFontCache::~QFontCache() { clear(); - { - EngineDataCache::ConstIterator it = engineDataCache.constBegin(), - end = engineDataCache.constEnd(); - while (it != end) { - if (!it.value()->ref.deref()) - delete it.value(); - else - FC_DEBUG("QFontCache::~QFontCache: engineData %p still has refcount %d", - it.value(), it.value()->ref.load()); - ++it; - } - } } void QFontCache::clear() @@ -2669,29 +2657,47 @@ void QFontCache::clear() data->engines[i] = 0; } } + if (!data->ref.deref()) { + delete data; + } else { + FC_DEBUG("QFontCache::clear: engineData %p still has refcount %d", + data, data->ref.load()); + } ++it; } } - bool mightHaveEnginesLeftForCleanup = true; - while (mightHaveEnginesLeftForCleanup) { + engineDataCache.clear(); + + + bool mightHaveEnginesLeftForCleanup; + do { mightHaveEnginesLeftForCleanup = false; for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end(); - it != end; ++it) { - if (it.value().data && engineCacheCount.value(it.value().data) > 0) { - --engineCacheCount[it.value().data]; - if (!it.value().data->ref.deref()) { - Q_ASSERT(engineCacheCount.value(it.value().data) == 0); - delete it.value().data; - mightHaveEnginesLeftForCleanup = true; + it != end; ++it) { + QFontEngine *engine = it.value().data; + if (engine) { + const int cacheCount = --engineCacheCount[engine]; + Q_ASSERT(cacheCount >= 0); + if (!engine->ref.deref()) { + Q_ASSERT(cacheCount == 0); + mightHaveEnginesLeftForCleanup = engine->type() == QFontEngine::Multi; + delete engine; + } else if (cacheCount == 0) { + FC_DEBUG("QFontCache::clear: engine %p still has refcount %d", + engine, engine->ref.load()); } it.value().data = 0; } } - } + } while (mightHaveEnginesLeftForCleanup); engineCache.clear(); engineCacheCount.clear(); + + + total_cost = 0; + max_cost = min_cost; } diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 47c59fb826..1ce70c6d83 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -199,6 +199,7 @@ QFontEngine::QFontEngine() font_(0), font_destroy_func(0), face_(0), face_destroy_func(0) { + cache_cost = 0; fsType = 0; symbol = false; @@ -263,11 +264,15 @@ void *QFontEngine::harfbuzzFont() const { HB_FontRec *hbFont = (HB_FontRec *)font_; if (!hbFont->x_ppem) { - QFixed emSquare = emSquareSize(); + qint64 emSquare = emSquareSize().truncate(); + Q_ASSERT(emSquare == emSquareSize().toInt()); // ensure no truncation + if (emSquare == 0) + emSquare = 1000; // a fallback value suitable for Type1 fonts hbFont->y_ppem = fontDef.pixelSize; hbFont->x_ppem = fontDef.pixelSize * fontDef.stretch / 100; - hbFont->x_scale = (QFixed(hbFont->x_ppem * (1 << 16)) / emSquare).value(); - hbFont->y_scale = (QFixed(hbFont->y_ppem * (1 << 16)) / emSquare).value(); + // same as QFixed(x)/QFixed(emSquare) but without int32 overflow for x + hbFont->x_scale = (((qint64)hbFont->x_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare; + hbFont->y_scale = (((qint64)hbFont->y_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare; } return font_; } diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp index 837850e4be..0a730abcac 100644 --- a/src/gui/text/qfontengine_qpa.cpp +++ b/src/gui/text/qfontengine_qpa.cpp @@ -688,6 +688,7 @@ void QFontEngineMultiQPA::init(QFontEngine *fe) fe->ref.ref(); fontDef = engines[0]->fontDef; setObjectName(QStringLiteral("QFontEngineMultiQPA")); + cache_cost = fe->cache_cost; } void QFontEngineMultiQPA::loadEngine(int at) |