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>
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>
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>
which is flaky.
Task-number: QTBUG-115598
Pick-to: 6.6 6.5
Change-Id: Ibb0a0c6b1e225144e2ce796691c40bb7510bfd56
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Amends 55fe46fd58. Before that change,
key release events were ignored as the QLineEdit::event reimplementation
continued to call QWidget::event, and as QLineEdit didn't override
keyReleaseEvent, the default implementation in QWidget got called to
ignore the event.
Restore that behavior by explicitly calling the QWidget implementation
after updating QLineEdit-specific states, and add a test case.
Fixes: QTBUG-114654
Pick-to: 6.5 6.6
Change-Id: Ic8aa35a1c915b446aece47aaf03ef5cf1884b936
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
If the style changes while a popup is open (or about to close),
the popup will change style as well before it's hidden. And
this can result in the popup window briefly ending up smaller
than what it needs to be, in order to fit all the menu items.
In that case, it will show 'up' and 'down' widgets in the
menu that auto scrolls it when hovered. And all this can
happen for a split second while the menu is about to close
(as a result of the user clicking on a menu item).
A bug happens because of this if you click on the last menu
item in the list, and this causes the style to change. In
that case, the 'down' widget will end up directly underneath
the mouse for a split second, which will trigger an auto-scroll
timer to start. This timer will trigger a bit later, after
the popup has been hidden, and scroll the list view a bit down.
The result is that the next time you open the popup, it ends up
at the wrong place on the screen in a failed attempt to center
the current index on top of the combobox.
This patch will make sure that we always scroll the list view
to the top before we start calculating where the popup should
be placed on the screen. Otherwise the geometry ends up wrong
since the popup will anyway be resized (if possible) to fit
all the menu items before it's shown and should therefore not
take scrolling into account.
Pick-to: 6.6 6.5
Fixes: QTBUG-113765
Change-Id: I61b5b832904de471c2303fc67325feec322b1449
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
currentTextChanged is emitted when the current index changes
and the current text doesn't.
This can be the case, if
- old and new index have identical text values
- an item is removed below the current index
[ChangeLog][Widgets][QComboBox] emit currentTextChanged only,
if currentText changes.
Add a corresponding test in tst_QComboBox::currentText().
Fixes: QTBUG-113717
Pick-to: 6.6
Change-Id: I847874f0792b29a2841e50bb82d06ad496fb02c3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
If a foreground style has been defined in the style sheet,
QStyleSheetStyle populates its brushes for the color roles ButtonText,
WindowText, Text, and the widget's foregroundRole with the foreground
brush. PlaceholderText is set to the same brush with a modified color.
That sets their resolve bits in QStyleSheeetStyle's palette and
prevents these color roles from being inherited by the widget's
palette - in contrast to all other brushes.
This patch makes the brushes mentioned default to the widget's palette
if they are set there. It adds a test in tst_QStyleSheetStyle.
Fixes: QTBUG-93009
Pick-to: 6.6 6.5
Change-Id: Ie3df9dbd17b96fa72beee90792fc7eca1933cdbe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
QDeferredDeleteEvent has the loopLevel field, which is a sum of
scope and loop levels found at posting. In sendPostedEvents however,
it is impossible to only use this information to find delete events
posted before the outermost loop (which should be handled by any loop)
based solely on this information, as the scope level essentialy removes
the information on loop level.
Break the loopLevel in two, storing both loop and scope levels in
QDeferredDeleteEvent, so that we can check whether an event was posted
before the outermost event loop (for which we need to compare only the
loop level).
QDeferredDeleteEvent was also made private as it should - it is an
implementation detail that wasn't hidden properly.
Change-Id: I0a607a0bd3a2deb5024acad67f740dbf4338574c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
QMenu's causedStack maintains a list of menus on the way to the menu,
and might contain nullptr if one of the entries was a tear-off menu
that got closed (and thus destroyed, due to DeleteOnClose).
If the entry we get from the stack is nullptr, fall back to the passed-
in parent widget pointer, and test for nullptr before accessing.
Add a test case that crashes without the fix.
Fixes: QTBUG-112217
Pick-to: 6.6 6.5 6.2
Change-Id: I958182db47c3cc8733e1780f7efef43881ffae11
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
When a floating dockwidget's title changes, it is rendered as a
window title. When the title changes while floating, the change will be
reverted to the pre-change title when the dockwidget is docked again.
This patch explicitly propagates the window title, if it has been
programmatically changed while the dock widget is floating.
It adds test functionality in tst_QDockWidget::floatingTabs().
Fixes: QTBUG-113591
Pick-to: 6.6 6.5
Change-Id: I96fa69fb27ad1a85f4ea9ce44c0a22290259fca6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
If an application sets the current index and resizes the tab widget
before showing it, then the scroll offset might be calculated based on
an old size. Since after ca15f650a1,
resizing explicitly avoids scrolling, this could result in tabs ending
up scrolled outside of the tab bar when showing the tab widget.
Fix that by explicitly making the current tab visible in the tab bar's
showEvent handler, which recalculates the scroll offset based on the
actual size.
This is only reproducible with a tab widget, which lays out the tab bar
for each change and resets the tab bar's layoutDirty flag. Add a test
case there.
Pick-to: 6.5 6.6
Fixes: QTBUG-114204
Change-Id: I1e9506b9dde1dd892291d108dd2c7b675ef99509
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Jonas Kvinge <jonas@jkvinge.net>
Amends e718818745, after which a context
menu was only shown if the format was rich text and there was a link at
the position of the click.
We always want to leave it up to the control to create a context menu,
so only return early if there is no control. The control will then
respect content at the position (i.e. link or not) and text interaction
flags, and create the menu based on that. I.e. a rich text label with
selectable text should still show "Select All" in the context menu, also
if not clicking on a link.
Add a test case to verify that the context menu event got accepted
as expected, which indicates that the label showed a menu.
Pick-to: 6.5
Change-Id: Ib2b36286e4f1253d10489b5add83e8cdd7197a06
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
The color role AccentColor has been added to QPalette.
This patch implements the new color role in QCssParser and subsequently
in QStyleSheetStyle.
The QBrush variable names used to populate brushes, have been changed
into speaking names for better code readability.
tst_QCssParser has been adapted accordingly.
The test function accentColor() has been added in tst_QStyleSheetStyle.
Documentation has been updated.
Change-Id: Ib09ddc1b61868f2bb8f70f654e83ea1c35276d30
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from
shadertools; done separately) become "RHI APIs", following the concept
of QPA APIs.
Mirror completely what is done for QPA headers, but using the "rhi"
prefix for the headers. This involves updating syncqt to handle the
new category of headers. (a note on the regex: matching everything
starting with "qrhi" is not acceptable due to incorrectly matching
existing and future headers, hence specifying the four header names
explicitly)
There is going to be one difference to QPA: the documentation for
everything RHI is going to be public and part of the regular docs, not
hidden with \internal.
In addition to the header renaming and adding the comments and
documentation notes and warnings, there is one significant change
here: there is no longer a need to do API-specific includes, such as
qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a
single header that is then included from qrhi.h. This means that users
within Qt, and any future applications can just do #include
<rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no
other headers are needed.
There are no changes to functionality in this patch. Only the
documentation is expanded, quite a lot, to eliminate all qdoc warnings
and make the generated API docs complete. An example, with a quite
extensive doc page is added as well.
Task-number: QTBUG-113331
Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
QTableWidgetItem uses additional enum flag ItemIsHeaderItem which has
the same numerical value as ItemFlag ItemNeverHasChildren.
This causes conflict since the user can set the latter flag using
the setFlags, while the ItemIsHeaderItem is only used internally
to mark header items.
Remove the additional flag and use boolean instead to fix the conflict.
Pick-to: 6.2 6.5 6.5.1
Fixes: QTBUG-113209
Change-Id: Icff549c7e452d9f84575a524361719204817274e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Amends ca15f650a1, after which scrolling
right to fill any gap might have resulted in overshooting to a negative
scrollOffset.
When we scroll right to fit the current tab, then we never want to end
up with a negative scroll, so clamp the result accordingly.
Augment test case accordingly. Since some styles align the tab bar in
the center, replace the calculation of the scroll offset with access to
the private data member (which inverts the sign when compared to the
calculated value).
Task-number: QTBUG-113140
Fixes: QTBUG-113376
Pick-to: 6.5 6.5.1
Change-Id: Ibdc6686b9dbd41b1ae3560e2227fa121d9b20e18
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
If there is an effect on the selected item we want to show it,
but if there is no item to highligh we just close the combo.
Fixes: QTBUG-113311
Pick-to: 6.5
Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The native style may not match the program style and it
makes sense to give an option rather than forcing native style.
Before it could only be done with setting AA_DontUseNativeDialogs
on the app, but it is reasonable to use native file dialogs and
Qt styled messageboxes - and it is extremely cumbersome - especially
since messageboxes often can start save dialogs.
It can look a bit strange that these introduced options has just one
option (DontUseNativeDialog) and four functions, but this way it works
similar to QColorDialog, QFileDialog and QFontDialog.
[ChangeLog][QWidgets][QMessageBox] Added options functionality to
QMessagebox. The currently only option available is DontUseNativeDialog.
Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
QTabBar lays out the tabs when the bar's size or content changes,
often lazily. This should not change the scroll offset of the tabbar,
which is controlled by the user, or at most when a tab needs to be made
visible (e.g. when it becomes the current tab).
Move the logic of updating the scoll offset into the makeVisible
function, so that the scroll is only adjusted to either leave no gap
between the last tab and the right edge of the widget of there is still
a scroll; or to reset it to 0 if there is enough space for the entire
tab bar. Since layoutTabs does show and hide the scroll buttons, we
cannot skip this when the buttons are invisible. However, the
normalizedScrollRect helper now needs to return the entire widget rect
if there are no visible scroll buttons.
Add a test case that simulates the previously broken behavior where
the scroll got unnecessarily reset to 0 when resizing.
Fixes: QTBUG-113140
Pick-to: 6.5
Change-Id: Ic19fbb82821ea09cc5e7646dcbce3aa7607909c2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
b1802a164b added handling for a parent to
become focus proxy of a child. The respective 'else if' branch didn't
check whether setFocusProxy() was called with a nullptr argument.
This patch adds the missing nullptr check.
It also adds functionality to tst_QWidget::tabOrderComboBox() to test
the removal of a focus proxy, as well as the complete removal of an
element from the focus chain.
Change-Id: I4cb865b9ac4497fc5e2595910738fb77694f5837
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When a parent became a new child's focus proxy in an existing focus
chain, the child was appended at the end of the chain.
That leads to broken tab order, e.g. with a QComboBox which became
editable after a focus chain has been set.
This patch captures the case and insertes the new child after its
parent in the focus chain.
A corresponding test function is added in tst_QWidget.
Fixes: QTBUG-111978
Pick-to: 6.5
Change-Id: I3a426c0560fa830b7b7ffead54f26dd0adef499f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Task-number: QTBUG-109779
Pick-to: 6.5
Change-Id: I21ecd4910ba3d699e44d9ea922093e98e0b8a335
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
The stepIntoDSTGap() hour cases were already conditioned on hour > 0,
explain why. The month and year tests need similar checks for kindred
reasons; add and document those checks.
Pick-to: 6.5
Change-Id: Ibcb69449fcd572ee94306a805fd680e9b5155322
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Given that QDTE only supports local time and UTC, using Europe/Oslo as
zone was disconnected from reality, especially as various QDateTime()s
were constructed using local time. Use the system zone.
Pick-to: 6.5 6.2
Change-Id: I95b3a6a6acf9ffc2b8c7f05d3dd9440ff173abfe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The test wants to start shortly after the transition, then step an
hour backwards, into it, to check we land safely on the other side.
However, it assumed the gap witdh was an hour, which is not reliable.
Use the gapWidth already used in computing springGap instead.
The -3590 seconds in the result time is correct, as it's the ten extra
seconds we started beyond the gap, minus the hour we step backwards.
Pick-to: 6.5
Change-Id: I4399af7e54a60bd55ea51d054d3cd2ecfcb0e354
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The "{forward,back} to %s, correct to nearest" tests were reporting
the time of the transition as %s but, like the jump test, were using
the middle of the gap as the time to set. So compute that mid-time's
string once and use it in all three test names. Also renamed some
local variables to accommodate the new one for this text.
Pick-to: 6.5
Change-Id: Ic6c40c470fc74ae8bcfc0dc9d1596af06318a883
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Although the zone's daylight time offset is usually the width of the
gap, it's possible the transition is (or includes) a change to
standard time; so determine the actual gap width by comparing the
difference between time a day earlier and later to the usual duration
of two days. Also skip the test if the transition isn't really a gap.
Pick-to: 6.5
Change-Id: I56e381c9f74cfa1806d43b3ed5e4637436ebdf57
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The function is passed a zone to work in, so setting the transition to
local time made no sense; set to the given zone's time, instead.
Pick-to: 6.5
Change-Id: Icaa0955fe5fcd5bc257322afcb7e25e932dedd1b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
QMenu::exec opens a blocking loop, which is problematic for webassembly.
Replace with QMenu::popup, and reset the down-state of the button when
the menu is about to hide. QMenu emits aboutToHide immediately before
existing the event loop in the hideEvent override, so the timing is the
same.
Change-Id: Iccb418d10fcb25f6ad1f73f9cdce6ea6581bd73b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>