Commit Graph

58844 Commits

Author SHA1 Message Date
Shawn Rutledge
e2f895db2e Blacklist tst_Gestures on macOS ARM
Test causes integrations on macOS to fail.
Temporary solution, fixing of auto test required.

Task-number: QTBUG-108402
Change-Id: I9ceef8ec425cdd5131bce0cfffcb4daf739e674d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-16 12:44:43 +01:00
Christian Stenger
84cc3b3cad Widgets: Fix high dpi hover icon
Amends aa5a595a98.

Pick-to: 6.4
Change-Id: I4ba7744e70d7d9de2d0b562a67b3828a72940306
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-16 10:47:31 +00:00
Martin Walch
1fee7adccf Scale BMP color samples with periodic bit expansion
Scale samples up by periodically repeating the bit pattern of each value to fill
up the lower bits instead of padding them with 0.

Vice versa truncate samples that exceed the bit depth of QRgb.

Change-Id: I777519e359932f52e54a33073a1ff297a76f620c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-11-16 08:36:18 +02:00
Thiago Macieira
9f64065c1f QString: merge the two toIntegral_helper() back to a template
We go from non-template toInt/toLongLong/etc. to template
QString::toIntegral_helper<T>, then to non-template
QString::toIntegral_helper, then back to template ::toIntegral().

I could maybe use QtPrivate::to{Signed,Unsigned}Integer, which operate
on QByteArrayView, but its use of QtPrivate::ParsedNumber as a return
type is slightly worse.

Change-Id: I3d74c753055744deb8acfffd1723cbc567837483
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-15 13:47:00 -08:00
Thiago Macieira
30c491f3b2 QString: mark inline to{U,}LongLong() for inlining in Qt 7
The original implementation of the toIntegral_helper() called these two
functions, before we added the out-of-line non-template
toIntegral_helper() overloads taking QStringView for Qt 5.15 in commit
f1cbc3c9d2. They should have been inlined
in Qt 6.0, but no one noticed this.

Change-Id: Id8e48e8f498c4a029619fffd172795aaba2d815b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-15 21:47:00 +00:00
Ben Fletcher
85a1663eb1 RHI: Add support for 1D textures
Support for 1D textures on Vulkan, OpenGL, Metal, and D3D.

Change-Id: Ie74ec103da9cfcbf83fa78588cf8cfc1bd6e104f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-11-15 11:36:18 -08:00
Tor Arne Vestbø
a47c7a9826 macOS: Add dialog helper for native message boxes
The native implementation uses NSAlert, making a best effort to map the
QMessageBox properties to the native dialog, falling back to the cross
platform non-native dialog if the discrepancy is too big.

The initial implementation focuses on the current state of the
native dialog helper "protocol", but there's room for improvement
here, which would allow even more dialog types and properties to
be native.

[ChangeLog][macOS] Message boxes such as QMessageBox now follow
the platform look and feel by using native dialogs if possible.

Change-Id: I4da33f99894194a7b301628cd1fbb44d646ddf18
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-15 20:36:17 +01:00
Mårten Nordheim
da0587c43a QNetworkInformation[win]: Capture another potential exception
As reported by a user.

Fixes: QTBUG-108382
Pick-to: 6.4
Change-Id: Ic94c65d533edd84c8fda5d713d9579a9492b88ae
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-15 17:12:33 +01:00
Morten Sørvig
64bb83f882 win: resolve theme fonts at 96 dpi
This code became out of sync with the changes to the
LOGFONT_to_QFont() implementation introduced in edb00660.

After that, LOGFONT_to_QFont() on longer adjusts the font size
according to the DPI for the primary display. This means that
the the code should also not get font metrics from the first
display, but instead get metrics at 96 DPI.

Fixes: QTBUG-105857
Pick-to: 6.4 6.2
Change-Id: I5974a77593e1944d889a45a352923fb9aa9a0dec
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-11-15 14:57:57 +00:00
Santhosh Kumar
2991c66b75 Apply system background color for top level window
Repaint top level window with system background color when it shows up
first time. The system background color will be affected by dark or
light mode settings in windows

Fixes: QTBUG-106583
Pick-to: 6.4
Change-Id: I9205335540e74e90bb068e30fc3d4db037fd580f
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-15 12:28:50 +01:00
Tor Arne Vestbø
0d517a1352 sharedmemory example: Handle QSharedMemory::AlreadyExists by attaching
Not all platforms clean up the shared memory entries on exit, so the
example needs to handle that case, by attaching instead, as documented.

Change-Id: Ifbcf92d0fad429caf30710bd8a344831cb0d859c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-15 12:27:43 +01:00
Tor Arne Vestbø
5a36ee7028 sharedmemory example: Show error string when failing to create shared memory
Change-Id: I27edc27aec742e1e34c060e48810c4cfba096ee8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-15 12:27:41 +01:00
Tor Arne Vestbø
523496984c QMessageBox: Reflect native dialog visibility via QWidget state
When a QMessageBox has a native backend we want the QWidget state of
the dialog to still reflect whether the dialog is visible or not,
as this is used by various features of QMessageBox, such as resolving
the default escape button, for example.

It is also key to being able to test the dialog, since the auto test
relies on the observable widget state, and being able to send key events
to the widget to trigger hiding of the dialog.

The other  QDialog subclasses with native dialog backends handle this
by showing the native dialog, and then setting Qt::WA_DontShowOnScreen
before calling QDialog::setVisible(), which results in the widget
state being "correct", but not showing any widget-based dialog.

QMessageBox however, did not implement setVisible(), and relied on
the QDialog implementation, which does not contain similar logic.

Ideally we want to clean up these overrides of setVisible(), and let
QDialog handle Qt::WA_DontShowOnScreen for all native dialogs, but
in the meantime we teach QMessageBox to do the same trick as the
other dialog subclasses.

Task-number: QTBUG-108153
Change-Id: I44c67cc9cd89660a703883bd57f351df70d7bdd3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-15 12:27:39 +01:00
Tor Arne Vestbø
5827ee5ffc QMessageBox: Resolve button title from button role if title is empty
Our tst_QMessageBox tests exhibits many cases of adding a button
to a message box without a specific title, e.g.:

  QPushButton *button = new QPushButton;
  msgBox.addButton(button, QMessageBox::DestructiveRole);

This results in buttons without a title, which for a native backend
may be an error. We mitigate the issue by resolving a default button
title based on its role.

Change-Id: Ib8a15818a83021771793ea85a5f782690fe677ec
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-15 12:27:37 +01:00
Tor Arne Vestbø
27f0854813 macOS: Ensure NSApp initialization without relying on event processing
When processing events without QEventLoop::EventLoopExec we can not rely
on [NSApp run] for running the native run loop. This can happen e.g. when
running a dialog, or when processing events manually via processEvents().

Unfortunately, AppKit relies on at least one call to [NSApp run] for doing
critical initialization of NSApplication, so when we end up spinning the
native runloop via other means, we still need to ensure we pass through
[NSApp run] at least once.

Doing so in a way that relies on our own runloop sources firing and
interrupting the NSApp run is fragile though. For example, the logic
added in bffbfc5b33 to avoid live locks
in CFRunLoop by skipping out event runloop source when processEvents()
is called manually will also result in the [NSApp run] never being
stopped.

To fix this we use a dedicated runloop block instead, where we
explicitly call [NSApp stop:] when first entering the runloop.
In addition we ensure that none of our sources will process
events, so that we don't end up recursing into a runModal
or similar call until after we've initialized NSApp.

Change-Id: I137df46d5fa4105cdc39fe74b6c12275cfd46127
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-15 12:27:33 +01:00
Mikolaj Boc
c56bd31f23 Always export and link in JSEvents and specialHTMLTargets
The two symbols are linked in & exported by using a publicly
visible symbol emscripten_set_wheel_callback. To actually link it,
but avoid calling it, a volatile false boolean flag is used in a
guarding if.

This should ideally be done by setting DEFAULT_LIBRARY_FUNCS_TO_INCLUDE,
but a cmake bug (see QTBUG-108444) is preventing this.

Fixes: QTBUG-108423
Task-number: QTBUG-108444
Change-Id: I6b0406d1059dcec63b3942468e210c53292ffe90
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-11-15 12:19:47 +01:00
Lucie Gérard
ea7a3105de Use SPDX license identifiers
Amends commit 05fc3aef53.
Some files were still missing.

Task-number: QTBUG-67283
Change-Id: I78b3cbf31138192805b7e186337c6fda4ac844aa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-15 07:50:17 +00:00
Samuel Mira
35cd0db935 Android: Skip/blacklist remaining tests for emulator bump to API 24
Skip on crashing tst_qvulkan test
Blacklisted completer_data on qfiledialog
(8d76c5af51 should have been enough but
it is still failing)

Task-number: QTBUG-108328
Task-number: QTBUG-108329
Change-Id: Iad5573af60cca16d16ba0462293e276186e25653
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-11-15 01:01:54 +00:00
Eskil Abrahamsen Blomfeldt
6fa2ee7f4a Fix crash when resetting a QShader
shader = QShader() would crash because qAtomicAssign() requires that
the other's d-pointer is non-null. Follows pattern from other usages
in Qt.

Pick-to: 6.2 6.4
Fixes: QTBUG-108121
Change-Id: I57d25a804340839d03f9dadcbd44e956fb259c30
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-11-14 11:05:48 +01:00
Laszlo Agocs
244daf4cfc Fix rhi flush eval perf. and native window problems
This effectively reverts a4a51f6a64
while solving the problem that change intended to fix by an
alternative approach: Swap the order of checks for rhi-based
flushing. Checking the widgets' wishes first was a mistake.  We should
first check what is forced, e.g. via the env.vars.  Then only move on
investigating the child widget hierarchy if there was nothing specific
requested.

This way having a QOpenGLWidget in a window and running with
QT_WIDGETS_RHI=1 QT_WIDGETS_RHI_BACKEND=vulkan will prioritize the
forced request (Vulkan) and so the QOpenGLWidget will gracefully not
render anything while printing the expected warning to tell what's
going on.

The expensive recursion plaguing the construction of larger widget
hierarchies is now avoided, that should no longer take seconds due to
walking the entire widget hierarchy of the top-level window every time
a new widget is added to it.

However, this then uncovered a set of problems concerning native child
widgets. The repaint manager seems to have an obvious mistake where
the usage of rhi (and so textures and whatnot) is decided based on
'widget' (which is either a top-level or a native child) instead of
'tlw' (which is the top-level with the backingstore). The usesRhiFlush
flag only really matters for a real top-level, not for native child
widgets.  The rhi-based flushing is tied to the backingstore, and the
backingstore comes from the top-level widget.

Finally, make the qopenglwidget autotest to actually exercise
something when it comes to QOpenGLWidgets (or their ancestors) turned
native.  The original code from a long time ago does not really test
native child widgets, because it turns the top-level into native which
is quite superfluous since the toplevel is backed by a native window
(and a backingstore) anyway.

Pick-to: 6.4
Task-number: QTBUG-105017
Fixes: QTBUG-108344
Fixes: QTBUG-108277
Change-Id: I1785b0ca627cf151aad06a5489f63874d787f087
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-14 11:05:48 +01:00
Michael Weghorn
092bbc9ad3 a11y: Implement QAccessibleSelectionInterface for item views
In QAccessibleTable's model, cells (rather than rows or columns)
are direct children of the table and therefore items handled in
the selection, so forward/make use of the corresponding methods
that handle cells.
(In QAccessibleTable::select and QAccessibleTable::unselect,
cast the child cell to QAccessibleTableCell*, as is already
done in QAccessibleTable::indexOfChild and
QAccessibleTree::indexOfChild.)

This can be tested e.g. by calling the methods from the
AT-SPI Selection interface using Accerciser and the
"interview" example
(qtbase/examples/widgets/itemviews/interview/interview).

Change-Id: Ic650a8a01b56653cae4f2cb26e28aed4dc566a7e
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-11-14 08:36:45 +01:00
Eirik Aavitsland
5d95205bae PDF writer: implement support for document internal links
QPdfEngine already supported links to external URIs, but not internal
links for navigation in a document.

For internal links, PDF supports "named destinations" instead of
direct coordinates. That way, we avoid the need for a two-pass
implementation. Instead, we just store the name and position of all
anchors as we enounter them. At document finishing time, we export the
list of named destinations in a PDF "name tree" structure.

The PDF named destinations feature uses the same main catalog item
("Names") as the attached files feature. Hence, this commit must
slightly change the implementation of file attachment support also, so
that the structure supports both. Now, we always add a reference to a
Names object in the catalog when we start the document. When we
finish, we write that object, making it reference the attached
files-structure and/or the named destinations-structure, as needed.

Fixes: QTBUG-83458
Change-Id: I9c43e7b423062d3f21965ab8a0d81a53c4dd72cb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-13 09:47:22 +00:00
Lorn Potter
a9f94d078a wasm: unblock virtual keybaord
QtVirtualKeyboard can be used for non touch apps as well. We were not
taking this into consideration and only allowing touch devices to
access it.

Pick-to: 6.4
Change-Id: I17fcb360b6655ace4fba7447eb85561ba75338a5
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-11-13 15:19:29 +10:00
Michael Weghorn
ece2feee03 a11y atspi: Bridge newly introduced QAccessibleSelectionInterface
This bridges the newly introduced QAccessibleSelectionInterface
to AT-SPI by exposing the AT-SPI Selection interface for
objects implementing QAccessibleSelectionInterface and
implementing the methods of the AT-SPI Selection
interface.

Fixes: QTBUG-105909
Change-Id: Ia05cef6c7dad8675ba8573f662f4338d301cf0e3
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-11-13 01:46:14 +01:00
Alexey Rochev
c083cf9309 Core: always link with CMAKE_DL_LIBS
`dlopen` feature is used in qlibraryinfo.cpp without `library` feature.
Change condition that adds libdl library to make sure that we can build without `library` feature.

Pick-to: 6.4
Change-Id: I5051e6b2e0a8daae5f7e269ed8980df99ecaa192
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-12 19:30:06 +03:00
Ville Voutilainen
8a11f16dc0 Fix QAnyStringView build with GCC 13
The problem is caused by GCC 13 having an intrinsic for is_convertible,
and that (correctly) checks for incomplete types. We then manage to
trigger the instantiation of the QAnyStringView converting constructor from isUtf16 etc.,
and that triggers the enable_if and is_convertible. The fix is to move
the Tag definition earlier, and to eagerly SFINAE away the Tag type so
that the converting constructor rejects it. Otherwise, the converting
constructor is considered a candidate for comparisons of Tags, and gets
instantiated for overload resolution.

Fixes: QTBUG-108136
Change-Id: I9b0c0f7ac771cdbf6a9c35a3d3b0ea01b88b970e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-11-12 03:10:16 +02:00
Mikolaj Boc
2fd4d0586f Call qtUpdateApi on module as expected
The qtUpdateDpi function is a module function, not a scope function
(regardless of it being window-scope self or QtLoader-scope self).
Therefore it should be executed with module as this.

Fixes: QTBUG-108112
Pick-to: 6.4
Change-Id: Ib4604a43dbdd0caa114d3d892ea97b5ee4c9a9a8
Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-11-11 19:31:30 +01:00
Marc Mutz
67fe8f709f Remove QSpan typedef
It's in the way of the planned QtCore std::span reimplementation of
the same name.

Task-number: QTBUG-108124
Change-Id: I55d9391d72644c02e4e4143f4ad2f6756404dcc7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-11 16:48:51 +00:00
Marc Mutz
660d4a0131 Expand QSpan typedef to underlying type QT_FT_Span
This frees up the QSpan name for the planned QtCore std::span
reimplementation, also called QSpan.

This is binary compatible because QSpan was just a typedef and because
it's all private API.

Task-number: QTBUG-108124
Change-Id: I3b5c1ea82673934e2d1eb490fddeae3f8e6a6ea3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-11 16:48:51 +00:00
Axel Spoerl
efb7463656 Add comment to tst_QWidget::saveRestoreGeometry() for debugging
saveRestoreGeometry() somtimes creates a 29px offset when debugged in
Qt Creator, which makes the test fail.

This patch adds a code comment to make developers aware of this fact.

Pick-to: 6.2 6.4
Change-Id: I920bd02eb7543faf8b25a0a242b888f3a3745e2a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-11 17:48:51 +01:00
Marc Mutz
7350480519 [doc] QRasterPaintEngine: remove docs for QSpan
Nothing in this class uses it, so there's no reason to document the
typedef. It will just confuse both the compiler and the user when we
add QSpan (a std::span implementation).

Pick-to: 6.4 6.2
Task-number: QTBUG-108124
Change-Id: Iff0249d2e12a05fca15998a046a0b1bf607b60be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-11 16:48:51 +00:00
Axel Spoerl
99aadcad5e Stabilize flakiness in tst_QWidget::multipleToplevelFocusCheck()
multipleToplevelFocusCheck() occasionally failed on XCB because
QApplication::activeWindow() was nullptr immediately after
qWaitForWindowActive() returned true.

This patch replaces QCOMPARE on QGuiApplicaiton::activeWindow() with
QTRY_COMPARE in order to continue spinning the event loop until the
condition has been met. It adds QWidget::activateWindow after show()
to ensure focus is acquired also when another window has received
focus in the meanwhile.

Pick-to: 6.2 6.4
Change-Id: If84eb8b77c5a6b16af271334a1fe5eb92c05644b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-11 17:48:51 +01:00
Michael Weghorn
9d16d5e224 a11y: Add new QAccessibleSelectionInterface
This adds a new QAccessibleSelectionInterface
that implements support for handling selections,
both retrieving information about the current selection
as well as modifying the selection, thus providing
the necessary foundation for exposing selections
to assistive technology.

This is similar to AT-SPI's Selection interface [1],
but uses QAccessibleInterface pointers instead of
child indices as parameters for methods.

Bridging this newly introduced interface to AT-SPI
will be done in a follow-up change.

The concept for selection handling in Microsoft's
UI Automation looks similar, so bridging this to the
corresponding UIA interfaces ISelectionProvider [2],
ISelectionItemProvider [3] and ISelectionProvider2 [4]
should also be reasonably straightforward.

At this point, this is only meant to be used for
handling selection of direct children as is the
concept in AT-SPI's Selection and presumably
in UIA as well. (The ISelectionItemProvider and
ISelectionProvider doc speaks of "child controls
of containers" etc., but doesn't explicitly mention
that this is only for direct children or whether
grand children are also allowed.)

(The proposed API itself could
also be used to support selection of objects
that are no direct children, but the practical
use of that is unclear and it would make mapping/
bridging to platform a11y layers tricky.)

[5] demonstrates a sample implementation of the
QAccessibleSelectionInterface for the Qt-based
UI variants of LibreOffice (screencast that
shows the use of the interface attached to
QTBUG-105909).

This interface is marked \preliminary until:

1. There is a working a11y bridge for macOS/VoiceOver
2. There is a working a11y bridge for Windows/UI Automation
3. There is a working a11y bridge for linux/AT-SPI
4. There is at least one implementation (e.g. QAccessibleTable)
   that implements it successfully (second candidate:
   Qt Quick TableView [6])

[1] https://lazka.github.io/pgi-docs/Atspi-2.0/classes/Selection.html
[2] https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-iselectionprovider
[3] https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-iselectionitemprovider
[4] https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-iselectionprovider2
[5] https://gerrit.libreoffice.org/c/core/+/138750
[6] https://doc-snapshots.qt.io/qt6-dev/qml-qtquick-tableview.html

[ChangeLog][QtGui][QAccessibleSelectionInterface] Added new
preliminary QAccessibleSelectionInterface that can be used to expose
selections to assistive technology.

Task-number: QTBUG-105909
Change-Id: If77beacd94fa3eb663f0fbb2373f12382bab2ee3
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-11-11 17:48:51 +01:00
Axel Spoerl
a45a1b8674 Stabilize flakiness in tst_QWidget::raise()
The test function raise() occasionally failed because of unexpected
paint events being counted.

This is due to a QTRY_VERIFY returning after consumption of the first
paint event. If more than one paint event got posted, it will be
delivered and counted when no more paint events are expected.

This patch ensures that all paint events are consumed before resetting
the count and expecting no more paint events.

Fixes: QTBUG-68175
Pick-to: 6.2 6.4
Change-Id: I3e91a34e851da4bd01c7429e824d2b9101077a06
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-11-11 17:48:50 +01:00
Eike Ziller
436467134e Doc: Add a dark offline CSS
Which can be used by Qt Creator and Assistant.

Task-number: QTBUG-97125
Task-number: QTCREATORBUG-26557
Change-Id: I03e5ac0a15f84101c73887724693e9eb27670754
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-11-11 18:48:50 +02:00
Tor Arne Vestbø
b2de858a8c QColorDialog: Account for native dialog helper not being able to show
The color dialog implementation lazily initializes the widget hierarchy,
so that they are not created if we're using a native dialog. But unlike
QFileDialog, which does the same, QColorDialog failed to handle the case
where the native helper could not show a native dialog.

We now correctly lazy initialize the widget hierarchy if the native
show fails.

The WA_DontShowOnScreen state management has been left out, as it
needs some general refactoring. This patch doesn't fix, or regress,
any logic related to WA_DontShowOnScreen.

Task-number: QTBUG-108153
Change-Id: Icbd506617a2fe302bb61aab977e7c8ea4bd64878
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-11 17:48:50 +01:00
Tor Arne Vestbø
c1088d493e QMessageBox: Don't add details button to native dialog helper
The "Show Details..." button is not plumbed in any way to the native
dialog, so when added to a native dialog it will just result in the
dialog being dismissed, instead of revealing any extra content in
the native dialog.

Both the iOS and Android native message dialog implementations add
the details text directly to the dialog, without any action to
explicitly reveal it.

Task-number: QTBUG-108153
Change-Id: I92e00c59b7836f633be44caebd534a47ac58be00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-11 17:48:50 +01:00
Tor Arne Vestbø
b7f621ccad QFileDialog: Decouple nativeDialogInUse from QPlatformDialogHelper
The QDialogPrivate::nativeDialogInUse member is used to track whether
a native dialog will be used down the line when the dialog is shown,
or if a native dialog is actively showing or has been shown once.

The former case applies to QFileDialog and QColorDialog, which both
set nativeDialogInUse based on the result of creating a platform
dialog helper in Q(File|Color)DialogPrivate::init(), and then use
that information to avoid creating a widget hierarchy if not needed.

The latter case applies when the native dialog is attempted to be
shown(), where failure to show the native dialog results in the
nativeDialogInUse member being set to false.

The QFontDialog and QMessageBox subclasses do not rely on the former
mechanism, and will only have nativeDialogInUse set to true if the
native dialog has been actively shown at least once.

The QPlatformDialogHelper on the other hand, tracked by the member
QDialogPrivate::m_platformHelper, does not map 1:1 to the state of
nativeDialogInUse, as in the case of QPlatformFileDialogHelper
there is also functionality in the helper to give hints to the
widget-based non-native dialog on how to behave. As a result,
we can have a valid m_platformHelper, but with nativeDialogInUse
being false.

To decouple this and simplify the code we let QFileDialog::setOption()
reset the nativeDialogInUse based on QDialog::DontUseNativeDialog,
just like QColorDialog does, and let QFileDialogPrivate::createWidgets()
proceed without having to delete the platform helper, which would
otherwise be necessary to reset nativeDialogInUse.

The only side effect of this is that a widget-based non-native
dialog will still have a QPlatformFileDialogHelper alive, but
since this dialog is not going to be shown this should not be
an issue in practice.

Task-number: QTBUG-108153
Change-Id: I96af6cfa715717c0907fe840aa86d4e5b280d54c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-11 17:48:50 +01:00
Tor Arne Vestbø
fb0a96f185 Remove noop modification of QDialogPrivate::nativeDialogInUse
The modification was inside a nativeDialogInUse == false
condition already.

Task-number: QTBUG-108153
Change-Id: Ice5f48fc5d2548085b063060817e2c4eeaf00452
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-11 17:48:50 +01:00
Tor Arne Vestbø
d5f92c1fb8 Remove unused tst_qfontdialog_mac_helpers.mm
The uses of the click_cocoa_button() function was removed in 2012,
in ba21ca7b5b.

Change-Id: If7abfc56bb307cfbf9f6628cec9c7267a8a1f31f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-11 17:48:50 +01:00
Ahmad Samir
9a74859c03 QTimerInfo/Unix: use chrono for time arithmetic
Change-Id: I2e193e2293c15e722d2e5c32ac8f7db1b5b7514a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 18:21:42 +02:00
Edward Welbourne
89c6271af0 QLocaleData::numberToCLocale(): consolidate two branches
The handling of a digit was done in two parts, separating the case for
the first digit from the handling of later digits. Nothing in the
else/if chain between involved digits, so the latter can move to the
front and be combined with the former.

Change-Id: I4c93515f36452721bdef472cc2f0af7ceeb00527
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
23a854c3a6 QLocaleData::validateChars(): exploit last to detect first iteration
Checking the value of last, instead of the index, prepares the way for
using QStringIterator here.

Change-Id: Ided0530413211e918acd406ebdb37f16006ef07d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
df8d26f309 QLocaleData::numberToCLocale(): cache last character
Remember last iteration's character, if only to align with
validateChars(); this replaces some calls to result->last(), that all
happen where last can't have been a grouping character, so it's OK to
let last be set to ',' as far as these points in code are concerned.

Change-Id: I24112c25e5620bb0b056aaeb78c7a2a18b09e8fb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
80aba027af QLocaleData::numberToCLocale(): make discarding of grouping overt
If grouping isn't allowed, return early on hitting any.
Make the elision of grouping from the converted string easier to see.

Change-Id: I452d1e2b64612cd3ce534907a4b9aac652669ba5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
8359436751 QLocaleData::numberToCLocale(): simplify non-decimal handling
Checking for list separators and percent sign was a distraction; none
of the callers will allow a string including those. The QString
methods, that have to cope with bases other than ten, are all now
routed via other methods, so numberToCLocale() no longer has to care
about letters as possible digits (although 'e' remains a return from
numericToCLocale(), as exponent).

It does still need to accept the letters of inf and nan, so retain a
check for them, but simplify the processing of ascii as it only needs
to get them right. We can also return false on invalid character,
rather than breaking out of the loop and leaving other conditions to
catch the error.

Change-Id: I49f46b2f116d11a310ed3514a0f0e09a3e90c8ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
bbb7a51ab8 QLocaleData::numberToCLocale(): use QFlags::testFlag() more
Convert the checks on the number options to use it. Also group local
variables by what part of the work they're involved in.

Change-Id: I420c95ad45b2cb2a6b31c0227544e90bd0985584
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
da5dd84858 Add more tests of QLocale and "single character" data that aren't
This tests that strings using the first Unicode code-point of such a
multi-character token don't get recognized as "valid" number strings.
This would catch an implementation issue if the parsing code
mistakenly matched against only the first code-point of each "single
character" token.

It also adds tests of integer formatting, with multi-character sign,
and reworks some QStringView().toString()s to use u"..."_s.

Task-number: QTBUG-107801
Change-Id: I7b868ce2955bb322b3ecfc200438a21437090a0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
cf36db4df9 Add benchmarks for QLocale number parsing
Based on those for QString, but with locale variation and exercising
some of the locales with multi-character signs and exponents.

Pick-to: 6.4 6.2 5.15
Change-Id: Id0253449f9abcc154285f89337aa0e26dd69900d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:52 +01:00
Edward Welbourne
7fef433004 Add benchmarks for QString number parsing
Based on the tests for QString::number(), but run in reverse, with
some embelishments. Also moved some shared code from number_*_data()
to their shared number_integer_common template.

Pick-to: 6.4 6.2 5.15
Change-Id: I74e7082372166c3cdbcd6bcbc31f9003e07cbcbc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-11 16:32:52 +01:00