Commit Graph

3209 Commits

Author SHA1 Message Date
Axel Spoerl
edc984db38 QDialogButtonBox: Manage hide and show of standard buttons
0b421fa58b9a73d657bf17834788fd1175c4767e ensured a correct focus chain,
when buttons in a QDialogButtonBox were hidden.

The implementation did not check, if a hidden button was added via
setStandardButtons(). In consequence, it was removed from the
standardButtonHash and never added again.
QDialogButtonBox::button() returned nullptr for a standard button,
once it had been hidden. That introduced a regression.

This follow-up patch makes sure, a standard button is not removed
from standardButtonHash, when hidden. By no longer removing it from
standardButtonHash, it makes showQDialogButtonBox::button() always
return the pointer to the standard button, even if it is hidden.

The function handleButtonDestroyed() used the argument
QDialogButtonBoxPrivate::RemoveRule::KeepConnections, in order to leave
signal/slot connections untouched. It expected the the destroyed button
to be removed from standardButtonHash. In order to retain that
functionality, the enum class RemoveRule is renamed to RemoveReason,
and one value was added. QDialogButtonBoxPrivate now handles all
necessary cases of removing a button:

ManualRemove (previously Disconnect):
- remove button from roles
- remove button from standardButtonHash
- disconnect all signals

LeaveEvent (previously KeepConnections):
- remove button from roles
- do not remove button form standardButtonHash
- do not disconnect signals

Destroyed (new):
- remove button from roles
- remove button from standardButtonHash
- do not disconnect signals (QObject will do that)

An autotest is added to tst_QDialogButtonBox.

Task-number: QTBUG-114377
Pick-to: 6.6 6.5
Change-Id: Ib28625d44fa89c3d06f181f64875c2e456cebbfa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-11 13:26:56 +00:00
Volker Hilsheimer
505ed52cd4 Dialogs: clean up native dialogs when object gets destroyed
QWidget::setVisible is virtual, and called via hide() by both the
QDialog and the QWidget destructor. A dialog that becomes invisible
when getting destroyed will at most execute the QDialog override.
Subclassing QDialog and overriding setVisible() to update the state
of the native platform dialog will not work, unless we explicitly
call hide() in the respective subclass's destructor.

Since e0bb9e81ab, QDialogPrivate::setVisible is
also virtual, and gets called by QDialog::setVisible. So the clean
solution is to move the implementation of the native dialog status
update into an override of QDialogPrivate::setVisible.

Add test that verifies that the transient parent of the dialog
becomes inactive when the (native) dialog shows (and skip if that
fails), and then becomes active again when the (native) dialog is
closed through the destructor of the Q*Dialog class. The test of
QFileDialog has to be skipped on Android for the same reason as the
widgetlessNativeDialog.

Fixes: QTBUG-116277
Pick-to: 6.6 6.5
Change-Id: Ie3f93980d8653b8d933bf70aac3ef90de606f0ef
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-09-06 23:12:33 +02:00
Ahmad Samir
ac9e968755 Remove redundant QPair includes
Nothing in those files uses QPair; and a local build finished fine without them.

Task-number: QTBUG-115841
Change-Id: I669cfecaa9129bce6b31e464826287f138b159db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-06 17:24:40 +00:00
Marc Mutz
5a96d13bb5 QCheckBox: add new checkStateChanged(Qt::CheckState) signal
... to replace the old stateChanged(int) one, which a) had the wrong
name and b) the wrong argument type.

Mark the old one as \obsolete, so new users don't see it
anymore. Prepare for deprecation in the test, but don't actually
deprecate, yet (this author does not know how to deprecate signals).

Found in API-review.

Amends 37b47ebf94.

As a drive-by, replace explicit qWait() calls with QTRY_COMPARE().

[ChangeLog][QtWidgets][QCheckBox] Added new
checkStateChanged(Qt::CheckState) signal, obsoleting
stateChanged(int).

Fixes: QTBUG-104688
Change-Id: I01791fd003b752c47d99bea65151202be9175c21
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-05 13:43:44 +00:00
Santhosh Kumar
4cf92d83c3 Reset palette resolve mask in windows vista style
The palette set by windows vista style during polish doesn't allow style-
sheet style to override it.

This patch reset resolve mask for the palette set by windows vista style
and thus it can be overridden.

Fixes: QTBUG-115511
Pick-to: 6.6 6.5
Change-Id: Ifcaf441f806cfa0273599b3dce83fdfaec3f5a66
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-09-05 10:59:00 +02:00
Axel Spoerl
41c8d215f2 tst_QSplitter: fix compiler warning
QLabel *l is declared uninitialized, assigned in a for loop. The last
object is deleted for testing purposes.
This leads to a false compiler warning about deleting a potentially
unintialized pointer.

=> initialize with nullptr to silence the warning.

Pick-to: 6.5 6.6
Change-Id: I1422b04fc1fdbfc7248de577884aabfb539f3f4b
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-01 00:11:51 +02:00
Laszlo Agocs
80520c2f52 Enable QWidget::grab() with QRhiWidget in the widget tree
This involves reimplementing QWidgetPrivate::grabFramebuffer().
Widgets call this function whenever a texture-based widget is
encountered.

This implies however that we rename QRhiWidget's own, lightweight
grab function, grab(), because it kind of shadows QWidget's grab().
Switch back to grabFramebuffer() which is what QQuickWidget and
QOpenGLWidget both use.

Supporting QWidget::grab() is particularly important when grabbing
an ancestor of the QRhiWidget, because that has no alternative.
Right now, due to not reimplementing the QWidgetPrivate function,
the place of the QRhiWidget is left empty.

In addition, grabFramebuffer() is now const. This is consistent
with QQuickWidget, but not with QOpenGLWidget and QOpenGLWindow.

Change-Id: I646bd920dab7ba50415dd7ee6b63a209f5673e8f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-28 21:14:28 +02:00
Timur Pocheptsov
a3cbbe449a Blacklist tst_QMainWindow::QTBUG52175_tabifiedDockWidgetActivated
We are BLACKLISTing on macos/arm - the test is flaky.

Pick-to: 6.6 6.5
Task-number: QTBUG-115945
Change-Id: I3be28c895d46ce5ba86e00d597016334bdb16021
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-25 18:37:23 +02:00
Tor Arne Vestbø
ea25b3962b Stabilize tst_QGraphicsEffect::draw()
It's very flakey in CI: http://testresults.qt.io/grafana/goto/XZQAAPRSg

What we want to test is whether Qt issues paint events in response
to enabling an already enabled effect. Doing so via qWait will process
both window system events and posted Qt events, and the former might
include spontaneous paint events from the system that we can't control.

Task-number: QTBUG-115945
Pick-to: 6.5 6.6
Change-Id: I65e5c6a4458e77b3bd2ad700c5caf6d441f4ca53
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-08-25 09:04:37 +02:00
Ahmad Samir
2e37cff19e tst_QSpinBox: handle an old TODO
QTBUG-69492 has been fixed since Qt 5.12.

Pick-to: 6.6 6.5
Change-Id: I8bc59bd37a9ee2f47f13fa8ff54aa91e2c9148fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-24 23:35:01 +03:00
Axel Spoerl
366b4d3ae7 tst_QDockWidget: Fix compiler warning in non-development build
Static variables for a message handler were used only in developer
build, while they were declared unconditionally.
That has lead to compiler warnings about unused variables in a
non developer build.

=> declare them only in developer build
=> move assignment and static method in front of the method,
that uses them.

Pick-to: 6.6 6.5
Change-Id: Ie06f91f7857130f08fd484a6e7319ddfd16c546b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-22 15:37:46 +02:00
Santhosh Kumar
90980a54e8 Rename accent color in QPalette
Accent color role has been renamed according to name rule of other
color roles in QPalette.

Fixes: QTBUG-116107
Pick-to: 6.6
Change-Id: I70ac98a1e97afbdc7ea5f8d79f808c307e170712
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-08-18 00:38:38 +02:00
Volker Hilsheimer
3965d52ad5 QTabBar: don't make current tab visible while tab bar is invisible
When changing the current index while the tab bar is not visible,
calculating the necessary scroll offset might result in wrong results if
the tab bar still has an old size. When the tab bar then gets shown and
resized, the scroll wouldn't be corrected, potentially leaving tabs
unnecessarily scrolled out.

We don't need to make the current index visible if the tab bar itself is
not visible, it's enough to flag the layout as dirty so that the next
show event (which either way makes the then current index visible)
triggers a laying out of the tab bar tabs.

Amends e851d4c06154bf02b23030ff1f7024a8b9edf874.

Fixes: QTBUG-115109
Task-number: QTBUG-113140
Pick-to: 6.6 6.5
Change-Id: I3d8633f9f8b907a36190123839a6104a17bfe138
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-16 22:36:35 +02:00
Axel Spoerl
e03bc88a80 QDockWidgetGroupWindow::adjustFlags() - don't show() empty group window
The method calls show() on a dock widget group window, when the window
flags have changed. When all of its contained, tabbed dock widgets are
programmatically hidden or docked on the main window, an empty group
window is shown.

This patch implements bool hasVisibleDockWidgets(). It returns true, if
at least one of the group window's dockwidget children is not hidden.
It replaces show() by setVisible(), passing the return value of
hasVisibleChildren().

It adapts tst_QDockWidget::floatingTabs() to test the fix.
(Drive-by: remove dead code)

Fixes: QTBUG-115058
Pick-to: 6.6 6.5 6.2
Change-Id: Ifb8e2450e91a7c78decc06f592e160631ca2faf5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-15 10:47:28 +02:00
Marc Mutz
3693dd74fe tst_QWizard: port from QSharedPointer to std::shared_ptr
QSharedPointer is 'meh', see QTBUG-109570 and 18113e22e9.

This is just a textual replacement of

- QSharedPointer<(.+)>::create() → std::make_shared<\1>()
- QSharedPointer → std::shared_ptr

And it compiles and still passes. No non-standard APIs to fix up.

Task-number: QTBUG-109570
Change-Id: I827d4a9be0511780c3900bd53ffcbdcb6aacbc3b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-08-14 23:11:54 +03:00
Marc Mutz
40afcb9d01 QtWidgets tests: port remaining users away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

As a drive-by, replace a QList legacy left-shift-based- with
initializer_list-construction.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I453e24272c4c4b7dce5b91a0bd04481d833c50bb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-14 23:11:54 +03:00
Marc Mutz
6f5f10bea8 tst_QMainWindow: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

As a drive-by, replace a QList with a C array
("never use a dynamically-sized container for statically-sized data").

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I1b1e8f093abf75093900631e6fe3cbc9e3019d34
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-08-14 23:11:54 +03:00
Axel Spoerl
4c7cac682f QPlainTextEdit: update placeholder text when document is empty
When the placeholder text is changed after having been displayed, it
doesn't get updated on the screen any more, unless the entire viewport
is updated, e.g. because of a document change or a focus event.

This patch simplifies QPlainTextEditPrivate::updatePlaceHolderVisibility()
to update the visibility if the text document is empty.
It replaces the member QPlainTextEditorPrivate::placeholderVisible
by the function isPlaceHolderTextVisible(). It returns true, if the
document is empty and a placeholder text exists, and otherwise false.
It adapts and corrects tst_QPlainTextEdit::placeHolderVisibility():
- usage of new member function instead of data member.
- do not expect an empty placeholder to be visible.

Fixes: QTBUG-115831
Pick-to: 6.6 6.5 6.2
Change-Id: Ic4427ce7f7f1b8cde89957b9de0b978bd34ba923
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-08-14 17:11:27 +00:00
Laszlo Agocs
72a453c6a8 Add QRhiWidget
Task-number: QTBUG-113331
Change-Id: I8baa697b4997b05f52acdee0e08d3c368fde5bc2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-14 17:05:36 +02:00
Axel Spoerl
be3b9b2ab1 QAndroidPlatformInputContext: send composition text and cursor jointly
QAndroidPlatformInputContext::focusObjectStopComposing() sends an input
event for each character newly added by the Android virtual keyboard.
It then sends a second input event to notify that the cursor has
advanced to the position after the new character.
The implicit assumption is, that the receiver of the input event does
not change the text.

If e.g. QLineEdit::setText() is called in the QLineEdit::textEdited
slot, the text does change. If the change implies a cursor change,
QLineEdit notifies the platform input context about it.
However, by sending the second input event, QAndroidPlatformContent
returns the cursor back to the position after the last character added
by the virtual keyboard.

This patch joins the composed text and the cursor position into one
single input method event. A new cursor position, set by the receiver
of the input method event, is no longer overridden.
The patch adds test functionality to tst_QLineEdit::setText().

Fixes: QTBUG-115756
Pick-to: 6.6 6.5 6.2
Change-Id: I85ffac5d6bab93ccb144be0f5b8083258a270550
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-14 16:24:45 +02:00
Axel Spoerl
814b7fd3a8 Improve diagnostic output in tst_QDockWidget::floatingTabs()
Use QTRY_COMPARE instead of QTRY_VERIFY.

Task-number: QTBUG-115058
Pick-to: 6.6 6.5 6.2
Change-Id: I2bfb7c54476e8fdd4f34c74888f56a6f7942a7ee
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-08-11 15:45:21 +02:00
Tero Heikkinen
de94265169 Add QEXPECT_FAIL to tst_QApplication::sendEventsOnProcessEvents
Test sendEventsOnProcessEvents has been noticed to fail when
qgtk3 (Glib) is loaded - Should be fixed in QTBUG-87137

Moving test from blacklist to use QEXPECT_FAIL as it's more
recommended until test is fixed in the relevant configurations.

QEXPECT_FAIL is selected to use as original investigator
reported also some cases when glib is working. Therefore
this approach is giving us more insight for further
investigation is it always failing with glib or not.

It was also reported linkage to zeroTimer test QTBUG-84291,
but not sure why removing that has affected to this one.

Update to QEXPECT_FAIL documentation to tell in first place
that XPASS is not only marking it as XPASS but also failing
the test. Same is mentioned in different location but it
needs more searching or testing how it works in real test.

Task-number: QTBUG-115155
Change-Id: I7fb4ef28dba8adb7009be528f88fc758a12e9006
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-10 16:42:51 +03:00
Marc Mutz
8de746a96c tst_QMainWindow: for UB (use of reserved names)
Identifiers matching _[A-Z_].* are reserved for use by the C++
implementation. Replace the __ prefix of variable names with _v_,
making them non-reserved.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I35127d7473678e2efd93a4b21847db562c53abd2
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-09 09:38:23 +02:00
Marc Mutz
af34c64d7f tst_QMdiArea: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables, albeit sometimes at the cost of an extra scope
(can't, yet, use C++20 ranged for loops with initializer).

In resizeMaximizedChildWindows(), decided to leave the container
construction as-is and use std::as_const instead (applying IILE to
make the container const would be too much churn).

In setViewMode(), removed a pointless clear() that prevented the
container from being marked const. There are no references to the
container following the clear(), and the container does not hold smart
pointers, so the clear() cannot have had non-trivial side-effects.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I00ce9c12ab696de30229f3605c16313af7eafffc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-07 23:56:11 +02:00
Marc Mutz
081670b840 tst_QGestureRecognizer: port away from Q_FOREACH
The single use of Q_FOREACH in this test is safe to port 1:1 to a
ranged for-loop, since we're in a constructor, and the loop body only
calls member functions of data members (incl. the base class), so we
cannot possibly modify the container passed in as a constructor
argument: any connections or event processing that could re-enter our
caller hasn't been set up, yet.

Task-number: QTBUG-115803
Change-Id: I7095aef1edddbda0d1b0c471192b18acd6fd1793
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 23:56:10 +02:00
Marc Mutz
ddcf716762 tst_QGroupBox: port away from Q_FOREACH
These are all simple: QObject::children() returns a reference-to-const
QList, so we can leave the calls in the for loop (no detach()ing).

The loop bodies also clearly don't modify the list of the QObject
children (they're just QVERIFYs).

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I9c5dcb2aefc433a1dead55dab669e645b6906963
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-07 21:56:10 +00:00
Marc Mutz
e0c1ae09fd tst_QWizard: port away from Q_FOREACH[5/5]: CombinationsTestData ctor
This is iterating over data member containers that are otherwise only
touched in the constructor of the same object. Luckily, the
initialization of these containers does not require *this, so use
NSDMI and mark the containers const, proving they can never be
modified and thus the protective copy of Q_FOREACH isn't required. Now
that we got rid of Q_FOREACH, we can and do make them arrays for extra
measure ("never use dynamically-sized containers for statically-sized
data").

Unfortunately, C++ neither allows us to use "flexible array
members" nor AAA in NSDMI, so grab the nettle and supply the array
size manually (ever so slightly violating DRY, but the compiler will
complain if we get it wrong).

Task-number: QTBUG-115803
Pick-to: 6.6 6.5
Change-Id: Ibb2ce48b6dcaf2e9d3d1a625602f3865d280c7c6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 21:56:10 +00:00
Marc Mutz
4741a7cd1c tst_QWizard: port away from Q_FOREACH[4/5]: TestWizard dtor
This is iterating over a data member container that's otherwise only
touched in the constructor of the same object. The only reason why
it's not a const is that the initialization from QWizard::addPage()
makes that very cumbersome. So port to a ranged for-loop and apply
std::as_const().

Task-number: QTBUG-115803
Pick-to: 6.6 6.5
Change-Id: I033e3725df95b29a8ef295c4e74d746d83234835
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 23:56:10 +02:00
Marc Mutz
d67aa6291d tst_QWizard: port away from Q_FOREACH[3/5]: OptionInfo ctor
This is iterating over the keys() of a member container we've just
filled in the same function. The loop body clearly doesn't modify the
container being iterated over. Port to the future-proof ranged
for-loop over asKeyValueRange(), using the _-in-SB pattern Christian
Ehrlicher showed me to indicate we're not interested in the value.

Task-number: QTBUG-115803
Pick-to: 6.6 6.5
Change-Id: I3d86a1de9ea460b7d57fa421ea76e41d2c122f43
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 23:56:10 +02:00
Marc Mutz
d0a4b29132 tst_QWizard: port away from Q_FOREACH[2/5]: WizardPages::shown()
This is safe to port to a ranged for loop, as it's iterating over a
private member container that is not modified under iteration
(WizardPage::shown() is just returning a boolean member).

Task-number: QTBUG-115803
Pick-to: 6.6 6.5
Change-Id: I50891e4b7509bd64399a128a5ee47d7795374f8e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 23:56:10 +02:00
Marc Mutz
88464f7e93 tst_QWizard: port away from Q_FOREACH[1/5]: TestWizard::applyOperations()
This function is called only from one test function. Mark the
function's argument as const in the caller, bringing this use into the
const-local category, which is implicitly safe to port 1:1 to
ranged-for.

Task-number: QTBUG-115803
Pick-to: 6.6 6.5
Change-Id: I9145c1ae2aed5ab3cafc4947dc3eaaf9a27c6a04
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 23:56:10 +02:00
Marc Mutz
32e8b27285 tst_QFileDialog/2: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

The only noteworthy point here is that, in order to mark it as const,
I had to move a container definition to the more narrow scope in which
it was actually initialized. There are no references to the container
outside the narrow scope that would require it to be defined in the
larger scope.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I20890f48a48ca662679f55fa5db759419d4db8c5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-07 13:28:20 +02:00
Marc Mutz
b8881ff280 tst_QComboBox: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: Idd6e65065ee27c2d29ce1b49607aadb2eaf5e15d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-07 13:28:10 +02:00
Liang Qi
6f6e62650d tests: skip three tests in tst_QDockWidget on Wayland
Task-number: QTBUG-107153
Pick-to: 6.6 6.5
Change-Id: Iad2bc83db96c25508b54ecc5b7c74280cfe90270
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-04 09:09:47 +02:00
Liang Qi
c41733b06b tests: blacklist tst_QWidget::render() on Wayland
which is flaky.

Task-number: QTBUG-115598
Pick-to: 6.6 6.5
Change-Id: Ibb0a0c6b1e225144e2ce796691c40bb7510bfd56
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-03 07:23:37 +02:00
Assam Boudjelthia
de7eaa940d Android: temporarily skip tst_qprinterinfo, tst_qwidget and tst_qwindow
Those tests often fail on Android 13 on RHEL 8.6 and 8.8. This patch
skips them to unblock CI while the underlying reasons are investigated
and fixed.

Task-number: QTQAINFRA-5606
Change-Id: If088d69c2160470ef50b2e74cd9b9399451c526d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-26 20:12:49 +03:00
Liang Qi
43c4d17e4d tests: blacklist tst_QGraphicsItem::itemUsesExtendedStyleOption() on Wayland
Task-number: QTBUG-115293
Pick-to: 6.6 6.5
Change-Id: I0a9251b5656a5d5a1048fa0cb1606df1c42dd85d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-18 08:25:41 +02:00
Marc Mutz
3ad359d44f tst_QLineEdit: fix -Wsuggest-override
Amends 8afe4faf29.

Pick-to: 6.6 6.5
Change-Id: If2b87f8db3e1a60ff5f5d34c68b3ecd45ff25f96
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-13 16:19:06 +02:00
Volker Hilsheimer
8c18a245b0 QAbstractScrollArea: Don't include size of invisible scrollbars
Amend 3e59a88e89, which incorrectly used
isHidden() to test whether the scrollbar is visible or not.
QWidget::isHidden() is only true for child widgets that are explicitly
hidden (or created for visible parents, which the scrollbars are not).
Since the scrollbars are children of a container that is hidden and
shown, isHidden always returns false.

Instead, use QWidget::isVisibleTo, passing the scroll area, as that
tells us if the scrollbar's visibility is relevant for the layout of the
scroll area.

Add a test case for QAbstractScrollArea, verifying that the scrollbar's
size is correctly taken into account when calculating the size hint.
This change revealed an instability in the tests introduced in the
earlier commit: the layout process is asynchronous, requiring event
processing to update the visibility of the scrollbars. Add a call to
processEvents before storing the reference size hint. Also, explicitly
set a style that doesn't use transient scrollbars as otherwise we cannot
control when the scrollbars are shown.

The chagne also revealed an inaccuracy in the QListView test, which
only passed because the width of the vertical scrollbar was included.
We cannot use font metrics results to compare expected width, as the
item delegate's text rendering uses text layouts.

Task-number: QTBUG-69120
Fixes: QTBUG-109326
Fixes: QTBUG-113552
Pick-to: 6.6 6.5
Change-Id: I1f06f9e88046a77722291ac17c56090f8dff7cf3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-11 01:34:19 +02:00
Edward Welbourne
ad61d2860b tst_QDateTimeEdit: skip parameters on EditorDateEdit declaration
Its single parameter is a pointer that defaults null, so don't bother
passing nullptr, much less 0, as it.

Change-Id: Iec68bf388d848c020359001699c971e12266a335
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-10 12:57:21 +02:00
Axel Spoerl
25f7d95fce tst_QDialogButtonBox::hideAndShowButton: Wait for focus widget
Spin the event loop with QTRY_VERIFY when checking the dialog box's
focus widget, to stop flaking.

Pick-to: 6.6 6.5
Change-Id: I24fab1264796e05645da4c12e4672daec9b06067
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-08 17:16:54 +02:00
Axel Spoerl
bbb71e7e80 QDialogButtonBox - Update focus chain when buttons show or hide
Hiding a button in a QDialogButtonBox doesn't remove its default and
focus behavior. Hiding the button shown in the first position, breaks
the focus chain. Tabbing between the button is no longer possible.

This patch implements listening to the buttons' HideToParent and
ShowToParent events. Hidden buttons are removed from the button box
and kept in a separate hash. That ensures focus chain consistency.
When they are shown again, they are added to the button logic and
their default/focus behavior is restored.

An autotest is added in tst_QDialogButtonBox.

Fixes: QTBUG-114377
Pick-to: 6.6 6.5
Change-Id: Id10c4675f43d6007206e41c694688c4f0a34ee52
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-06 08:41:04 +02:00
Alexandru Croitor
68cb89c8b2 CMake: Make widgets tests standalone projects
Add the boilerplate standalone test prelude to each test, so that they
can be opened with an IDE without the qt-cmake-standalone-test script,
but directly with qt-cmake or cmake.

Boilerplate was added using the following scripts:
https://git.qt.io/alcroito/cmake_refactor

Manual adjustments were made where the code was inserted in the wrong
location.

Task-number: QTBUG-93020
Change-Id: I3c0d1a63c474969e5eaee5fdbb1bb0229482fc5b
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-07-05 15:09:32 +02:00
Liang Qi
8b98c0a4c2 tests: blacklist tst_QAbstractItemView::selectionAutoScrolling() on Wayland
because it's flaky in current CI setup.

Task-number: QTBUG-109776
Pick-to: 6.6 6.5
Change-Id: I3e432e632622f47b8125344187daf238a03a7372
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-02 11:37:28 +02:00
Liang Qi
81ae227614 tests: blacklist tst_QMenu::pushButtonPopulateOnAboutToShow() on Wayland
Task-number: QTBUG-114997
Pick-to: 6.6
Change-Id: Ic6f0e9e3ec550b9d08cb70102bbe553328b29273
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-02 08:01:10 +02:00
Tor Arne Vestbø
1f70c073d4 QMessageBox: Respect clients overriding QDialog::done()
As a result of d8bbb5ee0e, we
were no longer calling QDialog::done(), which users may have
overridden.

We now pull out the dialog code to determine whether to
emit accepted/rejected directly in done(), so that we
can go back to calling QDialog::done().

Pick-to: 6.6 6.5
Change-Id: Ie08270123d61d9010acd8c989b66986f71960ad0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-29 18:49:46 +02:00
Richard Moe Gustavsen
d74235db5d tst_qcombobox: skip popupPositionAfterStyleChange on QEMU
The test turns out to be flaky on QEMU.

Fixes: QTBUG-114760
Pick-to: 6.6 6.5
Change-Id: I264f79e9a056e82d4e6735e6ead0710ddabd8eba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-27 13:58:55 +02:00
Axel Spoerl
2a1772a649 QHeaderView: Don't add new sections on no-op
When a table view adds its first row, QHeaderView::initializeSections()
is called. It initializes the vertical header view with the number of
added sections. Subsequently QHeaderView::sectionsInserted() is called
with the same amount of newly added rows/sections.
That leads to the initial amount of sections being 2x the number of
rows added in the first go. In other words, the table view will display
at least one row more than the underlying table model has.

This patch adds an OR condition to the early return check at the
beginning of QHeaderView::sectionsInserted(). The method returns early
if the number of sections equals the number of respective sections
(rows in this case) in the model.

An autotest is added in tst_QTableView::rowsInVerticalHeader().

Fixes: QTBUG-114225
Pick-to: 6.6 6.5
Change-Id: I895444f025591981965562e54e2335391db52357
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-06-23 19:21:42 +02:00
Axel Spoerl
f83ea89622 Implement QWidgetPrivate::focusObject()
QWidgetPrivate::focusObject() always returns nullptr. That has lead to
mismatches between QGuiApplication::focusObject() and
QApplication::focusWidget(), when a widget got focus by the window
system (e.g. mouse click).

This patch implements QWidgetPrivate::focusObject.
It returns the current widget, if it doesn't have a focus proxy.
If it has a focus proxy, it resolves the proxy chain and returns the
deepest focus proxy.
(Note: It does not return QWidget::focusWidget(), because the focus
widget might not yet have been set, when the method is called).

Fixes: QTBUG-92464
Fixes: QTBUG-108522
Pick-to: 6.6 6.5 6.2
Done-With: Liang Qi <liang.qi@qt.io>
Change-Id: Icf01e8ac4fc5f722fbf8e0ca5a562617ae9ae8f2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-06-21 00:30:41 +02:00
Marc Mutz
c41e03008a tst_qmenu: fix -Wsuggest-override
... and fix placement of {.

Amends f0049873d2.

Pick-to: 6.6 6.5 6.2
Change-Id: I2479087005d350a23e45eda126a89e0be91c0701
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-20 15:24:50 +02:00