Commit Graph

2039 Commits

Author SHA1 Message Date
Eirik Aavitsland
bfc09b8d8f Avoid overflow in text layout
Fixes oss-fuzz issue 29313.

Pick-to: 6.0 5.15
Change-Id: Idbabd162fa9e0dbce687981bdbcc75be37189a61
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-01-28 11:02:18 +01:00
Samuli Piippo
07c248a594 Remove blacklisting for b2qt tests that now pass
With the updated QEMU and toolchain, these tests now pass.

Change-Id: Icb74562a0e6422cd4564f63db991aa431e0e3119
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-01-28 09:27:14 +02:00
Sona Kurazyan
3a5a404a53 Port QMovie to the new property system
Task-number: QTBUG-85520
Task-number: QTBUG-85521
Change-Id: Ib936020260cf01a5221b63fb1eb0ccb23f5553a3
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-27 15:16:20 +01:00
Sona Kurazyan
ba62256c5a Port QStandardItemModel to the new property system
Task-number: QTBUG-85520
Task-number: QTBUG-85521
Change-Id: I2f9bbe8bc06838fcbadd446e111fb697120f550c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-26 21:48:00 +01:00
Bastien Bouclet
b69b04c479 QIcon: Use the @nx pixmaps in the paint method
Make use of the device pixel ratio in the QIcon paint method so the @nx
hi-dpi pixmaps are selected when appropriate when painting to a
QPainter.

Pick-to: 6.0
Fixes: QTBUG-90042
Change-Id: I53995a2285ef879e3c4fddb9f8da702e256a260f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-26 15:33:08 +00:00
Morten Johan Sørvig
3a1773dd76 High-DPI: Test application startup with no screens
Initialize the offscreen platform plugin with no screens,
create QGuiApplication object.

Not much of the high-dpi related Qt API can be used
in this configuration, but at least Qt should not crash
on startup.

Task-number: QTBUG-71034
Change-Id: I6620843c3bd8b692c5c2419b1ba290e16175ba5b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-01-22 14:27:27 +00:00
Laszlo Agocs
df0e98d408 rhi: Pipeline cache load/save
Add QRhi APIs to retrieve and reload the contents of the "pipeline
cache".

The only API where there is a true pipeline cache is object is Vulkan
(VkPipelineCache). For OpenGL, the other backend where we support this,
it is simulated with program binaries. The Qt 5 style OpenGL program
binary disk cache continues to work like before, but one has now the
option to do things in a more modern, graphics API agnostic way, that
leads to generating a single blob instead of a large set of files in
some system location, allowing easier "pre-baking" of the cache content.

It is expected that Qt Quick exposes the two new functions in form
if QSG_RHI_ environment variables, thus allowing easy testing and
cache file generation.

As an example for the performance improvements this can give, consider
Vulkan, where we do not have any existing persistent caching mechanism
in place:

Running BenchmarkDemoQt6.exe --scene flythrough --mode demo creates 18
QRhiGraphicsPipeline objects from Qt Quick and Qt Quick 3D.

The total time spent in QRhiGraphicsPipeline::create() during application
startup for these 18 pipelines is 35-40 ms on a given Windows (NVIDIA)
system.

When exporting the pipeline cache contents to a file, and then, in a
subsequent run, reloading the cache contents, this is reduced to 5-7 ms
on the same system, meaning we get a 6-7x improvement.

The generated data is always specific to a given Qt version, RHI
backend, graphics device, and driver version. Much of the implementation
consists of adding and verifying the appropriate header to the blobs
retrieved from the driver, to allow gracefully ignoring data that was
generated with a device or driver that differs from the one used at
run time. This should provide robustness, even if the Vulkan or OpenGL
implementation is for some reason not prepared to identity and reject
incompatible cache/program blobs.

Fixes: QTBUG-90398
Change-Id: I67b197f393562434f372c7b7377f638abab85cb3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-22 10:26:03 +01:00
Samuli Piippo
946facb1ae tst_qfont: expect failure on font testcase for QEMU ARMv7
FontConfig related tests fail on ARMv7 QEMU.

Task-number: QTQAINFRA-4127
Change-Id: I3202f660d12d09a65bc50747d679921b6dfa75f8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-01-22 09:00:24 +02:00
Laszlo Agocs
46b892c16c tst_qvulkan: Skip assumption about supportedApiVersion
...when the platform does not support Vulkan. The version is left
at the default 0 then, so checking for >= 1.0 is wrong.

This allows the test to pass with the offscreen platform plugin.

Change-Id: I5afba8f1e703e4fa0ff41da91d18f5fabfb54868
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-21 17:00:32 +01:00
Laszlo Agocs
c6d6029909 Update QVulkan(Device)Functions to Vulkan 1.2
This also needs improvements to qvkgen. What we get with this patch
are the Vulkan 1.1 and 1.2 core API's additional 11 instance-level
and 30 device-level commands present in QVulkanFunctions and
QVulkanDeviceFunctions.

All of these are attempted to be resolved upon construction. When the
implementation does not return a valid function pointer for some of them
(e.g. because it is a Vulkan 1.0 instance or physical device), calling
the corresponding wrapper functions will lead to unspecified behavior.
This is in line with how QOpenGLExtraFunctions works. The simple
autotest added to exercise some Vulkan 1.1 APIs demonstrates this in
action.

The member functions in the generated qvulkan(device)functions header
and source files are ifdefed by VK_VERSION_1_{0,1,2}. This is essential
because otherwise a Qt build made on a system with Vulkan 1.2
headers would cause compilation breaks in application build environments
with Vulkan 1.0/1.1 headers when including qvulkanfunctions.h (due to
missing the 1.1/1.2 types and constants, some of which are used in the
function prototypes). In practice this should be alright - the only
caveat to keep in mind is that the Qt builds meant to be distributed
to a wide variety of systems need to be made with a sufficiently new
version of the Vulkan headers installed, just to ensure that the
1.1 and 1.2 wrapper functions are compiled into the Qt libraries.

Task-number: QTBUG-90219
Change-Id: I48360a8a2e915d2709fe82993f65e99b2ccd5d53
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-19 14:17:55 +01:00
Laszlo Agocs
9f7088fd7f rhi: Stop hardcoding the Vulkan backend's desired instance extensions
Instead, have a static function in QRhiVulkanInitParams then Qt Quick
and anyone else who creates a QVulkanInstance that is then used in
combination with QRhi can query.

Change-Id: I046e0d84541fc00f5487a7527c97be262221527f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
7d378bd780 vulkan: Add instance-level version getter
...as described in the Vulkan >= 1.1 spec. One can now call
supportedApiVersion() (before create(), similarly to the other
supported* functions) to determine the available Vulkan
(instance-level) version.

Fixes: QTBUG-90333
Change-Id: Ibe8482402b7f07e4abc48c88252ff0365e4e2faa
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Shawn Rutledge
aeeac48cbd AA_SynthesizeTouchForUnhandledMouseEvents: keep correct coordinates
QGuiApplicationPrivate::processMouseEvent() sends a
QWindowSystemInterfacePrivate::TouchEvent if the mouse event is not
accepted and AA_SynthesizeTouchForUnhandledMouseEvents is enabled.
A QPA TouchEvent always contains native touch points, which is why
it calls QWindowSystemInterfacePrivate::fromNativeTouchPoints to
translate the QMouseEvent's device-independent position back to the
raw position that it would have had if it came from a real touchscreen.
Therefore we must give that function touchpoints that are actually in
native coordinates.

It may be that some of this transformation could be avoided entirely,
but here we prove that the existing way works correctly, by adding
coordinate checking to the tst_QWindow::mouseToTouchTranslation() test.

Pick-to: 6.0
Task-number: QTBUG-86165
Change-Id: I4c9ca2b11e9eb76d79712c187db3eb9865da581a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-14 19:09:28 +00:00
Morten Johan Sørvig
a2db96e253 Skip tst_qhighdpi when offscreen is not built
Android and Wasm do not build the offscreen platform
plugin (see src/plugins/platforms/CMakeLists.txt).

Skip building the tst_qhighdpi test as well in this
case. Remove the BLACKLIST entry.

Task-number: QTBUG-88505
Change-Id: I172198c8c24759b14f73ad07260c449fc6ab893f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-14 14:21:45 +01:00
Laszlo Agocs
c262a69851 rhi: gl: Add some enablers for supporting GL_TEXTURE_EXTERNAL_OES
From QRhi's perspective this consists of two things:

- A shader with samplerExternalOES in it cannot go through the standard
  pipeline. Rather, a QShader with suitable GLSL code in it has to be
  constructed manually. As this is something useful as an autotest
  anyway, add a test case to the qshader autotest that demonstrates
  this.

- When it comes to correctly calling glBindTexture, add a QRhiTexture
  flag. The expectation is that an OpenGL-only client sets this in
  combination with QRhiTexture::createFrom(), thus wrapping an existing
  texture that then gets bound to the GL_TEXTURE_EXTERNAL_OES target
  instead of our usual GL_TEXTURE_2D.

For completeness we also add a SamplerExternalOES variable type to
QShaderDescription, but the sampler type is not actually used by the
QRhi OpenGL backend, as it is the QRhiTexture that defines the
texture target.

Change-Id: I36b52325deb3703b59186ee3d726d0c3015bfc4b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Laszlo Agocs
042cd97884 rhi: Expose device name, type, and IDs
...to the extent it is sensible. We have to make compromises still,
meaning some fields will only be applicable with certain APIs.

Most of this is already shown upon QRhi::create() as info debug
prints, when enabled. Now expose it all through the QRhi API as
well.

This is useful for printing in qtdiag, and, while it should be
avoided as much as possible, to make decisions about disabling
3D rendering features depending on the driver and GPU in use.

Change-Id: Iebe1e192965c928b82a094d1c7c50ddf4b38b9a2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Joerg Bornemann
04f11f9935 Remove .prev_CMakeLists.txt files
Those serve no purpose anymore, now that the .pro files are gone.

Task-number: QTBUG-88742
Change-Id: I39943327b8c9871785b58e9973e4e7602371793e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-12 20:59:13 +01:00
Alexander Volkov
376e3bd8ec Introduce QUrlResourceProvider to load resources for HTML
QTextDocument and the text editor classes suggest to override
their loadResource() methods to provide data associated with
a text document. This approach has the following drawbacks:
- it requires subclassing
- there is no way to set a global resource provider
- QLabel is missing virtual loadResource() method and
  it can't be added without breaking ABI

QUrlResourceProvider is designed to solve these issues.
One should create a derived class that implements
QUrlResourceProvider::resource(). The objects of the derived
class then can be set for any text document.
The default resource provider can be set with
QUrlResourceProvider::setDefaultProvider().
This change also adds QLabel::setResourceProvider(),
which doesn't break ABI.

[ChangeLog][QtGui][Text] Introduced QUrlResourceProvider that allows to
load resources for HTML. It is intended to replace the use of
QTextDocument::loadResource().

Change-Id: Iaf19b229f522a73508f20715257450fe58f68daf
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-12 15:33:10 +03:00
Volker Hilsheimer
9963aaacdb Remove irrelevant test row, fix compiler warning
With the introduction of QKeyCombination, the result of |'ing together
a set of modifiers and a key goes always through the same QKeySequence
constructor, no matter the order.

The implicit conversion through int when the wrong order is used
causes a compiler warning as that conversion is deprecated. So remove
that test case.

Pick-to: 6.0
Change-Id: I04e27bcd51723ee0efc77e52e45ca3eb8bac5fc7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-01-08 16:37:22 +01:00
Samuli Piippo
18ef1b83fb tst_qtextmarkdown: blacklist tests for QEMU ARMv7
Most tests fail when running on QEMU ARMv7, but not on target HW or
QEMU ARM64.

Task-number: QTBUG-89819
Change-Id: I686268c200cce1a44a717b80c2970f608be44636
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-01-08 09:04:55 +02:00
Joerg Bornemann
ad2da2d27a Remove the qmake project files
Remove the qmake project files for most of Qt.

Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.

Also leave the qmake project files for utils and other minor parts that
lack CMake project files.

Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-07 15:32:28 +01:00
Liang Qi
e688b99995 QInputControl: accept surrogate category character
See also https://unicodebook.readthedocs.io/unicode_encodings.html#utf-16-surrogate-pairs .

Fixes: QTBUG-89184
Pick-to: 6.0 5.15
Change-Id: I04eff7f42f0030346603a7b31e4ac854a477030c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-05 16:24:29 +01:00
Laszlo Agocs
8da171a5ae Adjust surface type usage for onscreen tests in tst_qrhi
Change-Id: I1ae076f8bb44e00bf9ff7706063344e8c5502101
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:37 +01:00
Liang Qi
489ce6f91b tests: unblacklist tst_QWindow::modalWithChildWindow() on openSUSE
This reverts 3d53cf976d.

Task-number: QTBUG-66851
Change-Id: Ib2b76c539c57fe70ee60426635e6ba59291a1f90
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-23 19:41:42 +00:00
Samuli Piippo
d6c3d6355a qfont: blacklist tests for QEMU
Blacklist qfont tests that don't work correctly with qemu.

Task-number: QTQAINFRA-3836
Change-Id: I7f5d4b07428febb0adb82d38203226b5c56a2ad5
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-23 10:55:56 +02:00
David Skoland
27d96b4789 Replace QtTest headers with QTest
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.

Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-22 15:20:30 +01:00
Friedemann Kleint
f6bf303cee tst_qimagereader.cpp: Fix MSVC int conversions warnings
Change-Id: I1b002ffde60dea9c54a8c41985ed295c05c45858
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 16:21:28 +01:00
Friedemann Kleint
a46a723dba Tests: Fix building with qmake on Windows
Apparently some library definitions went overboard, link them directly.

Pick-to: 6.0
Change-Id: I009737f7e3edff5619241b700a627dc4e25e6018
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-17 13:02:15 +01:00
Alexandru Croitor
2304acab5f CMake: Regenerate projects using pro2cmake one last time
And fix up some wrong qmake project files

Pick-to: 6.0
Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-10 11:52:30 +01:00
Allan Sandfeld Jensen
48346e8d2d Add colorspace transfer functions based on tables of inputs
This is the most basic way to represent custom transfer functions.

Change-Id: I529fb647ece82c03e85ef77b056d9daf13fe5a61
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-10 11:03:12 +01:00
Liang Qi
4a85160e0b tests: blacklist tst_QGlyphRun::drawRightToLeft() on openSUSE
Task-number: QTBUG-89169
Change-Id: I4dfd608e264c9503093cc9fe27e80c489efe7aaf
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-08 09:35:21 +01:00
Allan Sandfeld Jensen
0c19e3f703 Fix QImage::setPixelColor on RGBA64_Premultiplied
QColors were not premultiplied before being set.

Pick-to: 6.0 5.15 5.12
Change-Id: Id3765b6932a72374ddfd788fae4bb628a4edf0b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 15:09:47 +01:00
Eskil Abrahamsen Blomfeldt
34fa01be82 Fix tst_QFontDatabase::aliases failure with ambiguous font
If the first font in the families list happens to have been
disambiguated because of duplicates, two things went wrong:

1. hasFamily() would return false for the font family, because
it does not disambiguate when checking for the family name and
only checks if the families list contains the exact string.

2. Adding aliases to the full disambiguated string is not supported,
only the family name.

The first issue has been reported separately as QTBUG-89068.

The test failure is fixed by just avoiding the fonts that
are ambiguous in the test, as it really doesn't matter which
font we pick.

Fixes: QTBUG-89008
Pick-to: 5.15 6.0
Change-Id: I829778c2e7bb6090475c34dcf9cdce58862729d6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-02 16:22:27 +00:00
Andreas Buhr
caa632803d Disable some OpenGL and QRhi tests for offscreen backend
This patch disables four failing unit tests when executed with the
offscreen backend.

Change-Id: Ie67341b886984e6de19cd8dd8a8a237a620a1b7a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-12-01 14:14:45 +01:00
Edward Welbourne
bbe74df26f Use QCOMPARE(,) in preference to QVERIFY(qFuzzyCompare(,))
The former also does fuzzy comparison, but it reports what the values
were, if the test ever fails.

Change-Id: I36ecda1f69bf3f430c904b37cd8c3a23201ab7e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-27 13:26:52 +01:00
Volker Hilsheimer
c2dbc26893 Fix compiler warnings from deprecated method
QTextCharFormat::fontFamily is deprecated in favor of fontFamilies,
which returns a QStringList wrapped in a QVariant, whereas the setter
expects a QStringList.

Change-Id: I3333eaae4fc5ec3e3bdbec58047d6b3554b4a171
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 07:28:24 +00:00
Volker Hilsheimer
63c5d13885 Fix compiler warning from deprecated function
Change-Id: I34d6788fd5b9ab004b0e337933bea90c8f63717a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 08:28:24 +01:00
Volker Hilsheimer
cd2f29891f Fix compiler warning from deprecated function
Make the string into a list and call setFontFamilies.

Pick-to: 6.0
Change-Id: I1b70db784fd6e495b48917141d07bacd1e883882
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-25 22:08:09 +01:00
Andy Shaw
8302ca22f4 Return a QString() if the families list is empty
Fixes: QTBUG-88781
Change-Id: Iafed2be29e2e0c3029e832986ba58d19446214eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-24 21:49:54 +01:00
Volker Hilsheimer
e59ab8b590 Fix compiler warning about discarded return value
Not testing the result of the copying, just verifying that it doesn't
assert.

Pick-to: 6.0
Change-Id: Ib51129134b74c17eada7e3819ccfff10bb9affbf
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-11-23 12:51:41 +01:00
Eskil Abrahamsen Blomfeldt
1d14067680 Fix weight when reading old serialized QFonts
The QFont::fromString() needs to differ between strings
produced before and after Qt 6.0 when interpreting the
weight value, since in older strings this will be the legacy
scale.

Luckily the number of tokens in the string can be used for this
purpose, since many tokens were added in Qt 6.0.

This broke KDE, where font settings are stored in QSettings
and serialized using QFont::toString() from Qt 5.

Fixes: QTBUG-88589
Pick-to: 6.0.0 6.0
Change-Id: I199737fed61917f8b9d8f86176ead29a89eb8e0c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-20 20:29:00 +00:00
Andy Shaw
d8602ce58b QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with
spaces, commas, quotes and so on are correctly handled without being
misinterpreted. For now it will split on the comma when a string
containing one is passed to setFamily. But from Qt 6.2 this will be
removed to preserve the family string as a convenience function.

[ChangeLog][QtGui][QFont] Indicated that setFamilies/families is
preferred over setFamily/family to ensure that font family names are
preserved when spaces, commas and so on are used in the name.

Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-20 14:30:22 +01:00
Kai Koehne
ce29ce586f Revert "Allow QWindowsPipe{Reader,Writer} to work with foreign event loops"
This reverts commit ee122077b0.

Reason for revert: This causes QProcess::readAll() to sometimes
return nothing after the process has ended.

Fixes: QTBUG-88624
Change-Id: I34fa27ae7fb38cc7c3a1e8eb2fdae2a5775584c2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 23100ee61e33680d20f934dcbc96b57e8da29bf9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-20 13:28:31 +00:00
Shawn Rutledge
5509449daf Add tst_QHighDpi::mouseVelocity()
Ensure the values are reasonable regardless of screen DPI.  Velocity
is supposed to be in logical pixels / second.

Task-number: QTBUG-88252
Task-number: QTBUG-88346
Change-Id: Ic209887f8ed0381c033a9ff04ae48b072c444df4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-11-20 10:45:11 +01:00
Allan Sandfeld Jensen
34304e3100 Get rid of Q_COMPILER_CONSTEXPR checks
Is required now.

Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-17 21:28:11 +01:00
Piotr Mikolajczyk
f92e195369 Android: Ensure windows always have a geometry on creation
A QWindow created without an explicit geometry needs to pick up
a default geometry in the platform plugin. If the window has a
maximized of fullscreen window state, it will fill the entire
available geometry of the parent window (or the screen if there's
not parent window).

Fixes: QTBUG-69159
Fixes: QTBUG-69156
Fixes: QTBUG-69154
Pick-to: 5.15
Change-Id: If8565d92a97bb4b3fa44757e68969d54d0bc7ebe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-17 10:48:05 +00:00
Alex Trotsenko
ee122077b0 Allow QWindowsPipe{Reader,Writer} to work with foreign event loops
When a foreign event loop that does not enter an alertable wait state
is running (which is also the case when a native dialog window is
modal), pipe handlers would freeze temporarily due to their APC
callbacks not being invoked.

We address this problem by moving the I/O callbacks to the Windows
thread pool, and only posting completion events to the main loop
from there. That makes the actual I/O completely independent from
any main loop, while the signal delivery works also with foreign
loops (because Qt event delivery uses Windows messages, which foreign
loops typically handle correctly).

As a nice side effect, performance (and in particular scalability)
is improved.

Several other approaches have been tried:
1) Using QWinEventNotifier was about a quarter slower and scaled much
   worse. Additionally, it also required a rather egregious hack to
   handle the (pathological) case of a single thread talking to both
   ends of a QLocalSocket synchronously.
2) Queuing APCs from the thread pool to the main thread and also
   posting wake-up events to its event loop, and handling I/O on the
   main thread; this performed roughly like this solution , but scaled
   half as well, and the separate wake-up path was still deemed hacky.
3) Only posting wake-up events to the main thread from the thread pool,
   and still handling I/O on the main thread; this still performed
   comparably to 2), and the pathological case was not handled at all.
4) Using this approach for reads and that of 3) for writes was slightly
   faster with big amounts of data, but scaled slightly worse, and the
   diverging implementations were deemed not desirable.

Fixes: QTBUG-64443
Change-Id: I1cd87c07db39f3b46a2683ce236d7eb67b5be549
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-11-17 12:45:50 +02:00
Assam Boudjelthia
87fdad35ca Android: exclude failing tests of tst_qhighdpi
Tests in tst_qhighdpi are crashing on Android.

Task-number: QTBUG-88505
Task-number: QTBUG-87025
Change-Id: Ie1350e06fb30d90f20c550f91555f4023eee56b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:46 +02:00
Assam Boudjelthia
ac1cbc752f Android: exclude tests crashing at start
These tests are failing with "java.lang.UnsatisfiedLinkError: dlopen
failed: invalid ELF file" at the start, excluding them now to enable
Android testing until they're fixed later.

Task-number: QTBUG-87671
Task-number: QTBUG-87025
Change-Id: Ida7d7158fccdc31df1f9689f77fde832964d732f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:44 +02:00
Giuseppe D'Angelo
1869615fc9 QChar: make construction from integral explicit
QChar should not be convertible from any integral type except from
char16_t, short and possibly char (since it's a direct superset).

David provided the perfect example:

  if (str == 123) { ~~~ }

compiles, with 123 implicitly converted to QChar (str == "123"
was meant instead). But similarly one can construct other
scenarios where QString(123) gets accidentally used (instead of
QString::number(123)), like QString s; s += 123;.

Add a macro to revert to the implicit constructors, for backwards
compatibility.

The breaks are mostly in tests that "abuse" of integers (arithmetic,
etc.). Maybe it's time for user-defined literals for QChar/QString,
but that is left for another commit.

[ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar
constructors from integral types are now by default explicit.
It is recommended to use explicit conversions, QLatin1Char,
QChar::fromUcs4 instead of implicit conversions. The old behavior
can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION
macro.

Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-15 14:41:05 +01:00
Volker Hilsheimer
e796857abb Stop copying events in tests
It's unnecessary, and copying QEvents is a bad practice since it's a
polymorphic class.

Change-Id: Ieb6de106084f838c5e6c8a0643c54fd3c7f4a7a8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-12 15:25:06 +01:00
Allan Sandfeld Jensen
94dd2cebdc Remove Qt4Compatible painting
Change-Id: Ie54206ca9b509875568f2158e229fca9cb1860a2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-12 08:31:18 +01:00
Eirik Aavitsland
7aa68ee6f2 Fix misidentification of some shearing QTransforms as only rotating
The dot product used rows instead of columns.

Pick-to: 5.15 5.12
Fixes: QTBUG-87984
Change-Id: I922f67ed0fa9a4f88aa4e9fc6d3c09f8dda21688
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-11 12:48:21 +01:00
Allan Sandfeld Jensen
04413b9dd8 Allow painting above INT16_MAX on 64-bit architectures
The logic in qgrayraster was ready for it except for an intermediate
format. qrasterizer.cpp and qcosmeticstroker.cpp uses a dot-16 fixed
point format, and had to be changed to handle higher coordinates on
64-bit architectures.

Fixes: QTBUG-84428
Change-Id: I85ab7a04e38bd0dbcefa9f16c16ccc84785a33cf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-09 14:04:13 +01:00
Morten Johan Sørvig
46a552583f Teach QPixmapIconEngine how to handle @Nx pixmaps
Bring QPixmapIconEngine on par with QIconLoaderEngine
when it comes to @Nx pixmap handling: Make the scale
factor a test parameter during icon lookup.

This allows storing e.g 16x16@1, 16x16@2, 16x16@3 versions
of a pixmap in the icon, and then having QIcon select
the correct one based on the target devicePixelRatio.

Extend the qiconhighdpi test to also cover QPixmapIconEngine,
via the addPixmap() API.

The corner cases of pixmap lookup can be much complicated.
QIconLoaderEngine and QPixmapIconEngine should ideally
have identical behavior in order to avoid surprises.

Change-Id: I17552cc61755bff9553c4a462e3983ac6759c13b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-08 19:49:53 +01:00
Volker Hilsheimer
b14b1c99f8 Rename QRangeCollection to QPageRanges, make it a proper value type
The type is specific about printing, so give it a name in line with
QPageLayout and QPageSize.

As per API review comment, it's not clear why this type should not be a
regular, copyable and movable value type. It stores a list of intervals.
Give it value-type semantics, as an implicitly shared class.

Convert the parse method into a static factory function.

Add a Range type and use it instead of the semantic-free QPair.
Move QPrinter getter into QPagedPainteDevice, make it return a copy
rather than a pointer, and add a setter.

Extend test case to cover all members and more merge cases. Fix bugs
found that way.

Fixes: QTBUG-88113
Change-Id: If17ea4d410d49f16b097e88b7979db5d72add820
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-08 11:49:54 +01:00
Alexandru Croitor
f5b214130a tests: Blacklist tst_qwindow failing test on Windows
Amends b13bad3ab0

Task-number: QTBUG-35109
Task-number: QTBUG-88250
Change-Id: I0b37369bb7cfc58e6968ca20969725e2f4143200
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 19:33:37 +01:00
Shawn Rutledge
f5c7799f59 Support the markdown underline extension
MarkdownDialectGitHub now includes this feature, so *emph* is italicized
and _emph_ is underlined. This is a better fit for QTextDocument capabilities;
until now, _underlined_ markdown could be read, but would be rendered with
italics, because in CommonMark, *emphasis* and _emphasis_ are the same.
But QTextMarkdownWriter already writes underlining and italics distinctly
in this way.

[ChangeLog][QtGui][Text] By default (with MarkdownDialectGitHub), markdown
_underline_ and *italic* text styles are now distinct.

Fixes: QTBUG-84429
Change-Id: Ifc6defa4852abe831949baa4ce28bae5f1a82265
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 09:35:11 +01:00
Shawn Rutledge
9a1a15b42f Introduce QEvent::isSinglePointEvent()
This makes high-level event dispatching easier: for example we often
need to cast an event to access getters like button() and buttons().
We can so far assume that any QPointerEvent that is not a QTouchEvent
is a QSinglePointEvent; but more explicit type-checking looks safer.

Implemented in a similar way as c7f7279969.

Change-Id: I980d759e2a7538b6b30fd3bdc3be0c351ec6c246
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 06:24:38 +01:00
Alexandru Croitor
b13bad3ab0 tests: Blacklist failing tests on MinGW
Also move redudant Android entries to already existing sections.

Task-number: QTBUG-35109
Task-number: QTBUG-88250
Change-Id: I9d5eaa5a3f11b55566a7c74f84a972a0c272cfea
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-06 21:03:51 +00:00
Morten Johan Sørvig
52ce0c177e Set the url to have the AtNx filename if one is found
There’s no need to convert the file name/path to QUrl,
and then back again to QString before calling qt_findAtNxFile().

Call qt_findAtNxFile first, and then convert to QUrl.
This makes sure the url-name and string-name stays
in sync.

Change-Id: I8b8939eabbdaff473945ebe31faafd408e9c4295
Pick-to: 5.15
Fixes: QTBUG-60793
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-06 09:16:30 +00:00
Assam Boudjelthia
039d3fe4e8 Android: blacklist a list of failing tests for android
We want to re-enable Android tests in QTQAINFRA-3867. However,
many tests are failing already preventing that from happening.
QTBUG-87025 is currently keeping track (links) to all of those
failing tests.

The current proposal is to hide those failing tests, and enable
Android test running in COIN for other tests. After, that try
to fix them one by one, and at the same time we can make sure
no more failing tests go unnoticed.

Task-number: QTBUG-87025
Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 12:27:49 +02:00
Shawn Rutledge
f6418343f1 Add QEventPoint::normalizedPosition() to replace normalizedPos()
In 4e400369c0 we deprecated
normalizedPos() because we suspect it's a legacy feature that few
users will need.  However Qt developers keep bringing up the continued
usage in autotests over and over.  (It's IMO not wrong to keep testing
deprecated functions in autotests, but the warning keeps attracting
attention.)

Of course it will turn out that normalizedPos() has users; we just
don't know how many.  One way to look at it is: why should they copy
a snippet of code to calculate it, when it costs us so little to
continue to provide this accessor.

It might also turn out that some users will complain that in Qt 5
it was passed through from the device driver (or at least from the
window system API) to the application, and perhaps the replacement will
not always work, for example if availableVirtualGeometry() ends up
wrong, or there is some strange scenario that generates events that are
out-of-bounds for the device that the event professes to come from, so
that the "normalized" coordinates also go outside the [0..1] range.
We reserve the right to put back the storage in QEventPointPrivate if
the need arises; so that's why this function is not inline.

We continue to hope that startNormalizedPos() and lastNormalizedPos()
are used even less and won't be missed much, because it would be
wasteful to store them all the time if only a few users need them.

Change-Id: I23ed78843e3f9e16133c5b6f462884a3845f91b6
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-03 20:36:35 +01:00
Volker Hilsheimer
a50f0f045d Get rid of all instance usage of QFontDatabase
All QFontDatabase APIs are static, use them accordingly.

Task-number: QTBUG-88114
Change-Id: I0e4a7508646037e6e2812611262eed8b6d7ad3de
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-03 20:36:34 +01:00
David Skoland
56a1a645ac Update tst_qguivariant to use QMetaType
Change-Id: I4c789ecfc9f4613bd4820a8a6530249c51344a83
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-28 22:18:45 +01:00
Lars Knoll
11bad61096 Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.

Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:58:57 +02:00
Lars Knoll
4175175588 Rename the QMetaType::MovableType flag to RelocatableType
Keep this in sync with the changes we have done in QTypeInfo.

Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:49:36 +02:00
Allan Sandfeld Jensen
e356ab2c32 Make QPointer comparisons hidden friends
Reduces ADL noise.

Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-23 09:32:37 +02:00
Shawn Rutledge
0e5bbf3507 Make QEvent::setAccepted() virtual; set QEventPoints state the same
In Qt Quick, when we deliver an item-specific QTouchEvent that contains
only the subset of eventpoints that are inside the Item's bounds,
traditionally the Item can accept the event to tell the delivery logic
that the event is handled and doesn't need to be delivered further.
But an Item cannot be expected to have total scene awareness; so now,
the delivery is "done" only when all eventpoints in the original event
are accepted.  This behavior has been working well enough already due to
logic in QQuickWindow that iterates the points and accepts them if the
event is accepted; but it seems appropriate to move this enforcement
into QPointerEvent itself.  Making setAccepted() virtual gives us a
useful degree of freedom.

Event-handling code should alternatively use QEventPoint:setAccepted()
or QPointerEvent::setExclusiveGrabber() to take resonsibility for only
a subset of the touchpoints.

Another way to put it is that we treat QPointerEvent::setAccepted() as a
convenience method: accepting the QEventPoints is what counts (at least
in Qt Quick).

Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-22 04:54:17 +00:00
Volker Hilsheimer
875a7fad52 Fix a bunch of compiler warnings in event handling test cases
Leave the normalizedPos warnings, there is no equivalent function.

Change-Id: I50c72ab24b4855e36941aafdee30cdb0e94c1684
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-22 02:43:26 +02:00
Piotr Mikolajczyk
a02ea26b46 [Android] Make sure expose events are emitted after window resize
Expose event would not be sent when window was resized

Fixes: QTBUG-69155
Pick-to: 5.15
Change-Id: I81bf2d54f830a0dabf15398e1f25b55ff7ff4479
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2020-10-21 07:08:54 +00:00
Shawn Rutledge
9aba868571 QEvent copy constructor: copy the type flags too
Failure to copy m_inputEvent and m_pointerEvent actually left them
uninitialized, and resulted in random behavior in Qt Quick when
Flickable clones a pointer event for later replay.

Remove the comment about copying events being a "bad idea" in Qt 4,
while we're at it.  Copying became more common in Qt 5, and we
probably won't be able to stop doing it now.

Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:22:36 +02:00
Morten Johan Sørvig
3df2448f63 Merge existing tst_qhighdpiscaling into tst_qhgihdpi
Move the factor() test, drop scale() which should be
covered already.

Change-Id: Id2079536a91c7e9f7199960bdf6b33489d0a6670
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:27:04 +02:00
Morten Johan Sørvig
d023da8639 Add high-dpi auto test
Use the new screen config feature of the offscreen
platform plugin to run tests on virtual screen setup.

This has the benefit that we can auto-test the QHighDpiScaling
implementation (as well as its usage in QtGui) on any platform
with a fixed mock screen setup which does not rely on physical
screen configuration.

Test the following configurations:
   - three screens: 96 DPI. (reference)
   - three screens: 192 DPI
   - three screens: mixed (high) DPI

Change-Id: I2fac889d896cf30ab2a79c306cee22177ad8f4ac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-10-20 07:26:57 +02:00
Volker Hilsheimer
b61d67f897 Fix compile warnings from ignored return value
The return value can be ignored here, so make intention clear.

Change-Id: I116869c47039b159db96f133b5850a2215873c2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-17 08:21:52 +02:00
Allan Sandfeld Jensen
986c09f815 Test QImage move semantics
Tests the move semantics of QImage in Qt6.

Change-Id: Ia4d95f0b88ca7dde0daf85a0f53049b42b5be1a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-16 18:49:01 +02:00
Andy Shaw
bdc9d272ee Fallback to using the family when doing an exact match
If the difference between the families sizes is just 1 where one of them
is 0 in size then we can fallback to the family in that case.

Pick-to: 5.15
Fixes: QTBUG-87267
Change-Id: I62b25b06c88000b4d7defe91871c07873b1fc792
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-12 14:08:06 +02:00
Laszlo Agocs
2189e0f2fc rhi: Make the new direct buffer update available for non-uniform buffers
The original restriction to UniformBuffer was due to the GL backend
where there is no GL buffer object for QRhiBuffers with usage
UniformBuffer. However, we can still implement this for cases when
there is a true GL buffer object underneath. With other backends it
should all work as-is already.

This becomes useful when one has buffers with usage Vertex that need
full updates every frame. (f.ex. instance data)

Unfortunately this involves renaming the function. But while at it, add
an autotest case as well.

Change-Id: Iff59e4509a8bae06654cc92fe8428bd79eb012fb
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-12 07:55:37 +02:00
Allan Sandfeld Jensen
564b59d903 Another round of replacing 0 with nullptr
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.

Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-07 23:02:47 +02:00
Tor Arne Vestbø
0efe79f80d Rename the new platform APIs from QPlatformInterface to QNativeInterface
We were already using the 'native' nomenclature when referring to these
kinds of APIs, e.g. when talking about native handles, or the existing
QPlatformNativeInterface on a QPA level. Using 'native' for the user
facing APIs also distinguishes them from the 'platform' backend layer
in QPA and elsewhere.

Change-Id: I0f3273265904f0f19c0b6d62471f8820d3c3232e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-07 13:03:27 +02:00
Shawn Rutledge
f51e6552e3 End touch->mouse synthesis when the chosen touchpoint is released
During delivery of a TouchBegin event, if no widget accepts it,
we begin treating the first touchpoint as a synth-mouse, as before.
If a second touchpoint is pressed or released in any order, it's
irrelevant: the fake mouse button is released as soon as the first
touchpoint is released.  This fixes the bug that such a scenario
caused the mouse release not to be sent, so that a widget could get
"stuck" in pressed state.

Done-with: Tang Haixiang <tanghaixiang@uniontech.com>
Fixes: QTBUG-86253
Pick-to: 5.15
Change-Id: I7fbbe120539d8ded8ef5e7cf712a27bd69391e02
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-02 14:17:44 +02:00
Laszlo Agocs
0b7aef08dc rhi: vk: Alter command buffer strategy
Reports on the Web have it that there's nothing guaranteeing a
driver does any actual freeing of resources then doing
vkFreeCommandBuffer for a command buffer from a command pool that
does not have VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, thus
leading to continuously growing resource usage with our current
allocate/free pattern. It could be that this is the source of out
of memory problems we are seeing on some Android devices.

Instead of just going straight for said command pool flag and doing
ResetCommandBuffer for the command buffers individually, take one
step further and use per-slot (slot being 0 or 1 if QVK_FRAMES_IN_FLIGHT
is 2) command pools. The current pool is reset in each
beginFrame/beginOffscreenFrame, moving all allocated command buffers
to the initial state (while other command buffers with the other pool
are not affected).

This may be (while impossible to tell from just guessing based on the
spec) our best approach to command buffer allocation since a Vulkan
implementation can likely just use some simple per pool allocator,
knowing that we never want to free or reset individual command buffers,
but we rather only reset the whole pool at once.

The option of importing an existing VkCommandPool when creating the
QRhi instance is now gone, but there was probably no point in offering
that in the first place.

When it comes to VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT it will
not be set unless releaseCachedResources() (in Qt Quick this is hooked
into QQuickWindow::releaseResources()) was called. What this does in
practice is unknown, but have an option to set it now and then if the
application really wants.

While we are at it, rename secondaryCbs to activeSecondaryCbStack to
indicate what it really is. (it's a stack as each call to
beginExternal() pushes a new one, while each endExternal() pops)

Change-Id: I2e5c1fad26d794e1f56c778e38f750998d706d84
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-02 13:14:31 +02:00
Laszlo Agocs
d92b0e18c1 rhi: Make per-frame flags per-pass where appropriate
ExternalContentsInPass becomes a per-pass flag now. Why is this
beneficial? Because while Qt Quick has no choice for its render
pass, not being able to guess if the application wants to do some
native rendering in there, Quick 3D's render passes, all the ones
that are under Quick3D's control, do not have native rendering
from the application in them, and so using secondary command
buffers with Vulkan is not necessary.

Introduce something similar for compute and OpenGL. By knowing that
none of the resources used in a pass are used with a compute pass
(e.g. because we know that there are no compute passes at all) a small
amount of time can be saved by skipping tracking buffers and textures
because the only purpose of said tracking is to generate barriers that
are relevant only to compute.

Change-Id: I0eceb4774d87803c73a39db527f5707a9f4d75c1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-02 13:14:08 +02:00
Shawn Rutledge
8f74f7d25b tst_qwindow: verify isBeginEvent(), isUpdateEvent() and isEndEvent()
It also demonstrated that the tests were out of sync with reality:
since a97759a336c597327cb82eebc9f45c793aec32c9 QMouseEvent::button()
and QWindowSystemInterfacePrivate::MouseEvent::button should be the
button that changes state of course; but when a button is pressed,
we are reacting to it after the fact, so QMouseEvent::buttons() and
QWindowSystemInterfacePrivate::MouseEvent::buttons should include the
new button that was just pressed.  Likewise when a button was released,
we send the event with buttons _omitting_ the button that was just
released.

Amends 147a8bc4c8 and
6d6ed64d6c

Change-Id: I670289019fcfa7de685ca38799804772dc0f1c8f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-30 23:17:57 +02:00
Allan Sandfeld Jensen
426308a93b Add logging categories to image handlers
Change-Id: Ia0c47826d08b3f641c17d8a585f62d008a8b095b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-30 08:39:45 +02:00
Liang Qi
be7d46f5e2 Revert "Blacklist tst_QWindow::exposeEventOnShrink_QTBUG54040"
This reverts commit b1ef104866.

This test is BPASS on openSUSE_42_3 for 5.12 and PASS on openSUSE_15_1
for 5.15.

Pick-to: 5.15
Pick-to: 5.12
Change-Id: Ia1d81ed38491c27c01f270623c5082663f4da699
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-09-30 06:18:49 +02:00
Laszlo Agocs
848ed9644c rhi: Drop QBitArray usage
Change-Id: I4ae92e6c8c91111a4593c51ee05443b3bc806c35
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-29 21:24:38 +02:00
Lars Knoll
0902508411 Fix compiler warnings from QKeyCombination
Change lots of code to avoid the deprecated operator+() or implicit
casts to int.

Change-Id: I0c343cd5b28603afdf1214eefb85e928313345e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-28 17:23:20 +02:00
Allan Sandfeld Jensen
b0b4fcd05c Preserve formats in QImage::scaled()
Do not always use the smoothScaled routine, the normal routines are
also optimized, and do not convert to alpha formats when not necessary.

Task-number: QTBUG-49719
Change-Id: I6ee9b620cc259472c419e7363357f41ce29b594a
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-26 18:49:10 +02:00
Volker Hilsheimer
2f319f3be9 Give QPixmap a move constructor
It already has a move-assignment operator, and implements swapping.

This requires a specialization of the QExplicitlySharedDataPointer
destructor to be forward declared, and an implementation that is
identical to the default version. Otherwise we would need
QPlatformPixmap to be fully defined in the public QPixmap header.

Change-Id: I2651bbc29a7083a93e3b3ad671d3aeea659b7d5a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-09-23 18:00:54 +02:00
Allan Sandfeld Jensen
7c1f94f387 Fix Qt6 todo in qcssparser
Colors with wrong number of elements are now invalid.

Change-Id: I32c934894de86095d9790baa5f0d2001d76bcd3c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-23 17:01:29 +02:00
Laszlo Agocs
fe3a1617af rhi: d3d: Fix dynamic offsets with multiple buffers
Fixes: QTBUG-86821
Change-Id: I57f86bf0f7e95b92f5b2c5fee587112ecf0fc8e6
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-23 16:59:06 +02:00
Alexandru Croitor
403213240c CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.
Clean up some stale .prev files that are not needed anymore.
Clean up some project files that are not used anymore.

Task-number: QTBUG-86815
Change-Id: I9947da921f98686023c6bb053dfcc101851276b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-23 16:59:06 +02:00
Alexandru Croitor
a3bd80c08c CMake: Regenerate projects
Clean up the state of the projects,
before changing the internal CMake API function names.

Task-number: QTBUG-86815
Change-Id: I90f1b21b8ae4439a4a293872c3bb728dab44a50d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-22 19:08:53 +02:00
Alexandru Croitor
9959090da8 CMake: Fix failing tests on macOS developer builds
tst_qguiapplication was missing an Info.plist file.
We can't directly reference the tst_qcoreapplication Info.plist
file like the qmake project does, because that breaks ninja
(says multiple rules create the same output file), so use a
copy instead.

Blacklist the qpluginloader loadMachO test when doing CMake builds.
The qmake projects use multiple custom rules to build the macho
plugins, which need to be ported to CMake.

Task-number: QTBUG-86053
Task-number: QTBUG-86792
Change-Id: Iaff2b2d5e9e84a457b4f2ffc011a580388498f00
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-22 19:08:53 +02:00
Allan Sandfeld Jensen
5f198584e2 Define inverted QRects consistently
Changes the definition of invalid QRects to be more consistent.
This simplifies the logic, and makes it possible for us to fix
normalized() so dimensions don't change.

The actual API is not changed except for inverted rects.

Only one use-case for the old normalized() function existed,
and has been reimplemented as QRect::span().

Fixes: QTBUG-22934
Change-Id: I29dad2952dc6c8e84a6d931898dc7e43d66780f3
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-21 15:04:51 +02:00
Lars Knoll
848927b688 Cleanup API of QMimeData
Do not use QVariant::Type anymore, instead use QMetaType

For some reason, this pushed the qvariant autotest over the limit where
MSVC requires the /bigobj flag, so add that one.

[ChangeLog][QtCore][QMimeData] The signature of the virtual retrieveData()
function has changed and now takes a QMetaType instead of a QVariant::Type.

Change-Id: Ib46773bd731ee2177b1ef74d8162d744be7017ef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-21 14:56:09 +02:00
Shawn Rutledge
153dcfbbba Rename is[Begin|Update|End]Event, reimplement in QWheelEvent
These states correspond well with ScrollPhase, and this abstraction
makes it possible to handle wheel events the same way as mouse events
in Qt Quick: on "begin" we deliver to all Items and Handlers until
all points (the only point) are accepted; on "update" and "end" we
deliver only to the exclusive grabber, if there is one, and to any
passive grabbers.

Change-Id: I702dbd4f2c1bf5962eb3dbb9e4b725300a00a887
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-17 19:03:24 +02:00
Volker Hilsheimer
861c4d8548 Deprecate implicit QPixmap conversion to QBitmap
It is lossy, so should be requested explicitly, using a dedicated
fromPixmap factory function.

Deprecate the constructor and assignment operator, and make the
constructor explicit.

[ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning
to a QBitmap from a QPixmap has been deprecated, and the respective
constructor has been made explicit. Use the fromPixmap factory
function instead.

Change-Id: I68ce85b26c901415137b664a1db687021d48bae0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-17 13:26:50 +02:00
Volker Hilsheimer
fe3bebbd68 Fix deprecation warnings in tests
Adjust to changes to QIcon::pixmap, QMetaType::type, and
QAbstractItemView::itemDelegate.

Change-Id: I9eb0331ef899131afc86c33f27feeee76331ffc8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-17 06:45:59 +02:00
Shawn Rutledge
a54988c822 Mouse->touch synthesis: send touch event with mouse device
In 4e400369c0 we began to send synth-mouse
events from the touch device, but in the opposite direction it was not
consistent.

Add autotests to prove that it's consistent both ways now.

Change-Id: I7df2328fef224dc1529ca5d27411cd8a5a9c8df9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 14:47:45 +02:00
Shawn Rutledge
1fdbbb49d9 Calculate velocity in QMutEventPoint::setTimestamp() with Kalman filter
This functionality was only in Qt Quick in Qt 5.  Now we move it up to QtGui
so that every QEventPoint will have a valid velocity() before being delivered
anywhere.

[ChangeLog][QtGui][QPointerEvent] Every QEventPoint should now carry a valid
velocity(): if the operating system doesn't provide it, Qt will calculate it,
using a simple Kalman filter to provide a weighted average over time.

Fixes: QTBUG-33891
Change-Id: I40352f717f0ad6edd87cf71ef55e955a591eeea1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 14:47:36 +02:00
Shawn Rutledge
2692237bb1 Track grab state in QPointingDevicePrivate::activePoints
QQuickEventPoint instances were very long-lived and got reused from one
event to the next.  That was initially done because they were "heavy"
QObjects; but it also became useful to store state in them between
events. But this is in conflict with the ubiquitous event replay
code that assumes it's OK to hold an event instance (especially
a QMouseEvent) for any length of time, and then send it to some widget,
item or window. Clearly QEventPoints must be stored in the QPointerEvent,
if we are to avoid the need for workarounds to keep such old code working.
And now they have d-pointers, so copying is cheap. But replay code
will need to detach() their QEventPoints now.

QEventPoint is useful as an object to hold state, but we now store
the truly persistent state separately in an EventPointData struct,
in QPointingDevicePrivate::activePoints. Incoming events merely
update the persistent points, then we deliver those instead.
Thus when event handler code modifies state, it will be remembered
even when the delivery is done and the QPA event is destroyed.

This gets us a step closer to supporting multiple simultaneous mice.

Within pointer events, the points are moved up to QPointerEvent itself:
 QList<QEventPoint> m_points;
This means pointCount(), point(int i) and points() can be non-virtual.
However in any QSinglePointEvent, the list only contains one point.
We hope that pessimization is worthwhile for the sake of removing
virtual functions, simplifying code in event classes themselves, and
enabling the use of the range-for loop over points() with any kind of
QPointerEvent, not just QTouchEvent. points() is a nicer API for the
sake of range-for looping; but point() is more suited to being
non-const.

In QML it's expected to be OK to emit a signal with a QPointerEvent
by value: that will involve copying the event.  But QEventPoint
instances are explicitly shared, so calling setAccepted() modifies
the instance in activePoints (EventPointData.eventPoint.d->accept);
and the grabbers are stored separately and thus preserved between events.
In code such as MouseArea { onPressed: mouse.accepted = false }
we can either continue to emit the QQuickMouseEvent wrapper
or perhaps QEvent::setAccepted() could become virtual and set
the eventpoint's accepted flag instead, so that it will survive
after the event copy that QML sees is discarded.

The grabChanged() signal is useful to keep QQuickWindow informed
when items or handlers change exclusive or passive grabbers.

When a release happens at a different location than the last move event,
Qt synthesizes an additional move.  But it would be "boring" if
QEventPoint::lastXPosition() accessors in any released eventpoint always
returned the same as the current QEventPoint::xPosition()s just because
of that; and it would mean that the velocity() must always be zero on
release, which would make it hard to use the final velocity to drive an
animation.  So now we expect the lastPositions to be different than
current positions in a released eventpoint.

De-inline some functions whose implementations might be subject to
change later on.  Improve documentation.

Since we have an accessor for pressTimestamp(), we might as well add one for
timestamp() too.  That way users get enough information to calculate
instantaneous velocity, since the plan is for velocity() to be somewhat
smoothed.

Change-Id: I2733d847139a1b1bea33c00275459dcd2a145ffc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 11:33:03 +02:00
Alexandru Croitor
9ce8281417 Fix tests to build in a no-widgets configuration
The qfilesystemmodel.pro was recently moved to the gui tests subfolder,
but it uses widgets inside. Skip it in a no-widgets build.

Amends fb9ec8ad44

Task-number: QTBUG-86187
Change-Id: I955556ffddad483d4c25602ae126b8c2433091b2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-15 15:55:47 +02:00
Mitch Curtis
fb65b32d76 Add qHash implementation for QPoint
[ChangeLog][QtCore][QPoint] Added qHash() implementation.

Change-Id: I65332e7aafab53af40a6e11457b9b457196d584c
Fixes: QTBUG-86457
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-15 02:46:40 +02:00
Lars Knoll
2c698a6d07 Fix compiler warnings about missing overrides
Change-Id: I52bf9fe45607f4a99cafa441bd78dfe5f7adb0e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-13 21:03:31 +02:00
Lars Knoll
557623cc4f Rename QLibraryInfo::location() to path()
As per ### Qt6 comment. Also rename the LibraryLocation enum
to LibraryPath.

Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-12 23:35:56 +02:00
Allan Sandfeld Jensen
5bb4baae03 Replace qreal with float in QColor
There is no reason to use double precision for colors. We at most have
16 significant bits anyway.

Change-Id: I8b402cd978675b8ba7248176976d934363212ff1
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-11 20:41:15 +02:00
Lars Knoll
6ae7a02104 Remove most compiler warnings about missing overrides
Remove around 1000 compiler warnings about missing overrides
in our auto tests.

This significantly reduce the compiler warning noise in our auto
tests, so that one can actually better see the real problems
inbetween.

Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-11 00:20:47 +02:00
Morten Johan Sørvig
b3c991ae8f Port from devicePixelRatioF() to devicePixelRatio()
This ports all of QtBase.

Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-10 17:28:11 +02:00
Allan Sandfeld Jensen
030962b01c Cleanup QAction::visible property
Gives it its own changed signal, and simplifies setting from group,
while fixing an inconsistency in propagation.

Change-Id: I22b243210260a8878144fa4b60204df46f847f37
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-10 09:24:18 +00:00
Shawn Rutledge
ae7442a4e9 Give QEventPoint a d-pointer after all
I still have doubts that QEventPoint can't be made small enough that
copying would be cheaper than reference-counting and all the indirections
in now-noninline accessors, but this gives us the usual freedom to
change the data members later on.

Change-Id: I792f7fc85ac3a9538589da9d7618b647edf0e70c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-10 03:15:49 +02:00
Allan Sandfeld Jensen
d263ab6af5 Create consistent sets of QImage methods
Adds consistently named inplace and imperative methods.

Change-Id: I8739c1c4585d2ba4aa181bb9a681255d76c120d7
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-09 00:14:49 +01:00
Shawn Rutledge
0e475eeea6 Refactor testlib touch functions into qtestsupport_gui and _widgets
Because we removed public setters from QTouchEvent and QEventPoint in
4e400369c0 and now it's proposed to give
QEventPoint a d-pointer again, the implementation of QTouchEventSequence
needs to start using QMutableEventPoint: being a friend will no longer
be enough, because the member variables won't be accessible in the future.
But because we have separate test libs for Gui and Widgets, it needs to
be further refactored into two classes.

Change-Id: I0bfc0978fc4187348ac872e1330d95259d557b69
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-08 08:02:15 +02:00
Giuseppe D'Angelo
fec51be209 tst_qshortcut (x2): use op | instead of op + to combine keys
Following the introduction of QKeyCombination, reduce the number
of warnings raised by the test. Drive-by, remove some pointless
math like Qt::SHIFT+0, which does not make any sense and would
actually fail to compile (shortly).

Refactoring the test to fully use QKeyCombination (instead of
ints) is left as a future exercise; some QKeyCombination->int
warnings are still around.

Change-Id: If825bc4c369986623447927bb11493c4f58b544f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-07 15:50:02 +02:00
Marcel Krems
c93b91c766 Remove deprecated method QQuaternion::conjugate
Change-Id: If539e47618357ef329925033842f266447632e6f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-07 04:36:16 +02:00
Volker Hilsheimer
00a5629d8d Remove deprecated QPrinter and QPagedPaintDevice APIs
Adjusting the QPrinter test case - some use cases no longer exist, or are
already tested in QPageSize and QPageLayout tests.

Adjust examples and manual tests.

Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-04 08:37:59 +02:00
Tor Arne Vestbø
f4c58b79a7 Extend test blacklisting from Ubuntu 18.04 to 20.04
Task-number: QTBUG-86187
Change-Id: I3ac3233f7355d1c16bc9bf6e052fdf4bd9ea90de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-03 14:30:04 +02:00
Giuseppe D'Angelo
25351dcc54 Long live QKeyCombination!
C++20 via P1120 is deprecating arithmetic operations between
unrelated enumeration types, and GCC 10 is already complaining.
Hence, these operations might become illegal in C++23 or C++26 at
the latest.

A case of this that affects Qt is in key combinations: a
QKeySequence can be constructed by summing / ORing modifiers and a
key, for instance:

  Qt::CTRL + Qt::Key_A
  Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below)

The problem is that the modifiers and the key belong to different
enumerations (and there's 2 enumerations for the modifier, and one
for the key).

To solve this: add a dedicated class to represent a combination of
keys, and operators between those enumerations to build instances
of this class.

I would've simply defined operator|, but again docs and pre-existing
code use operator+ as well, so added both to at least tackle simple
cases (modifier + key).

Multiple modifiers create a problem: operator+ between them yields
int, not the corresponding flags type (because operator+ is not
overloaded for this use case):

  Qt::CTRL + Qt::SHIFT + Qt::Key_A
  \__________________/      /
          int              /
           \______________/
                  int

Not only this loses track of the datatypes involved, but it would
also then "add" the key (with NO warnings, now its int + enum, so
it's not mixing enums!) and yielding int again.

I don't want to special-case this; the point of the class is
that int is the wrong datatype. Everything works just fine when
using operator| instead:

  Qt::CTRL | Qt::SHIFT | Qt::Key_A
  \__________________/      /
      Qt::Modifiers        /
           \______________/
            QKeyCombination

So I'm defining operator+ so that the simple cases still work,
but also deprecating it.

Port some code around Qt to the new class. In certain cases,
it's a huge win for clarity. In some others, I've just added
the necessary casts to make it still compile without warnings,
without attempting refactorings.

[ChangeLog][QtCore][QKeyCombination] New class to represent
a combination of a key and zero or more modifiers, to be used
when defining shortcuts or similar.

[ChangeLog][Potentially Source-Incompatible Changes] A keyboard
modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be
combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using
operator|, not operator+.  The result is now an object of type
QKeyCombination, that stores the key and the modifiers.

Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-03 07:00:31 +02:00
Peng Wenhao
f0ae973244 Qpagedpaintdevice: Use marginsF instead of internal struct margins
resolve remaining Qt6 TODOs

Change-Id: Iad659a09ddfe136bdc545bc0635b4c695540c58b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-01 04:57:48 +08:00
Tor Arne Vestbø
90358f6042 Deprecate and remove uses of AA_DisableHighDpiScaling
Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-31 19:14:55 +02:00
Morten Johan Sørvig
319462559f Port tst_qiconhighdpi to the new QIcon::pixmap() API
Port the high-dpi icon test to use the new pixmap()
API which takes the target devicePixelRatio as an argument.

This means we can run the fromTheme test at dpr = {1,2,3},
instead of at the current global devicePixelRatio only.

Task-number: QTBUG-85885
Change-Id: Iec7b21e04ed760e48964307d2048eaec1976ffe2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-29 10:02:47 +02:00
Tor Arne Vestbø
756d7facf6 Fix tst_QHighDpiScaling::scale
Without an override for logicalDpi() the base class implementation
would use the geometry of the screen to figure out the DPI, and end
up with ~100, which combined with a 96DPI base logical DPI would
give a wrong scale factor.

Change-Id: I68aecce44d2ee672c7b707dfe5444af8f551e961
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-08-28 13:00:05 +02:00
Jonas Karlsson
3558704ed5 Use OpenType font weights
Task-number: QTBUG-42248
Change-Id: Icdb301b27d6699c2b842c4563fbef9df73c23cbc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-08-28 07:26:54 +02:00
Morten Johan Sørvig
ffde7e8995 QIcon: Add pixmap() overload which take devicePixelRatio
Add new QIcon::pixmap() overload:

  QPixmap pixmap(const QSize &size, qreal devicePixelRatio, ...)

This function replaces the existing pixmap() function which
take a QWindow pointer, and should be more convenient in use.

Task-number: QTBUG-85885
Change-Id: Ie4ca96a266d9278864678dc61bdfc2836cabdb93
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-08-27 12:13:08 +02:00
Tor Arne Vestbø
b5f972361a Introduce QWindow::paintEvent with QPA plumbing
The explicit paint event on QtGui and QPA level allows us to untangle
the expose event, which today has at least 3 different meanings.

It also allows us to follow the platform more closely in its semantics
of when painting can happen. On some platforms a paint can come in
before a window is exposed, e.g. to prepare the first frame. On others
a paint can come in after a window has been de-exposed, to save a
snapshot of the window for use in an application switcher or similar.

The expose keeps its semantics of being a barrier signaling that the
application can now render at will, for example in a threaded render
loop.

There are two compatibility code paths in this patch:

  1. For platform plugins that do not yet report the PaintEvents
     capability, QtGui will synthesize paint events on the platform's
     behalf, based on the existing expose events coming from the platform.

  2. For applications that do not yet implement paintEvent, QtGui will
     send expose events instead, ensuring the same behavior as before.

For now none of the platform plugins deliver paint events natively,
so the first compatibility code path is always active.

Task-numnber: QTBUG-82676
Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 16:44:53 +02:00
Marcel Krems
8dd50ef206 Remove deprecated qGenericMatrix{To,From}Matrix4x4 functions
Change-Id: I3b43d48f5324f3a1f2fff8e22bb4f9563d3ea997
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:49:24 +02:00
Lars Knoll
acbf9a858b Cleanup QTypeInfo
Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6.
Also remove sizeOf, it's unused, and we have QMetaType for that if
required.
Remove all typeinfo declaractions for trivial types, as the default
template covers them correctly nowadays.

Finally set up a better default for isPointer, and do some smaller
cleanups all over the place.

Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-26 01:03:22 +02:00
Volker Hilsheimer
b77a3f47c9 Rename confusingly named QFont/QPalette::resolve overloads
Having three methods with the same name doing different things is
unnecessarily confusing, so follow the standard naming convention in
Qt and call the getter of the resolve mask resolveMask, and the setter
setResolveMask. These methods were all documented as internal.

The publicly documented resolve() method that merges two fonts and
palettes based on the respective masks remains as it is, even though
'merge' would perhaps be a better name.

Change-Id: If90b1ad800834baccd1dbc38fc6b861540d6df6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-25 17:59:10 +02:00
Shawn Rutledge
c7f7279969 Introduce QEvent::isPointerEvent()
This makes high-level event dispatching easier: for example in Qt Quick,
all pointer events should eventually be delivered to items in a similar way.

Implemented in a similar way as d1111632e2.

Change-Id: I2f0c4914bab228162f3b932dda8a88051ec2a4d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-25 06:34:01 +02:00
Volker Hilsheimer
fb9ec8ad44 Move QFileSystemModel into QtGui
This requires a QAbstractFileIconProvider in QtGui, as the standard
QFileIconProvider depends on QStyle, and cannot be moved out of
QtWidgets.

QAbstractFileIconProvider returns strings for file types, but returns
no icons yet. Support for a default icon set might be added in a
follow-up commit.

Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7
Fixes: QTBUG-66177
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-25 06:33:44 +02:00
Shawn Rutledge
38806273e5 Remove QEventPoint::event() in favor of device()
event()->device() was the most common use case anyway.

The idea that the "parent" of a QEventPoint is the QPointerEvent
interferes with the ability to copy and move event objects: the parent
pointers are dangling unless we use the QPointerEvent subclass
destructors to set the points' parents to null.  Since there is no move
constructor, even returning a QEventPoint from a function by value
results in destroying the temporary instance and copying it to the
caller's space.  So the parent pointer is often useless, unless we do
even more work to maintain it when the event moves.

If we optimize to avoid copying QEventPoints too much (and perhaps
enable exposing _mutable_ points to QML) by storing reusable instances in
QPointingDevice (which is the current plan), then the actual parent will
no longer be the event.  Events are usually stack-allocated, thus
temporary and intended to be movable.

Change-Id: I24b648dcc046fc79d2401c781f1fda6cb00f47b0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-08-24 13:50:55 +02:00
Lars Knoll
1697fbdf05 Deprecate the static int based API in QMetaType
And remove one of the type id to name mapping that still
existed in QMetaType. QMetaTypeInterface can provide that,
so there's no need to have a second copy of the data.

qMetaTypeTypeInternal() can still map all the names of all
builtin types to ids. That functionality is for now still
required by moc and can't be removed yet.

Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-24 00:19:05 +02:00
Lars Knoll
ed8acbeb7c Automatically register data/debug stream operations in QMetaType
And remove the old manual registration code for those operators.

Add some special handling for long/ulong, as these types could be
streamed as a QVariant so far, but are not directly streamable
through QDataStream.

[ChangeLog][QtCore][QMetaType] The QMetaType::registerStreamOperators()
and QMetaType::registerDebugStreamOperator() methods have been
removed. The streaming operators for a type are now automatically
registered together with the type registration.  This implies that the
operators should be visible wherever the type is visible and being used.

[ChangeLog][Behavior Incompatible Changes] Because the QDataStream and
QDebug serialization operators are automatically registered with
QMetaType, the declarations of those functions must be present at any
point where the type is used with QMetaType and QVariant.

Change-Id: I4a0732651b20319af4a8397ff90b848ca4580d99
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-24 00:17:03 +02:00
Andy Shaw
37c68503cb QFont: Extend the string description to include the missing elements
This extends to/fromString to include style strategy, capitalization,
letter and word spacing and stretch. QFont::fromString() keeps
compatibility with strings from earlier versions as well.

Fixes: QTBUG-67687
Change-Id: I5e95a58f1cd850214af2a7d8906a214facd4e661
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-08-22 22:21:35 +00:00
Edward Welbourne
16e546e32f Properly deprecate Qt::MidButton in favor of Qt::MiddleButton
MidButton had its // ### Qt 5: remove me
upgraded to Qt 6 at 5.0; but it dates back to 4.7.0

Replace the many remaining uses of MidButton with MiddleButton in the
process.

Pick-to: 5.15
Change-Id: Idc1b1b1816673dfdb344d703d101febc823a76ff
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-22 21:47:36 +02:00
Paul Lemire
6a2c89c043 rhi: sanityCheckGraphicsPipeline handle no vertex attributes
It is a valid use case to have a vertex shader with no
vertex attributes. Using gl_VertexID or gl_InstanceID
is enough to generate vertex data out of thin air.

Change-Id: If7689914624a84723923fd2d7aef355bda592e24
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-08-18 07:58:50 +02:00
Lars Knoll
8929c0a355 Remove QVariant(int type, void *data, ...) constructor
It was marked internal anyway. Use the constructor taking a
QMetaType instead.

Change-Id: I15b9cd0911aac063a0f0fe0352fa2c84b7f7c691
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-15 10:56:29 +02:00
Allan Sandfeld Jensen
6f0df02d00 Replace Qt CONSTEXPR defines with constexpr
Both normal and relaxed constexpr are required by our new minimum of
C++17.

Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-08-14 15:52:58 +02:00
Lars Knoll
048debe8f9 Restrict QVariant::isNull() behavior
isNull() would forward to the contained type and check that type's
isNull() method for some of the builtin types. Remove that behavior
and only return true in isNull(), if the variant is invalid, doesn't
contain data or contains a null pointer.

In addition, implement more consistent behavior when constructing
a QVariant using the internal API taking a copy from a void *.
isNull() should return true in both cases. This mainly changes behavior
for some corner cases and when using our internal API.

[ChangeLog][Important Behavior Changes] QVariant::isNull()
no longer returns true when the variant contains an object of some
type with an isNull() method, that returns true for the object;
QVariant::isNull() now only returns true when the variant contains
no object or a null pointer.

Change-Id: I3125041c4f8f8618a04aa375aa0a56b19c02dcf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-13 08:48:32 +02:00
Lars Knoll
50c96c17b6 Use the new support for comparisons in QMetaType for QVariant
Remove the compare method in the QVariant::Handler struct. Rely
on the generic support provided by QMetaType instead.

[ChangeLog][Important Behavior Changes][QVariant] QVariant will now use builtin support in
QMetaType to compare its content. This implies a behavioral change
for some graphical types like QPixmap, QImage and QIcon that will
never compare equal in Qt 6 (as they do not have a comparison
operator).

Change-Id: I30a6e7116c89124d11ed9052537cecc23f78116e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-08-13 08:48:03 +02:00
Laszlo Agocs
a99cee1c7b Remove old CBOR-based format from QShader
We only support version 4 and 5 in Qt 6.0. 1 and 2 are already gone
(due to being based on binary JSON), now we remove 3 as well.

Task-number: QTBUG-81346
Change-Id: I3627dcc0587f1e36f11e93edf7172889e911d64e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-08-11 13:45:09 +02:00
Giuseppe D'Angelo
3f6afac6b1 QPolygon: streamline constructors and special member functions
Employ RO0; inherit the constructors from the base class; and
do some code tidies as a drive by.

The inherited constructors bring in goodies like initializer_list
support.

Change-Id: Ia00a3f9b0ccbf182bf837bc65ba2305110c8dc60
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-08-07 15:01:26 +02:00
Alexandru Croitor
92ee9bd6b8 CMake: Properly handle CONFIG += thread aka Threads::Threads
mkspecs/features/qt.prf adds a dependency on the system threading
library if the Qt Core thread feature is enabled. Because qt.prf is
loaded by any public or internal Qt project, it's essentially a public
dependency for any Qt consumer.

To mimic that in CMake, we check if the thread feature is enabled, and
and set the Threads::Threads library as a dependency of Qt6::Platform,
which is a public target used by all Qt modules and plugins and Qt
consumers.

We also need to create a Qt6Dependencies.cmake file so we
find_package(Threads) every time find_package(Qt6) is called.

For the .prl files to be usable, we have to filter out some
CMake implementation specific directory separator tokens
'CMAKE_DIRECTORY_ID_SEP' aka '::@', which are added because we call
target_link_libraries() with a target created in a different scope
(I think).

As a result of this change, we shouldn't have to hardcode
Threads::Threads in other projects, because it's now a global public
dependency.

Task-number: QTBUG-85801
Task-number: QTBUG-85877
Change-Id: Ib5d662c43b28e63f7da49d3bd77d0ad751220b31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:15:39 +02:00
Eskil Abrahamsen Blomfeldt
76068d0114 Make QFontDatabase member functions static
QFontDatabase is a singleton and all instances would share
a single, mutex-protected global data pointer. But some functions
were implemented as non-static functions. This caused a lot
of code on the form

	QFontDatabase().families(...)

since there was no static access. Other functions were implemented
as static.

To consolidate, we make all functions static. This should be
source-compatible, but not binary compatible.

[ChangeLog][QtGui][Fonts] Some functions in QFontDatabase were in
principle static, but previously not implemented as such. All
member functions have now been made static, so that constructing
objects of QFontDatabase is no longer necessary to access certain
functionality.

Fixes: QTBUG-83284
Change-Id: Ifd8c15016281c71f631b53387402c942cd9c43f6
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2020-08-06 11:43:24 +02:00
Shawn Rutledge
6d6ed64d6c Add QPointerEvent::is[Press|Update|Release]Event accessors
QQuickPointerEvent had them, so despite how trivial they look,
it's very convenient to keep using them in QQuickWindow rather than
duplicating these kinds of checks in various places, and for multiple
event types too.

Change-Id: I32ad8110fd2361e69de50a679ddbdb2a2db7ecee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-06 10:23:56 +02:00
Morten Johan Sørvig
00f2d1a09b Establish baseline for QIcon test on dpr > 1
After enabling Qt::AA_UseHighDpiPixmaps, QIcon::pixmap()
now returns pixmaps larger than the requested size on
devicePixelRatio > 1 screens.

Adapt tests to account for this changed behavior.
Skip tests where it’s unclear what the the expected
behavior is, or where the test logic does not apply
to dpr > 1.

This gives a clearer indication of where we are
(39 passed, 0 failed, 9 skipped), and enables using
the qicon test to catch regressions also when running
at dpr > 1.

Remove the "lowdpi" testcase flags from the qmake and
cmake project files.

Change-Id: Ia7ce722ae356fc496a91b54e9f5d590d13b9df62
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-05 11:23:07 +02:00
Laszlo Agocs
c5da2e6f06 Remove old qsb versions from qshader autotest
Only keep 3, 4, and 5 because 3 is the lowest version where binary JSON
is not used anymore.

Change-Id: Id0319e8eceb845017ed493d0ef6902b53050d5a6
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-07-31 12:57:06 +02:00
Tor Arne Vestbø
47cb6ad698 Don't capture this explicitly in tests
Some compilers implicitly captures, and will warn about the unused capture.

Change-Id: Ib5e1cc3956c7eb0dc87cee834cce8a2b3dd0d30b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 18:34:16 +00:00
Alex Trotsenko
8969070cfd QEventDispatcherWin32: redesign event notifiers activation
The previous implementation multiplexed callback-based event
notification into a single proxy event (cf. 85403d0af), which was
in turn object-waited for (this was the case since the beginning
of public qt history). It makes more sense to multiplex into a
posted message, because that also works with foreign event loops
that do not know anything about our event objects.

Task-number: QTBUG-64443
Change-Id: I97945ac8b5d7c8582701077134c0aef4f3b5a18f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 18:34:34 +03:00