Commit Graph

60363 Commits

Author SHA1 Message Date
Volker Hilsheimer
f5105ea89a QStyleSheet: never treat styled scrollbars as transient
If a style sheet is applied to a scrollbar, then we cannot treat it as
transient, as the QStyleSheetStyle doesn't implement any fade-in/out
animation logic. And we also need to set the overlap to 0 (in both
the style sheet and the macOS style) if the scrollbars are not
transient; otherwise the opaque scrollbar will be placed on top of the
content.

Since a style sheet might only apply to a scrollbar based on its
orientation, we also have to pass the style option through to all calls
of the styleHint function.

And since that function is also called from other QStyle implementations
in the macOS style, we have to make sure that we call styleHint() on the
widget's style to get the correct value based on the style sheet.

Fixes: QTBUG-63381
Pick-to: 6.5 6.4 6.2
Change-Id: Ic67ce3a7cb5089f885dabfd5a1951e3029915446
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-27 19:26:05 +01:00
Volker Hilsheimer
519e3963fa QtGui: Use single precision for mouseMove detection
QGuiApplication::lastCursorPosition is a QPointF, and (at least on macOS)
compares always different from the QPointF stored in the event. This
might be due to the translation from system coordinates to QPointF
introducing noise.

The result is that even a simple button press causes mouseMove events
to be delivered.

To prevent this event noise, overload equality operators for the special
QLastCursorPosition type when comparing with QPointF to explicitly use
single precision comparison.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-111170
Change-Id: I82ea23ac9f4fa80c55c9c5c742527dd7ee74fd99
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-02-27 19:26:05 +01:00
Ben Fletcher
cd2d626b8b rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:31:07 -08:00
Ben Fletcher
3b997835e1 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:29:34 -08:00
Ben Fletcher
248ac343f1 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:28:11 -08:00
Ben Fletcher
479d17f7a9 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:26:58 -08:00
Ben Fletcher
70e0d9164d rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:25:55 -08:00
Ben Fletcher
2f216ac33f rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:25:02 -08:00
Ben Fletcher
dd3105d68d rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:24:20 -08:00
Ben Fletcher
3bf1541502 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:23:47 -08:00
Ben Fletcher
5dfb25e253 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:23:24 -08:00
Ben Fletcher
9ffa16baf0 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:23:05 -08:00
Ievgenii Meshcheriakov
742e79312f chat example: Update code style
Use lambdas instead of slots where practical.
Consistently use signals to transmit D-Bus messages.
Extract a local variable for the used D-Bus connection.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Icc6667e1392ada1b7d3b33c4e4b32917dd648390
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
57d25b3a53 chat example: Remove empty destructor
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I880c16638c992a4ee8528b1c545e6f563a7efa8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
fd03a04457 chat example: Remove commented-out code
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Ib8e89427357f604ab30cb0de50eb373cffb945fa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Ievgenii Meshcheriakov
8b48657590 chat example: Use QInputDialog to get a user nickname
This gets rid of a custom form. Also quit the application if user
closes the input dialog without entering a nickname.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: I56ed99d69d031e7ef06711fc7ec112311c974ca6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-27 15:55:07 +01:00
Mårten Nordheim
acc6dc9c09 Mark variable only used in Q_ASSERT as unused
Change-Id: Idee2a4772c7c12e293838a647ed768295612f794
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-27 12:10:43 +01:00
Doris Verria
276bf8cb23 Examples doc: Tag 'To Do List Example' for iOS
All QtQuickControls examples are marked for android by default.
However, the To Do List example is iOS specific so don't include it.
Add it to the list of iOS tags instead.

Fixes: QTBUG-111426
Pick-to: 6.5 6.4
Change-Id: Ic89d6b40d263f81ed402a2064f2e44b2fa826940
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-02-27 10:10:10 +01:00
Marc Mutz
e388d219a4 QCryptographicHash: don't include openssl/sha.h
... it conflicts with rfc6234/sha.h's SHA{1,224,256,384,512} symbols.

We can't drop the rfc6234/sha.h header, as openssl/sha.h doesn't give
us the algorithm's block sizes, necessary for HMAC
(QMessageAuthenticationCode).

But we can drop openssl/sha.h. The only reason we included the header
was to get access to SHA<N>_DIGEST_LENGTH, but this is a well-known
value and easily obtained from rfc6234/sha.h as SHA<N>HashSize, so use
that.

Even reduces #ifdef'ery.

Amends d9f9d03fd3.

Fixes: QTBUG-111467
Pick-to: 6.5
Change-Id: Ice19ad8c788fb2828666647cc40abb894cd7af2b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-27 09:10:09 +00:00
Amir Masoud Abdol
863eb576c8 Remove qmake files that provide support for building Qt modules
Repeating the body of the reported bug, "Building Qt modules with qmake
is unsupported in Qt6 and since 6.5's switch to syncqt.cpp broken."

[ChangeLog][qmake] Support for building Qt modules with qmake was
removed.

Pick-to: 6.5
Fixes: QTBUG-110134
Change-Id: Iee5aa5c85f7106bce742df448ec502e6cc039454
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-27 10:10:09 +01:00
Volker Hilsheimer
f75b29fbbd QListView: Reset style after using a temporary proxy
Amends 0242be9060, and removes unwanted
side effect of having a modified style behavior for later functions.

Pick-to: 6.5 6.4 6.2
Change-Id: If3dff0d7ab9e6c6c10e7a92d0a3eaff98fa1457f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-27 10:10:04 +01:00
Oliver Wolff
c912bde52a Windows drag&drop: Use correct window for drag target processing
GetFocus will return the window that currently has keyboard focus. This
is not what we want for drag and drop handling though. Use the window
under mouse and process events for that window when doing the touch/pen
input workaround. If no window is found we fall back to the focus
window. Followup to 31e7790102

Fixes: QTBUG-111149
Pick-to: 6.5 6.4 6.2
Change-Id: Ib8233debc267df0cc19b21c1dc5c6881d018d84a
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-02-27 08:26:49 +00:00
Christian Ehrlicher
6b9977c4ad SQL/OCI: Correctly calculate utc offset string when icu is not available
When ICU is not available, QTimeZone::displayName() does not return a
valid timezone offset string so the OCI driver will get a wrong utc
offset string and inserting a QDateTime will go wrong.
Fix it by creating the utc offset string by ourself (toOffsetString()
inside qdatetime.cpp is static and therefore not accessible for us).

Pick-to: 6.5 6.4 6.2 5.15
Fixes: QTBUG-111275
Change-Id: Ib724d760688614e162246e1e028ee5e004cc9477
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-27 06:23:58 +01:00
Ivan Tkachenko
aa111ada08 Doc: Fix typo in word mnemonic
Pick-to: 6.5 6.2
Change-Id: I7e667e29742d4672c445f8f42a04d81579112213
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-26 21:33:08 +00:00
Marc Mutz
ce955cd3ca QMessageAuthenticationCode: Extract Method setKey() from initMessageHash()
This makes it explicit when we process the key (setKey() called) and
when we don't. That the old initMessageHash() left the key alone if it
already had the correct size was properly hidden in plain sight. The
split makes clearer what's going on.

Pick-to: 6.5
Change-Id: Ib013dbf8b976aa9f564224866091256aa8434cbd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-26 16:27:45 +01:00
Marc Mutz
bdb13a1b31 QSmallByteArray: add sufficient API to make conversion to QByteArrayView implicit
Iterators were missing. Provide a const data() overload to implement
the iterator functions in their natural form.

Pick-to: 6.5
Change-Id: I906013e55fce2effbedba0d283fb4cea3b512fdd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 07:51:47 +01:00
Marc Mutz
a62aa18178 tst_QMessageAuthenticationCode: check that setKey() reset()s
It's documented as such.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7299d289117e52dcefe3c4ab917d7ecad6dd02be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-26 07:51:29 +01:00
Marc Mutz
54a4d4bf76 QCryptographicHash: implement non-OpenSSL3 part of supportsAlgorithm()
Unconditionally returning true is incorrect, not only just since
NumAlgorithms was added in 0411d98192.
The values may have gaps, we might be compiling with SHA1_ONLY, and,
on a language-lawyer level, enums can legally contain values other
than those explicitly enumerated, so give the right answer in all of
these cases.

Pick-to: 6.5
Change-Id: I705d4f759b2572b8b3d1cee18b7939939eedbbac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 07:51:13 +01:00
Thiago Macieira
ec2c27d596 QDeadlineTimer: add a few missing default template parameters
I don't think any of these make a difference because the Duration is an
implied parameter because of the time_point arguments, but this makes
the code match QDeadlineTimer::deadline<T>.

Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17468a41182944ab
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-25 18:14:11 -08:00
Thiago Macieira
81783d02e8 QElapsedTimer & QDeadlineTimer: use NSDMI for their two fields
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd174654d643c05097
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-25 18:14:11 -08:00
Thiago Macieira
cf059ac9ec QThread/Unix: move qt_nanosleep to qthread_unix.cpp
It's the only place that uses it.

Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17465370ac209c2f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-02-25 18:14:11 -08:00
Ahmad Samir
caa21ffc65 tst_benchlibcallgrind: silence a compiler warning
Change-Id: I68cc530fa8eaf941a6ddb7e6987ff37ec270bc4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 03:14:46 +02:00
Samuel Gaist
283cdb0e70 examples: port widget examples to new connection style
Task-number: QTBUG-106893
Change-Id: Ib10fd516fdbeda0087b1c8550ce340acd3973e6b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-25 22:11:57 +01:00
Ahmad Samir
683ddddc6a q_core_unix: move timspec<->chrono helpers from qtools_p.h
Where it has a home with its other timespec/chrono siblings.

Luckily I only needed to change one place in the code, and that source
file already has #include's q_core_unix_p.h.

Change-Id: I783383f958ceccfd6f9210f0b76d35b0f82b7cb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 23:11:54 +02:00
Thiago Macieira
09f5bb9969 QString: make insert_helper take the insertee by const-ref
Not all callers pass a view-type object: there are several call points
passing a QVarLengthArray, which means the value ended up being copied.

Introduced in 67108ef8db. Found by
Coverity scan (CID 404702).

Change-Id: I9671dee8ceb64aa9b9cafffd1742f9cda2131752
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-25 12:31:17 -08:00
Thiago Macieira
938dc34f94 Revert "QLocale: update the disabling of -Wfree-nonheap-object to GCC 10 only"
This reverts commit e76bcaa203.

I managed to reproduce the warning with GCC 12. It only happens
with -flto (LTCG) builds, not in regular release builds.

Change-Id: I6747273300ee51dec05563233017ba0cdf46794a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-25 16:45:01 +00:00
Marc Mutz
06a2101e95 QMessageAuthenticationCode: make finalizeUnchecked() properly noexcept
Replace the QVarLengthArray with HashBlock, an instantiation of
QSmallByteArray. Unlike QVLA, which may allocate memory when
capacity() exceeds Prealloc (not the case here, but could become an
issue with future hash algorithms, we're at 144 now, up from the
traditional 64), QSmallByteArray never throws, and the few Q_ASSERT()s
it contains don't matter, because we use the class' functions
in-contract here.

Requires to add an indexing operator to QSmallByteArray.

Pick-to: 6.5
Change-Id: Ica3656adc190e0141e065287fadc38e0cebce0f4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
57a8c3173d QMessageAuthenticationCode: replace result QByteArray with QSmallByteArray
This minimizes the impedance mismatch between
QCryptographicViewPrivate and QMessageAuthenticationCodePrivate and is
the penultimate step to finally marking QMAC's finalizeUnchecked()
noexcept, too (QCH's has been for a few Qt versions now).

It also enables adding a QMAC::resultView() a la QCH::resultView(),
but that's another commit, as 6.5 is closed for new API.

Pick-to: 6.5
Change-Id: I3fe228585c560d8d32e99e12bba2be21fddaf642
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
289a54a809 QMessageAuthenticationCode: reuse messageHash in finalizeUnchecked()
The only reason why we couldn't before was because we had a view on
messageHash's result, which would have been clobbered when resetting
messageHash for reuse.

Since QMessageAuthenticationCodePrivate now contains
QCryptographicHashPrivate, we gain access to the latter's
QSmallByteArray result, and can just take a copy before reset()ing.

Re-using a QCryptographicHash is faster than creating a new one,
esp. in OpenSSL3 mode, where construction allocates a context while
reset() no longer does.

Pick-to: 6.5
Change-Id: I3bc0454918840a104fd53909e79b6fe21326bfbf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
2a726582b7 QCryptographicHash: give the result container a catchy name
Repeating QSmallByteArray<maxHashLength()> when reusing the type for
QMessageAuthenticationCode isn't DRY.

Pick-to: 6.5
Change-Id: I6d5ca2c14c5ea696a4d28eeb1fb384ff5671d161
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
81ca8aa4ab QMessageAuthenticationCode: make qt_hash_block_size() constexpr
Because we can, and as a preparation for using it to determine the size
of a fixed-size buffer for the HMAC's key material.

Pick-to: 6.5
Change-Id: I4add1115ef6d649baab25a842e1238db8a98bb7d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Marc Mutz
0411d98192 QCryptographicHash: auto-calculate MaxHashLength
Add Algorithm::NumAlgorithms and use it to iterate over all
statically-available algorithms, querying their hashLengthInternal().

This avoids having to statically_assert(<= MaxHashLength) everywhere,
and auto-adjusts the buffer size in SHA1_ONLY builds.

Yes, the extra case labels for NumAlgorithms are a nuisance, but at
least the compiler will remind us when we forget, unlike a missing
static_cast(<= MaxHashLength) that might easily be forgotten.

Adjust the test (which iterates over the QMetaEnum for
QCryptographicHash::Algorithm, so finds NumAlgorithms and tries to
pass it to the hash() function which responds with a
Q_UNREACHABLE(). Only test hashLength() == 0 for that enum value.

Pick-to: 6.5
Change-Id: I70155d2460464f0b2094e136eb6bea185effc9d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Ahmad Samir
10e9687159 Use one common repeatCount() function in QLocale and QDateTimeParser
Change-Id: I4b6554966c4eb2c82f406a17d686982a38610b8c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-25 15:25:30 +02:00
Allan Sandfeld Jensen
93047c71e8 Add special thread pool for Qt Gui
To avoid gui slowdowns due to global pool being blocked.

Fixes: QTBUG-109511
Pick-to: 6.5 6.4 6.2
Change-Id: I4e8d91e8fb0bd2e395072a082e992a3c5d3464ad
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-25 10:54:19 +01:00
Ahmad Samir
a861eea14f QTimerInfo: replace a goto with a lambda
More readable and now we can return earlier in an already long method.

(Patch best viewed in terminal: `git show -W --ignore-all-space` :)).

Change-Id: Ia405cdb91966b993cf7130c662bc1d189ff2c155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:31:20 +02:00
Ahmad Samir
17d36d92fc QTimerInfo: use range-for; use STL algorithms
Change-Id: I7e1b603540a2a2b4d1b12d4dbdba7e9183ee367f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-24 18:31:10 +02:00
Ahmad Samir
2f17a1b4ef QTimerInfo: don't shadow member variable name
"currentTime", which one? the member, a local var or a method arg?!

Change-Id: I7f8269ef15a8a901e47e4f83f8e16f185fe8b8f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-24 18:30:54 +02:00
Ahmad Samir
6754795e54 QTimerInfo: use chrono for time intervals
For VeryCoarseTimer:
   - The code used to convert QTimerInfo::interval to seconds in
     registerTimer(), then convert to milliseconds when creating
     QTimerInfo in registeredTimers(); this is a bit confusing as
     "interval" was sometimes milliseconds and sometimes seconds
     depending on the type of the timer; instead "round" to the nearest
     second while always keeping "interval" in milliseconds (relying on
     chrono doing the conversion)..
   - Add roundToSecs() helper; it behaves like the original code (i.e.
     rounding each 500ms to 1 full second):
   const auto list = {300, 499, 500, 600, 1000, 1300, 1499, 1500, 1501,
                      1600, 2000, 2300, 2499, 2500, 2600};
   using namespace std::chrono;
   for (int dur : list) {
       auto i = dur;
       i /= 500; i += 1; i >>= 1; // Original code

       milliseconds msec{dur};
       seconds secs = duration_cast<seconds>(msec);
       milliseconds frac = msec - secs;
       if (frac >= 500ms)
          secs += 1s;

       assert(i == secs.count());
   }
----

- Don't mix signed and unsigned when doing arithmetic

The next "chrono-first" step would be changing
QAbstractEventDispatcher::TimerInfo::interval from int to
chrono::milliseconds, and adding a virtual
QAbstractEventDispatcher::registerTimer() overload that takes
chrono::milliseconds; neither can be done until Qt7 due to binary
compatibility constraints, c.f.:
https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C++

Task-number: QTBUG-110059
Change-Id: I36f9bd8fb29565b1131afb3cdfc313452f625598
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:30:38 +02:00
Ahmad Samir
39a4cd126f q_core_unix_p.h: use std::chrono for time intervals
Also move some timespec helpers from qtimerinfo_unix.cpp to
q_core_unix_p.h, so that similar functions are grouped in one place.

Change-Id: I817733dd70607a1f4243a9745626f5c9b37ddc2a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:30:29 +02:00
Assam Boudjelthia
738c48244b Android: use FileProvider with QDesktopServices::openUrl()
Allow openUrl() to use FileProvider for opening files that are located
under app scoped paths and that use a file scheme for Android sdk 24 or
above.

[ChangeLog][Core][Android] Add FileProvider support for
QDesktopServices::openUrl().
[ChangeLog][Core][Android] Add AndroidX dependency to Gradle builds
by default since it's required by FileProvider.

Fixes: QTBUG-85238
Change-Id: Ia7403f74f2a8fd4886f74dba72e42b318ef5d079
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-02-24 17:45:10 +02:00