Commit Graph

67635 Commits (56a4e72afa0df24cd0add559bbfc95886b8d4ceb)

Author SHA1 Message Date
Juha Vuolle 56a4e72afa Add few qdoc \targets to QDesktopServices
The targets are linked from qtnetworkauth documentation.

Task-number: QTBUG-125344
Change-Id: I95cc746a2dac4d8a99278c7d3ac5edf4b201a41b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 9b0f58809be68a956fe3cfabce36d8fbb90208af)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 15:15:28 +00:00
Tor Arne Vestbø 1d8ae2799d QAccessibleCache: Generalize macOS-specific hooks to all Apple platforms
These are used from the iOS platform plugin as well, so rename the hooks
to make it clear what's going on.

Change-Id: I701550a189b0047b8c604c9c27986f780aa157d4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c3f1533fba88c2e9fc4ce238f68055e37675292c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 13:42:16 +00:00
Marc Mutz aec1edfe40 qtypeinfo.h: move QTypeTraits part to qttypetraits.h
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.

Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.

Task-number: QTBUG-97601
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b2eb422699118f4ae8370519b4c7bb3fe121beb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 13:42:16 +00:00
Oliver Wolff ea588a8a2b tst_qprocess: Add crash helper for MSVC ARM64
The ud2 intrinsic isn't available for ARM64

Fixes: QTBUG-125436
Pick-to: 6.7
Change-Id: I3f71252c570cf9795de7907fea68f46ffc81211a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1fd965cd2be5e73ab7ab8d1e9b44d77f32182744)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 11:19:01 +00:00
Tuomas Vaarala 8f50ece5fa [QNX] Return Qt::Key_Clear when numpad key 5 is pressed without num lock
Based on the documentation, the numeric keypad key 5 is commonly mapped
to Qt::Key_Clear, when Num Lock is off. Previously the number 5 was
returned also when the Num Lock is off which caused an ui application
being unable to disable the numpad key number 5 when numlock is off.

Fixes: QTBUG-125958
Pick-to: 6.7 6.5
Change-Id: I62f7521376890a201cd11abf78847bcb0eb1752a
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
(cherry picked from commit cc89c4c76567184b2887952dfe44375ff3ebd28d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 10:38:50 +00:00
Ivan Solovev 31e247f9f8 tst_QCompareHelpers::compareWithAttributes(): do not generate deprecation warnings
Some compilers do not respect the

  QT_WARNING_PUSH
  QT_WARNING_DISABLE_DEPRECATED
  ...
  QT_WARNING_POP

incantation, so rewrite the test to use `template <typename X>` as
an Attribute parameter of the macros.
This allows to get rid of annoying warnings when compiling
tst_qcomparehelpers.

Amends de16185068.

Change-Id: I0b3a0f4ad3189d39f5662ce128d5e5f427543393
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit c6feed7e1d8b8ed991a81878c78bb361f038eaf6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-03 19:07:48 +00:00
Ali Kianian 98ecccba8d Add AssetDownloader to QtBase as a static library
Task-number: QTBUG-122550
Change-Id: I97419f27079475784ae05e1150493abc87e1b119
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit cbb2493cf76eaad23315ad1a4676d44d396fafc3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-03 19:07:48 +00:00
Tor Arne Vestbø 6d95a07af0 coin: Make macOS 12 and 13 Tart ARM VMs significant
The last 30 days shows that these configs are stable, so we can
make them significant:

 http://testresults.qt.io/grafana/goto/jBYi1JsSR?orgId=1

The tst_qheif::writeImage test has been blacklisted separately.

Change-Id: Ibe7981bce2db1ec90781d3ea33fe7d4541990aea
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 70ace7ae78d6637c21a646e726caffb36a1968a6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-03 12:57:01 +00:00
Juha Vuolle 52a91ac5b0 Fix JNI Types doc link
Fixes warning: Can't link to 'QJniObject::JNI Types'

Amends: aad13ef59c

Change-Id: I9361afe4745ef33908ea9a29f4543cfe044500d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5bc1bca2dd390180a3af214e82076228be42a4e5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-03 10:28:04 +00:00
Lorn Potter d2fbcc4cfe wasm: fix mic and camera permissions on firefox
For whatever reason, exceptions are raised on Firefox when
checkPermissions is called.,
"'camera' (value of 'name' member of PermissionDescriptor) is not a
valid value for enumeration PermissionName."
and
 "'microphone' (value of 'name' member of PermissionDescriptor) is not a
 valid value for enumeration PermissionName."

so instead of changing to denied when this happens,
just issue a silent warning and continue.

Fixes: QTBUG-125381
Pick-to: 6.7 6.6
Change-Id: I03ee45297d28f4b99cc96f593cf529113747488b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-06-03 11:57:24 +10:00
Lorn Potter 41cb01dc59 Wasm: fix QtVirtualKeyboard crash
Do not try to access non the existent input element when there is no touchscreen,
as we do not use it in that instance.

Fixes: QTBUG-125120
Pick-to: 6.7 6.7.1
Change-Id: Iedac1890d13b348ef12690947779347e3c2f8476
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2024-06-02 22:12:57 +00:00
Edward Welbourne 877e77eced qlocalexml2cpp.py: rework StringData handling of bit-sizes
Move to construction time, instead of passing to each append() call;
the table's field sizes are, after all, the same for all entries.
Add support for larger tables by allowing more than 16-bit indices.

Task-number: QTBUG-115158
Change-Id: I8f1113482e80838c512da6353fa17b9f365f956a
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-06-02 15:26:17 +02:00
Edward Welbourne 69aefa4edf Update C Locale constructor to match others on ids and codes
It was setting *_code='0' for the Any* forms of language, script and
territory; this is wrong, the codes for these are all empty or other
special tokens (like 'und', 'Zzzz', 'ZZ'). The IDs for them are zero,
as an int not a string, but were omitted. Also add the variant
details, for all that they're currently unused, for consistency.

This makes no difference to the generated data.

Task-number: QTBUG-115158
Change-Id: I339d1b201e50e2bbc510758ffbbaae0fa02277d4
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-06-02 15:26:05 +02:00
Edward Welbourne 0c809fc3b5 Derive C locale data from en_US, overriding minor details
The qlocalexml.py Locale.C() had to replicate a whole lot of data that
isn't really relevant to how C differs from en_US and every addition
to what we support required further additions to it. So pass the en_US
Locale object to the pseudoconstructor so that C can inherit from it
and only override the parts where we care about the difference.

Hand-code shortening for short Jalali month names, to match Soroush's
original contribution, and include the narrow forms in the hard-coded
data to keep the generated data unchanged (for now). Note some of the
departures from CLDR; we may want to drop these overrides later.

In the process, convert the mapping from keys to locales to
consistently use IDs for all members of the key, instead of using the
(empty) code value for (as yet unused) variant; it now gets ID 0 and
is consistent with returns from codesToIdNames(). This makes life
easier for the code that now has to construct an en_US key.

Task-number: QTBUG-115158
Change-Id: I3d7acb6a4059daec1bba341fcf015c39c7a6803b
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-06-02 15:25:52 +02:00
Edward Welbourne 5641b17e2f qlocalexml2cpp.py: Make clear that ByteArrayData is always ASCII
The container would be unsuitable otherwise.

Change-Id: I0b0aa22625fbd638bf8409c5ee257f62332d8e05
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-06-02 15:25:45 +02:00
Edward Welbourne 72a7dddc25 QLocaleXML: Improve documentation, tidy up a bit
Omit parentheses round what python will form into a tuple anyway.
Include trailing commas on last entries of tuples so adding future
entries don't drag the existing line into their diffs.
Let the writer's tag-opener handle attributes, if supplied.
Clean up spacing in some doc-strings.
This is all preparation for further changes, to limit their diffs.

Change-Id: I989ae28bbd235b2af9c1d72467d4741c4f1f20ae
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-06-02 15:25:36 +02:00
Edward Welbourne 9534341654 Integrate timezone data into the CLDR-via-QLocaleXml pipeline
Future work shall need the timezone alias data to be synchronized
between the (expanded) locale-independent timezone data and the
(coming) locale-dependent timezone data. The latter shall need to come
via QLocaleXml, hence the former now needs to, too.

This makes no change to the generated data, aside from changing the
regeneration instructions for qtimezoneprivate_data_p.h, to use the
same scripts as locale data, instead of cldr2qtimezone.py, which is
now removed.

Task-number: QTBUG-115158
Change-Id: I47ddd95f6af1855cbb1f601e9074c13f213cd61c
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-06-02 15:25:27 +02:00
Edward Welbourne 4e23dbb742 Add assorted notes and suggestions in util/locale_database/
Change-Id: I22534943f2c9710d501235672811a861a5fd3aea
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-06-02 15:25:21 +02:00
Edward Welbourne b48b4f4d3b Simplify UTC offset ID data by computing the offsets
It's trivial to do - and done when generating our compiled data
tables, so makes no difference to users - but makes the offset list
table simpler. Reformat the list so that the fragment-of-hour offsets
are clearly distinguished from the whole-hour ones.

Change-Id: I6e0ea23dc317542b3256e88492e4073faedef1d7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-06-02 15:25:13 +02:00
Edward Welbourne 08c877a703 Update the utcIdList (now that I've worked out where it came from)
It was originally (without any comment to this effect, either in the
code or the commit message) just the list of offset-zones
corresponding to known Windows zones' offsets, augmented to include
each whole hour offset out to ±14 hours. Absent documentation, of
course, this was not maintained.

Added the four offset zones implied by that, that hadn't been added
when new entries joined the Windows IDs with novel offsets. Check,
after scanning CLDR for Windows data, that this has been kept up to
date. Updated the generated data.

Change-Id: I3cf3932c320876f7f2f74840d8c3951be49cfe70
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-06-02 15:25:07 +02:00
Edward Welbourne 5f63885e84 Update CLDR Windows timezone data to v44.1
The recent change to IANA ID lists extracted for Windows adds new IANA
IDs to various zones and shuffles the order in some cases, leading to
changes in offsets throughout the related tables (and two test-case
that lose an expected entry that was an alias for one of its
others). This is caused by CLDR doing a clean-up of its zone
information, deprecating some old names, combining some synonymous
zones and reversing some aliases to better match the IANA DB. As a
result, some prior expect-fail tests now pass.

The code that reads the tables is insensitive to order after the first
entry in each list; and the first entries only change where they were
CLDR's ID for a zone, replaced by the modern IANA ID, which is what we
should be using. Various aliases are omitted from lists, but can be
looked up via the alias table.

[ChangeLog][Third-Party Code] Updated timezone data from the Unicode
Common Locale Data Repository (CLDR) to v44.1 to match QLocale's data.

Change-Id: I8d89bef7370b93572a3dcf61f6713d4f21963e3d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-06-02 15:25:00 +02:00
Giuseppe D'Angelo 48ab909c5d QDateTime::fromStdTimePoint: remove an unnecessary time_point_cast
The constraint now checks that the result of the clock_cast has a
duration which is convertible to milliseconds, so just do the
implicit conversion, without any cast for the duration.

Task-number: QTBUG-125587
Change-Id: Id2c8232d756318c3e4d33cd7e1556773961a9dba
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-06-02 11:52:11 +02:00
Jens Trillmann 9ec1de2528 Add Identifier role to QAccessible and use it in OS interfaces
* Unify the default identifier creation for QAccessibleInterface on
  all platforms to be the same as the previous identifier on Linux.
  This may change some identifiers on Windows.

[ChangeLog][QAccessible][QAccessibleInterface] Add possibility to
add unique identifier to QAccessibleInterface to give a11y elements
consistent identifiers.

Task-number: QTBUG-123361
Change-Id: I8c42956a4c497e71909d71dcb27bc87433937b69
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-06-01 22:58:20 +02:00
Ilya Fedin 3c93dedc06 Check D-Bus tray availability every time
It could appear in runtime, this allows applications to watch for it
themselves and re-create QSystemTrayIcon as needed.

Task-number: QTBUG-94871
Pick-to: 6.7 6.5
Change-Id: I10678cca4238ec0212c69155c9f22c07755ab1a8
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-06-01 21:50:20 +04:00
Thiago Macieira a98715c127 QByteArrayView: use memmem() to search for substrings
Let's just use whatever your C library provides, on the assumption that
it is optimized. Because it does the memchr() call when the size of the
needle is 1, we also skip the 1-char findByteArray() call.

It's been available on Linux since glibc 2.0, FreeBSD since 6.0, OpenBSD
5.4, NetBSD, Apple OSes, etc. even Solaris. If your OS doesn't have it,
you should ask your vendor to add it or consider upgrading to an OS that
already has it.

The glibc implementation[1] also uses a hashing for short needles and
the Two Way string search algorithm it describes as "a bad character
shift table similar to the Boyer-Moore algorithm" for longer ones. The
FreeBSD implementation[2] (which its man page says came from MUSL) uses
1-, 2-, 3-, and 4-byte search specializations before using the Two Way
search algorithm too.

[1] https://codebrowser.dev/glibc/glibc/string/memmem.c.html
[2] https://github.com/freebsd/freebsd-src/blob/main/lib/libc/string/memmem.c

Change-Id: If05cb740b64f42eba21efffd17d101e24528f7fd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-06-01 11:27:05 -03:00
Allan Sandfeld Jensen e673e5a257 Merge applyGray, applyReturnGray, and apply methods
Combine all into a single flexible apply method.

Also fixes a few issues with RGB colorspace on gray input. Blocking CMYK colorspace on Grayscale and ElementListProcessing RGB on grayscale out.

Fixes: QTBUG-125303
Change-Id: I3987010062fbb5aa708aeb1cc239f3ce9413e34f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-06-01 16:27:05 +02:00
Thiago Macieira 70dd53e3d3 uic: recognize <legal> tag as an alias for <comment>
That is printed at the top of the file and we've used it for the
copyright inside Qt, so just declare an alias.

[ChangeLog][uic] The Qt UI Compiler now accepts a <legal> XML tag to
indicate the copyright of the UI file and other legal terms of use. The
text of this tag will be emitted in the generated code. This tag is an
alias to <comment>.

Change-Id: If3345151ddf84c43a4f1fffd17d15ab77412e289
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-06-01 08:36:42 -03:00
Thiago Macieira d5dd7da3ee rcc: add the ability to output copyrights in the output
According to gnu.org[1]
> When a file is automatically generated from some other file in the
> distribution, it is useful for the automatic procedure to copy the
> copyright notice and permission notice of the file it is generated
> from, if possible.

This commit allows us to add copyright notices to the .qrc files
themselves and additionally have that be output into the generated .rcc
(of which we have a few committed to the repository)

[ChangeLog][rcc] The Qt Resource Compiler now accepts a <legal> XML tag
inside the main <RCC> entry, which can be used to document the copyright
of the resource file itself and other terms of use (even though the file
is probably created by a tool like Qt Creator's resource editor). The
text of this copyright will be emitted in the generated C++ or Python
source code.

[1] https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html

Change-Id: If05cb740b64f42eba21efffd17d00417433f1ee9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-06-01 08:36:41 -03:00
Thiago Macieira 24b1e52a1a QStorageInfo/Linux: reuse the file descriptor
We need it for the ioctl() to get the label and we already have it open.

Pick-to: 6.7
Change-Id: If3345151ddf84c43a4f1fffd17d3f7f1312ca185
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-06-01 08:36:11 -03:00
Thiago Macieira 8836b67778 QStorageInfo/Linux: use the mount ID to match paths to mountinfo lines
Linux kernel version 5.8 added support for the stx_mnt_id field in the
struct statx because "Systemd is hacking around to get it and it's
trivial to add to statx, so...". This allows us to much more neatly
match the lines in /proc/self/mountinfo.

The same kernel version added STATX_ATTR_MOUNT_ROOT so we can tell if a
given path is the mount point of a filesystem. We don't have a need for
that information for now.

We need to retain fallback code for two reasons: first, the user may be
running with an old Linux kernel, in which case we won't get the
STATX_MNT_ID bit set in stx_mask. Second, we may have failed to open()
the path in question, because the user may not have the necessary
permissions.

There's still a race condition because the mount IDs can be reused
immediately after something is unmounted. There's a 64-bit unique mount
ID (available since v6.8) but it's not reported in /proc/self/mountinfo,
so we couldn't us it right now. We can with 6.8's statmount().

Pick-to: 6.7
Task-number: QTBUG-125721
Change-Id: If3345151ddf84c43a4f1fffd17d3f7dbce4ff16b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-06-01 08:36:02 -03:00
Thiago Macieira ad968d3602 QStorageInfo/Linux: re-work the mountedVolumes() check for mounted-overs
Commit ddc39eb3a4 ("QStorageInfo/Linux:
fix mountedVolumes() for paths mounted over") added a clever check that
did stat() on the path to figure out if it was the device that we'd just
found on /proc/self/mountinfo. But if the same device was mounted on top
again, we may have got the wrong answer.

More importantly, since kernel 6.9, btrfs subvolume mounts no longer
report the subvolume's block ID in /proc/self/mountinfo, which would
lead us to conclude every single subvolume has been mounted-over.

So let's revert back to string-matching later lines to see if any is a
parent path.

https://lore.kernel.org/linux-btrfs/2548140.Uh0CODmnKu@tjmaciei-mobl5/T/

Fixes: QTBUG-125721
Pick-to: 6.7
Change-Id: If3345151ddf84c43a4f1fffd17d3d59fef4446dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-06-01 08:36:01 -03:00
Ilya Fedin f6cd286e66 Don't fallback to X11 tray backend on non-X11
This allows to have system tray support on the fly on Wayland at least
where only QDBusTrayIcon is possible and no need to fallback to
QSystemTrayIconSys

Fixes: QTBUG-114439
Task-number: QTBUG-94871
Pick-to: 6.7 6.5
Change-Id: Ic927cde585ef02f9b9ef03f3b6338f35072bef70
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-06-01 10:44:48 +04:00
Thiago Macieira 9b2ae564a5 Remove QT_TERMINATE_ON_EXCEPTION: no longer needed
When Marc introduced them way back in 2012 in commit
c856e37c5f ("Logging: mark qt_assert()/
qt_assert_x()/qFatal() as nothrow"), he said:

> QT_TERMINATE_ON_EXCEPTION, which expands to something like
>   try { expr; } catch(...) { std::terminate(); }
> if the compiler doesn't support Q_DECL_NOEXCEPT

Well, all compilers now support noexcept, so we always had the plain do
{ } while (0) expansion instead.

Change-Id: If3345151ddf84c43a4f1fffd17d27dbc0f100ec7
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-05-31 22:02:06 -03:00
Thiago Macieira 4c12ae7e67 QByteArrayView: inline the char overload of lastIndexOf()
It's just memrchr()... which unfortunately is a GNU extension (picked by
FreeBSD and OpenBSD too), so we need to provide a fallback
implementation for other OSes and bootstrap mode.

By creating a new overload instead of doing the inlining trick, this
gets inlined in QtCore uses as well and has a simpler #ifdef'ery. We
still reach the C library function indirectly, but that's going to be
minimal (and unavoidable) overhead, more than offset by the gain in
accessing an optimized memrchr().

Change-Id: If05cb740b64f42eba21efffd17d0b681bcfe9cf3
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-05-31 22:02:06 -03:00
Marc Mutz 5bf0c3d5d3 QFormDataPartBuilder: allow to override mime-type autodetection
If QT_CONFIG(mimetype) isn't set, this class was silently creating
invalid output. If no mimetype is specified by the user and the type
cannot be deduced then omit the content-type header.

Change-Id: Iff15462b94fa1e992369df26f74b2bd64d523f31
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-06-01 00:14:35 +00:00
Giuseppe D'Angelo c4fc3a74b4 QDateTime::fromStdTimePoint: fix a call to fromMSecsSinceEpoch
The overload taking a Qt::TimeSpec is deprecated; we need to use
the one taking a QTimeZone instead. However I can't just use
QTimeZone because this is inline code in qdatetime.h, and QTimeZone
is only forward declared there. Moving the definition in qtimezone.h is
possible (like it's done for zoned_time), but that is a source break
(requires a new inclusion from users) and also weird (this function
doesn't deal with timezones, why do we need to include qtimezone.h?).

Instead, just add another overload of fromStdTimePoint that takes
precisely sys_time<milliseconds>. As such, it can be always available
even in C++17, and implemented out-of-line.

Even if this is a new symbol, the new commit policy allows the
backport. I also don't think this qualifies as a new feature;
it's a cleanup that we forgot to do (if we had a C++20-enabled
configuration in the CI when we also did the fromMSecsSinceEpoch
deprecation, we would've caught this).

Pick-to: 6.7 6.5
Change-Id: Ica77da291be4bcda2ffc7c164316a2977974c386
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-05-31 23:38:28 +00:00
Shawn Rutledge 12d45d049a Add tst_QMenuBar::pressDragRelease
Test this gesture with both mouse and touch.

Change-Id: I0285e7a17302361893c4b7ed0faf97c4f342814e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-31 16:35:53 -07:00
Shawn Rutledge d06047698c QWindowPrivate::forwardToPopup: fix QMenu touch press-drag-release
QMenu doesn't handle touch events, but depends on mouse synthesis.
QGuiApplicationPrivate::processTouchEvent() calls
QWindow::forwardToPopup(), which sends it to the popup window, which
sends it to QMenu. The inherited QWidget::event() calls
QEvent::ignore(). It's important for forwardToPopup() to return nullptr
when the event is not handled, so that processTouchEvent() goes on to
create the synth-mouse event and send it to processMouseEvent(), which
calls forwardToPopup() again, which QMenu::mouseMoveEvent() handles.
And we also follow the usual pattern that when an event is duplicated
for delivery (as a synthetic event, or just to remap it), the accepted
state of the original event must be updated to reflect whether or not
the cloned event was accepted.

QTabletEvents are handled similarly.

Amends e4ef0f03e6

Change-Id: I0c6c03452a5b952161c9898d84d2c17afa52fc95
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-05-31 16:35:52 -07:00
Volker Hilsheimer 7afff8c16e JNI: remove tech-preview tag from documented APIs
Change-Id: I6493f53c747df16d9b54710627927e60f43edec1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-06-01 00:24:35 +02:00
Volker Hilsheimer 93ae58fd3c Update QJniObject documentation to refer to QtJniTypes
Change-Id: I5d0c27625eac3ef1c619cb591af110b7659b769a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-06-01 00:24:34 +02:00
Volker Hilsheimer aad13ef59c Document the QtJniTypes namespace and related macros
We use them heavily in Qt's Android code, so can be very certain that
they work as advertised. In order to properly document the respective
QJniObject and QJniEnvironment APIs and to move them out of
Technology Preview, we need to have those helpers documented as
well.

Change-Id: Ifd02cbdde892d7db721204eaf6f18ad59c53e8fd
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-06-01 00:24:34 +02:00
Tor Arne Vestbø 9122d826d2 macOS: Present Metal layer with transaction during display cycle
When our Metal layer changes its bounds or contents scale, for
example as a result of a window resize, or moving a window between
screens of different device-pixel-ratios, the layer will be marked
as needing display.

The changes to the layer will then make their way to the screen
as part of committing the root level CATransaction, managed by
the macOS display cycle, which synchronizes the presentation of
the bounds or scale changes to the screen's vertical sync.

By default, presenting a Metal drawable to a Metal layer ignores
any ongoing transactions, so the drawable ends up on the screen
as fast as possible. The downside to this is that the drawable
size or scale may be based on the yet-to-be presented bounds or
scale changes of the layer, as these happen when the display
cycle commits its transaction.

To ensure that the layer properties and content changes in lock
step we can enable the presentsWithTransaction property on the
Metal layer. We do so selectively when the layer is asked to
display, which happens during the display cycle, but not for
update requests (via our display-link).

This would normally be enough to ensure smooth and glitch free
resizing, as long as everything happens on the main thread.
Unfortunately, the [MTLCommandBuffer presentDrawable:] API we
use to present a Metal drawable when rendering in response to
update requests is actually scheduling the presentation on a
secondary thread com.Metal.CompletionQueueDispatch queue. The
result of this is that the presentation on the secondary thread
might race against a presentation on the main thread initiated
from the display-cycle, presenting too early, or overwriting
the layer's content with stale content.

To fix this we use [MTLCommandBuffer addScheduledHandler:]
explicitly instead, which lets us control what happens during
the presentation on the secondary thread. We then add a lock
to the layer that we lock as soon as the layer needs display,
and use this lock to skip presentations that should not step
on the toes of the display-cycle presentation. Once the display
cycle ends we unlock the lock.

The lock is a read-write lock, to ensure we prioritize the main
thread's display-cycle over any other presentations in case of
contention. We also defer update requests if we detect that the
lock is held, as there is no point in rendering a frame if we
are likely not going to present it. Doing this also prevents
the update-requests from starving the main thread from getting
its drawables.

The final case we have to account for is where the display
of the layer during the display-cycle is implemented by asking
another thread to do the rendering, as is the case with the
Qt Quick threaded render loop. In this case the main thread
is blocked while it waits for the render thread to complete
drawing and presenting a frame. But the actual presentation
of the Metal drawable still has to happen on the Main thread
for it to be part of the display-cycle's transaction.

To ensure the latter, we move the presentation of the drawable
to a block, that we schedule to be run on the main thread. Once
displayLayer is done with the expose event it processes the
deferred presentation, on the main thread.

Finally, to mitigate Qt Quick's threaded renderer running
animators without any coordination with the main thread, and
thereby starving it from drawables, we expose the inLiveResize
property on QNativeInterface::Private::QCocoaWindow, so that
the threaded render loop can step back during live resizing
and drive animators via the main thread's update request.

The QT_MTL_NO_TRANSACTION environment variable has been
kept, as an opt-out in case the new machinery breaks somehow.
It will disable the locked Metal layer, and all code paths
that depend on it.

[ChangeLog][macOS] Metal layers are now presented with
transactions during the display-cycle, which should fix
issues with the layer's content being out of sync with
the layer bounds or scale. If this causes issues, set the
QT_MTL_NO_TRANSACTION environment variable to opt out.

Fixes: QTBUG-107198
Fixes: QTBUG-114351
Change-Id: I765e11051c3a4d44b60ff10e787589feec8917a0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-06-01 00:24:34 +02:00
Tor Arne Vestbø eb4cb71925 widgets: Use per-surface-format RHI support and compositor
The RHI support and compositor in QPlatformBackingStore were
tied to the surface format of the top level window owning
the backing store.

This meant that inserting an RHI-enabled widget (QRhiWidget,
QOpenGLWidget, QQuickWidget, QWebEngineView) into the widget
hierarchy required recreating the top level window with a
matching surface format that could support the RHI composition.

It also meant that we could not have two RHI enabled widgets
with different surface format requirements (Metal and OpenGL
for example) in the same top level widget hierarchy.

The recreation of the window had various visual side effects,
such as temporarily switching out of full screen state, or the
widget rendering a frame of black, as well as more serious
problems such as not correctly restoring the window geometry.

In addition, if client code had pulled out the winId() of the
window, and did not invalidate these references on window
destruction via QEvent::WinIdChange or QEvent::PlatformSurface,
the client would reference stale window handles. Although
this is a programming error (QWidget::winId() specifically
mentions this requirement), we should avoid recreation if
we can.

We were already supporting flushing the backingstore to
individual native child widgets, but always did so via a
single RHI managed by the platform backingstore. By
expanding QPlatformBackingStore to keep one set of RHI
support and compositor per surface format, we can refine
the logic in QWidget and QWidgetRepaintManager to not
require recreating the top level. Native child widgets
are then flushed independently, including any RHI textures
and raster content that overlaps with the widget.

We still assume that a single RHI support and compositor
can be be used for multiple windows, as long as those
windows have the same surface format. In the future, if
needed, we can refine this to use one set per surface
format e.g.

Fixes: QTBUG-119221
Fixes: QTBUG-121181
Fixes: QTBUG-120096
Task-number: QTBUG-115652
Task-number: QTBUG-108344
Task-number: QTBUG-113557
Task-number: QTBUG-119309
Change-Id: I2635ed3d20c2fb76eab3b8130007dd656a0b93e5
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-06-01 00:24:34 +02:00
Shawn Rutledge e4ef0f03e6 Move popup management from QApplication to QGuiApplication
We need to be able to have true popup windows in Qt Quick and Controls,
including handling the press-drag-release sequence to select one entry
from a menu or combobox. After the mouse press, a new window is created.
On some platforms (such as xcb), the new window gets window system grabs
of both keyboard and mouse (QApplicationPrivate::openPopup() calls
grabForPopup() and it actually works); while on others, the pre-existing
window continues to get the whole sequence of mouse events until the
release. In the latter case, Qt needs to forward events from the
original window to the popup. Until now, the list of popups was
QApplicationPrivate::popupWidgets.

Now we track the open popups as a list of QWindows rather than QWidgets,
in QGuiApplicationPrivate::popup_list, and add a set of static functions
to manage that list. Functions such as QApplication::activePopupWidget()
QApplicationPrivate::openPopup() and closePopup() are rewritten to make
requests to QGuiApplicationPrivate.

276943c8b7 made
QGuiApplicationPrivate::closeAllPopups() virtual. That is now reverted,
because we're putting QGuiApplication in charge of popup management
and trying to minimize widget-specific behavior. So far,
QApplicationPrivate::closePopup() is still overridden to take care
of focus changes.

So far, QtGui does not take care of closing popups when the user
clicks outside: the active popup window gets those events, and needs
to close itself if the click occurs outside. An attempt to move this
logic raised some issues with legacy widget test cases.

Using a touchscreen to press on QMenuBar and open a QMenu, drag to
a menu item and release, is temporarily broken for now. The plan is
to fix it in a subsequent patch.

Task-number: QTBUG-68080
Task-number: QTBUG-69777
Change-Id: I02b5034987b5ee8909917d305f414c8b0db9c7f5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-31 10:40:31 -07:00
Eskil Abrahamsen Blomfeldt 1bc78f7739 Introduce flag to use typographical line metrics for fonts
For backwards compatibility reasons, font files have multiple different
ways to specify vertical metrics (ascent, descent, etc.).

For OpenType, the main two are the usWin* and sTypo* metrics in the OS/2
font table. The usWin* metrics are typically used as the clipping bounds
of the font (so no character will ever draw outside these bounds). The
sTypo* metrics thus make it possible to specify a different set of
metrics for use in text layouts which is smaller than the clipping
bounds (or bigger), so that you can have fonts where some characters
overlap with preceding or subsequent lines.

However, GDI (and thus many applications) use usWin* also for line
spacing, which lead to the sTypo* metrics being untrustworthy in some
fonts and later to the introduction of the USE_TYPO_METRICS in the OS/2
table version 4. The idea of this flag is to tell the font system that
the sTypo* metrics can be trusted and should be preferred over the usWin*
metrics.

But the OpenType specification states that sTypo* metrics should *always*
be preferred and modern font systems such as FreeType and DirectWrite
will respect this. This in turn has lead to fonts where the
USE_TYPO_METRICS flag is untrustworthy instead, i.e. the sTypo* metrics
are preferable, but the USE_TYPO_METRICS has accidentally not been set.

Qt trusts the USE_TYPO_METRICS flag and uses the usWin* metrics whenever
this is unset. Since QFontMetricsF::height() (ascent+descent) in this
case includes the line gap metric, a lot of components have been written
to use it for size without adding any margins over the text. So changing
the default now would break a large amount of components, including the
ones in our own Windows style.

Most fonts should work correctly, by setting the USE_TYPO_METRICS flag
if the typo metrics are intended to be used. For those that do not, we
introduce a PreferTypoLineMetrics style strategy.

[ChangeLog][QtGui][Fonts] Added QFont::PreferTypoLineMetrics for using
the recommended line spacing metrics of the font, even if the font has
not explicitly set its USE_TYPO_METRICS flag.

Fixes: QTBUG-125585
Change-Id: Ib2f7df404fe719186d78733bda26da712f1ab85a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-05-31 19:30:53 +02:00
Volker Hilsheimer d41ae1a9a8 JNI: Fix static_assert for type registrations
Types signatures have to start with either "[L" (array of class)
or "L" (just class), and end with ";". Only "[" (array of primitive
type) makes no sense, esp since we also require a terminating
";".

Change-Id: Iea9ce992c31a34639016c967f813ebf9343c6978
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-05-31 19:30:53 +02:00
Christian Ehrlicher 102670a82e SQL/QSqlRecord: rework QRecord::indexOf(QStringView)
Move it to the private implementation to be later used as a template
when switching to QAnyStringView.

Change-Id: If9977711757677546cfc058602ada9f54b978509
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-31 19:30:53 +02:00
Christian Ehrlicher 5a7c2cbabb QSqlDatabase: Rename currentThread() to thread()
... to be in sync with QObject naming.
This amends b4c63b89df.

Change-Id: I25301f65aa880205d8c0cfd6f4bfa9fdba34a01c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-31 19:30:53 +02:00
Christian Ehrlicher 60061f679c QIcon: don't load image twice
QIcon::addPixmap() creates an icon engine when not yet available. During
the initialization, the filename of the image is already passed to the
icon engine and some (e.g. svg icon engine) already loads it. Afterwards
the image is loaded again with addFile(). Avoid this by checking if the
ctor of the icon engine already loaded the file and don't call addFile()
afterwards in this case.

Fixes: QTBUG-8151
Change-Id: I9289f17e5d703c08a82ce51ce8bded70feb6f82d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-31 19:30:52 +02:00
Christian Ehrlicher 6843e5d26d QIcon: remove redundant nullptr check
Remove a redundant nullptr check found by CodeChecker.

Change-Id: I03327475e1df8de27459457fc8fc2c66592889ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-31 19:30:52 +02:00