summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure52
-rw-r--r--dist/changes-5.2.027
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.cpp3
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.cpp1
-rw-r--r--mkspecs/common/clang.conf10
-rw-r--r--mkspecs/common/ios/qmake.conf3
-rw-r--r--mkspecs/features/ios/default_post.prf35
-rw-r--r--mkspecs/features/simd.prf3
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp3
-rw-r--r--qmake/generators/makefile.cpp3
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/io/qdatastream.cpp5
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h5
-rw-r--r--src/corelib/json/qjson_p.h2
-rw-r--r--src/corelib/json/qjsonvalue.cpp12
-rw-r--r--src/corelib/json/qjsonvalue.h1
-rw-r--r--src/corelib/json/qjsonwriter.cpp9
-rw-r--r--src/corelib/kernel/qmetatype.h41
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp9
-rw-r--r--src/corelib/tools/qalgorithms.h67
-rw-r--r--src/corelib/tools/qalgorithms.qdoc31
-rw-r--r--src/corelib/tools/qbitarray.cpp11
-rw-r--r--src/corelib/tools/qbitarray.h1
-rw-r--r--src/corelib/tools/qharfbuzz_p.h14
-rw-r--r--src/corelib/tools/qset.h1
-rw-r--r--src/gui/image/qicon.cpp1
-rw-r--r--src/gui/image/qicon.h4
-rw-r--r--src/gui/image/qiconloader.cpp12
-rw-r--r--src/gui/image/qimage.h5
-rw-r--r--src/gui/kernel/qplatformservices.cpp5
-rw-r--r--src/gui/painting/painting.pri9
-rw-r--r--src/gui/painting/qcolor.cpp43
-rw-r--r--src/gui/painting/qcolor.h3
-rw-r--r--src/gui/painting/qcolor_p.cpp12
-rw-r--r--src/gui/painting/qdrawhelper.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp233
-rw-r--r--src/gui/text/qtextengine_p.h16
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp17
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h2
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend.cpp6
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp11
-rw-r--r--src/network/access/qnetworkaccessfilebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp6
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp114
-rw-r--r--src/network/access/qnetworkaccessmanager.h7
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h16
-rw-r--r--src/network/ssl/qssl.cpp2
-rw-r--r--src/network/ssl/qssl.h3
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp2
-rw-r--r--src/platformsupport/eglconvenience/qxlibeglintegration.cpp17
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices.cpp26
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm5
-rw-r--r--src/plugins/platforms/ios/plugin.pro2
-rw-r--r--src/plugins/platforms/qnx/main.cpp3
-rw-r--r--src/plugins/platforms/qnx/qnx.pro31
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.cpp12
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.h2
-rw-r--r--src/plugins/platforms/qnx/qqnxfiledialoghelper.h18
-rw-r--r--src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp209
-rw-r--r--src/plugins/platforms/qnx/qqnxfiledialoghelper_playbook.cpp (renamed from src/plugins/platforms/qnx/qqnxfiledialoghelper.cpp)18
-rw-r--r--src/plugins/platforms/qnx/qqnxfilepicker.cpp289
-rw-r--r--src/plugins/platforms/qnx/qqnxfilepicker.h110
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp34
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h15
-rw-r--r--src/plugins/platforms/qnx/qqnxtheme.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp141
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp2
-rw-r--r--src/tools/qdoc/config.h1
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp4
-rw-r--r--src/tools/qdoc/generator.cpp5
-rw-r--r--src/tools/qdoc/generator.h1
-rw-r--r--src/tools/qdoc/main.cpp7
-rw-r--r--src/tools/qdoc/qmlvisitor.h1
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp120
-rw-r--r--src/widgets/dialogs/qcolordialog.h4
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h7
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp2
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h8
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp2
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h2
-rw-r--r--src/widgets/graphicsview/qgridlayoutengine.cpp9
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp20
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h2
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp18
-rw-r--r--src/widgets/itemviews/qheaderview.cpp28
-rw-r--r--src/widgets/itemviews/qheaderview.h1
-rw-r--r--src/widgets/itemviews/qtableview.cpp17
-rw-r--r--src/widgets/itemviews/qtableview.h2
-rw-r--r--src/widgets/itemviews/qtreeview.cpp30
-rw-r--r--src/widgets/itemviews/qtreeview.h2
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp96
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h12
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h4
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp99
-rw-r--r--src/widgets/widgets/qscrollarea.cpp12
-rw-r--r--src/widgets/widgets/qscrollarea.h2
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp86
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp78
-rw-r--r--tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp80
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp81
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp5
-rw-r--r--tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp35
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp38
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp32
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp2
-rw-r--r--tests/manual/widgets/itemviews/qtreeview/main.cpp35
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp4
-rw-r--r--tools/configure/configureapp.cpp21
115 files changed, 2353 insertions, 504 deletions
diff --git a/configure b/configure
index 9c86fa1e5d..295644ce45 100755
--- a/configure
+++ b/configure
@@ -4316,8 +4316,7 @@ fi
# detect neon support
if [ "$CFG_ARCH" = "arm" ] && [ "${CFG_NEON}" = "auto" ]; then
- # The iOS toolchain has trouble building the pixman NEON draw-helpers
- if [ "$XPLATFORM_IOS" != "yes" ] && compileTest unix/neon "neon"; then
+ if compileTest unix/neon "neon"; then
CFG_NEON=yes
else
CFG_NEON=no
@@ -6208,16 +6207,28 @@ fi
# Add compiler sub-architecture support
echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
echo "// Compiler sub-arch support" >>"$outpath/src/corelib/global/qconfig.h.new"
-for SUBARCH in SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX AVX2 \
- IWMMXT NEON \
- MIPS_DSP MIPS_DSPR2; do
- eval "VAL=\$CFG_$SUBARCH"
- case "$VAL" in
- yes)
- echo "#define QT_COMPILER_SUPPORTS_$SUBARCH" \
- >>"$outpath/src/corelib/global/qconfig.h.new"
+for SUBARCH in X86: SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX AVX2 : \
+ ARM: IWMMXT NEON : \
+ MIPS: MIPS_DSP MIPS_DSPR2 :
+do
+ line=""
+ case $SUBARCH in
+ :)
+ line="#endif"
+ ;;
+ *:)
+ line="#ifdef Q_PROCESSOR_$(echo $SUBARCH | sed 's/:$//')"
+ ;;
+ *)
+ eval "VAL=\$CFG_$SUBARCH"
+ case "$VAL" in
+ yes)
+ line=" #define QT_COMPILER_SUPPORTS_$SUBARCH"
+ ;;
+ esac
;;
esac
+ [ -n "$line" ] && echo "$line" >>"$outpath/src/corelib/global/qconfig.h.new"
done
echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
@@ -6410,12 +6421,13 @@ fi
cat >>"$QTCONFIG.tmp" <<EOF
#configuration
CONFIG += $QTCONFIG_CONFIG
-QT_ARCH = $CFG_ARCH
-QT_HOST_ARCH = $CFG_HOST_ARCH
-QT_CPU_FEATURES = $CFG_CPUFEATURES
-QT_HOST_CPU_FEATURES = $CFG_HOST_CPUFEATURES
-QMAKE_DEFAULT_LIBDIRS = `echo "$DEFAULT_LIBDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
-QMAKE_DEFAULT_INCDIRS = `echo "$DEFAULT_INCDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
+host_build {
+ QT_ARCH = $CFG_HOST_ARCH
+} else {
+ QT_ARCH = $CFG_ARCH
+ QMAKE_DEFAULT_LIBDIRS = `echo "$DEFAULT_LIBDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
+ QMAKE_DEFAULT_INCDIRS = `echo "$DEFAULT_INCDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
+}
QT_EDITION = $Edition
QT_CONFIG += $QT_CONFIG
@@ -6497,6 +6509,14 @@ if [ -n "$CFG_SKIP_MODULES" ]; then
echo "QT_SKIP_MODULES += $CFG_SKIP_MODULES" >> "$QTMODULE.tmp"
fi
+cat >>"$QTMODULE.tmp" <<EOF
+host_build {
+ QT_CPU_FEATURES.$CFG_HOST_ARCH = $CFG_HOST_CPUFEATURES
+} else {
+ QT_CPU_FEATURES.$CFG_ARCH = $CFG_CPUFEATURES
+}
+EOF
+
if [ -n "$QT_CFLAGS_PSQL" ]; then
echo "QT_CFLAGS_PSQL = $QT_CFLAGS_PSQL" >> "$QTMODULE.tmp"
fi
diff --git a/dist/changes-5.2.0 b/dist/changes-5.2.0
new file mode 100644
index 0000000000..59ea4f9985
--- /dev/null
+++ b/dist/changes-5.2.0
@@ -0,0 +1,27 @@
+Qt 5.2 introduces many new features and improvements as well as bugfixes
+over the 5.1.x series. For more details, refer to the online documentation
+included in this distribution. The documentation is also available online:
+
+ http://qt-project.org/doc/qt-5.2
+
+The Qt version 5.2 series is binary compatible with the 5.1.x series.
+Applications compiled for 5.1 will continue to run with 5.2.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ http://bugreports.qt-project.org/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+QtWidgets
+---------
+
+- QAbstractScrollArea now has a SizeAdjustPolicy. If it is set to AdjustToContents
+ it will make use of the new protected viewportSizeHint() (binary compatible since it
+ was reserved in Qt5). This function returns a suggested size based on contents.
diff --git a/examples/widgets/itemviews/spreadsheet/main.cpp b/examples/widgets/itemviews/spreadsheet/main.cpp
index 1cc9205d7e..f518986bc5 100644
--- a/examples/widgets/itemviews/spreadsheet/main.cpp
+++ b/examples/widgets/itemviews/spreadsheet/main.cpp
@@ -42,14 +42,15 @@
#include "spreadsheet.h"
#include <QApplication>
+#include <QLayout>
int main(int argc, char** argv) {
Q_INIT_RESOURCE(spreadsheet);
QApplication app(argc, argv);
SpreadSheet sheet(10, 6);
sheet.setWindowIcon(QPixmap(":/images/interview.png"));
- sheet.resize(640, 420);
sheet.show();
+ sheet.layout()->setSizeConstraint(QLayout::SetFixedSize);
return app.exec();
}
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
index 59d29f0e61..6fab0c2aae 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
@@ -64,6 +64,7 @@ SpreadSheet::SpreadSheet(int rows, int cols, QWidget *parent)
toolBar->addWidget(formulaInput);
table = new QTableWidget(rows, cols, this);
+ table->setSizeAdjustPolicy(QTableWidget::AdjustToContents);
for (int c = 0; c < cols; ++c) {
QString character(QChar('A' + c));
table->setHorizontalHeaderItem(c, new QTableWidgetItem(character));
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index 3ce04b679e..c94ee40934 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -20,13 +20,3 @@ QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_LFLAGS_CXX11 =
-
-QMAKE_CFLAGS_SSE2 += -msse2
-QMAKE_CFLAGS_SSE3 += -msse3
-QMAKE_CFLAGS_SSSE3 += -mssse3
-QMAKE_CFLAGS_SSE4_1 += -msse4.1
-QMAKE_CFLAGS_SSE4_2 += -msse4.2
-QMAKE_CFLAGS_AVX += -mavx
-QMAKE_CFLAGS_AVX2 += -mavx2
-QMAKE_CFLAGS_IWMMXT += -mcpu=iwmmxt
-QMAKE_CFLAGS_NEON += -mfpu=neon
diff --git a/mkspecs/common/ios/qmake.conf b/mkspecs/common/ios/qmake.conf
index 39465aa765..3c477438a3 100644
--- a/mkspecs/common/ios/qmake.conf
+++ b/mkspecs/common/ios/qmake.conf
@@ -15,9 +15,6 @@ QMAKE_RANLIB = ranlib -s
QMAKE_LINK = $$QMAKE_CXX
QMAKE_LINK_SHLIB = $$QMAKE_CXX
-# Basic iOS frameworks needed for any GUI app
-QMAKE_LFLAGS += -framework Foundation -framework UIKit -framework QuartzCore -lz
-
# No OpenGL ES1
QMAKE_INCDIR_OPENGL_ES1 =
QMAKE_LIBDIR_OPENGL_ES1 =
diff --git a/mkspecs/features/ios/default_post.prf b/mkspecs/features/ios/default_post.prf
index e9d2149351..e55228ed4a 100644
--- a/mkspecs/features/ios/default_post.prf
+++ b/mkspecs/features/ios/default_post.prf
@@ -18,7 +18,7 @@ gui_app {
# linker have seen a use for so far. We need this because we load the platform
# plugin from the platform plugin itself, using Q_IMPORT_PLUGIN.
lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/libqios$$qtPlatformTargetSuffix()
- LIBS += "-force_load $${lib_path_and_base}.$${QMAKE_EXTENSION_STATICLIB}"
+ LIBS += -Wl,-force_load,$${lib_path_and_base}.$${QMAKE_EXTENSION_STATICLIB}
LIBS += $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS)
# Which means we don't want the auto-generated import for the platform plugin
@@ -46,24 +46,27 @@ isEmpty(QT_ARCH) {
# but we fail to pick up the architecture since we're not passing -arch
# yet. Xcode does not seem to have a way to run the shared toolchain
# in a way that will automatically do this (for example xcrun -sdk).
- contains(QMAKE_MAC_SDK, iphoneos.*): QT_ARCH = armv7
+ contains(QMAKE_MAC_SDK, iphoneos.*): QT_ARCH = arm
else: QT_ARCH = i386 # Simulator
-} else {
- # Fix up the QT_ARCH to be more specific
- equals(QT_ARCH, arm) {
- # Samsung S5PC100, Apple A4, A5, A5X
- QT_ARCH = armv7
-
- # FIXME: How do we support armv7s when Qt can't do universal builds?
- }
}
-!equals(MAKEFILE_GENERATOR, XCODE) {
- arch_flag = -arch $$QT_ARCH
- QMAKE_CFLAGS += $$arch_flag
- QMAKE_CXXFLAGS += $$arch_flag
- QMAKE_OBJECTIVE_CFLAGS += $$arch_flag
- QMAKE_LFLAGS += $$arch_flag
+# Be more specific about which architecture we're targeting
+equals(QT_ARCH, arm): \
+ actual_archs = armv7
+else: \
+ actual_archs = $$QT_ARCH
+
+equals(MAKEFILE_GENERATOR, XCODE) {
+ QMAKE_XCODE_ARCHS = $$actual_archs
+} else {
+ for(arch, actual_archs): \
+ arch_flags += -arch $$arch
+
+ QMAKE_CFLAGS += $$arch_flags
+ QMAKE_CXXFLAGS += $$arch_flags
+ QMAKE_OBJECTIVE_CFLAGS += $$arch_flags
+ QMAKE_LFLAGS += $$arch_flags
}
+unset(actual_archs)
load(default_post)
diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf
index b430e59ff0..751f836a2d 100644
--- a/mkspecs/features/simd.prf
+++ b/mkspecs/features/simd.prf
@@ -12,6 +12,9 @@
# Get the SIMD flags
load(qt_build_config)
+# Set QT_CPU_FEATURES for convenience
+QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH)
+
#
# Set up compilers for SIMD (SSE/AVX, NEON etc)
#
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index a09e10c55e..e148448c06 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1409,7 +1409,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
+ fixListForOutput("QMAKE_LIBS_PRIVATE"),
SettingsAsList, 6) << ";" << "\n";
}
- const ProStringList &archs = project->values("QT_ARCH");
+ const ProStringList &archs = !project->values("QMAKE_XCODE_ARCHS").isEmpty() ?
+ project->values("QMAKE_XCODE_ARCHS") : project->values("QT_ARCH");
if (!archs.isEmpty())
t << "\t\t\t\t" << writeSettings("ARCHS", archs) << ";" << "\n";
if (!project->isEmpty("OBJECTS_DIR"))
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index d095bdf83d..72aa1ffeb9 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -2244,8 +2244,7 @@ MakefileGenerator::writeHeader(QTextStream &t)
{
t << "#############################################################################" << endl;
t << "# Makefile for building: " << escapeFilePath(var("TARGET")) << endl;
- t << "# Generated by qmake (" QMAKE_VERSION_STR ") (Qt " QT_VERSION_STR ") on: ";
- t << QDateTime::currentDateTime().toString() << endl;
+ t << "# Generated by qmake (" QMAKE_VERSION_STR ") (Qt " QT_VERSION_STR ")" << endl;
t << "# Project: " << fileFixify(project->projectFile()) << endl;
t << "# Template: " << var("TEMPLATE") << endl;
if(!project->isActiveConfig("build_pass"))
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 58c4256aa5..c50235767a 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -45,11 +45,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.1.0"
+#define QT_VERSION_STR "5.2.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050100
+#define QT_VERSION 0x050200
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index dc7387bc85..da38f8ae21 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -251,7 +251,7 @@ QT_BEGIN_NAMESPACE
return retVal;
enum {
- DefaultStreamVersion = QDataStream::Qt_5_1
+ DefaultStreamVersion = QDataStream::Qt_5_2
};
/*!
@@ -538,8 +538,9 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_4_7 Same as Qt_4_6.
\value Qt_4_8 Same as Qt_4_6.
\value Qt_4_9 Same as Qt_4_6.
- \value Qt_5_0 Version 13 (Qt 5.0)
+ \value Qt_5_0 Version 13 (Qt 5.0, Qt 5.1, Qt 5.2)
\value Qt_5_1 Same as Qt_5_0.
+ \value Qt_5_2 Same as Qt_5_0.
\sa setVersion(), version()
*/
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 6017ba5e7d..f893e6a503 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -86,8 +86,9 @@ public:
Qt_4_8 = Qt_4_7,
Qt_4_9 = Qt_4_8,
Qt_5_0 = 13,
- Qt_5_1 = Qt_5_0
-#if QT_VERSION >= 0x050200
+ Qt_5_1 = Qt_5_0,
+ Qt_5_2 = Qt_5_1
+#if QT_VERSION >= 0x050300
#error Add the datastream version for this Qt version
#endif
};
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index d5bf29212f..16f30fffd6 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -110,6 +110,11 @@ public:
inline bool operator!=(const QPersistentModelIndex &other) const
{ return !operator==(other); }
QPersistentModelIndex &operator=(const QPersistentModelIndex &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPersistentModelIndex(QPersistentModelIndex &&other) : d(other.d) { other.d = 0; }
+ inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
inline void swap(QPersistentModelIndex &other) { qSwap(d, other.d); }
bool operator==(const QModelIndex &other) const;
bool operator!=(const QModelIndex &other) const;
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 81439a00ce..96a11cd40e 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -60,8 +60,10 @@
#include <qatomic.h>
#include <qstring.h>
#include <qendian.h>
+#include <qnumeric.h>
#include <limits.h>
+#include <limits>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index a540626579..d0b06c6924 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -156,6 +156,18 @@ QJsonValue::QJsonValue(int n)
}
/*!
+ \overload
+ Creates a value of type Double, with value \a n.
+ NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992).
+ If you pass in values outside this range expect a loss of precision to occur.
+ */
+QJsonValue::QJsonValue(qint64 n)
+ : d(0), t(Double)
+{
+ this->dbl = n;
+}
+
+/*!
Creates a value of type String, with value \a s.
*/
QJsonValue::QJsonValue(const QString &s)
diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h
index b8bdf55aa3..c8efab5d5f 100644
--- a/src/corelib/json/qjsonvalue.h
+++ b/src/corelib/json/qjsonvalue.h
@@ -79,6 +79,7 @@ public:
QJsonValue(bool b);
QJsonValue(double n);
QJsonValue(int n);
+ QJsonValue(qint64 n);
QJsonValue(const QString &s);
QJsonValue(QLatin1String s);
QJsonValue(const QJsonArray &a);
diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp
index 76f62241e3..8426b351f6 100644
--- a/src/corelib/json/qjsonwriter.cpp
+++ b/src/corelib/json/qjsonwriter.cpp
@@ -169,9 +169,14 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value &
case QJsonValue::Bool:
json += v.toBoolean() ? "true" : "false";
break;
- case QJsonValue::Double:
- json += QByteArray::number(v.toDouble(b));
+ case QJsonValue::Double: {
+ const double d = v.toDouble(b);
+ if (qIsFinite(d)) // +2 to format to ensure the expected precision
+ json += QByteArray::number(d, 'g', std::numeric_limits<double>::digits10 + 2); // ::digits10 is 15
+ else
+ json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
break;
+ }
case QJsonValue::String:
json += '"';
json += escapedString(v.toString(b));
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index aed998f2e2..c5eae7a83e 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -52,6 +52,10 @@
#endif
#include <new>
+#include <vector>
+#include <list>
+#include <map>
+
#ifdef Bool
#error qmetatype.h must be included before any header file that defines Bool
#endif
@@ -183,6 +187,19 @@ QT_BEGIN_NAMESPACE
#define QT_DEFINE_METATYPE_ID(TypeName, Id, Name) \
TypeName = Id,
+#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
+ F(QList) \
+ F(QVector) \
+ F(QQueue) \
+ F(QStack) \
+ F(QSet) \
+ F(QLinkedList)
+
+#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F) \
+ F(QHash, class) \
+ F(QMap, class) \
+ F(QPair, struct)
+
class QDataStream;
class QMetaTypeInterface;
struct QMetaObject;
@@ -546,11 +563,16 @@ namespace QtPrivate {
{ return -1; }
};
+#ifndef Q_COMPILER_VARIADIC_TEMPLATES
// Function pointers don't derive from QObject
template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
template <class Result, class Arg0> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1, class Arg2> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1, Arg2)> { enum { Value = false }; };
+#else
+ template <typename Result, typename... Args>
+ struct IsPointerToTypeDerivedFromQObject<Result(*)(Args...)> { enum { Value = false }; };
+#endif
template<typename T>
struct QMetaTypeTypeFlags
@@ -846,19 +868,6 @@ struct QMetaTypeId< SMART_POINTER<T> > : public QMetaTypeId_ ## SMART_POINTER ##
{ \
};
-#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
- F(QList) \
- F(QVector) \
- F(QQueue) \
- F(QStack) \
- F(QSet) \
- F(QLinkedList)
-
-#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F) \
- F(QHash, class) \
- F(QMap, class) \
- F(QPair, struct)
-
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F) \
F(QSharedPointer) \
F(QWeakPointer) \
@@ -872,6 +881,9 @@ QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(Q_DECLARE_METATYPE_TEMPLATE_1ARG_ITER)
#undef Q_DECLARE_METATYPE_TEMPLATE_1ARG_ITER
+Q_DECLARE_METATYPE_TEMPLATE_1ARG(std::vector)
+Q_DECLARE_METATYPE_TEMPLATE_1ARG(std::list)
+
#define Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER(TEMPLATENAME, CPPTYPE) \
template <class T1, class T2> CPPTYPE TEMPLATENAME; \
Q_DECLARE_METATYPE_TEMPLATE_2ARG(TEMPLATENAME)
@@ -880,6 +892,9 @@ QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER)
#undef Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER
+Q_DECLARE_METATYPE_TEMPLATE_2ARG(std::pair)
+Q_DECLARE_METATYPE_TEMPLATE_2ARG(std::map)
+
#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME) \
Q_DECLARE_SMART_POINTER_METATYPE(TEMPLATENAME)
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index e0c7f171c3..6c88ed4531 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -181,17 +181,16 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
: QObject(*new QSocketNotifierPrivate, parent)
{
Q_D(QSocketNotifier);
- if (socket < 0)
- qWarning("QSocketNotifier: Invalid socket specified");
d->sockfd = socket;
d->sntype = type;
d->snenabled = true;
- if (!d->threadData->eventDispatcher.load()) {
+ if (socket < 0)
+ qWarning("QSocketNotifier: Invalid socket specified");
+ else if (!d->threadData->eventDispatcher.load())
qWarning("QSocketNotifier: Can only be used with threads started with QThread");
- } else {
+ else
d->threadData->eventDispatcher.load()->registerSocketNotifier(this);
- }
}
/*!
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index e3b76886f1..8337afcb9d 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -516,6 +516,73 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator
} //namespace QAlgorithmsPrivate
+
+// Use __builtin_popcount on gcc. Clang claims to be gcc
+// but has a bug where __builtin_popcount is not marked as
+// constexpr.
+#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+#endif
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ // See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 24) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcountll(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 24) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 36) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 48) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 60) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigned int v)
+{
+ return qPopulationCount(static_cast<quint64>(v));
+}
+
+#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#undef QALGORITHMS_USE_BUILTIN_POPCOUNT
+#endif
+
+
QT_END_NAMESPACE
#endif // QALGORITHMS_H
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index cc544af868..7c3aa1a3b2 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -635,3 +635,34 @@ of \a value in the variable passed as a reference in argument \a n.
\sa {qLess()}{qLess<T>()}
*/
+
+
+/*!
+ \fn uint qPopulationCount(quint8 v)
+ \relates <QtAlgorithms>
+ \since 5.2
+
+ Returns the number of bits set in \a v. This number also called
+ the Hamming Weight of \a v.
+ */
+
+/*!
+ \fn uint qPopulationCount(quint16 v)
+ \relates <QtAlgorithms>
+ \since 5.2
+ \overload
+ */
+
+/*!
+ \fn uint qPopulationCount(quint32 v)
+ \relates <QtAlgorithms>
+ \since 5.2
+ \overload
+ */
+
+/*!
+ \fn uint qPopulationCount(quint64 v)
+ \relates <QtAlgorithms>
+ \since 5.2
+ \overload
+ */
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 2b459b2b1b..4949476f25 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qbitarray.h"
+#include <qalgorithms.h>
#include <qdatastream.h>
#include <qdebug.h>
#include <string.h>
@@ -159,24 +160,18 @@ int QBitArray::count(bool on) const
for (int i = 0; i < len; ++i)
numBits += testBit(i);
#else
- // See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
const quint8 *bits = reinterpret_cast<const quint8 *>(d.data()) + 1;
while (len >= 32) {
quint32 v = quint32(bits[0]) | (quint32(bits[1]) << 8) | (quint32(bits[2]) << 16) | (quint32(bits[3]) << 24);
- quint32 c = ((v & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- c += (((v & 0xfff000) >> 12) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- c += ((v >> 24) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
len -= 32;
bits += 4;
- numBits += int(c);
+ numBits += int(qPopulationCount(v));
}
while (len >= 24) {
quint32 v = quint32(bits[0]) | (quint32(bits[1]) << 8) | (quint32(bits[2]) << 16);
- quint32 c = ((v & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
- c += (((v & 0xfff000) >> 12) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
len -= 24;
bits += 3;
- numBits += int(c);
+ numBits += int(qPopulationCount(v));
}
while (len >= 0) {
if (bits[len / 8] & (1 << ((len - 1) & 7)))
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 1103712627..eaf9b2ff25 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -61,6 +61,7 @@ public:
QBitArray(const QBitArray &other) : d(other.d) {}
inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
+ inline QBitArray(QBitArray &&other) : d(std::move(other.d)) {}
inline QBitArray &operator=(QBitArray &&other)
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/tools/qharfbuzz_p.h
index 27ddb44e91..1471fd5712 100644
--- a/src/corelib/tools/qharfbuzz_p.h
+++ b/src/corelib/tools/qharfbuzz_p.h
@@ -140,20 +140,6 @@ typedef enum {
HB_ScriptCount = HB_Script_Inherited
} HB_Script;
-typedef enum {
- HB_NoJustification= 0, /* Justification can't be applied after this glyph */
- HB_Arabic_Space = 1, /* This glyph represents a space inside arabic text */
- HB_Character = 2, /* Inter-character justification point follows this glyph */
- HB_Space = 4, /* This glyph represents a blank outside an Arabic run */
- HB_Arabic_Normal = 7, /* Normal Middle-Of-Word glyph that connects to the right (begin) */
- HB_Arabic_Waw = 8, /* Next character is final form of Waw/Ain/Qaf/Fa */
- HB_Arabic_BaRa = 9, /* Next two chars are Ba + Ra/Ya/AlefMaksura */
- HB_Arabic_Alef = 10, /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
- HB_Arabic_HaaDal = 11, /* Next character is final form of Haa/Dal/Taa Marbutah */
- HB_Arabic_Seen = 12, /* Initial or Medial form Of Seen/Sad */
- HB_Arabic_Kashida = 13 /* Kashida(U+640) in middle of word */
-} HB_JustificationClass;
-
#ifdef __xlC__
typedef unsigned hb_bitfield;
#else
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index d5c3637293..1390c67c80 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -70,6 +70,7 @@ public:
inline QSet<T> &operator=(const QSet<T> &other)
{ q_hash = other.q_hash; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
+ inline QSet(QSet &&other) : q_hash(qMove(other.q_hash)) {}
inline QSet<T> &operator=(QSet<T> &&other)
{ qSwap(q_hash, other.q_hash); return *this; }
#endif
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 45eda78397..f2f822331d 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1068,7 +1068,6 @@ void QIcon::setThemeName(const QString &name)
*/
QString QIcon::themeName()
{
- QIconLoader::instance()->ensureInitialized();
return QIconLoader::instance()->themeName();
}
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index e81bea69d6..f1a78b508c 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -62,6 +62,10 @@ public:
QIcon();
QIcon(const QPixmap &pixmap);
QIcon(const QIcon &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QIcon(QIcon &&other)
+ :d(0) { qSwap(d, other.d); }
+#endif
explicit QIcon(const QString &fileName); // file or resource name
explicit QIcon(QIconEngine *engine);
~QIcon();
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 105dc26c9b..d202d62957 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -128,6 +128,7 @@ void QIconLoader::ensureInitialized()
QIconLoader *QIconLoader::instance()
{
+ iconLoaderInstance()->ensureInitialized();
return iconLoaderInstance();
}
@@ -368,17 +369,14 @@ bool QIconLoaderEngine::hasIcon() const
// Lazily load the icon
void QIconLoaderEngine::ensureLoaded()
{
-
- iconLoaderInstance()->ensureInitialized();
-
- if (!(iconLoaderInstance()->themeKey() == m_key)) {
+ if (!(QIconLoader::instance()->themeKey() == m_key)) {
while (!m_entries.isEmpty())
delete m_entries.takeLast();
Q_ASSERT(m_entries.size() == 0);
- m_entries = iconLoaderInstance()->loadIcon(m_iconName);
- m_key = iconLoaderInstance()->themeKey();
+ m_entries = QIconLoader::instance()->loadIcon(m_iconName);
+ m_key = QIconLoader::instance()->themeKey();
}
}
@@ -565,7 +563,7 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
{
QIconEngine::AvailableSizesArgument &arg
= *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
- const QList<QIconDirInfo> directoryKey = iconLoaderInstance()->theme().keyList();
+ const QList<QIconDirInfo> directoryKey = QIconLoader::instance()->theme().keyList();
arg.sizes.clear();
// Gets all sizes from the DirectoryInfo entries
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 50d4bc7666..a4aaf049f0 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -139,6 +139,11 @@ public:
explicit QImage(const QString &fileName, const char *format = 0);
QImage(const QImage &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QImage(QImage &&other)
+ : QPaintDevice(), d(0)
+ { qSwap(d, other.d); }
+#endif
~QImage();
QImage &operator=(const QImage &);
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index f2cade0a35..d09b74c6fe 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -74,7 +74,10 @@ bool QPlatformServices::openDocument(const QUrl &url)
/*!
* \brief QPlatformServices::desktopEnvironment returns the active desktop environment.
*
- * On Unix this function returns KDE, GNOME or UNKNOWN.
+ * On Unix this function returns the uppercase desktop environment name, such as
+ * KDE, GNOME, UNITY, XFCE, LXDE etc. or UNKNOWN if none was detected.
+ * The primary way to detect the desktop environment is the environment variable
+ * XDG_CURRENT_DESKTOP.
*/
QByteArray QPlatformServices::desktopEnvironment() const
{
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 47ba27d72a..aadcc0f686 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -91,9 +91,12 @@ SSE2_SOURCES += painting/qdrawhelper_sse2.cpp
SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp
IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp
AVX_SOURCES += painting/qdrawhelper_avx.cpp
-NEON_SOURCES += painting/qdrawhelper_neon.cpp
-NEON_HEADERS += painting/qdrawhelper_neon_p.h
-NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
+
+!ios {
+ NEON_SOURCES += painting/qdrawhelper_neon.cpp
+ NEON_HEADERS += painting/qdrawhelper_neon_p.h
+ NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
+}
MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp
MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 12ca84d8d1..c93320c491 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -90,7 +90,8 @@ QT_BEGIN_NAMESPACE
specified.
A color can be set by passing an RGB string (such as "#112233"),
- or a color name (such as "blue"), to the setNamedColor() function.
+ or an ARGB string (such as "#ff112233") or a color name (such as "blue"),
+ to the setNamedColor() function.
The color names are taken from the SVG 1.0 color names. The name()
function returns the name of the color in the format
"#RRGGBB". Colors can also be set using setRgb(), setHsv() and
@@ -301,6 +302,17 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QColor::NameFormat
+
+ How to format the output of the name() function
+
+ \value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. \c{#RRGGBB}).
+ \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. \c{#AARRGGBB}).
+
+ \sa name()
+*/
+
+/*!
\fn Spec QColor::spec() const
Returns how the color was specified.
@@ -489,8 +501,28 @@ QColor::QColor(Spec spec)
QString QColor::name() const
{
+ return name(HexRgb);
+}
+
+/*!
+ \since 5.2
+
+ Returns the name of the color in the specified \a format.
+
+ \sa setNamedColor(), NameFormat
+*/
+
+QString QColor::name(NameFormat format) const
+{
QString s;
- s.sprintf("#%02x%02x%02x", red(), green(), blue());
+ switch (format) {
+ case HexRgb:
+ s.sprintf("#%02x%02x%02x", red(), green(), blue());
+ break;
+ case HexArgb:
+ s.sprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue());
+ break;
+ }
return s;
}
@@ -501,6 +533,7 @@ QString QColor::name() const
\list
\li #RGB (each of R, G, and B is a single hex digit)
\li #RRGGBB
+ \li #AARRGGBB (Since 5.2)
\li #RRRGGGBBB
\li #RRRRGGGGBBBB
\li A name from the list of colors defined in the list of \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword names}
@@ -545,9 +578,9 @@ bool QColor::setColorFromString(const QString &name)
}
if (name.startsWith(QLatin1Char('#'))) {
- QRgb rgb;
- if (qt_get_hex_rgb(name.constData(), name.length(), &rgb)) {
- setRgb(rgb);
+ QRgb rgba;
+ if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) {
+ setRgba(rgba);
return true;
} else {
invalidate();
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index ef3503e8d8..1ede5a3682 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -65,6 +65,7 @@ class Q_GUI_EXPORT QColor
{
public:
enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl };
+ enum NameFormat { HexRgb, HexArgb };
QColor();
QColor(Qt::GlobalColor color);
@@ -77,7 +78,9 @@ public:
bool isValid() const;
+ // ### Qt 6: merge overloads
QString name() const;
+ QString name(NameFormat format) const;
void setNamedColor(const QString& name);
static QStringList colorNames();
diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp
index 35e607ec54..b913f5338c 100644
--- a/src/gui/painting/qcolor_p.cpp
+++ b/src/gui/painting/qcolor_p.cpp
@@ -79,7 +79,8 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
return false;
name++;
int len = qstrlen(name);
- int r, g, b;
+ int a, r, g, b;
+ a = 255;
if (len == 12) {
r = hex2int(name);
g = hex2int(name + 4);
@@ -88,6 +89,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
r = hex2int(name);
g = hex2int(name + 3);
b = hex2int(name + 6);
+ } else if (len == 8) {
+ a = hex2int(name);
+ r = hex2int(name + 2);
+ g = hex2int(name + 4);
+ b = hex2int(name + 6);
} else if (len == 6) {
r = hex2int(name);
g = hex2int(name + 2);
@@ -99,11 +105,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
} else {
r = g = b = -1;
}
- if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) {
+ if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
*rgb = 0;
return false;
}
- *rgb = qRgb(r, g ,b);
+ *rgb = qRgba(r, g ,b, a);
return true;
}
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 628d12d881..651949192b 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -6162,7 +6162,7 @@ void qInitDrawhelperAsm()
}
#endif // IWMMXT
-#if defined(QT_COMPILER_SUPPORTS_NEON)
+#if defined(QT_COMPILER_SUPPORTS_NEON) && !defined(Q_OS_IOS)
if (features & NEON) {
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 2fa7f0232d..229db80186 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -59,9 +59,9 @@
#include <algorithm>
#include <stdlib.h>
+#ifndef QT_NO_RAWFONT
#include "qfontengine_qpa_p.h"
-
-#include <private/qharfbuzz_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -838,21 +838,6 @@ void QTextEngine::bidiReorder(int numItems, const quint8 *levels, int *visualOrd
#endif
}
-// ask the font engine to find out which glyphs (as an index in the specific font) to use for the text in one item.
-static bool stringToGlyphs(HB_ShaperItem *item, QGlyphLayout *glyphs, QFontEngine *fontEngine)
-{
- int nGlyphs = item->num_glyphs;
-
- QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
- if (item->item.bidiLevel % 2)
- shaperFlags |= QFontEngine::RightToLeft;
-
- bool result = fontEngine->stringToCMap(reinterpret_cast<const QChar *>(item->string + item->item.pos), item->item.length, glyphs, &nGlyphs, shaperFlags);
- item->num_glyphs = nGlyphs;
- glyphs->numGlyphs = nGlyphs;
- return result;
-}
-
// shape all the items that intersect with the line, taking tab widths into account to find out what text actually fits in the line.
void QTextEngine::shapeLine(const QScriptLine &line)
{
@@ -892,19 +877,48 @@ void QTextEngine::shapeText(int item) const
if (si.num_glyphs)
return;
- shapeTextWithHarfbuzz(item);
-
si.width = 0;
+ si.glyph_data_offset = layoutData->used;
- if (!si.num_glyphs)
- return;
- QGlyphLayout glyphs = shapedGlyphs(&si);
+ const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.constData()) + si.position;
+ const int itemLength = length(item);
+
+ if (!ensureSpace(itemLength))
+ return; // ### report OOM error somehow
+
+ QString casedString;
+ if (si.analysis.flags && si.analysis.flags <= QScriptAnalysis::SmallCaps) {
+ casedString.resize(itemLength);
+ ushort *uc = reinterpret_cast<ushort *>(casedString.data());
+ for (int i = 0; i < itemLength; ++i) {
+ uint ucs4 = string[i];
+ if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) {
+ uint low = string[i + 1];
+ if (QChar::isLowSurrogate(low)) {
+ ++i;
+ ucs4 = QChar::surrogateToUcs4(ucs4, low);
+ ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
+ : QChar::toUpper(ucs4);
+ // high part never changes in simple casing
+ uc[i] = QChar::lowSurrogate(ucs4);
+ }
+ } else {
+ uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
+ : QChar::toUpper(ucs4);
+ }
+ }
+ string = reinterpret_cast<const ushort *>(casedString.constData());
+ }
+ QFontEngine *fontEngine = this->fontEngine(si, &si.ascent, &si.descent, &si.leading);
+
+ bool kerningEnabled;
bool letterSpacingIsAbsolute;
QFixed letterSpacing, wordSpacing;
#ifndef QT_NO_RAWFONT
if (useRawFont) {
QTextCharFormat f = format(&si);
+ kerningEnabled = f.fontKerning();
wordSpacing = QFixed::fromReal(f.fontWordSpacing());
letterSpacing = QFixed::fromReal(f.fontLetterSpacing());
letterSpacingIsAbsolute = true;
@@ -912,6 +926,7 @@ void QTextEngine::shapeText(int item) const
#endif
{
QFont font = this->font(si);
+ kerningEnabled = font.d->kerning;
letterSpacingIsAbsolute = font.d->letterSpacingIsAbsolute;
letterSpacing = font.d->letterSpacing;
wordSpacing = font.d->wordSpacing;
@@ -920,6 +935,13 @@ void QTextEngine::shapeText(int item) const
letterSpacing *= font.d->dpi / qt_defaultDpiY();
}
+ si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, kerningEnabled);
+ if (!si.num_glyphs)
+ return; // ### report shaping errors somehow
+ layoutData->used += si.num_glyphs;
+
+ QGlyphLayout glyphs = shapedGlyphs(&si);
+
if (letterSpacing != 0) {
for (int i = 1; i < si.num_glyphs; ++i) {
if (glyphs.attributes[i].clusterStart) {
@@ -940,12 +962,12 @@ void QTextEngine::shapeText(int item) const
}
if (wordSpacing != 0) {
for (int i = 0; i < si.num_glyphs; ++i) {
- if (glyphs.attributes[i].justification == HB_Space
- || glyphs.attributes[i].justification == HB_Arabic_Space) {
+ if (glyphs.attributes[i].justification == QGlyphAttributes::Space
+ || glyphs.attributes[i].justification == QGlyphAttributes::Arabic_Space) {
// word spacing only gets added once to a consecutive run of spaces (see CSS spec)
if (i + 1 == si.num_glyphs
- ||(glyphs.attributes[i+1].justification != HB_Space
- && glyphs.attributes[i+1].justification != HB_Arabic_Space))
+ ||(glyphs.attributes[i+1].justification != QGlyphAttributes::Space
+ && glyphs.attributes[i+1].justification != QGlyphAttributes::Arabic_Space))
glyphs.advances_x[i] += wordSpacing;
}
}
@@ -955,14 +977,6 @@ void QTextEngine::shapeText(int item) const
si.width += glyphs.advances_x[i] * !glyphs.attributes[i].dontPrint;
}
-static inline bool hasCaseChange(const QScriptItem &si)
-{
- return si.analysis.flags == QScriptAnalysis::SmallCaps ||
- si.analysis.flags == QScriptAnalysis::Uppercase ||
- si.analysis.flags == QScriptAnalysis::Lowercase;
-}
-
-
static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)
{
if (num > 0 && destination.glyphs != source.glyphs) {
@@ -973,84 +987,60 @@ static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLa
}
}
+QT_BEGIN_INCLUDE_NAMESPACE
+
+#include <private/qharfbuzz_p.h>
+
+QT_END_INCLUDE_NAMESPACE
+
Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t));
Q_STATIC_ASSERT(sizeof(HB_GlyphAttributes) == sizeof(QGlyphAttributes));
Q_STATIC_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
Q_STATIC_ASSERT(sizeof(HB_FixedPoint) == sizeof(QFixedPoint));
-/// take the item from layoutData->items and
-void QTextEngine::shapeTextWithHarfbuzz(int item) const
+// ask the font engine to find out which glyphs (as an index in the specific font) to use for the text in one item.
+static bool stringToGlyphs(HB_ShaperItem *item, QGlyphLayout *glyphs, QFontEngine *fontEngine)
{
- QScriptItem &si = layoutData->items[item];
-
- si.glyph_data_offset = layoutData->used;
+ int nGlyphs = item->num_glyphs;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
+ QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
+ if (item->item.bidiLevel % 2)
+ shaperFlags |= QFontEngine::RightToLeft;
- bool kerningEnabled;
-#ifndef QT_NO_RAWFONT
- if (useRawFont) {
- QTextCharFormat f = format(&si);
- kerningEnabled = f.fontKerning();
- } else
-#endif
- kerningEnabled = this->font(si).d->kerning;
+ bool result = fontEngine->stringToCMap(reinterpret_cast<const QChar *>(item->string + item->item.pos), item->item.length, glyphs, &nGlyphs, shaperFlags);
+ item->num_glyphs = nGlyphs;
+ glyphs->numGlyphs = nGlyphs;
+ return result;
+}
+int QTextEngine::shapeTextWithHarfbuzz(QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, bool kerningEnabled) const
+{
HB_ShaperItem entire_shaper_item;
memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));
- entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
- entire_shaper_item.stringLength = layoutData->string.length();
+ entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(string);
+ entire_shaper_item.stringLength = itemLength;
entire_shaper_item.item.script = script_to_hbscript(si.analysis.script);
- entire_shaper_item.item.pos = si.position;
- entire_shaper_item.item.length = length(item);
+ entire_shaper_item.item.pos = 0;
+ entire_shaper_item.item.length = itemLength;
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
- QVarLengthArray<HB_UChar16, 256> casedString;
- if (hasCaseChange(si)) {
- if (casedString.size() < static_cast<int>(entire_shaper_item.item.length))
- casedString.resize(entire_shaper_item.item.length);
- HB_UChar16 *uc = casedString.data();
- for (uint i = 0; i < entire_shaper_item.item.length; ++i) {
- uint ucs4 = entire_shaper_item.string[si.position + i];
- if (QChar::isHighSurrogate(ucs4)) {
- uc[i] = ucs4; // high part never changes in simple casing
- if (i + 1 < entire_shaper_item.item.length) {
- ushort low = entire_shaper_item.string[si.position + i + 1];
- if (QChar::isLowSurrogate(low)) {
- ucs4 = QChar::surrogateToUcs4(ucs4, low);
- ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
- : QChar::toUpper(ucs4);
- uc[++i] = QChar::lowSurrogate(ucs4);
- }
- }
- } else {
- uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
- : QChar::toUpper(ucs4);
- }
- }
- entire_shaper_item.item.pos = 0;
- entire_shaper_item.string = uc;
- entire_shaper_item.stringLength = entire_shaper_item.item.length;
- }
-
entire_shaper_item.shaperFlags = 0;
if (!kerningEnabled)
entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning;
if (option.useDesignMetrics())
entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics;
- entire_shaper_item.num_glyphs = qMax(layoutData->glyphLayout.numGlyphs - layoutData->used, int(entire_shaper_item.item.length));
- if (!ensureSpace(entire_shaper_item.num_glyphs))
- return;
+ entire_shaper_item.num_glyphs = itemLength;
+
QGlyphLayout initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
+ if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, fontEngine)) {
if (!ensureSpace(entire_shaper_item.num_glyphs))
- return;
+ return 0;
initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
+ if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, fontEngine)) {
// ############ if this happens there's a bug in the fontengine
- return;
+ return 0;
}
}
@@ -1060,7 +1050,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
itemBoundaries[0] = entire_shaper_item.item.pos;
itemBoundaries[1] = 0;
- if (font->type() == QFontEngine::Multi) {
+ if (fontEngine->type() == QFontEngine::Multi) {
uint lastEngine = 0;
int charIdx = entire_shaper_item.item.pos;
const int stringEnd = charIdx + entire_shaper_item.item.length;
@@ -1099,18 +1089,17 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
if (shaper_item.num_glyphs < shaper_item.item.length)
shaper_item.num_glyphs = shaper_item.item.length;
- QFontEngine *actualFontEngine = font;
+ QFontEngine *actualFontEngine = fontEngine;
uint engineIdx = 0;
- if (font->type() == QFontEngine::Multi) {
+ if (fontEngine->type() == QFontEngine::Multi) {
engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24);
- actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
+ actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);
+ si.ascent = qMax(actualFontEngine->ascent(), si.ascent);
+ si.descent = qMax(actualFontEngine->descent(), si.descent);
+ si.leading = qMax(actualFontEngine->leading(), si.leading);
}
- si.ascent = qMax(actualFontEngine->ascent(), si.ascent);
- si.descent = qMax(actualFontEngine->descent(), si.descent);
- si.leading = qMax(actualFontEngine->leading(), si.leading);
-
shaper_item.font = (HB_Font)actualFontEngine->harfbuzzFont();
shaper_item.face = (HB_Face)actualFontEngine->harfbuzzFace();
@@ -1120,7 +1109,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
do {
if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs))
- return;
+ return 0;
const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
if (shaper_item.num_glyphs > shaper_item.item.length)
@@ -1137,8 +1126,6 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
}
shaper_item.log_clusters = logClusters(&si) + shaper_item.item.pos - entire_shaper_item.item.pos;
-
-// qDebug(" .. num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs);
} while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz.
QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);
@@ -1158,10 +1145,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
glyph_pos += shaper_item.num_glyphs;
}
-// qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs);
- si.num_glyphs = glyph_pos;
-
- layoutData->used += si.num_glyphs;
+ return glyph_pos;
}
void QTextEngine::init(QTextEngine *e)
@@ -1821,7 +1805,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
point->type = type;
point->glyph = glyph;
- if (type >= HB_Arabic_Normal) {
+ if (type >= QGlyphAttributes::Arabic_Normal) {
QChar ch(0x640); // Kashida character
QGlyphLayoutArray<8> glyphs;
int nglyphs = 7;
@@ -1829,7 +1813,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
if (glyphs.glyphs[0] && glyphs.advances_x[0] != 0) {
point->kashidaWidth = glyphs.advances_x[0];
} else {
- point->type = HB_NoJustification;
+ point->type = QGlyphAttributes::NoJustification;
point->kashidaWidth = 0;
}
}
@@ -1897,7 +1881,7 @@ void QTextEngine::justify(const QScriptLine &line)
for (int i = 0; i < nItems; ++i) {
QScriptItem &si = layoutData->items[firstItem + i];
- int kashida_type = HB_Arabic_Normal;
+ int kashida_type = QGlyphAttributes::Arabic_Normal;
int kashida_pos = -1;
int start = qMax(line.from - si.position, 0);
@@ -1921,11 +1905,11 @@ void QTextEngine::justify(const QScriptLine &line)
int justification = g.attributes[i].justification;
switch(justification) {
- case HB_NoJustification:
+ case QGlyphAttributes::NoJustification:
break;
- case HB_Space :
+ case QGlyphAttributes::Space :
// fall through
- case HB_Arabic_Space :
+ case QGlyphAttributes::Arabic_Space :
if (kashida_pos >= 0) {
// qDebug("kashida position at %d in word", kashida_pos);
set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si));
@@ -1936,19 +1920,19 @@ void QTextEngine::justify(const QScriptLine &line)
}
}
kashida_pos = -1;
- kashida_type = HB_Arabic_Normal;
+ kashida_type = QGlyphAttributes::Arabic_Normal;
// fall through
- case HB_Character :
+ case QGlyphAttributes::Character :
set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si));
maxJustify = qMax(maxJustify, justification);
break;
- case HB_Arabic_Normal :
- case HB_Arabic_Waw :
- case HB_Arabic_BaRa :
- case HB_Arabic_Alef :
- case HB_Arabic_HaaDal :
- case HB_Arabic_Seen :
- case HB_Arabic_Kashida :
+ case QGlyphAttributes::Arabic_Normal :
+ case QGlyphAttributes::Arabic_Waw :
+ case QGlyphAttributes::Arabic_BaRa :
+ case QGlyphAttributes::Arabic_Alef :
+ case QGlyphAttributes::Arabic_HaaDal :
+ case QGlyphAttributes::Arabic_Seen :
+ case QGlyphAttributes::Arabic_Kashida :
if (justification >= kashida_type) {
kashida_pos = i;
kashida_type = justification;
@@ -1977,9 +1961,9 @@ void QTextEngine::justify(const QScriptLine &line)
// qDebug(" minKashida=%f, need=%f", minKashida.toReal(), need.toReal());
// distribute in priority order
- if (maxJustify >= HB_Arabic_Normal) {
+ if (maxJustify >= QGlyphAttributes::Arabic_Normal) {
while (need >= minKashida) {
- for (int type = maxJustify; need >= minKashida && type >= HB_Arabic_Normal; --type) {
+ for (int type = maxJustify; need >= minKashida && type >= QGlyphAttributes::Arabic_Normal; --type) {
for (int i = 0; need >= minKashida && i < nPoints; ++i) {
if (justificationPoints[i].type == type && justificationPoints[i].kashidaWidth <= need) {
justificationPoints[i].glyph.justifications->nKashidas++;
@@ -1996,7 +1980,7 @@ void QTextEngine::justify(const QScriptLine &line)
if (!need)
goto end;
- maxJustify = qMin(maxJustify, (int)HB_Space);
+ maxJustify = qMin(maxJustify, int(QGlyphAttributes::Space));
for (int type = maxJustify; need != 0 && type > 0; --type) {
int n = 0;
for (int i = 0; i < nPoints; ++i) {
@@ -2438,12 +2422,13 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
const int end = si.position + length(&si);
for (int i = si.position; i < end - 1; ++i) {
- if (layoutData->string.at(i) == QLatin1Char('&')) {
+ if (layoutData->string.at(i) == QLatin1Char('&')
+ && !attributes[i + 1].whiteSpace && attributes[i + 1].graphemeBoundary) {
const int gp = logClusters[i - si.position];
glyphs.attributes[gp].dontPrint = true;
- attributes[i + 1].graphemeBoundary = false;
- attributes[i + 1].lineBreak = false;
- attributes[i + 1].whiteSpace = false;
+ // emulate grapheme cluster
+ attributes[i] = attributes[i + 1];
+ memset(attributes + i + 1, 0, sizeof(QCharAttributes));
if (layoutData->string.at(i + 1) == QLatin1Char('&'))
++i;
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index ec7f7407b2..6d46231c67 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -96,6 +96,20 @@ typedef quint8 q_hb_bitfield;
#endif
typedef struct {
+ typedef enum {
+ NoJustification= 0, /* Justification can't be applied after this glyph */
+ Arabic_Space = 1, /* This glyph represents a space inside arabic text */
+ Character = 2, /* Inter-character justification point follows this glyph */
+ Space = 4, /* This glyph represents a blank outside an Arabic run */
+ Arabic_Normal = 7, /* Normal Middle-Of-Word glyph that connects to the right (begin) */
+ Arabic_Waw = 8, /* Next character is final form of Waw/Ain/Qaf/Fa */
+ Arabic_BaRa = 9, /* Next two chars are Ba + Ra/Ya/AlefMaksura */
+ Arabic_Alef = 10, /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
+ Arabic_HaaDal = 11, /* Next character is final form of Haa/Dal/Taa Marbutah */
+ Arabic_Seen = 12, /* Initial or Medial form Of Seen/Sad */
+ Arabic_Kashida = 13 /* Kashida(U+640) in middle of word */
+ } JustificationClass;
+
q_hb_bitfield justification :4; /* Justification class */
q_hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
q_hb_bitfield mark :1; /* needs to be positioned around base char */
@@ -685,7 +699,7 @@ private:
void setBoundary(int strPos) const;
void addRequiredBoundaries() const;
void shapeText(int item) const;
- void shapeTextWithHarfbuzz(int item) const;
+ int shapeTextWithHarfbuzz(QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, bool kerningEnabled) const;
void splitItem(int item, int pos) const;
int endOfLine(int lineNum);
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index a895864d76..47cd928541 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -47,6 +47,7 @@
#include "qnetworkreply_p.h"
#include "QtCore/qhash.h"
#include "QtCore/qmutex.h"
+#include "QtCore/qstringlist.h"
#include "QtNetwork/private/qnetworksession_p.h"
#include "qnetworkaccesscachebackend_p.h"
@@ -110,6 +111,22 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM
return 0;
}
+QStringList QNetworkAccessManagerPrivate::backendSupportedSchemes() const
+{
+ if (QNetworkAccessBackendFactoryData::valid.load()) {
+ QMutexLocker locker(&factoryData()->mutex);
+ QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin();
+ QNetworkAccessBackendFactoryData::ConstIterator end = factoryData()->constEnd();
+ QStringList schemes;
+ while (it != end) {
+ schemes += (*it)->supportedSchemes();
+ ++it;
+ }
+ return schemes;
+ }
+ return QStringList();
+}
+
QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice()
{
if (reply->outgoingDataBuffer)
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index bf284414e0..d9657cf750 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -62,6 +62,7 @@ class QAuthenticator;
class QNetworkProxy;
class QNetworkProxyQuery;
class QNetworkRequest;
+class QStringList;
class QUrl;
class QUrlInfo;
class QSslConfiguration;
@@ -219,6 +220,7 @@ class QNetworkAccessBackendFactory
public:
QNetworkAccessBackendFactory();
virtual ~QNetworkAccessBackendFactory();
+ virtual QStringList supportedSchemes() const = 0;
virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const = 0;
};
diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp
index b6c04dddea..a91751523a 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend.cpp
+++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp
@@ -42,6 +42,7 @@
#include "qnetworkaccessdebugpipebackend_p.h"
#include "QtCore/qdatastream.h"
#include <QCoreApplication>
+#include <QStringList>
#include <QUrlQuery>
#include "private/qnoncontiguousbytedevice_p.h"
@@ -54,6 +55,11 @@ enum {
WriteBufferSize = ReadBufferSize
};
+QStringList QNetworkAccessDebugPipeBackendFactory::supportedSchemes() const
+{
+ return QStringList(QStringLiteral("debugpipe"));
+}
+
QNetworkAccessBackend *
QNetworkAccessDebugPipeBackendFactory::create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const
diff --git a/src/network/access/qnetworkaccessdebugpipebackend_p.h b/src/network/access/qnetworkaccessdebugpipebackend_p.h
index 0ae49de132..7593dfa9b7 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend_p.h
+++ b/src/network/access/qnetworkaccessdebugpipebackend_p.h
@@ -102,6 +102,7 @@ private:
class QNetworkAccessDebugPipeBackendFactory: public QNetworkAccessBackendFactory
{
public:
+ virtual QStringList supportedSchemes() const Q_DECL_OVERRIDE;
virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const;
};
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 13428cc802..13e7394003 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -49,6 +49,17 @@
QT_BEGIN_NAMESPACE
+QStringList QNetworkAccessFileBackendFactory::supportedSchemes() const
+{
+ QStringList schemes;
+ schemes << QStringLiteral("file")
+ << QStringLiteral("qrc");
+#if defined(Q_OS_ANDROID)
+ schemes << QStringLiteral("assets");
+#endif
+ return schemes;
+}
+
QNetworkAccessBackend *
QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const
diff --git a/src/network/access/qnetworkaccessfilebackend_p.h b/src/network/access/qnetworkaccessfilebackend_p.h
index a52ecef165..157461fee7 100644
--- a/src/network/access/qnetworkaccessfilebackend_p.h
+++ b/src/network/access/qnetworkaccessfilebackend_p.h
@@ -88,6 +88,7 @@ private:
class QNetworkAccessFileBackendFactory: public QNetworkAccessBackendFactory
{
public:
+ virtual QStringList supportedSchemes() const Q_DECL_OVERRIDE;
virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const;
};
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 737d7d0151..246eb41657 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -43,6 +43,7 @@
#include "qnetworkaccessmanager_p.h"
#include "QtNetwork/qauthenticator.h"
#include "private/qnoncontiguousbytedevice_p.h"
+#include <QStringList>
#ifndef QT_NO_FTP
@@ -61,6 +62,11 @@ static QByteArray makeCacheKey(const QUrl &url)
QUrl::RemoveFragment);
}
+QStringList QNetworkAccessFtpBackendFactory::supportedSchemes() const
+{
+ return QStringList(QStringLiteral("ftp"));
+}
+
QNetworkAccessBackend *
QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index 1bc377d80e..c006d450b8 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -111,6 +111,7 @@ private:
class QNetworkAccessFtpBackendFactory: public QNetworkAccessBackendFactory
{
public:
+ virtual QStringList supportedSchemes() const Q_DECL_OVERRIDE;
virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
const QNetworkRequest &request) const;
};
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 83cb729589..402bdeba24 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -431,6 +431,7 @@ static void ensureInitialized()
QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
: QObject(*new QNetworkAccessManagerPrivate, parent)
{
+ Q_D(QNetworkAccessManager);
ensureInitialized();
qRegisterMetaType<QNetworkReply::NetworkError>();
@@ -447,6 +448,19 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
#endif
qRegisterMetaType<QNetworkReply::NetworkError>();
qRegisterMetaType<QSharedPointer<char> >();
+
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (!d->networkSessionRequired) {
+ // if a session is required, we track online state through
+ // the QNetworkSession's signals
+ connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)),
+ SLOT(_q_onlineStateChanged(bool)));
+ // we would need all active configurations to check for
+ // d->networkConfigurationManager.isOnline(), which is asynchronous
+ // and potentially expensive. We can just check the configuration here
+ d->online = (d->networkConfiguration.state() & QNetworkConfiguration::Active);
+ }
+#endif
}
/*!
@@ -833,6 +847,11 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ
To restore the default network configuration set the network configuration to the value
returned from QNetworkConfigurationManager::defaultConfiguration().
+ Setting a network configuration means that the QNetworkAccessManager instance will only
+ be using the specified one. In particular, if the default network configuration changes
+ (upon e.g. Wifi being available), this new configuration needs to be enabled
+ manually if desired.
+
\snippet code/src_network_access_qnetworkaccessmanager.cpp 2
If an invalid network configuration is set, a network session will not be created. In this
@@ -844,7 +863,10 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ
*/
void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config)
{
- d_func()->createSession(config);
+ Q_D(QNetworkAccessManager);
+ d->networkConfiguration = config;
+ d->customNetworkConfiguration = true;
+ d->createSession(config);
}
/*!
@@ -926,16 +948,23 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess
{
Q_D(const QNetworkAccessManager);
- QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());
- if (networkSession) {
- // d->online holds online/offline state of this network session.
+ if (d->networkSessionRequired) {
+ QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());
+ if (networkSession) {
+ // d->online holds online/offline state of this network session.
+ if (d->online)
+ return d->networkAccessible;
+ else
+ return NotAccessible;
+ } else {
+ // Network accessibility is either disabled or unknown.
+ return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility;
+ }
+ } else {
if (d->online)
return d->networkAccessible;
else
return NotAccessible;
- } else {
- // Network accessibility is either disabled or unknown.
- return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility;
}
}
@@ -1050,10 +1079,10 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
return new QDisabledNetworkReply(this, req, op);
}
- if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.isEmpty())) {
+ if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) {
QNetworkConfigurationManager manager;
- if (!d->networkConfiguration.isEmpty()) {
- d->createSession(manager.configurationFromIdentifier(d->networkConfiguration));
+ if (!d->networkConfiguration.identifier().isEmpty()) {
+ d->createSession(d->networkConfiguration);
} else {
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
d->createSession(manager.defaultConfiguration());
@@ -1130,6 +1159,57 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
return reply;
}
+/*!
+ \since 5.2
+
+ Lists all the URL schemes supported by the access manager.
+
+ \sa supportedSchemesImplementation()
+*/
+QStringList QNetworkAccessManager::supportedSchemes() const
+{
+ QStringList schemes;
+ QNetworkAccessManager *self = const_cast<QNetworkAccessManager *>(this); // We know we call a const slot
+ QMetaObject::invokeMethod(self, "supportedSchemesImplementation", Qt::DirectConnection,
+ Q_RETURN_ARG(QStringList, schemes));
+ schemes.removeDuplicates();
+ return schemes;
+}
+
+/*!
+ \since 5.2
+
+ Lists all the URL schemes supported by the access manager.
+
+ You should not call this function directly; use
+ QNetworkAccessManager::supportedSchemes() instead.
+
+ Reimplement this slot to provide your own supported schemes
+ in a QNetworkAccessManager subclass. It is for instance necessary
+ when your subclass provides support for new protocols.
+
+ Because of binary compatibility constraints, the supportedSchemes()
+ method (introduced in Qt 5.2) is not virtual. Instead, supportedSchemes()
+ will dynamically detect and call this slot.
+
+ \sa supportedSchemes()
+*/
+QStringList QNetworkAccessManager::supportedSchemesImplementation() const
+{
+ Q_D(const QNetworkAccessManager);
+
+ QStringList schemes = d->backendSupportedSchemes();
+ // Those ones don't exist in backends
+#ifndef QT_NO_HTTP
+ schemes << QStringLiteral("http");
+#ifndef QT_NO_SSL
+ if (QSslSocket::supportsSsl())
+ schemes << QStringLiteral("https");
+#endif
+#endif
+ schemes << QStringLiteral("data");
+ return schemes;
+}
/*!
\since 5.0
@@ -1403,7 +1483,7 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
Q_Q(QNetworkAccessManager);
QSharedPointer<QNetworkSession> networkSession(getNetworkSession());
if (networkSession) {
- networkConfiguration = networkSession->configuration().identifier();
+ networkConfiguration = networkSession->configuration();
//disconnect from old session
QObject::disconnect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
@@ -1437,6 +1517,18 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession
}
}
}
+
+void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline)
+{
+ // if the user set a config, we only care whether this one is active.
+ // Otherwise, this QNAM is online if there is an online config.
+ if (customNetworkConfiguration) {
+ online = (networkConfiguration.state() & QNetworkConfiguration::Active);
+ } else {
+ online = isOnline;
+ }
+}
+
#endif // QT_NO_BEARERMANAGEMENT
QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart)
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 826c8e47d7..46e46c49ab 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -97,6 +97,9 @@ public:
explicit QNetworkAccessManager(QObject *parent = 0);
~QNetworkAccessManager();
+ // ### Qt 6: turn into virtual
+ QStringList supportedSchemes() const;
+
void clearAccessCache();
#ifndef QT_NO_NETWORKPROXY
@@ -153,6 +156,9 @@ protected:
virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
QIODevice *outgoingData = 0);
+protected Q_SLOTS:
+ QStringList supportedSchemesImplementation() const;
+
private:
friend class QNetworkReplyImplPrivate;
friend class QNetworkReplyHttpImpl;
@@ -165,6 +171,7 @@ private:
#ifndef QT_NO_BEARERMANAGEMENT
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
+ Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool))
#endif
};
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index cf756dad7b..292755e7eb 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -60,6 +60,9 @@
#include "QtNetwork/qnetworkproxy.h"
#include "QtNetwork/qnetworksession.h"
#include "qnetworkaccessauthenticationmanager_p.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#include "QtNetwork/qnetworkconfigmanager.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -79,6 +82,10 @@ public:
#endif
#ifndef QT_NO_BEARERMANAGEMENT
lastSessionState(QNetworkSession::Invalid),
+ networkConfiguration(networkConfigurationManager.defaultConfiguration()),
+ customNetworkConfiguration(false),
+ networkSessionRequired(networkConfigurationManager.capabilities()
+ & QNetworkConfigurationManager::NetworkSessionRequired),
networkAccessible(QNetworkAccessManager::Accessible),
activeReplyCount(0),
online(false),
@@ -117,6 +124,7 @@ public:
#endif
QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request);
+ QStringList backendSupportedSchemes() const;
#ifndef QT_NO_BEARERMANAGEMENT
void createSession(const QNetworkConfiguration &config);
@@ -127,6 +135,7 @@ public:
void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config,
bool isSeamless);
void _q_networkSessionStateChanged(QNetworkSession::State state);
+ void _q_onlineStateChanged(bool isOnline);
#endif
QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart);
@@ -148,7 +157,12 @@ public:
QSharedPointer<QNetworkSession> networkSessionStrongRef;
QWeakPointer<QNetworkSession> networkSessionWeakRef;
QNetworkSession::State lastSessionState;
- QString networkConfiguration;
+ QNetworkConfigurationManager networkConfigurationManager;
+ QNetworkConfiguration networkConfiguration;
+ // we need to track whether the user set a config or not,
+ // because the default config might change
+ bool customNetworkConfiguration;
+ bool networkSessionRequired;
QNetworkAccessManager::NetworkAccessibility networkAccessible;
int activeReplyCount;
bool online;
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index 4e33001d8d..d5f5de10a2 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -161,6 +161,8 @@ QT_BEGIN_NAMESPACE
mechanism for renegotiating the connection parameters. When enabled, this
option can allow connections for legacy servers, but it introduces the
possibility that an attacker could inject plaintext into the SSL session.
+ \value SslOptionDisableSessionSharing Disables SSL session sharing via
+ the session ID handshake attribute.
By default, SslOptionDisableEmptyFragments is turned on since this causes
problems with a large number of servers. SslOptionDisableLegacyRenegotiation
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index 06d80965e2..2429f3d580 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -95,7 +95,8 @@ namespace QSsl {
SslOptionDisableSessionTickets = 0x02,
SslOptionDisableCompression = 0x04,
SslOptionDisableServerNameIndication = 0x08,
- SslOptionDisableLegacyRenegotiation = 0x10
+ SslOptionDisableLegacyRenegotiation = 0x10,
+ SslOptionDisableSessionSharing = 0x20
};
Q_DECLARE_FLAGS(SslOptions, SslOption)
}
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index d515f27865..24428a0321 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -1449,7 +1449,7 @@ void QSslSocketBackendPrivate::continueHandshake()
#endif
// Cache this SSL session inside the QSslContext
- if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionTickets)) {
+ if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionSharing)) {
if (!sslContextPointer->cacheSession(ssl))
sslContextPointer.clear(); // we could not cache the session
}
diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
index 58f24c0a04..80453816fc 100644
--- a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
+++ b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
@@ -41,17 +41,6 @@
#include "qxlibeglintegration_p.h"
-static int countBits(unsigned long mask)
-{
- int count = 0;
- while (mask != 0) {
- if (mask & 1)
- ++count;
- mask >>= 1;
- }
- return count;
-}
-
VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
{
VisualID visualId = 0;
@@ -92,9 +81,9 @@ VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay
return visualId;
}
- int visualRedSize = countBits(chosenVisualInfo->red_mask);
- int visualGreenSize = countBits(chosenVisualInfo->green_mask);
- int visualBlueSize = countBits(chosenVisualInfo->blue_mask);
+ int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask);
+ int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask);
+ int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask);
int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size
bool visualMatchesConfig = false;
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index fedaa3a655..77ea0f1db8 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -54,16 +54,24 @@ enum { debug = 0 };
static inline QByteArray detectDesktopEnvironment()
{
- if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION"))
- return QByteArray("KDE");
- // Check Unity first, whose older versions also have "GNOME_DESKTOP_SESSION_ID" set.
const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");
- if (xdgCurrentDesktop == "Unity")
- return QByteArrayLiteral("UNITY");
- // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it
- if (qgetenv("DESKTOP_SESSION") == "gnome" || !qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID"))
- return QByteArray("GNOME");
- return QByteArray("UNKNOWN");
+ if (!xdgCurrentDesktop.isEmpty())
+ return xdgCurrentDesktop.toUpper(); // KDE, GNOME, UNITY, LXDE, MATE, XFCE...
+
+ // Classic fallbacks
+ if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION"))
+ return QByteArrayLiteral("KDE");
+ if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID"))
+ return QByteArrayLiteral("GNOME");
+
+ // Fallback to checking $DESKTOP_SESSION (unreliable)
+ const QByteArray desktopSession = qgetenv("DESKTOP_SESSION");
+ if (desktopSession == "gnome")
+ return QByteArrayLiteral("GNOME");
+ if (desktopSession == "xfce")
+ return QByteArrayLiteral("XFCE");
+
+ return QByteArrayLiteral("UNKNOWN");
}
static inline bool checkExecutable(const QString &candidate, QString *result)
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index cabddcc815..bf5131f393 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -492,7 +492,11 @@ QStringList QGenericUnixTheme::themeNames()
#ifndef QT_NO_SETTINGS
result.push_back(QLatin1String(QKdeTheme::name));
#endif
- } else { // Gnome, Unity, other Gtk-based desktops like XFCE.
+ } else if (desktopEnvironment == QByteArrayLiteral("GNOME") ||
+ desktopEnvironment == QByteArrayLiteral("UNITY") ||
+ desktopEnvironment == QByteArrayLiteral("MATE") ||
+ desktopEnvironment == QByteArrayLiteral("XFCE") ||
+ desktopEnvironment == QByteArrayLiteral("LXDE")) { // Gtk-based desktops
// prefer the GTK2 theme implementation with native dialogs etc.
result.push_back(QStringLiteral("gtk2"));
// fallback to the generic Gnome theme if loading the GTK2 theme fails
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 8e9fcc443b..5d1600dba6 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -118,7 +118,7 @@ static bool isMouseEvent(NSEvent *ev)
// Windows with a transient parent (such as combobox popup windows)
// cannot become the main window:
- if (m_cocoaPlatformWindow->window()->transientParent())
+ if (m_cocoaPlatformWindow && m_cocoaPlatformWindow->window()->transientParent())
canBecomeMain = NO;
return canBecomeMain;
@@ -155,6 +155,9 @@ static bool isMouseEvent(NSEvent *ev)
- (BOOL)canBecomeKeyWindow
{
+ if (!m_cocoaPlatformWindow)
+ return NO;
+
// Only tool or dialog windows should become key:
if (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog)
return YES;
diff --git a/src/plugins/platforms/ios/plugin.pro b/src/plugins/platforms/ios/plugin.pro
index 591a0a67ed..5f46ea7ef5 100644
--- a/src/plugins/platforms/ios/plugin.pro
+++ b/src/plugins/platforms/ios/plugin.pro
@@ -4,7 +4,7 @@ PLUGIN_TYPE = platforms
load(qt_plugin)
QT += core-private gui-private platformsupport-private
-LIBS += -framework UIKit -framework QuartzCore
+LIBS += -framework Foundation -framework UIKit -framework QuartzCore
OBJECTIVE_SOURCES = \
plugin.mm \
diff --git a/src/plugins/platforms/qnx/main.cpp b/src/plugins/platforms/qnx/main.cpp
index ea50b12cb3..fb81928625 100644
--- a/src/plugins/platforms/qnx/main.cpp
+++ b/src/plugins/platforms/qnx/main.cpp
@@ -46,9 +46,8 @@ QT_BEGIN_NAMESPACE
QPlatformIntegration *QQnxIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
- Q_UNUSED(paramList);
if (system.toLower() == QLatin1String("qnx"))
- return new QQnxIntegration;
+ return new QQnxIntegration(paramList);
return 0;
}
diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro
index 203cdebda9..50884ace66 100644
--- a/src/plugins/platforms/qnx/qnx.pro
+++ b/src/plugins/platforms/qnx/qnx.pro
@@ -11,11 +11,11 @@ QT += platformsupport platformsupport-private
CONFIG(blackberry) {
CONFIG += qqnx_pps
- # Unomment this to enable screen event handling
- # through a dedicated thread.
- # DEFINES += QQNX_SCREENEVENTTHREAD
+ # Uncomment following line to enable screen event
+ # handling through a dedicated thread.
+ # CONFIG += qqnx_screeneventthread
} else {
- DEFINES += QQNX_SCREENEVENTTHREAD
+ CONFIG += qqnx_screeneventthread
}
# Uncomment these to enable debugging output for various aspects of the plugin
@@ -40,11 +40,11 @@ CONFIG(blackberry) {
#DEFINES += QQNXVIRTUALKEYBOARD_DEBUG
#DEFINES += QQNXWINDOW_DEBUG
#DEFINES += QQNXCURSOR_DEBUG
+#DEFINES += QQNXFILEPICKER_DEBUG
SOURCES = main.cpp \
qqnxbuffer.cpp \
- qqnxscreeneventthread.cpp \
qqnxintegration.cpp \
qqnxscreen.cpp \
qqnxwindow.cpp \
@@ -60,7 +60,6 @@ SOURCES = main.cpp \
HEADERS = main.h \
qqnxbuffer.h \
- qqnxscreeneventthread.h \
qqnxkeytranslator.h \
qqnxintegration.h \
qqnxscreen.h \
@@ -75,6 +74,12 @@ HEADERS = main.h \
qqnxservices.h \
qqnxcursor.h
+CONFIG(qqnx_screeneventthread) {
+ DEFINES += QQNX_SCREENEVENTTHREAD
+ SOURCES += qqnxscreeneventthread.cpp
+ HEADERS += qqnxscreeneventthread.h
+}
+
LIBS += -lscreen
contains(QT_CONFIG, opengles2) {
@@ -91,8 +96,7 @@ CONFIG(blackberry) {
qqnxbpseventfilter.cpp \
qqnxvirtualkeyboardbps.cpp \
qqnxtheme.cpp \
- qqnxsystemsettings.cpp \
- qqnxfiledialoghelper.cpp
+ qqnxsystemsettings.cpp
HEADERS += qqnxnavigatorbps.h \
qqnxeventdispatcher_blackberry.h \
@@ -105,6 +109,17 @@ CONFIG(blackberry) {
LIBS += -lbps
}
+CONFIG(blackberry-playbook) {
+ SOURCES += qqnxfiledialoghelper_playbook.cpp
+} else {
+ CONFIG(blackberry) {
+ SOURCES += qqnxfiledialoghelper_bb10.cpp \
+ qqnxfilepicker.cpp
+
+ HEADERS += qqnxfilepicker.h
+ }
+}
+
CONFIG(qqnx_pps) {
DEFINES += QQNX_PPS
diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
index d94d3c092a..133bf02fee 100644
--- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
+++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
@@ -41,11 +41,12 @@
#include "qqnxbpseventfilter.h"
#include "qqnxnavigatoreventhandler.h"
-#include "qqnxfiledialoghelper.h"
#include "qqnxscreen.h"
#include "qqnxscreeneventhandler.h"
#include "qqnxvirtualkeyboardbps.h"
+#include "qqnxfiledialoghelper.h"
+#include <QCoreApplication>
#include <QAbstractEventDispatcher>
#include <QDebug>
@@ -126,6 +127,7 @@ void QQnxBpsEventFilter::unregisterForScreenEvents(QQnxScreen *screen)
qWarning("QQNX: failed to unregister for screen events on screen %p", screen->nativeContext());
}
+#if defined(Q_OS_BLACKBERRY_TABLET)
void QQnxBpsEventFilter::registerForDialogEvents(QQnxFileDialogHelper *dialog)
{
if (dialog_request_events(0) != BPS_SUCCESS)
@@ -141,6 +143,7 @@ void QQnxBpsEventFilter::unregisterForDialogEvents(QQnxFileDialogHelper *dialog)
if (count == 0)
qWarning("QQNX: attempting to unregister dialog that was not registered");
}
+#endif // Q_OS_BLACKBERRY_TABLET
bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
@@ -160,12 +163,14 @@ bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *me
return m_screenEventHandler->handleEvent(screenEvent);
}
+#if defined(Q_OS_BLACKBERRY_TABLET)
if (eventDomain == dialog_get_domain()) {
dialog_instance_t nativeDialog = dialog_event_get_dialog_instance(event);
QQnxFileDialogHelper *dialog = m_dialogMapper.value(nativeDialog, 0);
if (dialog)
return dialog->handleEvent(event);
}
+#endif
if (eventDomain == navigator_get_domain())
return handleNavigatorEvent(event);
@@ -244,6 +249,11 @@ bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event)
break;
}
+ case NAVIGATOR_LOW_MEMORY:
+ qWarning() << "QGuiApplication based process" << QCoreApplication::applicationPid()
+ << "received \"NAVIGATOR_LOW_MEMORY\" event";
+ return false;
+
default:
qBpsEventFilterDebug() << Q_FUNC_INFO << "Unhandled navigator event. code=" << bps_event_get_code(event);
return false;
diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h
index e897863efb..f8e36823d5 100644
--- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h
+++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.h
@@ -73,8 +73,10 @@ public:
void registerForScreenEvents(QQnxScreen *screen);
void unregisterForScreenEvents(QQnxScreen *screen);
+#ifdef Q_OS_BLACKBERRY_TABLET
void registerForDialogEvents(QQnxFileDialogHelper *dialog);
void unregisterForDialogEvents(QQnxFileDialogHelper *dialog);
+#endif
private:
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h
index e17ea80501..ad2483365b 100644
--- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h
+++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h
@@ -44,12 +44,19 @@
#include <qpa/qplatformdialoghelper.h>
-#include <bps/dialog.h>
QT_BEGIN_NAMESPACE
class QQnxIntegration;
+#if defined(Q_OS_BLACKBERRY_TABLET)
+#include <bps/dialog.h>
+#define NativeDialogPtr dialog_instance_t
+#else
+class QQnxFilePicker;
+#define NativeDialogPtr QQnxFilePicker *
+#endif
+
class QQnxFileDialogHelper : public QPlatformFileDialogHelper
{
Q_OBJECT
@@ -57,7 +64,9 @@ public:
explicit QQnxFileDialogHelper(const QQnxIntegration *);
~QQnxFileDialogHelper();
+#if defined(Q_OS_BLACKBERRY_TABLET)
bool handleEvent(bps_event_t *event);
+#endif
void exec();
@@ -73,21 +82,24 @@ public:
void selectNameFilter(const QString &filter);
QString selectedNameFilter() const;
- dialog_instance_t nativeDialog() const { return m_dialog; }
+ NativeDialogPtr nativeDialog() const { return m_dialog; }
Q_SIGNALS:
void dialogClosed();
private:
void setNameFilter(const QString &filter);
+ void setNameFilters(const QStringList &filters);
const QQnxIntegration *m_integration;
- dialog_instance_t m_dialog;
+ NativeDialogPtr m_dialog;
QFileDialogOptions::AcceptMode m_acceptMode;
QString m_selectedFilter;
QPlatformDialogHelper::DialogCode m_result;
+#if defined(Q_OS_BLACKBERRY_TABLET)
QStringList m_paths;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp
new file mode 100644
index 0000000000..f4c48610a6
--- /dev/null
+++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp
@@ -0,0 +1,209 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqnxfiledialoghelper.h"
+
+#include "qqnxfilepicker.h"
+#include "qqnxbpseventfilter.h"
+#include "qqnxscreen.h"
+#include "qqnxintegration.h"
+
+#include <QDebug>
+#include <QEventLoop>
+#include <QScreen>
+#include <QTimer>
+#include <QWindow>
+
+#ifdef QQNXFILEDIALOGHELPER_DEBUG
+#define qFileDialogHelperDebug qDebug
+#else
+#define qFileDialogHelperDebug QT_NO_QDEBUG_MACRO
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration)
+ : QPlatformFileDialogHelper(),
+ m_integration(integration),
+ m_dialog(new QQnxFilePicker),
+ m_acceptMode(QFileDialogOptions::AcceptOpen),
+ m_selectedFilter(),
+ m_result(QPlatformDialogHelper::Rejected)
+{
+}
+
+QQnxFileDialogHelper::~QQnxFileDialogHelper()
+{
+ delete m_dialog;
+}
+
+void QQnxFileDialogHelper::exec()
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+
+ // Clear any previous results
+ m_dialog->setDirectories(QStringList());
+
+ QEventLoop loop;
+ connect(m_dialog, SIGNAL(closed()), &loop, SLOT(quit()));
+ loop.exec();
+
+ if (m_dialog->selectedFiles().isEmpty())
+ Q_EMIT reject();
+ else
+ Q_EMIT accept();
+}
+
+bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ Q_UNUSED(flags);
+ Q_UNUSED(parent);
+ Q_UNUSED(modality);
+
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+
+ // Create dialog
+ const QSharedPointer<QFileDialogOptions> &opts = options();
+ if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) {
+ // Select one or many files?
+ const QQnxFilePicker::Mode mode = (opts->fileMode() == QFileDialogOptions::ExistingFiles)
+ ? QQnxFilePicker::PickerMultiple : QQnxFilePicker::Picker;
+
+ m_dialog->setMode(mode);
+
+ // Set the actual list of extensions
+ if (!opts->nameFilters().isEmpty())
+ setNameFilters(opts->nameFilters());
+ else
+ setNameFilter(tr("All files (*.*)"));
+ } else {
+ const QQnxFilePicker::Mode mode = (opts->initiallySelectedFiles().count() >= 2)
+ ? QQnxFilePicker::SaverMultiple : QQnxFilePicker::Saver;
+
+ m_dialog->setMode(mode);
+
+ if (!opts->initiallySelectedFiles().isEmpty())
+ m_dialog->setDefaultSaveFileNames(opts->initiallySelectedFiles());
+ }
+
+ // Cache the accept mode so we know which functions to use to get the results back
+ m_acceptMode = opts->acceptMode();
+ m_dialog->setTitle(opts->windowTitle());
+ m_dialog->open();
+
+ return true;
+}
+
+void QQnxFileDialogHelper::hide()
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+ m_dialog->close();
+}
+
+bool QQnxFileDialogHelper::defaultNameFilterDisables() const
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+ return false;
+}
+
+void QQnxFileDialogHelper::setDirectory(const QString &directory)
+{
+ m_dialog->addDirectory(directory);
+}
+
+QString QQnxFileDialogHelper::directory() const
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+ if (!m_dialog->directories().isEmpty())
+ return m_dialog->directories().first();
+
+ return QString();
+}
+
+void QQnxFileDialogHelper::selectFile(const QString &fileName)
+{
+ m_dialog->addDefaultSaveFileName(fileName);
+}
+
+QStringList QQnxFileDialogHelper::selectedFiles() const
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+ return m_dialog->selectedFiles();
+}
+
+void QQnxFileDialogHelper::setFilter()
+{
+ // No native api to support setting a filter from QDir::Filters
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+}
+
+void QQnxFileDialogHelper::selectNameFilter(const QString &filter)
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter;
+ setNameFilter(filter);
+}
+
+QString QQnxFileDialogHelper::selectedNameFilter() const
+{
+ // For now there is no way for the user to change the selected filter
+ // so this just reflects what the developer has set programmatically.
+ qFileDialogHelperDebug() << Q_FUNC_INFO;
+ return m_selectedFilter;
+}
+
+void QQnxFileDialogHelper::setNameFilter(const QString &filter)
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter;
+
+ setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter));
+}
+
+void QQnxFileDialogHelper::setNameFilters(const QStringList &filters)
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO << "filters =" << filters;
+
+ Q_ASSERT(!filters.isEmpty());
+
+ m_dialog->setFilters(filters);
+ m_selectedFilter = filters.first();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_playbook.cpp
index 0325a33268..12e8d8afbf 100644
--- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.cpp
+++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper_playbook.cpp
@@ -118,7 +118,7 @@ bool QQnxFileDialogHelper::handleEvent(bps_event_t *event)
m_result = QPlatformDialogHelper::Rejected;
}
- emit dialogClosed();
+ Q_EMIT dialogClosed();
return true;
}
@@ -135,9 +135,9 @@ void QQnxFileDialogHelper::exec()
loop.exec();
if (m_result == QPlatformDialogHelper::Accepted)
- emit accept();
+ Q_EMIT accept();
else
- emit reject();
+ Q_EMIT reject();
}
bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
@@ -291,9 +291,15 @@ QString QQnxFileDialogHelper::selectedNameFilter() const
void QQnxFileDialogHelper::setNameFilter(const QString &filter)
{
qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter;
+ setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter));
+}
+
+void QQnxFileDialogHelper::setNameFilters(const QStringList &filters)
+{
+ qFileDialogHelperDebug() << Q_FUNC_INFO << "filters =" << filters;
+
+ Q_ASSERT(!filters.isEmpty());
- // Extract the globbing expressions
- QStringList filters = QPlatformFileDialogHelper::cleanFilterList(filter);
char **globs = new char*[filters.size()];
for (int i = 0; i < filters.size(); ++i) {
QByteArray glob = filters.at(i).toLocal8Bit();
@@ -303,7 +309,7 @@ void QQnxFileDialogHelper::setNameFilter(const QString &filter)
// Set the filters
dialog_set_filebrowse_filter(m_dialog, const_cast<const char**>(globs), filters.size());
- m_selectedFilter = filter;
+ m_selectedFilter = filters.first();
// Cleanup
for (int i = 0; i < filters.size(); ++i)
diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.cpp b/src/plugins/platforms/qnx/qqnxfilepicker.cpp
new file mode 100644
index 0000000000..5229d1f1f5
--- /dev/null
+++ b/src/plugins/platforms/qnx/qqnxfilepicker.cpp
@@ -0,0 +1,289 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqnxfilepicker.h"
+
+#include <QAbstractEventDispatcher>
+#include <QCoreApplication>
+#include <QDebug>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonArray>
+#include <QJsonParseError>
+#include <QUrl>
+
+#include <bps/navigator.h>
+#include <bps/navigator_invoke.h>
+
+#include <errno.h>
+
+#ifdef QQNXFILEPICKER_DEBUG
+#define qFilePickerDebug qDebug
+#else
+#define qFilePickerDebug QT_NO_QDEBUG_MACRO
+#endif
+
+static const char s_filePickerTarget[] = "sys.filepicker.target";
+
+QQnxFilePicker::QQnxFilePicker(QObject *parent)
+ : QObject(parent)
+ , m_invocationHandle(0)
+ , m_mode(QQnxFilePicker::Picker)
+ , m_title(tr("Pick a file"))
+{
+ QCoreApplication::eventDispatcher()->installNativeEventFilter(this);
+}
+
+QQnxFilePicker::~QQnxFilePicker()
+{
+ cleanup();
+
+ QCoreApplication::eventDispatcher()->removeNativeEventFilter(this);
+}
+
+void QQnxFilePicker::open()
+{
+ if (m_invocationHandle)
+ return;
+
+ int errorCode = BPS_SUCCESS;
+
+ errorCode = navigator_invoke_invocation_create(&m_invocationHandle);
+ if (errorCode != BPS_SUCCESS) {
+ qWarning() << "QQnxFilePicker: unable to create invocation:" << strerror(errno);
+ return;
+ }
+
+ errorCode = navigator_invoke_invocation_set_target(m_invocationHandle, s_filePickerTarget);
+
+ if (errorCode != BPS_SUCCESS) {
+ cleanup();
+ qWarning() << "QQnxFilePicker: unable to set target:" << strerror(errno);
+ return;
+ }
+
+ errorCode = navigator_invoke_invocation_set_action(m_invocationHandle, "bb.action.OPEN");
+ if (errorCode != BPS_SUCCESS) {
+ cleanup();
+ qWarning() << "QQnxFilePicker: unable to set action:" << strerror(errno);
+ return;
+ }
+
+ errorCode = navigator_invoke_invocation_set_type(m_invocationHandle, "application/vnd.blackberry.file_picker");
+ if (errorCode != BPS_SUCCESS) {
+ cleanup();
+ qWarning() << "QQnxFilePicker: unable to set mime type:" << strerror(errno);
+ return;
+ }
+
+ QVariantMap map;
+ map[QStringLiteral("Type")] = QStringLiteral("Other");
+ map[QStringLiteral("Mode")] = modeToString(m_mode);
+ map[QStringLiteral("Title")] = m_title;
+ map[QStringLiteral("ViewMode")] = QStringLiteral("Default");
+ map[QStringLiteral("SortBy")] = QStringLiteral("Default");
+ map[QStringLiteral("SortOrder")] = QStringLiteral("Default");
+ map[QStringLiteral("ImageCrop")] = false;
+ map[QStringLiteral("AllowOverwrite")] = false;
+
+ if (!m_defaultSaveFileNames.isEmpty())
+ map[QStringLiteral("DefaultFileNames")] = m_defaultSaveFileNames.join(",");
+ if (!m_filters.isEmpty())
+ map[QStringLiteral("Filter")] = m_filters.join(";");
+
+ QJsonDocument document;
+ document.setObject(QJsonObject::fromVariantMap(map));
+ const QByteArray jsonData = document.toJson(QJsonDocument::Compact);
+
+ errorCode = navigator_invoke_invocation_set_data(m_invocationHandle, jsonData.constData(), jsonData.size());
+ if (errorCode != BPS_SUCCESS) {
+ cleanup();
+ qWarning() << "QQnxFilePicker: unable to set data:" << strerror(errno);
+ return;
+ }
+
+ navigator_invoke_invocation_send(m_invocationHandle);
+}
+
+void QQnxFilePicker::close()
+{
+ navigator_card_close_child();
+ cleanup();
+}
+
+bool QQnxFilePicker::nativeEventFilter(const QByteArray&, void *message, long*)
+{
+ bps_event_t * const event = static_cast<bps_event_t*>(message);
+ if (!event)
+ return false;
+
+ if (bps_event_get_code(event) == NAVIGATOR_INVOKE_TARGET_RESULT) {
+ const char *id = navigator_event_get_id(event);
+ const char *err = navigator_event_get_err(event);
+ qFilePickerDebug("received invocation response: id=%s err=%s", id, err);
+ } else if (bps_event_get_code(event) == NAVIGATOR_CHILD_CARD_CLOSED) {
+ const char *data = navigator_event_get_card_closed_data(event);
+ qFilePickerDebug("received data: data='%s'", data);
+ handleFilePickerResponse(data);
+ }
+
+ return false; // do not drop the event
+}
+
+void QQnxFilePicker::setMode(QQnxFilePicker::Mode mode)
+{
+ m_mode = mode;
+}
+
+void QQnxFilePicker::setDefaultSaveFileNames(const QStringList &fileNames)
+{
+ m_defaultSaveFileNames = fileNames;
+}
+
+void QQnxFilePicker::addDefaultSaveFileName(const QString &fileName)
+{
+ m_defaultSaveFileNames.append(fileName);
+}
+
+void QQnxFilePicker::setDirectories(const QStringList &directories)
+{
+ m_directories = directories;
+}
+
+void QQnxFilePicker::addDirectory(const QString &directory)
+{
+ m_directories.append(directory);
+}
+
+void QQnxFilePicker::setFilters(const QStringList &filters)
+{
+ m_filters = filters;
+}
+
+void QQnxFilePicker::setTitle(const QString &title)
+{
+ m_title = title;
+}
+
+QQnxFilePicker::Mode QQnxFilePicker::mode() const
+{
+ return m_mode;
+}
+
+QStringList QQnxFilePicker::defaultSaveFileNames() const
+{
+ return m_defaultSaveFileNames;
+}
+
+QStringList QQnxFilePicker::directories() const
+{
+ return m_directories;
+}
+
+QStringList QQnxFilePicker::filters() const
+{
+ return m_filters;
+}
+
+QStringList QQnxFilePicker::selectedFiles() const
+{
+ return m_selectedFiles;
+}
+
+QString QQnxFilePicker::title() const
+{
+ return m_title;
+}
+
+void QQnxFilePicker::cleanup()
+{
+ if (m_invocationHandle) {
+ navigator_invoke_invocation_destroy(m_invocationHandle);
+ m_invocationHandle = 0;
+ }
+}
+
+void QQnxFilePicker::handleFilePickerResponse(const char *data)
+{
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(data, &jsonError);
+
+ if (jsonError.error != QJsonParseError::NoError) {
+ qFilePickerDebug() << "Error parsing FilePicker response: "
+ << jsonError.errorString();
+ Q_EMIT closed();
+ cleanup();
+ return;
+ }
+
+ // The response is a list of Json objects.
+ const QVariantList array = document.array().toVariantList();
+
+ foreach (const QVariant &variant, array) {
+ const QJsonObject object = QJsonObject::fromVariantMap(variant.toMap());
+ const QUrl url(object.value(QStringLiteral("uri")).toString());
+ const QString localFile = url.toLocalFile(); // strip "file://"
+
+ if (!localFile.isEmpty())
+ m_selectedFiles << localFile;
+
+ qFilePickerDebug() << "FilePicker uri response:" << localFile;
+ }
+
+ Q_EMIT closed();
+ cleanup();
+}
+
+QString QQnxFilePicker::modeToString(QQnxFilePicker::Mode mode) const
+{
+ switch (mode) {
+ case Picker:
+ return QStringLiteral("Picker");
+ case Saver:
+ return QStringLiteral("Saver");
+ case PickerMultiple:
+ return QStringLiteral("PickerMultiple");
+ case SaverMultiple:
+ return QStringLiteral("SaverMultiple");
+ }
+
+ return QStringLiteral("Picker");
+}
diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.h b/src/plugins/platforms/qnx/qqnxfilepicker.h
new file mode 100644
index 0000000000..5bb8f0969f
--- /dev/null
+++ b/src/plugins/platforms/qnx/qqnxfilepicker.h
@@ -0,0 +1,110 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQNXFILEPICKER_H
+#define QQNXFILEPICKER_H
+
+#include <QAbstractNativeEventFilter>
+#include <QObject>
+#include <QStringList>
+
+struct navigator_invoke_invocation_t;
+
+class QQnxFilePicker : public QObject, public QAbstractNativeEventFilter
+{
+ Q_OBJECT
+
+public:
+ explicit QQnxFilePicker(QObject *parent = 0);
+ ~QQnxFilePicker();
+
+ enum Mode {
+ Picker,
+ Saver,
+ PickerMultiple,
+ SaverMultiple
+ };
+
+ bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
+
+ void setMode(Mode mode);
+ void setDefaultSaveFileNames(const QStringList &fileNames);
+ void addDefaultSaveFileName(const QString &fileName);
+ void setDirectories(const QStringList &directories);
+ void addDirectory(const QString &directory);
+ void setFilters(const QStringList &filters);
+ void setTitle(const QString &title);
+
+ Mode mode() const;
+
+ QStringList defaultSaveFileNames() const;
+ QStringList directories() const;
+ QStringList filters() const;
+ QStringList selectedFiles() const;
+
+ QString title() const;
+
+Q_SIGNALS:
+ void closed();
+
+public Q_SLOTS:
+ void open();
+ void close();
+
+private:
+ void cleanup();
+ void handleFilePickerResponse(const char *data);
+
+ QString modeToString(Mode mode) const;
+
+ navigator_invoke_invocation_t *m_invocationHandle;
+
+ Mode m_mode;
+
+ QStringList m_defaultSaveFileNames;
+ QStringList m_directories;
+ QStringList m_filters;
+ QStringList m_selectedFiles;
+
+ QString m_title;
+};
+
+#endif // QQNXFILEPICKER_H
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 4cbbfa4da8..2b10a26c88 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -40,7 +40,9 @@
****************************************************************************/
#include "qqnxintegration.h"
+#if defined(QQNXSCREENEVENTTHREAD)
#include "qqnxscreeneventthread.h"
+#endif
#include "qqnxnativeinterface.h"
#include "qqnxrasterbackingstore.h"
#include "qqnxscreen.h"
@@ -84,6 +86,8 @@
#include <qpa/qplatformwindow.h>
#include <qpa/qwindowsysteminterface.h>
+#include <QtGui/private/qguiapplication_p.h>
+
#if !defined(QT_NO_OPENGL)
#include "qqnxglcontext.h"
#include <QtGui/QOpenGLContext>
@@ -107,9 +111,20 @@ QT_BEGIN_NAMESPACE
QQnxWindowMapper QQnxIntegration::ms_windowMapper;
QMutex QQnxIntegration::ms_windowMapperMutex;
-QQnxIntegration::QQnxIntegration()
+static inline QQnxIntegration::Options parseOptions(const QStringList &paramList)
+{
+ QQnxIntegration::Options options = QQnxIntegration::NoOptions;
+ if (!paramList.contains(QLatin1String("no-fullscreen"))) {
+ options |= QQnxIntegration::FullScreenApplication;
+ }
+ return options;
+}
+
+QQnxIntegration::QQnxIntegration(const QStringList &paramList)
: QPlatformIntegration()
+#if defined(QQNX_SCREENEVENTTHREAD)
, m_screenEventThread(0)
+#endif
, m_navigatorEventHandler(new QQnxNavigatorEventHandler())
, m_virtualKeyboard(0)
#if defined(QQNX_PPS)
@@ -134,6 +149,7 @@ QQnxIntegration::QQnxIntegration()
#if !defined(QT_NO_DRAGANDDROP)
, m_drag(new QSimpleDrag())
#endif
+ , m_options(parseOptions(paramList))
{
qIntegrationDebug() << Q_FUNC_INFO;
// Open connection to QNX composition manager
@@ -186,8 +202,13 @@ QQnxIntegration::QQnxIntegration()
#if defined(Q_OS_BLACKBERRY)
QQnxVirtualKeyboardBps* virtualKeyboardBps = new QQnxVirtualKeyboardBps;
- m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler,
- (m_screenEventThread ? 0 : m_screenEventHandler), virtualKeyboardBps);
+
+#if defined(QQNX_SCREENEVENTTHREAD)
+ m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, 0, virtualKeyboardBps);
+#else
+ m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler, virtualKeyboardBps);
+#endif
+
m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher);
m_virtualKeyboard = virtualKeyboardBps;
@@ -385,7 +406,7 @@ QPlatformDrag *QQnxIntegration::drag() const
QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
{
qIntegrationDebug() << Q_FUNC_INFO;
- if (hint == ShowIsFullScreen)
+ if ((hint == ShowIsFullScreen) && (m_options & FullScreenApplication))
return true;
return QPlatformIntegration::styleHint(hint);
@@ -530,6 +551,11 @@ QQnxScreen *QQnxIntegration::primaryDisplay() const
return m_screens.first();
}
+QQnxIntegration::Options QQnxIntegration::options() const
+{
+ return m_options;
+}
+
bool QQnxIntegration::supportsNavigatorEvents() const
{
// If QQNX_PPS or Q_OS_BLACKBERRY is defined then we have navigator
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index e3eb9e06ba..5f9d709928 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -51,7 +51,9 @@
QT_BEGIN_NAMESPACE
class QQnxBpsEventFilter;
+#if defined(QQNX_SCREENEVENTTHREAD)
class QQnxScreenEventThread;
+#endif
class QQnxFileDialogHelper;
class QQnxNativeInterface;
class QQnxWindow;
@@ -80,7 +82,12 @@ typedef QHash<screen_window_t, QWindow *> QQnxWindowMapper;
class QQnxIntegration : public QPlatformIntegration
{
public:
- QQnxIntegration();
+ enum Option { // Options to be passed on command line.
+ NoOptions = 0x0,
+ FullScreenApplication = 0x1
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+ explicit QQnxIntegration(const QStringList &paramList);
~QQnxIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
@@ -129,6 +136,8 @@ public:
void createDisplay(screen_display_t display, bool isPrimary);
void removeDisplay(QQnxScreen *screen);
QQnxScreen *primaryDisplay() const;
+ Options options() const;
+
private:
void createDisplays();
void destroyDisplays();
@@ -137,7 +146,9 @@ private:
static void removeWindow(screen_window_t qnxWindow);
screen_context_t m_screenContext;
+#if defined(QNX_SCREENEVENTTHREAD)
QQnxScreenEventThread *m_screenEventThread;
+#endif
QQnxNavigatorEventHandler *m_navigatorEventHandler;
QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
#if defined(QQNX_PPS)
@@ -164,6 +175,8 @@ private:
static QQnxWindowMapper ms_windowMapper;
static QMutex ms_windowMapperMutex;
+ const Options m_options;
+
friend class QQnxWindow;
};
diff --git a/src/plugins/platforms/qnx/qqnxtheme.cpp b/src/plugins/platforms/qnx/qqnxtheme.cpp
index 733b7223b6..37c1079441 100644
--- a/src/plugins/platforms/qnx/qqnxtheme.cpp
+++ b/src/plugins/platforms/qnx/qqnxtheme.cpp
@@ -58,10 +58,8 @@ QQnxTheme::~QQnxTheme()
bool QQnxTheme::usePlatformNativeDialog(DialogType type) const
{
-#if defined(Q_OS_BLACKBERRY_TABLET)
if (type == QPlatformTheme::FileDialog)
return true;
-#endif
#if !defined(QT_NO_COLORDIALOG)
if (type == QPlatformTheme::ColorDialog)
return false;
@@ -76,10 +74,8 @@ bool QQnxTheme::usePlatformNativeDialog(DialogType type) const
QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) const
{
switch (type) {
-#if defined(Q_OS_BLACKBERRY_TABLET)
case QPlatformTheme::FileDialog:
return new QQnxFileDialogHelper(m_integration);
-#endif
#if !defined(QT_NO_COLORDIALOG)
case QPlatformTheme::ColorDialog:
#endif
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index c0f1b3a000..7407d88f8b 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -215,7 +215,9 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di
if (QWindowsContext::verboseFonts)
qDebug("%s %g", __FUNCTION__, pixelSize);
- d->directWriteFactory->AddRef();
+ Q_ASSERT(m_directWriteFontFace);
+
+ m_fontEngineData->directWriteFactory->AddRef();
m_directWriteFontFace->AddRef();
fontDef.pixelSize = pixelSize;
@@ -237,19 +239,17 @@ QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite()
void QWindowsFontEngineDirectWrite::collectMetrics()
{
- if (m_directWriteFontFace != 0) {
- DWRITE_FONT_METRICS metrics;
-
- m_directWriteFontFace->GetMetrics(&metrics);
- m_unitsPerEm = metrics.designUnitsPerEm;
-
- m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness);
- m_ascent = DESIGN_TO_LOGICAL(metrics.ascent);
- m_descent = DESIGN_TO_LOGICAL(metrics.descent);
- m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight);
- m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap);
- m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition);
- }
+ DWRITE_FONT_METRICS metrics;
+
+ m_directWriteFontFace->GetMetrics(&metrics);
+ m_unitsPerEm = metrics.designUnitsPerEm;
+
+ m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness);
+ m_ascent = DESIGN_TO_LOGICAL(metrics.ascent);
+ m_descent = DESIGN_TO_LOGICAL(metrics.descent);
+ m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight);
+ m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap);
+ m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition);
}
QFixed QWindowsFontEngineDirectWrite::underlinePosition() const
@@ -272,31 +272,24 @@ bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, ui
{
bool ret = false;
- if (m_directWriteFontFace) {
- DWORD t = qbswap<quint32>(tag);
-
- const void *tableData = 0;
- void *tableContext = 0;
- UINT32 tableSize;
- BOOL exists;
- HRESULT hr = m_directWriteFontFace->TryGetFontTable(
- t, &tableData, &tableSize, &tableContext, &exists
- );
-
- if (SUCCEEDED(hr)) {
- if (exists) {
- if (!buffer) {
- *length = tableSize;
- ret = true;
- } else if (*length >= tableSize) {
- memcpy(buffer, tableData, tableSize);
- ret = true;
- }
- }
- m_directWriteFontFace->ReleaseFontTable(tableContext);
- } else {
- qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__);
+ const void *tableData = 0;
+ UINT32 tableSize;
+ void *tableContext = 0;
+ BOOL exists;
+ HRESULT hr = m_directWriteFontFace->TryGetFontTable(qbswap<quint32>(tag)
+ &tableData, &tableSize,
+ &tableContext, &exists);
+ if (SUCCEEDED(hr)) {
+ if (exists) {
+ ret = true;
+ if (buffer && *length >= tableSize)
+ memcpy(buffer, tableData, tableSize);
+ else
+ *length = tableSize;
}
+ m_directWriteFontFace->ReleaseFontTable(tableContext);
+ } else {
+ qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__);
}
return ret;
@@ -327,43 +320,43 @@ inline unsigned int getChar(const QChar *str, int &i, const int len)
bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
int *nglyphs, QFontEngine::ShaperFlags flags) const
{
- if (m_directWriteFontFace != 0) {
- QVarLengthArray<UINT32> codePoints(len);
- for (int i=0; i<len; ++i) {
- codePoints[i] = getChar(str, i, len);
- if (flags & QFontEngine::RightToLeft)
- codePoints[i] = QChar::mirroredChar(codePoints[i]);
- }
+ if (*nglyphs < len) {
+ *nglyphs = len;
+ return false;
+ }
- QVarLengthArray<UINT16> glyphIndices(len);
- HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(),
- len,
- glyphIndices.data());
+ QVarLengthArray<UINT32> codePoints(len);
+ int actualLength = 0;
+ if (flags & QFontEngine::RightToLeft) {
+ for (int i = 0; i < len; ++i)
+ codePoints[actualLength++] = QChar::mirroredChar(getChar(str, i, len));
+ } else {
+ for (int i = 0; i < len; ++i)
+ codePoints[actualLength++] = getChar(str, i, len);
+ }
- if (SUCCEEDED(hr)) {
- for (int i=0; i<len; ++i)
- glyphs->glyphs[i] = glyphIndices[i];
+ QVarLengthArray<UINT16> glyphIndices(actualLength);
+ HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength,
+ glyphIndices.data());
+ if (FAILED(hr)) {
+ qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__);
+ return false;
+ }
- *nglyphs = len;
- glyphs->numGlyphs = len;
+ for (int i = 0; i < actualLength; ++i)
+ glyphs->glyphs[i] = glyphIndices.at(i);
- if (!(flags & GlyphIndicesOnly))
- recalcAdvances(glyphs, 0);
+ *nglyphs = actualLength;
+ glyphs->numGlyphs = actualLength;
- return true;
- } else {
- qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__);
- }
- }
+ if (!(flags & GlyphIndicesOnly))
+ recalcAdvances(glyphs, 0);
- return false;
+ return true;
}
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
{
- if (m_directWriteFontFace == 0)
- return;
-
QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);
// ### Caching?
@@ -391,9 +384,6 @@ void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEn
void QWindowsFontEngineDirectWrite::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
QPainterPath *path, QTextItem::RenderFlags flags)
{
- if (m_directWriteFontFace == 0)
- return;
-
QVarLengthArray<UINT16> glyphIndices(nglyphs);
QVarLengthArray<DWRITE_GLYPH_OFFSET> glyphOffsets(nglyphs);
QVarLengthArray<FLOAT> glyphAdvances(nglyphs);
@@ -439,9 +429,6 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(const QGlyphLayout &g
glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g)
{
- if (m_directWriteFontFace == 0)
- return glyph_metrics_t();
-
UINT16 glyphIndex = g;
DWRITE_GLYPH_METRICS glyphMetrics;
@@ -668,14 +655,14 @@ bool QWindowsFontEngineDirectWrite::canRender(const QChar *string, int len)
if (FAILED(hr)) {
qErrnoWarning("%s: GetGlyphIndices failed", __FUNCTION__);
return false;
- } else {
- for (int i=0; i<glyphIndices.size(); ++i) {
- if (glyphIndices.at(i) == 0)
- return false;
- }
+ }
- return true;
+ for (int i = 0; i < actualLength; ++i) {
+ if (glyphIndices.at(i) == 0)
+ return false;
}
+
+ return true;
}
QFontEngine::Type QWindowsFontEngineDirectWrite::type() const
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
index 106087f757..ab14cb49eb 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
@@ -107,8 +107,6 @@ public:
static QString fontNameSubstitute(const QString &familyName);
private:
- friend class QRawFontPrivate;
-
QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
void collectMetrics();
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 51c400ed9c..c66ed53152 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -736,7 +736,7 @@ Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s)
int QXcbKeyboard::translateKeySym(uint key) const
{
- int code = -1;
+ int code = Qt::Key_unknown;
int i = 0; // any other keys
while (KeyTbl[i]) {
if (key == KeyTbl[i]) {
diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h
index 521f1c12b8..e21998070a 100644
--- a/src/tools/qdoc/config.h
+++ b/src/tools/qdoc/config.h
@@ -198,6 +198,7 @@ private:
#define CONFIG_OUTPUTFORMATS "outputformats"
#define CONFIG_OUTPUTPREFIXES "outputprefixes"
#define CONFIG_PROJECT "project"
+#define CONFIG_REDIRECTDOCUMENTATIONTODEVNULL "redirectdocumentationtodevnull"
#define CONFIG_QHP "qhp"
#define CONFIG_QUOTINGINFORMATION "quotinginformation"
#define CONFIG_SCRIPTDIRS "scriptdirs"
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index 68edb1336a..db7c637b53 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -867,8 +867,8 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
}
}
else if (command == COMMAND_REIMP) {
- if (node->parent() && !node->parent()->isInternal()) {
- if (node != 0 && node->type() == Node::Function) {
+ if (node != 0 && node->parent() && !node->parent()->isInternal()) {
+ if (node->type() == Node::Function) {
FunctionNode *func = (FunctionNode *) node;
const FunctionNode *from = func->reimplementedFrom();
if (from == 0) {
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp
index dfa49e8563..d9ee0e42ee 100644
--- a/src/tools/qdoc/generator.cpp
+++ b/src/tools/qdoc/generator.cpp
@@ -97,6 +97,7 @@ QStringList Generator::styleDirs;
QStringList Generator::styleFiles;
bool Generator::debugging_ = false;
bool Generator::noLinkErrors_ = false;
+bool Generator::redirectDocumentationToDevNull_ = false;
Generator::Passes Generator::qdocPass_ = Both;
void Generator::setDebugSegfaultFlag(bool b)
@@ -268,7 +269,8 @@ void Generator::beginSubPage(const InnerNode* node, const QString& fileName)
path += fileName;
Generator::debugSegfault("Writing: " + path);
outFileNames.insert(fileName,fileName);
- QFile* outFile = new QFile(path);
+
+ QFile* outFile = new QFile(redirectDocumentationToDevNull_ ? QStringLiteral("/dev/null") : path);
if (!outFile->open(QFile::WriteOnly))
node->location().fatal(tr("Cannot open output file '%1'").arg(outFile->fileName()));
QTextStream* out = new QTextStream(outFile);
@@ -1473,6 +1475,7 @@ QString Generator::indent(int level, const QString& markedCode)
void Generator::initialize(const Config &config)
{
outputFormats = config.getOutputFormats();
+ redirectDocumentationToDevNull_ = config.getBool(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL);
if (!outputFormats.isEmpty()) {
outDir_ = config.getOutputDir();
if (outDir_.isEmpty()) {
diff --git a/src/tools/qdoc/generator.h b/src/tools/qdoc/generator.h
index 28a9ae5ce8..08ee9b4e9b 100644
--- a/src/tools/qdoc/generator.h
+++ b/src/tools/qdoc/generator.h
@@ -204,6 +204,7 @@ private:
static QStringList styleFiles;
static bool debugging_;
static bool noLinkErrors_;
+ static bool redirectDocumentationToDevNull_;
static Passes qdocPass_;
void appendFullName(Text& text,
diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp
index 9c2dd4dcfc..a4e35c5f96 100644
--- a/src/tools/qdoc/main.cpp
+++ b/src/tools/qdoc/main.cpp
@@ -95,6 +95,7 @@ bool creationTimeBefore(const QFileInfo &fi1, const QFileInfo &fi2)
static bool highlighting = false;
static bool showInternal = false;
+static bool redirectDocumentationToDevNull = false;
static bool noLinkErrors = false;
static bool obsoleteLinks = false;
static QStringList defines;
@@ -139,6 +140,8 @@ static void printHelp()
"Run qdoc to read the index files and generate the docs\n"
" -showinternal "
"Include content marked internal\n"
+ " -redirect-documentation-to-dev-null "
+ "Save all documentation content to /dev/null. Useful if someone is interested in qdoc errors only.\n"
" -version "
"Display version of qdoc and exit\n") );
}
@@ -257,6 +260,7 @@ static void processQdocconfFile(const QString &fileName)
}
config.setStringList(CONFIG_SYNTAXHIGHLIGHTING, QStringList(highlighting ? "true" : "false"));
config.setStringList(CONFIG_SHOWINTERNAL, QStringList(showInternal ? "true" : "false"));
+ config.setStringList(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL, QStringList(redirectDocumentationToDevNull ? "true" : "false"));
config.setStringList(CONFIG_NOLINKERRORS, QStringList(noLinkErrors ? "true" : "false"));
config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false"));
@@ -573,6 +577,9 @@ int main(int argc, char **argv)
else if (opt == "-showinternal") {
showInternal = true;
}
+ else if (opt == "-redirect-documentation-to-dev-null") {
+ redirectDocumentationToDevNull = true;
+ }
else if (opt == "-no-examples") {
Config::generateExamples = false;
}
diff --git a/src/tools/qdoc/qmlvisitor.h b/src/tools/qdoc/qmlvisitor.h
index 2c3ff341d6..b59fbb0cbb 100644
--- a/src/tools/qdoc/qmlvisitor.h
+++ b/src/tools/qdoc/qmlvisitor.h
@@ -45,7 +45,6 @@
#include <qstring.h>
#include "qqmljsastvisitor_p.h"
#include "node.h"
-#include "tree.h"
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index d6254076c5..5edf883e5a 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -63,6 +63,8 @@
#include "qmimedata.h"
#include "qspinbox.h"
#include "qdialogbuttonbox.h"
+#include "qscreen.h"
+#include "qcursor.h"
QT_BEGIN_NAMESPACE
@@ -1417,6 +1419,15 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
return false;
}
+QColor QColorDialogPrivate::grabScreenColor(const QPoint &p)
+{
+ const QDesktopWidget *desktop = QApplication::desktop();
+ const QPixmap pixmap = QGuiApplication::screens().at(desktop->screenNumber())->grabWindow(desktop->winId(),
+ p.x(), p.y(), 1, 1);
+ QImage i = pixmap.toImage();
+ return i.pixel(0, 0);
+}
+
//sets all widgets except cs to display rgb
void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
{
@@ -1442,6 +1453,48 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
custom->setSelected(-1,-1);
}
+void QColorDialogPrivate::_q_pickScreenColor()
+{
+ Q_Q(QColorDialog);
+ screenColorPicking = true;
+ // If user pushes Escape, the last color before picking will be restored.
+ beforeScreenColorPicking = cs->currentColor();
+ /*For some reason, q->grabMouse(Qt::CrossCursor) doesn't change
+ * the cursor, and therefore I have to change it manually.
+ */
+ q->grabMouse();
+ q->setCursor(Qt::CrossCursor);
+ q->grabKeyboard();
+ /* With setMouseTracking(true) the desired color can be more precisedly picked up,
+ * and continuously pushing the mouse button is not necessary.
+ */
+ q->setMouseTracking(true);
+
+ addCusBt->setDisabled(true);
+ buttons->setDisabled(true);
+ screenColorPickerButton->setDisabled(true);
+
+ q->setCurrentColor(grabScreenColor(QCursor::pos()));
+ lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel")
+ .arg(QCursor::pos().x())
+ .arg(QCursor::pos().y())
+ .arg(q->currentColor().name()));
+}
+
+void QColorDialogPrivate::releaseColorPicking()
+{
+ Q_Q(QColorDialog);
+ screenColorPicking = false;
+ q->releaseMouse();
+ q->releaseKeyboard();
+ q->setCursor(Qt::ArrowCursor);
+ q->setMouseTracking(false);
+ lblScreenColorInfo->setText(QLatin1String("\n"));
+ addCusBt->setDisabled(false);
+ buttons->setDisabled(false);
+ screenColorPickerButton->setDisabled(false);
+}
+
void QColorDialogPrivate::init(const QColor &initial)
{
Q_Q(QColorDialog);
@@ -1450,7 +1503,7 @@ void QColorDialogPrivate::init(const QColor &initial)
q->setWindowTitle(QColorDialog::tr("Select Color"));
nativeDialogInUse = (platformColorDialogHelper() != 0);
-
+ screenColorPicking = false;
nextCust = 0;
QVBoxLayout *mainLay = new QVBoxLayout(q);
// there's nothing in this dialog that benefits from sizing up
@@ -1486,6 +1539,15 @@ void QColorDialogPrivate::init(const QColor &initial)
leftLay->addWidget(lblBasicColors);
leftLay->addWidget(standard);
+#if !defined(Q_OS_WINCE) && !defined(QT_SMALL_COLORDIALOG)
+ // The screen color picker button
+ screenColorPickerButton = new QPushButton(QColorDialog::tr("Pick Screen Color"));
+ leftLay->addWidget(screenColorPickerButton);
+ lblScreenColorInfo = new QLabel(QLatin1String("\n"));
+ leftLay->addWidget(lblScreenColorInfo);
+ q->connect(screenColorPickerButton, SIGNAL(clicked()), SLOT(_q_pickScreenColor()));
+#endif
+
#if !defined(Q_OS_WINCE)
leftLay->addStretch();
#endif
@@ -1658,6 +1720,11 @@ static const Qt::WindowFlags DefaultWindowFlags =
during the execution of the program. Use setCustomColor() to set
the custom colors, and use customColor() to get them.
+ When pressing the "Pick Screen Color" button, the cursor changes to a haircross
+ and the colors on the screen are scanned. The user can pick up one by clicking
+ the mouse or the Enter button. Pressing Escape restores the last color selected
+ before entering this mode.
+
The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
how to use QColorDialog as well as other built-in Qt dialogs.
@@ -1972,6 +2039,57 @@ void QColorDialog::changeEvent(QEvent *e)
}
/*!
+ \reimp
+*/
+void QColorDialog::mouseMoveEvent(QMouseEvent *e)
+{
+ Q_D(QColorDialog);
+ if (d->screenColorPicking) {
+ setCurrentColor(d->grabScreenColor(e->globalPos()));
+ d->lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel")
+ .arg(e->globalPos().x())
+ .arg(e->globalPos().y())
+ .arg(currentColor().name()));
+ return;
+ }
+ QDialog::mouseMoveEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QColorDialog::mouseReleaseEvent(QMouseEvent *e)
+{
+ Q_D(QColorDialog);
+ if (d->screenColorPicking) {
+ setCurrentColor(d->grabScreenColor(e->globalPos()));
+ d->releaseColorPicking();
+ return;
+ }
+ QDialog::mouseReleaseEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QColorDialog::keyPressEvent(QKeyEvent *e)
+{
+ Q_D(QColorDialog);
+ if (d->screenColorPicking) {
+ if (e->key() == Qt::Key_Escape) {
+ d->releaseColorPicking();
+ d->setCurrentColor(d->beforeScreenColorPicking);
+ } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
+ setCurrentColor(d->grabScreenColor(QCursor::pos()));
+ d->releaseColorPicking();
+ }
+ e->accept();
+ return;
+ }
+ QDialog::keyPressEvent(e);
+}
+
+/*!
Closes the dialog and sets its result code to \a result. If this dialog
is shown with exec(), done() causes the local event loop to finish,
and exec() to return \a result.
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index 80a31c4268..e76a120c3a 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -112,6 +112,9 @@ Q_SIGNALS:
protected:
void changeEvent(QEvent *event);
+ virtual void mouseMoveEvent(QMouseEvent *);
+ virtual void mouseReleaseEvent(QMouseEvent *);
+ virtual void keyPressEvent(QKeyEvent *);
void done(int result);
private:
@@ -122,6 +125,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
friend class QColorShower;
};
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
index 900b38fc61..bb24992512 100644
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ b/src/widgets/dialogs/qcolordialog_p.h
@@ -87,6 +87,7 @@ public:
void setCurrentColor(QRgb rgb);
void setCurrentQColor(const QColor &color);
bool selectColor(const QColor &color);
+ QColor grabScreenColor(const QPoint &p);
int currentAlpha() const;
void setCurrentAlpha(int a);
@@ -100,6 +101,8 @@ public:
void _q_newColorTypedIn(QRgb rgb);
void _q_newCustom(int, int);
void _q_newStandard(int, int);
+ void _q_pickScreenColor();
+ void releaseColorPicking();
QWellArray *custom;
QWellArray *standard;
@@ -111,12 +114,16 @@ public:
QColorShower *cs;
QLabel *lblBasicColors;
QLabel *lblCustomColors;
+ QLabel *lblScreenColorInfo;
QPushButton *ok;
QPushButton *cancel;
QPushButton *addCusBt;
+ QPushButton *screenColorPickerButton;
QColor selectedQColor;
int nextCust;
bool smallDisplay;
+ bool screenColorPicking;
+ QRgb beforeScreenColorPicking;
QSharedPointer<QColorDialogOptions> options;
QPointer<QObject> receiverToDisconnectOnClose;
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 213aefe5f5..0f12c2b80e 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -238,7 +238,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
#endif
#ifdef Q_OS_WIN
- if (m_resolveSymlinks && fileInfo.isSymLink()) {
+ if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QFileInfo resolvedInfo(fileInfo.symLinkTarget());
resolvedInfo = resolvedInfo.canonicalFilePath();
if (resolvedInfo.exists()) {
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 0c4e644e40..447ee78edc 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -108,7 +108,13 @@ public:
return QExtendedInformation::System;
}
- bool isSymLink() const {
+ bool isSymLink(bool ignoreNtfsSymLinks = false) const
+ {
+ if (ignoreNtfsSymLinks) {
+#ifdef Q_OS_WIN
+ return !mFileInfo.suffix().compare(QLatin1String("lnk"), Qt::CaseInsensitive);
+#endif
+ }
return mFileInfo.isSymLink();
}
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 8e3ecc3e0e..519c158f81 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -800,7 +800,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
if (!index.isValid())
return QString();
QFileSystemNode *dirNode = node(index);
- if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() && dirNode->isSymLink()) {
+ if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QString fullPath = QDir::fromNativeSeparators(filePath(index));
if (resolvedSymLinks.contains(fullPath))
return resolvedSymLinks[fullPath];
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index d61936d545..663be3d933 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -116,7 +116,7 @@ public:
inline bool isFile() const { if (info) return info->isFile(); return true; }
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
- inline bool isSymLink() const { if (info) return info->isSymLink(); return false; }
+ inline bool isSymLink(bool ignoreNtfsSymLinks = false) const { return info && info->isSymLink(ignoreNtfsSymLinks); }
inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; }
inline QIcon icon() const { if (info) return info->icon; return QIcon(); }
diff --git a/src/widgets/graphicsview/qgridlayoutengine.cpp b/src/widgets/graphicsview/qgridlayoutengine.cpp
index b80612bc47..8fc4b205d2 100644
--- a/src/widgets/graphicsview/qgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgridlayoutengine.cpp
@@ -432,6 +432,8 @@ QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const
result.q_maximumSize = 0.0;
qreal nextSpacing = 0.0;
for (int i = start; i < end; ++i) {
+ if (ignore.testBit(i))
+ continue;
result.add(boxes.at(i), stretches.at(i), nextSpacing);
nextSpacing = spacings.at(i);
}
@@ -1475,7 +1477,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutSt
int effectiveRowSpan = 1;
for (int i = 1; i < itemRowSpan; ++i) {
- if (!rowData->ignore.testBit(i))
+ if (!rowData->ignore.testBit(i + itemRow))
++effectiveRowSpan;
}
@@ -1713,7 +1715,8 @@ void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo,
q_descents.resize(rowCount());
if (constraintOrientation() != Qt::Horizontal) {
- //We might have items whose width depends on their height
+ // We might have items whose height depends on their width,
+ // or none of the items has a dynamic constraint.
ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], styleInfo, NULL, NULL, Qt::Horizontal);
//Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as
//constraints to find the row heights
@@ -1724,7 +1727,7 @@ void QGridLayoutEngine::ensureGeometries(const QLayoutStyleInfo &styleInfo,
q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(),
q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]);
} else {
- //We have items whose height depends on their width
+ // We have items whose width depends on their height
ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], styleInfo, NULL, NULL, Qt::Vertical);
//Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as
//constraints to find the column widths
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 70c8f44a73..b79525b9df 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1108,6 +1108,7 @@ void QAbstractItemView::reset()
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ d->updateGeometry();
}
/*!
@@ -1124,6 +1125,7 @@ void QAbstractItemView::setRootIndex(const QModelIndex &index)
}
d->root = index;
d->doDelayedItemsLayout();
+ d->updateGeometry();
}
/*!
@@ -2668,8 +2670,10 @@ void QAbstractItemView::updateEditorGeometries()
*/
void QAbstractItemView::updateGeometries()
{
+ Q_D(QAbstractItemView);
updateEditorGeometries();
- d_func()->fetchMoreTimer.start(0, this); //fetch more later
+ d->fetchMoreTimer.start(0, this); //fetch more later
+ d->updateGeometry();
}
/*!
@@ -3231,6 +3235,7 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ d->updateGeometry();
}
/*!
@@ -3332,6 +3337,7 @@ void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int star
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ updateGeometry();
}
/*!
@@ -3412,6 +3418,7 @@ void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int s
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ updateGeometry();
}
@@ -3435,6 +3442,7 @@ void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int sta
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ updateGeometry();
}
/*!
@@ -3459,6 +3467,7 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int
QAccessible::updateAccessibility(&accessibleEvent);
}
#endif
+ updateGeometry();
}
/*!
@@ -4084,7 +4093,14 @@ void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const
delayedPendingLayout = false;
}
-
+void QAbstractItemViewPrivate::updateGeometry()
+{
+ Q_Q(QAbstractItemView);
+ if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
+ return;
+ if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce)
+ q->updateGeometry();
+}
QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,
const QStyleOptionViewItem &options)
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index 86eab174ed..5da22615e2 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -127,6 +127,8 @@ public:
void doDelayedItemsLayout(int delay = 0);
void interruptDelayedItemsLayout() const;
+ void updateGeometry();
+
void startAutoScroll()
{ // ### it would be nice to make this into a style hint one day
int scrollInterval = (verticalScrollMode == QAbstractItemView::ScrollPerItem) ? 150 : 50;
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index 8a0736ec70..b435639390 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -220,6 +220,22 @@ QIcon QFileIconProvider::icon(IconType type) const
return QIcon();
}
+static bool isCacheable(const QFileInfo &fi)
+{
+ if (!fi.isFile())
+ return false;
+
+#ifdef Q_OS_WIN
+ // On windows it's faster to just look at the file extensions. QTBUG-13182
+ const QString fileExtension = fi.suffix();
+ return fileExtension.compare(QLatin1String("exe"), Qt::CaseInsensitive) &&
+ fileExtension.compare(QLatin1String("lnk"), Qt::CaseInsensitive) &&
+ fileExtension.compare(QLatin1String("ico"), Qt::CaseInsensitive);
+#else
+ return !fi.isExecutable() && !fi.isSymLink();
+#endif
+}
+
QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const
{
QIcon retIcon;
@@ -234,7 +250,7 @@ QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const
const QString fileExtension = fi.suffix().toUpper();
const QString keyBase = QLatin1String("qt_.") + fi.suffix().toUpper();
- bool cacheable = fi.isFile() && !fi.isExecutable() && !fi.isSymLink() && fileExtension != QLatin1String("ICO");
+ bool cacheable = isCacheable(fi);
if (cacheable) {
QPixmap pixmap;
QPixmapCache::find(keyBase + QString::number(sizes.at(0)), pixmap);
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index edfbc5c8f1..0dbf0a6a76 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -550,6 +550,22 @@ QSize QHeaderView::sizeHint() const
}
/*!
+ \reimp
+*/
+
+void QHeaderView::setVisible(bool v)
+{
+ bool actualChange = (v != isVisible());
+ QAbstractItemView::setVisible(v);
+ if (actualChange) {
+ QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget());
+ if (parent)
+ parent->updateGeometry();
+ }
+}
+
+
+/*!
Returns a suitable size hint for the section specified by \a logicalIndex.
\sa sizeHint(), defaultSectionSize(), minimumSectionSize(),
@@ -918,6 +934,18 @@ void QHeaderView::resizeSection(int logical, int size)
d->doDelayedResizeSections();
r = d->viewport->rect();
}
+
+ // If the parent is a QAbstractScrollArea with QAbstractScrollArea::AdjustToContents
+ // then we want to change the geometry on that widget. Not doing it at once can/will
+ // cause scrollbars flicker as they would be shown at first but then removed.
+ // In the same situation it will also allow shrinking the whole view when stretchLastSection is set
+ // (It is default on QTreeViews - and it wouldn't shrink since the last stretch was made before the
+ // viewport was resized)
+
+ QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget());
+ if (parent && parent->sizeAdjustPolicy() == QAbstractScrollArea::AdjustToContents)
+ parent->updateGeometry();
+
d->viewport->update(r.normalized());
emit sectionResized(logical, oldSize, size);
}
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index 8fcd8d7a36..0b94eedf78 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -84,6 +84,7 @@ public:
int offset() const;
int length() const;
QSize sizeHint() const;
+ void setVisible(bool v);
int sectionSizeHint(int logicalIndex) const;
int visualIndexAt(int position) const;
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index a6623b9462..471f8b149c 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1056,6 +1056,19 @@ QTableView::~QTableView()
/*!
\reimp
*/
+QSize QTableView::viewportSizeHint() const
+{
+ Q_D(const QTableView);
+ QSize result( (d->verticalHeader->isHidden() ? 0 : d->verticalHeader->width()) + d->horizontalHeader->length(),
+ (d->horizontalHeader->isHidden() ? 0 : d->horizontalHeader->height()) + d->verticalHeader->length());
+ result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0,
+ horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0);
+ return result;
+}
+
+/*!
+ \reimp
+*/
void QTableView::setModel(QAbstractItemModel *model)
{
Q_D(QTableView);
@@ -1760,13 +1773,13 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
visualRow = bottom;
break;
case MovePageUp: {
- int newRow = rowAt(visualRect(current).top() - d->viewport->height());
+ int newRow = rowAt(visualRect(current).bottom() - d->viewport->height());
if (newRow == -1)
newRow = d->logicalRow(0);
return d->model->index(newRow, current.column(), d->root);
}
case MovePageDown: {
- int newRow = rowAt(visualRect(current).bottom() + d->viewport->height());
+ int newRow = rowAt(visualRect(current).top() + d->viewport->height());
if (newRow == -1)
newRow = d->logicalRow(bottom);
return d->model->index(newRow, current.column(), d->root);
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index 824348dbe8..db956480d6 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -118,6 +118,8 @@ public:
void sortByColumn(int column, Qt::SortOrder order);
+ QSize viewportSizeHint() const;
+
public Q_SLOTS:
void selectRow(int row);
void selectColumn(int column);
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 6aefbb5367..dd450daaea 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -335,6 +335,7 @@ void QTreeView::setHeader(QHeaderView *header)
this, SLOT(updateGeometries()));
setSortingEnabled(d->sortingEnabled);
+ d->updateGeometry();
}
/*!
@@ -2619,6 +2620,35 @@ void QTreeView::selectAll()
}
/*!
+ \reimp
+*/
+QSize QTreeView::viewportSizeHint() const
+{
+ Q_D(const QTreeView);
+ d->executePostedLayout(); // Make sure that viewItems are up to date.
+
+ if (d->viewItems.size() == 0)
+ return QAbstractItemView::viewportSizeHint();
+
+ // Get rect for last item
+ const QRect deepestRect = visualRect(d->viewItems.last().index);
+
+ if (!deepestRect.isValid())
+ return QAbstractItemView::viewportSizeHint();
+
+ QSize result = QSize(d->header->length(), deepestRect.bottom() + 1);
+
+ // add size for header
+ result += QSize(0, d->header->isVisible() ? d->header->height() : 0);
+
+ // add size for scrollbars
+ result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0,
+ horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0);
+
+ return result;
+}
+
+/*!
\since 4.2
Expands all expandable items.
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index 73f11f1a48..fae814c6f6 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -144,6 +144,8 @@ public:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
void selectAll();
+ QSize viewportSizeHint() const;
+
Q_SIGNALS:
void expanded(const QModelIndex &index);
void collapsed(const QModelIndex &index);
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 900e95f4da..e7827055fb 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -167,6 +167,7 @@ QT_BEGIN_NAMESPACE
QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
:hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
+ shownOnce(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),
viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
xoffset(0), yoffset(0), viewportFilter(0)
#ifdef Q_WS_WIN
@@ -527,6 +528,19 @@ void QAbstractScrollAreaPrivate::layoutChildren()
}
/*!
+ \enum QAbstractScrollArea::SizeAdjustPolicy
+ \since 5.2
+
+ This enum specifies how the size hint of the QAbstractScrollArea should
+ adjust when the size of the viewport changes.
+
+ \value AdjustIgnored The scroll area will behave like before - and not do any adjust.
+ \value AdjustToContents The scroll area will always adjust to the viewport
+ \value AdjustToContentsOnFirstShow The scroll area will adjust to its viewport the first time it is shown.
+*/
+
+
+/*!
\internal
Creates a new QAbstractScrollAreaPrivate, \a dd with the given \a parent.
@@ -983,6 +997,13 @@ bool QAbstractScrollArea::event(QEvent *e)
case QEvent::Resize:
d->layoutChildren();
break;
+ case QEvent::Show:
+ if (!d->shownOnce && d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContentsOnFirstShow) {
+ d->sizeHint = QSize();
+ updateGeometry();
+ }
+ d->shownOnce = true;
+ return QFrame::event(e);
case QEvent::Paint: {
QStyleOption option;
option.initFrom(this);
@@ -1533,17 +1554,70 @@ QSize QAbstractScrollArea::minimumSizeHint() const
}
/*!
+ Returns the sizeHint property of the scroll area. The size is determined by using
+ viewportSizeHint() plus some extra space for scroll bars, if needed.
\reimp
*/
QSize QAbstractScrollArea::sizeHint() const
{
- return QSize(256, 192);
-#if 0
Q_D(const QAbstractScrollArea);
- int h = qMax(10, fontMetrics().height());
- int f = 2 * d->frameWidth;
- return QSize((6 * h) + f, (4 * h) + f);
-#endif
+ if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
+ return QSize(256, 192);
+
+ if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
+ const int f = 2 * d->frameWidth;
+ const QSize frame( f, f );
+ const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0,
+ d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0);
+ d->sizeHint = frame + scrollbars + viewportSizeHint();
+ }
+ return d->sizeHint;
+}
+
+/*!
+ \since 5.2
+ Returns the recommended size for the viewport.
+ The default implementation returns viewport()->sizeHint().
+ Note that the size is just the viewport's size, without any scroll bars visible.
+ */
+QSize QAbstractScrollArea::viewportSizeHint() const
+{
+ Q_D(const QAbstractScrollArea);
+ if (d->viewport) {
+ const QSize sh = d->viewport->sizeHint();
+ if (sh.isValid()) {
+ return sh;
+ }
+ }
+ const int h = qMax(10, fontMetrics().height());
+ return QSize(6 * h, 4 * h);
+}
+
+/*!
+ \since 5.2
+ \property QAbstractScrollArea::sizeAdjustPolicy
+ This property holds the policy describing how the size of the scroll area changes when the
+ size of the viewport changes.
+
+ The default policy is QAbstractScrollArea::AdjustIgnored.
+ Changing this property might actually resize the scrollarea.
+*/
+
+QAbstractScrollArea::SizeAdjustPolicy QAbstractScrollArea::sizeAdjustPolicy() const
+{
+ Q_D(const QAbstractScrollArea);
+ return d->sizeAdjustPolicy;
+}
+
+void QAbstractScrollArea::setSizeAdjustPolicy(SizeAdjustPolicy policy)
+{
+ Q_D(QAbstractScrollArea);
+ if (d->sizeAdjustPolicy == policy)
+ return;
+
+ d->sizeAdjustPolicy = policy;
+ d->sizeHint = QSize();
+ updateGeometry();
}
/*!
@@ -1559,16 +1633,6 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport)
Q_UNUSED(viewport);
}
-/*!
- \internal
-
- This method is reserved for future use.
-*/
-QSize QAbstractScrollArea::viewportSizeHint() const
-{
- return QSize();
-}
-
QT_END_NAMESPACE
#include "moc_qabstractscrollarea.cpp"
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
index ccf16b5e5c..fb9562db1b 100644
--- a/src/widgets/widgets/qabstractscrollarea.h
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -56,13 +56,22 @@ class QAbstractScrollAreaPrivate;
class Q_WIDGETS_EXPORT QAbstractScrollArea : public QFrame
{
Q_OBJECT
+
+ Q_ENUMS(SizeAdjustPolicy)
Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
+ Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
public:
explicit QAbstractScrollArea(QWidget* parent=0);
~QAbstractScrollArea();
+ enum SizeAdjustPolicy {
+ AdjustIgnored,
+ AdjustToContentsOnFirstShow,
+ AdjustToContents
+ };
+
Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
QScrollBar *verticalScrollBar() const;
@@ -89,6 +98,9 @@ public:
virtual void setupViewport(QWidget *viewport);
+ SizeAdjustPolicy sizeAdjustPolicy() const;
+ void setSizeAdjustPolicy(SizeAdjustPolicy policy);
+
protected:
QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
void setViewportMargins(int left, int top, int right, int bottom);
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index 34d767fe29..3093c2f812 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -75,6 +75,10 @@ public:
QScrollBar *hbar, *vbar;
Qt::ScrollBarPolicy vbarpolicy, hbarpolicy;
+ bool shownOnce;
+ mutable QSize sizeHint;
+ QAbstractScrollArea::SizeAdjustPolicy sizeAdjustPolicy;
+
QWidget *viewport;
QWidget *cornerWidget;
QRect cornerPaintingRect;
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index 5f929caf03..0b0efa2bdf 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -54,6 +54,88 @@
QT_BEGIN_NAMESPACE
+static QFontDatabase::WritingSystem writingSystemFromScript(QLocale::Script script)
+{
+ switch (script) {
+ case QLocale::ArabicScript:
+ return QFontDatabase::Arabic;
+ case QLocale::CyrillicScript:
+ return QFontDatabase::Cyrillic;
+ case QLocale::GurmukhiScript:
+ return QFontDatabase::Gurmukhi;
+ case QLocale::SimplifiedHanScript:
+ return QFontDatabase::SimplifiedChinese;
+ case QLocale::TraditionalHanScript:
+ return QFontDatabase::TraditionalChinese;
+ case QLocale::LatinScript:
+ return QFontDatabase::Latin;
+ case QLocale::ArmenianScript:
+ return QFontDatabase::Armenian;
+ case QLocale::BengaliScript:
+ return QFontDatabase::Bengali;
+ case QLocale::DevanagariScript:
+ return QFontDatabase::Devanagari;
+ case QLocale::GeorgianScript:
+ return QFontDatabase::Georgian;
+ case QLocale::GreekScript:
+ return QFontDatabase::Greek;
+ case QLocale::GujaratiScript:
+ return QFontDatabase::Gujarati;
+ case QLocale::HebrewScript:
+ return QFontDatabase::Hebrew;
+ case QLocale::JapaneseScript:
+ return QFontDatabase::Japanese;
+ case QLocale::KhmerScript:
+ return QFontDatabase::Khmer;
+ case QLocale::KannadaScript:
+ return QFontDatabase::Kannada;
+ case QLocale::KoreanScript:
+ return QFontDatabase::Korean;
+ case QLocale::LaoScript:
+ return QFontDatabase::Lao;
+ case QLocale::MalayalamScript:
+ return QFontDatabase::Malayalam;
+ case QLocale::MyanmarScript:
+ return QFontDatabase::Myanmar;
+ case QLocale::TamilScript:
+ return QFontDatabase::Tamil;
+ case QLocale::TeluguScript:
+ return QFontDatabase::Telugu;
+ case QLocale::ThaanaScript:
+ return QFontDatabase::Thaana;
+ case QLocale::ThaiScript:
+ return QFontDatabase::Thai;
+ case QLocale::TibetanScript:
+ return QFontDatabase::Tibetan;
+ case QLocale::SinhalaScript:
+ return QFontDatabase::Sinhala;
+ case QLocale::SyriacScript:
+ return QFontDatabase::Syriac;
+ case QLocale::OriyaScript:
+ return QFontDatabase::Oriya;
+ case QLocale::OghamScript:
+ return QFontDatabase::Ogham;
+ case QLocale::RunicScript:
+ return QFontDatabase::Runic;
+ case QLocale::NkoScript:
+ return QFontDatabase::Nko;
+ default:
+ return QFontDatabase::Any;
+ }
+}
+
+static QFontDatabase::WritingSystem writingSystemFromLocale()
+{
+ QStringList uiLanguages = QLocale::system().uiLanguages();
+ QLocale::Script script;
+ if (!uiLanguages.isEmpty())
+ script = QLocale(uiLanguages.at(0)).script();
+ else
+ script = QLocale::system().script();
+
+ return writingSystemFromScript(script);
+}
+
static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
{
QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase().writingSystems(font.family());
@@ -66,7 +148,22 @@ static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool
if (writingSystems.isEmpty())
return QFontDatabase::Any;
- QFontDatabase::WritingSystem system = writingSystems.last();
+ QFontDatabase::WritingSystem system = writingSystemFromLocale();
+
+ if (writingSystems.contains(system))
+ return system;
+
+ if (system == QFontDatabase::TraditionalChinese
+ && writingSystems.contains(QFontDatabase::SimplifiedChinese)) {
+ return QFontDatabase::SimplifiedChinese;
+ }
+
+ if (system == QFontDatabase::SimplifiedChinese
+ && writingSystems.contains(QFontDatabase::TraditionalChinese)) {
+ return QFontDatabase::TraditionalChinese;
+ }
+
+ system = writingSystems.last();
if (!*hasLatin) {
// we need to show something
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index 93c335c56b..2a6d4620d7 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -407,6 +407,18 @@ QSize QScrollArea::sizeHint() const
return sz.boundedTo(QSize(36 * h, 24 * h));
}
+/*!
+ \reimp
+ */
+QSize QScrollArea::viewportSizeHint() const
+{
+ Q_D(const QScrollArea);
+ if (d->widget) {
+ return d->resizable ? d->widget->sizeHint() : d->widget->size();
+ }
+ const int h = fontMetrics().height();
+ return QSize(6 * h, 4 * h);
+}
/*!
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
index 576c9bc9e0..70af5fbbd7 100644
--- a/src/widgets/widgets/qscrollarea.h
+++ b/src/widgets/widgets/qscrollarea.h
@@ -69,6 +69,8 @@ public:
void setWidgetResizable(bool resizable);
QSize sizeHint() const;
+ QSize viewportSizeHint() const;
+
bool focusNextPrevChild(bool next);
Qt::Alignment alignment() const;
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 6811551769..543226978c 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -44,6 +44,7 @@
#include "qjsonobject.h"
#include "qjsonvalue.h"
#include "qjsondocument.h"
+#include <limits>
#define INVALID_UNICODE "\357\277\277" // "\uffff"
#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet
@@ -94,6 +95,8 @@ private Q_SLOTS:
void toVariantList();
void toJson();
+ void toJsonSillyNumericValues();
+ void toJsonLargeNumericValues();
void fromJson();
void fromJsonErrors();
void fromBinary();
@@ -1080,6 +1083,89 @@ void tst_QtJson::toJson()
}
}
+void tst_QtJson::toJsonSillyNumericValues()
+{
+ QJsonObject object;
+ QJsonArray array;
+ array.append(QJsonValue(std::numeric_limits<double>::infinity())); // encode to: null
+ array.append(QJsonValue(-std::numeric_limits<double>::infinity())); // encode to: null
+ array.append(QJsonValue(std::numeric_limits<double>::quiet_NaN())); // encode to: null
+ object.insert("Array", array);
+
+ QByteArray json = QJsonDocument(object).toJson();
+
+ QByteArray expected =
+ "{\n"
+ " \"Array\": [\n"
+ " null,\n"
+ " null,\n"
+ " null\n"
+ " ]\n"
+ "}\n";
+
+ QCOMPARE(json, expected);
+
+ QJsonDocument doc;
+ doc.setObject(object);
+ json = doc.toJson();
+ QCOMPARE(json, expected);
+}
+
+void tst_QtJson::toJsonLargeNumericValues()
+{
+ QJsonObject object;
+ QJsonArray array;
+ array.append(QJsonValue(1.234567)); // actual precision bug in Qt 5.0.0
+ array.append(QJsonValue(1.7976931348623157e+308)); // JS Number.MAX_VALUE
+ array.append(QJsonValue(5e-324)); // JS Number.MIN_VALUE
+ array.append(QJsonValue(std::numeric_limits<double>::min()));
+ array.append(QJsonValue(std::numeric_limits<double>::max()));
+ array.append(QJsonValue(std::numeric_limits<double>::epsilon()));
+ array.append(QJsonValue(std::numeric_limits<double>::denorm_min()));
+ array.append(QJsonValue(0.0));
+ array.append(QJsonValue(-std::numeric_limits<double>::min()));
+ array.append(QJsonValue(-std::numeric_limits<double>::max()));
+ array.append(QJsonValue(-std::numeric_limits<double>::epsilon()));
+ array.append(QJsonValue(-std::numeric_limits<double>::denorm_min()));
+ array.append(QJsonValue(-0.0));
+ array.append(QJsonValue(9007199254740992LL)); // JS Number max integer
+ array.append(QJsonValue(-9007199254740992LL)); // JS Number min integer
+ object.insert("Array", array);
+
+ QByteArray json = QJsonDocument(object).toJson();
+
+ QByteArray expected =
+ "{\n"
+ " \"Array\": [\n"
+ " 1.234567,\n"
+ " 1.7976931348623157e+308,\n"
+ // ((4.9406564584124654e-324 == 5e-324) == true)
+ // I can only think JavaScript has a special formatter to
+ // emit this value for this IEEE754 bit pattern.
+ " 4.9406564584124654e-324,\n"
+ " 2.2250738585072014e-308,\n"
+ " 1.7976931348623157e+308,\n"
+ " 2.2204460492503131e-16,\n"
+ " 4.9406564584124654e-324,\n"
+ " 0,\n"
+ " -2.2250738585072014e-308,\n"
+ " -1.7976931348623157e+308,\n"
+ " -2.2204460492503131e-16,\n"
+ " -4.9406564584124654e-324,\n"
+ " 0,\n"
+ " 9007199254740992,\n"
+ " -9007199254740992\n"
+ " ]\n"
+ "}\n";
+
+ QCOMPARE(json, expected);
+
+ QJsonDocument doc;
+ doc.setObject(object);
+ json = doc.toJson();
+ QCOMPARE(json, expected);
+}
+
void tst_QtJson::fromJson()
{
{
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 77ea39da53..3e569814c9 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -1302,15 +1302,20 @@ Q_DECLARE_METATYPE(MyObjectPtr)
void tst_QMetaType::automaticTemplateRegistration()
{
- {
- QList<int> intList;
- intList << 42;
- QVERIFY(QVariant::fromValue(intList).value<QList<int> >().first() == 42);
- QVector<QList<int> > vectorList;
- vectorList << intList;
- QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<int> > >().first().first() == 42);
+#define TEST_SEQUENTIAL_CONTAINER(CONTAINER, VALUE_TYPE) \
+ { \
+ CONTAINER<VALUE_TYPE> innerContainer; \
+ innerContainer.push_back(42); \
+ QVERIFY(*QVariant::fromValue(innerContainer).value<CONTAINER<VALUE_TYPE> >().begin() == 42); \
+ QVector<CONTAINER<VALUE_TYPE> > outerContainer; \
+ outerContainer << innerContainer; \
+ QVERIFY(*QVariant::fromValue(outerContainer).value<QVector<CONTAINER<VALUE_TYPE> > >().first().begin() == 42); \
}
+ TEST_SEQUENTIAL_CONTAINER(QList, int)
+ TEST_SEQUENTIAL_CONTAINER(std::vector, int)
+ TEST_SEQUENTIAL_CONTAINER(std::list, int)
+
{
QList<QByteArray> bytearrayList;
bytearrayList << QByteArray("foo");
@@ -1323,14 +1328,9 @@ void tst_QMetaType::automaticTemplateRegistration()
QCOMPARE(::qMetaTypeId<QVariantList>(), (int)QMetaType::QVariantList);
QCOMPARE(::qMetaTypeId<QList<QVariant> >(), (int)QMetaType::QVariantList);
- {
- QList<QVariant> variantList;
- variantList << 42;
- QVERIFY(QVariant::fromValue(variantList).value<QList<QVariant> >().first() == 42);
- QVector<QList<QVariant> > vectorList;
- vectorList << variantList;
- QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QVariant> > >().first().first() == 42);
- }
+ TEST_SEQUENTIAL_CONTAINER(QList, QVariant)
+ TEST_SEQUENTIAL_CONTAINER(std::vector, QVariant)
+ TEST_SEQUENTIAL_CONTAINER(std::list, QVariant)
{
QList<QSharedPointer<QObject> > sharedPointerList;
@@ -1395,6 +1395,31 @@ void tst_QMetaType::automaticTemplateRegistration()
QCOMPARE(QVariant::fromValue(variantMap).value<QVariantMap>().value(QStringLiteral("4")), QVariant(2));
}
{
+ typedef std::map<int, int> IntIntMap;
+ IntIntMap intIntMap;
+ intIntMap[4] = 2;
+ QCOMPARE(QVariant::fromValue(intIntMap).value<IntIntMap>()[4], 2);
+ }
+ {
+ typedef std::map<int, uint> StdIntUIntMap;
+ StdIntUIntMap intUIntMap;
+ intUIntMap[4] = 2;
+ QCOMPARE(QVariant::fromValue(intUIntMap).value<StdIntUIntMap>()[4], (uint)2);
+ }
+ {
+ typedef std::map<int, CustomObject*> StdMapIntCustomObject ;
+ StdMapIntCustomObject intComparableMap;
+ CustomObject *o = 0;
+ intComparableMap[4] = o;
+ QCOMPARE(QVariant::fromValue(intComparableMap).value<StdMapIntCustomObject >()[4], o);
+ }
+ {
+ typedef std::map<QString, QVariant> StdMapStringVariant;
+ StdMapStringVariant variantMap;
+ variantMap[QStringLiteral("4")] = 2;
+ QCOMPARE(QVariant::fromValue(variantMap).value<StdMapStringVariant>()[QStringLiteral("4")], QVariant(2));
+ }
+ {
typedef QPair<int, int> IntIntPair;
IntIntPair intIntPair = qMakePair(4, 2);
QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().first, 4);
@@ -1412,6 +1437,25 @@ void tst_QMetaType::automaticTemplateRegistration()
QCOMPARE(QVariant::fromValue(intComparablePair).value<IntComparablePair>().second, m);
}
{
+ typedef std::pair<int, int> IntIntPair;
+ IntIntPair intIntPair = std::make_pair(4, 2);
+ QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().first, 4);
+ QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().second, 2);
+ }
+ {
+ typedef std::pair<int, uint> StdIntUIntPair;
+ StdIntUIntPair intUIntPair = std::make_pair<int, uint>(4, 2);
+ QCOMPARE(QVariant::fromValue(intUIntPair).value<StdIntUIntPair>().first, 4);
+ QCOMPARE(QVariant::fromValue(intUIntPair).value<StdIntUIntPair>().second, (uint)2);
+ }
+ {
+ typedef std::pair<int, CustomQObject*> StdIntComparablePair;
+ CustomQObject* o = 0;
+ StdIntComparablePair intComparablePair = std::make_pair(4, o);
+ QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().first, 4);
+ QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().second, o);
+ }
+ {
typedef QHash<int, UnregisteredType> IntUnregisteredTypeHash;
QVERIFY(qRegisterMetaType<IntUnregisteredTypeHash>("IntUnregisteredTypeHash") > 0);
}
@@ -1781,11 +1825,15 @@ typedef Undefined (*UndefinedFunction0)();
typedef Undefined (*UndefinedFunction1)(Undefined);
typedef Undefined (*UndefinedFunction2)(Undefined, Undefined);
typedef Undefined (*UndefinedFunction3)(Undefined, Undefined, Undefined);
+typedef Undefined (*UndefinedFunction4)(Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined, Undefined);
Q_DECLARE_METATYPE(UndefinedFunction0);
Q_DECLARE_METATYPE(UndefinedFunction1);
Q_DECLARE_METATYPE(UndefinedFunction2);
Q_DECLARE_METATYPE(UndefinedFunction3);
+#ifdef Q_COMPILER_VARIADIC_TEMPLATES
+Q_DECLARE_METATYPE(UndefinedFunction4);
+#endif
QTEST_MAIN(tst_QMetaType)
#include "tst_qmetatype.moc"
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index 72bf5c58ca..c18ba4d05c 100644
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -78,10 +78,22 @@ private slots:
void qCountContainer() const;
void binaryFindOnLargeContainer() const;
-#if Q_TEST_PERFORMANCE
+ void popCount08_data() { popCount_data_impl(sizeof(quint8 )); }
+ void popCount16_data() { popCount_data_impl(sizeof(quint16)); }
+ void popCount32_data() { popCount_data_impl(sizeof(quint32)); }
+ void popCount64_data() { popCount_data_impl(sizeof(quint64)); }
+ void popCount08() { popCount_impl<quint8 >(); }
+ void popCount16() { popCount_impl<quint16>(); }
+ void popCount32() { popCount_impl<quint32>(); }
+ void popCount64() { popCount_impl<quint64>(); }
+
private:
+#if Q_TEST_PERFORMANCE
void performance();
#endif
+ void popCount_data_impl(size_t sizeof_T_Int);
+ template <typename T_Int>
+ void popCount_impl();
};
class TestInt
@@ -1007,6 +1019,72 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const
QCOMPARE(foundIt.pos(), 1073987655);
}
+// alternative implementation of qPopulationCount for comparison:
+static const uint bitsSetInNibble[] = {
+ 0, 1, 1, 2, 1, 2, 2, 3,
+ 1, 2, 2, 3, 2, 3, 3, 4,
+};
+Q_STATIC_ASSERT(sizeof bitsSetInNibble / sizeof *bitsSetInNibble == 16);
+
+static Q_DECL_CONSTEXPR uint bitsSetInByte(quint8 byte)
+{
+ return bitsSetInNibble[byte & 0xF] + bitsSetInNibble[byte >> 4];
+}
+static Q_DECL_CONSTEXPR uint bitsSetInShort(quint16 word)
+{
+ return bitsSetInByte(word & 0xFF) + bitsSetInByte(word >> 8);
+}
+static Q_DECL_CONSTEXPR uint bitsSetInInt(quint32 word)
+{
+ return bitsSetInShort(word & 0xFFFF) + bitsSetInShort(word >> 16);
+}
+static Q_DECL_CONSTEXPR uint bitsSetInInt64(quint64 word)
+{
+ return bitsSetInInt(word & 0xFFFFFFFF) + bitsSetInInt(word >> 32);
+}
+
+
+void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int)
+{
+ using namespace QTest;
+ addColumn<quint64>("input");
+ addColumn<uint>("expected");
+
+ for (uint i = 0; i < UCHAR_MAX; ++i) {
+ const uchar byte = static_cast<uchar>(i);
+ const uint bits = bitsSetInByte(byte);
+ const quint64 value = static_cast<quint64>(byte);
+ const quint64 input = value << ((i % sizeof_T_Int) * 8U);
+ newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bits;
+ }
+
+ // and some random ones:
+ if (sizeof_T_Int >= 8)
+ for (size_t i = 0; i < 1000; ++i) {
+ const quint64 input = quint64(qrand()) << 32 | quint32(qrand());
+ newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bitsSetInInt64(input);
+ }
+ else if (sizeof_T_Int >= 2)
+ for (size_t i = 0; i < 1000 ; ++i) {
+ const quint32 input = qrand();
+ if (sizeof_T_Int >= 4)
+ newRow(qPrintable(QString().sprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input);
+ else
+ newRow(qPrintable(QString().sprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
+ }
+}
+
+template <typename T_Int>
+void tst_QAlgorithms::popCount_impl()
+{
+ QFETCH(quint64, input);
+ QFETCH(uint, expected);
+
+ const T_Int value = static_cast<T_Int>(input);
+
+ QCOMPARE(qPopulationCount(value), expected);
+}
+
QTEST_APPLESS_MAIN(tst_QAlgorithms)
#include "tst_qalgorithms.moc"
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 6fe7961545..1b1f5575b1 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -61,6 +61,8 @@ private slots:
void name_data();
void name();
+ void namehex_data();
+ void namehex();
void setNamedColor();
void constructNamedColorWithSpace();
@@ -254,36 +256,75 @@ void tst_QColor::isValid()
QVERIFY(color.isValid() == isValid);
}
+Q_DECLARE_METATYPE(QColor::NameFormat);
+
void tst_QColor::name_data()
{
QTest::addColumn<QColor>("color");
QTest::addColumn<QString>("name");
-
- QTest::newRow("invalid") << QColor() << "#000000";
- QTest::newRow("global color black") << QColor(Qt::black) << "#000000";
- QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff";
- QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080";
- QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4";
- QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0";
- QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000";
- QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00";
- QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff";
- QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff";
- QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff";
- QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00";
- QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000";
- QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000";
- QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080";
- QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080";
- QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080";
- QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000";
+ QTest::addColumn<QColor::NameFormat>("nameFormat");
+
+ QTest::newRow("invalid") << QColor() << "#000000" << QColor::HexRgb;
+ QTest::newRow("global color black") << QColor(Qt::black) << "#000000" << QColor::HexRgb;
+ QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff" << QColor::HexRgb;
+ QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080" << QColor::HexRgb;
+ QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4" << QColor::HexRgb;
+ QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0" << QColor::HexRgb;
+ QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000" << QColor::HexRgb;
+ QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00" << QColor::HexRgb;
+ QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff" << QColor::HexRgb;
+ QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff" << QColor::HexRgb;
+ QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff" << QColor::HexRgb;
+ QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00" << QColor::HexRgb;
+ QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000" << QColor::HexRgb;
+ QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000" << QColor::HexRgb;
+ QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080" << QColor::HexRgb;
+ QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080" << QColor::HexRgb;
+ QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080" << QColor::HexRgb;
+ QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000" << QColor::HexRgb;
+ QTest::newRow("transparent red") << QColor(255, 0, 0, 102) << "#66ff0000" << QColor::HexArgb;
}
void tst_QColor::name()
{
QFETCH(QColor, color);
QFETCH(QString, name);
- QCOMPARE(color.name(), name);
+ QFETCH(QColor::NameFormat, nameFormat);
+ QCOMPARE(color.name(nameFormat), name);
+}
+
+void tst_QColor::namehex_data()
+{
+ QTest::addColumn<QString>("hexcolor");
+ QTest::addColumn<QColor>("color");
+
+ QTest::newRow("global color black") << "#000000" << QColor(Qt::black);
+ QTest::newRow("global color white") << "#ffffff" << QColor(Qt::white);
+ QTest::newRow("global color darkGray") << "#808080" << QColor(Qt::darkGray);
+ QTest::newRow("global color gray") << "#a0a0a4" << QColor(Qt::gray);
+ QTest::newRow("global color lightGray") << "#c0c0c0" << QColor(Qt::lightGray);
+ QTest::newRow("global color red") << "#ff0000" << QColor(Qt::red);
+ QTest::newRow("global color green") << "#00ff00" << QColor(Qt::green);
+ QTest::newRow("global color blue") << "#0000ff" << QColor(Qt::blue);
+ QTest::newRow("global color cyan") << "#00ffff" << QColor(Qt::cyan);
+ QTest::newRow("global color magenta") << "#ff00ff" << QColor(Qt::magenta);
+ QTest::newRow("global color yellow") << "#ffff00" << QColor(Qt::yellow);
+ QTest::newRow("global color darkRed") << "#800000" << QColor(Qt::darkRed);
+ QTest::newRow("global color darkGreen") << "#008000" << QColor(Qt::darkGreen);
+ QTest::newRow("global color darkBlue") << "#000080" << QColor(Qt::darkBlue);
+ QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan);
+ QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta);
+ QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow);
+ QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102);
+ QTest::newRow("invalid red") << "#gg0000" << QColor();
+ QTest::newRow("invalid transparent") << "#gg00ff00" << QColor();
+}
+
+void tst_QColor::namehex()
+{
+ QFETCH(QString, hexcolor);
+ QFETCH(QColor, color);
+ QCOMPARE(QColor(hexcolor), color);
}
void tst_QColor::globalColors_data()
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index ca6c42c9bd..86e282fad2 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -344,8 +344,6 @@ void tst_QCssParser::term_data()
val.variant = QVariant(QColor("#ffbb00"));
QTest::newRow("hexcolor2") << true << "#fb0" << val;
- QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val;
-
val.type = QCss::Value::Uri;
val.variant = QString("www.kde.org");
QTest::newRow("uri1") << true << "url(\"www.kde.org\")" << val;
@@ -367,9 +365,6 @@ void tst_QCssParser::term()
QFETCH(QString, css);
QFETCH(QCss::Value, expectedValue);
- if (strcmp(QTest::currentDataTag(), "hexcolor_failure") == 0)
- QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'");
-
QCss::Parser parser(css);
QCss::Value val;
QVERIFY(parser.testTerm());
diff --git a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
index 25301feee4..125eab2f8c 100644
--- a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
+++ b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
@@ -77,30 +77,43 @@ void tst_QNetworkAccessManager::networkAccessible()
QSignalSpy spy(&manager,
SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
- QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
+ // if there is no session, we cannot know in which state we are in
+ QNetworkAccessManager::NetworkAccessibility initialAccessibility =
+ manager.networkAccessible();
+ QCOMPARE(manager.networkAccessible(), initialAccessibility);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
- QNetworkAccessManager::NotAccessible);
+ int expectedCount = (initialAccessibility == QNetworkAccessManager::Accessible) ? 1 : 0;
+ QCOMPARE(spy.count(), expectedCount);
+ if (expectedCount > 0)
+ QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
+ QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
- QNetworkAccessManager::UnknownAccessibility);
- QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
+ QCOMPARE(spy.count(), expectedCount);
+ if (expectedCount > 0)
+ QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
+ initialAccessibility);
+ QCOMPARE(manager.networkAccessible(), initialAccessibility);
QNetworkConfigurationManager configManager;
+ bool sessionRequired = (configManager.capabilities()
+ & QNetworkConfigurationManager::NetworkSessionRequired);
QNetworkConfiguration defaultConfig = configManager.defaultConfiguration();
if (defaultConfig.isValid()) {
manager.setConfiguration(defaultConfig);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
- QNetworkAccessManager::Accessible);
+ // the accessibility has not changed if no session is required
+ if (sessionRequired) {
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
+ QNetworkAccessManager::Accessible);
+ } else {
+ QCOMPARE(spy.count(), 0);
+ }
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index bcc0641973..97f9667140 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -5920,7 +5920,7 @@ void tst_QNetworkReply::sslSessionSharing()
warmupRequest.setAttribute(QNetworkRequest::User, sessionSharingEnabled); // so we can read it from the slot
if (! sessionSharingEnabled) {
QSslConfiguration configuration(QSslConfiguration::defaultConfiguration());
- configuration.setSslOption(QSsl::SslOptionDisableSessionTickets, true);
+ configuration.setSslOption(QSsl::SslOptionDisableSessionSharing, true);
warmupRequest.setSslConfiguration(configuration);
}
QNetworkReply *reply = manager.get(warmupRequest);
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 2b9dfc5081..ee5c7e42d8 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -513,7 +513,7 @@ void tst_QTcpSocket::bind()
{
QFETCH_GLOBAL(bool, setProxy);
if (setProxy)
- QSKIP("QTBUG-22964");
+ return; // QTBUG-22964 for proxies, QTBUG-29972 for QSKIP
QFETCH(QString, stringAddr);
QFETCH(bool, successExpected);
QFETCH(QString, stringExpectedLocalAddress);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 41e5ed466c..92caeb7803 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -126,6 +126,7 @@ private slots:
void spanningItem2x3_data();
void spanningItem2x3();
void spanningItem();
+ void spanAcrossEmptyRow();
void heightForWidth();
void widthForHeight();
void heightForWidthWithSpanning();
@@ -3180,23 +3181,19 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning()
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 1));
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(200, 100));
- QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue);
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30000, 30000));
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100));
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100));
- QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue);
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100));
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 10000));
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 10000));
- QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue);
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 10000));
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100));
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100));
- QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue);
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100));
}
Q_DECLARE_METATYPE(QSizePolicy::Policy)
@@ -3352,6 +3349,37 @@ void tst_QGraphicsGridLayout::spanningItem()
QCOMPARE(layout->maximumSize(), QSizeF(160,80));
}
+void tst_QGraphicsGridLayout::spanAcrossEmptyRow()
+{
+ QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window);
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(form);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ RectWidget *w1 = new RectWidget;
+ RectWidget *w2 = new RectWidget;
+ RectWidget *w3 = new RectWidget;
+
+ QSizeF size(10, 10);
+ for (int i = 0; i < 3; ++i) {
+ w1->setSizeHint((Qt::SizeHint)i, size);
+ w2->setSizeHint((Qt::SizeHint)i, size);
+ w3->setSizeHint((Qt::SizeHint)i, size);
+ size+=size; //[(10,10), (20,20), (40,40)]
+ }
+ layout->addItem(w1, 0, 0, 1, 1);
+ layout->addItem(w2, 0, 1, 1, 2);
+ layout->addItem(w3, 0, 99, 1, 1);
+
+ form->resize(60,20);
+ QCOMPARE(w1->geometry(), QRectF( 0, 0, 20, 20));
+ QCOMPARE(w2->geometry(), QRectF(20, 0, 20, 20));
+ QCOMPARE(w3->geometry(), QRectF(40, 0, 20, 20));
+
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize), QSizeF(30, 10));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 20));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize), QSizeF(120, 40));
+}
+
void tst_QGraphicsGridLayout::stretchAndHeightForWidth()
{
QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window);
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 8e888f06ee..dfb780c8fa 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -106,6 +106,8 @@ private slots:
void moveCursorStrikesBack_data();
void moveCursorStrikesBack();
+ void moveCursorBiggerJump();
+
void hideRows_data();
void hideRows();
@@ -1354,6 +1356,34 @@ void tst_QTableView::moveCursorStrikesBack()
QCOMPARE(newColumn, expectedColumn);
}
+void tst_QTableView::moveCursorBiggerJump()
+{
+ QtTestTableModel model(50, 7);
+ QTableView view;
+ view.setModel(&model);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ int height = view.horizontalHeader()->height();
+ for (int i=0;i<8;i++)
+ height += view.verticalHeader()->sectionSize(i);
+ view.resize(view.width(), height);
+ view.setCurrentIndex(model.index(0,0));
+
+ QTest::keyClick(&view, Qt::Key_PageDown);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(1,0));
+ QTest::keyClick(&view, Qt::Key_PageDown);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(8,0));
+ QTest::keyClick(&view, Qt::Key_PageDown);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(15,0));
+ QTest::keyClick(&view, Qt::Key_PageUp);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(14,0));
+ QTest::keyClick(&view, Qt::Key_PageUp);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0));
+ QTest::keyClick(&view, Qt::Key_PageUp);
+ QCOMPARE(view.indexAt(QPoint(0,0)), model.index(0,0));
+}
+
void tst_QTableView::hideRows_data()
{
QTest::addColumn<int>("rowCount");
@@ -3762,8 +3792,6 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections()
QTRY_COMPARE(tv.rowAt(0), tv.verticalHeader()->logicalIndex(0));
int newRow = tv.rowAt(tv.viewport()->height());
- if (newRow == tv.rowAt(tv.viewport()->height() - 1)) // Overlapping row
- newRow++;
QTest::keyClick(&tv, Qt::Key_PageDown); // Scroll down and check current
QTRY_COMPARE(tv.currentIndex().row(), newRow);
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 9a7b7956d8..dcda9f7fd7 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -2017,6 +2017,8 @@ void tst_QTreeView::clicked()
view.setModel(&model);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
QModelIndex firstIndex = model.index(0, 0, QModelIndex());
QVERIFY(firstIndex.isValid());
int itemHeight = view.visualRect(firstIndex).height();
diff --git a/tests/manual/widgets/itemviews/qtreeview/main.cpp b/tests/manual/widgets/itemviews/qtreeview/main.cpp
index 296ba6bcbf..22b4e07f75 100644
--- a/tests/manual/widgets/itemviews/qtreeview/main.cpp
+++ b/tests/manual/widgets/itemviews/qtreeview/main.cpp
@@ -39,17 +39,34 @@
**
****************************************************************************/
-
-#include <QtWidgets/QFileSystemModel>
-#include <QtWidgets/QtWidgets>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QFileSystemModel *model = new QFileSystemModel;
- model->setRootPath(QDir::currentPath());
- QTreeView *tree = new QTreeView();
- tree->setModel(model);
- tree->show();
- app.exec();
+ QFileSystemModel model;
+ QWidget window;
+ QTreeView *tree = new QTreeView(&window);
+ tree->setMaximumSize(1000, 600);
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->setSizeConstraint(QLayout::SetFixedSize);
+ layout->addWidget(tree);
+
+ window.setLayout(layout);
+ model.setRootPath("");
+ tree->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
+ tree->setModel(&model);
+
+ tree->setAnimated(false);
+ tree->setIndentation(20);
+ tree->setSortingEnabled(true);
+ tree->header()->setStretchLastSection(false);
+
+ window.setWindowTitle(QObject::tr("Dir View"));
+ tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+
+ window.show();
+
+ return app.exec();
}
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
index aec2479239..bb05570f18 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
@@ -49,7 +49,7 @@ public:
setFlags(QGraphicsItem::ItemIsSelectable);
}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option*/, QWidget * /*widget*/)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option*/, QWidget * /*widget*/) Q_DECL_OVERRIDE
{
if (isSelected())
painter->fillRect(rect(), QColor(255, 0, 0));
@@ -68,7 +68,7 @@ public:
connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF)));
}
protected:
- void mouseMoveEvent(QMouseEvent *event)
+ void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
{
QGraphicsView::mouseMoveEvent(event);
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index a18aac3209..884b9aa6e8 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -2881,6 +2881,14 @@ void Configure::generateCachefile()
moduleStream << "QT_SKIP_MODULES += " << skipModules.join(' ') << endl;
moduleStream << endl;
+ moduleStream << "host_build {" << endl;
+ moduleStream << " QT_CPU_FEATURES." << dictionary["QT_HOST_ARCH"] <<
+ " = " << dictionary["QT_HOST_CPU_FEATURES"] << endl;
+ moduleStream << "} else {" << endl;
+ moduleStream << " QT_CPU_FEATURES." << dictionary["QT_ARCH"] <<
+ " = " << dictionary["QT_CPU_FEATURES"] << endl;
+ moduleStream << "}" << endl;
+
if (dictionary["QT_EDITION"] != "QT_EDITION_OPENSOURCE")
moduleStream << "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" << endl;
@@ -3159,15 +3167,16 @@ void Configure::generateQConfigPri()
configStream << " qpa";
configStream << endl;
- configStream << "QT_ARCH = " << dictionary["QT_ARCH"] << endl;
- configStream << "QT_HOST_ARCH = " << dictionary["QT_HOST_ARCH"] << endl;
- configStream << "QT_CPU_FEATURES = " << dictionary["QT_CPU_FEATURES"] << endl;
- configStream << "QT_HOST_CPU_FEATURES = " << dictionary["QT_HOST_CPU_FEATURES"] << endl;
+ configStream << "host_build {" << endl;
+ configStream << " QT_ARCH = " << dictionary["QT_HOST_ARCH"] << endl;
+ configStream << "} else {" << endl;
+ configStream << " QT_ARCH = " << dictionary["QT_ARCH"] << endl;
if (dictionary.contains("XQMAKESPEC") && !dictionary["XQMAKESPEC"].startsWith("wince")) {
// FIXME: add detection
- configStream << "QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib" << endl;
- configStream << "QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include" << endl;
+ configStream << " QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib" << endl;
+ configStream << " QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include" << endl;
}
+ configStream << "}" << endl;
if (dictionary["QT_EDITION"].contains("OPENSOURCE"))
configStream << "QT_EDITION = " << QLatin1String("OpenSource") << endl;
else