diff --git a/doc/global/externalsites/external-resources.qdoc b/doc/global/externalsites/external-resources.qdoc index 01c6939dca0..1c3d37c1994 100644 --- a/doc/global/externalsites/external-resources.qdoc +++ b/doc/global/externalsites/external-resources.qdoc @@ -71,6 +71,16 @@ \title CMake AUTOMOC Documentation */ +/*! + \externalpage https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html#autorcc + \title CMake AUTORCC Documentation +*/ + +/*! + \externalpage https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html#autouic + \title CMake AUTOUIC Documentation +*/ + /*! \externalpage https://cmake.org/cmake/help/latest/prop_tgt/LOCATION.html \title CMake LOCATION Documentation diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf index dbf5b743552..57cfec78b38 100644 --- a/mkspecs/features/qml_module.prf +++ b/mkspecs/features/qml_module.prf @@ -50,10 +50,7 @@ builtin_resources { # Install rules qmldir.base = $$qmldir_path -# Tools need qmldir and plugins.qmltypes always installed on the file system - qmldir.files = $$qmldir_file -install_qml_files: qmldir.files += $$fq_qml_files qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH INSTALLS += qmldir @@ -65,12 +62,12 @@ INSTALLS += qmlfiles !debug_and_release|!build_all|CONFIG(release, debug|release) { !prefix_build { - COPIES += qmldir + COPIES += qmldir qmlfiles } else { # For non-installed static builds, tools need qmldir and plugins.qmltypes # files in the build dir - qmldir2build.files = $$qmldir_file $$fq_aux_qml_files - qmldir2build.path = $$DESTDIR - COPIES += qmldir2build + qml2build.files = $$qmldir_file $$fq_aux_qml_files + qml2build.path = $$DESTDIR + COPIES += qml2build } } diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index de726c674cf..54d351bfd5b 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -67,7 +67,7 @@ contains(TEMPLATE, .*app) { # replacing the app name placeholder with the actual app name. apphtml.name = application main html file apphtml.output = $$DESTDIR/$$TARGET_HTML - apphtml.commands = sed -e s/APPNAME/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML + apphtml.commands = sed -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML apphtml.input = $$WASM_PLUGIN_PATH/wasm_shell.html apphtml.depends = $$apphtml.input QMAKE_EXTRA_COMPILERS += apphtml diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 48ca96ae925..b271abcee3a 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1154,8 +1154,9 @@ \target DEPENDPATH \section1 DEPENDPATH - Specifies a list of all directories to look in to resolve dependencies. This - variable is used when crawling through \c included files. + Specifies a list of directories for qmake to scan, to resolve dependencies. + This variable is used when qmake crawls through the header files that you + \c{#include} in your source code. \target DESTDIR \section1 DESTDIR diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index cfd71a911b5..6a6cb244415 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1995,14 +1995,11 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell); dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } + QByteArray depData; + while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc)) + depData.append(buff, read_in); QT_PCLOSE(proc); + const QString indeps = QString::fromLocal8Bit(depData); if(!indeps.isEmpty()) { QDir outDir(Option::output_dir); QStringList dep_cmd_deps = splitDeps(indeps, dep_lines); @@ -2083,14 +2080,11 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, out, LocalShell); dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } + QByteArray depData; + while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc)) + depData.append(buff, read_in); QT_PCLOSE(proc); + const QString indeps = QString::fromLocal8Bit(depData); if(!indeps.isEmpty()) { QDir outDir(Option::output_dir); QStringList dep_cmd_deps = splitDeps(indeps, dep_lines); diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cmake b/src/corelib/doc/snippets/cmake-macros/examples.cmake new file mode 100644 index 00000000000..bba082586f5 --- /dev/null +++ b/src/corelib/doc/snippets/cmake-macros/examples.cmake @@ -0,0 +1,26 @@ +#! [qt5_wrap_cpp] +set(SOURCES myapp.cpp main.cpp) +qt5_wrap_cpp(SOURCES myapp.h) +add_executable(myapp ${SOURCES}) +#! [qt5_wrap_cpp] + +#! [qt5_add_resources] +set(SOURCES main.cpp) +qt5_add_resources(SOURCES example.qrc) +add_executable(myapp ${SOURCES}) +#! [qt5_add_resources] + +#! [qt5_add_big_resources] +set(SOURCES main.cpp) +qt5_add_big_resources(SOURCES big_resource.qrc) +add_executable(myapp ${SOURCES}) +#! [qt5_add_big_resources] + +#! [qt5_add_binary_resources] +qt5_add_binary_resources(resources project.qrc OPTIONS -no-compress) +add_dependencies(myapp resources) +#! [qt5_add_binary_resources] + +#! [qt5_generate_moc] +qt5_generate_moc(main.cpp main.moc TARGET myapp) +#! [qt5_generate_moc] diff --git a/src/corelib/doc/src/cmake-macros.qdoc b/src/corelib/doc/src/cmake-macros.qdoc new file mode 100644 index 00000000000..6140e8be44a --- /dev/null +++ b/src/corelib/doc/src/cmake-macros.qdoc @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qtcore-cmake-qt5-wrap-cpp.html +\ingroup cmake-macros-qtcore + +\title qt5_wrap_cpp + +\brief Creates \c{.moc} files from sources. + +\section1 Synopsis + +\badcode +qt5_wrap_cpp( src_file1 [src_file2 ...] + [TARGET target] + [OPTIONS ...] + [DEPENDS ...]) +\endcode + +\section1 Description + +Creates rules for calling \l{moc}{Meta-Object Compiler (moc)} on the given +source files. For each input file, an output file is generated in the build +directory. The paths of the generated files are added to\c{}. + +\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a +more convenient way to let source files be processed with \c{moc}. + +\section1 Options + +You can set an explicit \c{TARGET}. This will make sure that the target +properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used +when scanning the source files with \c{moc}. + +You can set additional \c{OPTIONS} that should be added to the \c{moc} calls. +You can find possible options in the \l{moc}{moc documentation}. + +\c{DEPENDS} allows you to add additional dependencies for recreation of the +generated files. This is useful when the sources have implicit dependencies, +like code for a Qt plugin that includes a \c{.json} file using the +Q_PLUGIN_METADATA() macro. + +\section1 Examples + +\snippet cmake-macros/examples.cmake qt5_wrap_cpp +*/ + +/*! +\page qtcore-cmake-qt5-add-resources.html +\ingroup cmake-macros-qtcore + +\title qt5_add_resources + +\brief Compiles binary resources into source code. + +\section1 Synopsis + +\badcode +qt5_add_resources( file1.qrc [file2.qrc ...] + [OPTIONS ...]) +\endcode + +\section1 Description + +Creates source code from Qt resource files using the +\l{Resource Compiler (rcc)}. Paths to the generated source files are added to +\c{}. + +\note This is a low-level macro. See the \l{CMake AUTORCC Documentation} for a +more convenient way to let Qt resource files be processed with \c{rcc}. +For embedding bigger resources, see \l qt5_add_big_resources. + +\section1 Arguments + +You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls. +You can find possible options in the \l{rcc}{rcc documentation}. + +\section1 Examples + +\snippet cmake-macros/examples.cmake qt5_add_resources +*/ + +/*! +\page qtcore-cmake-qt5-add-big-resources.html +\ingroup cmake-macros-qtcore + +\title qt5_add_big_resources + +\brief Compiles big binary resources into object code. + +\section1 Synopsis + +\badcode +qt5_add_big_resources( file1.qrc [file2.qrc ...] + [OPTIONS ...]) +\endcode + +\section1 Description + +Creates compiled object files from Qt resource files using the +\l{Resource Compiler (rcc)}. Paths to the generated files are added to +\c{}. + +This is similar to \l qt5_add_resources, but directly generates object +files (\c .o, \c .obj) files instead of C++ source code. This allows to +embed bigger resources, where compiling to C++ sources and then to +binaries would be too time consuming or memory intensive. + +\section1 Arguments + +You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls. +You can find possible options in the \l{rcc}{rcc documentation}. + +\section1 Examples + +\snippet cmake-macros/examples.cmake qt5_add_big_resources +*/ + +/*! +\page qtcore-cmake-qt5_add_binary_resources.html +\ingroup cmake-macros-qtcore + +\title qt5_add_binary_resources + +\brief Creates an \c{RCC} file from a list of Qt resource files. + +\section1 Synopsis + +\badcode +qt5_add_binary_resources(target file1.qrc [file2.qrc ...] + [DESTINATION ...] + [OPTIONS ...]) +\endcode + +\section1 Description + +Adds a custom \c target that compiles Qt resource files into a binary \c{.rcc} +file. + +\section1 Arguments + +\c{DESTINATION} sets the path of the generated \c{.rcc} file. The default is +\c{${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc}. + +You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls. +You can find possible options in the \l{rcc}{rcc documentation}. + +\section1 Examples + +\snippet cmake-macros/examples.cmake qt5_add_binary_resources +*/ + +/*! +\page qtcore-cmake-qt5-generate-moc.html +\ingroup cmake-macros-qtcore + +\title qt5_generate_moc + +\brief Calls moc on an input file. + +\section1 Synopsis + +\badcode +qt5_generate_moc(src_file dest_file + [TARGET target]) +\endcode + +\section1 Description + +Creates a rule to call the \l{moc}{Meta-Object Compiler (moc)} on \c src_file +and store the output in \c dest_file. + +\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a +more convenient way to let source files be processed with \c{moc}. +\l qt5_wrap_cpp is also similar, but automatically generates a temporary file +path for you. + +\section1 Arguments + +You can set an explicit \c{TARGET}. This will make sure that the target +properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used +when scanning the source files with \c{moc}. + +\section1 Examples + +\snippet cmake-macros/examples.cmake qt5_generate_moc +*/ diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5bab897d431..b78e037865d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -695,52 +695,36 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, Q_UNUSED(data); return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); #else - char *ret = 0; -# if defined(Q_OS_DARWIN) - ret = (char*)malloc(PATH_MAX + 1); - if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { - const int savedErrno = errno; // errno is checked below, and free() might change it - free(ret); - errno = savedErrno; - ret = 0; - } -# elif defined(Q_OS_ANDROID) - // On some Android versions, realpath() will return a path even if it does not exist - // To work around this, we check existence in advance. + char stack_result[PATH_MAX+1]; + char *resolved_name = nullptr; +# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) + // On some Android and macOS versions, realpath() will return a path even if + // it does not exist. To work around this, we check existence in advance. if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute)) fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute); if (!data.exists()) { - ret = 0; errno = ENOENT; } else { - ret = (char*)malloc(PATH_MAX + 1); - if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { - const int savedErrno = errno; // errno is checked below, and free() might change it - free(ret); - errno = savedErrno; - ret = 0; - } + resolved_name = stack_result; } - + if (resolved_name && realpath(entry.nativeFilePath().constData(), resolved_name) == nullptr) + resolved_name = nullptr; # else -# if _POSIX_VERSION >= 200801L - ret = realpath(entry.nativeFilePath().constData(), (char*)0); +# if _POSIX_VERSION >= 200801L // ask realpath to allocate memory + resolved_name = realpath(entry.nativeFilePath().constData(), nullptr); # else - ret = (char*)malloc(PATH_MAX + 1); - if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { - const int savedErrno = errno; // errno is checked below, and free() might change it - free(ret); - errno = savedErrno; - ret = 0; - } + resolved_name = stack_result; + if (realpath(entry.nativeFilePath().constData(), resolved_name) == nullptr) + resolved_name = nullptr; # endif # endif - if (ret) { + if (resolved_name) { data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; data.entryFlags |= QFileSystemMetaData::ExistsAttribute; - QString canonicalPath = QDir::cleanPath(QFile::decodeName(ret)); - free(ret); + QString canonicalPath = QDir::cleanPath(QFile::decodeName(resolved_name)); + if (resolved_name != stack_result) + free(resolved_name); return QFileSystemEntry(canonicalPath); } else if (errno == ENOENT || errno == ENOTDIR) { // file doesn't exist data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 625790abb8d..b70c61e351d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -46,6 +46,7 @@ #include "qcoreevent.h" #include "qeventloop.h" #endif +#include "qmetaobject.h" #include "qcorecmdlineargs_p.h" #include #include @@ -952,6 +953,10 @@ bool QCoreApplication::isSetuidAllowed() Sets the attribute \a attribute if \a on is true; otherwise clears the attribute. + \note Some application attributes must be set \b before creating a + QCoreApplication instance. Refer to the Qt::ApplicationAttribute + documentation for more information. + \sa testAttribute() */ void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on) @@ -960,6 +965,27 @@ void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on) QCoreApplicationPrivate::attribs |= 1 << attribute; else QCoreApplicationPrivate::attribs &= ~(1 << attribute); + if (Q_UNLIKELY(qApp)) { + switch (attribute) { + case Qt::AA_EnableHighDpiScaling: + case Qt::AA_DisableHighDpiScaling: + case Qt::AA_PluginApplication: + case Qt::AA_UseDesktopOpenGL: + case Qt::AA_UseOpenGLES: + case Qt::AA_UseSoftwareOpenGL: + case Qt::AA_ShareOpenGLContexts: +#ifdef QT_BOOTSTRAPPED + qWarning("Attribute %d must be set before QCoreApplication is created.", + attribute); +#else + qWarning("Attribute Qt::%s must be set before QCoreApplication is created.", + QMetaEnum::fromType().valueToKey(attribute)); +#endif + break; + default: + break; + } + } } /*! diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 10b14a7e031..fcd92afd898 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -230,7 +230,8 @@ public: template static QMetaEnum fromType() { Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper::Value, - "QMetaEnum::fromType only works with enums declared as Q_ENUM or Q_FLAG"); + "QMetaEnum::fromType only works with enums declared as " + "Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS"); const QMetaObject *metaObject = qt_getEnumMetaObject(T()); const char *name = qt_getEnumName(T()); return metaObject->enumerator(metaObject->indexOfEnumerator(name)); diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 0e32776c718..3aadd1a73b6 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE # define QLIBRARY_AS_DEBUG true #endif -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) || defined(Q_CC_MINGW) // We don't use separate debug and release libs on UNIX, so we want // to allow loading plugins, regardless of how they were built. # define QT_NO_DEBUG_PLUGIN_CHECK diff --git a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp index 4266da0a118..a7e22e549d0 100644 --- a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp +++ b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp @@ -50,8 +50,8 @@ //! [0] QStandardItemModel model(4, 4); -for (int row = 0; row < 4; ++row) { - for (int column = 0; column < 4; ++column) { +for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column)); model.setItem(row, column, item); } diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 4b85973e925..4f8e9a38176 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -492,5 +492,13 @@ QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen) return platformScreen->geometry().topLeft(); } +QPoint QHighDpiScaling::origin(const QWindow *window) +{ + if (window && window->isTopLevel() && window->screen()) + return window->screen()->geometry().topLeft(); + + return QPoint(0, 0); +} + #endif //QT_NO_HIGHDPISCALING QT_END_NAMESPACE diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 28cf7de75b1..dfc6abf5ba7 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -83,6 +83,7 @@ public: static qreal factor(const QPlatformScreen *platformScreen); static QPoint origin(const QScreen *screen); static QPoint origin(const QPlatformScreen *platformScreen); + static QPoint origin(const QWindow *window); static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen); static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); @@ -203,94 +204,42 @@ inline QPointF toNativeLocalPosition(const QPointF &pos, const QWindow *window) return pos * scaleFactor; } -inline QRect fromNativePixels(const QRect &pixelRect, const QPlatformScreen *platformScreen) +template +inline QRect fromNativePixels(const QRect &pixelRect, const C *context) { - const qreal scaleFactor = QHighDpiScaling::factor(platformScreen); - const QPoint origin = QHighDpiScaling::origin(platformScreen); + const qreal scaleFactor = QHighDpiScaling::factor(context); + const QPoint origin = QHighDpiScaling::origin(context); return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin), fromNative(pixelRect.size(), scaleFactor)); } -inline QRect toNativePixels(const QRect &pointRect, const QPlatformScreen *platformScreen) +template +inline QRect toNativePixels(const QRect &pointRect, const C *context) { - const qreal scaleFactor = QHighDpiScaling::factor(platformScreen); - const QPoint origin = QHighDpiScaling::origin(platformScreen); + const qreal scaleFactor = QHighDpiScaling::factor(context); + const QPoint origin = QHighDpiScaling::origin(context); return QRect(toNative(pointRect.topLeft(), scaleFactor, origin), toNative(pointRect.size(), scaleFactor)); } -inline QRect fromNativePixels(const QRect &pixelRect, const QScreen *screen) +template +inline QRectF toNativePixels(const QRectF &pointRect, const C *context) { - const qreal scaleFactor = QHighDpiScaling::factor(screen); - const QPoint origin = QHighDpiScaling::origin(screen); - return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin), - fromNative(pixelRect.size(), scaleFactor)); -} - -inline QRect toNativePixels(const QRect &pointRect, const QScreen *screen) -{ - const qreal scaleFactor = QHighDpiScaling::factor(screen); - const QPoint origin = QHighDpiScaling::origin(screen); - return QRect(toNative(pointRect.topLeft(), scaleFactor, origin), - toNative(pointRect.size(), scaleFactor)); -} - -inline QRect fromNativePixels(const QRect &pixelRect, const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) { - return fromNativePixels(pixelRect, window->screen()); - } else { - const qreal scaleFactor = QHighDpiScaling::factor(window); - return QRect(pixelRect.topLeft() / scaleFactor, fromNative(pixelRect.size(), scaleFactor)); - } -} - -inline QRectF toNativePixels(const QRectF &pointRect, const QScreen *screen) -{ - const qreal scaleFactor = QHighDpiScaling::factor(screen); - const QPoint origin = QHighDpiScaling::origin(screen); + const qreal scaleFactor = QHighDpiScaling::factor(context); + const QPoint origin = QHighDpiScaling::origin(context); return QRectF(toNative(pointRect.topLeft(), scaleFactor, origin), - toNative(pointRect.size(), scaleFactor)); + toNative(pointRect.size(), scaleFactor)); } -inline QRect toNativePixels(const QRect &pointRect, const QWindow *window) +template +inline QRectF fromNativePixels(const QRectF &pixelRect, const C *context) { - if (window && window->isTopLevel() && window->screen()) { - return toNativePixels(pointRect, window->screen()); - } else { - const qreal scaleFactor = QHighDpiScaling::factor(window); - return QRect(pointRect.topLeft() * scaleFactor, toNative(pointRect.size(), scaleFactor)); - } -} - -inline QRectF fromNativePixels(const QRectF &pixelRect, const QScreen *screen) -{ - const qreal scaleFactor = QHighDpiScaling::factor(screen); - const QPoint origin = QHighDpiScaling::origin(screen); + const qreal scaleFactor = QHighDpiScaling::factor(context); + const QPoint origin = QHighDpiScaling::origin(context); return QRectF(fromNative(pixelRect.topLeft(), scaleFactor, origin), fromNative(pixelRect.size(), scaleFactor)); } -inline QRectF fromNativePixels(const QRectF &pixelRect, const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) { - return fromNativePixels(pixelRect, window->screen()); - } else { - const qreal scaleFactor = QHighDpiScaling::factor(window); - return QRectF(pixelRect.topLeft() / scaleFactor, pixelRect.size() / scaleFactor); - } -} - -inline QRectF toNativePixels(const QRectF &pointRect, const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) { - return toNativePixels(pointRect, window->screen()); - } else { - const qreal scaleFactor = QHighDpiScaling::factor(window); - return QRectF(pointRect.topLeft() * scaleFactor, pointRect.size() * scaleFactor); - } -} - inline QSize fromNativePixels(const QSize &pixelSize, const QWindow *window) { return pixelSize / QHighDpiScaling::factor(window); @@ -311,56 +260,28 @@ inline QSizeF toNativePixels(const QSizeF &pointSize, const QWindow *window) return pointSize * QHighDpiScaling::factor(window); } -inline QPoint fromNativePixels(const QPoint &pixelPoint, const QScreen *screen) +template +inline QPoint fromNativePixels(const QPoint &pixelPoint, const C *context) { - return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen)); + return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); } -inline QPoint fromNativePixels(const QPoint &pixelPoint, const QWindow *window) +template +inline QPoint toNativePixels(const QPoint &pointPoint, const C *context) { - if (window && window->isTopLevel() && window->screen()) - return fromNativePixels(pixelPoint, window->screen()); - else - return pixelPoint / QHighDpiScaling::factor(window); + return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); } -inline QPoint toNativePixels(const QPoint &pointPoint, const QScreen *screen) +template +inline QPointF fromNativePixels(const QPointF &pixelPoint, const C *context) { - return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen)); + return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); } -inline QPoint toNativePixels(const QPoint &pointPoint, const QWindow *window) +template +inline QPointF toNativePixels(const QPointF &pointPoint, const C *context) { - if (window && window->isTopLevel() && window->screen()) - return toNativePixels(pointPoint, window->screen()); - else - return pointPoint * QHighDpiScaling::factor(window); -} - -inline QPointF fromNativePixels(const QPointF &pixelPoint, const QScreen *screen) -{ - return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen)); -} - -inline QPointF fromNativePixels(const QPointF &pixelPoint, const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) - return fromNativePixels(pixelPoint, window->screen()); - else - return pixelPoint / QHighDpiScaling::factor(window); -} - -inline QPointF toNativePixels(const QPointF &pointPoint, const QScreen *screen) -{ - return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen)); -} - -inline QPointF toNativePixels(const QPointF &pointPoint, const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) - return toNativePixels(pointPoint, window->screen()); - else - return pointPoint * QHighDpiScaling::factor(window); + return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); } inline QMargins fromNativePixels(const QMargins &pixelMargins, const QWindow *window) @@ -425,47 +346,26 @@ inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *wi } // Any T that has operator/() -template -T fromNativePixels(const T &pixelValue, const QWindow *window) +template +T fromNativePixels(const T &pixelValue, const C *context) { if (!QHighDpiScaling::isActive()) return pixelValue; - return pixelValue / QHighDpiScaling::factor(window); - -} - - //##### ????? -template -T fromNativePixels(const T &pixelValue, const QScreen *screen) -{ - if (!QHighDpiScaling::isActive()) - return pixelValue; - - return pixelValue / QHighDpiScaling::factor(screen); + return pixelValue / QHighDpiScaling::factor(context); } // Any T that has operator*() -template -T toNativePixels(const T &pointValue, const QWindow *window) +template +T toNativePixels(const T &pointValue, const C *context) { if (!QHighDpiScaling::isActive()) return pointValue; - return pointValue * QHighDpiScaling::factor(window); + return pointValue * QHighDpiScaling::factor(context); } -template -T toNativePixels(const T &pointValue, const QScreen *screen) -{ - if (!QHighDpiScaling::isActive()) - return pointValue; - - return pointValue * QHighDpiScaling::factor(screen); -} - - // Any QVector where T has operator/() template QVector fromNativePixels(const QVector &pixelValues, const QWindow *window) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 277d976dde7..f906f808d82 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -471,6 +471,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick); case QPlatformTheme::UiEffects: return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects); + case QPlatformTheme::ShowShortcutsInContextMenus: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus); default: return QPlatformTheme::defaultThemeHint(hint); } @@ -521,7 +523,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) case QPlatformTheme::StyleNames: return QVariant(QStringList()); case QPlatformTheme::ShowShortcutsInContextMenus: - return QVariant(false); + return QVariant(true); case TextCursorWidth: return QVariant(1); case DropShadow: diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 562289a8c96..4e957513977 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -705,14 +705,20 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, w, defaultWidth, defaultHeight); return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor)); } - const QScreen *screen = effectiveScreen(w); + const auto *wp = qt_window_private(const_cast(w)); + const bool position = wp->positionAutomatic && w->type() != Qt::Popup; + if (!position && !wp->resizeAutomatic) + return initialGeometry; + const QScreen *screen = wp->positionAutomatic + ? effectiveScreen(w) + : QGuiApplication::screenAt(initialGeometry.center()); if (!screen) return initialGeometry; - const auto *wp = qt_window_private(const_cast(w)); + // initialGeometry refers to window's screen QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); if (wp->resizeAutomatic) rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); - if (wp->positionAutomatic && w->type() != Qt::Popup) { + if (position) { const QRect availableGeometry = screen->availableGeometry(); // Center unless the geometry ( + unknown window frame) is too large for the screen). if (rect.height() < (availableGeometry.height() * 8) / 9 diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 500e0fae549..ec4a35087a2 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -434,7 +434,7 @@ public: QImage::Format prepare(QImage *image); - uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y=0); Q_ASSERT(y #include #include #include @@ -410,6 +411,29 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc writer.writeEndElement(); // list-item } +static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, qreal *width, qreal *height) +{ + QImageReader reader(device); + const QByteArray format = reader.format().toLower(); + if (format == "png") { + *mimeType = QStringLiteral("image/png"); + } else if (format == "jpg") { + *mimeType = QStringLiteral("image/jpg"); + } else if (format == "svg") { + *mimeType = QStringLiteral("image/svg+xml"); + } else { + *image = reader.read(); + return false; + } + + const QSize size = reader.size(); + + *width = size.width(); + *height = size.height(); + + return true; +} + void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const { writer.writeStartElement(drawNS, QString::fromLatin1("frame")); @@ -420,47 +444,73 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF QTextImageFormat imageFormat = fragment.charFormat().toImageFormat(); writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name()); + QByteArray data; + QString mimeType; + qreal width = 0; + qreal height = 0; + QImage image; QString name = imageFormat.name(); if (name.startsWith(QLatin1String(":/"))) // auto-detect resources name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); - const QVariant data = m_document->resource(QTextDocument::ImageResource, url); - if (data.type() == QVariant::Image) { - image = qvariant_cast(data); - } else if (data.type() == QVariant::ByteArray) { - image.loadFromData(data.toByteArray()); - } + const QVariant variant = m_document->resource(QTextDocument::ImageResource, url); + if (variant.type() == QVariant::Image) { + image = qvariant_cast(variant); + } else if (variant.type() == QVariant::ByteArray) { + data = variant.toByteArray(); - if (image.isNull()) { - if (image.isNull()) { // try direct loading - name = imageFormat.name(); // remove qrc:/ prefix again - image.load(name); + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + probeImageData(&buffer, &image, &mimeType, &width, &height); + } else { + // try direct loading + QFile file(imageFormat.name()); + if (file.open(QIODevice::ReadOnly) && !probeImageData(&file, &image, &mimeType, &width, &height)) { + file.seek(0); + data = file.readAll(); } } if (! image.isNull()) { QBuffer imageBytes; - QString filename = m_strategy->createUniqueImageName(); + int imgQuality = imageFormat.quality(); if (imgQuality >= 100 || imgQuality < 0 || image.hasAlphaChannel()) { QImageWriter imageWriter(&imageBytes, "png"); imageWriter.write(image); - m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data()); + + data = imageBytes.data(); + mimeType = QStringLiteral("image/png"); } else { // Write images without alpha channel as jpg with quality set by QTextImageFormat QImageWriter imageWriter(&imageBytes, "jpg"); imageWriter.setQuality(imgQuality); imageWriter.write(image); - m_strategy->addFile(filename, QString::fromLatin1("image/jpg"), imageBytes.data()); + + data = imageBytes.data(); + mimeType = QStringLiteral("image/jpg"); } - // get the width/height from the format. - qreal width = imageFormat.hasProperty(QTextFormat::ImageWidth) - ? imageFormat.width() : image.width(); + + width = image.width(); + height = image.height(); + } + + if (!data.isEmpty()) { + if (imageFormat.hasProperty(QTextFormat::ImageWidth)) { + width = imageFormat.width(); + } + if (imageFormat.hasProperty(QTextFormat::ImageHeight)) { + height = imageFormat.height(); + } + + QString filename = m_strategy->createUniqueImageName(); + + m_strategy->addFile(filename, mimeType, data); + writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width)); - qreal height = imageFormat.hasProperty(QTextFormat::ImageHeight) - ? imageFormat.height() : image.height(); writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height)); + writer.writeAttribute(textNS, QStringLiteral("anchor-type"), QStringLiteral("as-char")); writer.writeStartElement(drawNS, QString::fromLatin1("image")); writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename); writer.writeEndElement(); // image diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index bb6ef077412..9f8a42ad892 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -235,7 +235,7 @@ void QNetworkReplyWasmImpl::close() void QNetworkReplyWasmImpl::abort() { Q_D(const QNetworkReplyWasmImpl); - setError( QNetworkReply::OperationCanceledError, "Operation canceled" ); + setError( QNetworkReply::OperationCanceledError, QStringLiteral("Operation canceled")); d->doAbort(); close(); @@ -328,8 +328,6 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() m_xhr = val::global("XMLHttpRequest").new_(); std::string verb = q->methodName().toStdString(); - QString extraDataString; - m_xhr.call("open", verb, request.url().toString().toStdString()); m_xhr.set("onerror", val::module_property("qt_QNetworkReplyWasmImplPrivate_requestErrorCallback")); @@ -348,30 +346,12 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() if (outgoingData) // data from post request extraData = outgoingData->readAll(); - if (contentType.contains("text") || - contentType.contains("json") || - contentType.contains("form")) { - if (extraData.size() > 0) - extraDataString.fromUtf8(extraData); - } - if (contentType.contains("json")) { - if (!extraDataString.isEmpty()) { - m_xhr.set("responseType", val("json")); - dataToSend = val(extraDataString.toStdString()); - } - } else if (contentType.contains("form")) { //construct form data - if (!extraDataString.isEmpty()) { - val formData = val::global("FormData").new_(); - QStringList formList = extraDataString.split('&'); - - for (auto formEntry : formList) { - formData.call("append", formEntry.split('=')[0].toStdString(), formEntry.split('=')[1].toStdString()); - } - dataToSend = formData; - } - } else { - m_xhr.set("responseType", val("blob")); + if (!extraData.isEmpty()) { + dataToSend = val(typed_memory_view(extraData.size(), + reinterpret_cast + (extraData.constData()))); } + m_xhr.set("responseType", val("blob")); // set request headers for (auto header : request.rawHeaderList()) { m_xhr.call("setRequestHeader", header.toStdString(), request.rawHeader(header).toStdString()); diff --git a/src/openglextensions/qopenglextensions.h b/src/openglextensions/qopenglextensions.h index 59dbdd4f12f..439e0e6530a 100644 --- a/src/openglextensions/qopenglextensions.h +++ b/src/openglextensions/qopenglextensions.h @@ -66,10 +66,10 @@ #include -class QOpenGLContext; - QT_BEGIN_NAMESPACE +class QOpenGLContext; + #if 0 // silence syncqt warnings #pragma qt_class(QOpenGLExtensions) diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index f425e34b393..76e9c8712c9 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -435,8 +435,23 @@ QList QMacPasteboardMimeUnicodeText::convertFromMime(const QString & if (flavor == QLatin1String("public.utf8-plain-text")) ret.append(string.toUtf8()); #if QT_CONFIG(textcodec) - else if (flavor == QLatin1String("public.utf16-plain-text")) - ret.append(QTextCodec::codecForName("UTF-16")->fromUnicode(string)); + else if (flavor == QLatin1String("public.utf16-plain-text")) { + QTextCodec::ConverterState state; +#if defined(Q_OS_MACOS) + // Some applications such as Microsoft Excel, don't deal well with + // a BOM present, so we follow the traditional approach of Qt on + // macOS to not generate public.utf16-plain-text with a BOM. + state.flags = QTextCodec::IgnoreHeader; +#else + // Whereas iOS applications will fail to paste if we do _not_ + // include a BOM in the public.utf16-plain-text content, most + // likely due to converting the data using NSUTF16StringEncoding + // which assumes big-endian byte order if there is no BOM. + state.flags = QTextCodec::DefaultConversion; +#endif + ret.append(QTextCodec::codecForName("UTF-16")->fromUnicode( + string.constData(), string.length(), &state)); + } #endif return ret; } diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 40db7dbac78..99666bcec6d 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -984,7 +984,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, || matrix.xy != 0 || matrix.yx != 0; - if (transform || (format != Format_Mono && !isScalableBitmap())) + if (transform || obliquen || (format != Format_Mono && !isScalableBitmap())) load_flags |= FT_LOAD_NO_BITMAP; FT_Error err = FT_Load_Glyph(face, glyph, load_flags); diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 5838c43ecaa..8cc7a539b55 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -581,10 +581,16 @@ void QKmsDevice::createScreens() #if QT_CONFIG(drm_atomic) // check atomic support - m_has_atomic_support = !drmSetClientCap(m_dri_fd, DRM_CLIENT_CAP_ATOMIC, 1) - && qEnvironmentVariableIntValue("QT_QPA_EGLFS_KMS_ATOMIC"); - if (m_has_atomic_support) - qCDebug(qLcKmsDebug) << "Atomic Support found"; + m_has_atomic_support = !drmSetClientCap(m_dri_fd, DRM_CLIENT_CAP_ATOMIC, 1); + if (m_has_atomic_support) { + qCDebug(qLcKmsDebug, "Atomic reported as supported"); + if (qEnvironmentVariableIntValue("QT_QPA_EGLFS_KMS_ATOMIC")) { + qCDebug(qLcKmsDebug, "Atomic enabled"); + } else { + qCDebug(qLcKmsDebug, "Atomic disabled"); + m_has_atomic_support = false; + } + } #endif drmModeResPtr resources = drmModeGetResources(m_dri_fd); diff --git a/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/src/platformsupport/linuxaccessibility/dbusconnection.cpp index 3e2248a0187..cacbfdae9f0 100644 --- a/src/platformsupport/linuxaccessibility/dbusconnection.cpp +++ b/src/platformsupport/linuxaccessibility/dbusconnection.cpp @@ -71,6 +71,10 @@ DBusConnection::DBusConnection(QObject *parent) { // Start monitoring if "org.a11y.Bus" is registered as DBus service. QDBusConnection c = QDBusConnection::sessionBus(); + if (!c.isConnected()) { + return; + } + dbusWatcher = new QDBusServiceWatcher(A11Y_SERVICE, c, QDBusServiceWatcher::WatchForRegistration, this); connect(dbusWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered())); diff --git a/src/platformsupport/windowsuiautomation/uiaserverinterfaces_p.h b/src/platformsupport/windowsuiautomation/uiaserverinterfaces_p.h index 64c54c694a6..fd39b6ee339 100644 --- a/src/platformsupport/windowsuiautomation/uiaserverinterfaces_p.h +++ b/src/platformsupport/windowsuiautomation/uiaserverinterfaces_p.h @@ -360,4 +360,27 @@ __CRT_UUID_DECL(IGridItemProvider, 0xd02541f1, 0xfb81, 0x4d64, 0xae,0x32, 0xf5,0 #endif #endif + +#ifndef __IWindowProvider_INTERFACE_DEFINED__ +#define __IWindowProvider_INTERFACE_DEFINED__ +DEFINE_GUID(IID_IWindowProvider, 0x987df77b, 0xdb06, 0x4d77, 0x8f,0x8a, 0x86,0xa9,0xc3,0xbb,0x90,0xb9); +MIDL_INTERFACE("987df77b-db06-4d77-8f8a-86a9c3bb90b9") +IWindowProvider : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE SetVisualState(enum WindowVisualState state) = 0; + virtual HRESULT STDMETHODCALLTYPE Close( void) = 0; + virtual HRESULT STDMETHODCALLTYPE WaitForInputIdle(int milliseconds, __RPC__out BOOL *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_CanMaximize(__RPC__out BOOL *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_CanMinimize(__RPC__out BOOL *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_IsModal(__RPC__out BOOL *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_WindowVisualState(__RPC__out enum WindowVisualState *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_WindowInteractionState(__RPC__out enum WindowInteractionState *pRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_IsTopmost(__RPC__out BOOL *pRetVal) = 0; +}; +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IWindowProvider, 0x987df77b, 0xdb06, 0x4d77, 0x8f,0x8a, 0x86,0xa9,0xc3,0xbb,0x90,0xb9) +#endif +#endif + #endif diff --git a/src/platformsupport/windowsuiautomation/uiatypes_p.h b/src/platformsupport/windowsuiautomation/uiatypes_p.h index ea58417943f..8ef71843a3e 100644 --- a/src/platformsupport/windowsuiautomation/uiatypes_p.h +++ b/src/platformsupport/windowsuiautomation/uiatypes_p.h @@ -141,6 +141,20 @@ enum PropertyConditionFlags { PropertyConditionFlags_IgnoreCase = 1 }; +enum WindowVisualState { + WindowVisualState_Normal = 0, + WindowVisualState_Maximized = 1, + WindowVisualState_Minimized = 2 +}; + +enum WindowInteractionState { + WindowInteractionState_Running = 0, + WindowInteractionState_Closing = 1, + WindowInteractionState_ReadyForUserInteraction = 2, + WindowInteractionState_BlockedByModalWindow = 3, + WindowInteractionState_NotResponding = 4 +}; + struct UiaRect { double left; double top; diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 07a6b52dbee..db40c30d7d3 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -1129,46 +1129,63 @@ QString QAndroidInputContext::getSelectedText(jint /*flags*/) QString QAndroidInputContext::getTextAfterCursor(jint length, jint /*flags*/) { - //### the preedit text could theoretically be after the cursor - QVariant textAfter = QInputMethod::queryFocusObject(Qt::ImTextAfterCursor, QVariant(length)); - if (textAfter.isValid()) { - return textAfter.toString().left(length); - } - - //compatibility code for old controls that do not implement the new API - QSharedPointer query = focusObjectInputMethodQuery(); - if (query.isNull()) + if (length <= 0) return QString(); - QString text = query->value(Qt::ImSurroundingText).toString(); - if (!text.length()) - return text; + QString text; - int cursorPos = query->value(Qt::ImCursorPosition).toInt(); - return text.mid(cursorPos, length); + QVariant reportedTextAfter = QInputMethod::queryFocusObject(Qt::ImTextAfterCursor, length); + if (reportedTextAfter.isValid()) { + text = reportedTextAfter.toString(); + } else { + // Compatibility code for old controls that do not implement the new API + QSharedPointer query = + focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImSurroundingText); + if (query) { + const int cursorPos = query->value(Qt::ImCursorPosition).toInt(); + text = query->value(Qt::ImSurroundingText).toString().mid(cursorPos); + } + } + + // Controls do not report preedit text, so we have to add it + if (!m_composingText.isEmpty()) { + const int cursorPosInsidePreedit = m_composingCursor - m_composingTextStart; + text = m_composingText.midRef(cursorPosInsidePreedit) + text; + } + + text.truncate(length); + return text; } QString QAndroidInputContext::getTextBeforeCursor(jint length, jint /*flags*/) { - QVariant textBefore = QInputMethod::queryFocusObject(Qt::ImTextBeforeCursor, QVariant(length)); - if (textBefore.isValid()) - return textBefore.toString().rightRef(length) + m_composingText; - - //compatibility code for old controls that do not implement the new API - QSharedPointer query = focusObjectInputMethodQuery(); - if (query.isNull()) + if (length <= 0) return QString(); - int cursorPos = query->value(Qt::ImCursorPosition).toInt(); - QString text = query->value(Qt::ImSurroundingText).toString(); - if (!text.length()) - return text; + QString text; - //### the preedit text does not need to be immediately before the cursor - if (cursorPos <= length) - return text.leftRef(cursorPos) + m_composingText; - else - return text.midRef(cursorPos - length, length) + m_composingText; + QVariant reportedTextBefore = QInputMethod::queryFocusObject(Qt::ImTextBeforeCursor, length); + if (reportedTextBefore.isValid()) { + text = reportedTextBefore.toString(); + } else { + // Compatibility code for old controls that do not implement the new API + QSharedPointer query = + focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImSurroundingText); + if (query) { + const int cursorPos = query->value(Qt::ImCursorPosition).toInt(); + text = query->value(Qt::ImSurroundingText).toString().left(cursorPos); + } + } + + // Controls do not report preedit text, so we have to add it + if (!m_composingText.isEmpty()) { + const int cursorPosInsidePreedit = m_composingCursor - m_composingTextStart; + text += m_composingText.leftRef(cursorPosInsidePreedit); + } + + if (text.length() > length) + text = text.right(length); + return text; } /* @@ -1231,6 +1248,8 @@ jboolean QAndroidInputContext::setComposingRegion(jint start, jint end) if (query.isNull()) return JNI_FALSE; + if (start == end) + return JNI_TRUE; if (start > end) qSwap(start, end); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 1d35d9f440f..300082d6941 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -403,8 +403,13 @@ QCocoaServices *QCocoaIntegration::services() const QVariant QCocoaIntegration::styleHint(StyleHint hint) const { - if (hint == QPlatformIntegration::FontSmoothingGamma) + switch (hint) { + case FontSmoothingGamma: return QCoreTextFontEngine::fontSmoothingGamma(); + case ShowShortcutsInContextMenus: + return QVariant(false); + default: break; + } return QPlatformIntegration::styleHint(hint); } diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index ba6cfca2199..358a6b49fd1 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -489,19 +489,16 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const QMacInternalPasteboardMime *c = mimes.at(mime); QString c_flavor = c->flavorFor(format); if (!c_flavor.isEmpty()) { - // Handle text/plain a little differently. Try handling Unicode first. - bool checkForUtf16 = (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text") - || c_flavor == QLatin1String("public.utf8-plain-text")); - if (checkForUtf16 || c_flavor == QLatin1String("public.utf16-plain-text")) { - // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped - // correctly (as '\n') in this data. The 'public.utf16-plain-text' type - // usually maps newlines to '\r' instead. + // Converting via PasteboardCopyItemFlavorData below will for some UITs result + // in newlines mapping to '\r' instead of '\n'. To work around this we shortcut + // the conversion via NSPasteboard's NSStringPboardType if possible. + if (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text") + || c_flavor == QLatin1String("public.utf8-plain-text") + || c_flavor == QLatin1String("public.utf16-plain-text")) { QString str = qt_mac_get_pasteboardString(paste); if (!str.isEmpty()) return str; } - if (checkForUtf16 && hasFlavor(QLatin1String("public.utf16-plain-text"))) - c_flavor = QLatin1String("public.utf16-plain-text"); QVariant ret; QList retList; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp index 738c30c65a5..b8f04cf978f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp @@ -221,7 +221,7 @@ EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow QSurfaceFormat QEglFSOpenWFDIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const { - QSurfaceFormat format; + QSurfaceFormat format = inputFormat; format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index e5419b1766d..0561a826c64 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -834,9 +834,14 @@ static void executeBlockWithoutAnimation(Block block) - (void)updateSelection { if (!hasSelection()) { - _cursorLayer.visible = NO; - _anchorLayer.visible = NO; - QIOSTextInputOverlay::s_editMenu.visible = NO; + if (_cursorLayer.visible) { + _cursorLayer.visible = NO; + _anchorLayer.visible = NO; + // Only hide the edit menu if we had a selection from before, since + // the edit menu can also be used for other purposes by others (in + // which case we try our best not to interfere). + QIOSTextInputOverlay::s_editMenu.visible = NO; + } return; } diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 150783e193c..31b9104de13 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -180,6 +181,18 @@ QPlatformOpenGLContext *QWasmIntegration::createPlatformOpenGLContext(QOpenGLCon } #endif +void QWasmIntegration::initialize() +{ + QString icStr = QPlatformInputContextFactory::requested(); + if (!icStr.isNull()) + m_inputContext.reset(QPlatformInputContextFactory::create(icStr)); +} + +QPlatformInputContext *QWasmIntegration::inputContext() const +{ + return m_inputContext.data(); +} + QPlatformFontDatabase *QWasmIntegration::fontDatabase() const { if (m_fontDb == nullptr) diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 6bd2f857db4..c04c0eaecc3 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -34,6 +34,7 @@ #include #include +#include #include @@ -73,6 +74,9 @@ public: QPlatformTheme *createPlatformTheme(const QString &name) const override; QPlatformServices *services() const override; QPlatformClipboard *clipboard() const override; + void initialize() override; + QPlatformInputContext *inputContext() const override; + QWasmClipboard *getWasmClipboard() { return m_clipboard; } static QWasmIntegration *get() { return s_instance; } @@ -91,6 +95,7 @@ private: QHash m_screens; mutable QWasmClipboard *m_clipboard; qreal m_fontDpi = -1; + mutable QScopedPointer m_inputContext; static QWasmIntegration *s_instance; }; diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index ae43e2ebf0a..1658f32f9eb 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -37,6 +37,14 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format) : m_requestedFormat(format) { m_requestedFormat.setRenderableType(QSurfaceFormat::OpenGLES); + + // if we set one, we need to set the other as well since in webgl, these are tied together + if (format.depthBufferSize() < 0 && format.stencilBufferSize() > 0) + m_requestedFormat.setDepthBufferSize(16); + + if (format.stencilBufferSize() < 0 && format.depthBufferSize() > 0) + m_requestedFormat.setStencilBufferSize(8); + } QWasmOpenGLContext::~QWasmOpenGLContext() @@ -91,10 +99,14 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.majorVersion = 2; } + // WebGL doesn't allow separate attach buffers to STENCIL_ATTACHMENT and DEPTH_ATTACHMENT + // we need both or none + bool useDepthStencil = (format.depthBufferSize() > 0 || format.stencilBufferSize() > 0); + // WebGL offers enable/disable control but not size control for these attributes.alpha = format.alphaBufferSize() > 0; - attributes.depth = format.depthBufferSize() > 0; - attributes.stencil = format.stencilBufferSize() > 0; + attributes.depth = useDepthStencil; + attributes.stencil = useDepthStencil; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes); diff --git a/src/plugins/platforms/wasm/wasm_shell.html b/src/plugins/platforms/wasm/wasm_shell.html index f7c856d63d9..a118c217f3c 100644 --- a/src/plugins/platforms/wasm/wasm_shell.html +++ b/src/plugins/platforms/wasm/wasm_shell.html @@ -3,7 +3,7 @@ - APPNAME + @APPNAME@