diff options
Diffstat (limited to 'src/gui')
34 files changed, 273 insertions, 68 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index cb89fccc2d..59794a5a06 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -648,9 +648,8 @@ void QAccessible::setRootObject(QObject *object) void QAccessible::updateAccessibility(QObject *object, int child, Event reason) { Q_ASSERT(object); - - QAccessibleEvent event = QAccessibleEvent(reason, object, child); - updateAccessibility(event); + QAccessibleEvent ev(reason, object, child); + updateAccessibility(&ev); } /*! @@ -672,7 +671,7 @@ void QAccessible::updateAccessibility(QObject *object, int child, Event reason) the parameters of the call is expensive you can test isActive() to avoid unnecessary computations. */ -void QAccessible::updateAccessibility(const QAccessibleEvent &event) +void QAccessible::updateAccessibility(QAccessibleEvent *event) { if (updateHandler) { updateHandler(event); diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index e8a5cf8bad..ffdd3fe7ce 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -327,7 +327,7 @@ public: }; typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*); - typedef void(*UpdateHandler)(const QAccessibleEvent &event); + typedef void(*UpdateHandler)(QAccessibleEvent *event); typedef void(*RootObjectHandler)(QObject*); static void installFactory(InterfaceFactory); @@ -338,7 +338,7 @@ public: static QAccessibleInterface *queryAccessibleInterface(QObject *); QT_DEPRECATED static void updateAccessibility(QObject *object, int child, Event reason); - static void updateAccessibility(const QAccessibleEvent &event); + static void updateAccessibility(QAccessibleEvent *event); static bool isActive(); static void setRootObject(QObject *object); diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index 708910b8df..56a39b640d 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -164,6 +164,9 @@ public: virtual bool isSelected() const = 0; // Gets the row and column indexes and extents of this cell accessible and whether or not it is selected. + // ### Is this really needed?? + // + // ### Maybe change to QSize cellSize(), we already have accessors for the row, column and selected virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const = 0; // Returns a reference to the accessbile of the containing table. virtual QAccessibleInterface* table() const = 0; diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/gui/accessible/qaccessiblebridge.h index 147bf30bd0..80830bd01c 100644 --- a/src/gui/accessible/qaccessiblebridge.h +++ b/src/gui/accessible/qaccessiblebridge.h @@ -60,7 +60,7 @@ class QAccessibleBridge public: virtual ~QAccessibleBridge() {} virtual void setRootObject(QAccessibleInterface *) = 0; - virtual void notifyAccessibilityUpdate(const QAccessibleEvent &event) = 0; + virtual void notifyAccessibilityUpdate(QAccessibleEvent *event) = 0; }; struct Q_GUI_EXPORT QAccessibleBridgeFactoryInterface : public QFactoryInterface diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 1f4e005dfe..db4ee242ff 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -162,6 +162,7 @@ QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const { for (int i = 0; i < childCount(); ++i) { QAccessibleInterface *childIface = child(i); + Q_ASSERT(childIface); if (childIface->rect().contains(x,y)) { return childIface; } diff --git a/src/gui/accessible/qplatformaccessibility_qpa.cpp b/src/gui/accessible/qplatformaccessibility_qpa.cpp index 9de11e7c1f..057d43add3 100644 --- a/src/gui/accessible/qplatformaccessibility_qpa.cpp +++ b/src/gui/accessible/qplatformaccessibility_qpa.cpp @@ -75,7 +75,7 @@ QPlatformAccessibility::~QPlatformAccessibility() { } -void QPlatformAccessibility::notifyAccessibilityUpdate(const QAccessibleEvent &event) +void QPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { initialize(); diff --git a/src/gui/accessible/qplatformaccessibility_qpa.h b/src/gui/accessible/qplatformaccessibility_qpa.h index 364f87b0c9..3bd6316d01 100644 --- a/src/gui/accessible/qplatformaccessibility_qpa.h +++ b/src/gui/accessible/qplatformaccessibility_qpa.h @@ -57,7 +57,7 @@ public: QPlatformAccessibility(); virtual ~QPlatformAccessibility(); - virtual void notifyAccessibilityUpdate(const QAccessibleEvent &event); + virtual void notifyAccessibilityUpdate(QAccessibleEvent *event); virtual void setRootObject(QObject *o); virtual void initialize(); virtual void cleanup(); diff --git a/src/gui/animation/animation.pri b/src/gui/animation/animation.pri new file mode 100644 index 0000000000..add9ae7119 --- /dev/null +++ b/src/gui/animation/animation.pri @@ -0,0 +1,2 @@ +SOURCES += \ + animation/qguivariantanimation.cpp diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp new file mode 100644 index 0000000000..c344a18b8a --- /dev/null +++ b/src/gui/animation/qguivariantanimation.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtCore/qvariantanimation.h> +#include <private/qvariantanimation_p.h> + +#ifndef QT_NO_ANIMATION + +#include <QtGui/qcolor.h> +#include <QtGui/qvector2d.h> +#include <QtGui/qvector3d.h> +#include <QtGui/qvector4d.h> +#include <QtGui/qquaternion.h> + +QT_BEGIN_NAMESPACE + +template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress) +{ + return QColor(qBound(0,_q_interpolate(f.red(), t.red(), progress),255), + qBound(0,_q_interpolate(f.green(), t.green(), progress),255), + qBound(0,_q_interpolate(f.blue(), t.blue(), progress),255), + qBound(0,_q_interpolate(f.alpha(), t.alpha(), progress),255)); +} + +template<> Q_INLINE_TEMPLATE QQuaternion _q_interpolate(const QQuaternion &f,const QQuaternion &t, qreal progress) +{ + return QQuaternion::slerp(f, t, progress); +} + +static void qRegisterGuiGetInterpolator() +{ + qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>); + qRegisterAnimationInterpolator<QVector2D>(_q_interpolateVariant<QVector2D>); + qRegisterAnimationInterpolator<QVector3D>(_q_interpolateVariant<QVector3D>); + qRegisterAnimationInterpolator<QVector4D>(_q_interpolateVariant<QVector4D>); + qRegisterAnimationInterpolator<QQuaternion>(_q_interpolateVariant<QQuaternion>); +} +Q_CONSTRUCTOR_FUNCTION(qRegisterGuiGetInterpolator) + +static void qUnregisterGuiGetInterpolator() +{ + // casts required by Sun CC 5.5 + qRegisterAnimationInterpolator<QColor>( + (QVariant (*)(const QColor &, const QColor &, qreal))0); + qRegisterAnimationInterpolator<QVector2D>( + (QVariant (*)(const QVector2D &, const QVector2D &, qreal))0); + qRegisterAnimationInterpolator<QVector3D>( + (QVariant (*)(const QVector3D &, const QVector3D &, qreal))0); + qRegisterAnimationInterpolator<QVector4D>( + (QVariant (*)(const QVector4D &, const QVector4D &, qreal))0); + qRegisterAnimationInterpolator<QQuaternion>( + (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))0); +} +Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) + +QT_END_NAMESPACE + +#endif //QT_NO_ANIMATION diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 2cee31fce1..e6a820b5c4 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -31,6 +31,7 @@ include(painting/painting.pri) include(util/util.pri) include(math3d/math3d.pri) include(opengl/opengl.pri) +include(animation/animation.pri) QMAKE_LIBS += $$QMAKE_LIBS_GUI @@ -150,4 +151,4 @@ win32:!contains(QT_CONFIG, directwrite) { sse2: SOURCES += $$SSE2_SOURCES ssse3: SOURCES += $$SSSE3_SOURCES iwmmxt: SOURCES += $$IWMMXT_SOURCES - } + }
\ No newline at end of file diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index f9e11f1390..8ff1e43b71 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -260,8 +260,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) { - Q_ASSERT(ncols == 0); - if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask)) return false; if (d->read((char *)&green_mask, sizeof(green_mask)) != sizeof(green_mask)) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index adf5f66679..3e3db64d6f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1146,12 +1146,13 @@ QMoveEvent::~QMoveEvent() /*! \class QExposeEvent + \since 5.0 \brief The QExposeEvent class contains event parameters for expose events. \ingroup events - Expose events are sent to widgets when an area of the widget is invalidated - and needs to be flushed from the backing store. + Expose events are sent to windows when an area of the window is invalidated + or window visibility in the windowing system changes. The event handler QWindow::exposeEvent() receives expose events. */ @@ -1761,9 +1762,11 @@ void QInputMethodEvent::setTentativeCommitString(const QString &tentativeCommitS \sa setTentativeCommitString() */ -/*! \class QInputMethodQueryEvent +/*! + \class QInputMethodQueryEvent + \since 5.0 - This event is sent by the input context to input objects. + \brief This event is sent by the input context to input objects. It is used by the input method to query a set of properties of the object to be @@ -3375,9 +3378,10 @@ QWindowStateChangeEvent::~QWindowStateChangeEvent() gestures. Whenever such a decision is made (the gesture is recognized), the clients will be notified with a QEvent::TouchCancel event so they can update their state accordingly. - The touchPoints() function returns a list of all touch points contained in the event. - Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class. - The Qt::TouchPointState enum describes the different states that a touch point may have. + The touchPoints() function returns a list of all touch points contained in the event. Note that + this list may be empty, for example in case of a QEvent::TouchCancel event. Information about + each touch point can be retrieved using the QTouchEvent::TouchPoint class. The + Qt::TouchPointState enum describes the different states that a touch point may have. \section1 Event Delivery and Propagation diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 26690c78cf..d72647091d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -110,6 +110,7 @@ enum ApplicationResourceFlags static unsigned applicationResourceFlags = 0; +QString *QGuiApplicationPrivate::platform_name = 0; bool QGuiApplicationPrivate::app_do_modal = false; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette @@ -194,6 +195,7 @@ static inline void clearFontUnlocked() flow and main settings. \inmodule QtGui + \since 5.0 QGuiApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the @@ -361,6 +363,9 @@ QGuiApplication::~QGuiApplication() #ifndef QT_NO_CURSOR d->cursor_list.clear(); #endif + + delete QGuiApplicationPrivate::platform_name; + QGuiApplicationPrivate::platform_name = 0; } QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) @@ -470,6 +475,17 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) return 0; } +/*! + \property QGuiApplication::platformName + \brief The name of the underlying platform plugin. + \since 5.0 +*/ + +QString QGuiApplication::platformName() +{ + return QGuiApplicationPrivate::platform_name ? + *QGuiApplicationPrivate::platform_name : QString(); +} static void init_platform(const QString &pluginArgument, const QString &platformPluginPath) { @@ -509,7 +525,9 @@ static void init_platform(const QString &pluginArgument, const QString &platform // Create the platform integration. QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath); - if (!QGuiApplicationPrivate::platform_integration) { + if (QGuiApplicationPrivate::platform_integration) { + QGuiApplicationPrivate::platform_name = new QString(name); + } else { QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); QString fatalMessage = QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); @@ -521,13 +539,22 @@ static void init_platform(const QString &pluginArgument, const QString &platform } // Create the platform theme: - // 1) Ask the platform integration to create a platform theme - QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->platformTheme(); + // 1) Ask the platform integration for a list of names. + const QStringList themeNames = QGuiApplicationPrivate::platform_integration->themeNames(); + foreach (const QString &themeName, themeNames) { + QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); + if (QGuiApplicationPrivate::platform_theme) + break; + } // 2) If none found, look for a theme plugin. Theme plugins are located in the // same directory as platform plugins. if (!QGuiApplicationPrivate::platform_theme) { - QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(name, platformPluginPath); + foreach (const QString &themeName, themeNames) { + QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); + if (QGuiApplicationPrivate::platform_theme) + break; + } // No error message; not having a theme plugin is allowed. } @@ -731,6 +758,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() qt_cleanupFontDatabase(); + delete platform_theme; delete platform_integration; platform_integration = 0; } diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index 6fdbb000fe..cc7dea422f 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -75,7 +75,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication { Q_OBJECT Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection) - + Q_PROPERTY(QString platformName READ platformName STORED false) Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) public: @@ -86,6 +86,8 @@ public: static QWindowList topLevelWindows(); static QWindow *topLevelAt(const QPoint &pos); + static QString platformName(); + #ifdef QT_DEPRECATED static QT_DEPRECATED QWindow *activeWindow() { return focusWindow(); } #endif diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index d9477a3e9e..f30a2bb5a0 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -146,6 +146,7 @@ public: static QGuiApplicationPrivate *instance() { return self; } + static QString *platform_name; static bool app_do_modal; static Qt::MouseButtons buttons; diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index f9ebf8820c..eaff417f15 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -76,6 +76,7 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex; /*! \class QOpenGLContext + \since 5.0 \brief The QOpenGLContext represents a native OpenGL context, enabling OpenGL rendering on a QSurface. @@ -621,6 +622,7 @@ void QOpenGLContext::deleteQGLContext() /*! \class QOpenGLContextGroup + \since 5.0 \brief The QOpenGLContextGroup represents a group of contexts sharing OpenGL resources. diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index e8721edce7..786e915a19 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -44,6 +44,7 @@ #include <QtGui/QPlatformFontDatabase> #include <QtGui/QPlatformClipboard> #include <QtGui/QPlatformAccessibility> +#include <QtGui/QPlatformTheme> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qpixmap_raster_p.h> #include <QtGui/private/qplatformscreen_qpa_p.h> @@ -259,6 +260,8 @@ QPlatformInputContext *QPlatformIntegration::inputContext() const return 0; } +#ifndef QT_NO_ACCESSIBILITY + /*! Returns the platforms accessibility. @@ -269,6 +272,8 @@ QPlatformAccessibility *QPlatformIntegration::accessibility() const return 0; } +#endif + QVariant QPlatformIntegration::styleHint(StyleHint hint) const { switch (hint) { @@ -315,9 +320,15 @@ void QPlatformIntegration::screenAdded(QPlatformScreen *ps) emit qGuiApp->screenAdded(screen); } -class QPlatformTheme *QPlatformIntegration::platformTheme() const +QStringList QPlatformIntegration::themeNames() const { - return 0; + return QStringList(); +} + +class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &name) const +{ + Q_UNUSED(name) + return new QPlatformTheme; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 3f9de9df5e..632b3af613 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -105,7 +105,9 @@ public: virtual QPlatformDrag *drag() const; #endif virtual QPlatformInputContext *inputContext() const; +#ifndef QT_NO_ACCESSIBILITY virtual QPlatformAccessibility *accessibility() const; +#endif // Access native handles. The window handle is already available from Wid; virtual QPlatformNativeInterface *nativeInterface() const; @@ -126,7 +128,8 @@ public: virtual Qt::KeyboardModifiers queryKeyboardModifiers() const; - virtual QPlatformTheme *platformTheme() const; + virtual QStringList themeNames() const; + virtual QPlatformTheme *createPlatformTheme(const QString &name) const; protected: void screenAdded(QPlatformScreen *screen); diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp index f87a2956a3..48e43f5226 100644 --- a/src/gui/kernel/qplatformnativeinterface_qpa.cpp +++ b/src/gui/kernel/qplatformnativeinterface_qpa.cpp @@ -43,6 +43,11 @@ QT_BEGIN_NAMESPACE +void *QPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) +{ + Q_UNUSED(resource); + return 0; +} void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { Q_UNUSED(resource); diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h index b25ebf0fe9..dd1ef22354 100644 --- a/src/gui/kernel/qplatformnativeinterface_qpa.h +++ b/src/gui/kernel/qplatformnativeinterface_qpa.h @@ -60,6 +60,7 @@ class Q_GUI_EXPORT QPlatformNativeInterface : public QObject { Q_OBJECT public: + virtual void *nativeResourceForIntegration(const QByteArray &resource); virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore); diff --git a/src/gui/kernel/qplatformsurface_qpa.cpp b/src/gui/kernel/qplatformsurface_qpa.cpp index 5fd9c073fe..6d3b6503d7 100644 --- a/src/gui/kernel/qplatformsurface_qpa.cpp +++ b/src/gui/kernel/qplatformsurface_qpa.cpp @@ -43,7 +43,10 @@ QT_BEGIN_NAMESPACE -QPlatformSurface::~QPlatformSurface() {} +QPlatformSurface::~QPlatformSurface() +{ + +} QSurface::SurfaceClass QPlatformSurface::surfaceClass() const { diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index da0716b7d5..5d7ffdbc2b 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE /*! \class QScreen + \since 5.0 \brief The QScreen class is used to query screen properties. A note on logical vs physical dots per inch: physical DPI is based on the diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index c98158b6b6..15fcec21d8 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -50,6 +50,11 @@ static inline QVariant hint(QPlatformIntegration::StyleHint h) return QGuiApplicationPrivate::platformIntegration()->styleHint(h); } +/*! + \class QStyleHints + \since 5.0 + \brief The QStyleHints contains platform specific hints and settings. + */ QStyleHints::QStyleHints() : QObject() { diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index eb2676802b..534135cc2f 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE /*! \class QSurface + \since 5.0 \brief The QSurface class is an abstraction of renderable surfaces in Qt. The size of the surface is accessible with the size() function. The rendering diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 9021d82e20..cc6b621047 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -108,6 +108,7 @@ public: /*! \class QSurfaceFormat + \since 5.0 \brief The QSurfaceFormat class represents the format of a QSurface. The format includes the size of the color buffers, red, green, and blue; diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 367cee70e3..78b6f6f722 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE /*! \class QWindow + \since 5.0 \brief The QWindow class represents a window in the underlying windowing system. A window that is supplied a parent becomes a native child window of @@ -597,6 +598,11 @@ bool QWindow::isActive() const return false; QWindow *focus = QGuiApplication::focusWindow(); + + // Means the whole application lost the focus + if (!focus) + return false; + if (focus == this) return true; diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 1a1f08f73d..0014efc450 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -207,7 +207,9 @@ QFontEngine *loadEngine(int script, const QFontDef &request, fallbacks = family->fallbackFamilies; QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); - engine = pfdb->fontEngineMulti(engine, QUnicodeTables::Script(script), fallbacks); + QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QUnicodeTables::Script(script)); + pfMultiEngine->setFallbackFamiliesList(fallbacks); + engine = pfMultiEngine; // Cache Multi font engine as well in case we got the FT single // font engine when we are actually looking for a Multi one diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 364a356b96..5c18ddeef8 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1366,6 +1366,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (!engine(0)->stringToCMap(str, len, glyphs, &ng, flags)) return false; + const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried(); int glyph_pos = 0; for (int i = 0; i < len; ++i) { bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()); diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 1114cdf12c..4741de3000 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -395,12 +395,14 @@ public: } virtual bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const; + virtual void setFallbackFamiliesList(const QStringList &) {} protected: friend class QPSPrintEnginePrivate; friend class QPSPrintEngineFontMulti; friend class QRawFont; virtual void loadEngine(int at) = 0; + virtual void ensureFallbackFamiliesQueried() {} QVector<QFontEngine *> engines; }; diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp index 48679824a4..d12e2d651c 100644 --- a/src/gui/text/qfontengine_qpa.cpp +++ b/src/gui/text/qfontengine_qpa.cpp @@ -674,6 +674,7 @@ QFontEngineMultiQPA::QFontEngineMultiQPA(QFontEngine *fe, int _script) , script(_script) , fallbacksQueried(false) { + fallbackFamilies << QString(); init(fe); } @@ -688,36 +689,43 @@ void QFontEngineMultiQPA::init(QFontEngine *fe) void QFontEngineMultiQPA::loadEngine(int at) { - bool canLoadFallbackEngine = true; - if (!fallbacksQueried) { - // Original FontEngine to restore after the fill. - QFontEngine *fe = engines[0]; - fallbackFamilies = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fallbacksForFamily(fe->fontDef.family, QFont::Style(fe->fontDef.style) - , QFont::AnyStyle, QUnicodeTables::Script(script)); - if (fallbackFamilies.size() > 1) { - engines.fill(0, fallbackFamilies.size() + 1); - engines[0] = fe; - } else { - // Turns out we lied about having any fallback at all. - canLoadFallbackEngine = false; - engines[1] = fe; - } - fallbacksQueried = true; - } + ensureFallbackFamiliesQueried(); Q_ASSERT(at < engines.size()); Q_ASSERT(engines.at(at) == 0); QFontDef request = fontDef; - if (canLoadFallbackEngine) { - request.styleStrategy |= QFont::NoFontMerging; - request.family = fallbackFamilies.at(at-1); - engines[at] = QFontDatabase::findFont(script, - /*fontprivate = */0, - request, /*multi = */false); - } + request.styleStrategy |= QFont::NoFontMerging; + request.family = fallbackFamilies.at(at-1); + engines[at] = QFontDatabase::findFont(script, + /*fontprivate = */0, + request, /*multi = */false); Q_ASSERT(engines[at]); engines[at]->ref.ref(); engines[at]->fontDef = request; } +void QFontEngineMultiQPA::ensureFallbackFamiliesQueried() +{ + if (fallbacksQueried) + return; + QStringList fallbacks = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fallbacksForFamily(engine(0)->fontDef.family, QFont::Style(engine(0)->fontDef.style) + , QFont::AnyStyle, QUnicodeTables::Script(script)); + setFallbackFamiliesList(fallbacks); +} + +void QFontEngineMultiQPA::setFallbackFamiliesList(const QStringList &fallbacks) +{ + // Original FontEngine to restore after the fill. + QFontEngine *fe = engines[0]; + fallbackFamilies = fallbacks; + if (!fallbackFamilies.isEmpty()) { + engines.fill(0, fallbackFamilies.size() + 1); + engines[0] = fe; + } else { + // Turns out we lied about having any fallback at all. + fallbackFamilies << fe->fontDef.family; + engines[1] = fe; + } + fallbacksQueried = true; +} /* This is used indirectly by QtWebKit when using QTextLayout::setRawFont @@ -750,7 +758,7 @@ QFontEngine* QFontEngineMultiQPA::createMultiFontEngine(QFontEngine *fe, int scr it++; } if (!engine) { - engine = new QFontEngineMultiQPA(fe, script); + engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QUnicodeTables::Script(script)); QFontCache::instance()->insertEngine(key, engine, /* insertMulti */ !faceIsLocal); } Q_ASSERT(engine); diff --git a/src/gui/text/qfontengine_qpa_p.h b/src/gui/text/qfontengine_qpa_p.h index 16991ad2ca..e6907149b2 100644 --- a/src/gui/text/qfontengine_qpa_p.h +++ b/src/gui/text/qfontengine_qpa_p.h @@ -247,6 +247,7 @@ class Q_GUI_EXPORT QFontEngineMultiQPA : public QFontEngineMulti { public: QFontEngineMultiQPA(QFontEngine *fe, int script, const QStringList &fallbacks); + QFontEngineMultiQPA(QFontEngine *fe, int script); void loadEngine(int at); static QFontEngine* createMultiFontEngine(QFontEngine *fe, int script); @@ -254,13 +255,15 @@ public: int fallbackFamilyCount() const { return fallbackFamilies.size(); } QString fallbackFamilyAt(int at) const { return fallbackFamilies.at(at); } + virtual void ensureFallbackFamiliesQueried(); + virtual void setFallbackFamiliesList(const QStringList &fallbacks); + private: - QFontEngineMultiQPA(QFontEngine *fe, int script); void init(QFontEngine *fe); - QStringList fallbackFamilies; + mutable QStringList fallbackFamilies; int script; - bool fallbacksQueried; + mutable bool fallbacksQueried; }; QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index fb898a850f..64596ebaf5 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -246,16 +246,32 @@ QList<QByteArray> QFontEngineQPF::cleanUpAfterClientCrash(const QList<int> &cras int fd = QT_OPEN(fileName.constData(), O_RDONLY, 0); if (fd >= 0) { - void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); - if (header && header != MAP_FAILED) { - quint32 lockValue = reinterpret_cast<QFontEngineQPF::Header *>(header)->lock; + QT_STATBUF st; + int nDataSize = 0; + if (QT_FSTAT(fd, &st)) { +#if defined(DEBUG_FONTENGINE) + qDebug() << "stat failed! " << fileName; +#endif + } else { + nDataSize = st.st_size; + } - if (lockValue && crashedClientIds.contains(lockValue)) { - removedFonts.append(fileName); - QFile::remove(QFile::decodeName(fileName)); - } + if (nDataSize >= (int)sizeof(QFontEngineQPF::Header)) { + void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); + if (header && header != MAP_FAILED) { + quint32 lockValue = reinterpret_cast<QFontEngineQPF::Header *>(header)->lock; - ::munmap(header, sizeof(QFontEngineQPF::Header)); + if (lockValue && crashedClientIds.contains(lockValue)) { + removedFonts.append(fileName); + QFile::remove(QFile::decodeName(fileName)); + } + + ::munmap(header, sizeof(QFontEngineQPF::Header)); + } + } else { +#if defined(DEBUG_FONTENGINE) + qDebug() << "Unsufficient header data in QSF file " << fileName; +#endif } QT_CLOSE(fd); } @@ -363,6 +379,7 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng #if defined(DEBUG_FONTENGINE) qErrnoWarning(errno, "QFontEngineQPF: write() failed for %s", encodedName.constData()); #endif + QFile::remove(fileName); return; } } else { diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp index 47a9fe5ab1..6bd8284fa0 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.cpp +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -276,10 +276,9 @@ void QPlatformFontDatabase::populateFontDatabase() a certain character. */ QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, - QUnicodeTables::Script script, - const QStringList &fallbacks) + QUnicodeTables::Script script) { - return new QFontEngineMultiQPA(fontEngine, script, fallbacks); + return new QFontEngineMultiQPA(fontEngine, script); } /*! diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index 5a5a8f321f..3810b75dbf 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -89,7 +89,7 @@ class Q_GUI_EXPORT QPlatformFontDatabase public: virtual ~QPlatformFontDatabase(); virtual void populateFontDatabase(); - virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script, const QStringList &fallbacks); + virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script); virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); |