From 3ed2ec14870c4035cfd1bd986f6d8f4f55890270 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Mar 2014 16:20:11 +0100 Subject: Fix some documentation errors. Correct links and fix typos, remove obsolete documentation, fix some snippets, mark some classes as internal. Change-Id: I9a3266605f060783413d32740057a57a820c8929 Reviewed-by: Laszlo Agocs --- src/corelib/kernel/qmimedata.cpp | 2 +- src/corelib/kernel/qobject.cpp | 6 ++--- src/corelib/tools/qmargins.cpp | 20 ++++++++++++++++ src/corelib/tools/qstring.cpp | 4 ++-- src/corelib/xml/qxmlstream.cpp | 4 ++-- src/dbus/qdbusreply.cpp | 7 +++++- src/gui/image/qimage.cpp | 2 +- src/gui/kernel/qdrag.cpp | 2 +- src/gui/kernel/qevent.cpp | 4 ++-- src/gui/kernel/qopenglcontext.cpp | 4 ++-- src/gui/kernel/qsessionmanager.cpp | 8 +++---- src/gui/kernel/qsurfaceformat.cpp | 2 +- src/gui/opengl/qopengltexture.cpp | 14 ++++++------ src/opengl/qgl.cpp | 47 +------------------------------------- src/opengl/qglfunctions.cpp | 4 ++-- src/sql/kernel/qsqlquery.cpp | 2 +- 16 files changed, 55 insertions(+), 77 deletions(-) diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 483692cdf8..5d2adb0561 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -299,7 +299,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty QMacPasteboardMime maps MIME to Mac flavors. \sa QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag, - QWindowsMime, QMacPasteboardMime, {Drag and Drop} + QMacPasteboardMime, {Drag and Drop} */ /*! diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 262d259136..01bedb4a3a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -551,7 +551,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object) QObject::signalsBlocked() state is transferred to this object. The object's signals this signal blocker was blocking prior to - being moved to, if any, are unblocked \em except in the case where + being moved to, if any, are unblocked \e except in the case where both instances block the same object's signals and \c *this is unblocked while \a other is not, at the time of the move. */ @@ -2731,9 +2731,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign Qt::ConnectionType type) but it uses QMetaMethod to specify signal and method. - \sa connect(const QObject *sender, const char *signal, - const QObject *receiver, const char *method, - Qt::ConnectionType type) + \sa connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) */ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 03993f05a9..6f2c6c2c7c 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -333,6 +333,26 @@ QT_BEGIN_NAMESPACE \since 5.1 */ +/*! + \fn QMargins &QMargins::operator+=(int addend) + \overload + + Adds the \a addend to each component of this object + and returns a reference to it. + + \sa operator-=() +*/ + +/*! + \fn QMargins &QMargins::operator-=(int subtrahend) + \overload + + Subtracts the \a subtrahend from each component of this object + and returns a reference to it. + + \sa operator+=() +*/ + /*! \fn QMargins &QMargins::operator*=(int factor) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7547ba8c19..a8770e886b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6168,7 +6168,7 @@ qulonglong QString::toIntegral_helper(const QChar *data, uint len, bool *ok, int \snippet qstring/main.cpp 73 - \sa number(), toULong(), toInt(), QLocale::toLong() + \sa number(), toULong(), toInt(), QLocale::toInt() */ long QString::toLong(bool *ok, int base) const @@ -6197,7 +6197,7 @@ long QString::toLong(bool *ok, int base) const \snippet qstring/main.cpp 78 - \sa number(), QLocale::toULong() + \sa number(), QLocale::toUInt() */ ulong QString::toULong(bool *ok, int base) const diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 5461139582..83d0c73ae1 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -349,11 +349,11 @@ QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const \l{QNetworkAccessManager} {network access manager}, you would issue a \l{QNetworkRequest} {network request} to the manager and receive a \l{QNetworkReply} {network reply} in return. Since a QNetworkReply - is a QIODevice, you connect its \l{QNetworkReply::readyRead()} + is a QIODevice, you connect its \l{QIODevice::readyRead()} {readyRead()} signal to a custom slot, e.g. \c{slotReadyRead()} in the code snippet shown in the discussion for QNetworkAccessManager. In this slot, you read all available data with - \l{QNetworkReply::readAll()} {readAll()} and pass it to the XML + \l{QIODevice::readAll()} {readAll()} and pass it to the XML stream reader using addData(). Then you call your custom parsing function that reads the XML events from the reader. diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index b1326c11f1..551891fdf2 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -155,7 +155,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QDBusReply::error() + \fn const QDBusError& QDBusReply::error() const Returns the error code that was returned from the remote function call. If the remote call did not return an error (i.e., if it succeeded), then the QDBusError object that is returned will @@ -164,6 +164,11 @@ QT_BEGIN_NAMESPACE \sa isValid() */ +/*! + \fn const QDBusError& QDBusReply::error() + \overload +*/ + /*! \fn QDBusReply::value() const Returns the remote function's calls return value. If the remote call returned with an error, diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 48c262ae7a..3998bbf3ff 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -611,7 +611,7 @@ bool QImageData::checkForAlphaPixels() const */ /*! - \fn QImage &operator=(QImage &&other) + \fn QImage &QImage::operator=(QImage &&other) Move-assigns \a other to this QImage instance. diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 465c04cdc8..d7fd4d5bc0 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -101,7 +101,7 @@ QT_BEGIN_NAMESPACE \l{QWidget::mouseMoveEvent()}{mouseMoveEvent()} to check whether a QDrag is required. - \sa {Drag and Drop}, QClipboard, QMimeData, QWindowsMime, QMacPasteboardMime, + \sa {Drag and Drop}, QClipboard, QMimeData, QMacPasteboardMime, {Draggable Icons Example}, {Draggable Text Example}, {Drop Site Example}, {Fridge Magnets Example} */ diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 92d9871dc5..bb7000a266 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -628,7 +628,7 @@ QHoverEvent::~QHoverEvent() \a modifiers holds the keyboard modifier flags at the time of the event, and \a orient holds the wheel's orientation. - \sa pos(), pixelDelta(), angleDelta(), state() + \sa pos(), pixelDelta(), angleDelta() */ #ifndef QT_NO_WHEELEVENT QWheelEvent::QWheelEvent(const QPointF &pos, int delta, @@ -659,7 +659,7 @@ QWheelEvent::~QWheelEvent() \a orient holds the wheel's orientation. - \sa pos(), pixelDelta(), angleDelta(), state() + \sa pos(), pixelDelta(), angleDelta() */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 5087e33b47..e258218e85 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -165,7 +165,7 @@ void QOpenGLVersionProfile::setVersion(int majorVersion, int minorVersion) /*! Returns the OpenGL profile. Only makes sense if profiles are supported by this version. - \sa setProfile(), supportsProfiles() + \sa setProfile() */ QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const { @@ -176,7 +176,7 @@ QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const Sets the OpenGL profile \a profile. Only makes sense if profiles are supported by this version. - \sa profile(), supportsProfiles() + \sa profile() */ void QOpenGLVersionProfile::setProfile(QSurfaceFormat::OpenGLContextProfile profile) { diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp index b9ef35854c..a428840ca8 100644 --- a/src/gui/kernel/qsessionmanager.cpp +++ b/src/gui/kernel/qsessionmanager.cpp @@ -201,7 +201,7 @@ QString QSessionManager::sessionKey() const Here's an example of how an application's QGuiApplication::commitDataRequest() might be implemented: - \snippet code/src_gui_kernel_qguiapplication.cpp 8 + \snippet code/src_gui_kernel_qguiapplication.cpp 1 If an error occurred within the application while saving its data, you may want to try allowsErrorInteraction() instead. @@ -293,7 +293,7 @@ QSessionManager::RestartHint QSessionManager::restartHint() const If the session manager is capable of restoring sessions it will execute \a command in order to restore the application. The command defaults to - \snippet code/src_gui_kernel_qguiapplication.cpp 9 + \snippet code/src_gui_kernel_qguiapplication.cpp 2 The \c -session option is mandatory; otherwise QGuiApplication cannot tell whether it has been restored or what the current session identifier @@ -321,7 +321,7 @@ void QSessionManager::setRestartCommand(const QStringList &command) To iterate over the list, you can use the \l foreach pseudo-keyword: - \snippet code/src_gui_kernel_qguiapplication.cpp 10 + \snippet code/src_gui_kernel_qguiapplication.cpp 3 \sa setRestartCommand(), restartHint() */ @@ -347,7 +347,7 @@ void QSessionManager::setDiscardCommand(const QStringList &command) To iterate over the list, you can use the \l foreach pseudo-keyword: - \snippet code/src_gui_kernel_qguiapplication.cpp 11 + \snippet code/src_gui_kernel_qguiapplication.cpp 4 \sa setDiscardCommand(), restartCommand(), setRestartCommand() */ diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 23c0e59779..2b8e611dff 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -387,7 +387,7 @@ void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on) Returns true if the format option \a option is set; otherwise returns false. - \sa options(), testOption() + \sa options() */ bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option) const { diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 983496230d..078274eabd 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -2668,12 +2668,12 @@ void QOpenGLTexture::generateMipMaps() } /*! - Generates mipmaps for this texture object from mipmap level \baseLevel. If you are + Generates mipmaps for this texture object from mipmap level \a baseLevel. If you are using a texture target and filtering option that requires mipmaps and you have disabled automatic mipmap generation then you need to call this function or the overload to create the mipmap chain. - The generation of mipmaps to above \baseLevel is achieved by setting the mipmap + The generation of mipmaps to above \a baseLevel is achieved by setting the mipmap base level to \a baseLevel and then generating the mipmap chain. If \a resetBaseLevel is \c true, then the baseLevel of the texture will be reset to its previous value. @@ -3000,7 +3000,7 @@ void QOpenGLTexture::setBorderColor(QColor color) } /*! - Sets the color red to \a {r}, green to \a {g}, blue to \{b}, and \a {a} to the + Sets the color red to \a {r}, green to \a {g}, blue to \a {b}, and \a {a} to the alpha value. \overload */ @@ -3033,8 +3033,8 @@ void QOpenGLTexture::setBorderColor(float r, float g, float b, float a) } /*! - Sets the color red to \a {r}, green to \a {g}, blue to \a {b}, and \a the alpha - value to {a}. + Sets the color red to \a {r}, green to \a {g}, blue to \a {b}, and the alpha + value to \a {a}. \overload */ void QOpenGLTexture::setBorderColor(int r, int g, int b, int a) @@ -3068,8 +3068,8 @@ void QOpenGLTexture::setBorderColor(int r, int g, int b, int a) } /*! - Sets the color red to \a {r}, green to \a {g}, blue to \a {b}, and \a the alpha - value to {a}. + Sets the color red to \a {r}, green to \a {g}, blue to \a {b}, and the alpha + value to \a {a}. \overload */ void QOpenGLTexture::setBorderColor(uint r, uint g, uint b, uint a) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index de1de476b8..e602a05af9 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3227,43 +3227,6 @@ void QGLContext::moveToThread(QThread *thread) visual. On other platforms it may work differently. */ -/*! \fn int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc) - - \b{Win32 only:} This virtual function chooses a pixel format - that matches the OpenGL \l{setFormat()}{format}. - Reimplement this function in a subclass if you need a custom - context. - - \warning The \a dummyPfd pointer and \a pdc are used as a \c - PIXELFORMATDESCRIPTOR*. We use \c void to avoid using - Windows-specific types in our header files. - - \sa chooseContext() -*/ - -/*! \fn void *QGLContext::chooseVisual() - - \b{X11 only:} This virtual function tries to find a visual that - matches the format, reducing the demands if the original request - cannot be met. - - The algorithm for reducing the demands of the format is quite - simple-minded, so override this method in your subclass if your - application has spcific requirements on visual selection. - - \sa chooseContext() -*/ - -/*! \fn void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) - \internal - - \b{X11 only:} This virtual function chooses a visual that matches - the OpenGL \l{format()}{format}. Reimplement this function - in a subclass if you need a custom visual. - - \sa chooseContext() -*/ - /*! \fn void QGLContext::reset() @@ -3706,7 +3669,7 @@ QGLWidget::~QGLWidget() */ /*! - \fn QFunctionPointer QGLContext::getProcAddress() const + \fn QFunctionPointer QGLContext::getProcAddress(const QString &proc) const Returns a function pointer to the GL extension function passed in \a proc. 0 is returned if a pointer to the function could not be @@ -4045,14 +4008,6 @@ void QGLWidget::paintEvent(QPaintEvent *) */ -/*! - \fn void QGLWidget::setMouseTracking(bool enable) - - If \a enable is true then mouse tracking is enabled; otherwise it - is disabled. -*/ - - /*! Renders the current scene on a pixmap and returns the pixmap. diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp index 450f17b171..d6d77d0568 100644 --- a/src/opengl/qglfunctions.cpp +++ b/src/opengl/qglfunctions.cpp @@ -466,7 +466,7 @@ void QGLFunctions::initializeGLFunctions(const QGLContext *context) */ /*! - \fn void QGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage) + \fn void QGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage) Convenience function that calls glBufferData(\a target, \a size, \a data, \a usage). @@ -475,7 +475,7 @@ void QGLFunctions::initializeGLFunctions(const QGLContext *context) */ /*! - \fn void QGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data) + \fn void QGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data) Convenience function that calls glBufferSubData(\a target, \a offset, \a size, \a data). diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index 0cfc37833d..b08f6bc8ef 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -311,7 +311,7 @@ QSqlQuery& QSqlQuery::operator=(const QSqlQuery& other) /*! Returns \c true if the query is not \l{isActive()}{active}, the query is not positioned on a valid record, - there is no such field, or the field is null; otherwise \c false. + there is no such \a field, or the \a field is null; otherwise \c false. Note that for some drivers, isNull() will not return accurate information until after an attempt is made to retrieve data. -- cgit v1.2.3 From 48679a3748108fc600853f5f7355cb8495c649d2 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 22 Mar 2014 13:04:10 +0200 Subject: Fix tst_QTextScriptEngine failures on some platforms The text shaping process has been unified for all platforms. Task-number: QTBUG-23064 Task-number: QTBUG-24565 Task-number: QTBUG-26495 Change-Id: Ida4c4be85f1a72c04399d2e6760fa36b33a0464e Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../qtextscriptengine/tst_qtextscriptengine.cpp | 287 ++++++++++++--------- 1 file changed, 166 insertions(+), 121 deletions(-) diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 74802c3217..c4db669695 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -86,12 +86,13 @@ private slots: void greek_data(); void greek(); - void controlInSyllable_qtbug14204(); - void combiningMarks_qtbug15675(); - void mirroredChars_data(); void mirroredChars(); + void controlInSyllable_qtbug14204(); + void combiningMarks_qtbug15675_data(); + void combiningMarks_qtbug15675(); + void thaiIsolatedSaraAm(); void thaiWithZWJ(); void thaiMultipleVowels(); @@ -1051,87 +1052,18 @@ void tst_QTextScriptEngine::greek() doShapingTests(); } -void tst_QTextScriptEngine::controlInSyllable_qtbug14204() -{ -#if 0 && defined(Q_OS_UNIX) - // ### the test is incorrect -> disable for now - QString s; - s.append(QChar(0x0915)); - s.append(QChar(0x094d)); - s.append(QChar(0x200d)); - s.append(QChar(0x0915)); - - QTextLayout layout(s); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - QVERIFY(e->layoutData->glyphLayout.advances[1].toInt() != 0); -#endif -} - -void tst_QTextScriptEngine::combiningMarks_qtbug15675() -{ -#if defined(Q_OS_MAC) - QString s; - s.append(QChar(0x0061)); - s.append(QChar(0x0062)); - s.append(QChar(0x0300)); - s.append(QChar(0x0063)); - - QFont font("Monaco"); - QTextLayout layout(s, font); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(4)); - QCOMPARE(e->layoutData->glyphLayout.advances[2].toInt(), 0); -#else - QFontDatabase db; - - if (!db.families().contains("DejaVu Sans Mono")) - QSKIP("Required font (DejaVu Sans Mono) doesn't exist, skip test."); - - QString s; - s.append(QChar(0x0062)); - s.append(QChar(0x0332)); - s.append(QChar(0x0063)); - - QTextLayout layout(s, QFont("DejaVu Sans Mono")); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); - QCOMPARE(e->layoutData->glyphLayout.advances[1].toInt(), 0); -#endif -} - void tst_QTextScriptEngine::mirroredChars_data() { - QTest::addColumn("hintingPreference"); + QTest::addColumn("s"); - QTest::newRow("Default hinting") << int(QFont::PreferDefaultHinting); - QTest::newRow("No hinting") << int(QFont::PreferNoHinting); - QTest::newRow("Vertical hinting") << int(QFont::PreferVerticalHinting); - QTest::newRow("Full hinting") << int(QFont::PreferFullHinting); + QTest::newRow("()") << QStringLiteral("()"); + QTest::newRow("[]") << QStringLiteral("[]"); + QTest::newRow("{}") << QStringLiteral("{}"); } void tst_QTextScriptEngine::mirroredChars() { -#if defined(Q_OS_MAC) - QSKIP("Not supported on Mac"); -#endif - QFETCH(int, hintingPreference); - - QFont font; - font.setHintingPreference(QFont::HintingPreference(hintingPreference)); - - QString s; - s.append(QLatin1Char('(')); - s.append(QLatin1Char(')')); + QFETCH(QString, s); glyph_t leftParenthesis; glyph_t rightParenthesis; @@ -1144,10 +1076,12 @@ void tst_QTextScriptEngine::mirroredChars() QTextEngine *e = layout.engine(); e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + e->shape(0); QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout; + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); leftParenthesis = glyphLayout.glyphs[0]; rightParenthesis = glyphLayout.glyphs[1]; } @@ -1158,61 +1092,170 @@ void tst_QTextScriptEngine::mirroredChars() QTextEngine *e = layout.engine(); e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + e->shape(0); QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); - const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout; + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); QCOMPARE(glyphLayout.glyphs[0], rightParenthesis); QCOMPARE(glyphLayout.glyphs[1], leftParenthesis); } } +void tst_QTextScriptEngine::controlInSyllable_qtbug14204() +{ + QFontDatabase db; + if (!db.families().contains(QStringLiteral("Aparajita"))) + QSKIP("couldn't find 'Aparajita' font"); + + QFont font(QStringLiteral("Aparajita")); + font.setStyleStrategy(QFont::NoFontMerging); + + QString s; + s.append(QChar(0x0915)); + s.append(QChar(0x094d)); + s.append(QChar(0x200d)); + s.append(QChar(0x0915)); + + QTextLayout layout(s, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); + QCOMPARE(log_clusters[1], ushort(0)); + QCOMPARE(log_clusters[2], ushort(0)); + QCOMPARE(log_clusters[3], ushort(0)); +} + +void tst_QTextScriptEngine::combiningMarks_qtbug15675_data() +{ + QTest::addColumn("font"); + QTest::addColumn("string"); + + bool hasTests = false; + + QStringList families; + families << QStringLiteral("Monaco"); + families << QStringLiteral("DejaVu Sans Mono"); + + foreach (const QString &family, families) { + QFont font(family); + font.setStyleStrategy(QFont::NoFontMerging); + if (QFontInfo(font).family() != family) + continue; + + hasTests = true; + + QString s(QStringLiteral("ab cd")); + for (ushort uc = 0x0300; uc < 0x0370; ++uc) { + s[2] = QChar(uc); + QByteArray testName = family.toLatin1() + ": abcd"; + QTest::newRow(testName.constData()) << font << s; + } + } + + if (!hasTests) + QSKIP("Couldn't find required fonts, skip test."); +} + +void tst_QTextScriptEngine::combiningMarks_qtbug15675() +{ + QFETCH(QFont, font); + QFETCH(QString, string); + + QTextLayout layout(string, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + const int diff = e->layoutData->items[0].num_glyphs - string.size(); + QVERIFY(diff >= -1 && diff <= 1); // could compose or decompose exactly one character + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); + QCOMPARE(log_clusters[1], ushort(1)); + QCOMPARE(log_clusters[2], ushort(1)); + QCOMPARE(log_clusters[3], ushort(3 + diff)); + QCOMPARE(log_clusters[4], ushort(4 + diff)); + + const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]); + for (int i = 0; i < glyphLayout.numGlyphs; ++i) { + if ((diff >= 0 && i == 2) || (diff > 0 && i == 2 + diff)) + QCOMPARE(glyphLayout.advances[i].toInt(), 0); + else + QVERIFY(glyphLayout.advances[i].toInt() != 0); + } +} + void tst_QTextScriptEngine::thaiIsolatedSaraAm() { - if (QFontDatabase().families(QFontDatabase::Any).contains("Waree")) { - QString s; - s.append(QChar(0x0e33)); + QFontDatabase db; + if (!db.families().contains("Waree")) + QSKIP("couldn't find 'Waree' font"); - QTextLayout layout(s, QFont("Waree")); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QFont font(QStringLiteral("Waree")); + font.setStyleStrategy(QFont::NoFontMerging); - QTextEngine *e = layout.engine(); - e->itemize(); - e->shape(0); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); + QString s; + s.append(QChar(0x0e33)); - unsigned short *logClusters = e->logClusters(&e->layoutData->items[0]); - QCOMPARE(logClusters[0], ushort(0)); - } else - QSKIP("Cannot find Waree."); + QTextLayout layout(s, font); + QTextEngine *e = layout.engine(); + e->itemize(); + QCOMPARE(e->layoutData->items.size(), 1); + + QFontEngine *fe = e->fontEngine(e->layoutData->items[0]); + if (fe->type() == QFontEngine::Box) + QSKIP("OpenType support missing for script"); + QCOMPARE(fe->fontDef.family, font.family()); + + e->shape(0); + QVERIFY(e->layoutData->items[0].num_glyphs > 0); + + const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); + QCOMPARE(log_clusters[0], ushort(0)); } void tst_QTextScriptEngine::thaiWithZWJ() { -#ifdef Q_OS_WIN - QSKIP("This test currently fails on Windows - QTBUG-24565"); -#endif + QFontDatabase db; + if (!db.families().contains("Waree")) + QSKIP("couldn't find 'Waree' font"); + + QFont font(QStringLiteral("Waree")); + font.setStyleStrategy(QFont::NoFontMerging); + QString s(QString::fromUtf8("\xe0\xb8\xa3\xe2\x80\x8d\xe0\xb8\xa3\xe2\x80" "\x8c\x2e\xe0\xb8\xa3\x2e\xe2\x80\x9c\xe0\xb8" "\xa3\xe2\x80\xa6\xe0\xb8\xa3\xe2\x80\x9d\xe0" "\xb8\xa3\xa0\xe0\xb8\xa3\xe6\x9c\xac\xe0\xb8\xa3") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); - QTextLayout layout(s); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QTextLayout layout(s, font); QTextEngine *e = layout.engine(); - e->width(0, s.length()); //force itemize and shape - - // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. - // The current implementation hides them, so we test for that. - // But make sure that we don't hide anything else + e->itemize(); QCOMPARE(e->layoutData->items.size(), 11); + + for (int item = 0; item < e->layoutData->items.size(); ++item) + e->shape(item); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a separate item QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character @@ -1231,15 +1274,18 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) QCOMPARE(logClusters[i+7], ushort(0)); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23064", Abort); -#endif QCOMPARE(logClusters[17], ushort(1)); - // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 - // and 3. - for (int i = 0; i < 18; i++) - QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. + // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 and 3. + const QGlyphLayout glyphLayout = e->layoutData->glyphLayout; + for (int i = 0; i < 18; i++) { + if (i == 1 || i == 3) + QCOMPARE(glyphLayout.advances[i].toInt(), 0); + else + QVERIFY(glyphLayout.advances[i].toInt() != 0); + } } void tst_QTextScriptEngine::thaiMultipleVowels() @@ -1253,14 +1299,13 @@ void tst_QTextScriptEngine::thaiMultipleVowels() for (int i = 0; i < 10; i++) s += s; //Repeat the string to make it more likely to crash if we have a buffer overflow - QTextLayout layout(s); - layout.setCacheEnabled(true); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); + QTextLayout layout(s); QTextEngine *e = layout.engine(); - e->width(0, s.length()); //force itemize and shape + e->itemize(); + + for (int item = 0; item < e->layoutData->items.size(); ++item) + e->shape(item); // If we haven't crashed at this point, then the test has passed. } -- cgit v1.2.3 From cd8e11ed416035763dc25a25a71291d10976943a Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Mon, 24 Mar 2014 12:45:48 +0100 Subject: Doc: Fix warning about nonexistent 'message' parameter Change-Id: I3461f2468ef90452ae7e3830625bf3ed57d22a41 Reviewed-by: Friedemann Kleint --- src/testlib/qtestcase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 7b225ef5b4..3ab3fcc44c 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2591,10 +2591,10 @@ void QTest::ignoreMessage(QtMsgType type, const char *message) /*! \overload - Ignores messages created by qDebug() or qWarning(). If the \a message + Ignores messages created by qDebug() or qWarning(). If the message matching \a messagePattern with the corresponding \a type is outputted, it will be removed from the - test log. If the test finished and the \a message was not outputted, + test log. If the test finished and the message was not outputted, a test failure is appended to the test log. \b {Note:} Invoking this function will only ignore one message. -- cgit v1.2.3 From 225a5b4787b3a04fd32958dba3e479761efc0623 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 17 Mar 2014 14:06:43 +0100 Subject: Do not use -Bsymbolic* on anything but x86 and x86-64 We're getting problems with PMF comparisons failing on ARM and PPC, which in turn break the new PMF-based connect syntax. Dropping -Bsymbolic* seems to work around the issue (which has been reported upstream, and it's likely to be a linker issue, see the discussion in the bug report). Task-number: QTBUG-36129 Change-Id: I8675a57acf26fdb9fbbc4d03896d5f6a9a96d506 Reviewed-by: Thiago Macieira --- config.tests/unix/bsymbolic_functions.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.tests/unix/bsymbolic_functions.test b/config.tests/unix/bsymbolic_functions.test index d495e56bef..4d66ee6de0 100755 --- a/config.tests/unix/bsymbolic_functions.test +++ b/config.tests/unix/bsymbolic_functions.test @@ -6,6 +6,10 @@ VERBOSE=$2 cat >>bsymbolic_functions.c << EOF +#if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)) +#error "Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129)." +#endif + int main() { return 0; } EOF -- cgit v1.2.3 From dbb6b58abede12cf9f2fad3086dd59a9d46b7ee7 Mon Sep 17 00:00:00 2001 From: John Layt Date: Sun, 23 Mar 2014 17:07:26 +0100 Subject: QPrintDialog - Convert manual test to .ui file Convert the manual print dialogs test to use a ui file as subsequent changes will add a lot more widgets. Change-Id: I06ac54b67532f0eea1e91a2d9aca4f587d2fa332 Reviewed-by: Friedemann Kleint --- tests/manual/dialogs/dialogs.pro | 1 + tests/manual/dialogs/printdialogpanel.cpp | 157 ++++++----------- tests/manual/dialogs/printdialogpanel.h | 18 +- tests/manual/dialogs/printdialogpanel.ui | 270 ++++++++++++++++++++++++++++++ tests/manual/dialogs/utils.cpp | 21 +++ tests/manual/dialogs/utils.h | 4 + 6 files changed, 357 insertions(+), 114 deletions(-) create mode 100644 tests/manual/dialogs/printdialogpanel.ui diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro index 71c41119fe..21ebf9b622 100644 --- a/tests/manual/dialogs/dialogs.pro +++ b/tests/manual/dialogs/dialogs.pro @@ -8,3 +8,4 @@ SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp wizardpanel.cpp messageboxpanel.cpp printdialogpanel.cpp utils.cpp HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \ wizardpanel.h messageboxpanel.h printdialogpanel.h utils.h +FORMS += printdialogpanel.ui diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index 5c89055e22..b012d34db0 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -65,7 +65,7 @@ #include #include -const FlagData modeComboData[] = +const FlagData printerModeComboData[] = { {"ScreenResolution", QPrinter::ScreenResolution}, {"PrinterResolution", QPrinter::PrinterResolution}, @@ -260,91 +260,30 @@ public slots: void slotPaintRequested(QPrinter *p) { print(p); } }; -class PageSizeControl : public QWidget { -public: - explicit PageSizeControl(QWidget *parent = 0); - QSizeF pageSize() const { return QSizeF(m_width->value(), m_height->value()); } - void setPageSize(const QSizeF &s) { m_width->setValue(s.width()); m_height->setValue(s.height()); } - -private: - QDoubleSpinBox *m_width; - QDoubleSpinBox *m_height; -}; - -PageSizeControl::PageSizeControl(QWidget *parent) - : QWidget(parent) - , m_width(new QDoubleSpinBox(this)) - , m_height(new QDoubleSpinBox(this)) -{ - m_width->setRange(1, 1000); - m_width->setSingleStep(10); - m_height->setRange(1, 1000); - m_height->setSingleStep(10); - QHBoxLayout *hBoxLayout = new QHBoxLayout(this); - hBoxLayout->addWidget(m_width); - hBoxLayout->addWidget(new QLabel("x", this)); - hBoxLayout->addWidget(m_height); - hBoxLayout->addWidget(new QLabel("mm", this)); -} - PrintDialogPanel::PrintDialogPanel(QWidget *parent) : QWidget(parent) - , m_creationGroupBox(new QGroupBox(tr("Create"), this)) - , m_settingsGroupBox(new QGroupBox(tr("Settings"), this)) - , m_dialogsGroupBox(new QGroupBox(tr("Dialogs"), this)) - , m_pageSizeCombo(new QComboBox) { - // Create with resolution - QHBoxLayout *hBoxLayout = new QHBoxLayout(m_creationGroupBox); - m_modeCombo = createCombo(m_creationGroupBox, modeComboData, sizeof(modeComboData)/sizeof(FlagData)); - hBoxLayout->addWidget(m_modeCombo); - m_createButton = new QPushButton(tr("Create"), m_creationGroupBox); - connect(m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter())); - hBoxLayout->addWidget(m_createButton); - m_deleteButton = new QPushButton(tr("Delete"), m_creationGroupBox); - connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter())); - hBoxLayout->addWidget(m_deleteButton); - hBoxLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); - - QFormLayout *formLayout = new QFormLayout(m_settingsGroupBox); - m_pageSizeCombo = createCombo(m_settingsGroupBox, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData)); - connect(m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl())); - formLayout->addRow(tr("Paper #:"), m_pageSizeCombo); - m_customPageSizeControl = new PageSizeControl; - formLayout->addRow(tr("Custom size:"), m_customPageSizeControl); - m_orientationCombo = createCombo(m_settingsGroupBox, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData)); - formLayout->addRow("Orientation:", m_orientationCombo); - m_fullPageCheckBox = new QCheckBox(tr("Full page"), m_settingsGroupBox); - formLayout->addRow(m_fullPageCheckBox); - - QVBoxLayout *vBoxLayout = new QVBoxLayout(m_dialogsGroupBox); - - m_printDialogOptionsControl = new OptionsControl(tr("Options"), printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData), m_dialogsGroupBox); - vBoxLayout->addWidget(m_printDialogOptionsControl); - m_printDialogRangeCombo = createCombo(m_dialogsGroupBox, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData)); - vBoxLayout->addWidget(m_printDialogRangeCombo); - - { - QPrintDialog dialog; - m_printDialogOptionsControl->setValue(dialog.options()); - m_printDialogRangeCombo->setCurrentIndex(dialog.printRange()); - } - - QPushButton *button = new QPushButton(tr("Print..."), m_dialogsGroupBox); - connect(button, SIGNAL(clicked()), this, SLOT(showPrintDialog())); - vBoxLayout->addWidget(button); - button = new QPushButton(tr("Preview..."), m_dialogsGroupBox); - connect(button, SIGNAL(clicked()), this, SLOT(showPreviewDialog())); - vBoxLayout->addWidget(button); - button = new QPushButton(tr("Page Setup..."), m_dialogsGroupBox); - connect(button, SIGNAL(clicked()), this, SLOT(showPageSetupDialog())); - vBoxLayout->addWidget(button); - - QGridLayout *gridLayout = new QGridLayout(this); - gridLayout->addWidget(m_creationGroupBox, 0, 0); - gridLayout->addWidget(m_settingsGroupBox, 1, 0); - gridLayout->addWidget(m_dialogsGroupBox, 0, 1, 2, 1); - gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 2, 0, 1, 2); + m_panel.setupUi(this); + + // Setup the Create box + populateCombo(m_panel.m_printerModeCombo, printerModeComboData, sizeof(printerModeComboData)/sizeof(FlagData)); + connect(m_panel.m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter())); + connect(m_panel.m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter())); + + // Setup the Settings box + populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData)); + connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl())); + populateCombo(m_panel.m_orientationCombo, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData)); + + // Setup the Dialogs box + m_panel.m_dialogOptionsGroupBox->populateOptions(printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData)); + populateCombo(m_panel.m_printDialogRangeCombo, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData)); + QPrintDialog dialog; + m_panel.m_dialogOptionsGroupBox->setValue(dialog.options()); + m_panel.m_printDialogRangeCombo->setCurrentIndex(dialog.printRange()); + connect(m_panel.m_printButton, SIGNAL(clicked()), this, SLOT(showPrintDialog())); + connect(m_panel.m_printPreviewButton, SIGNAL(clicked()), this, SLOT(showPreviewDialog())); + connect(m_panel.m_pageSetupButton, SIGNAL(clicked()), this, SLOT(showPageSetupDialog())); enablePanels(); } @@ -356,16 +295,16 @@ PrintDialogPanel::~PrintDialogPanel() void PrintDialogPanel::enablePanels() { const bool exists = !m_printer.isNull(); - m_createButton->setEnabled(!exists); - m_modeCombo->setEnabled(!exists); - m_deleteButton->setEnabled(exists); - m_settingsGroupBox->setEnabled(exists); - m_dialogsGroupBox->setEnabled(exists); + m_panel.m_createButton->setEnabled(!exists); + m_panel.m_printerModeCombo->setEnabled(!exists); + m_panel.m_deleteButton->setEnabled(exists); + m_panel.m_settingsGroupBox->setEnabled(exists); + m_panel.m_dialogsGroupBox->setEnabled(exists); } void PrintDialogPanel::createPrinter() { - const QPrinter::PrinterMode mode = comboBoxValue(m_modeCombo); + const QPrinter::PrinterMode mode = comboBoxValue(m_panel.m_printerModeCombo); m_printer.reset(new QPrinter(mode)); // Can set only once. retrieveSettings(m_printer.data()); enablePanels(); @@ -378,36 +317,49 @@ void PrintDialogPanel::deletePrinter() enablePanels(); } +QSizeF PrintDialogPanel::pageSize() const +{ + return QSizeF(m_panel.m_pageWidth->value(), m_panel.m_pageHeight->value()); +} + +void PrintDialogPanel::setPageSize(const QSizeF &sizef) +{ + m_panel.m_pageWidth->setValue(sizef.width()); + m_panel.m_pageHeight->setValue(sizef.height()); +} + void PrintDialogPanel::applySettings(QPrinter *printer) const { - const QPrinter::PageSize pageSize = comboBoxValue(m_pageSizeCombo); - if (pageSize == QPrinter::Custom) - printer->setPaperSize(m_customPageSizeControl->pageSize(), QPrinter::Millimeter); + const QPrinter::PageSize pageSizeId = comboBoxValue(m_panel.m_pageSizeCombo); + if (pageSizeId == QPrinter::Custom) + printer->setPaperSize(pageSize(), QPrinter::Millimeter); else - printer->setPageSize(pageSize); - printer->setOrientation(comboBoxValue(m_orientationCombo)); - printer->setFullPage(m_fullPageCheckBox->isChecked()); + printer->setPageSize(pageSizeId); + printer->setOrientation(comboBoxValue(m_panel.m_orientationCombo)); + printer->setFullPage(m_panel.m_fullPageCheckBox->isChecked()); } void PrintDialogPanel::retrieveSettings(const QPrinter *printer) { - setComboBoxValue(m_pageSizeCombo, printer->pageSize()); - setComboBoxValue(m_orientationCombo, printer->orientation()); - m_fullPageCheckBox->setChecked(printer->fullPage()); - m_customPageSizeControl->setPageSize(m_printer->paperSize(QPrinter::Millimeter)); + setComboBoxValue(m_panel.m_pageSizeCombo, printer->pageSize()); + setComboBoxValue(m_panel.m_orientationCombo, printer->orientation()); + m_panel.m_fullPageCheckBox->setChecked(printer->fullPage()); + setPageSize(m_printer->paperSize(QPrinter::Millimeter)); } void PrintDialogPanel::enableCustomSizeControl() { - m_customPageSizeControl->setEnabled(m_pageSizeCombo->currentIndex() == QPrinter::Custom); + bool custom = (m_panel.m_pageSizeCombo->currentIndex() == QPrinter::Custom); + m_panel.m_pageWidth->setEnabled(custom); + m_panel.m_pageHeight->setEnabled(custom); } void PrintDialogPanel::showPrintDialog() { applySettings(m_printer.data()); QPrintDialog dialog(m_printer.data(), this); - dialog.setOptions(m_printDialogOptionsControl->value()); - dialog.setPrintRange(comboBoxValue(m_printDialogRangeCombo)); + dialog.setOptions(m_panel.m_dialogOptionsGroupBox->value()); + dialog.setPrintRange(comboBoxValue(m_panel.m_printDialogRangeCombo)); if (dialog.exec() == QDialog::Accepted) { retrieveSettings(m_printer.data()); print(m_printer.data()); @@ -431,6 +383,7 @@ void PrintDialogPanel::showPageSetupDialog() retrieveSettings(m_printer.data()); } +#include "moc_printdialogpanel.cpp" #include "printdialogpanel.moc" #endif // !QT_NO_PRINTER diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h index c869782769..a7ae257cf8 100644 --- a/tests/manual/dialogs/printdialogpanel.h +++ b/tests/manual/dialogs/printdialogpanel.h @@ -44,6 +44,8 @@ #ifndef QT_NO_PRINTER +#include "ui_printdialogpanel.h" + #include QT_BEGIN_NAMESPACE @@ -73,22 +75,14 @@ private slots: void enableCustomSizeControl(); private: + QSizeF pageSize() const; + void setPageSize(const QSizeF &sizef); void applySettings(QPrinter *printer) const; void retrieveSettings(const QPrinter *printer); void enablePanels(); - QGroupBox *m_creationGroupBox; - QPushButton *m_createButton; - QPushButton *m_deleteButton; - QGroupBox *m_settingsGroupBox; - QCheckBox *m_fullPageCheckBox; - QGroupBox *m_dialogsGroupBox; - OptionsControl *m_printDialogOptionsControl; - QComboBox *m_printDialogRangeCombo; - QComboBox *m_modeCombo; - QComboBox *m_orientationCombo; - QComboBox *m_pageSizeCombo; - PageSizeControl *m_customPageSizeControl; + Ui::PrintDialogPanel m_panel; + QScopedPointer m_printer; }; diff --git a/tests/manual/dialogs/printdialogpanel.ui b/tests/manual/dialogs/printdialogpanel.ui new file mode 100644 index 0000000000..a185629fc1 --- /dev/null +++ b/tests/manual/dialogs/printdialogpanel.ui @@ -0,0 +1,270 @@ + + + PrintDialogPanel + + + + 0 + 0 + 507 + 291 + + + + + 0 + 0 + + + + Form + + + + + + + + + 0 + 0 + + + + Create + + + + + + Printer Mode: + + + + + + + + + + + + Create + + + + + + + Delete + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + Settings + + + + + + Page Size: + + + + + + + + + + + + mm + + + 1000.000000000000000 + + + 10.000000000000000 + + + + + + + x + + + + + + + mm + + + 1000.000000000000000 + + + 10.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Orientation: + + + + + + + + + + Full Page Mode: + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 22 + + + + + + + + + + + + + 0 + 0 + + + + Dialogs + + + + + + Options + + + + + + + + + + Print... + + + + + + + Preview... + + + + + + + Page Setup... + + + + + + + + + + Qt::Vertical + + + + 20 + 80 + + + + + + + + + + + OptionsControl + QGroupBox +
utils.h
+ 1 +
+
+ + +
diff --git a/tests/manual/dialogs/utils.cpp b/tests/manual/dialogs/utils.cpp index 7e0067c7f3..2dc01359b1 100644 --- a/tests/manual/dialogs/utils.cpp +++ b/tests/manual/dialogs/utils.cpp @@ -52,11 +52,23 @@ QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size) return c; } +void populateCombo(QComboBox *combo, const FlagData *d, size_t size) +{ + for (size_t i = 0; i < size; ++i) + combo->addItem(QLatin1String(d[i].description), QVariant(d[i].value)); +} + void setComboBoxValue(QComboBox *c, int v) { c->setCurrentIndex(c->findData(QVariant(v))); } +OptionsControl::OptionsControl(QWidget *parent) + : QGroupBox(parent) +{ + setLayout(new QVBoxLayout(this)); +} + OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent) : QGroupBox(title, parent) { @@ -68,6 +80,15 @@ OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_ } } +void OptionsControl::populateOptions(const FlagData *data, size_t count) +{ + for (size_t i = 0; i < count; ++i) { + QCheckBox *box = new QCheckBox(QString::fromLatin1(data[i].description)); + m_checkBoxes.push_back(CheckBoxFlagPair(box, data[i].value)); + layout()->addWidget(box); + } +} + void OptionsControl::setValue(int flags) { foreach (const CheckBoxFlagPair &cf, m_checkBoxes) diff --git a/tests/manual/dialogs/utils.h b/tests/manual/dialogs/utils.h index 634795627f..ac91754139 100644 --- a/tests/manual/dialogs/utils.h +++ b/tests/manual/dialogs/utils.h @@ -59,6 +59,7 @@ struct FlagData // Helpers for creating combo boxes representing enumeration values from flag data. QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size); +void populateCombo(QComboBox *combo, const FlagData *d, size_t size); template Enum comboBoxValue(const QComboBox *c) @@ -71,8 +72,11 @@ void setComboBoxValue(QComboBox *c, int v); // A group box with check boxes for option flags. class OptionsControl : public QGroupBox { public: + OptionsControl(QWidget *parent); explicit OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent); + void populateOptions(const FlagData *data, size_t count); + void setValue(int flags); template Enum value() const { return static_cast(intValue()); } -- cgit v1.2.3 From d48db922d4310bd001faa708d9cd39e5c17863fa Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 24 Mar 2014 11:51:05 +0100 Subject: QPrintDialog - Add more options to manual test Add all the available QPrinter options to the QPrintDialog manual test to allow for testing presets. Change-Id: Ia6394094fc9920da0d6c645793d51650404899d8 Reviewed-by: Friedemann Kleint --- tests/manual/dialogs/printdialogpanel.cpp | 383 +++++++++++++++++++++++--- tests/manual/dialogs/printdialogpanel.h | 48 +++- tests/manual/dialogs/printdialogpanel.ui | 437 +++++++++++++++++++++++++++++- 3 files changed, 810 insertions(+), 58 deletions(-) diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index b012d34db0..f7d027020c 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -45,6 +45,7 @@ #include "utils.h" #include +#include #include #include #include @@ -64,6 +65,7 @@ #include #include #include +#include const FlagData printerModeComboData[] = { @@ -72,12 +74,7 @@ const FlagData printerModeComboData[] = {"HighResolution", QPrinter::HighResolution} }; -const FlagData orientationComboData[] = -{ - {"Portrait", QPrinter::Portrait}, - {"Landscape", QPrinter::Landscape}, -}; - +#if QT_VERSION < 0x050300 const FlagData pageSizeComboData[] = { {"A4", QPrinter::A4}, @@ -112,6 +109,76 @@ const FlagData pageSizeComboData[] = {"Tabloid", QPrinter::Tabloid}, {"Custom", QPrinter::Custom} }; +#endif + +const FlagData printRangeComboData[] = +{ + {"AllPages", QPrinter::AllPages}, + {"Selection", QPrinter::Selection}, + {"PageRange", QPrinter::PageRange}, + {"CurrentPage", QPrinter::CurrentPage} +}; + +const FlagData pageOrderComboData[] = +{ + {"FirstPageFirst", QPrinter::FirstPageFirst}, + {"LastPageFirst", QPrinter::LastPageFirst}, +}; + +const FlagData duplexModeComboData[] = +{ + {"DuplexNone", QPrinter::DuplexNone}, + {"DuplexAuto", QPrinter::DuplexAuto}, + {"DuplexLongSide", QPrinter::DuplexLongSide}, + {"DuplexShortSide", QPrinter::DuplexShortSide}, +}; + +const FlagData paperSourceComboData[] = +{ + {"OnlyOne", QPrinter::OnlyOne}, + {"Lower", QPrinter::Lower}, + {"Middle", QPrinter::Middle}, + {"Manual", QPrinter::Manual}, + {"Envelope", QPrinter::Envelope}, + {"EnvelopeManual", QPrinter::EnvelopeManual}, + {"Auto", QPrinter::Auto}, + {"Tractor", QPrinter::Tractor}, + {"SmallFormat", QPrinter::SmallFormat}, + {"LargeFormat", QPrinter::LargeFormat}, + {"LargeCapacity", QPrinter::LargeCapacity}, + {"Cassette", QPrinter::Cassette}, + {"FormSource", QPrinter::FormSource}, + {"DuplexLongSide", QPrinter::DuplexLongSide}, + {"DuplexShortSide", QPrinter::DuplexShortSide}, +}; + +const FlagData colorModeComboData[] = +{ + {"GrayScale", QPrinter::GrayScale}, + {"Color", QPrinter::Color}, +}; + +const FlagData unitsComboData[] = +{ + {"Millimeter", QPageLayout::Millimeter}, + {"Inch", QPageLayout::Inch}, + {"Point", QPageLayout::Point}, + {"Pica", QPageLayout::Pica}, + {"Didot", QPageLayout::Didot}, + {"Cicero", QPageLayout::Cicero}, +}; + +const FlagData orientationComboData[] = +{ + {"Portrait", QPageLayout::Portrait}, + {"Landscape", QPageLayout::Landscape}, +}; + +const FlagData layoutModeComboData[] = +{ + {"StandardMode", QPageLayout::StandardMode}, + {"FullPageMode", QPageLayout::FullPageMode}, +}; const FlagData printDialogOptions[] = { @@ -123,14 +190,6 @@ const FlagData printDialogOptions[] = {"PrintCurrentPage", QPrintDialog::PrintCurrentPage} }; -const FlagData printRangeOptions[] = -{ - {"AllPages", QPrintDialog::AllPages}, - {"Selection", QPrintDialog::Selection}, - {"PageRange", QPrintDialog::PageRange}, - {"CurrentPage", QPrintDialog::CurrentPage} -}; - QTextStream &operator<<(QTextStream &s, const QSizeF &size) { s << size.width() << 'x' << size.height(); @@ -261,8 +320,12 @@ public slots: }; PrintDialogPanel::PrintDialogPanel(QWidget *parent) - : QWidget(parent) + : QWidget(parent), m_blockSignals(true) { +#if QT_VERSION < 0x050300 + m_printerLayout.setOutputFormat(QPrinter::PdfFormat); +#endif + m_panel.setupUi(this); // Setup the Create box @@ -270,22 +333,55 @@ PrintDialogPanel::PrintDialogPanel(QWidget *parent) connect(m_panel.m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter())); connect(m_panel.m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter())); - // Setup the Settings box + // Setup the Page Layout box + populateCombo(m_panel.m_unitsCombo, unitsComboData, sizeof(unitsComboData)/sizeof(FlagData)); + connect(m_panel.m_unitsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged())); +#if QT_VERSION >= 0x050300 + for (int i = QPageSize::A4; i < QPageSize::LastPageSize; ++i) { + QPageSize::PageSizeId id = QPageSize::PageSizeId(i); + m_panel.m_pageSizeCombo->addItem(QPageSize::name(id), QVariant(id)); + } +#else populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData)); - connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl())); +#endif + connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged())); + connect(m_panel.m_pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged())); + connect(m_panel.m_pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged())); populateCombo(m_panel.m_orientationCombo, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData)); + connect(m_panel.m_orientationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(orientationChanged())); + connect(m_panel.m_leftMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged())); + connect(m_panel.m_topMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged())); + connect(m_panel.m_rightMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged())); + connect(m_panel.m_bottomMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged())); + populateCombo(m_panel.m_layoutModeCombo, layoutModeComboData, sizeof(layoutModeComboData)/sizeof(FlagData)); + connect(m_panel.m_layoutModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutModeChanged())); + + // Setup the Print Job box + m_panel.m_printerCombo->addItem(tr("Print to PDF"), QVariant("PdfFormat")); +#if QT_VERSION >= 0x050300 + foreach (const QString &name, QPrinterInfo::availablePrinterNames()) + m_panel.m_printerCombo->addItem(name, QVariant(name)); +#else + foreach (const QPrinterInfo &printer, QPrinterInfo::availablePrinters()) + m_panel.m_printerCombo->addItem(printer.printerName(), QVariant(printer.printerName())); +#endif + connect(m_panel.m_printerCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(printerChanged())); + populateCombo(m_panel.m_printRangeCombo, printRangeComboData, sizeof(printRangeComboData)/sizeof(FlagData)); + populateCombo(m_panel.m_pageOrderCombo, pageOrderComboData, sizeof(pageOrderComboData)/sizeof(FlagData)); + populateCombo(m_panel.m_duplexModeCombo, duplexModeComboData, sizeof(duplexModeComboData)/sizeof(FlagData)); + populateCombo(m_panel.m_paperSourceCombo, paperSourceComboData, sizeof(paperSourceComboData)/sizeof(FlagData)); + populateCombo(m_panel.m_colorModeCombo, colorModeComboData, sizeof(colorModeComboData)/sizeof(FlagData)); // Setup the Dialogs box m_panel.m_dialogOptionsGroupBox->populateOptions(printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData)); - populateCombo(m_panel.m_printDialogRangeCombo, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData)); QPrintDialog dialog; m_panel.m_dialogOptionsGroupBox->setValue(dialog.options()); - m_panel.m_printDialogRangeCombo->setCurrentIndex(dialog.printRange()); connect(m_panel.m_printButton, SIGNAL(clicked()), this, SLOT(showPrintDialog())); connect(m_panel.m_printPreviewButton, SIGNAL(clicked()), this, SLOT(showPreviewDialog())); connect(m_panel.m_pageSetupButton, SIGNAL(clicked()), this, SLOT(showPageSetupDialog())); enablePanels(); + m_blockSignals = false; } PrintDialogPanel::~PrintDialogPanel() @@ -298,7 +394,8 @@ void PrintDialogPanel::enablePanels() m_panel.m_createButton->setEnabled(!exists); m_panel.m_printerModeCombo->setEnabled(!exists); m_panel.m_deleteButton->setEnabled(exists); - m_panel.m_settingsGroupBox->setEnabled(exists); + m_panel.m_pageLayoutGroupBox->setEnabled(exists); + m_panel.m_printJobGroupBox->setEnabled(exists); m_panel.m_dialogsGroupBox->setEnabled(exists); } @@ -308,7 +405,6 @@ void PrintDialogPanel::createPrinter() m_printer.reset(new QPrinter(mode)); // Can set only once. retrieveSettings(m_printer.data()); enablePanels(); - enableCustomSizeControl(); } void PrintDialogPanel::deletePrinter() @@ -317,41 +413,249 @@ void PrintDialogPanel::deletePrinter() enablePanels(); } -QSizeF PrintDialogPanel::pageSize() const +QSizeF PrintDialogPanel::customPageSize() const { return QSizeF(m_panel.m_pageWidth->value(), m_panel.m_pageHeight->value()); } -void PrintDialogPanel::setPageSize(const QSizeF &sizef) +// Apply the settings to the QPrinter +void PrintDialogPanel::applySettings(QPrinter *printer) const +{ + QString printerName = m_panel.m_printerCombo->currentData().toString(); + if (printerName == QStringLiteral("PdfFormat")) + printer->setOutputFileName(m_panel.m_fileName->text()); + else + printer->setPrinterName(printerName); + printer->setPrintRange(comboBoxValue(m_panel.m_printRangeCombo)); + printer->setFromTo(m_panel.m_fromPage->value(), m_panel.m_toPage->value()); + printer->setPageOrder(comboBoxValue(m_panel.m_pageOrderCombo)); + printer->setCopyCount(m_panel.m_copyCount->value()); + printer->setCollateCopies(m_panel.m_collateCopies->isChecked()); + printer->setDuplex(comboBoxValue(m_panel.m_duplexModeCombo)); + printer->setPaperSource(comboBoxValue(m_panel.m_paperSourceCombo)); + printer->setColorMode(comboBoxValue(m_panel.m_colorModeCombo)); + printer->setResolution(m_panel.m_resolution->value()); + +#if QT_VERSION >= 0x050300 + printer->setPageLayout(m_pageLayout); +#else + if (m_printerLayout.pageSize() == QPrinter::Custom) + printer->setPaperSize(customPageSize(), m_units); + else + printer->setPageSize(m_printerLayout.pageSize()); + printer->setOrientation(m_printerLayout.orientation()); + printer->setFullPage(m_printerLayout.fullPage()); + double left, top, right, bottom; + m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units); + printer->setPageMargins(left, top, right, bottom, m_units); +#endif +} + +// Retrieve the settings from the QPrinter +void PrintDialogPanel::retrieveSettings(const QPrinter *printer) { + if (printer->outputFormat() == QPrinter::NativeFormat) { + m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(printer->printerName()))); + m_panel.m_fileName->setEnabled(false); + } else { + m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(QStringLiteral("PdfFormat")))); + m_panel.m_fileName->setEnabled(true); + } + m_panel.m_fileName->setText(printer->outputFileName()); + setComboBoxValue(m_panel.m_printRangeCombo, printer->printRange()); + m_panel.m_fromPage->setValue(printer->fromPage()); + m_panel.m_toPage->setValue(printer->toPage()); + setComboBoxValue(m_panel.m_pageOrderCombo, printer->pageOrder()); + m_panel.m_copyCount->setValue(printer->copyCount()); + m_panel.m_collateCopies->setChecked(printer->collateCopies()); + setComboBoxValue(m_panel.m_duplexModeCombo, printer->duplex()); + setComboBoxValue(m_panel.m_paperSourceCombo, printer->paperSource()); + setComboBoxValue(m_panel.m_colorModeCombo, printer->colorMode()); + m_panel.m_resolution->setValue(printer->resolution()); + +#if QT_VERSION >= 0x050300 + m_pageLayout = printer->pageLayout(); +#else + if (printer->pageSize() == QPrinter::Custom) + m_printerLayout.setPaperSize(customPageSize(), m_units); + else + m_printerLayout.setPageSize(printer->pageSize()); + m_printerLayout.setOrientation(printer->orientation()); + m_printerLayout.setFullPage(printer->fullPage()); + double left, top, right, bottom; + printer->getPageMargins(&left, &top, &right, &bottom, m_units); + m_printerLayout.setPageMargins(left, top, right, bottom, m_units); +#endif + updatePageLayoutWidgets(); +} + +void PrintDialogPanel::updatePageLayoutWidgets() +{ + m_blockSignals = true; +#if QT_VERSION >= 0x050300 + setComboBoxValue(m_panel.m_unitsCombo, m_pageLayout.units()); + setComboBoxValue(m_panel.m_pageSizeCombo, m_pageLayout.pageSize().id()); + QSizeF sizef = m_pageLayout.pageSize().size(QPageSize::Unit(m_pageLayout.units())); + bool custom = (m_pageLayout.pageSize().id() == QPageSize::Custom); + setComboBoxValue(m_panel.m_orientationCombo, m_pageLayout.orientation()); + m_panel.m_leftMargin->setValue(m_pageLayout.margins().left()); + m_panel.m_topMargin->setValue(m_pageLayout.margins().top()); + m_panel.m_rightMargin->setValue(m_pageLayout.margins().right()); + m_panel.m_bottomMargin->setValue(m_pageLayout.margins().bottom()); + setComboBoxValue(m_panel.m_layoutModeCombo, m_pageLayout.mode()); + QRectF rectf = m_pageLayout.paintRect(); +#else + setComboBoxValue(m_panel.m_unitsCombo, m_units); + setComboBoxValue(m_panel.m_pageSizeCombo, m_printerLayout.pageSize()); + QSizeF sizef = m_printerLayout.paperSize(m_units); + bool custom = (m_printerLayout.pageSize() == QPrinter::Custom); + setComboBoxValue(m_panel.m_orientationCombo, m_printerLayout.orientation()); + double left, top, right, bottom; + m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units); + m_panel.m_leftMargin->setValue(left); + m_panel.m_topMargin->setValue(top); + m_panel.m_rightMargin->setValue(right); + m_panel.m_bottomMargin->setValue(bottom); + if (m_printerLayout.fullPage()) + setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::FullPageMode); + else + setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::StandardMode); + QRectF rectf = m_printerLayout.pageRect(m_units); +#endif m_panel.m_pageWidth->setValue(sizef.width()); m_panel.m_pageHeight->setValue(sizef.height()); + m_panel.m_pageWidth->setEnabled(custom); + m_panel.m_pageHeight->setEnabled(custom); + m_panel.m_rectX->setValue(rectf.x()); + m_panel.m_rectY->setValue(rectf.y()); + m_panel.m_rectWidth->setValue(rectf.width()); + m_panel.m_rectHeight->setValue(rectf.height()); + QString suffix; + switch (comboBoxValue(m_panel.m_unitsCombo)) { + case QPageLayout::Millimeter: + suffix = tr(" mm"); + break; + case QPageLayout::Point: + suffix = tr(" pt"); + break; + case QPageLayout::Inch: + suffix = tr(" in"); + break; + case QPageLayout::Pica: + suffix = tr(" pc"); + break; + case QPageLayout::Didot: + suffix = tr(" DD"); + break; + case QPageLayout::Cicero: + suffix = tr(" CC"); + break; + } + m_panel.m_pageWidth->setSuffix(suffix); + m_panel.m_pageHeight->setSuffix(suffix); + m_panel.m_leftMargin->setSuffix(suffix); + m_panel.m_topMargin->setSuffix(suffix); + m_panel.m_rightMargin->setSuffix(suffix); + m_panel.m_bottomMargin->setSuffix(suffix); + m_panel.m_rectX->setSuffix(suffix); + m_panel.m_rectY->setSuffix(suffix); + m_panel.m_rectWidth->setSuffix(suffix); + m_panel.m_rectHeight->setSuffix(suffix); + m_blockSignals = false; } -void PrintDialogPanel::applySettings(QPrinter *printer) const +void PrintDialogPanel::unitsChanged() { - const QPrinter::PageSize pageSizeId = comboBoxValue(m_panel.m_pageSizeCombo); - if (pageSizeId == QPrinter::Custom) - printer->setPaperSize(pageSize(), QPrinter::Millimeter); + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + m_pageLayout.setUnits(comboBoxValue(m_panel.m_unitsCombo)); +#else + m_units = comboBoxValue(m_panel.m_unitsCombo); +#endif + updatePageLayoutWidgets(); +} + +void PrintDialogPanel::pageSizeChanged() +{ + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + const QPageSize::PageSizeId pageSizeId = comboBoxValue(m_panel.m_pageSizeCombo); + QPageSize pageSize; + if (pageSizeId == QPageSize::Custom) + pageSize = QPageSize(QSizeF(200, 200), QPageSize::Unit(m_pageLayout.units())); + else + pageSize = QPageSize(pageSizeId); + m_pageLayout.setPageSize(pageSize); +#else + const QPrinter::PageSize pageSize = comboBoxValue(m_panel.m_pageSizeCombo); + if (pageSize == QPrinter::Custom) + m_printerLayout.setPaperSize(QSizeF(200, 200), m_units); else - printer->setPageSize(pageSizeId); - printer->setOrientation(comboBoxValue(m_panel.m_orientationCombo)); - printer->setFullPage(m_panel.m_fullPageCheckBox->isChecked()); + m_printerLayout.setPageSize(pageSize); +#endif + updatePageLayoutWidgets(); } -void PrintDialogPanel::retrieveSettings(const QPrinter *printer) +void PrintDialogPanel::pageDimensionsChanged() { - setComboBoxValue(m_panel.m_pageSizeCombo, printer->pageSize()); - setComboBoxValue(m_panel.m_orientationCombo, printer->orientation()); - m_panel.m_fullPageCheckBox->setChecked(printer->fullPage()); - setPageSize(m_printer->paperSize(QPrinter::Millimeter)); + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + m_pageLayout.setPageSize(QPageSize(customPageSize(), QPageSize::Unit(m_pageLayout.units()))); +#else + m_printerLayout.setPaperSize(customPageSize(), m_units); +#endif + updatePageLayoutWidgets(); } -void PrintDialogPanel::enableCustomSizeControl() +void PrintDialogPanel::orientationChanged() { - bool custom = (m_panel.m_pageSizeCombo->currentIndex() == QPrinter::Custom); - m_panel.m_pageWidth->setEnabled(custom); - m_panel.m_pageHeight->setEnabled(custom); + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + m_pageLayout.setOrientation(comboBoxValue(m_panel.m_orientationCombo)); +#else + m_printerLayout.setOrientation(comboBoxValue(m_panel.m_orientationCombo)); +#endif + updatePageLayoutWidgets(); +} + +void PrintDialogPanel::marginsChanged() +{ + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + m_pageLayout.setMargins(QMarginsF(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(), + m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value())); +#else + m_printerLayout.setPageMargins(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(), + m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value(), + m_units); +#endif + updatePageLayoutWidgets(); +} + +void PrintDialogPanel::layoutModeChanged() +{ + if (m_blockSignals) + return; +#if QT_VERSION >= 0x050300 + m_pageLayout.setMode(comboBoxValue(m_panel.m_layoutModeCombo)); +#else + bool fullPage = (comboBoxValue(m_panel.m_layoutModeCombo) == QPageLayout::FullPageMode); + m_printerLayout.setFullPage(fullPage); +#endif + updatePageLayoutWidgets(); +} + +void PrintDialogPanel::printerChanged() +{ + bool isPdf = (m_panel.m_printerCombo->currentData().toString() == QStringLiteral("PdfFormat")); + m_panel.m_fileName->setEnabled(isPdf); + if (isPdf && m_panel.m_fileName->text().isEmpty()) + m_panel.m_fileName->setText(QDir::homePath() + QDir::separator() + QStringLiteral("print.pdf")); } void PrintDialogPanel::showPrintDialog() @@ -359,7 +663,6 @@ void PrintDialogPanel::showPrintDialog() applySettings(m_printer.data()); QPrintDialog dialog(m_printer.data(), this); dialog.setOptions(m_panel.m_dialogOptionsGroupBox->value()); - dialog.setPrintRange(comboBoxValue(m_panel.m_printDialogRangeCombo)); if (dialog.exec() == QDialog::Accepted) { retrieveSettings(m_printer.data()); print(m_printer.data()); diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h index a7ae257cf8..3932cd174f 100644 --- a/tests/manual/dialogs/printdialogpanel.h +++ b/tests/manual/dialogs/printdialogpanel.h @@ -46,6 +46,10 @@ #include "ui_printdialogpanel.h" +#if QT_VERSION >= 0x050300 +#include +#endif +#include #include QT_BEGIN_NAMESPACE @@ -59,6 +63,31 @@ QT_END_NAMESPACE class PageSizeControl; class OptionsControl; +#if QT_VERSION < 0x050300 +// Copied from class QPageLayout introduced in Qt 5.3 +namespace QPageLayout +{ + enum Unit { + Millimeter, + Point, + Inch, + Pica, + Didot, + Cicero + }; + + enum Orientation { + Portrait, + Landscape + }; + + enum Mode { + StandardMode, // Paint Rect includes margins + FullPageMode // Paint Rect excludes margins + }; +} +#endif + class PrintDialogPanel : public QWidget { Q_OBJECT @@ -72,17 +101,30 @@ private slots: void showPrintDialog(); void showPreviewDialog(); void showPageSetupDialog(); - void enableCustomSizeControl(); + void unitsChanged(); + void pageSizeChanged(); + void pageDimensionsChanged(); + void orientationChanged(); + void marginsChanged(); + void layoutModeChanged(); + void printerChanged(); private: - QSizeF pageSize() const; - void setPageSize(const QSizeF &sizef); + QSizeF customPageSize() const; void applySettings(QPrinter *printer) const; void retrieveSettings(const QPrinter *printer); + void updatePageLayoutWidgets(); void enablePanels(); + bool m_blockSignals; Ui::PrintDialogPanel m_panel; +#if QT_VERSION >= 0x050300 + QPageLayout m_pageLayout; +#else + QPrinter m_printerLayout; + QPrinter::Unit m_units; +#endif QScopedPointer m_printer; }; diff --git a/tests/manual/dialogs/printdialogpanel.ui b/tests/manual/dialogs/printdialogpanel.ui index a185629fc1..733d52ad9e 100644 --- a/tests/manual/dialogs/printdialogpanel.ui +++ b/tests/manual/dialogs/printdialogpanel.ui @@ -6,8 +6,8 @@ 0 0 - 507 - 291 + 650 + 707 @@ -79,7 +79,7 @@ - + 0 @@ -87,20 +87,30 @@ - Settings + Page Layout + + + Units: + + + + + + + Page Size: - + - + @@ -150,30 +160,430 @@ - + Orientation: - + - + + + + Margins: + + + + + + + + + 1000.000000000000000 + + + + + + + l + + + + + + + 1000.000000000000000 + + + + + + + t + + + + + + + 1000.000000000000000 + + + + + + + r + + + + + + + 1000.000000000000000 + + + + + + + b + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - Full Page Mode: + Layout Mode: + + + + + + + + + + Paint Rect: + + + + + + + + + false + + + QAbstractSpinBox::NoButtons + + + mm + + + 1000.000000000000000 + + + + + + + x + + + + + + + false + + + QAbstractSpinBox::NoButtons + + + 1000.000000000000000 + + + + + + + y + + + + + + + false + + + QAbstractSpinBox::NoButtons + + + 1000.000000000000000 + + + + + + + w + + + + + + + false + + + QAbstractSpinBox::NoButtons + + + 1000.000000000000000 + + + + + + + h + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + Print Job + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Printer: + + + + + + + + + + File Name: + + + + + + + + + + Print Range: + + + + + + + + + + Page Range: - + + + + + 0 + + + 100 + + + 0 + + + + + + + to + + + + + + + 0 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + - + Copies: + + + + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Collate Copies + + + + + + + + + Duplex Mode: + + + + + + + + + + Paper Source: + + + + + + + + + + Color Mode: + + + + + + + + + + Resolution: + + + + + + + + + 1 + + + 5000 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Page Order: + + + + + + @@ -213,9 +623,6 @@ - - - -- cgit v1.2.3 From 742ef8fa79e896e72213cea2411181148cd90ef1 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 23 Mar 2014 22:42:10 +0100 Subject: Implement DownloadLocation retrieving using SHGetKnownFolderPath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch implements the TODO concerning the retrieval of DownloadLocation using SHGetKnownFolderPath [ChangeLog][QtCore][Windows] Now QStandardPaths::DownloadLocation returns the proper path for Windows Vista and up Task-number: QTBUG-35194 Change-Id: Ifc7686e23de76dbfd7826a75e4bf99aa5b9268b0 Reviewed-by: Jan Arve Sæther --- src/corelib/io/qstandardpaths_win.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index a0344a0206..62da5ea245 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -49,6 +49,10 @@ #include #endif +#if !defined(Q_OS_WINCE) +const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } }; +#endif + #include #include #if !defined(Q_OS_WINCE) @@ -68,6 +72,10 @@ QT_BEGIN_NAMESPACE +#if !defined(Q_OS_WINCE) +typedef HRESULT (WINAPI *GetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, LPWSTR*); +#endif + static QString convertCharArray(const wchar_t *path) { return QDir::fromNativeSeparators(QString::fromWCharArray(path)); @@ -77,6 +85,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) { QString result; +#if !defined(Q_OS_WINCE) + static GetKnownFolderPath SHGetKnownFolderPath = (GetKnownFolderPath)QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"); +#endif + wchar_t path[MAX_PATH]; switch (type) { @@ -107,7 +119,18 @@ QString QStandardPaths::writableLocation(StandardLocation type) result = convertCharArray(path); break; - case DownloadLocation: // TODO implement with SHGetKnownFolderPath(FOLDERID_Downloads) (starting from Vista) + case DownloadLocation: +#if !defined(Q_OS_WINCE) + if (SHGetKnownFolderPath) { + LPWSTR path; + if (SHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, 0, 0, &path) == S_OK) { + result = convertCharArray(path); + CoTaskMemFree(path); + } + break; + } +#endif + // fall through case DocumentsLocation: if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE)) result = convertCharArray(path); -- cgit v1.2.3 From d1778a26a3abab9a6656a49c01dcb12f0e692e85 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 21 Mar 2014 15:08:39 +0200 Subject: [HarfBuzz-NG] Optimize Unicode de-/composition callbacks Use QStringIterator instead of QString::toUcs4() and escape earlier. Change-Id: If80b886bece1a43af7078e8cdc9c31babf602731 Reviewed-by: Lars Knoll --- src/gui/text/qharfbuzzng.cpp | 59 +++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 1258ea9a78..b0bade83ee 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -264,16 +264,12 @@ _hb_qt_unicode_compose(hb_unicode_funcs_t * /*ufuncs*/, // ### optimize QString s = QString::fromUcs4(&a, 1) + QString::fromUcs4(&b, 1); QString normalized = s.normalized(QString::NormalizationForm_C); - if (normalized.isEmpty()) - return false; - QVector ucs4str = normalized.toUcs4(); - if (ucs4str.size() == 1) { - *ab = ucs4str.at(0); - return true; - } + QStringIterator it(normalized); + Q_ASSERT(it.hasNext()); // size>0 + *ab = it.next(); - return false; + return !it.hasNext(); // size==1 } static hb_bool_t @@ -287,29 +283,28 @@ _hb_qt_unicode_decompose(hb_unicode_funcs_t * /*ufuncs*/, return false; QString normalized = QChar::decomposition(ab); - Q_ASSERT(!normalized.isEmpty()); + if (normalized.isEmpty()) + return false; - const QVector ucs4str = normalized.toUcs4(); - Q_ASSERT(ucs4str.size() <= HB_UNICODE_MAX_DECOMPOSITION_LEN); + QStringIterator it(normalized); + Q_ASSERT(it.hasNext()); // size>0 + *a = it.next(); - if (ucs4str.size() == 1) { - *a = ucs4str.at(0); + if (!it.hasNext()) { // size==1 *b = 0; return *a != ab; } - if (ucs4str.size() == 2) { - *a = ucs4str.at(0); - *b = ucs4str.at(1); - + // size>1 + *b = it.next(); + if (!it.hasNext()) { // size==2 // Here's the ugly part: if ab decomposes to a single character and // that character decomposes again, we have to detect that and undo // the second part :-( - QString recomposed = normalized.normalized(QString::NormalizationForm_C); - if (recomposed.isEmpty() || recomposed == normalized) - return false; - - hb_codepoint_t c = recomposed.toUcs4().at(0); + const QString recomposed = normalized.normalized(QString::NormalizationForm_C); + QStringIterator jt(recomposed); + Q_ASSERT(jt.hasNext()); // size>0 + const hb_codepoint_t c = jt.next(); if (c != *a && c != ab) { *a = c; *b = 0; @@ -317,17 +312,18 @@ _hb_qt_unicode_decompose(hb_unicode_funcs_t * /*ufuncs*/, return true; } + // size>2 // If decomposed to more than two characters, take the last one, // and recompose the rest to get the first component - *b = ucs4str.last(); - normalized.chop(1); - QString recomposed = normalized.normalized(QString::NormalizationForm_C); - if (recomposed.isEmpty() || recomposed == normalized) - return false; - + do { + *b = it.next(); + } while (it.hasNext()); + normalized.chop(QChar::requiresSurrogates(*b) ? 2 : 1); + const QString recomposed = normalized.normalized(QString::NormalizationForm_C); + QStringIterator jt(recomposed); + Q_ASSERT(jt.hasNext()); // size>0 // We expect that recomposed has exactly one character now - *a = recomposed.toUcs4().at(0); - + *a = jt.next(); return true; } @@ -337,9 +333,6 @@ _hb_qt_unicode_decompose_compatibility(hb_unicode_funcs_t * /*ufuncs*/, hb_codepoint_t *decomposed, void * /*user_data*/) { - if (QChar::decompositionTag(u) == QChar::NoDecomposition) // !NFKD - return 0; - const QString normalized = QChar::decomposition(u); uint outlen = 0; -- cgit v1.2.3 From 6cf7c3212fd8ed55b2bf18d6b87d1ef2bd543431 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 21 Mar 2014 19:30:12 +0200 Subject: Set default activity launchMode to singleInstance This attriute is needed otherwise if the user puts the application in background and uses the appication icon to bring it back in front, andriod will create a new activity. Task-number: QTBUG-37186 Change-Id: Icdc87239c1a07a3e555296692a4866eb6351348e Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/java/AndroidManifest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/android/java/AndroidManifest.xml b/src/android/java/AndroidManifest.xml index 3209ab58ac..1741101bc1 100644 --- a/src/android/java/AndroidManifest.xml +++ b/src/android/java/AndroidManifest.xml @@ -4,7 +4,8 @@ + android:screenOrientation="unspecified" + android:launchMode="singleInstance"> -- cgit v1.2.3 From 63de1350c2a926a9941ee1b72a73c84b08cb0fdb Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 24 Mar 2014 10:07:46 +0100 Subject: winphone: deploy default font files as DirectWrite is not supported For Visual Studio we can add the fonts we want to deploy to the project file by using the DEPLOYMENT variable. Change-Id: Ifc87a12a2bb4ec4ff1c0a8dc8f0b1fbf37e4e513 Reviewed-by: Andrew Knight --- mkspecs/features/winrt/font_deployment.prf | 60 ++++++++++++++++++++++++++++++ mkspecs/winphone-arm-msvc2012/qmake.conf | 1 + mkspecs/winphone-x86-msvc2012/qmake.conf | 1 + 3 files changed, 62 insertions(+) create mode 100644 mkspecs/features/winrt/font_deployment.prf diff --git a/mkspecs/features/winrt/font_deployment.prf b/mkspecs/features/winrt/font_deployment.prf new file mode 100644 index 0000000000..36db5b7cac --- /dev/null +++ b/mkspecs/features/winrt/font_deployment.prf @@ -0,0 +1,60 @@ +# Provide default fonts for windows phone +# The DEFAULTFONTS variable indicates, whether the default set of fonts is +# used for deployment. The check below won't work after the fonts are added +# so this helper variable is added and used for the user warning check later. +!defined(FONTS, var):winphone { + FONTS = \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSans.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSans-Bold.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSans-BoldOblique.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSansMono.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSansMono-Bold.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSansMono-BoldOblique.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSansMono-Oblique.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSans-Oblique.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSerif.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSerif-Bold.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSerif-BoldOblique.ttf \ + $$[QT_HOST_PREFIX/src]/lib/fonts/DejaVuSerif-Oblique.ttf + DEFAULTFONTS = +} + +if(build_pass:equals(TEMPLATE, "app"))| \ +if(!build_pass:equals(TEMPLATE, "vcapp")) { + defined(DEFAULTFONTS, var) { + message(Default fonts will automatically be deployed with your application. \ + To avoid automatic deployment unset the \"FONTS\" variable (\"FONTS =\") in your .pro file. \ + You can also customize which fonts are deployed by setting the \"FONTS\" variable.) + } + + contains(TEMPLATE, "vc.*") { + BUILD_DIR = $$OUT_PWD + } else { + load(resolve_target) + BUILD_DIR = $$dirname(QMAKE_RESOLVED_TARGET) + } + + for (FONT, FONTS) { + font_$${FONT}.input = $$FONT + font_$${FONT}.output = $$BUILD_DIR/fonts/$$basename(FONT) + font_$${FONT}.CONFIG = verbatim + QMAKE_SUBSTITUTES += font_$${FONT} + } + + !isEmpty(FONTS):equals(TEMPLATE, "app") { + fonts.files = $$BUILD_DIR/fonts/* + isEmpty($$target.path) { + fonts.path = $$OUT_PWD/fonts + } else { + fonts.path = $$target.path/fonts + } + + INSTALLS += fonts + } +} + +!isEmpty(FONTS):winphone:equals(TEMPLATE, "vcapp"):build_pass { + fonts.files = $$OUT_PWD/fonts/* + fonts.path = fonts + DEPLOYMENT += fonts +} diff --git a/mkspecs/winphone-arm-msvc2012/qmake.conf b/mkspecs/winphone-arm-msvc2012/qmake.conf index 72961c320d..ce95fdf0b9 100644 --- a/mkspecs/winphone-arm-msvc2012/qmake.conf +++ b/mkspecs/winphone-arm-msvc2012/qmake.conf @@ -7,6 +7,7 @@ include(../common/winrt_winphone/qmake.conf) QMAKE_COMPILER_DEFINES += _MSC_VER=1700 QMAKE_PLATFORM = winphone $$QMAKE_PLATFORM +CONFIG += font_deployment DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP ARM __ARM__ __arm__ QMAKE_LFLAGS += /MACHINE:ARM diff --git a/mkspecs/winphone-x86-msvc2012/qmake.conf b/mkspecs/winphone-x86-msvc2012/qmake.conf index f7838d187a..ff3d714bc5 100644 --- a/mkspecs/winphone-x86-msvc2012/qmake.conf +++ b/mkspecs/winphone-x86-msvc2012/qmake.conf @@ -7,6 +7,7 @@ include(../common/winrt_winphone/qmake.conf) QMAKE_COMPILER_DEFINES += _MSC_VER=1700 QMAKE_PLATFORM = winphone $$QMAKE_PLATFORM +CONFIG += font_deployment DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP X86 __X86__ __x86__ QMAKE_LFLAGS += /MACHINE:X86 -- cgit v1.2.3 From 305907ecfaa8452f9ffc46791088b60b3d620180 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 24 Mar 2014 10:16:28 +0100 Subject: WinPhone: Install DejaVu ttf fonts into Qt As these fonts are deployed as part of the package for WinPhone projects by default they have to be installed in order to be available in the packages. Change-Id: Iaaca7b7db0525f06d3e1716d5a337550ffb1dea9 Reviewed-by: Andrew Knight --- src/plugins/platforms/winrt/winrt.pro | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 306bbc8174..60c87bb61a 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -1,6 +1,15 @@ TARGET = qwinrt CONFIG -= precompile_header +# For Windows Phone 8 we have to deploy fonts together with the application as DirectWrite +# is not supported here. +# TODO: Add a condition/remove this block if Windows Phone 8.1 supports DirectWrite +winphone { + fonts.path = $$[QT_INSTALL_LIBS]/fonts + fonts.files = $$QT_SOURCE_TREE/lib/fonts/DejaVu*.ttf + INSTALLS += fonts +} + PLUGIN_TYPE = platforms PLUGIN_CLASS_NAME = QWinRTIntegrationPlugin load(qt_plugin) -- cgit v1.2.3 From ce8271ce051677a90e975db3a3b82b1e9c7261eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 18 Mar 2014 10:05:57 +0100 Subject: Remove useless Q_NO_DECLARED_NOT_DEFINED flag The flag is used only in qstring.h and gives no real value. Task-number: QTBUG-37437 Change-Id: I7513b56af208a5edee8452b8bbcb9b128e25133d Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/tools/qstring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index cf0726d831..2d9a42957e 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -711,7 +711,7 @@ public: Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {} private: -#if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED) +#if defined(QT_NO_CAST_FROM_ASCII) QString &operator+=(const char *s); QString &operator+=(const QByteArray &s); QString(const char *ch); -- cgit v1.2.3 From a6bf169479df40f489fed549c893958f2519010e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 21 Mar 2014 14:31:23 +0100 Subject: OSX: make reported window state consistent with reality You can't always get what you want: if you exit from fullscreen mode via showNormal, it might actually be maximized; or if you exit via showMaximized, it might actually be normal, if that's the mode the NSWindow remembers. We can't set the state, we can only toggle it. But now at least it's predictable, so that if you call showNormal or showMaximized twice, you will definitely get back to that state. Task-number: QTBUG-35166 Change-Id: I7422960a64f624920566c25763f5c3b03a684fb5 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 26 +++++++++++++++++++++----- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 6e1f00eebe..34ec142d90 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -252,6 +252,7 @@ public: // for QNSView QList m_childWindows; Qt::WindowFlags m_windowFlags; + bool m_effectivelyMaximized; Qt::WindowState m_synchedWindowState; Qt::WindowModality m_windowModality; QPointer m_activePopupWindow; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c7fba4eef0..f25aea67fa 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -352,6 +352,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_contentViewIsToBeEmbedded(false) , m_parentCocoaWindow(0) , m_isNSWindowChild(false) + , m_effectivelyMaximized(false) , m_synchedWindowState(Qt::WindowActive) , m_windowModality(Qt::NonModal) , m_windowUnderMouse(false) @@ -1436,7 +1437,6 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState) { if (!m_nsWindow) return; - // if content view width or height is 0 then the window animations will crash so // do nothing except set the new state NSRect contentRect = [contentView() frame]; @@ -1446,9 +1446,7 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState) return; } - if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized)) { - [m_nsWindow performZoom : m_nsWindow]; // toggles - } + Qt::WindowState predictedState = newState; if ((m_synchedWindowState & Qt::WindowMinimized) != (newState & Qt::WindowMinimized)) { if (newState & Qt::WindowMinimized) { @@ -1458,12 +1456,26 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState) } } + if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized) || (m_effectivelyMaximized && newState == Qt::WindowNoState)) { + if ((m_synchedWindowState & Qt::WindowFullScreen) == (newState & Qt::WindowFullScreen)) { + [m_nsWindow performZoom : m_nsWindow]; // toggles + m_effectivelyMaximized = !m_effectivelyMaximized; + } else if (!(newState & Qt::WindowMaximized)) { + // it would be nice to change the target geometry that toggleFullScreen will animate toward + // but there is no known way, so the maximized state is not possible at this time + predictedState = static_cast(static_cast(newState) | Qt::WindowMaximized); + m_effectivelyMaximized = true; + } + } + if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) { bool fakeFullScreen = true; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { if (window()->flags() & Qt::WindowFullscreenButtonHint) { fakeFullScreen = false; + if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen) + predictedState = Qt::WindowMaximized; [m_nsWindow toggleFullScreen : m_nsWindow]; } } @@ -1490,8 +1502,12 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState) } } +#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG + qDebug() << "QCocoaWindow::syncWindowState" << newState << "actual" << predictedState << "was" << m_synchedWindowState << "effectively maximized" << m_effectivelyMaximized; +#endif + // New state is now the current synched state - m_synchedWindowState = newState; + m_synchedWindowState = predictedState; } bool QCocoaWindow::setWindowModified(bool modified) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 47081ab890..1197aa9148 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -281,6 +281,12 @@ static QTouchDevice *touchDevice = 0; - (void)notifyWindowStateChanged:(Qt::WindowState)newState { + // If the window was maximized, then fullscreen, then tried to go directly to "normal" state, + // this notification will say that it is "normal", but it will still look maximized, and + // if you called performZoom it would actually take it back to "normal". + // So we should say that it is maximized because it actually is. + if (newState == Qt::WindowNoState && m_platformWindow->m_effectivelyMaximized) + newState = Qt::WindowMaximized; QWindowSystemInterface::handleWindowStateChanged(m_window, newState); // We want to read the window state back from the window, // but the event we just sent may be asynchronous. @@ -346,6 +352,8 @@ static QTouchDevice *touchDevice = 0; - (void)notifyWindowWillZoom:(BOOL)willZoom { Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState; + if (!willZoom) + m_platformWindow->m_effectivelyMaximized = false; [self notifyWindowStateChanged:newState]; } -- cgit v1.2.3 From f65a0b6e3f4bee40dcabcb65e5fdd7d7eb9dd87f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 15:08:57 +0100 Subject: Update evdevtouch readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed/updated some out of date information. Change-Id: Iec2105f15c83f04dafbed15a9600e3de0e03f0de Reviewed-by: Jørgen Lind Reviewed-by: Shawn Rutledge --- src/plugins/generic/evdevtouch/README | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/plugins/generic/evdevtouch/README b/src/plugins/generic/evdevtouch/README index 833b511fd8..e5c9aff0af 100644 --- a/src/plugins/generic/evdevtouch/README +++ b/src/plugins/generic/evdevtouch/README @@ -1,20 +1,17 @@ Generic plug-in for evdev multiple touch (ABS_MT) events. Supports protocol type A & B. Type B is supported both directly and via libmtdev. -Single-touch devices reporting ABS_X and Y only are not supported -by this plugin. Use tslib or evdevmouse instead. - The protocol type will be detected automatically. libmtdev is automatically detected based on library availability. To disable it, pass -no-mtdev to configure. -Tested with the following kernel drivers: - bcm5974 (type A) - hid_magicmouse (type A with ABS_MT_TRACKING_ID) (type B over libmtdev) - wacom (type B) +Single-touch devices reporting ABS_X and Y are supported too. Keep in +mind however that the libudev-based device discovery may not be able +to recognize such devices. If mouse events are sufficient, it may be +better to use evdevmouse or tslib with such devices. -To use this "driver", pass -plugin EvdevTouch on the command line. +To use this plugin, pass -plugin EvdevTouch on the command line. If automatic detection does not work, use -plugin EvdevTouch:/dev/input/eventN to explicitly set the device file -- cgit v1.2.3 From 895fa0de79b40345d5abefe7514527dfd585cbe1 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 25 Mar 2014 12:46:15 +0100 Subject: Fix grammar in QFontInfo::styleName() doc. Change-Id: I673ecc8931f4824dc4fb923056354cfd2e119e40 Reviewed-by: Jerome Pasion --- src/gui/text/qfont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 2e21a81187..a8b3aabf19 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2395,7 +2395,7 @@ QString QFontInfo::family() const \since 4.8 Returns the style name of the matched window system font on - system that supports it. + systems that support it. \sa QFont::styleName() */ -- cgit v1.2.3 From dd1220651c50b0bacceab618df8fdf3a7f26a0ab Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 18:42:19 +0100 Subject: eglfs: Avoid double surfaceFormatFor() calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hooks' surfaceFormatFor() function is called twice on the format when creating platform contexts, once from the integration and once from the constructor. This is potentially dangerous. Do it only once. Change-Id: I58eadce01b8f2183abe116f88b1ee9f2b47c003d Reviewed-by: Jørgen Lind --- src/plugins/platforms/eglfs/qeglfscontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 9083abc562..4d443b91e3 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -53,8 +53,8 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display) - : QEGLPlatformContext(QEglFSHooks::hooks()->surfaceFormatFor(format), share, display, - QEglFSIntegration::chooseConfig(display, QEglFSHooks::hooks()->surfaceFormatFor(format))) + : QEGLPlatformContext(format, share, display, + QEglFSIntegration::chooseConfig(display, format)) { } -- cgit v1.2.3 From ebcb5c176fa3552960f3b96c2fcbd7aaa2b29e50 Mon Sep 17 00:00:00 2001 From: Kalle Viironen Date: Wed, 26 Feb 2014 16:16:34 +0200 Subject: Externalize license key handling from configure Enterprise only license key handling removed from configure. This does not affect the functionality of the Open Source version nor the enterprise version. Change-Id: I01736eba3066c56b6e50e022fae8de6aa9bd884b Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- configure | 312 ++------------------------------------- tools/configure/configureapp.cpp | 38 ++--- tools/configure/configureapp.h | 1 - tools/configure/tools.cpp | 189 ++++-------------------- tools/configure/tools.h | 6 +- 5 files changed, 56 insertions(+), 490 deletions(-) diff --git a/configure b/configure index 96273193a6..52588c39d2 100755 --- a/configure +++ b/configure @@ -2766,203 +2766,25 @@ if [ "$COMMERCIAL_USER" = "ask" ]; then done fi -CFG_RTOS_ENABLED=yes -EditionString=Commercial if [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" ]; then # Commercial preview release Licensee="Preview" Edition="Preview" - LicenseType="Technology Preview" + EditionString="Technology Preview" elif [ $COMMERCIAL_USER = "yes" ]; then - # one of commercial editions - - # read in the license file - [ -z "$LICENSE_FILE" ] && LICENSE_FILE="$QT_LICENSE_FILE" - [ -z "$LICENSE_FILE" ] && LICENSE_FILE="$HOME/.qt-license" - if [ -f "$LICENSE_FILE" ]; then - tr -d '\r' <"$LICENSE_FILE" >"${LICENSE_FILE}.tmp" - diff "${LICENSE_FILE}.tmp" "${LICENSE_FILE}" >/dev/null 2>&1 || LICENSE_FILE="${LICENSE_FILE}.tmp" - . "$LICENSE_FILE" >/dev/null 2>&1 - if [ -z "$LicenseKeyExt" ]; then - echo - echo "You are using an old license file." - echo - echo "Please install the license file supplied by Digia," - echo "or install the Qt Open Source Edition if you intend to" - echo "develop free software." - exit 1 - fi - if [ -z "$Licensee" ]; then - echo - echo "Invalid license key. Please check the license key." + if test -x "$relpath/bin/licheck"; then + LicheckOutput=`$relpath/bin/licheck $relpath $outpath $PLATFORM $XPLATFORM` + if [ $? -ne 0 ]; then exit 1 + else + eval "$LicheckOutput" fi else - if [ -z "$LicenseKeyExt" ]; then - echo - echo $ECHO_N "Please enter your license key: $ECHO_C" - read LicenseKeyExt - Licensee="Unknown user" - fi - fi - - # Key verification - echo "$LicenseKeyExt" | grep ".....*-....*-....*-....*-.....*-.....*-...." >/dev/null 2>&1 \ - && LicenseValid="yes" \ - || LicenseValid="no" - if [ "$LicenseValid" != "yes" ]; then echo - echo "Invalid license key. Please check the license key." - exit 1 - fi - ProductCode=`echo $LicenseKeyExt | cut -f 1 -d - | cut -b 1` - PlatformCode=`echo $LicenseKeyExt | cut -f 2 -d -` - LicenseTypeCode=`echo $LicenseKeyExt | cut -f 3 -d -` - LicenseFeatureCode=`echo $LicenseKeyExt | cut -f 4 -d - | cut -b 1` - - # determine which edition we are licensed to use - case "$LicenseTypeCode" in - F4M) - LicenseType="Commercial" - case $ProductCode in - F) - Edition="Universal" - ;; - B) - Edition="FullFramework" - EditionString="Full Framework" - ;; - L) - Edition="GUIFramework" - EditionString="GUI Framework" - ;; - esac - ;; - Z4M|R4M|Q4M) - LicenseType="Evaluation" - QMakeVar add DEFINES QT_EVAL - case $ProductCode in - B) - Edition="Evaluation" - ;; - esac - ;; - esac - if [ -z "$LicenseType" -o -z "$Edition" ]; then - echo - echo "Invalid license key. Please check the license key." - exit 1 - fi - - # verify that we are licensed to use Qt on this platform - LICENSE_EXTENSION= - case "$PlatformCode" in - *L) - CFG_RTOS_ENABLED=yes - PlatformCode=`echo "$PlatformCode" | sed 'h;y/8NPQRTZ/UCWX9M7/;x;G;s/\(.\)....\(.\)./\1\2/'` - ;; - *) - CFG_RTOS_ENABLED=no - PlatformCode=`echo "$PlatformCode" | sed 's/.$//'` - ;; - esac - ### EMBEDDED_QPA logic missing ### - case "$PlatformCode,$XPLATFORM_MAC" in - X9,* | XC,* | XU,* | XW,* | XM,*) - # Qt All-OS - LICENSE_EXTENSION="-ALLOS" - ;; - 8M,* | KM,* | S9,* | SC,* | SM,* | SU,* | SW,* | X9,* | XC,* | XU,* | XW,*) - # Qt for Embedded Linux - LICENSE_EXTENSION="-EMBEDDED" - ;; - 6M,* | N7,* | N9,* | NX,*) - # Embedded no-deploy - LICENSE_EXTENSION="-EMBEDDED" - ;; - FM,* | LM,yes | ZM,no) - # Desktop - LICENSE_EXTENSION="-DESKTOP" - ;; - *) - Platform=Linux/X11 - [ "$XPLATFORM_MAC" = "yes" ] && Platform='Mac OS X' - echo - echo "You are not licensed for the $Platform platform." - echo - echo "Please use the contact form at http://qt.digia.com/contact-us" - echo "to upgrade your license to include the $Platform platform, or install" - echo "the Qt Open Source Edition if you intend to develop free software." - exit 1 - ;; - esac - - if test -r "$relpath/.LICENSE"; then - # Generic, non-final license - LICENSE_EXTENSION="" - line=`sed 'y/a-z/A-Z/;q' "$relpath"/.LICENSE` - case "$line" in - *BETA*) - Edition=Beta - ;; - *TECHNOLOGY?PREVIEW*) - Edition=Preview - ;; - *EVALUATION*) - Edition=Evaluation - ;; - *) - echo >&2 "Invalid license files; cannot continue" - exit 1 - ;; - esac - Licensee="$Edition" - EditionString="$Edition" - fi - - case "$LicenseFeatureCode" in - B|G|L|Y) - # US - case "$LicenseType" in - Commercial) - cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}-US" "$outpath/LICENSE" - ;; - Evaluation) - cp -f "$relpath/.LICENSE-EVALUATION-US" "$outpath/LICENSE" - ;; - esac - ;; - 2|4|5|F) - # non-US - case "$LicenseType" in - Commercial) - cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}" "$outpath/LICENSE" - ;; - Evaluation) - cp -f "$relpath/.LICENSE-EVALUATION" "$outpath/LICENSE" - ;; - esac - ;; - *) - echo - echo "Invalid license key. Please check the license key." - exit 1 - ;; - esac - case "$LicenseFeatureCode" in - 4|B|F|Y) - CFG_RTOS_ENABLED=yes - ;; - 2|5|G|L) - CFG_RTOS_ENABLED=no - ;; - esac - if [ '!' -f "$outpath/LICENSE" ]; then - echo "The LICENSE, LICENSE.GPL LICENSE.LGPL file shipped with" - echo "this software has disappeared." - echo - echo "Sorry, you are not licensed to use this software." - echo "Try re-installing." + echo "Error: This is the Open Source version of Qt." + echo "If you want to use Enterprise features of Qt," + echo "use the contact form at http://qt.digia.com/contact-us" + echo "to purchase a license." echo exit 1 fi @@ -2972,22 +2794,11 @@ elif [ $COMMERCIAL_USER = "no" ]; then Edition="OpenSource" EditionString="Open Source" fi -echo -echo "This is the Qt ${EditionString} Edition." -echo -if [ "$CFG_RTOS_ENABLED" = "no" ]; then - case `basename "$XPLATFORM"` in - qnx-* | vxworks-*) - echo "" - echo "You are not licensed for Qt for `basename $XPLATFORM`." - echo "" - echo "Please use the contact form at http://qt.digia.com/contact-us" - echo "to upgrade your license to include this platform, or install" - echo "the Qt Open Source Edition if you intend to develop free software." - exit 1 - ;; - esac +if [ "$Edition" = "OpenSource" ] || [ "$Edition" = "Preview" ]; then + echo + echo "This is the Qt ${EditionString} Edition." + echo fi if [ "$Edition" = "OpenSource" ]; then @@ -3003,7 +2814,7 @@ if [ "$Edition" = "OpenSource" ]; then fi echo if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then - echo "You have already accepted the terms of the $LicenseType license." + echo "You have already accepted the terms of the $EditionString license." acceptance=yes else if [ -f "$relpath/LICENSE.GPL" ]; then @@ -3034,7 +2845,7 @@ elif [ "$Edition" = "Preview" ]; then while true; do if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then - echo "You have already accepted the terms of the $LicenseType license." + echo "You have already accepted the terms of the $EditionString license." acceptance=yes else echo "You are licensed to use this software under the terms of" @@ -3058,77 +2869,6 @@ elif [ "$Edition" = "Preview" ]; then more "$relpath/LICENSE.PREVIEW.COMMERCIAL" fi done -elif [ "$Edition" != "OpenSource" ]; then - if [ -n "$ExpiryDate" ]; then - ExpiryDate=`echo $ExpiryDate | sed -e 's,-,,g' | tr -d '\n\r'` - [ -z "$ExpiryDate" ] && ExpiryDate="0" - Today=`date +%Y%m%d` - if [ "$Today" -gt "$ExpiryDate" ]; then - case "$LicenseType" in - Commercial|Academic|Educational) - echo - echo "WARNING WARNING WARNING WARNING" - echo - echo " Your support and upgrade period has expired." - echo - echo " You may continue to use your last licensed release" - echo " of Qt under the terms of your existing license" - echo " agreement. But you are not entitled to technical" - echo " support, nor are you entitled to use any more recent" - echo " Qt releases." - echo - echo " Please use the contact form at http://qt.digia.com/contact-us" - echo " to renew your support and upgrades for this license." - echo - echo "WARNING WARNING WARNING WARNING" - echo - sleep 3 - ;; - Evaluation|*) - echo - echo "NOTICE NOTICE NOTICE NOTICE" - echo - echo " Your Evaluation license has expired." - echo - echo " You are no longer licensed to use this software. Please" - echo " use the contact form at http://qt.digia.com/contact-us to" - echo " purchase license, or install the Qt Open Source Edition" - echo " if you intend to develop free software." - echo - echo "NOTICE NOTICE NOTICE NOTICE" - echo - exit 1 - ;; - esac - fi - fi - TheLicense=`head -n 1 "$outpath/LICENSE"` - while true; do - if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then - echo "You have already accepted the terms of the $TheLicense." - acceptance=yes - else - echo "You are licensed to use this software under the terms of" - echo "the $TheLicense." - echo - echo "Type '?' to view the $TheLicense." - echo "Type 'yes' to accept this license offer." - echo "Type 'no' to decline this license offer." - echo - echo $ECHO_N "Do you accept the terms of the $TheLicense? $ECHO_C" - read acceptance - fi - echo - if [ "$acceptance" = "yes" ]; then - break - elif [ "$acceptance" = "no" ]; then - echo "You are not licensed to use this software." - echo - exit 1 - else [ "$acceptance" = "?" ] - more "$outpath/LICENSE" - fi - done fi #------------------------------------------------------------------------------- @@ -3851,22 +3591,6 @@ else chmod -w "$outpath/src/corelib/global/qconfig.cpp" fi -# ----------------------------------------------------------------------------- -if [ "$LicenseType" = "Evaluation" ]; then - EVALKEY=qt_qevalkey=$LicenseKeyExt -elif echo "$DEFINES" | grep QT_EVAL >/dev/null 2>&1; then - EVALKEY=qt_qevalkey= -fi - -if [ -n "$EVALKEY" ]; then - rm -f "$outpath/src/corelib/global/qconfig_eval.cpp" - cat > "$outpath/src/corelib/global/qconfig_eval.cpp" <>"$outpath/src/corelib/global/qconfig.h.new" <>"$outpath/src/corelib/global/qconfig.h.new" [ '!' -z "$LicenseKeyExt" ] && echo "#define QT_PRODUCT_LICENSEKEY \"$LicenseKeyExt\"" >>"$outpath/src/corelib/global/qconfig.h.new" diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index fddf99d2da..9cebe6682b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3388,7 +3388,7 @@ void Configure::generateConfigfiles() << endl; } tmpStream << "/* License information */" << endl; - tmpStream << "#define QT_PRODUCT_LICENSEE \"" << licenseInfo[ "LICENSEE" ] << "\"" << endl; + tmpStream << "#define QT_PRODUCT_LICENSEE \"" << dictionary[ "LICENSEE" ] << "\"" << endl; tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl; tmpStream << endl; if (dictionary["BUILDDEV"] == "yes") { @@ -3508,16 +3508,6 @@ void Configure::generateConfigfiles() dictionary[ "DONE" ] = "error"; } - if (dictionary["EDITION"] == "Evaluation" || qmakeDefines.contains("QT_EVAL")) { - FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig_eval.cpp"); - - tmpStream << "/* Evaluation license key */" << endl - << "static const volatile char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl; - - if (!tmpStream.flush()) - dictionary[ "DONE" ] = "error"; - } - } void Configure::displayConfig() @@ -3542,10 +3532,10 @@ void Configure::displayConfig() sout << " PATH=\n " << env << endl; if (dictionary[QStringLiteral("EDITION")] != QStringLiteral("OpenSource")) { - QString l1 = licenseInfo[ "LICENSEE" ]; - QString l2 = licenseInfo[ "LICENSEID" ]; + QString l1 = dictionary[ "LICENSEE" ]; + QString l2 = dictionary[ "LICENSEID" ]; QString l3 = dictionary["EDITION"] + ' ' + "Edition"; - QString l4 = licenseInfo[ "EXPIRYDATE" ]; + QString l4 = dictionary[ "EXPIRYDATE" ]; sout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl; sout << "License ID.................." << (l2.isNull() ? "" : l2) << endl; sout << "Product license............." << (l3.isNull() ? "" : l3) << endl; @@ -3877,7 +3867,7 @@ void Configure::generateQConfigCpp() { FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.cpp"); tmpStream << "/* Licensed */" << endl - << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << licenseInfo["LICENSEE"] << "\";" << endl + << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << dictionary["LICENSEE"] << "\";" << endl << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl << endl << "/* Build date */" << endl @@ -4302,7 +4292,7 @@ void Configure::readLicense() } if (hasOpenSource && openSource) { cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl; - licenseInfo["LICENSEE"] = "Open Source"; + dictionary["LICENSEE"] = "Open Source"; dictionary["EDITION"] = "OpenSource"; cout << endl; if (!showLicense(dictionary["LICENSE FILE"])) { @@ -4316,20 +4306,14 @@ void Configure::readLicense() } #ifdef COMMERCIAL_VERSION else { - Tools::checkLicense(dictionary, licenseInfo, firstLicensePath(), sourcePath); - if (dictionary["DONE"] != "error") { - // give the user some feedback, and prompt for license acceptance - cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " " << dictionary["EDITION"] << " Edition."<< endl << endl; - if (!showLicense(dictionary["LICENSE FILE"])) { - cout << "Configuration aborted since license was not accepted"; - dictionary["DONE"] = "error"; - return; - } - } + Tools::checkLicense(dictionary, sourcePath, buildPath); } #else // !COMMERCIAL_VERSION else { - cout << endl << "Cannot build commercial edition from the open source version of the library." << endl; + cout << endl << "Error: This is the Open Source version of Qt." + << endl << "If you want to use Enterprise features of Qt," + << endl << "use the contact form at http://qt.digia.com/contact-us" + << endl << "to purchase a license." << endl << endl; dictionary["DONE"] = "error"; } #endif diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index 36668f18ba..e8de10dcf7 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -147,7 +147,6 @@ private: QString sybase; QString sybaseLibs; - QMap licenseInfo; QString outputLine; QTextStream outStream; diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index 07c3c82a0b..e2a6f3cc8a 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -40,191 +40,56 @@ ****************************************************************************/ #include "tools.h" +#include "environment.h" #include #include #include +#include - -// std stuff ------------------------------------ #include -#include -#include -#define NUMBER_OF_PARTS 7 -std::ostream &operator<<(std::ostream &s, const QString &val); // defined in configureapp.cpp +std::ostream &operator<<(std::ostream &s, const QString &val); using namespace std; -void Tools::checkLicense(QMap &dictionary, QMap &licenseInfo, - const QString &path, const QString &sourcePath) +void Tools::checkLicense(QMap &dictionary, + const QString &sourcePath, const QString &buildPath) { - QString tpLicense = sourcePath + "/LICENSE.PREVIEW.OPENSOURCE"; - if (QFile::exists(tpLicense)) { - dictionary["EDITION"] = "Preview"; - dictionary["LICENSE FILE"] = tpLicense; - return; // No license key checking in Tech Preview - } - tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; + QString tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; if (QFile::exists(tpLicense)) { dictionary["EDITION"] = "Preview"; dictionary["LICENSE FILE"] = tpLicense; - return; // No license key checking in Tech Preview - } - - // Read in the license file - QFile licenseFile(path); - if( !path.isEmpty() && licenseFile.open( QFile::ReadOnly ) ) { - cout << "Reading license file in....." << qPrintable(path) << endl; - - QString buffer = licenseFile.readLine(1024); - while (!buffer.isEmpty()) { - if( buffer[ 0 ] != '#' ) { - QStringList components = buffer.split( '=' ); - if ( components.size() >= 2 ) { - QStringList::Iterator it = components.begin(); - QString key = (*it++).trimmed().remove('"').toUpper(); - QString value = (*it++).trimmed().remove('"'); - licenseInfo[ key ] = value; - } - } - // read next line - buffer = licenseFile.readLine(1024); - } - licenseFile.close(); - } else { - cout << "License file not found in " << QDir::homePath() << endl; - cout << "Please put the Qt license file, '.qt-license' in your home " - << "directory and run configure again."; - dictionary["DONE"] = "error"; - return; - } - - // Verify license info... - QString licenseKey = licenseInfo["LICENSEKEYEXT"]; - QByteArray clicenseKey = licenseKey.toLatin1(); - //We check the license - static const char * const SEP = "-"; - char *licenseParts[NUMBER_OF_PARTS]; - int partNumber = 0; - for (char *part = strtok(clicenseKey.data(), SEP); part != 0; part = strtok(0, SEP)) - licenseParts[partNumber++] = part; - if (partNumber < (NUMBER_OF_PARTS-1)) { - dictionary["DONE"] = "error"; - cout << "License file does not contain proper license key." < -#include #include - class Tools { public: - static void checkLicense(QMap &dictionary, QMap &licenseInfo, - const QString &path, const QString &sourcePath); + static void checkLicense(QMap &dictionary, + const QString &sourcePath, const QString &buildPath); }; #endif // _TOOLS_H_ -- cgit v1.2.3 From dc685cf6331f5fb46285cf10d6464c2ecf41f73e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 20:09:11 +0100 Subject: eglfs: Print the chosen config in debug mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit q_printEglConfig has been left unused. Start using it again, in case QT_QPA_EGLFS_DEBUG is set. This will, similarly to QSG_INFO, help debugging, especially on embedded devices. Change-Id: I1448632ed055dd71e98259f042d3cac64620a4ce Reviewed-by: Jørgen Lind --- src/platformsupport/eglconvenience/qeglconvenience.cpp | 4 +--- src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 7cf1f88b02..f014ae42e5 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -446,11 +446,9 @@ void q_printEglConfig(EGLDisplay display, EGLConfig config) for (index = 0; attrs[index].attr != -1; ++index) { EGLint value; if (eglGetConfigAttrib(display, config, attrs[index].attr, &value)) { - qWarning("\t%s: %d\n", attrs[index].name, (int)value); + qDebug("\t%s: %d", attrs[index].name, (int)value); } } - - qWarning("\n"); } #ifdef Q_OS_LINUX diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 9c3b9b539c..0dcb9f68bb 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -44,6 +44,7 @@ #include "qeglpbuffer_p.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -191,6 +192,12 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont return; } + static const bool printConfig = qgetenv("QT_QPA_EGLFS_DEBUG").toInt(); + if (printConfig) { + qDebug() << "Created context for format" << format << "with config:"; + q_printEglConfig(m_eglDisplay, m_eglConfig); + } + #ifndef QT_NO_OPENGL // Make the context current to ensure the GL version query works. This needs a surface too. const EGLint pbufferAttributes[] = { -- cgit v1.2.3 From 11a6270079657e40ff57d47be1eef6cb09a40d23 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 20:03:22 +0100 Subject: eglfs: Add a way to force 24/32 bit configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some embedded devices do not play nicely with 16-bit (565) EGL configurations, resulting in ugly banding in Quick apps. Add a QT_QPA_EGLFS_FORCE888 environment variable that can be set on systems where it is known that only 24 or 32 bit configs provide acceptable results. Change-Id: I7b8d7b9a2cd40b51a844d0795b7156b735e18ebb Reviewed-by: Jørgen Lind --- src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index dfb766db32..4aa3f29260 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -141,7 +141,16 @@ QImage::Format QEglFSHooks::screenFormat() const QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const { - return inputFormat; + QSurfaceFormat format = inputFormat; + + static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt(); + if (force888) { + format.setRedBufferSize(8); + format.setGreenBufferSize(8); + format.setBlueBufferSize(8); + } + + return format; } bool QEglFSHooks::filterConfig(EGLDisplay, EGLConfig) const -- cgit v1.2.3 From e7ad615cca2f4ae5383f1772b7c2845d59c4d68a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 19:58:58 +0100 Subject: Remove unused ifdef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QEGL_DEBUG defines have been removed some time ago from eglfs and eglconvenience, except for this one. It is also inconvenient due to the OpenGL dependency of it. Quick apps can anyway get the same information with QSG_INFO=1. Change-Id: Ie25c5286234a10699652d618d6f4174c6d3238e2 Reviewed-by: Jørgen Lind --- .../eglconvenience/qeglplatformcontext.cpp | 32 ++++------------------ 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 0dcb9f68bb..eec6463c21 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -268,37 +268,15 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) return true; } - bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); - if (!ok) - qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); -#ifdef QEGL_EXTRA_DEBUG - static bool showDebug = true; - if (showDebug) { - showDebug = false; - const char *str = (const char*)glGetString(GL_VENDOR); - qWarning("Vendor %s\n", str); - str = (const char*)glGetString(GL_RENDERER); - qWarning("Renderer %s\n", str); - str = (const char*)glGetString(GL_VERSION); - qWarning("Version %s\n", str); - - str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - qWarning("Extensions %s\n",str); - - str = (const char*)glGetString(GL_EXTENSIONS); - qWarning("Extensions %s\n", str); - - } -#endif - + const bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); if (ok) { if (!m_swapIntervalEnvChecked) { m_swapIntervalEnvChecked = true; if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) { QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); - bool ok; - const int swapInterval = swapIntervalString.toInt(&ok); - if (ok) + bool intervalOk; + const int swapInterval = swapIntervalString.toInt(&intervalOk); + if (intervalOk) m_swapIntervalFromEnv = swapInterval; } } @@ -309,6 +287,8 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) m_swapInterval = requestedSwapInterval; eglSwapInterval(eglDisplay(), m_swapInterval); } + } else { + qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); } return ok; -- cgit v1.2.3 From f254474d71fb6e11f721e57214940c289a387c8e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 19:55:29 +0100 Subject: egl: Remove commented code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix also the statement about buffer size handling. Change-Id: I94e93fa4df7fee9b789ecca33d8722fbfc86ccc5 Reviewed-by: Jørgen Lind --- src/platformsupport/eglconvenience/qeglconvenience.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index f014ae42e5..e6624fb9ff 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -82,16 +82,7 @@ QVector q_createConfigAttributesFromFormat(const QSurfaceFormat &format) // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that // if the application sets the red/green/blue size to 5/6/5 on the QSurfaceFormat, - // they will probably get a 32-bit config, even when there's an RGB565 config available. - -// // Now normalize the values so -1 becomes 0 -// redSize = redSize > 0 ? redSize : 0; -// greenSize = greenSize > 0 ? greenSize : 0; -// blueSize = blueSize > 0 ? blueSize : 0; -// alphaSize = alphaSize > 0 ? alphaSize : 0; -// depthSize = depthSize > 0 ? depthSize : 0; -// stencilSize = stencilSize > 0 ? stencilSize : 0; -// sampleCount = sampleCount > 0 ? sampleCount : 0; + // they might still get a 32-bit config, even when there's an RGB565 config available. QVector configAttributes; -- cgit v1.2.3 From 15be1e8c069b6b7b846d3e16f6a814c4a52e4165 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Mar 2014 14:20:25 +0100 Subject: Fix up warnings in linuxfb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the warning about the graphics mode switch. In some environments it just pollutes the output since it will always fail. Change the errno-based warnings to qErrnoWarning. Change-Id: Ib7a7bfe64eda29996db288e52d369dcfad76c096 Reviewed-by: Friedemann Kleint Reviewed-by: Jørgen Lind --- src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index aca8d76041..72d5833e73 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -360,7 +360,7 @@ bool QLinuxFbScreen::initialize() // Open the device mFbFd = openFramebufferDevice(fbDevice); if (mFbFd == -1) { - qWarning("Failed to open framebuffer %s : %s", qPrintable(fbDevice), strerror(errno)); + qErrnoWarning(errno, "Failed to open framebuffer %s", qPrintable(fbDevice)); return false; } @@ -371,12 +371,12 @@ bool QLinuxFbScreen::initialize() memset(&finfo, 0, sizeof(finfo)); if (ioctl(mFbFd, FBIOGET_FSCREENINFO, &finfo) != 0) { - qWarning("Error reading fixed information: %s", strerror(errno)); + qErrnoWarning(errno, "Error reading fixed information"); return false; } if (ioctl(mFbFd, FBIOGET_VSCREENINFO, &vinfo)) { - qWarning("Error reading variable information: %s", strerror(errno)); + qErrnoWarning(errno, "Error reading variable information"); return false; } @@ -391,7 +391,7 @@ bool QLinuxFbScreen::initialize() mMmap.size = finfo.smem_len; uchar *data = (unsigned char *)mmap(0, mMmap.size, PROT_READ | PROT_WRITE, MAP_SHARED, mFbFd, 0); if ((long)data == -1) { - qWarning("Failed to mmap framebuffer: %s", strerror(errno)); + qErrnoWarning(errno, "Failed to mmap framebuffer"); return false; } @@ -420,10 +420,12 @@ bool QLinuxFbScreen::initialize() mTtyFd = openTtyDevice(ttyDevice); if (mTtyFd == -1) - qWarning() << "Failed to open tty" << strerror(errno); + qErrnoWarning(errno, "Failed to open tty"); - if (doSwitchToGraphicsMode && !switchToGraphicsMode(mTtyFd, &mOldTtyMode)) - qWarning() << "Failed to set graphics mode" << strerror(errno); + if (doSwitchToGraphicsMode) + switchToGraphicsMode(mTtyFd, &mOldTtyMode); + // Do not warn if the switch fails: the ioctl fails when launching from + // a remote console and there is nothing we can do about it. blankScreen(mFbFd, false); -- cgit v1.2.3 From 7f41e56ec3e69569b62e9ee76537a1123fc66bfc Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Sun, 16 Mar 2014 12:38:50 +0200 Subject: WinRT: Prevent GUI dispatcher lookup from non-GUI thread When we create an event dispatcher outside of the main thread, we shouldn't be looking up the core event dispatcher as it will fail. This ends up printing a scary warning for all e.g. Qt Quick apps when in reality nothing bad actually happened. Task-number: QTBUG-35327 Change-Id: I2060f0a9d4baffc42ca727e8d4e1ef7c13f6a2df Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/qeventdispatcher_winrt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index 56f4ac40de..1d4b57642c 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,11 @@ QEventDispatcherWinRT::QEventDispatcherWinRT(QObject *parent) : QAbstractEventDispatcher(*new QEventDispatcherWinRTPrivate, parent) { Q_D(QEventDispatcherWinRT); + + // Only look up the event dispatcher in the main thread + if (QThread::currentThread() != QCoreApplicationPrivate::theMainThread) + return; + ComPtr application; HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&application)); -- cgit v1.2.3 From d668f1be22c0e0219c02bcc6928a825ca4f33e42 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 25 Mar 2014 13:12:48 +0100 Subject: Fix regression in minimized state handling WM_STATE and _NET_WM_STATE are not the same. c6e271da6d1d972ad73a97871baafe57578a69a9 introduces a severe regression in this respect, making applications on xcb not to follow window state changes properly. Task-number: QTBUG-37695 Change-Id: Ia058bc11d5aa988eab513939c9f755c2f77512ee Reviewed-by: Martin Klapetek Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index d890398416..bed6eb59dc 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1829,21 +1829,21 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev return; Qt::WindowState newState = Qt::WindowNoState; - if (event->atom == atom(QXcbAtom::_NET_WM_STATE)) { // WM_STATE: Quick check for 'Minimize'. + if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'. const xcb_get_property_cookie_t get_cookie = - xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), - XCB_ATOM_ANY, 0, 1024); + xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), + XCB_ATOM_ANY, 0, 1024); xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), get_cookie, NULL); - if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::_NET_WM_STATE)) { + if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { const quint32 *data = (const quint32 *)xcb_get_property_value(reply); if (reply->length != 0 && XCB_WM_STATE_ICONIC == data[0]) newState = Qt::WindowMinimized; } free(reply); - } // WM_STATE: Quick check for 'Minimize'. + } if (newState != Qt::WindowMinimized) { // Something else changed, get _NET_WM_STATE. const NetWmStates states = netWmStates(); if ((states & NetWmStateMaximizedHorz) && (states & NetWmStateMaximizedVert)) -- cgit v1.2.3 From 0b87f4f6c912a508f170cd25ff5317bb77665fa9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 25 Mar 2014 10:08:05 +0100 Subject: Android: Fix font merging Our fallback fonts would contain a minimal list of hardcoded fallback fonts, which is neither sufficient for displaying all text, nor portable to different vendors which can supply different font sets. [ChangeLog][Android] Fixed font merging problem which caused e.g. missing glyphs for Arabic numerals. Task-number: QTBUG-37738 Change-Id: Ic971343a1cd5610c79a81f6f6152c637937b5626 Reviewed-by: Konstantin Ritt --- src/gui/text/qfontdatabase.cpp | 2 +- .../fontdatabases/basic/qbasicfontdatabase.cpp | 6 +++++- .../fontdatabases/basic/qbasicfontdatabase_p.h | 2 +- .../platforms/android/qandroidplatformfontdatabase.cpp | 18 ++++++++++++++---- .../platforms/android/qandroidplatformfontdatabase.h | 3 +++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ae7b6c1c0d..558258c30e 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -531,7 +531,7 @@ static const int scriptForWritingSystem[] = { Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount); -int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem) +Q_GUI_EXPORT int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem) { return scriptForWritingSystem[writingSystem]; } diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index 88814151b6..26ae0eb724 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -220,7 +220,7 @@ void QBasicFontDatabase::releaseHandle(void *handle) extern FT_Library qt_getFreetype(); -QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) +QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems) { FT_Library library = qt_getFreetype(); @@ -259,6 +259,8 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt if (cm->encoding == FT_ENCODING_ADOBE_CUSTOM || cm->encoding == FT_ENCODING_MS_SYMBOL) { writingSystems.setSupported(QFontDatabase::Symbol); + if (supportedWritingSystems) + supportedWritingSystems->setSupported(QFontDatabase::Symbol); break; } } @@ -277,6 +279,8 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt }; writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange); + if (supportedWritingSystems) + *supportedWritingSystems = writingSystems; if (os2->usWeightClass == 0) ; diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h index 45d7218ece..247a2855e2 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h @@ -64,7 +64,7 @@ public: QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); void releaseHandle(void *handle); - static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file); + static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems = 0); static QString fontNameFromTTFile(const QString &filename); }; diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index 7f68b44ed8..7423e6c55a 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -60,7 +60,17 @@ void QAndroidPlatformFontDatabase::populateFontDatabase() QDir dir(fontpath, QLatin1String("*.ttf")); for (int i = 0; i < int(dir.count()); ++i) { const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); - addTTFile(QByteArray(), file); + + QSupportedWritingSystems supportedWritingSystems; + QStringList families = addTTFile(QByteArray(), file, &supportedWritingSystems); + + extern int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem); + for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { + if (i == QFontDatabase::Any || supportedWritingSystems.supported(QFontDatabase::WritingSystem(i))) { + QChar::Script script = QChar::Script(qt_script_for_writing_system(QFontDatabase::WritingSystem(i))); + m_fallbacks[script] += families; + } + } } } @@ -71,9 +81,9 @@ QStringList QAndroidPlatformFontDatabase::fallbacksForFamily(const QString &fami { Q_UNUSED(family); Q_UNUSED(style); - Q_UNUSED(script); + if (styleHint == QFont::Monospace) - return QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(";"); + return QString(qgetenv("QT_ANDROID_FONTS_MONOSPACE")).split(";") + m_fallbacks[script]; - return QString(qgetenv("QT_ANDROID_FONTS")).split(";"); + return QString(qgetenv("QT_ANDROID_FONTS")).split(";") + m_fallbacks[script]; } diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.h b/src/plugins/platforms/android/qandroidplatformfontdatabase.h index 3cbfe95d36..cdd3cf1674 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.h +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.h @@ -53,6 +53,9 @@ public: QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; + +private: + QHash m_fallbacks; }; #endif // QANDROIDPLATFORMFONTDATABASE_H -- cgit v1.2.3 From a0dc3e608fe67ae1ec3f0ee92e1dc15ebaa0fe9e Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 19 Feb 2014 01:05:32 +0900 Subject: qmake: change a linker option in .pc file from -llibhoge to -lhoge Change-Id: Ib4d01bf190eec753f1b5e37e8e5871514e43ac71 Reviewed-by: Oswald Buddenhagen --- qmake/generators/makefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index fe8d289a7c..bad4eb5456 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -3299,7 +3299,7 @@ MakefileGenerator::writePkgConfigFile() pkgConfiglibName = "-framework " + bundle + " "; } else { pkgConfiglibDir = "-L${libdir}"; - pkgConfiglibName = "-l" + fileInfo(fname).completeBaseName(); + pkgConfiglibName = "-l" + unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); if (project->isActiveConfig("shared")) pkgConfiglibName += project->first("TARGET_VERSION_EXT").toQString(); } -- cgit v1.2.3 From f1f07eae2d40f202a709af33ca1e8d86551c9ace Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Sat, 22 Mar 2014 08:08:08 +0200 Subject: Android: Fix software keyboard show/hide state Task-number: QTBUG-34831 Change-Id: Ic38334d011ceef2dc75e4fb3fcea48f62aeea757 Reviewed-by: Paul Olav Tvete --- .../qtproject/qt5/android/QtActivityDelegate.java | 22 +++++++----- .../qtproject/qt5/android/QtInputConnection.java | 39 ++++------------------ 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index ea8e5cd44c..e62b5dab82 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -120,7 +120,7 @@ public class QtActivityDelegate private boolean m_keyboardIsVisible = false; public boolean m_backKeyPressedSent = false; - + private long m_showHideTimeStamp = System.nanoTime(); public void setFullScreen(boolean enterFullScreen) { @@ -201,12 +201,18 @@ public class QtActivityDelegate private final int ApplicationInactive = 0x2; private final int ApplicationActive = 0x4; - public void setKeyboardVisibility(boolean visibility) + + public boolean setKeyboardVisibility(boolean visibility, long timeStamp) { + if (m_showHideTimeStamp > timeStamp) + return false; + m_showHideTimeStamp = timeStamp; + if (m_keyboardIsVisible == visibility) - return; + return false; m_keyboardIsVisible = visibility; QtNative.keyboardVisibilityChanged(m_keyboardIsVisible); + return true; } public void resetSoftwareKeyboard() { @@ -304,11 +310,11 @@ public class QtActivityDelegate QtNativeInputConnection.updateCursorPosition(); //FALLTHROUGH case InputMethodManager.RESULT_UNCHANGED_SHOWN: - setKeyboardVisibility(true); + setKeyboardVisibility(true, System.nanoTime()); break; case InputMethodManager.RESULT_HIDDEN: case InputMethodManager.RESULT_UNCHANGED_HIDDEN: - setKeyboardVisibility(false); + setKeyboardVisibility(false, System.nanoTime()); break; } } @@ -331,11 +337,11 @@ public class QtActivityDelegate switch (resultCode) { case InputMethodManager.RESULT_SHOWN: case InputMethodManager.RESULT_UNCHANGED_SHOWN: - setKeyboardVisibility(true); + setKeyboardVisibility(true, System.nanoTime()); break; case InputMethodManager.RESULT_HIDDEN: case InputMethodManager.RESULT_UNCHANGED_HIDDEN: - setKeyboardVisibility(false); + setKeyboardVisibility(false, System.nanoTime()); break; } } @@ -827,7 +833,7 @@ public class QtActivityDelegate if (keyCode == KeyEvent.KEYCODE_BACK && !m_backKeyPressedSent) { hideSoftwareKeyboard(); - setKeyboardVisibility(false); + setKeyboardVisibility(false, System.nanoTime()); return true; } diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java index 5e6e227c2b..655ab95dd8 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java @@ -82,18 +82,11 @@ class QtNativeInputConnection } class HideKeyboardRunnable implements Runnable { - private QtInputConnection m_connection; - HideKeyboardRunnable(QtInputConnection connection) - { - m_connection = connection; - } + private long m_hideTimeStamp = System.nanoTime(); @Override public void run() { - if (m_connection.getInputState() == QtInputConnection.InputStates.Hiding) { - QtNative.activityDelegate().setKeyboardVisibility(false); - m_connection.reset(); - } + QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp); } } @@ -107,34 +100,14 @@ public class QtInputConnection extends BaseInputConnection private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod; private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary; - - enum InputStates { Visible, FinishComposing, Hiding }; - private QtEditText m_view = null; - private InputStates m_inputState = InputStates.Visible; - - public void reset() - { - m_inputState = InputStates.Visible; - } - - public InputStates getInputState() - { - return m_inputState; - } private void setClosing(boolean closing) { - if (closing && m_inputState == InputStates.Hiding) - return; - - if (closing && m_view.getActivityDelegate().isSoftwareKeyboardVisible()) { - m_view.postDelayed(new HideKeyboardRunnable(this), 100); - m_inputState = InputStates.Hiding; + if (closing) { + m_view.postDelayed(new HideKeyboardRunnable(), 100); } else { - if (m_inputState == InputStates.Hiding) - QtNative.activityDelegate().setKeyboardVisibility(true); - m_inputState = closing ? InputStates.FinishComposing : InputStates.Visible; + QtNative.activityDelegate().setKeyboardVisibility(true, System.nanoTime()); } } @@ -154,7 +127,7 @@ public class QtInputConnection extends BaseInputConnection @Override public boolean endBatchEdit() { -// setClosing(false); + setClosing(false); return true; } -- cgit v1.2.3 From 12bd35aa24c914046e30a46f650ed2e43c4956b1 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 24 Mar 2014 09:35:52 +0200 Subject: REG: Fix window repaint geometry Task-number: QTBUG-37530 Change-Id: I642c8ef8cf7de50e4a84d8356693b82f8674cece Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/android/qandroidplatformrasterwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformrasterwindow.cpp b/src/plugins/platforms/android/qandroidplatformrasterwindow.cpp index 334b9cdd23..eb5a73c4a3 100644 --- a/src/plugins/platforms/android/qandroidplatformrasterwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformrasterwindow.cpp @@ -57,7 +57,7 @@ void QAndroidPlatformRasterWindow::repaint(const QRegion ®ion) if (QAndroidPlatformWindow::parent()) return; - QRect currentGeometry = geometry().translated(mapToGlobal(QPoint(0,0))); + QRect currentGeometry = geometry(); QRect dirtyClient = region.boundingRect(); QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), @@ -74,7 +74,7 @@ void QAndroidPlatformRasterWindow::repaint(const QRegion ®ion) void QAndroidPlatformRasterWindow::setGeometry(const QRect &rect) { - m_oldGeometry = geometry().translated(mapToGlobal(QPoint(0,0)));; + m_oldGeometry = geometry(); QAndroidPlatformWindow::setGeometry(rect); } -- cgit v1.2.3 From cd08d34452c9dd1a7f69c93b5380bc39cb9a52bb Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 19 Mar 2014 22:37:57 +0800 Subject: QDoc: Doc: Use correct terminology ("signal" vs. "signal handler") Change-Id: I0c6cdc77296b8a1a759671bac2c920bc05d0cbcb Reviewed-by: Jerome Pasion --- src/tools/qdoc/doc/qdoc-manual-topiccmds.qdoc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/tools/qdoc/doc/qdoc-manual-topiccmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-topiccmds.qdoc index 68f3f9652b..b9667b7758 100644 --- a/src/tools/qdoc/doc/qdoc-manual-topiccmds.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-topiccmds.qdoc @@ -1113,27 +1113,24 @@ \section1 \\qmlattachedsignal The \\qmlattachedsignal command is for documenting an attachable - \l{http://qt-project.org/doc/qt-4.7/qdeclarativeintroduction.html#signal-handlers} - {signal handler}. The \\qmlattachedsignal command is used just like - the \l{qmlsignal-command} {\\qmlsignal} command. + \l{Signal and Handler Event System}{signal}. The \\qmlattachedsignal + command is used just like the \l{qmlsignal-command} {\\qmlsignal} command. The argument is the rest of the line. It should be the name of the - QML type where the signal handler is declared, the \c{::} - qualifier, and finally the signal handler name. If we have a QML - attached signal handler named \c onAdd() in the \c GridView - element, the \\qmlattachedsignal for it would look like this: + QML type where the signal is declared, the \c{::} + qualifier, and finally the signal name. For example, a QML + attached signal named \c add() in the \c GridView + element is documented like this: \code / *! - \qmlattachedsignal GridView::onAdd() - This attached handler is called immediately after an item is - added to the view. + \qmlattachedsignal GridView::add() + This attached signal is emitted immediately after an item is added to the view. * / \endcode QDoc includes this documentation on the QML reference page for the - \l{http://qt-project.org/doc/qt-4.7/qml-gridview.html#onAdd-signal} - {GridView} element. + \l GridView element. \target qmlbasictype-command \section1 \\qmlbasictype -- cgit v1.2.3 From 5b00bb39f2f079e4745a0ca6f3a8c56e18bd2775 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 21 Mar 2014 10:35:09 +0100 Subject: Polish tst_qsslsocket a bit. Output the SSL library version, output socket error string on connection failure consistently, silence numerous warnings about QIODevice not being open in tst_QSslSocket::constructing. Change-Id: Ia23d42de5b2daca55b2f6f50af025d61e99c52a0 Reviewed-by: Peter Hartmann --- .../auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 6eb20dd1f5..ded3966992 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -271,6 +271,9 @@ void tst_QSslSocket::initTestCase_data() void tst_QSslSocket::initTestCase() { + qDebug("Using SSL library %s (%ld)", + qPrintable(QSslSocket::sslLibraryVersionString()), + QSslSocket::sslLibraryVersionNumber()); QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); } @@ -347,6 +350,9 @@ void tst_QSslSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthent void tst_QSslSocket::constructing() { + const char readNotOpenMessage[] = "QIODevice::read: device not open"; + const char writeNotOpenMessage[] = "QIODevice::write: device not open"; + if (!QSslSocket::supportsSsl()) return; @@ -363,6 +369,7 @@ void tst_QSslSocket::constructing() QCOMPARE(socket.sslConfiguration(), QSslConfiguration::defaultConfiguration()); QCOMPARE(socket.errorString(), QString("Unknown error")); char c = '\0'; + QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage); QVERIFY(!socket.getChar(&c)); QCOMPARE(c, '\0'); QVERIFY(!socket.isOpen()); @@ -371,11 +378,16 @@ void tst_QSslSocket::constructing() QVERIFY(!socket.isTextModeEnabled()); QVERIFY(!socket.isWritable()); QCOMPARE(socket.openMode(), QIODevice::NotOpen); + QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage); QVERIFY(socket.peek(2).isEmpty()); QCOMPARE(socket.pos(), qint64(0)); + QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage); QVERIFY(!socket.putChar('c')); + QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage); QVERIFY(socket.read(2).isEmpty()); + QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage); QCOMPARE(socket.read(0, 0), qint64(-1)); + QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage); QVERIFY(socket.readAll().isEmpty()); QTest::ignoreMessage(QtWarningMsg, "QIODevice::readLine: Called with maxSize < 2"); QCOMPARE(socket.readLine(0, 0), qint64(-1)); @@ -388,7 +400,9 @@ void tst_QSslSocket::constructing() QCOMPARE(socket.size(), qint64(0)); QVERIFY(!socket.waitForBytesWritten(10)); QVERIFY(!socket.waitForReadyRead(10)); + QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage); QCOMPARE(socket.write(0, 0), qint64(-1)); + QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage); QCOMPARE(socket.write(QByteArray()), qint64(-1)); QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); QVERIFY(!socket.flush()); @@ -672,7 +686,7 @@ void tst_QSslSocket::sessionCipher() connect(socket.data(), SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); QVERIFY(socket->sessionCipher().isNull()); socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */); - QVERIFY(socket->waitForConnected(10000)); + QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY(socket->sessionCipher().isNull()); socket->startClientEncryption(); if (!socket->waitForEncrypted(5000)) @@ -775,7 +789,7 @@ void tst_QSslSocket::peerCertificateChain() socket->connectToHost(QtNetworkSettings::serverName(), 443); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); - QVERIFY2(socket->waitForConnected(10000), "Network timeout"); + QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted(10000)) @@ -1334,7 +1348,7 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); - QVERIFY(socket->waitForConnected(10000)); + QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -1679,7 +1693,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() socket->ignoreSslErrors(); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); socket->ignoreSslErrors(); - QVERIFY(socket->waitForConnected(10*1000)); + QVERIFY2(socket->waitForConnected(10*1000), qPrintable(socket->errorString())); if (setProxy && !socket->waitForEncrypted(10*1000)) QSKIP("Skipping flaky test - See QTBUG-29941"); -- cgit v1.2.3 From 5279134935e858e6fa8565c936b17e88d7bded50 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 21 Jan 2014 10:35:01 +0100 Subject: Reuse one QCollator instance for QString::localeAwareCompare Constructing a QCollator is somewhat expensive, and made localeAwareCompare really slow. As QCollator (at least with the ICU implementation) is not thread safe, use one collator per thread. This speeds up collation of a long list of strings by a factor of 250 for the test case in the bug below. Task-number: QTBUG-36149 Change-Id: I645cdc3546347d1dcc7a03b7563b628c7f756944 Reviewed-by: Thiago Macieira Reviewed-by: Konstantin Ritt --- src/corelib/tools/qstring.cpp | 10 ++++++++-- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a8770e886b..f14cdcedda 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -78,6 +78,7 @@ #include "qchar.cpp" #include "qstringmatcher.cpp" #include "qstringiterator_p.h" +#include "qthreadstorage.h" #ifdef Q_OS_WIN # include @@ -5319,6 +5320,10 @@ int QString::localeAwareCompare(const QString &other) const return localeAwareCompare_helper(constData(), length(), other.constData(), other.length()); } +#if defined(QT_USE_ICU) +Q_GLOBAL_STATIC(QThreadStorage, defaultCollator) +#endif + /*! \internal \since 4.5 @@ -5362,8 +5367,9 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, CFRelease(otherString); return result; #elif defined(QT_USE_ICU) - QCollator collator; - return collator.compare(data1, length1, data2, length2); + if (!defaultCollator()->hasLocalData()) + defaultCollator()->setLocalData(QCollator()); + return defaultCollator()->localData().compare(data1, length1, data2, length2); #elif defined(Q_OS_UNIX) // declared in int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 629a095f9d..5655d9f529 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -4876,10 +4876,8 @@ void tst_QString::localeAwareCompare() DWORD oldLcid = GetUserDefaultLCID(); SetUserDefaultLCID(locale); QCOMPARE(locale, GetUserDefaultLCID()); -#elif defined (Q_OS_MAC) - QSKIP("Setting the locale is not supported on OS X (you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)"); -#elif defined(QT_USE_ICU) - QLocale::setDefault(QLocale(locale)); +#elif defined (Q_OS_MAC) || defined(QT_USE_ICU) + QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)"); #else if (!locale.isEmpty()) { const char *newLocale = setlocale(LC_ALL, locale.toLatin1()); -- cgit v1.2.3 From 071098b08b12fc1af6341ff6d7ba6713e5de1481 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 21 Mar 2014 09:36:05 +0100 Subject: Make QWidget::render() work correctly with all paint devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure QWidget::render takes correct code paths with all kinds of paint devices. Correctly restore the inRenderWithPainter flag. The old code would not correctly restore the flag, likely leading to inconsistencies. Remove the unused last parameter in QWidgetPrivate::render. Remove the special handling for QPrinter in the same method. Task-number: QTBUG-26564 Change-Id: Iba43269b090abd8dd88c5225b75e1ee9239d58f9 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qwidget.cpp | 29 +++++++---------------------- src/widgets/kernel/qwidget_p.h | 2 +- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 102e659fbf..c2f7a9b184 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4677,7 +4677,8 @@ void QWidget::unsetCursor() void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, RenderFlags renderFlags) { - d_func()->render(target, targetOffset, sourceRegion, renderFlags, false); + QPainter p(target); + render(&p, targetOffset, sourceRegion, renderFlags); } /*! @@ -4721,9 +4722,6 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, d->createExtra(); d->extra->inRenderWithPainter = true; -#ifdef Q_WS_MAC - d->render_helper(painter, targetOffset, toBePainted, renderFlags); -#else QPaintEngine *engine = painter->paintEngine(); Q_ASSERT(engine); QPaintEnginePrivate *enginePriv = engine->d_func(); @@ -4734,7 +4732,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, // Render via a pixmap when dealing with non-opaque painters or printers. if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) { d->render_helper(painter, targetOffset, toBePainted, renderFlags); - d->extra->inRenderWithPainter = false; + d->extra->inRenderWithPainter = inRenderWithPainter; return; } @@ -4755,7 +4753,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, enginePriv->setSystemViewport(oldSystemClip); } - render(target, targetOffset, toBePainted, renderFlags); + d->render(target, targetOffset, toBePainted, renderFlags); // Restore system clip, viewport and transform. enginePriv->systemClip = oldSystemClip; @@ -4764,9 +4762,8 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, // Restore shared painter. d->setSharedPainter(oldPainter); -#endif - d->extra->inRenderWithPainter = false; + d->extra->inRenderWithPainter = inRenderWithPainter; } static void sendResizeEvents(QWidget *target) @@ -5204,8 +5201,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, - const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, - bool readyToRender) + const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) { if (!target) { qWarning("QWidget::render: null pointer to paint device"); @@ -5213,7 +5209,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, } const bool inRenderWithPainter = extra && extra->inRenderWithPainter; - QRegion paintRegion = !inRenderWithPainter && !readyToRender + QRegion paintRegion = !inRenderWithPainter ? prepareToRender(sourceRegion, renderFlags) : sourceRegion; if (paintRegion.isEmpty()) @@ -5272,23 +5268,12 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, flags |= DontSetCompositionMode; - if (target->devType() == QInternal::Printer) { - QPainter p(target); - render_helper(&p, targetOffset, paintRegion, renderFlags); - return; - } - -#ifndef Q_WS_MAC // Render via backingstore. drawWidget(target, paintRegion, offset, flags, sharedPainter()); // Restore shared painter. if (oldSharedPainter) setSharedPainter(oldSharedPainter); -#else - // Render via backingstore (no shared painter). - drawWidget(target, paintRegion, offset, flags, 0); -#endif } void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn, diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index bdfc57f7c3..41e36ee6a5 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -389,7 +389,7 @@ public: void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags); void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, - QWidget::RenderFlags renderFlags, bool readyToRender); + QWidget::RenderFlags renderFlags); void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0); -- cgit v1.2.3 From 244e2ef7b9f078faecb9ec6f08c66864eb0ce399 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Wed, 26 Mar 2014 13:22:00 +0200 Subject: WinRT: Use registerFontFamily to reduce font registration overhead Adopt to the new lazy font loading strategy in order to reduce memory and startup time associated with populating the entire font database. Change-Id: I0134cc123f73cb8485fe85c4a6b8e3b3a3a2cab0 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtfontdatabase.cpp | 331 +++++++++++---------- src/plugins/platforms/winrt/qwinrtfontdatabase.h | 3 + 2 files changed, 182 insertions(+), 152 deletions(-) diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp index 3da87de708..70bb9469db 100644 --- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp +++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp @@ -63,7 +63,7 @@ QString QWinRTFontDatabase::fontDir() const fontDirectory = applicationDirPath + QLatin1String("/fonts"); if (!QFile::exists(fontDirectory)) { #ifndef Q_OS_WINPHONE - if (m_fonts.isEmpty()) + if (m_fontFamilies.isEmpty()) #endif qWarning("No fonts directory found in application package."); fontDirectory = applicationDirPath; @@ -78,6 +78,9 @@ QWinRTFontDatabase::~QWinRTFontDatabase() { foreach (IDWriteFontFile *fontFile, m_fonts.keys()) fontFile->Release(); + + foreach (IDWriteFontFamily *fontFamily, m_fontFamilies) + fontFamily->Release(); } QFont QWinRTFontDatabase::defaultFont() const @@ -132,175 +135,196 @@ void QWinRTFontDatabase::populateFontDatabase() } QString familyName = QString::fromWCharArray(familyBuffer.data(), familyNameLength); - int fontCount = fontFamily->GetFontCount(); - for (int j = 0; j < fontCount; ++j) { - ComPtr font; - hr = fontFamily->GetFont(j, &font); - if (FAILED(hr)) { - qWarning("Unable to get base font: %s", qPrintable(qt_error_string(hr))); - continue; - } + m_fontFamilies.insert(familyName, fontFamily.Detach()); - ComPtr baseFontFace; - hr = font->CreateFontFace(&baseFontFace); - if (FAILED(hr)) { - qWarning("Unable to create base font face: %s", qPrintable(qt_error_string(hr))); - continue; - } - ComPtr fontFace; - hr = baseFontFace.As(&fontFace); - if (FAILED(hr)) { - qWarning("Unable to create font face: %s", qPrintable(qt_error_string(hr))); - continue; - } + registerFontFamily(familyName); + } - // Only try to load true-type fonts - DWRITE_FONT_FACE_TYPE type = fontFace->GetType(); - if (!(type == DWRITE_FONT_FACE_TYPE_TRUETYPE - || type == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)) { - continue; - } + QBasicFontDatabase::populateFontDatabase(); +} - // We can't deal with multi-file fonts - quint32 fileCount; - hr = fontFace->GetFiles(&fileCount, NULL); - if (FAILED(hr)) { - qWarning("Unable to get font file count: %s", qPrintable(qt_error_string(hr))); - continue; - } - if (fileCount != 1) // Should not happen as we only look at TT fonts - continue; - - ComPtr informationalStrings; - BOOL exists; - hr = font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_MANUFACTURER, - &informationalStrings, &exists); - if (FAILED(hr)) { - qWarning("Unable to get font foundry: %s", qPrintable(qt_error_string(hr))); - continue; - } - QString foundryName; - if (exists) { - quint32 length; - hr = informationalStrings->GetStringLength(0, &length); +void QWinRTFontDatabase::populateFamily(const QString &familyName) +{ + IDWriteFontFamily *fontFamily = m_fontFamilies.value(familyName); + if (!fontFamily) { + qWarning("The font family %s was not found.", qPrintable(familyName)); + return; + } + + bool fontRegistered = false; + const int fontCount = fontFamily->GetFontCount(); + for (int j = 0; j < fontCount; ++j) { + ComPtr font; + HRESULT hr = fontFamily->GetFont(j, &font); + if (FAILED(hr)) { + qWarning("Unable to get font: %s", qPrintable(qt_error_string(hr))); + continue; + } + + // Skip simulated faces + if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) + continue; + + ComPtr baseFontFace; + hr = font->CreateFontFace(&baseFontFace); + if (FAILED(hr)) { + qWarning("Unable to create base font face: %s", qPrintable(qt_error_string(hr))); + continue; + } + ComPtr fontFace; + hr = baseFontFace.As(&fontFace); + if (FAILED(hr)) { + qWarning("Unable to create font face: %s", qPrintable(qt_error_string(hr))); + continue; + } + + // We can't deal with multi-file fonts + quint32 fileCount; + hr = fontFace->GetFiles(&fileCount, NULL); + if (FAILED(hr)) { + qWarning("Unable to get font file count: %s", qPrintable(qt_error_string(hr))); + continue; + } + if (fileCount != 1) + continue; + + ComPtr informationalStrings; + BOOL exists; + hr = font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_MANUFACTURER, + &informationalStrings, &exists); + if (FAILED(hr)) { + qWarning("Unable to get font foundry: %s", qPrintable(qt_error_string(hr))); + continue; + } + QString foundryName; + if (exists) { + quint32 length; + hr = informationalStrings->GetStringLength(0, &length); + if (FAILED(hr)) + qWarning("Unable to get foundry name length: %s", qPrintable(qt_error_string(hr))); + if (SUCCEEDED(hr)) { + QVector buffer(length + 1); + hr = informationalStrings->GetString(0, buffer.data(), buffer.size()); if (FAILED(hr)) - qWarning("Unable to get foundry name length: %s", qPrintable(qt_error_string(hr))); - if (SUCCEEDED(hr)) { - QVector buffer(length + 1); - hr = informationalStrings->GetString(0, buffer.data(), buffer.size()); - if (FAILED(hr)) - qWarning("Unable to get foundry name: %s", qPrintable(qt_error_string(hr))); - if (SUCCEEDED(hr)) - foundryName = QString::fromWCharArray(buffer.data(), length); - } + qWarning("Unable to get foundry name: %s", qPrintable(qt_error_string(hr))); + if (SUCCEEDED(hr)) + foundryName = QString::fromWCharArray(buffer.data(), length); } + } - QFont::Weight weight; - switch (font->GetWeight()) { - case DWRITE_FONT_WEIGHT_THIN: - case DWRITE_FONT_WEIGHT_EXTRA_LIGHT: - case DWRITE_FONT_WEIGHT_LIGHT: - case DWRITE_FONT_WEIGHT_SEMI_LIGHT: - weight = QFont::Light; - break; - default: - case DWRITE_FONT_WEIGHT_NORMAL: - case DWRITE_FONT_WEIGHT_MEDIUM: - weight = QFont::Normal; - break; - case DWRITE_FONT_WEIGHT_DEMI_BOLD: - weight = QFont::DemiBold; - break; - case DWRITE_FONT_WEIGHT_BOLD: - case DWRITE_FONT_WEIGHT_EXTRA_BOLD: - weight = QFont::Bold; - break; - case DWRITE_FONT_WEIGHT_BLACK: - case DWRITE_FONT_WEIGHT_EXTRA_BLACK: - weight = QFont::Black; - break; - } + QFont::Weight weight; + switch (font->GetWeight()) { + case DWRITE_FONT_WEIGHT_THIN: + case DWRITE_FONT_WEIGHT_EXTRA_LIGHT: + case DWRITE_FONT_WEIGHT_LIGHT: + case DWRITE_FONT_WEIGHT_SEMI_LIGHT: + weight = QFont::Light; + break; + default: + case DWRITE_FONT_WEIGHT_NORMAL: + case DWRITE_FONT_WEIGHT_MEDIUM: + weight = QFont::Normal; + break; + case DWRITE_FONT_WEIGHT_DEMI_BOLD: + weight = QFont::DemiBold; + break; + case DWRITE_FONT_WEIGHT_BOLD: + case DWRITE_FONT_WEIGHT_EXTRA_BOLD: + weight = QFont::Bold; + break; + case DWRITE_FONT_WEIGHT_BLACK: + case DWRITE_FONT_WEIGHT_EXTRA_BLACK: + weight = QFont::Black; + break; + } - QFont::Style style; - switch (font->GetStyle()) { - default: - case DWRITE_FONT_STYLE_NORMAL: - style = QFont::StyleNormal; - break; - case DWRITE_FONT_STYLE_OBLIQUE: - style = QFont::StyleOblique; - break; - case DWRITE_FONT_STYLE_ITALIC: - style = QFont::StyleItalic; - break; - } + QFont::Style style; + switch (font->GetStyle()) { + default: + case DWRITE_FONT_STYLE_NORMAL: + style = QFont::StyleNormal; + break; + case DWRITE_FONT_STYLE_OBLIQUE: + style = QFont::StyleOblique; + break; + case DWRITE_FONT_STYLE_ITALIC: + style = QFont::StyleItalic; + break; + } - QFont::Stretch stretch; - switch (font->GetStretch()) { - default: - case DWRITE_FONT_STRETCH_UNDEFINED: - case DWRITE_FONT_STRETCH_NORMAL: - stretch = QFont::Unstretched; - break; - case DWRITE_FONT_STRETCH_ULTRA_CONDENSED: - stretch = QFont::UltraCondensed; - break; - case DWRITE_FONT_STRETCH_EXTRA_CONDENSED: - stretch = QFont::ExtraCondensed; - break; - case DWRITE_FONT_STRETCH_CONDENSED: - stretch = QFont::Condensed; - break; - case DWRITE_FONT_STRETCH_SEMI_CONDENSED: - stretch = QFont::SemiCondensed; - break; - case DWRITE_FONT_STRETCH_SEMI_EXPANDED: - stretch = QFont::SemiExpanded; - break; - case DWRITE_FONT_STRETCH_EXPANDED: - stretch = QFont::Expanded; - break; - case DWRITE_FONT_STRETCH_EXTRA_EXPANDED: - stretch = QFont::ExtraExpanded; - break; - case DWRITE_FONT_STRETCH_ULTRA_EXPANDED: - stretch = QFont::UltraExpanded; - break; - } + QFont::Stretch stretch; + switch (font->GetStretch()) { + default: + case DWRITE_FONT_STRETCH_UNDEFINED: + case DWRITE_FONT_STRETCH_NORMAL: + stretch = QFont::Unstretched; + break; + case DWRITE_FONT_STRETCH_ULTRA_CONDENSED: + stretch = QFont::UltraCondensed; + break; + case DWRITE_FONT_STRETCH_EXTRA_CONDENSED: + stretch = QFont::ExtraCondensed; + break; + case DWRITE_FONT_STRETCH_CONDENSED: + stretch = QFont::Condensed; + break; + case DWRITE_FONT_STRETCH_SEMI_CONDENSED: + stretch = QFont::SemiCondensed; + break; + case DWRITE_FONT_STRETCH_SEMI_EXPANDED: + stretch = QFont::SemiExpanded; + break; + case DWRITE_FONT_STRETCH_EXPANDED: + stretch = QFont::Expanded; + break; + case DWRITE_FONT_STRETCH_EXTRA_EXPANDED: + stretch = QFont::ExtraExpanded; + break; + case DWRITE_FONT_STRETCH_ULTRA_EXPANDED: + stretch = QFont::UltraExpanded; + break; + } - const bool fixedPitch = fontFace->IsMonospacedFont(); + const bool fixedPitch = fontFace->IsMonospacedFont(); - quint32 unicodeRange[4]; - quint32 actualRangeCount; - hr = fontFace->GetUnicodeRanges( - 2, reinterpret_cast(unicodeRange), &actualRangeCount); - if (FAILED(hr) && hr != E_NOT_SUFFICIENT_BUFFER) { // Ignore insufficient buffer; we only need 4 indices - qWarning("Unable to get font unicode range: %s", qPrintable(qt_error_string(hr))); - continue; - } - quint32 codePageRange[2] = { 0, 0 }; - QSupportedWritingSystems writingSystems = - QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange); - - IDWriteFontFile *fontFile; - hr = fontFace->GetFiles(&fileCount, &fontFile); - if (FAILED(hr)) { - qWarning("Unable to get font file: %s", qPrintable(qt_error_string(hr))); - continue; - } + quint32 unicodeRange[4]; + quint32 actualRangeCount; + hr = fontFace->GetUnicodeRanges( + 2, reinterpret_cast(unicodeRange), &actualRangeCount); + if (FAILED(hr) && hr != E_NOT_SUFFICIENT_BUFFER) { // Ignore insufficient buffer; we only need 4 indices + qWarning("Unable to get font unicode range: %s", qPrintable(qt_error_string(hr))); + continue; + } + quint32 codePageRange[2] = { 0, 0 }; + QSupportedWritingSystems writingSystems = + QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange); - FontDescription description = { fontFace->GetIndex(), QUuid::createUuid().toByteArray() }; - m_fonts.insert(fontFile, description); - registerFont(familyName, QString(), foundryName, weight, style, stretch, - true, true, 0, fixedPitch, writingSystems, fontFile); + IDWriteFontFile *fontFile; + hr = fontFace->GetFiles(&fileCount, &fontFile); + if (FAILED(hr)) { + qWarning("Unable to get font file: %s", qPrintable(qt_error_string(hr))); + continue; } + + FontDescription description = { fontFace->GetIndex(), QUuid::createUuid().toByteArray() }; + m_fonts.insert(fontFile, description); + registerFont(familyName, QString(), foundryName, weight, style, stretch, + true, true, 0, fixedPitch, writingSystems, fontFile); + fontRegistered = true; } - QBasicFontDatabase::populateFontDatabase(); + // Always populate something to avoid an assert + if (!fontRegistered) { + registerFont(familyName, QString(), QString(), QFont::Normal, QFont::StyleNormal, + QFont::Unstretched, false, false, 0, false, QSupportedWritingSystems(), 0); + } } QFontEngine *QWinRTFontDatabase::fontEngine(const QFontDef &fontDef, void *handle) { + if (!handle) // Happens if a font family population failed + return 0; + IDWriteFontFile *fontFile = reinterpret_cast(handle); if (!m_fonts.contains(fontFile)) return QBasicFontDatabase::fontEngine(fontDef, handle); @@ -361,6 +385,9 @@ QFontEngine *QWinRTFontDatabase::fontEngine(const QFontDef &fontDef, void *handl void QWinRTFontDatabase::releaseHandle(void *handle) { + if (!handle) + return; + IDWriteFontFile *fontFile = reinterpret_cast(handle); if (m_fonts.contains(fontFile)) { m_fonts.remove(fontFile); diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/plugins/platforms/winrt/qwinrtfontdatabase.h index 6f194a10cc..b318a95502 100644 --- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h +++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.h @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE #ifndef Q_OS_WINPHONE struct IDWriteFontFile; +struct IDWriteFontFamily; struct FontDescription { @@ -64,10 +65,12 @@ public: ~QWinRTFontDatabase(); QFont defaultFont() const Q_DECL_OVERRIDE; void populateFontDatabase() Q_DECL_OVERRIDE; + void populateFamily(const QString &familyName) Q_DECL_OVERRIDE; QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE; void releaseHandle(void *handle) Q_DECL_OVERRIDE; private: QHash m_fonts; + QHash m_fontFamilies; #endif // !Q_OS_WINPHONE }; -- cgit v1.2.3 From c761d2721a0c4ade17acf43ca0aec774db2b2357 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 25 Mar 2014 21:05:04 +0100 Subject: Doc: Remove empty and duplicated file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This example already exists under examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc Change-Id: If50efa704fb29ed111d6d589ea74cd2575131372 Reviewed-by: Sze Howe Koh Reviewed-by: Topi Reiniö --- examples/dbus/doc/src/remotecontrolledcar.qdoc | 31 -------------------------- 1 file changed, 31 deletions(-) delete mode 100644 examples/dbus/doc/src/remotecontrolledcar.qdoc diff --git a/examples/dbus/doc/src/remotecontrolledcar.qdoc b/examples/dbus/doc/src/remotecontrolledcar.qdoc deleted file mode 100644 index b3b81ebba9..0000000000 --- a/examples/dbus/doc/src/remotecontrolledcar.qdoc +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example remotecontrolledcar - \title D-Bus Remote Controlled Car Example -*/ -- cgit v1.2.3 From 5ee07bf6919dda0c9a192adedc9fc4512b7bba36 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 26 Mar 2014 13:52:09 +0100 Subject: Mark some tests as XFAIL on QNX Extending this to stock QNX as well since it is not BlackBerry 10 specific. - tst_QNumeric::floatDistance() - tst_QNumeric::floatDistance_double() - tst_QtJson::testNumbers_2() - tst_QtJson::toJsonLargeNumericValues() - tst_QtJson::parseNumbers() Task-number: QTBUG-37066 Change-Id: If0e5d4fbefac5e8a0efed8ef8b1b7655ff6e7766 Reviewed-by: Fabian Bumberger --- tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 4 ++-- tests/auto/corelib/json/tst_qtjson.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 79df4b7055..0b4f0e3c4b 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -167,7 +167,7 @@ void tst_QNumeric::floatDistance() QFETCH(float, val1); QFETCH(float, val2); QFETCH(quint32, expectedDistance); -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX QEXPECT_FAIL("denormal", "See QTBUG-37094", Continue); #endif QCOMPARE(qFloatDistance(val1, val2), expectedDistance); @@ -214,7 +214,7 @@ void tst_QNumeric::floatDistance_double() QFETCH(double, val1); QFETCH(double, val2); QFETCH(quint64, expectedDistance); -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX QEXPECT_FAIL("denormal", "See QTBUG-37094", Continue); #endif QCOMPARE(qFloatDistance(val1, val2), expectedDistance); diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 2f75ad631f..a17fe7561a 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -347,7 +347,7 @@ void tst_QtJson::testNumbers_2() QJsonDocument jDocument2(QJsonDocument::fromJson(ba)); for (int power = 0; power <= 1075; power++) { floatValues_1[power] = jDocument2.object().value(QString::number(power)).toDouble(); -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX if (power >= 970) QEXPECT_FAIL("", "See QTBUG-37066", Abort); #endif @@ -1346,7 +1346,7 @@ void tst_QtJson::toJsonLargeNumericValues() " ]\n" "}\n"; -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX QEXPECT_FAIL("", "See QTBUG-37066", Continue); #endif QCOMPARE(json, expected); @@ -1354,7 +1354,7 @@ void tst_QtJson::toJsonLargeNumericValues() QJsonDocument doc; doc.setObject(object); json = doc.toJson(); -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX QEXPECT_FAIL("", "See QTBUG-37066", Continue); #endif QCOMPARE(json, expected); @@ -1758,7 +1758,7 @@ void tst_QtJson::parseNumbers() json += numbers[i].str; json += " ]"; QJsonDocument doc = QJsonDocument::fromJson(json); -#ifdef Q_OS_BLACKBERRY +#ifdef Q_OS_QNX if (0 == QString::compare(numbers[i].str, "1.1e-308")) QEXPECT_FAIL("", "See QTBUG-37066", Abort); #endif -- cgit v1.2.3 From eab7efd1ee0475fd331774ccc99ee92c816f588c Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 20 Mar 2014 17:47:25 +0100 Subject: Stabilize tst_QProcess::softExitInSlots() This test takes more than 5000ms to finish some times, so waiting for 10000ms should be enough to make it more stable on all platforms. ../tst_qprocess.cpp:1072 :: [gui app] QTestLib: This test case check ("proc.waitedForFinished") failed because the requested timeout (5000 ms) was too short, 6150 ms would have been sufficient this time. Change-Id: I266ad0e65bf3c84e73b7ca6543dc15335dad4c99 Reviewed-by: Fabian Bumberger --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index f5aa2c2412..b67166272b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1069,7 +1069,7 @@ void tst_QProcess::softExitInSlots() SoftExitProcess proc(i); proc.writeAfterStart("OLEBOLE", 8); // include the \0 proc.start(appName); - QTRY_VERIFY(proc.waitedForFinished); + QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000); QCOMPARE(proc.state(), QProcess::NotRunning); } } -- cgit v1.2.3 From ad1c088a2a5c52a5c95075e1e24dfc31aa41b6c1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 25 Mar 2014 15:27:05 +0100 Subject: Fix the QOpenGL autotest's offscreen surface handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Be more robust. Change-Id: I0e37612681140530c81cfd0082cca61f0f21958c Reviewed-by: Jørgen Lind --- tests/auto/gui/qopengl/tst_qopengl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 4018c00a38..f37602ef78 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -157,7 +157,22 @@ static QSurface *createSurface(int surfaceClass) window->create(); return window; } else if (surfaceClass == int(QSurface::Offscreen)) { + // Create a window and get the format from that. For example, if an EGL + // implementation provides 565 and 888 configs for PBUFFER_BIT but only + // 888 for WINDOW_BIT, we may end up with a pbuffer surface that is + // incompatible with the context since it could choose the 565 while the + // window and the context uses a config with 888. + static QSurfaceFormat format; + if (format.redBufferSize() == -1) { + QWindow *window = new QWindow; + window->setSurfaceType(QWindow::OpenGLSurface); + window->setGeometry(0, 0, 10, 10); + window->create(); + format = window->format(); + delete window; + } QOffscreenSurface *offscreenSurface = new QOffscreenSurface; + offscreenSurface->setFormat(format); offscreenSurface->create(); return offscreenSurface; } -- cgit v1.2.3 From 75f9c75f0a56d4531b219775e3c79eee3b7a8d6d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 25 Mar 2014 15:03:51 +0100 Subject: Enhance QOffscreenSurface docs wrt the format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent nasty surprises on some EGL implementations. Change-Id: I0c6c8a6c631d4dcb979afd81a150491a42aa63f8 Reviewed-by: Jørgen Lind --- src/gui/kernel/qoffscreensurface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index ce913a98af..1625909843 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -71,6 +71,14 @@ QT_BEGIN_NAMESPACE How the offscreen surface is implemented depends on the underlying platform, but it will typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally. + + \note In order to create an offscreen surface that is guaranteed to be compatible with + a given context and window, make sure to set the format to the context's or the + window's actual format, that is, the QSurfaceFormat returned from + QOpenGLContext::format() or QWindow::format() \e{after the context or window has been + created}. Passing the format returned from QWindow::requestedFormat() to setFormat() + may result in an incompatible offscreen surface since the underlying windowing system + interface may offer a different set of configurations for window and pbuffer surfaces. */ class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate { -- cgit v1.2.3 From 7aec099ca3cbc3f04562db027dc88f29e7ca28e4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 25 Mar 2014 17:45:29 +0100 Subject: OSX: a window can be de-maximized by resizing After that, QWidget::isMaximized() should return false. Task-number: QTBUG-37703 Change-Id: Ic8b0de63ab007066cd277f511dfaa969404ff069 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 8 ++++++++ src/plugins/platforms/cocoa/qnswindowdelegate.mm | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 34ec142d90..b7a6a14d4a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -183,6 +183,7 @@ public: void windowWillMove(); void windowDidMove(); void windowDidResize(); + void windowDidEndLiveResize(); bool windowShouldClose(); bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f25aea67fa..b27e1b03db 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1165,6 +1165,14 @@ void QCocoaWindow::windowDidResize() [m_qtView updateGeometry]; } +void QCocoaWindow::windowDidEndLiveResize() +{ + if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) { + m_effectivelyMaximized = false; + [m_qtView notifyWindowStateChanged:Qt::WindowNoState]; + } +} + bool QCocoaWindow::windowShouldClose() { bool accepted = false; diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index c9b3d69381..d9509098c6 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -75,6 +75,14 @@ } } +- (void)windowDidEndLiveResize:(NSNotification *)notification +{ + Q_UNUSED(notification); + if (m_cocoaWindow) { + m_cocoaWindow->windowDidEndLiveResize(); + } +} + - (void)windowWillMove:(NSNotification *)notification { Q_UNUSED(notification); -- cgit v1.2.3 From f16d690a2f8c6ff1830a15794950c8564ae18a29 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 26 Mar 2014 10:14:45 +0100 Subject: Accessibility Mac: Fix handling of top level widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies how we handle QNSView for accessibility purposes. Instead of trying to half-merge the top level widget (window->accessibleRoot) into the view, just have the view always return it as child. This makes the accessibility implementation for QNSView simpler and makes applications that show a top level widget such as a button possible. (We would return accessibility ignored for the button before). As a side effect finding the active focus and hit-testing should be more reliable as well. Task-number: QTBUG-37794 Change-Id: Ib52037f88da8887a0bdc77204b0f3daddfe7709d Reviewed-by: Morten Johan Sørvig Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 18 ++++- .../platforms/cocoa/qnsviewaccessibility.mm | 53 ++++---------- .../qaccessibilitymac/tst_qaccessibilitymac.cpp | 20 +++++- .../tst_qaccessibilitymac_helpers.h | 3 +- .../tst_qaccessibilitymac_helpers.mm | 83 ++++++++++++++++++---- 5 files changed, 121 insertions(+), 56 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index bc98d002f0..0b674b8d2f 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -417,7 +417,23 @@ } - (id)accessibilityFocusedUIElement { - return NSAccessibilityUnignoredAncestor(self); + QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); + + if (!iface || !iface->isValid()) { + qWarning() << "FocusedUIElement for INVALID"; + return nil; + } + QAccessibleInterface *childInterface = iface->focusChild(); + if (childInterface) { + QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); + // FIXME: parent could be wrong + QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement createElementWithId:childAxid parent:self]; + [accessibleElement autorelease]; + return accessibleElement; + } + + // no focus found + return nil; } @end diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index a438950a55..31e3e343b9 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -54,6 +54,15 @@ @implementation QNSView (QNSViewAccessibility) +- (id)childAccessibleElement { + if (!m_window->accessibleRoot()) + return nil; + + QAccessible::Id childId = QAccessible::uniqueId(m_window->accessibleRoot()); + QCocoaAccessibleElement *child = [QCocoaAccessibleElement createElementWithId: childId parent: self]; + return [child autorelease]; +} + // The QNSView is a container that the user does not interact directly with: // Remove it from the user-visible accessibility tree. - (BOOL)accessibilityIsIgnored { @@ -61,58 +70,22 @@ } - (id)accessibilityAttributeValue:(NSString *)attribute { - // activate accessibility updates QCocoaIntegration::instance()->accessibility()->setActive(true); - if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { - if (m_window->accessibleRoot()) - return QCocoaAccessible::macRole(m_window->accessibleRoot()); - return NSAccessibilityUnknownRole; - } else if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { - return NSAccessibilityRoleDescriptionForUIElement(self); - } else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) { - if (!m_window->accessibleRoot()) - return [super accessibilityAttributeValue:attribute]; - return QCocoaAccessible::unignoredChildren(self, m_window->accessibleRoot()); + if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) { + return NSAccessibilityUnignoredChildrenForOnlyChild([self childAccessibleElement]); } else { return [super accessibilityAttributeValue:attribute]; } } - (id)accessibilityHitTest:(NSPoint)point { - if (!m_window->accessibleRoot()) - return [super accessibilityHitTest:point]; - - QAccessibleInterface *childInterface = m_window->accessibleRoot()->childAt(point.x, qt_mac_flipYCoordinate(point.y)); - // No child found, meaning we hit the NSView - if (!childInterface) { - return [super accessibilityHitTest:point]; - } - - // Hit a child, forward to child accessible interface. - QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); - // FIXME: parent could be wrong - QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement createElementWithId:childAxid parent:self ]; - [accessibleElement autorelease]; - return [accessibleElement accessibilityHitTest:point]; + return [[self childAccessibleElement] accessibilityHitTest: point]; } - (id)accessibilityFocusedUIElement { - if (!m_window->accessibleRoot()) - return [super accessibilityFocusedUIElement]; - - QAccessibleInterface *childInterface = m_window->accessibleRoot()->focusChild(); - if (childInterface) { - QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); - // FIXME: parent could be wrong - QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement createElementWithId:childAxid parent:self]; - [accessibleElement autorelease]; - return accessibleElement; - } - - // should not happen - return nil; + return [[self childAccessibleElement] accessibilityFocusedUIElement]; } @end diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp index 25dd0d39dd..25b47ee836 100644 --- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp @@ -79,6 +79,7 @@ private slots: void init(); void cleanup(); + void singleWidgetTest(); void lineEditTest(); void hierarchyTest(); private: @@ -101,6 +102,16 @@ void tst_QAccessibilityMac::cleanup() delete m_window; } +void tst_QAccessibilityMac::singleWidgetTest() +{ + if (!macNativeAccessibilityEnabled()) + return; + + delete m_window; + m_window = 0; + + QVERIFY(singleWidget()); +} void tst_QAccessibilityMac::lineEditTest() { @@ -122,14 +133,19 @@ void tst_QAccessibilityMac::hierarchyTest() QWidget *w = new QWidget(m_window); m_window->addWidget(w); - QPushButton *b = new QPushButton(w); + w->setLayout(new QVBoxLayout()); + QPushButton *b = new QPushButton(w); w->layout()->addWidget(b); b->setText("I am a button"); + QPushButton *b2 = new QPushButton(w); + w->layout()->addWidget(b2); + b2->setText("Button 2"); + QVERIFY(QTest::qWaitForWindowExposed(m_window)); QCoreApplication::processEvents(); - QVERIFY(testHierarchy()); + QVERIFY(testHierarchy(w)); } QTEST_MAIN(tst_QAccessibilityMac) diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h index ec5beab125..635b6383ab 100644 --- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h @@ -48,4 +48,5 @@ bool macNativeAccessibilityEnabled(); bool trusted(); bool testLineEdit(); -bool testHierarchy(); +bool testHierarchy(QWidget *w); +bool singleWidget(); diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm index 8620b7dd2f..bc89ac858b 100644 --- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm @@ -43,8 +43,10 @@ #define QT_NO_KEYWORDS #include "tst_qaccessibilitymac_helpers.h" -#include -#include +#include +#include +#include +#include #include #import @@ -148,9 +150,41 @@ bool trusted() return p; } ++ (TestAXObject *) getApplicationAXObject +{ + pid_t pid = getpid(); + AXUIElementRef appRef = AXUIElementCreateApplication(pid); + TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: appRef]; + return appObject; +} + @end +bool singleWidget() +{ + QLineEdit le; + le.setText("button"); + le.show(); + EXPECT(QTest::qWaitForWindowExposed(&le)); + QCoreApplication::processEvents(); + + TestAXObject *appObject = [TestAXObject getApplicationAXObject]; + EXPECT(appObject); + + NSArray *windows = [appObject windowList]; + EXPECT([windows count] == 1); + + AXUIElementRef windowRef = (AXUIElementRef) [windows objectAtIndex: 0]; + EXPECT(windowRef != nil); + TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef]; + + AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole]; + EXPECT(lineEdit != nil); + + return true; +} + bool testLineEdit() { // not sure if this is needed. on my machine the calls succeed. @@ -159,10 +193,8 @@ bool testLineEdit() // AXError e = AXMakeProcessTrusted((CFStringRef) path); // NSLog(@"error: %i", e); - pid_t pid = getpid(); - AXUIElementRef app = AXUIElementCreateApplication(pid); - EXPECT(app != nil); - TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + TestAXObject *appObject = [TestAXObject getApplicationAXObject]; + EXPECT(appObject); NSArray *windowList = [appObject windowList]; // one window @@ -184,12 +216,10 @@ bool testLineEdit() return true; } -bool testHierarchy() +bool testHierarchy(QWidget *w) { - pid_t pid = getpid(); - AXUIElementRef app = AXUIElementCreateApplication(pid); - EXPECT(app != nil); - TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + TestAXObject *appObject = [TestAXObject getApplicationAXObject]; + EXPECT(appObject); NSArray *windowList = [appObject windowList]; // one window @@ -207,7 +237,36 @@ bool testHierarchy() TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]]; // check that the parent is a window - EXPECT([[parentObject role] isEqualToString: (NSString *)kAXWindowRole]); + EXPECT([[parentObject role] isEqualToString: NSAccessibilityWindowRole]); + + // test the focus + // child 0 is the layout, then button1 and 2 + QPushButton *button1 = qobject_cast(w->children().at(1)); + EXPECT(button1); + QPushButton *button2 = qobject_cast(w->children().at(2)); + EXPECT(button2); + button2->setFocus(); + + AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); + AXUIElementRef focussedElement = NULL; + AXError error = AXUIElementCopyAttributeValue(systemWideElement, + (CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement); + EXPECT(!error); + EXPECT(focussedElement); + TestAXObject *focusButton2 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement]; + + EXPECT([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]); + EXPECT([[focusButton2 description] isEqualToString: @"Button 2"]); + + + button1->setFocus(); + error = AXUIElementCopyAttributeValue(systemWideElement, + (CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement); + EXPECT(!error); + EXPECT(focussedElement); + TestAXObject *focusButton1 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement]; + EXPECT([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]); + EXPECT([[focusButton1 description] isEqualToString: @"I am a button"]); return true; } -- cgit v1.2.3 From 38fc11b74bfb0aca467c1f240af30d4dfbfed642 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 25 Mar 2014 14:30:18 +0100 Subject: QNX: Retrieve name of the display Task-number: QTBUG-34545 Change-Id: I51d36c7352351b0770a1a076bdcc738677d7fcb6 Reviewed-by: Bernd Weimer Reviewed-by: Sergio Ahumada --- src/plugins/platforms/qnx/qqnxscreen.cpp | 5 +++++ src/plugins/platforms/qnx/qqnxscreen.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index a6c69164c7..2707f14db2 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -177,6 +177,11 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, m_currentGeometry = m_initialGeometry = QRect(0, 0, val[0], val[1]); + char name[100]; + Q_SCREEN_CHECKERROR(screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, 100, + name), "Failed to query display name"); + m_name = QString::fromUtf8(name); + // Cache size of this display in millimeters. We have to take care of the orientation. // libscreen always reports the physical size dimensions as width and height in the // native orientation. Contrary to this, QPlatformScreen::physicalSize() expects the diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index d39a210d4b..a0b760135f 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -77,6 +77,8 @@ public: int rotation() const { return m_currentRotation; } + QString name() const { return m_name; } + int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; } screen_display_t nativeDisplay() const { return m_display; } screen_context_t nativeContext() const { return m_screenContext; } @@ -132,6 +134,7 @@ private: int m_initialRotation; int m_currentRotation; int m_keyboardHeight; + QString m_name; QSize m_initialPhysicalSize; QSize m_currentPhysicalSize; Qt::ScreenOrientation m_nativeOrientation; -- cgit v1.2.3 From 3f4277c264db3ef19e7783c3daf1959ff662d04a Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 25 Mar 2014 12:12:11 +0100 Subject: QNX: Fix geometry changed event for non FS windows For non full screen windows the geometry change event was not sent. Change-Id: I982621d87fe248bbe13640dd3e17b31fb9f30120 Reviewed-by: Bernd Weimer Reviewed-by: Sergio Ahumada --- src/plugins/platforms/qnx/qqnxwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index f11a009bca..42318729b1 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -709,12 +709,12 @@ void QQnxWindow::initWindow() if (window()->parent() && window()->parent()->handle()) setParent(window()->parent()->handle()); - if (shouldMakeFullScreen()) { + if (shouldMakeFullScreen()) setGeometryHelper(screen()->geometry()); - QWindowSystemInterface::handleGeometryChange(window(), screen()->geometry()); - } else { + else setGeometryHelper(window()->geometry()); - } + + QWindowSystemInterface::handleGeometryChange(window(), screen()->geometry()); } void QQnxWindow::createWindowGroup() -- cgit v1.2.3 From 7ca958eb61eec6c01d4fcc6720941ba37bd2924d Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 18 Mar 2014 17:18:04 +0100 Subject: QNX: Fix QWindow autotest On QNX a actual platform window is not created unless the window is explicitly postet (raster) or a swapBuffers (opengl) is executed. Change-Id: Ia06b97ea1a477d59e78d74d895c5d6ba6dd86edf Reviewed-by: Sergio Ahumada --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 54 ++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index da142c80a6..eefa85a745 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -49,6 +49,10 @@ #include #include +#if defined(Q_OS_QNX) +#include +#endif + // For QSignalSpy slot connections. Q_DECLARE_METATYPE(Qt::ScreenOrientation) Q_DECLARE_METATYPE(QWindow::Visibility) @@ -122,6 +126,9 @@ public: { reset(); setFlags(flags); +#if defined(Q_OS_QNX) + setSurfaceType(QSurface::OpenGLSurface); +#endif } void reset() @@ -187,7 +194,12 @@ void tst_QWindow::resizeEventAfterResize() // Make sure we get a resizeEvent after calling resize window.resize(400, 100); +#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen + // so we only expect one resize event + QTRY_COMPARE(window.received(QEvent::Resize), 1); +#else QTRY_COMPARE(window.received(QEvent::Resize), 2); +#endif } void tst_QWindow::positioning_data() @@ -244,13 +256,24 @@ void tst_QWindow::positioning() window.setWindowState(Qt::WindowFullScreen); QCoreApplication::processEvents(); +#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen + // so we only expect one resize event + Q_UNUSED(resizecount); + QTRY_COMPARE(window.received(QEvent::Resize), 1); +#else QTRY_COMPARE(window.received(QEvent::Resize), 2); +#endif QTest::qWait(2000); window.setWindowState(Qt::WindowNoState); QCoreApplication::processEvents(); +#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen + // so we only expect one resize event + QTRY_COMPARE(window.received(QEvent::Resize), 1); +#else QTRY_COMPARE(window.received(QEvent::Resize), resizecount); +#endif QTRY_COMPARE(originalPos, window.position()); QTRY_COMPARE(originalFramePos, window.framePosition()); @@ -309,6 +332,13 @@ void tst_QWindow::isActive() QCoreApplication::processEvents(); QTRY_VERIFY(window.isExposed()); +#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store + // and then post the window in order for screen to show the window + QOpenGLContext context; + context.create(); + context.makeCurrent(&window); + context.swapBuffers(&window); +#endif QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); QVERIFY(window.isActive()); @@ -511,7 +541,7 @@ void tst_QWindow::testInputEvents() // Now with null pointer as window. local param should not be utilized: // handleMouseEvent() with tlw == 0 means the event is in global coords only. window.mousePressButton = window.mouseReleaseButton = 0; - QPointF nonWindowGlobal(500, 500); // not inside the window + QPointF nonWindowGlobal(2000, 500); // not inside the window QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::LeftButton); QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::NoButton); QCoreApplication::processEvents(); @@ -913,10 +943,21 @@ void tst_QWindow::activateAndClose() { for (int i = 0; i < 10; ++i) { QWindow window; +#if defined(Q_OS_QNX) + window.setSurfaceType(QSurface::OpenGLSurface); +#endif // qWaitForWindowActive will block for the duration of // of the timeout if the window is at 0,0 window.setGeometry(QGuiApplication::primaryScreen()->availableGeometry().adjusted(1, 1, -1, -1)); window.showNormal(); +#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store + // and then post the window in order for screen to show the window + QTest::qWaitForWindowExposed(&window); + QOpenGLContext context; + context.create(); + context.makeCurrent(&window); + context.swapBuffers(&window); +#endif window.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window)); QCOMPARE(qGuiApp->focusWindow(), &window); @@ -1252,15 +1293,26 @@ void tst_QWindow::initialSize() Window w; w.setWidth(200); w.show(); +#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen + // so we only expect one resize event + QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width()); +#else QTRY_COMPARE(w.width(), 200); +#endif QTRY_VERIFY(w.height() > 0); } { Window w; w.resize(200, 42); w.show(); +#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen + // so we only expect one resize event + QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width()); + QTRY_COMPARE(w.height(), qGuiApp->primaryScreen()->availableGeometry().height()); +#else QTRY_COMPARE(w.width(), 200); QTRY_COMPARE(w.height(), 42); +#endif } } -- cgit v1.2.3 From 74cade1ee42dbe15d3242b08d5880e08e6294e2e Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Thu, 9 Jan 2014 01:57:41 +0100 Subject: Fix application font removal when using FontConfig This patch fixes an issue when a font that was added with QFontDatabase::addApplicationFont can not be removed any more. The reason for that is that QFontconfigDatabase::addApplicationFont adds the font to the FontConfig application set from where it cannot be removed any more and is picked up every time the font database is repopulated (e.g. after a call to QFontDatabase::removeApplicationFont). This also fixes the QFontDatabase autotest which unfortunately does not fail on linux, because it tries to add "FreeMono" (which in most cases is already there as a system font). So this patch removes FreeMono and adds LED_REAL as test font. Change-Id: I70fc823075923aa426da1eb3e052affcc416e399 Reviewed-by: Konstantin Ritt --- .../fontconfig/qfontconfigdatabase.cpp | 220 +++++++++++---------- tests/auto/gui/text/qfontdatabase/FreeMono.ttf | Bin 267400 -> 0 bytes tests/auto/gui/text/qfontdatabase/LED_REAL.TTF | Bin 0 -> 4708 bytes .../gui/text/qfontdatabase/LED_REAL_readme.txt | 34 ++++ .../gui/text/qfontdatabase/tst_qfontdatabase.cpp | 2 +- 5 files changed, 147 insertions(+), 109 deletions(-) delete mode 100644 tests/auto/gui/text/qfontdatabase/FreeMono.ttf create mode 100644 tests/auto/gui/text/qfontdatabase/LED_REAL.TTF create mode 100644 tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 1a31400ea5..17717dd53c 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -331,10 +331,8 @@ static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) return stylehint; } -void QFontconfigDatabase::populateFontDatabase() +static void populateFromPattern(FcPattern *pattern) { - FcFontSet *fonts; - QString familyName; FcChar8 *value = 0; int weight_value; @@ -348,6 +346,110 @@ void QFontconfigDatabase::populateFontDatabase() FcBool scalable; FcBool antialias; + if (FcPatternGetString(pattern, FC_FAMILY, 0, &value) != FcResultMatch) + return; + + familyName = QString::fromUtf8((const char *)value); + + slant_value = FC_SLANT_ROMAN; + weight_value = FC_WEIGHT_REGULAR; + spacing_value = FC_PROPORTIONAL; + file_value = 0; + indexValue = 0; + scalable = FcTrue; + + + if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant_value) != FcResultMatch) + slant_value = FC_SLANT_ROMAN; + if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight_value) != FcResultMatch) + weight_value = FC_WEIGHT_REGULAR; + if (FcPatternGetInteger(pattern, FC_WIDTH, 0, &width_value) != FcResultMatch) + width_value = FC_WIDTH_NORMAL; + if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing_value) != FcResultMatch) + spacing_value = FC_PROPORTIONAL; + if (FcPatternGetString(pattern, FC_FILE, 0, &file_value) != FcResultMatch) + file_value = 0; + if (FcPatternGetInteger(pattern, FC_INDEX, 0, &indexValue) != FcResultMatch) + indexValue = 0; + if (FcPatternGetBool(pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch) + scalable = FcTrue; + if (FcPatternGetString(pattern, FC_FOUNDRY, 0, &foundry_value) != FcResultMatch) + foundry_value = 0; + if (FcPatternGetString(pattern, FC_STYLE, 0, &style_value) != FcResultMatch) + style_value = 0; + if (FcPatternGetBool(pattern,FC_ANTIALIAS,0,&antialias) != FcResultMatch) + antialias = true; + + QSupportedWritingSystems writingSystems; + FcLangSet *langset = 0; + FcResult res = FcPatternGetLangSet(pattern, FC_LANG, 0, &langset); + if (res == FcResultMatch) { + bool hasLang = false; + for (int j = 1; j < QFontDatabase::WritingSystemsCount; ++j) { + const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[j]; + if (lang) { + FcLangResult langRes = FcLangSetHasLang(langset, lang); + if (langRes != FcLangDifferentLang) { + writingSystems.setSupported(QFontDatabase::WritingSystem(j)); + hasLang = true; + } + } + } + if (!hasLang) + // none of our known languages, add it to the other set + writingSystems.setSupported(QFontDatabase::Other); + } else { + // we set Other to supported for symbol fonts. It makes no + // sense to merge these with other ones, as they are + // special in a way. + writingSystems.setSupported(QFontDatabase::Other); + } + +#if FC_VERSION >= 20297 + for (int j = 1; j < QFontDatabase::WritingSystemsCount; ++j) { + if (writingSystems.supported(QFontDatabase::WritingSystem(j)) + && requiresOpenType(j) && openType[j]) { + FcChar8 *cap; + res = FcPatternGetString (pattern, FC_CAPABILITY, 0, &cap); + if (res != FcResultMatch || !strstr((const char *)cap, openType[j])) + writingSystems.setSupported(QFontDatabase::WritingSystem(j),false); + } + } +#endif + + FontFile *fontFile = new FontFile; + fontFile->fileName = QLatin1String((const char *)file_value); + fontFile->indexValue = indexValue; + + QFont::Style style = (slant_value == FC_SLANT_ITALIC) + ? QFont::StyleItalic + : ((slant_value == FC_SLANT_OBLIQUE) + ? QFont::StyleOblique + : QFont::StyleNormal); + // Note: weight should really be an int but registerFont incorrectly uses an enum + QFont::Weight weight = QFont::Weight(weightFromFcWeight(weight_value)); + + double pixel_size = 0; + if (!scalable) + FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size); + + bool fixedPitch = spacing_value >= FC_MONO; + // Note: stretch should really be an int but registerFont incorrectly uses an enum + QFont::Stretch stretch = QFont::Stretch(stretchFromFcWidth(width_value)); + QString styleName = style_value ? QString::fromUtf8((const char *) style_value) : QString(); + QPlatformFontDatabase::registerFont(familyName,styleName,QLatin1String((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,fixedPitch,writingSystems,fontFile); +// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size; + + for (int k = 1; FcPatternGetString(pattern, FC_FAMILY, k, &value) == FcResultMatch; ++k) + QPlatformFontDatabase::registerAliasToFontFamily(familyName, QString::fromUtf8((const char *)value)); + +} + +void QFontconfigDatabase::populateFontDatabase() +{ + FcInitReinitialize(); + FcFontSet *fonts; + { FcObjectSet *os = FcObjectSetCreate(); FcPattern *pattern = FcPatternCreate(); @@ -371,103 +473,8 @@ void QFontconfigDatabase::populateFontDatabase() FcPatternDestroy(pattern); } - for (int i = 0; i < fonts->nfont; i++) { - if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) - continue; - // capitalize(value); - familyName = QString::fromUtf8((const char *)value); - slant_value = FC_SLANT_ROMAN; - weight_value = FC_WEIGHT_REGULAR; - spacing_value = FC_PROPORTIONAL; - file_value = 0; - indexValue = 0; - scalable = FcTrue; - - - if (FcPatternGetInteger (fonts->fonts[i], FC_SLANT, 0, &slant_value) != FcResultMatch) - slant_value = FC_SLANT_ROMAN; - if (FcPatternGetInteger (fonts->fonts[i], FC_WEIGHT, 0, &weight_value) != FcResultMatch) - weight_value = FC_WEIGHT_REGULAR; - if (FcPatternGetInteger (fonts->fonts[i], FC_WIDTH, 0, &width_value) != FcResultMatch) - width_value = FC_WIDTH_NORMAL; - if (FcPatternGetInteger (fonts->fonts[i], FC_SPACING, 0, &spacing_value) != FcResultMatch) - spacing_value = FC_PROPORTIONAL; - if (FcPatternGetString (fonts->fonts[i], FC_FILE, 0, &file_value) != FcResultMatch) - file_value = 0; - if (FcPatternGetInteger (fonts->fonts[i], FC_INDEX, 0, &indexValue) != FcResultMatch) - indexValue = 0; - if (FcPatternGetBool(fonts->fonts[i], FC_SCALABLE, 0, &scalable) != FcResultMatch) - scalable = FcTrue; - if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch) - foundry_value = 0; - if (FcPatternGetString(fonts->fonts[i], FC_STYLE, 0, &style_value) != FcResultMatch) - style_value = 0; - if(FcPatternGetBool(fonts->fonts[i],FC_ANTIALIAS,0,&antialias) != FcResultMatch) - antialias = true; - - QSupportedWritingSystems writingSystems; - FcLangSet *langset = 0; - FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset); - if (res == FcResultMatch) { - bool hasLang = false; - for (int j = 1; j < QFontDatabase::WritingSystemsCount; ++j) { - const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[j]; - if (lang) { - FcLangResult langRes = FcLangSetHasLang(langset, lang); - if (langRes != FcLangDifferentLang) { - writingSystems.setSupported(QFontDatabase::WritingSystem(j)); - hasLang = true; - } - } - } - if (!hasLang) - // none of our known languages, add it to the other set - writingSystems.setSupported(QFontDatabase::Other); - } else { - // we set Other to supported for symbol fonts. It makes no - // sense to merge these with other ones, as they are - // special in a way. - writingSystems.setSupported(QFontDatabase::Other); - } - -#if FC_VERSION >= 20297 - for (int j = 1; j < QFontDatabase::WritingSystemsCount; ++j) { - if (writingSystems.supported(QFontDatabase::WritingSystem(j)) - && requiresOpenType(j) && openType[j]) { - FcChar8 *cap; - res = FcPatternGetString (fonts->fonts[i], FC_CAPABILITY, 0, &cap); - if (res != FcResultMatch || !strstr((const char *)cap, openType[j])) - writingSystems.setSupported(QFontDatabase::WritingSystem(j),false); - } - } -#endif - - FontFile *fontFile = new FontFile; - fontFile->fileName = QLatin1String((const char *)file_value); - fontFile->indexValue = indexValue; - - QFont::Style style = (slant_value == FC_SLANT_ITALIC) - ? QFont::StyleItalic - : ((slant_value == FC_SLANT_OBLIQUE) - ? QFont::StyleOblique - : QFont::StyleNormal); - // Note: weight should really be an int but registerFont incorrectly uses an enum - QFont::Weight weight = QFont::Weight(weightFromFcWeight(weight_value)); - - double pixel_size = 0; - if (!scalable) - FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size); - - bool fixedPitch = spacing_value >= FC_MONO; - // Note: stretch should really be an int but registerFont incorrectly uses an enum - QFont::Stretch stretch = QFont::Stretch(stretchFromFcWidth(width_value)); - QString styleName = style_value ? QString::fromUtf8((const char *) style_value) : QString(); - QPlatformFontDatabase::registerFont(familyName,styleName,QLatin1String((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,fixedPitch,writingSystems,fontFile); -// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size; - - for (int k = 1; FcPatternGetString(fonts->fonts[i], FC_FAMILY, k, &value) == FcResultMatch; ++k) - QPlatformFontDatabase::registerAliasToFontFamily(familyName, QString::fromUtf8((const char *)value)); - } + for (int i = 0; i < fonts->nfont; i++) + populateFromPattern(fonts->fonts[i]); FcFontSetDestroy (fonts); @@ -802,6 +809,7 @@ static FcPattern *queryFont(const FcChar8 *file, const QByteArray &data, int id, QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { QStringList families; + FcFontSet *set = FcConfigGetFonts(0, FcSetApplication); if (!set) { FcConfigAppFontAddFile(0, (const FcChar8 *)":/non-existent"); @@ -814,28 +822,24 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, FcBlanks *blanks = FcConfigGetBlanks(0); int count = 0; - FcPattern *pattern = 0; + FcPattern *pattern; do { pattern = queryFont((const FcChar8 *)QFile::encodeName(fileName).constData(), fontData, id, blanks, &count); if (!pattern) return families; - FcPatternDel(pattern, FC_FILE); - QByteArray cs = fileName.toUtf8(); - FcPatternAddString(pattern, FC_FILE, (const FcChar8 *) cs.constData()); - FcChar8 *fam = 0; if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) { QString family = QString::fromUtf8(reinterpret_cast(fam)); families << family; } + populateFromPattern(pattern); - if (!FcFontSetAdd(set, pattern)) - return families; + FcFontSetAdd(set, pattern); ++id; - } while (pattern && id < count); + } while (id < count); return families; } diff --git a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf b/tests/auto/gui/text/qfontdatabase/FreeMono.ttf deleted file mode 100644 index d7ce52ddc7..0000000000 Binary files a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf and /dev/null differ diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF new file mode 100644 index 0000000000..f87ea95e0e Binary files /dev/null and b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF differ diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt new file mode 100644 index 0000000000..06a5b40313 --- /dev/null +++ b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt @@ -0,0 +1,34 @@ +Font: LED Real (led_real.ttf) +Created By: Matthew Welch +E-Mail: daffy-duck@worldnet.att.net +Web Address: http://home.att.net/~daffy-duck + (PGP public key available here) + +LED Real, like all of my fonts, is free. You can use it for most +personal or business uses you'd like, and I ask for no money. I +would, however, like to hear from you. If you use my fonts for +something please send me a postcard or e-mail letting me know how +you used it. Send me a copy if you can or let me know where I can +find your work. + +You may use this font for graphical or printed work, but you may not +sell it or include it in a collection of fonts (on CD or otherwise) +being sold. You can redistribute this font as long as you charge +nothing to receive it. If you redistribute it include this text file +with it as is (without modifications). + +If you use this font for commercial purposes please credit me in +at least some little way. + +About the font: + +Unlike most LED/LCD style fonts mine could be recreated with an +actual LED. I created this font working from memories of the good +old Speak and Spell display. Since I don't have an actual Speak +and Spell to work from I had to just do as well as I could in its +spirit. Be warned that some characters look just like others. The +( and the <, for instance. Also C and [. Most of these will be +pretty clear in context. To see all the sections of the LED "lit +up" at once use character 127 (hold down alt and type 0127 on the +numeric keypad). This font is, of course, monospaced. + diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index fa5c81a2f0..28db0ba291 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -83,7 +83,7 @@ private: }; tst_QFontDatabase::tst_QFontDatabase() - : m_testFont(QFINDTESTDATA("FreeMono.ttf")) + : m_testFont(QFINDTESTDATA("LED_REAL.TTF")) { } -- cgit v1.2.3 From ad22303bff0dac7accc748e284bd1ffbf6b24cb3 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 26 Mar 2014 21:14:19 +0100 Subject: update bundled sqlite to 3.8.4.2 The "Fixed CE build of sqlite3" patch is preserved in this change. (ea70ec8711af45128d63634a01dfc4c1a51ac331) Change-Id: I7da6504a1d1bee7926a122d7c4ec3a2bf4035d03 Reviewed-by: Friedemann Kleint --- src/3rdparty/sqlite/sqlite3.c | 7 ++++--- src/3rdparty/sqlite/sqlite3.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index a2e37dd48e..f8a10149bc 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.8.4.1. By combining all the individual C code files into this +** version 3.8.4.2. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -222,9 +222,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.8.4.1" +#define SQLITE_VERSION "3.8.4.2" #define SQLITE_VERSION_NUMBER 3008004 -#define SQLITE_SOURCE_ID "2014-03-11 15:27:36 018d317b1257ce68a92908b05c9c7cf1494050d0" +#define SQLITE_SOURCE_ID "2014-03-26 18:51:19 02ea166372bdb2ef9d8dfbb05e78a97609673a8e" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -64786,6 +64786,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompare( }else{ idx1 = getVarint32(aKey1, szHdr1); d1 = szHdr1; + if( d1>(unsigned)nKey1 ) return 1; /* Corruption */ i = 0; } diff --git a/src/3rdparty/sqlite/sqlite3.h b/src/3rdparty/sqlite/sqlite3.h index 1f19ada4cb..d0d676afae 100644 --- a/src/3rdparty/sqlite/sqlite3.h +++ b/src/3rdparty/sqlite/sqlite3.h @@ -107,9 +107,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.8.4.1" +#define SQLITE_VERSION "3.8.4.2" #define SQLITE_VERSION_NUMBER 3008004 -#define SQLITE_SOURCE_ID "2014-03-11 15:27:36 018d317b1257ce68a92908b05c9c7cf1494050d0" +#define SQLITE_SOURCE_ID "2014-03-26 18:51:19 02ea166372bdb2ef9d8dfbb05e78a97609673a8e" /* ** CAPI3REF: Run-Time Library Version Numbers -- cgit v1.2.3 From ddf2e2367ccf651fc25f02a3e7975a8b57a4bc98 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 21 Mar 2014 10:02:07 +0100 Subject: Doc: Move IPC example documentation Examples under examples/ipc were not part of any module documentation. This change adds the above folder to Qt Core documentation, and moves the corresponding files so that the example documentation is built correctly. Change-Id: If1f34ce7ef04a02df8a87f820bb2e68ffa723dd4 Reviewed-by: Friedemann Kleint Reviewed-by: Jerome Pasion --- doc/src/examples/localfortuneclient.qdoc | 40 ------- doc/src/examples/localfortuneserver.qdoc | 39 ------ doc/src/examples/sharedmemory.qdoc | 131 --------------------- doc/src/images/localfortuneclient-example.png | Bin 8402 -> 0 bytes doc/src/images/localfortuneserver-example.png | Bin 5715 -> 0 bytes doc/src/images/sharedmemory-example_1.png | Bin 14926 -> 0 bytes doc/src/images/sharedmemory-example_2.png | Bin 21976 -> 0 bytes .../ipc/doc/images/localfortuneclient-example.png | Bin 0 -> 8402 bytes .../ipc/doc/images/localfortuneserver-example.png | Bin 0 -> 5715 bytes examples/ipc/doc/images/sharedmemory-example_1.png | Bin 0 -> 14926 bytes examples/ipc/doc/images/sharedmemory-example_2.png | Bin 0 -> 21976 bytes examples/ipc/doc/src/localfortuneclient.qdoc | 40 +++++++ examples/ipc/doc/src/localfortuneserver.qdoc | 39 ++++++ examples/ipc/doc/src/sharedmemory.qdoc | 131 +++++++++++++++++++++ src/corelib/doc/qtcore.qdocconf | 1 + 15 files changed, 211 insertions(+), 210 deletions(-) delete mode 100644 doc/src/examples/localfortuneclient.qdoc delete mode 100644 doc/src/examples/localfortuneserver.qdoc delete mode 100644 doc/src/examples/sharedmemory.qdoc delete mode 100644 doc/src/images/localfortuneclient-example.png delete mode 100644 doc/src/images/localfortuneserver-example.png delete mode 100644 doc/src/images/sharedmemory-example_1.png delete mode 100644 doc/src/images/sharedmemory-example_2.png create mode 100644 examples/ipc/doc/images/localfortuneclient-example.png create mode 100644 examples/ipc/doc/images/localfortuneserver-example.png create mode 100644 examples/ipc/doc/images/sharedmemory-example_1.png create mode 100644 examples/ipc/doc/images/sharedmemory-example_2.png create mode 100644 examples/ipc/doc/src/localfortuneclient.qdoc create mode 100644 examples/ipc/doc/src/localfortuneserver.qdoc create mode 100644 examples/ipc/doc/src/sharedmemory.qdoc diff --git a/doc/src/examples/localfortuneclient.qdoc b/doc/src/examples/localfortuneclient.qdoc deleted file mode 100644 index ec1306b10a..0000000000 --- a/doc/src/examples/localfortuneclient.qdoc +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example ipc/localfortuneclient - \title Local Fortune Client Example - \ingroup examples-ipc - \brief Demonstrates using QLocalSocket for a simple local service client. - - The Local Fortune Client example shows how to create a client for a simple - local service using QLocalSocket. It is intended to be run alongside the - \l{ipc/localfortuneserver}{Local Fortune Server} example. - - \image localfortuneclient-example.png Screenshot of the Local Fortune Client example - -*/ diff --git a/doc/src/examples/localfortuneserver.qdoc b/doc/src/examples/localfortuneserver.qdoc deleted file mode 100644 index d9828d4145..0000000000 --- a/doc/src/examples/localfortuneserver.qdoc +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example ipc/localfortuneserver - \title Local Fortune Server Example - \ingroup examples-ipc - \brief Demonstrates using QLocalServer and QLocalSocket for serving a simple local service. - - The Local Fortune Server example shows how to create a server for a simple - local service. It is intended to be run alongside the - \l{ipc/localfortuneclient}{Local Fortune Client} example - - \image localfortuneserver-example.png Screenshot of the Local Fortune Server example - */ diff --git a/doc/src/examples/sharedmemory.qdoc b/doc/src/examples/sharedmemory.qdoc deleted file mode 100644 index e8c3f00f26..0000000000 --- a/doc/src/examples/sharedmemory.qdoc +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example ipc/sharedmemory - \title Shared Memory Example - \ingroup examples-ipc - \brief Demonstrates doing inter-process communication using shared memory with - the QSharedMemory class. - - The Shared Memory example shows how to use the QSharedMemory class - to implement inter-process communication using shared memory. To - build the example, run make. To run the example, start two instances - of the executable. The main() function creates an \l {QApplication} - {application} and an instance of our example's Dialog class. The - dialog is displayed and then control is passed to the application in - the standard way. - - \snippet examples/ipc/sharedmemory/main.cpp 0 - - Two instances of class Dialog appear. - - \image sharedmemory-example_1.png Screenshot of the Shared Memory example - - Class Dialog inherits QDialog. It encapsulates the user interface - and an instance of QSharedMemory. It also has two public slots, - loadFromFile() and loadFromMemory() that correspond to the two - buttons on the dialog. - - \snippet examples/ipc/sharedmemory/dialog.h 0 - - The constructor builds the user interface widgets and connects the - clicked() signal of each button to the corresponding slot function. - - \snippet examples/ipc/sharedmemory/dialog.cpp 0 - - Note that "QSharedMemoryExample" is passed to the \l {QSharedMemory} - {QSharedMemory()} constructor to be used as the key. This will be - used by the system as the identifier of the underlying shared memory - segment. - - Click the \tt {Load Image From File...} button on one of the - dialogs. The loadFromFile() slot is invoked. First, it tests whether - a shared memory segment is already attached to the process. If so, - that segment is detached from the process, so we can be assured of - starting off the example correctly. - - \snippet examples/ipc/sharedmemory/dialog.cpp 1 - - The user is then asked to select an image file using - QFileDialog::getOpenFileName(). The selected file is loaded into a - QImage. Using a QImage lets us ensure that the selected file is a - valid image, and it also allows us to immediately display the image - in the dialog using setPixmap(). - - Next the image is streamed into a QBuffer using a QDataStream. This - gives us the size, which we then use to \l {QSharedMemory::} - {create()} our shared memory segment. Creating a shared memory - segment automatically \l {QSharedMemory::attach()} {attaches} the - segment to the process. Using a QBuffer here lets us get a pointer - to the image data, which we then use to do a memcopy() from the - QBuffer into the shared memory segment. - - \snippet examples/ipc/sharedmemory/dialog.cpp 2 - - Note that we \l {QSharedMemory::} {lock()} the shared memory segment - before we copy into it, and we \l {QSharedMemory::} {unlock()} it - again immediately after the copy. This ensures we have exclusive - access to the shared memory segment to do our memcopy(). If some - other process has the segment lock, then our process will block - until the lock becomes available. - - Note also that the function does not \l {QSharedMemory::} {detach()} - from the shared memory segment after the memcopy() and - unlock(). Recall that when the last process detaches from a shared - memory segment, the segment is released by the operating - system. Since this process only one that is attached to the shared - memory segment at the moment, if loadFromFile() detached from the - shared memory segment, the segment would be destroyed before we get - to the next step. - - When the function returns, if the file you selected was qt.png, your - first dialog looks like this. - - \image sharedmemory-example_2.png Screenshot of the Shared Memory example - - In the second dialog, click the \tt {Display Image From Shared - Memory} button. The loadFromMemory() slot is invoked. It first \l - {QSharedMemory::attach()} {attaches} the process to the same shared - memory segment created by the first process. Then it \l - {QSharedMemory::lock()} {locks} the segment for exclusive access and - links a QBuffer to the image data in the shared memory segment. It - then streams the data into a QImage and \l {QSharedMemory::unlock()} - {unlocks} the segment. - - \snippet examples/ipc/sharedmemory/dialog.cpp 3 - - In this case, the function does \l {QSharedMemory::} {detach()} from - the segment, because now we are effectively finished using - it. Finally, the QImage is displayed. At this point, both dialogs - should be showing the same image. When you close the first dialog, - the Dialog destructor calls the QSharedMemory destructor, which - detaches from the shared memory segment. Since this is the last - process to be detached from the segment, the operating system will - now release the shared memory. - - */ diff --git a/doc/src/images/localfortuneclient-example.png b/doc/src/images/localfortuneclient-example.png deleted file mode 100644 index 614784bf0f..0000000000 Binary files a/doc/src/images/localfortuneclient-example.png and /dev/null differ diff --git a/doc/src/images/localfortuneserver-example.png b/doc/src/images/localfortuneserver-example.png deleted file mode 100644 index 2f04c7528e..0000000000 Binary files a/doc/src/images/localfortuneserver-example.png and /dev/null differ diff --git a/doc/src/images/sharedmemory-example_1.png b/doc/src/images/sharedmemory-example_1.png deleted file mode 100644 index 53244d3f52..0000000000 Binary files a/doc/src/images/sharedmemory-example_1.png and /dev/null differ diff --git a/doc/src/images/sharedmemory-example_2.png b/doc/src/images/sharedmemory-example_2.png deleted file mode 100644 index fc71aed56e..0000000000 Binary files a/doc/src/images/sharedmemory-example_2.png and /dev/null differ diff --git a/examples/ipc/doc/images/localfortuneclient-example.png b/examples/ipc/doc/images/localfortuneclient-example.png new file mode 100644 index 0000000000..614784bf0f Binary files /dev/null and b/examples/ipc/doc/images/localfortuneclient-example.png differ diff --git a/examples/ipc/doc/images/localfortuneserver-example.png b/examples/ipc/doc/images/localfortuneserver-example.png new file mode 100644 index 0000000000..2f04c7528e Binary files /dev/null and b/examples/ipc/doc/images/localfortuneserver-example.png differ diff --git a/examples/ipc/doc/images/sharedmemory-example_1.png b/examples/ipc/doc/images/sharedmemory-example_1.png new file mode 100644 index 0000000000..53244d3f52 Binary files /dev/null and b/examples/ipc/doc/images/sharedmemory-example_1.png differ diff --git a/examples/ipc/doc/images/sharedmemory-example_2.png b/examples/ipc/doc/images/sharedmemory-example_2.png new file mode 100644 index 0000000000..fc71aed56e Binary files /dev/null and b/examples/ipc/doc/images/sharedmemory-example_2.png differ diff --git a/examples/ipc/doc/src/localfortuneclient.qdoc b/examples/ipc/doc/src/localfortuneclient.qdoc new file mode 100644 index 0000000000..a68f4bad0c --- /dev/null +++ b/examples/ipc/doc/src/localfortuneclient.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example localfortuneclient + \title Local Fortune Client Example + \ingroup examples-ipc + \brief Demonstrates using QLocalSocket for a simple local service client. + + The Local Fortune Client example shows how to create a client for a simple + local service using QLocalSocket. It is intended to be run alongside the + \l{Local Fortune Server Example}. + + \image localfortuneclient-example.png Screenshot of the Local Fortune Client example + +*/ diff --git a/examples/ipc/doc/src/localfortuneserver.qdoc b/examples/ipc/doc/src/localfortuneserver.qdoc new file mode 100644 index 0000000000..13f7f3ca74 --- /dev/null +++ b/examples/ipc/doc/src/localfortuneserver.qdoc @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example localfortuneserver + \title Local Fortune Server Example + \ingroup examples-ipc + \brief Demonstrates using QLocalServer and QLocalSocket for serving a simple local service. + + The Local Fortune Server example shows how to create a server for a simple + local service. It is intended to be run alongside the + \l{Local Fortune Client Example} + + \image localfortuneserver-example.png Screenshot of the Local Fortune Server example + */ diff --git a/examples/ipc/doc/src/sharedmemory.qdoc b/examples/ipc/doc/src/sharedmemory.qdoc new file mode 100644 index 0000000000..b9f0c86d44 --- /dev/null +++ b/examples/ipc/doc/src/sharedmemory.qdoc @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example sharedmemory + \title Shared Memory Example + \ingroup examples-ipc + \brief Demonstrates doing inter-process communication using shared memory with + the QSharedMemory class. + + The Shared Memory example shows how to use the QSharedMemory class + to implement inter-process communication using shared memory. To + build the example, run make. To run the example, start two instances + of the executable. The main() function creates an \l {QApplication} + {application} and an instance of our example's Dialog class. The + dialog is displayed and then control is passed to the application in + the standard way. + + \snippet sharedmemory/main.cpp 0 + + Two instances of class Dialog appear. + + \image sharedmemory-example_1.png Screenshot of the Shared Memory example + + Class Dialog inherits QDialog. It encapsulates the user interface + and an instance of QSharedMemory. It also has two public slots, + loadFromFile() and loadFromMemory() that correspond to the two + buttons on the dialog. + + \snippet sharedmemory/dialog.h 0 + + The constructor builds the user interface widgets and connects the + clicked() signal of each button to the corresponding slot function. + + \snippet sharedmemory/dialog.cpp 0 + + Note that "QSharedMemoryExample" is passed to the \l {QSharedMemory} + {QSharedMemory()} constructor to be used as the key. This will be + used by the system as the identifier of the underlying shared memory + segment. + + Click the \tt {Load Image From File...} button on one of the + dialogs. The loadFromFile() slot is invoked. First, it tests whether + a shared memory segment is already attached to the process. If so, + that segment is detached from the process, so we can be assured of + starting off the example correctly. + + \snippet sharedmemory/dialog.cpp 1 + + The user is then asked to select an image file using + QFileDialog::getOpenFileName(). The selected file is loaded into a + QImage. Using a QImage lets us ensure that the selected file is a + valid image, and it also allows us to immediately display the image + in the dialog using setPixmap(). + + Next the image is streamed into a QBuffer using a QDataStream. This + gives us the size, which we then use to \l {QSharedMemory::} + {create()} our shared memory segment. Creating a shared memory + segment automatically \l {QSharedMemory::attach()} {attaches} the + segment to the process. Using a QBuffer here lets us get a pointer + to the image data, which we then use to do a memcopy() from the + QBuffer into the shared memory segment. + + \snippet sharedmemory/dialog.cpp 2 + + Note that we \l {QSharedMemory::} {lock()} the shared memory segment + before we copy into it, and we \l {QSharedMemory::} {unlock()} it + again immediately after the copy. This ensures we have exclusive + access to the shared memory segment to do our memcopy(). If some + other process has the segment lock, then our process will block + until the lock becomes available. + + Note also that the function does not \l {QSharedMemory::} {detach()} + from the shared memory segment after the memcopy() and + unlock(). Recall that when the last process detaches from a shared + memory segment, the segment is released by the operating + system. Since this process only one that is attached to the shared + memory segment at the moment, if loadFromFile() detached from the + shared memory segment, the segment would be destroyed before we get + to the next step. + + When the function returns, if the file you selected was qt.png, your + first dialog looks like this. + + \image sharedmemory-example_2.png Screenshot of the Shared Memory example + + In the second dialog, click the \tt {Display Image From Shared + Memory} button. The loadFromMemory() slot is invoked. It first \l + {QSharedMemory::attach()} {attaches} the process to the same shared + memory segment created by the first process. Then it \l + {QSharedMemory::lock()} {locks} the segment for exclusive access and + links a QBuffer to the image data in the shared memory segment. It + then streams the data into a QImage and \l {QSharedMemory::unlock()} + {unlocks} the segment. + + \snippet sharedmemory/dialog.cpp 3 + + In this case, the function does \l {QSharedMemory::} {detach()} from + the segment, because now we are effectively finished using + it. Finally, the QImage is displayed. At this point, both dialogs + should be showing the same image. When you close the first dialog, + the Dialog destructor calls the QSharedMemory destructor, which + detaches from the shared memory segment. Since this is the last + process to be detached from the segment, the operating system will + now release the shared memory. + + */ diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 2ad24d33b1..18342d0138 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -37,6 +37,7 @@ exampledirs += \ snippets \ ../../../examples/threads/ \ ../../../examples/tools/ \ + ../../../examples/ipc/ \ ../../../examples/json/ \ ../../../examples/network/dnslookup -- cgit v1.2.3 From 76eefbe8af7655f8d6979069aea07e4cb32c6ee8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 24 Mar 2014 15:08:58 +0100 Subject: Android: Fix missing data from some autotests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a test ended, we would instantly try to fetch its output, but at this point, it might still not be available through the adb interface, probably due to some cache synchronization in the file system? Adding an arbitrary three second pause between finishing the test and requesting the file fixes this. If the error pops up later again, we could do something more robust, like going in a loop for X seconds until the file has been fetched. Especially if detecting task finish was successful. Task-number: QTBUG-37444 Change-Id: I5442e1e0181f489b0626834a390e46c15bc0b371 Reviewed-by: Simo Fält --- tests/auto/android/runtests_androiddeployqt.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl index 1cc52d0495..3d57dcfd65 100755 --- a/tests/auto/android/runtests_androiddeployqt.pl +++ b/tests/auto/android/runtests_androiddeployqt.pl @@ -217,6 +217,10 @@ sub startTest print "Someone should kill $packageName\n"; return 1; } + + # Wait for three seconds to allow process to write all data + sleep(3); + system("$adb_tool $device_serial pull /data/data/$packageName/output.xml $output_dir/$output_file.xml") if ($get_xml); system("$adb_tool $device_serial pull /data/data/$packageName/output.txt $output_dir/$output_file.txt") if ($get_txt); return 1; -- cgit v1.2.3 From d1ed2dee51ce1843e53912e250bc75b34b5bb0da Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 26 Mar 2014 10:07:59 +0100 Subject: Android: REG: Fix launching intents When the launch mode is singleInstance, then intents will not be launched as activities inside the same task, but as separate tasks, and onActivityResult() is always called immediately without any data. This is documented in various stack overflows and google group messages if you search for it on the Internet, and the singleInstance launch mode is documented as "not recommended for normal use". This broke e.g. automatic downloads of Ministro. The singleTop launch mode seems more like what we're after, and fixes both the original issue as well as the current problem with intents. Change-Id: Iab24a654a4433f979064509b1ef721db9ef352af Reviewed-by: BogDan Vatra --- src/android/java/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/java/AndroidManifest.xml b/src/android/java/AndroidManifest.xml index 1741101bc1..8e551ba7ac 100644 --- a/src/android/java/AndroidManifest.xml +++ b/src/android/java/AndroidManifest.xml @@ -5,7 +5,7 @@ android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:screenOrientation="unspecified" - android:launchMode="singleInstance"> + android:launchMode="singleTop"> -- cgit v1.2.3 From e7270b68fe36528ba064e0f371f00988b443d1c0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 26 Mar 2014 13:00:26 +0100 Subject: Doc: Update year to 2014 Change-Id: Iae2f31232fb364b26aa4da99048d92c262b4fdec Reviewed-by: Sergio Ahumada Reviewed-by: Jerome Pasion --- doc/global/config.qdocconf | 2 +- doc/global/html-footer.qdocconf | 2 +- src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc | 2 +- src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/global/config.qdocconf b/doc/global/config.qdocconf index 2b3ca1d6ba..8629b89e7e 100644 --- a/doc/global/config.qdocconf +++ b/doc/global/config.qdocconf @@ -3,7 +3,7 @@ dita.metadata.default.author = Qt Project dita.metadata.default.permissions = all dita.metadata.default.publisher = Qt Project -dita.metadata.default.copyryear = 2013 +dita.metadata.default.copyryear = 2014 dita.metadata.default.copyrholder = Digia Plc dita.metadata.default.audience = programmer diff --git a/doc/global/html-footer.qdocconf b/doc/global/html-footer.qdocconf index c53eb2f599..a77950ff99 100644 --- a/doc/global/html-footer.qdocconf +++ b/doc/global/html-footer.qdocconf @@ -8,7 +8,7 @@ HTML.footer = \ "\n" \ "
\n" \ "

\n" \ - " © 2013 Digia Plc and/or its\n" \ + " © 2014 Digia Plc and/or its\n" \ " subsidiaries. Documentation contributions included herein are the copyrights of\n" \ " their respective owners.
" \ " The documentation provided herein is licensed under the terms of the" \ diff --git a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc index ee0a7b41db..fe43938968 100644 --- a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc @@ -3775,7 +3775,7 @@ Qt Development Frameworks Qt Project - + Qt Project diff --git a/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc b/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc index 3adcf9b213..a28e65e976 100644 --- a/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc @@ -1569,7 +1569,7 @@ dita.metadata.default.author = Qt Development Frameworks dita.metadata.default.permissions = all dita.metadata.default.publisher = Qt Project - dita.metadata.default.copyryear = 2013 + dita.metadata.default.copyryear = 2014 dita.metadata.default.copyrholder = Qt Project dita.metadata.default.audience = programmer \endcode -- cgit v1.2.3 From b3f201b8afcf88015f5bff7b3f43e90b13f8a8f1 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 25 Mar 2014 17:31:09 +0100 Subject: Android: use fbo read back workaround with specific GPUs. Namely, the Mali 400 and the Adreno 200. We used to enable this workaround only for the Samsung Galaxy Tab 3, which has a Mali 400. The same problem was confirmed with the Samsung Galaxy Note N7000 (Mali 400) and the ZTE Blade (Adreno 200). Task-number: QTBUG-33951 Task-number: QTBUG-34984 Change-Id: Ic624962986f718285b98ab4ca48e22f9aa110753 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Shawn Rutledge --- .../platforms/android/qandroidplatformintegration.cpp | 4 ++-- .../platforms/android/qandroidplatformintegration.h | 2 +- .../android/qandroidplatformopenglcontext.cpp | 18 +++++++++++++++++- .../platforms/android/qandroidplatformopenglcontext.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 9adefd5b2c..a06f69b8d5 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -132,7 +132,7 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidSystemLocale = new QAndroidSystemLocale; } -bool QAndroidPlatformIntegration::needsWorkaround() +bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() { static bool needsWorkaround = QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 @@ -150,7 +150,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case OpenGL: return true; case ForeignWindows: return true; case ThreadedOpenGL: - if (needsWorkaround()) + if (needsBasicRenderloopWorkaround()) return false; else return true; diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index 2d685bc567..4a3fe6c766 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -120,9 +120,9 @@ public: QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } - static bool needsWorkaround(); EGLDisplay m_eglDisplay; private: + static bool needsBasicRenderloopWorkaround(); QTouchDevice *m_touchDevice; diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index a0b3ae066c..289480c625 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -62,6 +62,22 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) static_cast(surface)->checkNativeSurface(eglConfig()); } +bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaroud() +{ + static bool set = false; + static bool needsWorkaround = false; + + if (!set) { + const char *rendererString = reinterpret_cast(glGetString(GL_RENDERER)); + needsWorkaround = + qstrcmp(rendererString, "Mali-400 MP") == 0 + || qstrcmp(rendererString, "Adreno (TM) 200") == 0; + set = true; + } + + return needsWorkaround; +} + bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) { bool ret = QEGLPlatformContext::makeCurrent(surface); @@ -71,7 +87,7 @@ bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) ctx_d->workaround_missingPrecisionQualifiers = true; - if (!ctx_d->workaround_brokenFBOReadBack && QAndroidPlatformIntegration::needsWorkaround()) + if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaroud()) ctx_d->workaround_brokenFBOReadBack = true; return ret; diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h index 29e5f596d5..10a89d541b 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h @@ -56,6 +56,8 @@ public: private: virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); + + static bool needsFBOReadBackWorkaroud(); }; QT_END_NAMESPACE -- cgit v1.2.3 From 3c68252bf58a80fcf75fffcc2e0c976b1aa172fb Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Thu, 27 Mar 2014 01:50:11 +1100 Subject: Doc: Fix typos Change-Id: I720813b126f02d4813c88811316a0fa99961c6d8 Reviewed-by: Friedemann Kleint --- src/gui/opengl/qopenglpaintdevice.cpp | 2 +- src/opengl/doc/src/qtopengl-index.qdoc | 2 +- src/xml/doc/src/qtxml-index.qdoc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index fa392d16aa..6750458f83 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE multisampling. Most hardware require significantly more memory to do multisampling and the resulting quality is not on par with the quality of the software paint engine. The OpenGL paint engine's - strenght lies in its performance, not its visual rendering + strength lies in its performance, not its visual rendering quality. \section1 State Changes diff --git a/src/opengl/doc/src/qtopengl-index.qdoc b/src/opengl/doc/src/qtopengl-index.qdoc index fc131c4b17..ff946c6e4e 100644 --- a/src/opengl/doc/src/qtopengl-index.qdoc +++ b/src/opengl/doc/src/qtopengl-index.qdoc @@ -68,5 +68,5 @@ non-OpenGL-specific GUI functionality. The \l{Qt OpenGL C++ Classes} page gives an overview over the available classes - int this module. + in this module. */ diff --git a/src/xml/doc/src/qtxml-index.qdoc b/src/xml/doc/src/qtxml-index.qdoc index ded8f3de3c..76866ad66b 100644 --- a/src/xml/doc/src/qtxml-index.qdoc +++ b/src/xml/doc/src/qtxml-index.qdoc @@ -44,5 +44,5 @@ \snippet code/doc_src_qtxml.pro 1 The \l{Qt XML C++ Classes} page gives an overview over the available classes - int this module. + in this module. */ -- cgit v1.2.3 From bd9f490d4552fa4d41c308bf3ee285d26d2019b6 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 25 Mar 2014 15:01:16 +0100 Subject: Disable non-fullscreen windows for WinRT The integration seems to have been missing this flag. Hence we tried to open new windows in non-fullscreen mode causing lots of issues. For instance this resolves QCombobox popup problems. Task-number: QTBUG-37593 Change-Id: I3d3e3699dff91dcb95613893c2a5bdefc90131b7 Reviewed-by: Andrew Knight --- src/plugins/platforms/winrt/qwinrtintegration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index be82390723..b3a2cafa2e 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -124,6 +124,8 @@ bool QWinRTIntegration::hasCapability(QPlatformIntegration::Capability cap) cons case OpenGL: case ApplicationState: return true; + case NonFullScreenWindows: + return false; default: return QPlatformIntegration::hasCapability(cap); } -- cgit v1.2.3 From 18d031fb1896001a9edbd42edfa8b2b7a6ba9825 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Sat, 22 Mar 2014 08:22:25 +0200 Subject: Don't create screen surface if there are no raster windows. Change-Id: Idaf5df814bb087707654d7ad7046ba8799f99c0a Reviewed-by: Sean Harmer Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 3 ++- src/plugins/platforms/android/qandroidplatformscreen.cpp | 13 +++++++++++-- src/plugins/platforms/android/qandroidplatformscreen.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 784cc2e38b..ff1a40bfc5 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -576,7 +576,8 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/) } QAndroidPlatformScreen *screen = static_cast(m_androidPlatformIntegration->screen()); - QMetaObject::invokeMethod(screen, "setDirty", Qt::QueuedConnection, Q_ARG(QRect,screen->geometry())); + if (screen->rasterSurfaces()) + QMetaObject::invokeMethod(screen, "setDirty", Qt::QueuedConnection, Q_ARG(QRect,screen->geometry())); } static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state) diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index dbf317696f..678f4e6b5a 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -133,8 +133,10 @@ void QAndroidPlatformScreen::addWindow(QAndroidPlatformWindow *window) return; m_windowStack.prepend(window); - if (window->isRaster()) + if (window->isRaster()) { + m_rasterSurfaces.ref(); setDirty(window->geometry()); + } QWindow *w = topWindow(); QWindowSystemInterface::handleWindowActivated(w); @@ -148,8 +150,10 @@ void QAndroidPlatformScreen::removeWindow(QAndroidPlatformWindow *window) m_windowStack.removeOne(window); if (window->isRaster()) { + m_rasterSurfaces.deref(); setDirty(window->geometry()); } + QWindow *w = topWindow(); QWindowSystemInterface::handleWindowActivated(w); topWindowChanged(w); @@ -238,6 +242,11 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) } } +int QAndroidPlatformScreen::rasterSurfaces() +{ + return m_rasterSurfaces; +} + void QAndroidPlatformScreen::doRedraw() { PROFILE_SCOPE; @@ -246,7 +255,7 @@ void QAndroidPlatformScreen::doRedraw() return; QMutexLocker lock(&m_surfaceMutex); - if (m_id == -1) { + if (m_id == -1 && m_rasterSurfaces) { m_id = QtAndroid::createSurface(this, m_geometry, true, m_depth); m_surfaceWaitCondition.wait(&m_surfaceMutex); } diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h index 625e77840e..96a91fbf06 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.h +++ b/src/plugins/platforms/android/qandroidplatformscreen.h @@ -82,6 +82,7 @@ public: void scheduleUpdate(); void topWindowChanged(QWindow *w); + int rasterSurfaces(); public slots: void setDirty(const QRect &rect); @@ -110,6 +111,7 @@ private slots: private: int m_id = -1; + QAtomicInt m_rasterSurfaces = 0; ANativeWindow* m_nativeSurface = nullptr; QWaitCondition m_surfaceWaitCondition; }; -- cgit v1.2.3 From 13b38ac661f936c9cbd7af1f7851f82afb2634b9 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 27 Mar 2014 09:14:53 +0200 Subject: Android: registerTouchDevice at startup I'd like to keep registerTouchDevice from androidjniinput.cpp, touchEnd as a backup for buggy Android devices that are not setting Configurations.touchscreen field correctly. Task-number: QTBUG-36007 Change-Id: Ib8f107474baa278b2d82d9ca14913512dfff01c2 Reviewed-by: Shawn Rutledge --- .../android/qandroidplatformintegration.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index a06f69b8d5..6395f71398 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -41,6 +41,7 @@ #include "qandroidplatformintegration.h" +#include #include #include #include @@ -130,6 +131,38 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ #endif m_androidSystemLocale = new QAndroidSystemLocale; + + QJNIObjectPrivate javaActivity(QtAndroid::activity()); + if (javaActivity.isValid()) { + QJNIObjectPrivate resources = javaActivity.callObjectMethod("getResources", "()Landroid/content/res/Resources;"); + QJNIObjectPrivate configuration = resources.callObjectMethod("getConfiguration", "()Landroid/content/res/Configuration;"); + + int touchScreen = configuration.getField("touchscreen"); + if (touchScreen == QJNIObjectPrivate::getStaticField("android/content/res/Configuration", "TOUCHSCREEN_FINGER") + || touchScreen == QJNIObjectPrivate::getStaticField("android/content/res/Configuration", "TOUCHSCREEN_STYLUS")) + { + m_touchDevice = new QTouchDevice; + m_touchDevice->setType(QTouchDevice::TouchScreen); + m_touchDevice->setCapabilities(QTouchDevice::Position + | QTouchDevice::Area + | QTouchDevice::Pressure + | QTouchDevice::NormalizedPosition); + + QJNIObjectPrivate pm = javaActivity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;"); + Q_ASSERT(pm.isValid()); + if (pm.callMethod("hasSystemFeature","(Ljava/lang/String;)Z", + QJNIObjectPrivate::getStaticObjectField("android/content/pm/PackageManager", "FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND", "Ljava/lang/String;").object())) { + m_touchDevice->setMaximumTouchPoints(10); + } else if (pm.callMethod("hasSystemFeature","(Ljava/lang/String;)Z", + QJNIObjectPrivate::getStaticObjectField("android/content/pm/PackageManager", "FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT", "Ljava/lang/String;").object())) { + m_touchDevice->setMaximumTouchPoints(4); + } else if (pm.callMethod("hasSystemFeature","(Ljava/lang/String;)Z", + QJNIObjectPrivate::getStaticObjectField("android/content/pm/PackageManager", "FEATURE_TOUCHSCREEN_MULTITOUCH", "Ljava/lang/String;").object())) { + m_touchDevice->setMaximumTouchPoints(2); + } + QWindowSystemInterface::registerTouchDevice(m_touchDevice); + } + } } bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() -- cgit v1.2.3 From bc2e7054ef10a25a9bdc11c66eacf9c118c232a6 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 27 Mar 2014 10:30:50 +0200 Subject: Android: Change Ministro's source to 5.3 Task-number: QTBUG-37879 Change-Id: If9a3f38a5dc267862a166ac4c8e6940739eab911 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/java/res/values/libs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/java/res/values/libs.xml b/src/android/java/res/values/libs.xml index 797e6bb8c4..664ab0abec 100644 --- a/src/android/java/res/values/libs.xml +++ b/src/android/java/res/values/libs.xml @@ -1,7 +1,7 @@ - https://download.qt-project.org/ministro/android/qt5/qt-5.2 + https://download.qt-project.org/ministro/android/qt5/qt-5.3