From 14e138652d04f43d6da8fb2fee3ed9ba8b8fdfce Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 2 Dec 2015 16:00:45 +0100 Subject: [PATCH 01/36] eglfs: Fix the logical dpi calculation for some devices KMS and backends using the default logicalDpi() implementation (EGLDevice for instance) did not correctly check if the physical width and height are greater than zero. The result is a NaN dpi on systems where the drivers report a zero size. This in turn breaks font rendering and various other things. isValid() is changed to !isEmpty(). This way we check for width and height > 0 instead of >= 0. Change-Id: I8cdcf93a116379ae33c65599ad792a3b712518a3 Reviewed-by: Louai Al-Khanji --- .../eglfs_kms/qeglfskmsscreen.cpp | 6 +++--- .../qeglfskmsegldeviceintegration.cpp | 14 +++++++++++++- .../platforms/eglfs/qeglfsdeviceintegration.cpp | 11 +++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp index 60586f98a7..048f5433dc 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp @@ -160,10 +160,10 @@ QSizeF QEglFSKmsScreen::physicalSize() const QDpi QEglFSKmsScreen::logicalDpi() const { - QSizeF ps = physicalSize(); - QSize s = geometry().size(); + const QSizeF ps = physicalSize(); + const QSize s = geometry().size(); - if (ps.isValid() && s.isValid()) + if (!ps.isEmpty() && !s.isEmpty()) return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); else diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index 1ddcb3b862..f7450708ab 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -33,6 +33,7 @@ #include "qeglfskmsegldeviceintegration.h" #include +#include QT_BEGIN_NAMESPACE @@ -115,7 +116,18 @@ EGLDisplay QEglFSKmsEglDeviceIntegration::createDisplay(EGLNativeDisplayType nat QSizeF QEglFSKmsEglDeviceIntegration::physicalScreenSize() const { - return QSizeF(m_drm_connector->mmWidth, m_drm_connector->mmHeight); + const int defaultPhysicalDpi = 100; + static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); + static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); + QSizeF size(width, height); + if (size.isEmpty()) { + size = QSizeF(m_drm_connector->mmWidth, m_drm_connector->mmHeight); + if (size.isEmpty()) { + const float pixelsPerMm = Q_MM_PER_INCH / defaultPhysicalDpi; + size = QSizeF(screenSize().width() * pixelsPerMm, screenSize().height() * pixelsPerMm); + } + } + return size; } QSize QEglFSKmsEglDeviceIntegration::screenSize() const diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index 064b9f6306..8af48a893b 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp @@ -212,11 +212,14 @@ QSize QEGLDeviceIntegration::screenSize() const QDpi QEGLDeviceIntegration::logicalDpi() const { - QSizeF ps = physicalScreenSize(); - QSize s = screenSize(); + const QSizeF ps = physicalScreenSize(); + const QSize s = screenSize(); - return QDpi(25.4 * s.width() / ps.width(), - 25.4 * s.height() / ps.height()); + if (!ps.isEmpty() && !s.isEmpty()) + return QDpi(25.4 * s.width() / ps.width(), + 25.4 * s.height() / ps.height()); + else + return QDpi(100, 100); } qreal QEGLDeviceIntegration::pixelDensity() const From afaa7351c0f7f19c86796e9e48e2d16dbf5e4aa9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 3 Dec 2015 09:28:23 +0100 Subject: [PATCH 02/36] QStandardPaths::standardLocations()/WinRT: Return empty lists. Previously, lists containing one empty string were returned for the unimplemented functions. Change-Id: Ia64b53325420e32076f2bacf22c48885d7121df0 Reviewed-by: Maurice Kalinowski --- src/corelib/io/qstandardpaths_winrt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp index b1e51c5082..cb4d1dd152 100644 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ b/src/corelib/io/qstandardpaths_winrt.cpp @@ -123,7 +123,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) QStringList QStandardPaths::standardLocations(StandardLocation type) { - return QStringList(writableLocation(type)); + const QString writable = writableLocation(type); + return writable.isEmpty() ? QStringList() : QStringList(writable); } QT_END_NAMESPACE From b07c10c5de0161208a75bba3c5470614538dfb6e Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 17 Nov 2015 11:18:19 +0000 Subject: [PATCH 03/36] Revert "Doc: Added info about sorting in QItemSelectionModel::selectedIndexes" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d0f57439d02582cf7564d1509d13f715eadc7f05. This commit had introduced a wrong statement about the sorting. Change-Id: I2f6ea6f7cfb318bca7bd44c686956ba135b65b20 Reviewed-by: Topi Reiniö --- src/corelib/itemmodels/qitemselectionmodel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 222e722c06..51c670f79e 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1646,7 +1646,6 @@ QModelIndexList QItemSelectionModel::selectedIndexes() const /*! \since 4.2 Returns the indexes in the given \a column for the rows where all columns are selected. - The list is not sorted. \sa selectedIndexes(), selectedColumns() */ From 8724dc5eacfc92cb2cf92540fa5022cd1c93a43a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 27 Nov 2015 14:55:00 +0100 Subject: [PATCH 04/36] Doc: added doc for missing stylesheet outline properties. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-26673 Change-Id: Iaf13921515981c09a84822e66fd1ed21d73779f6 Reviewed-by: Topi Reiniö --- .../src/widgets-and-layouts/stylesheet.qdoc | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 843807b67c..2fb6819c47 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -2185,6 +2185,54 @@ \snippet code/doc_src_stylesheet.qdoc 68 + \row + \li \b outline + \li + \li The outline drawn around the object's border. + + \row + \li \b outline-color + \li \l{#Color}{Color} + \li The color of the outline. + See also \l{Qt Style Sheets Reference#border-color-prop}{border-color} + + \row + \li \b outline-offset + \li \l{#Length}{Length} + \li The outline's offset from the border of the widget. + + \row + \li \b outline-style + \li + \li Specifies the pattern used to draw the outline. + See also \l{Qt Style Sheets Reference#border-style-prop}{border-style} + + \row + \li \b outline-radius + \li + \li Adds rounded corners to the outline + + \row + \li \b outline-bottom-left-radius + \li \l{#Radius}{Radius} + \li The radius for the bottom-left rounded corner of the outline. + + \row + \li \b outline-bottom-right-radius + \li \l{#Radius}{Radius} + \li The radius for the bottom-right rounded corner of the outline. + + \row + \li \b outline-top-left-radius + \li \l{#Radius}{Radius} + \li The radius for the top-left corner of the outline. + + \row + \li \b outline-top-right-radius + \li \l{#Radius}{Radius} + \li The radius for the top-right rounded corner of the outline. + + \row \li \b{\c padding} \target padding-prop \li \l{#Box Lengths}{Box Lengths} From 1c720be3fb3cf31be697e5da042b00ef9e92f1d7 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 23 Nov 2015 14:41:22 +0100 Subject: [PATCH 05/36] Doc: corrected statement about QByteArray::clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-45096 Change-Id: I30a49044690c2f0ef5bf6ee80712e1395c60ac77 Reviewed-by: Topi Reiniö --- src/corelib/tools/qbytearray.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index a9f361c205..00d15fd518 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -2883,9 +2883,9 @@ QByteArray QByteArray::toUpper_helper(QByteArray &a) /*! \fn void QByteArray::clear() - Clears the contents of the byte array and makes it empty. + Clears the contents of the byte array and makes it null. - \sa resize(), isEmpty() + \sa resize(), isNull() */ void QByteArray::clear() From eb812cf3ceb49084bbde73f014a75eee7feaccb3 Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Thu, 3 Dec 2015 12:43:09 +0100 Subject: [PATCH 06/36] Updating the Toradex Colibri mkspec Change-Id: I7d7256689e2b6ce4fa8930b62397b2d48d8984d6 Reviewed-by: Friedemann Kleint --- mkspecs/wince80colibri-armv7-msvc2012/qmake.conf | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf b/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf index ea86bc0071..3712c94778 100644 --- a/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf +++ b/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf @@ -5,11 +5,11 @@ include(../common/wince/qmake.conf) -CE_SDK = Toradex_CE8_SDK # replace with actual SDK name +CE_SDK = Toradex_CE800 # replace with actual SDK name CE_ARCH = ARMV7 QT_CONFIG -= accessibility -DEFINES += QT_NO_CLIPBOARD QT_NO_ACCESSIBILITY QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x800 $$CE_ARCH _AMRV7_ armv7 _ARM_ UNDER_CE WINCE ARM +DEFINES += QT_NO_CLIPBOARD QT_NO_ACCESSIBILITY QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x800 $$CE_ARCH _AMRV7_ armv7 _ARM_ UNDER_CE WINCE ARM QT_NO_WINCE_SHELLSDK QT_NO_WINCE_NUIOUSER #QMAKE_CXXFLAGS += /P QMAKE_CFLAGS_RELEASE += -O2 -MT @@ -25,7 +25,7 @@ QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -MD QMAKE_CXXFLAGS_DEBUG -= -MDd QMAKE_CXXFLAGS_DEBUG += -MTd QMAKE_INCDIR_OPENGL_ES2 += $$(NV_WINCE_T2_PLAT)/include -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,8.00 /MACHINE:ARM /ENTRY:mainCRTStartup +QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,8.00 /MACHINE:ARM QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,8.00 /MACHINE:ARM QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,8.00 /MACHINE:ARM /DLL /SAFESEH:NO QMAKE_LIBFLAGS_RELEASE = /LTCG @@ -33,13 +33,10 @@ QMAKE_LIBS = coredll.lib QMAKE_LIBS_CORE = ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib QMAKE_LIBS_GUI = ole32.lib $$QMAKE_LIBS_CORE QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI -QMAKE_LIBS_OPENGL = -QMAKE_LIBS_COMPAT = -QMAKE_LIBS_OPENVG = QMAKE_LIBS_OPENGL_ES2 = $${LIBEGL_NAME}.lib $${LIBGLESV2_NAME}.lib -QMAKE_LIBDIR_OPENGL_ES2 = $$(NV_WINCE_T2_PLAT)/lib/Test -QMAKE_INCDIR_EGL = $$(NV_WINCE_T2_PLAT)/include -QMAKE_LIBDIR_EGL = $$(NV_WINCE_T2_PLAT)/lib/Test + +MAKEFILE_GENERATOR = MSBUILD +VCPROJ_EXTENSION = .vcxproj QMAKE_RC = rc From ba40d1a872dabb323c1c901929d5db6da1fc5059 Mon Sep 17 00:00:00 2001 From: Samuel Nevala Date: Mon, 30 Nov 2015 15:49:36 +0200 Subject: [PATCH 07/36] Combine environment variable implementations Environment variable storage implementations on Windows Runtime and CE are very similar. For better maintainability have just one implementation. Change-Id: I12ec38f7bde3fcc0bcc56face88d5f19cf3b3504 Reviewed-by: Marc Mutz Reviewed-by: Andreas Holzammer Reviewed-by: Friedemann Kleint Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/kernel.pri | 2 + src/corelib/kernel/qfunctions_fake_env_p.h | 101 +++++++++++++++++++++ src/corelib/kernel/qfunctions_wince.cpp | 50 +--------- src/corelib/kernel/qfunctions_wince.h | 32 +++---- src/corelib/kernel/qfunctions_winrt.cpp | 51 +---------- src/corelib/kernel/qfunctions_winrt.h | 16 ++-- 6 files changed, 129 insertions(+), 123 deletions(-) create mode 100644 src/corelib/kernel/qfunctions_fake_env_p.h diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index f09fa4debc..bc93791c2e 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -88,6 +88,7 @@ wince { SOURCES += \ kernel/qfunctions_wince.cpp HEADERS += \ + kernel/qfunctions_fake_env_p.h \ kernel/qfunctions_wince.h } @@ -95,6 +96,7 @@ winrt { SOURCES += \ kernel/qfunctions_winrt.cpp HEADERS += \ + kernel/qfunctions_fake_env_p.h \ kernel/qfunctions_winrt.h } diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h new file mode 100644 index 0000000000..8b1ab44696 --- /dev/null +++ b/src/corelib/kernel/qfunctions_fake_env_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFUNCTIONS_FAKE_ENV_P_H +#define QFUNCTIONS_FAKE_ENV_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qbytearray.h" +#include "qhash.h" + +QT_BEGIN_NAMESPACE + +// Environment ------------------------------------------------------ +Q_CORE_EXPORT QHash &qt_app_environment() +{ + static QHash internalEnvironment; + return internalEnvironment; +} + +errno_t qt_fake_getenv_s(size_t *sizeNeeded, char *buffer, size_t bufferSize, const char *varName) +{ + if (!sizeNeeded) + return EINVAL; + + QHash::const_iterator iterator = qt_app_environment().constFind(varName); + if (iterator == qt_app_environment().constEnd()) { + if (buffer) + buffer[0] = '\0'; + return ENOENT; + } + + const int size = iterator->size() + 1; + if (bufferSize < size_t(size)) { + *sizeNeeded = size; + return ERANGE; + } + + qstrcpy(buffer, iterator->constData()); + return 0; +} + +errno_t qt_fake__putenv_s(const char *varName, const char *value) +{ + QHash::iterator iterator = qt_app_environment().find(varName); + QHash::iterator end = qt_app_environment().end(); + if (!value || !*value) { + if (iterator != end) + qt_app_environment().erase(iterator); + } else { + if (iterator == end) + qt_app_environment()[varName] = QByteArray(value); + else + (*iterator) = value; + } + + return 0; +} + +QT_END_NAMESPACE + +#endif // QFUNCTIONS_FAKE_ENV_P_H diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 2503a262cd..0619503c51 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -44,9 +44,8 @@ #include "qplatformdefs.h" #include "qfunctions_wince.h" +#include "qfunctions_fake_env_p.h" #include "qstring.h" -#include "qbytearray.h" -#include "qhash.h" QT_USE_NAMESPACE @@ -399,51 +398,4 @@ int qt_wince__getpid() #ifdef __cplusplus } // extern "C" #endif -// Environment ------------------------------------------------------ -inline QHash& qt_app_environment() -{ - static QHash internalEnvironment; - return internalEnvironment; -} - -errno_t qt_wince_getenv_s(size_t* sizeNeeded, char* buffer, size_t bufferSize, const char* varName) -{ - if (!sizeNeeded) - return EINVAL; - - if (!qt_app_environment().contains(varName)) { - if (buffer) - buffer[0] = '\0'; - return ENOENT; - } - - QByteArray value = qt_app_environment().value(varName); - if (!value.endsWith('\0')) // win32 guarantees terminated string - value.append('\0'); - - if (bufferSize < (size_t)value.size()) { - *sizeNeeded = value.size(); - return 0; - } - - strcpy(buffer, value.constData()); - return 0; -} - -errno_t qt_wince__putenv_s(const char* varName, const char* value) -{ - QByteArray input = value; - if (input.isEmpty()) { - if (qt_app_environment().contains(varName)) - qt_app_environment().remove(varName); - } else { - // win32 guarantees terminated string - if (!input.endsWith('\0')) - input.append('\0'); - qt_app_environment()[varName] = input; - } - - return 0; -} - #endif // Q_OS_WINCE diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h index 4273070c11..347f57f95d 100644 --- a/src/corelib/kernel/qfunctions_wince.h +++ b/src/corelib/kernel/qfunctions_wince.h @@ -76,8 +76,8 @@ QT_END_NAMESPACE #endif // Environment ------------------------------------------------------ -errno_t qt_wince_getenv_s(size_t*, char*, size_t, const char*); -errno_t qt_wince__putenv_s(const char*, const char*); +errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*); +errno_t qt_fake__putenv_s(const char*, const char*); #ifdef __cplusplus // have this as tiff plugin is written in C extern "C" { @@ -398,20 +398,20 @@ typedef DWORD OLE_COLOR; { \ return qt_wince_##funcname(p1); \ } -#define generate_inline_return_func2(funcname, returntype, param1, param2) \ +#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \ inline returntype funcname(param1 p1, param2 p2) \ { \ - return qt_wince_##funcname(p1, p2); \ + return prependnamespace##funcname(p1, p2); \ } #define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \ inline returntype funcname(param1 p1, param2 p2, param3 p3) \ { \ return qt_wince_##funcname(p1, p2, p3); \ } -#define generate_inline_return_func4(funcname, returntype, param1, param2, param3, param4) \ +#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \ inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \ { \ - return qt_wince_##funcname(p1, p2, p3, p4); \ + return prependnamespace##funcname(p1, p2, p3, p4); \ } #define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \ inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ @@ -433,28 +433,28 @@ typedef unsigned (__stdcall *StartAdressExFunc)(void *); typedef void(*StartAdressFunc)(void *); typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ; -generate_inline_return_func4(getenv_s, errno_t, size_t *, char *, size_t, const char *) -generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *) +generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *) +generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *) generate_inline_return_func0(_getpid, int) generate_inline_return_func1(time_tToFt, FILETIME, time_t) generate_inline_return_func1(ftToTime_t, time_t, FILETIME) generate_inline_return_func0(_getdrive, int) -generate_inline_return_func2(_waccess, int, const wchar_t *, int) +generate_inline_return_func2(_waccess, int, qt_wince_, const wchar_t *, int) generate_inline_return_func3(_wopen, int, const wchar_t *, int, int) -generate_inline_return_func2(_fdopen, FILE *, int, const char *) -generate_inline_return_func2(fdopen, FILE *, int, const char *) +generate_inline_return_func2(_fdopen, FILE *, qt_wince_, int, const char *) +generate_inline_return_func2(fdopen, FILE *, qt_wince_, int, const char *) generate_inline_return_func1(rewind, void, FILE *) generate_inline_return_func0(tmpfile, FILE *) -generate_inline_return_func2(_rename, int, const char *, const char *) +generate_inline_return_func2(_rename, int, qt_wince_, const char *, const char *) generate_inline_return_func1(_remove, int, const char *) generate_inline_return_func1(SetErrorMode, int, int) #if _WIN32_WCE < 0x800 -generate_inline_return_func2(_chmod, bool, const char *, int) -generate_inline_return_func2(_wchmod, bool, const wchar_t *, int) +generate_inline_return_func2(_chmod, bool, qt_wince_, const char *, int) +generate_inline_return_func2(_wchmod, bool, qt_wince_, const wchar_t *, int) #endif generate_inline_return_func7(CreateFileA, HANDLE, LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE) -generate_inline_return_func4(SetWindowOrgEx, BOOL, HDC, int, int, LPPOINT) -generate_inline_return_func2(calloc, void *, size_t, size_t) +generate_inline_return_func4(SetWindowOrgEx, BOOL, qt_wince_, HDC, int, int, LPPOINT) +generate_inline_return_func2(calloc, void *, qt_wince_, size_t, size_t) generate_inline_return_func0(GetThreadLocale, DWORD) generate_inline_return_func3(_beginthread, HANDLE, StartAdressFunc, unsigned, void *) generate_inline_return_func6(_beginthreadex, unsigned long, void *, unsigned, StartAdressExFunc, void *, unsigned, unsigned *) diff --git a/src/corelib/kernel/qfunctions_winrt.cpp b/src/corelib/kernel/qfunctions_winrt.cpp index ea7f2ac671..f8fa19464f 100644 --- a/src/corelib/kernel/qfunctions_winrt.cpp +++ b/src/corelib/kernel/qfunctions_winrt.cpp @@ -35,59 +35,10 @@ #ifdef Q_OS_WINRT -#include "qstring.h" -#include "qbytearray.h" -#include "qhash.h" +#include "qfunctions_fake_env_p.h" QT_BEGIN_NAMESPACE -// Environment ------------------------------------------------------ -inline QHash &qt_app_environment() -{ - static QHash internalEnvironment; - return internalEnvironment; -} - -errno_t qt_winrt_getenv_s(size_t* sizeNeeded, char* buffer, size_t bufferSize, const char* varName) -{ - if (!sizeNeeded) - return EINVAL; - - if (!qt_app_environment().contains(varName)) { - if (buffer) - buffer[0] = '\0'; - return ENOENT; - } - - QByteArray value = qt_app_environment().value(varName); - if (!value.endsWith('\0')) // win32 guarantees terminated string - value.append('\0'); - - if (bufferSize < (size_t)value.size()) { - *sizeNeeded = value.size(); - return ERANGE; - } - - strcpy(buffer, value.constData()); - return 0; -} - -errno_t qt_winrt__putenv_s(const char* varName, const char* value) -{ - QByteArray input = value; - if (input.isEmpty()) { - if (qt_app_environment().contains(varName)) - qt_app_environment().remove(varName); - } else { - // win32 on winrt guarantees terminated string - if (!input.endsWith('\0')) - input.append('\0'); - qt_app_environment()[varName] = input; - } - - return 0; -} - void qt_winrt_tzset() { } diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h index 7efd042456..69d5c1eb52 100644 --- a/src/corelib/kernel/qfunctions_winrt.h +++ b/src/corelib/kernel/qfunctions_winrt.h @@ -65,8 +65,8 @@ QT_BEGIN_NAMESPACE #endif // Environment ------------------------------------------------------ -errno_t qt_winrt_getenv_s(size_t*, char*, size_t, const char*); -errno_t qt_winrt__putenv_s(const char*, const char*); +errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*); +errno_t qt_fake__putenv_s(const char*, const char*); void qt_winrt_tzset(); void qt_winrt__tzset(); @@ -91,20 +91,20 @@ QT_END_NAMESPACE { \ return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1); \ } -#define generate_inline_return_func2(funcname, returntype, param1, param2) \ +#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \ inline returntype funcname(param1 p1, param2 p2) \ { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2); \ + return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2); \ } #define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \ inline returntype funcname(param1 p1, param2 p2, param3 p3) \ { \ return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3); \ } -#define generate_inline_return_func4(funcname, returntype, param1, param2, param3, param4) \ +#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \ inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \ { \ - return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4); \ + return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2, p3, p4); \ } #define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \ inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ @@ -126,8 +126,8 @@ typedef unsigned (__stdcall *StartAdressExFunc)(void *); typedef void(*StartAdressFunc)(void *); typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ; -generate_inline_return_func4(getenv_s, errno_t, size_t *, char *, size_t, const char *) -generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *) +generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *) +generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *) generate_inline_return_func0(tzset, void) generate_inline_return_func0(_tzset, void) From d93a4158e0758541717bb90fce30c2f78b66de34 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 3 Dec 2015 11:46:33 +0100 Subject: [PATCH 08/36] tst_QLocalSocket::threadedConnection(): Add failure message. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce QVERIFY2() to get some information when exactly it fails. Change-Id: Icaddf2ecae434d0bafc90c18458c5ee067dfd506 Reviewed-by: Edward Welbourne Reviewed-by: Jędrzej Nowacki --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 56728432f8..d7480a4109 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -732,7 +732,10 @@ public: int done = clients; while (done > 0) { bool timedOut = true; - QVERIFY(server.waitForNewConnection(7000, &timedOut)); + QVERIFY2(server.waitForNewConnection(7000, &timedOut), + (QByteArrayLiteral("done=") + QByteArray::number(done) + + QByteArrayLiteral(", timedOut=") + + (timedOut ? "true" : "false")).constData()); QVERIFY(!timedOut); QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); From de7d2eb2adcdee82e48b04945aca87d455e65f9f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 26 Nov 2015 15:04:33 +0100 Subject: [PATCH 09/36] Polish the fortune server/client examples. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove Qt::WindowContextHelpButtonHint. - Make the server label interactive (enable copy). - Introduce new connection syntax. - Remove unneeded member variables. - Use constructor initialization where appropriate. - Adapt the layout to fullscreen platforms by wrapping it into a QGroupBox. Change-Id: I6e397ad082f22ba1e99fc5a17440b2be1f9584f6 Reviewed-by: Topi Reiniö --- examples/network/fortuneclient/client.cpp | 73 ++++++++++++++--------- examples/network/fortuneclient/client.h | 7 +-- examples/network/fortuneclient/main.cpp | 1 + examples/network/fortuneserver/main.cpp | 1 + examples/network/fortuneserver/server.cpp | 43 +++++++++---- examples/network/fortuneserver/server.h | 3 +- 6 files changed, 78 insertions(+), 50 deletions(-) diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index fc03a3c596..b4c3d9328d 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -45,13 +45,18 @@ //! [0] Client::Client(QWidget *parent) -: QDialog(parent), networkSession(0) + : QDialog(parent) + , hostCombo(new QComboBox) + , portLineEdit(new QLineEdit) + , getFortuneButton(new QPushButton(tr("Get Fortune"))) +//! [1] + , tcpSocket(new QTcpSocket(this)) +//! [1] + , blockSize(0) + , networkSession(Q_NULLPTR) { + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); //! [0] - hostLabel = new QLabel(tr("&Server name:")); - portLabel = new QLabel(tr("S&erver port:")); - - hostCombo = new QComboBox; hostCombo->setEditable(true); // find out name of this machine QString name = QHostInfo::localHostName(); @@ -61,7 +66,7 @@ Client::Client(QWidget *parent) if (!domain.isEmpty()) hostCombo->addItem(name + QChar('.') + domain); } - if (name != QString("localhost")) + if (name != QLatin1String("localhost")) hostCombo->addItem(QString("localhost")); // find out IP addresses of this machine QList ipAddressesList = QNetworkInterface::allAddresses(); @@ -76,54 +81,64 @@ Client::Client(QWidget *parent) hostCombo->addItem(ipAddressesList.at(i).toString()); } - portLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); + QLabel *hostLabel = new QLabel(tr("&Server name:")); hostLabel->setBuddy(hostCombo); + QLabel *portLabel = new QLabel(tr("S&erver port:")); portLabel->setBuddy(portLineEdit); statusLabel = new QLabel(tr("This examples requires that you run the " "Fortune Server example as well.")); - getFortuneButton = new QPushButton(tr("Get Fortune")); getFortuneButton->setDefault(true); getFortuneButton->setEnabled(false); - quitButton = new QPushButton(tr("Quit")); + QPushButton *quitButton = new QPushButton(tr("Quit")); - buttonBox = new QDialogButtonBox; + QDialogButtonBox *buttonBox = new QDialogButtonBox; buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); -//! [1] - tcpSocket = new QTcpSocket(this); -//! [1] - - connect(hostCombo, SIGNAL(editTextChanged(QString)), - this, SLOT(enableGetFortuneButton())); - connect(portLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(enableGetFortuneButton())); - connect(getFortuneButton, SIGNAL(clicked()), - this, SLOT(requestNewFortune())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(hostCombo, &QComboBox::editTextChanged, + this, &Client::enableGetFortuneButton); + connect(portLineEdit, &QLineEdit::textChanged, + this, &Client::enableGetFortuneButton); + connect(getFortuneButton, &QAbstractButton::clicked, + this, &Client::requestNewFortune); + connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close); //! [2] //! [3] - connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readFortune())); + connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune); //! [2] //! [4] - connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), + typedef void (QAbstractSocket::*QAbstractSocketErrorSignal)(QAbstractSocket::SocketError); + connect(tcpSocket, static_cast(&QAbstractSocket::error), //! [3] - this, SLOT(displayError(QAbstractSocket::SocketError))); + this, &Client::displayError); //! [4] - QGridLayout *mainLayout = new QGridLayout; + QGridLayout *mainLayout = Q_NULLPTR; + if (QGuiApplication::styleHints()->showIsFullScreen()) { + QVBoxLayout *outerVerticalLayout = new QVBoxLayout(this); + outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + QHBoxLayout *outerHorizontalLayout = new QHBoxLayout; + outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + QGroupBox *groupBox = new QGroupBox(QGuiApplication::applicationDisplayName()); + mainLayout = new QGridLayout(groupBox); + outerHorizontalLayout->addWidget(groupBox); + outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + outerVerticalLayout->addLayout(outerHorizontalLayout); + outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + } else { + mainLayout = new QGridLayout(this); + } mainLayout->addWidget(hostLabel, 0, 0); mainLayout->addWidget(hostCombo, 0, 1); mainLayout->addWidget(portLabel, 1, 0); mainLayout->addWidget(portLineEdit, 1, 1); mainLayout->addWidget(statusLabel, 2, 0, 1, 2); mainLayout->addWidget(buttonBox, 3, 0, 1, 2); - setLayout(mainLayout); - setWindowTitle(tr("Fortune Client")); + setWindowTitle(QGuiApplication::applicationDisplayName()); portLineEdit->setFocus(); QNetworkConfigurationManager manager; @@ -142,7 +157,7 @@ Client::Client(QWidget *parent) } networkSession = new QNetworkSession(config, this); - connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); + connect(networkSession, &QNetworkSession::opened, this, &Client::sessionOpened); getFortuneButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); @@ -189,7 +204,7 @@ void Client::readFortune() in >> nextFortune; if (nextFortune == currentFortune) { - QTimer::singleShot(0, this, SLOT(requestNewFortune())); + QTimer::singleShot(0, this, &Client::requestNewFortune); return; } //! [11] diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h index a93d35e4ed..9b7d6f4dbf 100644 --- a/examples/network/fortuneclient/client.h +++ b/examples/network/fortuneclient/client.h @@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE class QComboBox; -class QDialogButtonBox; class QLabel; class QLineEdit; class QPushButton; @@ -60,7 +59,7 @@ class Client : public QDialog Q_OBJECT public: - Client(QWidget *parent = 0); + explicit Client(QWidget *parent = Q_NULLPTR); private slots: void requestNewFortune(); @@ -70,14 +69,10 @@ private slots: void sessionOpened(); private: - QLabel *hostLabel; - QLabel *portLabel; QComboBox *hostCombo; QLineEdit *portLineEdit; QLabel *statusLabel; QPushButton *getFortuneButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; QTcpSocket *tcpSocket; QString currentFortune; diff --git a/examples/network/fortuneclient/main.cpp b/examples/network/fortuneclient/main.cpp index 2c02dcbaa6..66fff7a374 100644 --- a/examples/network/fortuneclient/main.cpp +++ b/examples/network/fortuneclient/main.cpp @@ -44,6 +44,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QGuiApplication::setApplicationDisplayName(Client::tr("Fortune Client")); Client client; client.show(); return app.exec(); diff --git a/examples/network/fortuneserver/main.cpp b/examples/network/fortuneserver/main.cpp index 589bb5e339..3b8eef40ba 100644 --- a/examples/network/fortuneserver/main.cpp +++ b/examples/network/fortuneserver/main.cpp @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QGuiApplication::setApplicationDisplayName(Server::tr("Fortune Server")); Server server; server.show(); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 64a7814a20..28f0230894 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -46,11 +46,13 @@ #include "server.h" Server::Server(QWidget *parent) -: QDialog(parent), tcpServer(0), networkSession(0) + : QDialog(parent) + , statusLabel(new QLabel) + , tcpServer(Q_NULLPTR) + , networkSession(0) { - statusLabel = new QLabel; - quitButton = new QPushButton(tr("Quit")); - quitButton->setAutoDefault(false); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { @@ -68,7 +70,7 @@ Server::Server(QWidget *parent) } networkSession = new QNetworkSession(config, this); - connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); + connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened); statusLabel->setText(tr("Opening network session.")); networkSession->open(); @@ -85,10 +87,11 @@ Server::Server(QWidget *parent) << tr("You cannot kill time without injuring eternity.") << tr("Computers are not intelligent. They only think they are."); //! [2] - - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + QPushButton *quitButton = new QPushButton(tr("Quit")); + quitButton->setAutoDefault(false); + connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close); //! [3] - connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); + connect(tcpServer, &QTcpServer::newConnection, this, &Server::sendFortune); //! [3] QHBoxLayout *buttonLayout = new QHBoxLayout; @@ -96,12 +99,26 @@ Server::Server(QWidget *parent) buttonLayout->addWidget(quitButton); buttonLayout->addStretch(1); - QVBoxLayout *mainLayout = new QVBoxLayout; + QVBoxLayout *mainLayout = Q_NULLPTR; + if (QGuiApplication::styleHints()->showIsFullScreen()) { + QVBoxLayout *outerVerticalLayout = new QVBoxLayout(this); + outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + QHBoxLayout *outerHorizontalLayout = new QHBoxLayout; + outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + QGroupBox *groupBox = new QGroupBox(QGuiApplication::applicationDisplayName()); + mainLayout = new QVBoxLayout(groupBox); + outerHorizontalLayout->addWidget(groupBox); + outerHorizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + outerVerticalLayout->addLayout(outerHorizontalLayout); + outerVerticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + } else { + mainLayout = new QVBoxLayout(this); + } + mainLayout->addWidget(statusLabel); mainLayout->addLayout(buttonLayout); - setLayout(mainLayout); - setWindowTitle(tr("Fortune Server")); + setWindowTitle(QGuiApplication::applicationDisplayName()); } void Server::sessionOpened() @@ -165,8 +182,8 @@ void Server::sendFortune() //! [6] //! [7] QTcpSocket *clientConnection = tcpServer->nextPendingConnection(); - connect(clientConnection, SIGNAL(disconnected()), - clientConnection, SLOT(deleteLater())); + connect(clientConnection, &QAbstractSocket::disconnected, + clientConnection, &QObject::deleteLater); //! [7] //! [8] clientConnection->write(block); diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h index d21aa107cf..5b3413295a 100644 --- a/examples/network/fortuneserver/server.h +++ b/examples/network/fortuneserver/server.h @@ -56,7 +56,7 @@ class Server : public QDialog Q_OBJECT public: - Server(QWidget *parent = 0); + explicit Server(QWidget *parent = Q_NULLPTR); private slots: void sessionOpened(); @@ -64,7 +64,6 @@ private slots: private: QLabel *statusLabel; - QPushButton *quitButton; QTcpServer *tcpServer; QStringList fortunes; QNetworkSession *networkSession; From d508c6697b3fa319cc117048d0969806d2a42175 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Oct 2015 15:41:26 +0100 Subject: [PATCH 10/36] Freetype font engine: Restrict bold depending on OS2 weight class. Limit setting bold to weights <=750. Task-number: QTBUG-48922 Change-Id: Id38b636698e58b0686dda9711ee1b3426a3b45b9 Reviewed-by: Gunnar Roth Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 8dfabd48ad..89bc72ae4f 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -717,8 +717,12 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, FT_Set_Transform(face, &matrix, 0); freetype->matrix = matrix; // fake bold - if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) - embolden = true; + if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) { + if (const TT_OS2 *os2 = reinterpret_cast(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) { + if (os2->usWeightClass < 750) + embolden = true; + } + } // underline metrics line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); From ed5937623982ac4bef4c99215a6ec2df7d321514 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 20 Nov 2015 13:59:46 +0100 Subject: [PATCH 11/36] Doc: Clarified QTextTable::mergeCells() documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-37928 Change-Id: I8d3ae3b540f9483d1e93d4c8135f777dea13f967 Reviewed-by: Topi Reiniö --- src/gui/text/qtexttable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index a75a1aae54..454d3440d6 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -986,8 +986,8 @@ void QTextTable::removeColumns(int pos, int num) Merges the cell at the specified \a row and \a column with the adjacent cells into one cell. The new cell will span \a numRows rows and \a numCols columns. - If \a numRows or \a numCols is less than the current number of rows or columns - the cell spans then this method does nothing. + This method does nothing if \a numRows or \a numCols is less than the current + number of rows or columns spanned by the cell. \sa splitCell() */ From 68a2f6206523914017029afaa917358ddcb6138d Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 19 Nov 2015 12:04:50 +0100 Subject: [PATCH 12/36] Doc: Added missing semicolons to snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-34594 Change-Id: I3eeff4494f5b27c5b34b911008b1a87abe032868 Reviewed-by: Topi Reiniö --- .../code/src_network_bearer_qnetworkconfigmanager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/doc/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/src/network/doc/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp index cd05ad63fb..00bcf35c07 100644 --- a/src/network/doc/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp +++ b/src/network/doc/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp @@ -40,9 +40,9 @@ //! [0] QNetworkConfigurationManager mgr; -QList activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active) +QList activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active); if (activeConfigs.count() > 0) - Q_ASSERT(mgr.isOnline()) + Q_ASSERT(mgr.isOnline()); else - Q_ASSERT(!mgr.isOnline()) + Q_ASSERT(!mgr.isOnline()); //! [0] From 2366ecfb2dbf96eda8fa77d1f8cb484d80b52642 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 3 Dec 2015 16:43:42 +0100 Subject: [PATCH 13/36] Manual dialog test: Build also when QtPrintSupport is not available. Fixes the build on WinRT. Change-Id: I68510b70b61433ceed6bf06a31424f93a02230dc Reviewed-by: Maurice Kalinowski --- tests/manual/dialogs/dialogs.pro | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro index 21ebf9b622..d765b8cf05 100644 --- a/tests/manual/dialogs/dialogs.pro +++ b/tests/manual/dialogs/dialogs.pro @@ -1,11 +1,20 @@ QT += core gui -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport + +greaterThan(QT_MAJOR_VERSION, 4) { + QT += widgets + qtHaveModule(printsupport): QT += printsupport +} TARGET = dialogs TEMPLATE = app SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp \ - wizardpanel.cpp messageboxpanel.cpp printdialogpanel.cpp utils.cpp + wizardpanel.cpp messageboxpanel.cpp utils.cpp HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \ - wizardpanel.h messageboxpanel.h printdialogpanel.h utils.h -FORMS += printdialogpanel.ui + wizardpanel.h messageboxpanel.h utils.h + +!contains(DEFINES, QT_NO_PRINTER) { + SOURCES += printdialogpanel.cpp + HEADERS += printdialogpanel.h + FORMS += printdialogpanel.ui +} From c04e7dead8bee51e11698fe1c625c76915a60753 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 3 Dec 2015 15:15:19 +0100 Subject: [PATCH 14/36] QImage pixelColor and setPixelColor must use unpremultiplied QColor QColor always uses unpremultiplied alpha, but the new QImage methods were based on the QRgb versions which might be either. This patches fixes the two new methods so they treat QColor alpha correctly. Change-Id: I78a5b875ad4e78ad7fde3b811c6187482b4f6d15 Reviewed-by: Gunnar Sletta --- src/gui/image/qimage.cpp | 30 ++++++++++++++++------ tests/auto/gui/image/qimage/tst_qimage.cpp | 18 +++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 798002224a..a992ad6fea 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2380,17 +2380,25 @@ QColor QImage::pixelColor(int x, int y) const return QColor(); } + QRgba64 c; const uchar * s = constScanLine(y); switch (d->format) { case Format_BGR30: case Format_A2BGR30_Premultiplied: - return QColor(qConvertA2rgb30ToRgb64(reinterpret_cast(s)[x])); + c = qConvertA2rgb30ToRgb64(reinterpret_cast(s)[x]); + break; case Format_RGB30: case Format_A2RGB30_Premultiplied: - return QColor(qConvertA2rgb30ToRgb64(reinterpret_cast(s)[x])); + c = qConvertA2rgb30ToRgb64(reinterpret_cast(s)[x]); + break; default: - return QColor(pixel(x, y)); + c = QRgba64::fromArgb32(pixel(x, y)); + break; } + // QColor is always unpremultiplied + if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied) + c = c.unpremultiplied(); + return QColor(c); } /*! @@ -2421,6 +2429,12 @@ void QImage::setPixelColor(int x, int y, const QColor &color) qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y); return; } + // QColor is always unpremultiplied + QRgba64 c = color.rgba64(); + if (!hasAlphaChannel()) + c.setAlpha(65535); + else if (qPixelLayouts[d->format].premultiplied) + c = c.premultiplied(); // detach is called from within scanLine uchar * s = scanLine(y); switch (d->format) { @@ -2430,19 +2444,19 @@ void QImage::setPixelColor(int x, int y, const QColor &color) qWarning("QImage::setPixelColor: called on monochrome or indexed format"); return; case Format_BGR30: - ((uint *)s)[x] = qConvertRgb64ToRgb30(color.rgba64()) | 0xc0000000; + ((uint *)s)[x] = qConvertRgb64ToRgb30(c) | 0xc0000000; return; case Format_A2BGR30_Premultiplied: - ((uint *)s)[x] = qConvertRgb64ToRgb30(color.rgba64()); + ((uint *)s)[x] = qConvertRgb64ToRgb30(c); return; case Format_RGB30: - ((uint *)s)[x] = qConvertRgb64ToRgb30(color.rgba64()) | 0xc0000000; + ((uint *)s)[x] = qConvertRgb64ToRgb30(c) | 0xc0000000; return; case Format_A2RGB30_Premultiplied: - ((uint *)s)[x] = qConvertRgb64ToRgb30(color.rgba64()); + ((uint *)s)[x] = qConvertRgb64ToRgb30(c); return; default: - setPixel(x, y, color.rgba()); + setPixel(x, y, c.toArgb32()); return; } } diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 5574a92ad9..23ddfbdd58 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -196,6 +196,8 @@ private slots: void metadataPassthrough(); + void pixelColor(); + private: const QString m_prefix; }; @@ -3020,5 +3022,21 @@ void tst_QImage::metadataPassthrough() QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio()); } +void tst_QImage::pixelColor() +{ + QImage argb32(1, 1, QImage::Format_ARGB32); + QImage argb32pm(1, 1, QImage::Format_ARGB32_Premultiplied); + + QColor c(Qt::red); + c.setAlpha(128); + argb32.setPixelColor(QPoint(0, 0), c); + argb32pm.setPixelColor(QPoint(0, 0), c); + QCOMPARE(argb32.pixelColor(QPoint(0, 0)), c); + QCOMPARE(argb32pm.pixelColor(QPoint(0, 0)), c); + + QImage t = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QCOMPARE(t.pixel(0,0), argb32pm.pixel(0,0)); +} + QTEST_GUILESS_MAIN(tst_QImage) #include "tst_qimage.moc" From 98f326e9b82e6dbf0ef68a16292c38276181416a Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 4 Dec 2015 08:46:03 +0100 Subject: [PATCH 15/36] windows: enable drop for embedded windows when embedding a QWindow into a native win32 window hierarchy, dragndrop is not working, as RegisterDragDrop is not called. the parent HWND is wrapped via QWindow::fromWinId(), which is topLevel, but a Qt::ForeignWindow. it's children are not topLevel. we therefore add a conditon to call RegisterDragDrop on non-topLevel windows whose parent is a Qt::ForeignWindow Change-Id: Id2bfa1130857c21566feae9cb10b62b648d86a72 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 48484209b5..611d586b19 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1033,7 +1033,17 @@ void QWindowsWindow::destroyWindow() void QWindowsWindow::updateDropSite(bool topLevel) { bool enabled = false; - if (topLevel) { + bool parentIsEmbedded = false; + + if (!topLevel) { + // if the parent window is a foreign window wrapped via QWindow::fromWinId, we need to enable the drop site + // on the first child window + const QWindow *parent = window()->parent(); + if (parent && (parent->type() == Qt::ForeignWindow)) + parentIsEmbedded = true; + } + + if (topLevel || parentIsEmbedded) { switch (window()->type()) { case Qt::Window: case Qt::Dialog: From dc0c68262e63b2f74268af7bbf43023b158329b8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Dec 2015 10:55:56 +0100 Subject: [PATCH 16/36] WinRT/QMessageBox: Default to QtWidgets-based dialog for rich text. Change-Id: I071810cc5bc2773df9f6202c4547379d3ecd8b5c Reviewed-by: Andrew Knight Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp index bb04144563..bad15126d4 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp @@ -37,6 +37,7 @@ #include "qwinrtmessagedialoghelper.h" #include "qwinrttheme.h" +#include #include #include @@ -110,6 +111,10 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa const QString informativeText = options->informativeText(); const QString title = options->windowTitle(); const QString text = informativeText.isEmpty() ? options->text() : (options->text() + QLatin1Char('\n') + informativeText); + if (Qt::mightBeRichText(text)) { + qWarning("Rich text detected, defaulting to QtWidgets-based dialog."); + return false; + } HRESULT hr; ComPtr dialogFactory; From 753ebd5ba02d2f3e7286f69626d8415f52b775fc Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 3 Dec 2015 10:53:06 +0100 Subject: [PATCH 17/36] Respond with a sound for certain message boxes on windows This was a regression (it worked in 4.8) that was probably introduced by the refactoring of the accessibility framework in Qt 5. Now, QPlatformAccessibility::notifyAccessibilityUpdate() is called regardless of isActive(), so its the responsibility of each implementation of notifyAccessibilityUpdate() to check for isActive() where it matters. Task-number: QTBUG-33303 Change-Id: I0d18f8c1890ef679460408b05e704712b886bf7c Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- src/gui/accessible/qaccessible.cpp | 21 +++++++++---------- .../linuxaccessibility/bridge.cpp | 2 +- .../platforms/cocoa/qcocoaaccessibility.mm | 2 ++ .../ios/qiosplatformaccessibility.mm | 2 ++ .../accessible/qwindowsaccessibility.cpp | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index e9995045b1..1a8d263f94 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -852,18 +852,17 @@ void QAccessible::updateAccessibility(QAccessibleEvent *event) // during construction of widgets. If you see cases where the // cache seems wrong, this call is "to blame", but the code that // caches dynamic data should be updated to handle change events. - if (!isActive() || !event->accessibleInterface()) - return; + QAccessibleInterface *iface = event->accessibleInterface(); + if (isActive() && iface) { + if (event->type() == QAccessible::TableModelChanged) { + if (iface->tableInterface()) + iface->tableInterface()->modelChange(static_cast(event)); + } - if (event->type() == QAccessible::TableModelChanged) { - QAccessibleInterface *iface = event->accessibleInterface(); - if (iface && iface->tableInterface()) - iface->tableInterface()->modelChange(static_cast(event)); - } - - if (updateHandler) { - updateHandler(event); - return; + if (updateHandler) { + updateHandler(event); + return; + } } if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) diff --git a/src/platformsupport/linuxaccessibility/bridge.cpp b/src/platformsupport/linuxaccessibility/bridge.cpp index 55ef7161d1..bd02b032f9 100644 --- a/src/platformsupport/linuxaccessibility/bridge.cpp +++ b/src/platformsupport/linuxaccessibility/bridge.cpp @@ -99,7 +99,7 @@ void QSpiAccessibleBridge::notifyAccessibilityUpdate(QAccessibleEvent *event) { if (!dbusAdaptor) return; - if (isActive()) + if (isActive() && event->accessibleInterface()) dbusAdaptor->notify(event); } diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 4e901ba015..723c341e59 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -51,6 +51,8 @@ QCocoaAccessibility::~QCocoaAccessibility() void QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { + if (!isActive() || !event->accessibleInterface()) + return; QMacAccessibilityElement *element = [QMacAccessibilityElement elementWithId: event->uniqueId()]; if (!element) { qWarning() << "QCocoaAccessibility::notifyAccessibilityUpdate: invalid element"; diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.mm b/src/plugins/platforms/ios/qiosplatformaccessibility.mm index bfe91df7bd..d8d366a4f4 100644 --- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm +++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm @@ -66,6 +66,8 @@ void invalidateCache(QAccessibleInterface *iface) void QIOSPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { + if (!isActive() || !event->accessibleInterface()) + return; switch (event->type()) { case QAccessible::ObjectCreated: case QAccessible::ObjectShow: diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 0bf3c27350..7015424f47 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -151,7 +151,7 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) // An event has to be associated with a window, // so find the first parent that is a widget and that has a WId QAccessibleInterface *iface = event->accessibleInterface(); - if (!iface || !iface->isValid()) + if (!isActive() || !iface || !iface->isValid()) return; QWindow *window = QWindowsAccessibility::windowHelper(iface); From 00abd1ddd28c5e6a18b4e9d022c1c3c8273cba96 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 4 Dec 2015 12:15:54 +0100 Subject: [PATCH 18/36] vcproj generator: Fix auto-generated inter-project dependencies Task-number: QTBUG-49580 Change-Id: I356be24ac555ed436e4f638e83c6cca703281cba Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_vcproj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index c9f0d92eb9..e90a319828 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -585,7 +585,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHashtarget && // Not self opt != "opengl32.lib" && // We don't care about these libs From b99300712f88925047a955fd974ca3608bc11450 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 4 Dec 2015 12:25:12 +0100 Subject: [PATCH 19/36] Remove superfluous code from collectDependencies val.first was never used. Change-Id: I7be631c09061d6969234502fc0d5660c147aca39 Reviewed-by: Andy Shaw --- qmake/generators/win32/msvc_vcproj.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index e90a319828..d70480b028 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -520,7 +520,6 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash val = qMakePair(fi.absoluteFilePath(), tmpList); // Initialize a 'fake' project to get the correct variables // and to be able to extract all the dependencies Option::QMAKE_MODE old_mode = Option::qmake_mode; @@ -552,8 +551,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHashtarget = newDep->target.left(newDep->target.length()-3) + "lib"; projGuids.insert(newDep->orig_target, newDep->target); - if (val.second.size()) { - const ProStringList depends = val.second; + if (tmpList.size()) { + const ProStringList depends = tmpList; foreach (const ProString &dep, depends) { QString depend = dep.toQString(); if (!projGuids[depend].isEmpty()) { @@ -565,8 +564,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHashdependencies << projGuids[projLookup[tmpDep]]; } } else { - QStringList dependencies = val.second.toQStringList(); - extraSubdirs.insert(newDep, dependencies); + extraSubdirs.insert(newDep, tmpList.toQStringList()); newDep->dependencies.clear(); break; } From 361e24b79ef835e1df040c64a71b9f42f90f14ad Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 24 Nov 2015 14:46:05 +0200 Subject: [PATCH 20/36] Fix extract style on Android 6.0 A few things were changed in Android 6.0 Task-number: QTBUG-49323 Change-Id: I3112d885881dce541d5c4f3a1561f6c34d75e319 Reviewed-by: Christian Stromme --- .../jar/src/org/qtproject/qt5/android/ExtractStyle.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java index 12ae8a65d8..f5dac1fa60 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java @@ -671,7 +671,7 @@ public class ExtractStyle { json.put("gradient",gradientStateClass.getField("mGradient").getInt(obj)); GradientDrawable.Orientation orientation=(Orientation) gradientStateClass.getField("mOrientation").get(obj); json.put("orientation",orientation.name()); - int [] intArray=(int[]) gradientStateClass.getField("mColors").get(obj); + int [] intArray=(int[]) gradientStateClass.getField((Build.VERSION.SDK_INT < 23) ? "mColors" : "mGradientColors").get(obj); if (intArray != null) json.put("colors",getJsonArray(intArray, 0, intArray.length)); json.put("positions",getJsonArray((float[]) gradientStateClass.getField("mPositions").get(obj))); @@ -707,7 +707,10 @@ public class ExtractStyle { json.put("type", "rotate"); Object obj = drawable.getConstantState(); Class rotateStateClass = obj.getClass(); - json.put("drawable", getDrawable(getAccessibleField(rotateStateClass, "mDrawable").get(obj), filename, null)); + if (Build.VERSION.SDK_INT < 23) + json.put("drawable", getDrawable(getAccessibleField(rotateStateClass, "mDrawable").get(obj), filename, null)); + else + json.put("drawable", getDrawable(drawable.getClass().getMethod("getDrawable").invoke(drawable), filename, null)); json.put("pivotX", getAccessibleField(rotateStateClass, "mPivotX").getFloat(obj)); json.put("pivotXRel", getAccessibleField(rotateStateClass, "mPivotXRel").getBoolean(obj)); json.put("pivotY", getAccessibleField(rotateStateClass, "mPivotY").getFloat(obj)); From 118d5dc4960e24d222f06ba7e1c6eab643a30f3e Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 23 Nov 2015 12:22:50 +0100 Subject: [PATCH 21/36] Skip testing empty window sizes on Windows Change-Id: Ib4f3bc63196527583a274180c40d0f7847e13f55 Reviewed-by: Friedemann Kleint --- .../auto/widgets/kernel/qwidget/tst_qwidget.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 97c23ddf26..ddbb4e6d75 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4562,8 +4562,18 @@ void tst_QWidget::setWindowGeometry_data() QList windowFlags; windowFlags << 0 << Qt::FramelessWindowHint; + const bool skipEmptyRects = (m_platform == QStringLiteral("windows")); foreach (QList l, rects) { QRect rect = l.first(); + if (skipEmptyRects) { + QList::iterator it = l.begin(); + while (it != l.end()) { + if (it->isEmpty()) + it = l.erase(it); + else + ++it; + } + } foreach (int windowFlag, windowFlags) { QTest::newRow(QString("%1,%2 %3x%4, flags %5") .arg(rect.x()) @@ -4612,8 +4622,13 @@ void tst_QWidget::setWindowGeometry() widget.setGeometry(rect); widget.showNormal(); - if (rect.isValid()) + if (rect.isValid()) { QVERIFY(QTest::qWaitForWindowExposed(&widget)); + } else { + // in case of an invalid rect, wait for the geometry to become + // adjusted to the actual (valid) value. + QApplication::processEvents(); + } QTRY_COMPARE(widget.geometry(), rect); // setGeometry() while shown From dae77465d1a96d7a6c4fd21e9cd92dc11d5ff68b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Jul 2015 12:55:21 -0700 Subject: [PATCH 22/36] syncqt: print errors and warnings to stderr Change-Id: Ib056b47dde3341ef9a52ffff13ef5f6b8d21aeab Reviewed-by: Tobias Hunger Reviewed-by: Oswald Buddenhagen --- bin/syncqt.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/syncqt.pl b/bin/syncqt.pl index 72b678041f..4016ea2d7c 100755 --- a/bin/syncqt.pl +++ b/bin/syncqt.pl @@ -357,7 +357,7 @@ sub check_header { print STDERR "$lib: ERROR: $iheader includes private header $include\n" if ($include =~ /_p.h$/); for my $trylib (keys(%modules)) { if (-e "$out_basedir/include/$trylib/$include") { - print "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n"; + print STDERR "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n"; } } } @@ -376,15 +376,15 @@ sub check_header { if ($public_header) { if ($header_skip_qt_begin_namespace_test == 0 and $stop_processing == 0) { if ($qt_begin_namespace_found == 0) { - print "$lib: WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n"; + print STDERR "$lib: WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n"; } if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) { - print "$lib: WARNING: $iheader has QT_BEGIN_NAMESPACE$qt_namespace_suffix but no QT_END_NAMESPACE$qt_namespace_suffix\n"; + print STDERR "$lib: WARNING: $iheader has QT_BEGIN_NAMESPACE$qt_namespace_suffix but no QT_END_NAMESPACE$qt_namespace_suffix\n"; } } } elsif ($private_header) { - print "$lib: WARNING: $iheader does not have the \"We mean it.\" warning\n" if (!$we_mean_it); + print STDERR "$lib: WARNING: $iheader does not have the \"We mean it.\" warning\n" if (!$we_mean_it); } close(F); @@ -764,7 +764,7 @@ while ( @ARGV ) { $var = "version"; $val = shift @ARGV; } elsif($arg =~/^-/) { - print "Unknown option: $arg\n\n" if(!$var); + print STDERR "Unknown option: $arg\n\n" if (!$var); showUsage(); } else { $basedir = locateSyncProfile($arg); @@ -777,7 +777,7 @@ while ( @ARGV ) { #do something if(!$var || $var eq "show_help") { - print "Unknown option: $arg\n\n" if(!$var); + print STDERR "Unknown option: $arg\n\n" if (!$var); showUsage(); } elsif ($var eq "copy") { if($val eq "yes") { From 4b365cb4463858534f87dc5804bb31423dd7d518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Thu, 19 Nov 2015 22:48:11 +0000 Subject: [PATCH 23/36] Fix typo in QObject::disconnect() documentation Change-Id: I65f95c7f22399b9fea65c44b971afc7efbb73d64 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c9884cd76c..c316ebc69f 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4822,7 +4822,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) \note It is not possible to use this overload to diconnect signals connected to functors or lambda expressions. That is because it is not - possible to compare them. Instead, use the olverload that take a + possible to compare them. Instead, use the overload that takes a QMetaObject::Connection \sa connect() From 2766215c9ec68bf175c0ddafbd7be5a03b403795 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Fri, 4 Dec 2015 10:36:16 +0100 Subject: [PATCH 24/36] Remove additional copyright notice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I181579d755a79e2e0a26ff2de119d9642183a2ca Reviewed-by: Jani Heikkinen Reviewed-by: Topi Reiniö --- src/widgets/doc/snippets/qlistview-dnd/model.cpp | 10 ---------- src/widgets/doc/snippets/qlistview-dnd/model.h | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.cpp b/src/widgets/doc/snippets/qlistview-dnd/model.cpp index 846ca94e14..80b2a4ec1f 100644 --- a/src/widgets/doc/snippets/qlistview-dnd/model.cpp +++ b/src/widgets/doc/snippets/qlistview-dnd/model.cpp @@ -38,16 +38,6 @@ ** ****************************************************************************/ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of an example program for Qt. -** EDITIONS: NOLIMITS -** -****************************************************************************/ - /* model.cpp diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.h b/src/widgets/doc/snippets/qlistview-dnd/model.h index b4c8196341..fd00a9b986 100644 --- a/src/widgets/doc/snippets/qlistview-dnd/model.h +++ b/src/widgets/doc/snippets/qlistview-dnd/model.h @@ -38,16 +38,6 @@ ** ****************************************************************************/ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of an example program for Qt. -** EDITIONS: NOLIMITS -** -****************************************************************************/ - #ifndef MODEL_H #define MODEL_H From a76f2897143e3c428ea5e106c023105270b7ed0c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 26 Nov 2015 14:22:07 +0100 Subject: [PATCH 25/36] Initialize function tables without QGuiApplication QImage can be used without QGuiApplication, but wihout QGuiApplication the accelerated methods would not be used. This patch changes the initialization of the QtGui function tables to happen in static object constructors on QtGui load, instead of in the QGuiApplication init. Change-Id: Ib58982fbc50fd79122352d021d93a3c99aca5043 Reviewed-by: Erik Verbruggen Reviewed-by: Gunnar Sletta --- src/gui/image/qimage_conversions.cpp | 13 ++++++++++++- src/gui/image/qimage_p.h | 2 -- src/gui/kernel/qguiapplication.cpp | 10 ---------- src/gui/painting/qdrawhelper.cpp | 17 ++++++++++++++++- src/gui/painting/qdrawhelper_p.h | 2 -- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 7d1fb23b15..cbdcf49da7 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -2920,7 +2920,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma } // Format_Grayscale8 }; -void qInitImageConversions() +static void qInitImageConversions() { #if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSSE3) if (qCpuHasFeature(SSSE3)) { @@ -2967,4 +2967,15 @@ void qInitImageConversions() #endif } +class QImageConversionsInitializer { +public: + QImageConversionsInitializer() + { + qInitImageConversions(); + } +}; + +// Ensure initialization if this object file is linked. +static QImageConversionsInitializer qImageConversionsInitializer; + QT_END_NAMESPACE diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index feeab60abd..3badda0864 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -111,8 +111,6 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha); -void qInitImageConversions(); - const uchar *qt_get_bitflip_array(); Q_GUI_EXPORT void qGamma_correct_back_to_linear_cs(QImage *image); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 087bed439c..00245b25b0 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -192,9 +192,6 @@ extern void qRegisterGuiVariant(); #ifndef QT_NO_ANIMATION extern void qRegisterGuiGetInterpolator(); #endif -extern void qInitBlendFunctions(); -extern void qInitDrawhelperAsm(); -extern void qInitImageConversions(); static bool qt_detectRTLLanguage() { @@ -1327,13 +1324,6 @@ void QGuiApplicationPrivate::init() if (platform_integration == 0) createPlatformIntegration(); - // Set up blend function tables. - qInitBlendFunctions(); - // Set up which span functions should be used in raster engine... - qInitDrawhelperAsm(); - // and QImage conversion functions - qInitImageConversions(); - initPalette(); QFont::initialize(); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5854008ea3..8f5eb4d095 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6328,7 +6328,7 @@ void qt_memfill32(quint32 *dest, quint32 color, int count) template const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); #endif -void qInitDrawhelperAsm() +static void qInitDrawhelperFunctions() { #ifdef __SSE2__ qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; @@ -6523,4 +6523,19 @@ void qInitDrawhelperAsm() #endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 } +extern void qInitBlendFunctions(); +class DrawHelperInitializer { +public: + DrawHelperInitializer() + { + // Set up basic blend function tables. + qInitBlendFunctions(); + // Set up architecture optimized methods for the current machine. + qInitDrawhelperFunctions(); + } +}; + +// Ensure initialization if this object file is linked. +static DrawHelperInitializer drawHelperInitializer; + QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1d70477051..1ff19f4e04 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -213,8 +213,6 @@ struct Operator }; }; -void qInitDrawhelperAsm(); - class QRasterPaintEngine; struct QSolidData From 80ae3baed03916db4d38bb4b8844cde258a0abf6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 21 Oct 2015 15:49:34 +0200 Subject: [PATCH 26/36] Q_UNIMPLEMENTED: remove explicit file, line and funcinfo information This information is already registered by the QMessageLogger ctor. Change-Id: Iac378777675f00ad5d07b938605484b1466aa5c5 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index db8c60831f..07a0b5e27a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -760,7 +760,7 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; } typedef void (*QFunctionPointer)(); #if !defined(Q_UNIMPLEMENTED) -# define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO) +# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.") #endif Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT Q_DECL_UNUSED; From 270aa5b58d7a4db23287a77c89a97dddd81694a6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Dec 2015 14:46:29 +0100 Subject: [PATCH 27/36] WinRT: Set TemporaryError in QNativeSocketEngine::accept() when no connections are pending. This suppresses the emission of QTcpServer::acceptError() from QTcpServerPrivate::readNotification(). Task-number: QTBUG-49776 Change-Id: Icfb686d44c0a396ae2bf5867bd31a91232ef3e3c Reviewed-by: Markus Goetz (Woboq GmbH) Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 173221dec0..1c68b28784 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -380,8 +380,10 @@ int QNativeSocketEngine::accept() Q_CHECK_STATE(QNativeSocketEngine::accept(), QAbstractSocket::ListeningState, -1); Q_CHECK_TYPE(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket, -1); - if (d->socketDescriptor == -1 || d->pendingConnections.isEmpty()) + if (d->socketDescriptor == -1 || d->pendingConnections.isEmpty()) { + d->setError(QAbstractSocket::TemporaryError, QNativeSocketEnginePrivate::TemporaryErrorString); return -1; + } // Start processing incoming data if (d->socketType == QAbstractSocket::TcpSocket) { From 7908da98f01c24bd95a9e7a7f938de697a6a02b6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 5 Dec 2015 14:57:06 +0100 Subject: [PATCH 28/36] Android: Fix QInputMethod's visible property There are many cases in which finishComposingText is called and it does not mean the keyboard will be hidden. Add a check that there are space reserved for the keyboard before closing it. This is not helping with floating keyboards, but it's already better. [ChangeLog] Made QInputMethod's visible more accurate Task-number: QTBUG-42444 Change-Id: I4d706f1ea5ba2f0f6d3ec1921139317bc4f8dafb Reviewed-by: BogDan Vatra --- .../qtproject/qt5/android/QtInputConnection.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 0f3e9083d4..1536d60faa 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java @@ -40,6 +40,9 @@ import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputMethodManager; +import android.graphics.Rect; +import android.app.Activity; +import android.util.DisplayMetrics; class QtExtractedText { @@ -80,7 +83,15 @@ class HideKeyboardRunnable implements Runnable { @Override public void run() { - QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp); + // Check that the keyboard is really no longer there. + Activity activity = QtNative.activity(); + Rect r = new Rect(); + activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); + DisplayMetrics metrics = new DisplayMetrics(); + activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + final int kbHeight = metrics.heightPixels - r.bottom; + if (kbHeight < 100) + QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp); } } From 420b4dbece04f8015cad24a49622c65c540f0a22 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 5 Dec 2015 13:23:26 +0100 Subject: [PATCH 29/36] Android: Implement QInputMethod::keyboardRectangle We can use getWindowVisibleDisplayFrame to know the height on the keyboard, and we can use getLocationOnScreen to find out how much the view is scrolled. Since onPreDraw is always called when the view is scrolled or when the keyboard appears or disapear, we can call the native functions from there. This is not working for floating keyboards. [ChangeLog][Android] Implemented QInputMethod::keyboardRectangle Task-number: QTBUG-40731 Change-Id: I7848eb34fece410b29a06bf0bbb2313112fffa68 Reviewed-by: Samuel Nevala Reviewed-by: BogDan Vatra --- .../qt5/android/QtActivityDelegate.java | 21 ++++++++++++ .../org/qtproject/qt5/android/QtNative.java | 1 + src/gui/kernel/qinputmethod.cpp | 3 ++ .../platforms/android/androidjniinput.cpp | 32 +++++++++++++++++-- .../platforms/android/androidjniinput.h | 2 ++ .../android/qandroidinputcontext.cpp | 2 +- 6 files changed, 58 insertions(+), 3 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 445896622a..4575d8a1d3 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -66,6 +66,8 @@ import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.view.ViewTreeObserver; +import android.graphics.Rect; import java.io.BufferedReader; import java.io.DataOutputStream; @@ -859,6 +861,25 @@ public class QtActivityDelegate QtNative.handleOrientationChanged(rotation, m_nativeOrientation); m_currentRotation = rotation; + + m_layout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (!m_keyboardIsVisible) + return true; + + Rect r = new Rect(); + m_activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); + DisplayMetrics metrics = new DisplayMetrics(); + m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + final int kbHeight = metrics.heightPixels - r.bottom; + final int[] location = new int[2]; + m_layout.getLocationOnScreen(location); + QtNative.keyboardGeometryChanged(location[0], r.bottom - location[1], + r.width(), kbHeight); + return true; + } + }); } public void initializeAccessibility() diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 602b25eb45..8880c003e7 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -677,6 +677,7 @@ public class QtNative public static native void keyDown(int key, int unicode, int modifier, boolean autoRepeat); public static native void keyUp(int key, int unicode, int modifier, boolean autoRepeat); public static native void keyboardVisibilityChanged(boolean visibility); + public static native void keyboardGeometryChanged(int x, int y, int width, int height); // keyboard methods // dispatch events methods diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp index 8d51be853a..2684c43518 100644 --- a/src/gui/kernel/qinputmethod.cpp +++ b/src/gui/kernel/qinputmethod.cpp @@ -147,6 +147,9 @@ QRectF QInputMethod::cursorRectangle() const /*! \property QInputMethod::keyboardRectangle \brief Virtual keyboard's geometry in window coordinates. + + This might be an empty rectangle if it is not possible to know the geometry + of the keyboard. This is the case for a floating keyboard on android. */ QRectF QInputMethod::keyboardRectangle() const { diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 8982787ec9..9cc5e95378 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -51,6 +51,7 @@ namespace QtAndroidInput static bool m_ignoreMouseEvents = false; static bool m_softwareKeyboardVisible = false; + static QRect m_softwareKeyboardRect; static QList m_touchPoints; @@ -108,6 +109,11 @@ namespace QtAndroidInput return m_softwareKeyboardVisible; } + QRect softwareKeyboardRect() + { + return m_softwareKeyboardRect; + } + static void mouseDown(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) { @@ -734,14 +740,35 @@ namespace QtAndroidInput static void keyboardVisibilityChanged(JNIEnv */*env*/, jobject /*thiz*/, jboolean visibility) { m_softwareKeyboardVisible = visibility; + if (!visibility) + m_softwareKeyboardRect = QRect(); + QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); - if (inputContext && qGuiApp) + if (inputContext && qGuiApp) { inputContext->emitInputPanelVisibleChanged(); + if (!visibility) + inputContext->emitKeyboardRectChanged(); + } #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL qDebug() << "@@@ KEYBOARDVISIBILITYCHANGED" << inputContext; #endif } + static void keyboardGeometryChanged(JNIEnv */*env*/, jobject /*thiz*/, jint x, jint y, jint w, jint h) + { + QRect r = QRect(x, y, w, h); + if (r == m_softwareKeyboardRect) + return; + m_softwareKeyboardRect = r; + QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); + if (inputContext && qGuiApp) + inputContext->emitKeyboardRectChanged(); + +#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL + qDebug() << "@@@ KEYBOARDRECTCHANGED" << m_softwareKeyboardRect; +#endif + } + static JNINativeMethod methods[] = { {"touchBegin","(I)V",(void*)touchBegin}, {"touchAdd","(IIIZIIFF)V",(void*)touchAdd}, @@ -753,7 +780,8 @@ namespace QtAndroidInput {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent}, {"keyDown", "(IIIZ)V", (void *)keyDown}, {"keyUp", "(IIIZ)V", (void *)keyUp}, - {"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged} + {"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged}, + {"keyboardGeometryChanged", "(IIII)V", (void *)keyboardGeometryChanged} }; bool registerNatives(JNIEnv *env) diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h index d737dc9c98..7132d1fc4e 100644 --- a/src/plugins/platforms/android/androidjniinput.h +++ b/src/plugins/platforms/android/androidjniinput.h @@ -35,6 +35,7 @@ #define ANDROIDJNIINPUT_H #include #include +#include QT_BEGIN_NAMESPACE @@ -45,6 +46,7 @@ namespace QtAndroidInput void resetSoftwareKeyboard(); void hideSoftwareKeyboard(); bool isSoftwareKeyboardVisible(); + QRect softwareKeyboardRect(); void updateSelection(int selStart, int selEnd, int candidatesStart, int candidatesEnd); // Software keyboard support diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index e3ea048e84..0eddb26959 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -512,7 +512,7 @@ void QAndroidInputContext::invokeAction(QInputMethod::Action action, int cursorP QRectF QAndroidInputContext::keyboardRect() const { - return QPlatformInputContext::keyboardRect(); + return QtAndroidInput::softwareKeyboardRect(); } bool QAndroidInputContext::isAnimating() const From 9dde61f4b3519b4de5b83fab463c8d8136baf5b6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 30 Nov 2015 15:26:16 +0100 Subject: [PATCH 30/36] Optimize qt_findAtNxFile by reducing the amount of allocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I94a2b40933f9469f509a4cc54d68138696704ba2 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qicon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index dc6cbfed1f..d9e1347e4b 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Olivier Goffart ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -1400,15 +1401,15 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati if (disableNxImageLoading) return baseFileName; - QString atNx = QLatin1String("@%1x"); int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.')); if (dotIndex == -1) /* no dot */ dotIndex = baseFileName.size(); /* append */ + QString atNxfileName = baseFileName; + atNxfileName.insert(dotIndex, QLatin1String("@2x")); // Check for @Nx, ..., @3x, @2x file versions, - for (int n = qCeil(targetDevicePixelRatio); n > 1; --n) { - QString atNxfileName = baseFileName; - atNxfileName.insert(dotIndex, atNx.arg(n)); + for (int n = qMin(qCeil(targetDevicePixelRatio), 9); n > 1; --n) { + atNxfileName[dotIndex + 1] = QLatin1Char('0' + n); if (QFile::exists(atNxfileName)) { if (sourceDevicePixelRatio) *sourceDevicePixelRatio = n; From 891c98ebd63b5a5b079a1f5a2736a29d89afcbd2 Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Fri, 4 Dec 2015 16:00:57 -0500 Subject: [PATCH 31/36] Don't treat "/etc/localtime" in TZ env var as a valid timezone id On some Debian distros, the TZ environment variable can be set to ":/etc/localtime", which libc defines as "default value". If this is set, the current QTimeZone parsing code will return "/etc/localtime" as the system timezone id, which is clearly wrong. So in that case, just unset the ianaId variable and let the other blocks look for the timezone. Change-Id: I3f5795d0a05f4974a60556387a07a1e2e1e7aa30 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 90ce8e3b68..85ed345869 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -918,6 +918,13 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const if (!ianaId.isEmpty() && ianaId.at(0) == ':') ianaId = ianaId.mid(1); + // The TZ value can be ":/etc/localtime" which libc considers + // to be a "default timezone", in which case it will be read + // by one of the blocks below, so unset it here so it is not + // considered as a valid/found ianaId + if (ianaId == "/etc/localtime") + ianaId.clear(); + // On Debian Etch and later /etc/localtime is real file with name held in /etc/timezone if (ianaId.isEmpty()) { QFile tzif(QStringLiteral("/etc/timezone")); From 9744ca10856e3b113231d37baf2e073611c7cc09 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Nov 2015 10:58:55 +0100 Subject: [PATCH 32/36] Add QStyleHints::showIsMaximized(). Expose QPlatformIntegration::ShowIsMaximized similarly to QPlatformIntegration::ShowIsFullScreen. This allows for applications to adapt their UI to mobile/desktop accordingly. Change-Id: Ic14d16fde11d7d2740b2f4092ae12e88a2f522fd Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Gunnar Sletta Reviewed-by: Lars Knoll --- src/gui/kernel/qstylehints.cpp | 18 +++++++++++++++++- src/gui/kernel/qstylehints.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 7ff0f9f860..7fc89112e6 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -305,13 +305,29 @@ int QStyleHints::cursorFlashTime() const \note The platform may still choose to show certain windows non-fullscreen, such as popups or dialogs. This property only reports the default behavior. - \sa QWindow::show() + \sa QWindow::show(), showIsMaximized() */ bool QStyleHints::showIsFullScreen() const { return hint(QPlatformIntegration::ShowIsFullScreen).toBool(); } +/*! + \property QStyleHints::showIsMaximized + \brief \c true if the platform defaults to windows being maximized, + otherwise \c false. + + \note The platform may still choose to show certain windows non-maximized, + such as popups or dialogs. This property only reports the default behavior. + + \sa QWindow::show(), showIsFullScreen() + \since 5.6 +*/ +bool QStyleHints::showIsMaximized() const +{ + return hint(QPlatformIntegration::ShowIsMaximized).toBool(); +} + /*! \property QStyleHints::passwordMaskDelay \brief the time, in milliseconds, a typed letter is displayed unshrouded diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 82eb8a6f7d..c5b8241e07 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -56,6 +56,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL) Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL) Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen STORED false CONSTANT FINAL) + Q_PROPERTY(bool showIsMaximized READ showIsMaximized STORED false CONSTANT FINAL) Q_PROPERTY(int startDragDistance READ startDragDistance NOTIFY startDragDistanceChanged FINAL) Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL) Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL) @@ -78,6 +79,7 @@ public: void setCursorFlashTime(int cursorFlashTime); int cursorFlashTime() const; bool showIsFullScreen() const; + bool showIsMaximized() const; int passwordMaskDelay() const; QChar passwordMaskCharacter() const; qreal fontSmoothingGamma() const; From df053dc642b4cb284112f63b6572ac5cfc175b35 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Dec 2015 12:20:50 +0100 Subject: [PATCH 33/36] WinRT: Add RETURN_[]_IF_FAILED_WITH_ARGS macros. Make it possible to pass arguments to the messages by introducing variadic macro versions of RETURN_[]_IF_FAILED. Change-Id: Iec27adb33d9d3211fdc299f07777fcdf33f08a93 Reviewed-by: Oliver Wolff --- src/corelib/kernel/qfunctions_winrt.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h index 69d5c1eb52..ee4e050793 100644 --- a/src/corelib/kernel/qfunctions_winrt.h +++ b/src/corelib/kernel/qfunctions_winrt.h @@ -49,10 +49,20 @@ ret; \ } +#define RETURN_IF_FAILED_WITH_ARGS(msg, ret, ...) \ + if (FAILED(hr)) { \ + qErrnoWarning(hr, msg, __VA_ARGS__); \ + ret; \ + } + #define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr) #define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK) #define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false) #define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return) +#define RETURN_HR_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return hr, __VA_ARGS__) +#define RETURN_OK_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return S_OK, __VA_ARGS__) +#define RETURN_FALSE_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return false, __VA_ARGS__) +#define RETURN_VOID_IF_FAILED_WITH_ARGS(msg, ...) RETURN_IF_FAILED_WITH_ARGS(msg, return, __VA_ARGS__) #define Q_ASSERT_SUCCEEDED(hr) \ Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); From 60536d742175bacca2130f46d06663013c91bae2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Dec 2015 10:13:23 +0100 Subject: [PATCH 34/36] WinRT: Prepend '.' to default file suffix. IFileSavePicker::put_DefaultFileExtension() fails when the '.' is missing, causing the QtWidgets-based dialog to show up (Windows 10). Change-Id: Ifcb870431b792ffa8e4a608dec999225e8383fa9 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp index b0f377147e..68e0227ef5 100644 --- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp @@ -444,12 +444,14 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit } } - const QString suffix = dialogOptions->defaultSuffix(); + QString suffix = dialogOptions->defaultSuffix(); if (!suffix.isEmpty()) { + if (!suffix.startsWith(QLatin1Char('.'))) + suffix.prepend(QLatin1Char('.')); HStringReference nativeSuffix(reinterpret_cast(suffix.utf16()), suffix.length()); hr = picker->put_DefaultFileExtension(nativeSuffix.Get()); - RETURN_FALSE_IF_FAILED("Failed to set default file extension"); + RETURN_FALSE_IF_FAILED_WITH_ARGS("Failed to set default file extension \"%s\"", qPrintable(suffix)); } const QString suggestedName = QFileInfo(d->saveFileName.toLocalFile()).fileName(); From df57e3a33f6da6bfd076ab5e20ca1addbbbe8f25 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Tue, 17 Nov 2015 11:46:55 +0100 Subject: [PATCH 35/36] Doc: Add the missing styles to get multi-column classes list Add two- and three-column layouts for the 'All C++ Classes' list. Also affects the layout of 'All QML Types' page. Task-number: QTBUG-49376 Change-Id: I80953c0955dbc37db5aa4c60eb9ea8e3023a77f2 Reviewed-by: Martin Smith --- doc/global/template/style/offline.css | 15 +++++++++++++++ doc/global/template/style/online.css | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/doc/global/template/style/offline.css b/doc/global/template/style/offline.css index 5aabd82dcb..1f76efbd38 100644 --- a/doc/global/template/style/offline.css +++ b/doc/global/template/style/offline.css @@ -595,6 +595,21 @@ ol.a > li{ margin-left: 15px } +.flowList { + padding: 25px +} +.flowList dd { + display: inline-block; + margin-left: 10px; + width: 255px; + line-height: 1.15em; + overflow-x: hidden; + text-overflow: ellipsis +} +.alphaChar { + font-size: 2em; + position: relative +} /* ----------- Content table diff --git a/doc/global/template/style/online.css b/doc/global/template/style/online.css index 86e30e89b3..c7758d0ca8 100644 --- a/doc/global/template/style/online.css +++ b/doc/global/template/style/online.css @@ -254,6 +254,13 @@ line-height:1.4; font-size:0.875em } +@media (min-width: 1320px) { + .context .flowListDiv dl.flowList { + -webkit-column-count:3; + -moz-column-count:3; + column-count:3 + } +} @media (min-width: 1120px) { #navbar.fixed,#navbar.shadow_bottom { -moz-box-shadow:0px 0px 8px rgba(0,0,0,0.2); @@ -293,6 +300,11 @@ #navbar.fixed #mainmenu li.current-menu-item a { border-bottom:4px solid #80C342 } + .flowListDiv dl.flowList { + -webkit-column-count:2; + -moz-column-count:2; + column-count:2 + } } @media (max-width: 1120px) { #navbar { @@ -1220,6 +1232,19 @@ li a.active { .flowList { padding:25px } +.flowListDiv dl { + -webkit-column-count:1; + -moz-column-count:1; + column-count:1 +} +.flowList dd { + display:inline-block; + margin-left:10px; + width:90%; + line-height:1.15em; + overflow-x:hidden; + text-overflow:ellipsis +} .alphaChar { font-size:2em; position:absolute From 4ad8798de428b44fe4c56e1ca111940068056c57 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 7 Dec 2015 12:44:09 +0100 Subject: [PATCH 36/36] QPlatformWindow::initialGeometry(): Pass screen when scaling. Otherwise, the window may up outside the display area when centering on a secondary screen and the primary screen has a different scale factor. Task-number: QTBUG-49803 Change-Id: I91ec7c5348722a90012f80a247e662e96bcbb391 Reviewed-by: Alessandro Portale --- src/gui/kernel/qplatformwindow.cpp | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 8757715c0d..aea029b7f5 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -581,6 +581,9 @@ void QPlatformWindow::invalidateSurface() QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry, int defaultWidth, int defaultHeight) { + const QScreen *screen = effectiveScreen(w); + if (!screen) + return initialGeometry; QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); if (rect.width() == 0) { const int minWidth = w->minimumWidth(); @@ -591,25 +594,23 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, rect.setHeight(minHeight > 0 ? minHeight : defaultHeight); } if (w->isTopLevel() && qt_window_private(const_cast(w))->positionAutomatic - && w->type() != Qt::Popup) { - if (const QScreen *screen = effectiveScreen(w)) { - const QRect availableGeometry = screen->availableGeometry(); - // Center unless the geometry ( + unknown window frame) is too large for the screen). - if (rect.height() < (availableGeometry.height() * 8) / 9 + && w->type() != Qt::Popup) { + const QRect availableGeometry = screen->availableGeometry(); + // Center unless the geometry ( + unknown window frame) is too large for the screen). + if (rect.height() < (availableGeometry.height() * 8) / 9 && rect.width() < (availableGeometry.width() * 8) / 9) { - const QWindow *tp = w->transientParent(); - if (tp) { - // A transient window should be centered w.r.t. its transient parent. - rect.moveCenter(tp->geometry().center()); - } else { - // Center the window on the screen. (Only applicable on platforms - // which do not provide a better way.) - rect.moveCenter(availableGeometry.center()); - } + const QWindow *tp = w->transientParent(); + if (tp) { + // A transient window should be centered w.r.t. its transient parent. + rect.moveCenter(tp->geometry().center()); + } else { + // Center the window on the screen. (Only applicable on platforms + // which do not provide a better way.) + rect.moveCenter(availableGeometry.center()); } } } - return QHighDpi::toNativePixels(rect, w); + return QHighDpi::toNativePixels(rect, screen); } /*!