summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
Commit message (Collapse)AuthorAgeFilesLines
* QWidget: cope with QObject::connect()'s incomplete SFINAE-friendlinessMarc Mutz2021-07-242-24/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The plan for QObject::connect() (perfect) forwarders, such as QWidget::addAction(), was to just use a variant of the Detection Idiom to see whether QObject::connect() with the arguments as given would compile and SFINAE out the forwarder otherwise. It turns out that the "functor" overload of QObject::connect(), in particular, is severly underconstrained and accepts e.g. QKeySequence as a function object, only erroring out via a static_assert() in the body of the function, and thus at instantiation time and not, as needed, at overload resolution time. At the same time, we don't really want QObject::connect() to SFINAE out on argument mismatches between signal and slot, because the resulting error messages would be ... unkind to users of the API. We would like to keep the static_assert()s for easier error reporting. Reconciling these two contradicting requirements has so far eluded this author, so for now, to unblock progress, we explicitly black- and, in one case, white-list possible arguments. Because QKeySequence, in particular, is implicitly constructible from int(!), and therefore any enum type(!), incl. Qt::ConnectionType, we need to do way too much coding in the addAction() constraints. Hopefully, we'll be able to fix the issue at the root cause, in QObject, before Qt 6.3 is out, but until then, this is an ok-ish stop-gap measure. Add thorough overload set checks (positive ones only, for now) to tst_qwidget and tst_qmenu. Change-Id: Ia05233df818bc82ecc924fc44c1b349af41cbbf1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Sync default action when checking tool button programmaticallyVolker Hilsheimer2021-07-221-0/+59
| | | | | | | | | | | | | | | | | | | | | | QAbstractButton::setChecked is not virtual, so QToolButton cannot override to synchronize the default action's checked state. This resulted in button and default action not being in sync when the checked state of the button was changed programmatically, while changing the checked state on the action kept the button in sync. Connect to the button's own toggled signal instead to keep the state of the default action in sync. Make it a unique connection to allow multiple calls to setDefaultAction, which are used by QToolButton to keep the button updated if properties of the default action change. Add a test that confirms that button and action are synchronized both ways, and that we only get single signal emissions when changing either programmatically. Fixes: QTBUG-95255 Pick-to: 6.2 6.1 Change-Id: I0e027faf1da763ef1878e46e85bfa70073c8bf82 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* emit layoutAboutToBeChanged timelyLuca Beldi2021-07-203-0/+208
| | | | | | | | | | | layoutAboutToBeChanged must be called before persistentIndexList as the user might create persistent indexes as a response to the signal Fixes: QTBUG-93466 Pick-to: 6.2 5.15 Change-Id: I73c24501f536ef9b6092c3374821497f0a8f0de4 Reviewed-by: David Faure <david.faure@kdab.com>
* Support pt units for sizes, as documentedVolker Hilsheimer2021-07-201-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | Declaration::lengthValue only supported 'px' sizes, but one can transform any 'pt' value into 'px' by multiplying with 1.33. Notes: this ignores display DPI, and instead follows the W3C definition of 'pt' and 'px' as absolute lengths [1]. [1] https://www.w3.org/TR/css3-values/#absolute-lengths 1pt = 1/72th of 1 inch 1px = 1/96th of 1 inch so the conversion is px = pt * (72/96). Add unit test that verifies this using QPushButton's icon-sizes property, also with changed font in preparation of adding support for 'em' and 'ex' units in a follow up commit. Task-number: QTBUG-8096 Pick-to: 6.2 Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> Change-Id: I58782e7ad0e2ff9d89ed695f8a23b1e584cfed64 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* tst_QComboBox: fix -Wsuggest-overrideMarc Mutz2021-07-181-1/+1
| | | | | Change-Id: I6fce7f84cf1578ac0e4ee0b2d7da579b54d78ec3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_QGraphicsScene: fix compiler warning about misleading indentationMarc Mutz2021-07-171-4/+4
| | | | | Change-Id: I532b5eeb0d4f9632f517deef61a7528bcb4151c6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QListView: don't scroll if selected items are removedVolker Hilsheimer2021-07-161-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | For SingleSelection, removing the selected item will select the nearest item and, if autoScroll is enabled, ensures that the newly selected item is visible in the viewport. This may result in scrolling. For Multi- or ExtendedSelection, this should not happen, as having no selection is perfectly fine in those modes. However, QListView still tried to scroll to the current item in response to the currentIndexChanged signal. Since the currentIndex is at this point already hidden, the rectangle for it became invalid, and the attempt to scroll resulted in a one-pixel up-movement of the viewport (since the invalid rectangle has width == height == -1). Fix this by not scrolling if the rect for the index is invalid. Note that the index is still valid at this point, so we can't shortcut the call stack earlier. Add test that exercises the different combinations of ViewMode and SelectionMode, and demonstrates the one-pixel movement without the fix. Fixes: QTBUG-94788 Pick-to: 6.2 6.1 5.15 Change-Id: I1f36973eadb46e8c9b8b8068bc76ee09e9f490dd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMenu/QToolBar: remove addAction() functionsMarc Mutz2021-07-131-0/+13
| | | | | | | | | | | | | | | | | | | | They're now in QWidget itself. Remove them from the API, but not the ABI. The QToolBar case is straight-forward. QMenu is a bit more complicated: Since QT_CONFIG(shortcut) builds changed the signature of an existing function instead of adding/removing an overload, we have to deal with two cases: In a QT_CONFIG(shortcut) build, these overloads that take a trailing QKeySequence parameter have been deprecated and therefore cannot be removed. In a !QT_CONFIG(shortcut) build, the same functions are 1:1 copies of QWidget functions and can be removed (from the API). [ChangeLog][QtWidgets][QMenu/QToolBar] The addAction() functions have been moved down into QWidget. Change-Id: I49997b3440c137a1d4e3858d1d27d34a191e1eed Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QTableView: fix selection with rows and cells in ExtendedSelection modeChristian Ehrlicher2021-07-121-0/+72
| | | | | | | | | | | | QTableView stored the current row/column selection start in an own variable instead using currentSelectionStartIndex. This leads to an inconsistent behavior when the selection is done with a click on the header and then in a cell (and the other way round) Fixes: QTBUG-92561 Change-Id: I4c8bda3a938de451b6eff2819141e86a6870fbef Pick-to: 6.1 6.2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix auto completion in QFileDialog on WindowsVolker Hilsheimer2021-07-091-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends c0b3c06a7d4f6a2f90742e8dc81c898082a70416. The QCompleter used by QFileDialog uses starts-with matching of the path parts, for all parts of the path. It uses the EditRole of the underlying model for the data to match. The path parts used for a path on Windows are "C:", "Users", "etc...", and then finally whatever input has been typed so far. If we try to match that against a starts-with rule against "Local Disk (C:)", then it will fail and the completer will never have anything to show. So, for the EditRole, return just the volume drive letter as we did before c0b3c06a7d4f6a2f90742e8dc81c898082a70416, not the volume name. Neither can be edited anyway. This happens to then match the native file dialog behavior, which doesn't complete "L" to "Local Disk (C:)" if the Computer contents (ie. volumes) are shown. Augment the QCompleter test case to cover that scenario (it already has everything set up for this particular combination, even though we are actually testing QFileSystemModel returning the correct data). Fixes: QTBUG-94799 Task-number: QTBUG-78043 Pick-to: 5.15 6.2 6.1 Change-Id: I14844d91601e9b16dc07cff2ca48713acb7cdd09 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix placement of placeholder text in QLineEdits with action iconsVolker Hilsheimer2021-07-061-0/+66
| | | | | | | | | | | | | | | | | | | | After dc794f7622bc00f7ca50fab65d6965695d6d2972, side widgets only got space if they were not fading out, but the logic was not correctly accounting for side widgets that never fade, such as buttons added via QLineEdit::addAction. Fix this to give visible widgets space, unless they are fading out. That was the intent of the original change. Rename the variable to make its purpose clearer, and reset it at the end of the fade-out animation. Add a much-needed test that relies on private APIs to verify that the effective margins are calculated correctly. Fixes: QTBUG-94824 Pick-to: 6.2 6.1 5.15 Change-Id: If2ee6be52be9e4f9be1e91f72f27681ce27def6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix memory leaks in tst_qlineeditAndreas Buhr2021-07-061-2/+2
| | | | | | | | | | | | In the unit tests, two times a validator was used without a parent, which led to memory leaks. This patch changes this: The validators are initialized with the widget they are meant for as parent. This fixes the memory leaks. Pick-to: 6.2 Change-Id: I480c0c5104cbe60159fad49df28cbb6240e7ce68 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Repolish child widgets when parent style sheet changesVolker Hilsheimer2021-07-051-0/+14
| | | | | | | | | | | | | | | | | | | If a child widget that is affected by the parent's style sheet is polished (because it's been shown explicitly, for instance by a layout), then it must be repolished when the parent's style sheet changes, even if the parent itself has not been polished yet. Since the style sheet is set on the parent widget, we must repolish the parent (which will repolish the entire widget tree), not just the individual children and grand children. Fixes: QTBUG-76945 Task-number: QTBUG-39427 Task-number: QTBUG-18958 Change-Id: I7bca9ee1badc07202fa05dc97f440f4ca6c9517d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Use UTC when parsing only a date or only a time, not a date-timeEdward Welbourne2021-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This should reduce the amount of fall-out from DST complications. Also document the assumptions of QDateTimeParser's two fromString() methods (and fix the punctuation on the QDateTime parameter). Adjusted some tests to match. Since only QDateTime-returning methods will show the difference, and it's at least somewhat odd to be using those on QDateEdit or QTimeEdit, this should have little impact on API users. [ChangeLog][QtCore][Behavior Change] QDateEdit and QTimeEdit now operate in UTC, to avoid spurious complications arising from time-zone transitions (e.g. DST) causing the implicit other half to combine with the part being edited to make an invalid result. Returns from their dateTime() and other methods returning QDateTime (max/min) shall thus be in UTC where previously they were in local time. QDateTimeEdit continues using local time. The default can be over-ridden by setTimeSpec(), as ever. Change-Id: I44fece004c12342fe536bbe3048217d236fd97b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of day-of-week in QDateTimeParser and QDateTimeEditEdward Welbourne2021-06-231-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDTP's absoluteMax(), setDigit() and getDigit() simply treated day-of-week as synonym for day-of-month. Consequently, QDTE::stepBy() did the same. This meant that wrapping happened at the month boundary, so would jump within the week if it wrapped around, otherwise the up/down arrow would "jam" at a particular day of the week when further steps would leave the month. Instead, when wrapping, wrap round the week while still moving the day-of-month to match, jumping back or forward a week to stay within the month on hitting a month boundary; otherwise, stop backwards stepping on hitting the locale-specific day of the week, or forward stepping when the step would be to or past this first day. Fixed various bugs found in the course of testing this. [ChangeLog][QtWidgets][QDateTimeEdit] Corrected handling of weekdays. Previously, changes to the week-day were simply changes to the day of the month. Weekday fields are now handled as such: changes to them do change the day of the month, but a change that would step past the end (or start) of the month is adjusted to the relevant day of the nearest week within the month. When wrapping is disabled, the locale-specific first and last days of the week are the bounds. Formats which specify day of week but not day of month will now preserve day of week when changing month or year, selecting the nearest day of month that matches. Change-Id: I7868b000fea7a4bc17a1b5687c44bcd56d42ae90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWidgetAction: add test for defaultWidget() being deleted before actionMarc Mutz2021-06-221-0/+12
| | | | | | | | | ... even though the documentation states that the action takes ownership of the widget. Change-Id: Ie5520fbda295a5a2774ff8b82165070e9d49e310 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* BLACKLIST tst_QListView::internalDragDropMove for OpenSUSE leapHeikki Halmet2021-06-211-0/+3
| | | | | | | | Task-number: QTBUG-94250 Change-Id: I9ea92b5952e1823cf90716f027f2f8eea1b86278 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
* Do not alter a widget's backing window's format once createdLaszlo Agocs2021-06-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing anything on a QWindow's QSurfaceFormat has zero and null effects once the underlying native window has been created. Letting QWidget update the format is wrong in this case, because we always expect that the value returned from QWindow::format() reflects reality. (reality being the settings with which the underlying native resource was created, which is typically frozen after QWindow::create(), not the state of some QWidget attribute. There are certain exceptions to this, such as when preparing to recreate the underlying native window, in which case one will want to update all relevant fields of the format based on the current values of the widget attributes, which is exactly what QWidgetPrivate::create() implements, and that's good.) Such a mismatch can have fatal consequences when OpenGL and friends are involved, but this always depends heavily on the platform and windowing system. For example, claiming that the alpha buffer size is 0 when the native window was created with 8, or vice versa, can break OpenGL-related code (both in Qt itself and in applications), that tries to create a QOpengGLContext configured based on what QWindow::format() returns. If that format describes settings that are incompatible with the actual underlying native window, we end up with the classic Invalid pixel format, EGL_BAD_MATCH, and alike errors. This is exactly what is happening when a QOpenGLWidget (or QQuickWidget) is placed in a QDockWidget where one of the ancestors is forced to native (winId() was called or WA_NativeWindow was set). When undocking, various code paths in QWidget will try to update the opaque flag of the widget, which in turn calls updateIsTranslucent. Now, if this function unconditionally changes the alphaBufferSize in the QWindow's QSurfaceFormat (even though this is completely futile to do, it has no visible effect in practice), we get the problem described above: rendering breaking down due to OpenGL contexts created with a pixel format incompatible with the native window. Prevent all this by not touching the format once the QWindow has a QPlatformWindow. This is the right thing to do, regardless of the bug in question: a window's (or context's or any other native resource wrapping class's) format must describe the underlying native resource and must never deviate, unless we are preparing to create a new native resource underneath. When it comes to the autotest, this changes the test added in 555661b625c40f21a6a3e4c73e928a6e8a46db20: the autotest logic is inverted because what we should test for is that the QSurfaceFormat stays untouched once the application makes a - futile - attribute change on the widget. Fixes: QTBUG-85714 Pick-to: 6.2 6.1 Change-Id: I7bf90711867e8a0fd474895625bf9530a7821fd5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix recursion crash when calling setStyleSheet with `qproperty-styleSheet`Zhang Yu2021-06-181-0/+18
| | | | | | | | | | | When calling `setStyleSheet` with property `qproperty-styleSheet`, `QStyleSheetStyle::polish` will call`QStyleSheetStyle::setProperties`, and then`QStyleSheetStyle::setProperties` goes on to call `setProperty`.Because there is property `qproperty-styleSheet`, it will update stylesheet by calling QStyleSheetStyle::polish`. This causes the recursive call to crash. Fixes: QTBUG-94448 Pick-to: 5.15 6.2 Change-Id: I79c51192a939b0b62e5b1d0dcc90d38f79e28222 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Stabilize flaky scrollerSmoothScroll test caseVolker Hilsheimer2021-06-151-2/+4
| | | | | | | | | | | | | | This test failed when checking for a pre-condition of the tested scenario, so skip the test if that condition isn't met, as the test won't test anything. Amends b1fdcc8c0fefe0660302494618032342b623e199. Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-64543 Change-Id: I135cd5b45efcae111305b9be338eb5429d3b97d5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Prefer QFAIL("Informative message") over QVERIFY(false)Edward Welbourne2021-06-143-6/+6
| | | | | Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAIV: Don't open editor on release when press closed editorVolker Hilsheimer2021-06-141-0/+58
| | | | | | | | | | | | | | | | | A mouse press that transfers focus from an open editor back to the view will close the editor. To prevent that the corresponding release then opens the same editor again we need to know that the closeEditor call was caused by the mouse press. Since Qt first generates the focusOut event, and then delivers the mouse press, we have to start a zero-timer to check whether we are in the same event delivery process. If so, ignore the corresponding release. Add test case that simulates that chain of events. Fixes: QTBUG-20456 Pick-to: 6.2 6.1 Change-Id: I28fa32bfbc776db207c594c329961f575ae58ea9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Check scrollbar ScrollBarOverlap when computing QListView marginsZhang Hao2021-06-101-0/+31
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if QStyle::PM_ScrollView_ScrollBarOverlap returns true, the text displayed an empty line. Fix this by not reserving the width of the vertical scrollbar if the flow is TopToBottom and the vertical scrollbar, and QStyle returns true for PM_ScrollView_ScrollBarOverlap. Amends aeef92c3c33e4ebcb7e5d8dd955020f4f4600e84 Pick-to: 6.1 6.2 Fixes: QTBUG-94248 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I4d47c7e86bbb86474cb1a99bb26d8b67f0e8a7e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemView: block autoScroll from interfering with QScrollerVolker Hilsheimer2021-06-091-0/+62
| | | | | | | | | | | | | | | | When pressing an index in order to start a flick gesture, QAIV sets the current index. When QScroller changes state to Dragging, then QAIV restores the current index to what it was before the press, as the user is clearly scrolling the view. With autoScroll enabled, this will produce an ugly jump if the old current index is no longer in the viewport. To prevent this, disable autoScroll before restoring the currentIndex. Fixes: QTBUG-64543 Pick-to: 6.2 6.1 5.15 Change-Id: I3e0a18a6a179d80b9d810fce5aa658f0cfff9a29 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix scrolling of tab bar when the visible tab is wider than the visible spaceVolker Hilsheimer2021-06-091-0/+70
| | | | | | | | | | | | | | When finding the index we need to scroll to, use the one where both start and end of the tab rect are outside the currently visible section. Otherwise we wouldn't scroll when the left-most index ends outside the visible section. Add test, which requires that the scroll buttons have object names. Fixes: QTBUG-70498 Pick-to: 6.2 6.1 5.15 Change-Id: Id153c77dd5fca146612375e0ff39bd1f3e0536b1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix rearranging of icons in listview via drag'n'dropVolker Hilsheimer2021-06-081-2/+5
| | | | | | | | | | | | | | | | | | | | Since 0f1008a5936c903ca9448193df7df6117e2c617b, views record if they moved the item in the model, and prevent the deletion of the source item in QAbstractItemView by setting the dropEventMoved private data member. However, QListView in icon mode is special: it doesn't rearrange the model, it repositions the icons in the view. While the dropEventMoved logic was applied to the drag event filter to prevent deletion, the variable was never set in the filterDropEvent handler. The drop event got ignored, breaking rearranging of icons. Fix this by setting the dropEventMoved member in filterDropEvent. Fixes: QTBUG-94226 Pick-to: 5.15 6.1 Change-Id: I963f5db0f81bcd0d25eef05d9a265be00a5871f6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QAItemView: in MultiSelection, press deselects only if no drag can startVolker Hilsheimer2021-06-081-10/+19
| | | | | | | | | | | | | | | | | | | | In MultiSelection mode, items are by default toggled on press, which follows the example of standard Windows controls. However, when dragging is enabled, then the press might be the beginning of a drag'n'drop operation, and deselecting the item on press breaks the selection and user experience. Don't toggle the selection for presses on an already selected item that might get dragged; instead, wait for the release event. Extend the test case slightly to cover the special case. Dragging a selection in a drag-enabled and MultiSelection item view wasn't possible before either. Fixes: QTBUG-59888 Change-Id: Ibd3e95a71ea63dd1e9bc3c8a723eafa9a1c21afa Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* QAbstractItemView: don't toggle extended selection on Ctrl+PressVolker Hilsheimer2021-06-072-7/+30
| | | | | | | | | | | | | | | | | | | In ExtendedSelection mode, a Ctrl+Press might be both the start of a selection toggle, or the start of a Ctrl+Drag operation. If we already toggle on the press, then it's impossible to drag the existing selection while the Control key is pressed. Ignore Ctrl+Press events and let the corresponding release event toggle the selection. Adjust the relevant test cases accordingly. The QItemDelegate test case used a click+control event incorrectly, such an event doesn't change the clicked state and should not be eaten, and now it does change the selection, so fix the test. Task-number: QTBUG-59888 Change-Id: Ia76126e31c28bc97d3e93e54965bdb1d0b8ac6a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QAbstractItemView: add test for mouse selectionVolker Hilsheimer2021-06-031-0/+215
| | | | | | | | | | Covers all selection modes and various combinations of mouse press, click, drag, with or without modifiers. Task-number: QTBUG-59888 Change-Id: Ib8ddc319a89649338d55fbc47e5a7ccfed338af9 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAbstractItemView: don't block dragging after double clickVolker Hilsheimer2021-06-031-0/+95
| | | | | | | | | | | | | | | | | | | | | After d6551fe12520 it was no longer possible to start a drag with a double click (where the first click selects an item, and the second press+move starts the drag). Resetting the pressedItem variable to block the emission of the clicked() signal had this unwanted side effect. Instead, use an explicit boolean to store that the next release event will be the result of a double click, so that the clicked() signal is not emitted again (preventing the double-emission was the purpose of change d6551fe12520). Task-number: QTBUG-77771 Fixes: QTBUG-94087 Pick-to: 6.1 5.15 Change-Id: I082c5169d89eb980dcd7985ef3d302b6ff060fb9 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Olivier BARTHELEMY <perso.olivier.barthelemy@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QDateTimeEdit::editingRanged(): use QScopedPointerEdward Welbourne2021-06-031-16/+12
| | | | | | | | | | Test would previously have leaked on failure. While checking for other uses of delete-after-checks, simplify one place that tested deleting a calendar widget lead to recreation. Pick-to: 5.15 6.1 Change-Id: I9524902a02dd42793bcf71113c6799dc925ac4a0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix PageDown behavior and PageUPTang Haixiang2021-05-311-0/+51
| | | | | | | | | | | | | When the PageDown is pressed, the current's rect cannot be used to match the item, because we don't know the size of the rect. Move the rect by the height of the viewport, and then move the rect upwards until it matches the button <= viewport's bottom of the item Fixes: QTBUG-92583 Pick-to: 6.1 Change-Id: I210edc0e8b942984f3fc20e7752c6e1315152ea1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: propagate style change on widget to internal containerVolker Hilsheimer2021-05-311-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | When changing the style of the combobox, the change will not propagate to the internal container widget, so the changeEvent handler won't be called. This is correct (as per QWidget::setStyle documentation). QComboBoxPrivateContainer asks the combobox style for relevant settings, such as the frame style, which is then used for sizing and positioning. If the combobox's and container's settings become inconsistent, then the combobox popup will not get the correct size and/or position. Move some of the style-dependent changes into a separate function and call it when the QComboBox::changeEvent handles the style change so that both widgets have a consistent set of settings. Add a test case that verifies that the style is asked for the relevant setting when the style changes. Note: QComboBox does a lot of style-dependent setup work in different places, which is quite messy and complex. Trying to consolidate that further breaks tests though, so this change is doing the minimum necessary to fix the reported issue. Pick-to: 6.1 5.15 Fixes: QTBUG-92488 Change-Id: Ia957d504b2d800add26fc0565be727b5c08a5358 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix wrong variable initialization in tst_QScrollBar::task_209492Tor Arne Vestbø2021-05-261-1/+1
| | | | | Change-Id: Icf1f6da46caa7fb7f3bd308eaaf4e037af814d17 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Blacklist tst_QWidget::multipleToplevelFocusCheck() on SLES 15Allan Sandfeld Jensen2021-05-181-0/+1
| | | | | | | | Pick-to: 6.1 5.15 Task-number: QTBUG-64446 Change-Id: Ic1f7a1e7b89a9802e4d3103a6755d7df85b1fd81 Reviewed-by: Tarja Sundqvist <tarja.sundqvist@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Do not remove non-widget items when removeWidget() called with nullptrPiotr Srebrny2021-05-111-0/+24
| | | | | | | | | | | child->widget() returns null if the layout item is not a widget. Thus, calling removeWidget(nullptr) will remove all non-widget items such as layouts or strechers. Change-Id: I772c1158d0f7e8e2850b6e571b0405a2896f09b8 Pick-to: 6.0 6.1 5.15 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Check scrollbar visibility when computing QListView marginsChen Bin2021-05-111-0/+54
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if the text needs a newline display and the vbar is not shown, the width of the item was subtracted from the width of the scrollbar. In most cases, the listview needs to reserve the size of the scrollbar. But if the flow is TopToBottom and the vertical scrollbar is not visible, the width of the vertical scrollbar cannot be reserved. Fixes: QTBUG-92366 Pick-to: 5.15 6.0 6.1 Change-Id: I73cce691099a253d409019dbb3fe9a16e1830bb1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: take a style sheet's font into account when laying out tabsVolker Hilsheimer2021-05-061-0/+67
| | | | | | | | | | | | | | If a tab has a font assigned to it through a style sheet, then take the font size into account when calculating the contents rectangle. Add a test, which hardcodes the windows style to avoid flaky behavior when e.g. macOS lays tabs out in the center. Fixes: QTBUG-92988 Pick-to: 6.1 Change-Id: Ifb0ac97db7647cc25367972737be8878e50f6040 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMdiArea: Fix top level window title when using ↵Friedemann Kleint2021-05-061-1/+42
| | | | | | | | | | | | | | DontMaximizeSubWindowOnActivation When trying to find the original window title, check for another maximized sub window and use its title. Protect the calls to setWindowTitle to prevent the original title from being cleared. Pick-to: 6.1 5.15 Fixes: QTBUG-92240 Change-Id: I55175382ab261b4cf8b5528304adaaec4fbe2c31 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Blacklist and skip failing tests on macOS ARMTor Arne Vestbø2021-05-041-0/+2
| | | | | | Task-number: QTQAINFRA-4431 Change-Id: I4ae47bb461634d524995077501b54322f6beccf3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix wrong C-style cast, use correct QTest::keyClick overloadVolker Hilsheimer2021-04-281-1/+1
| | | | | Change-Id: Ic1e170a5f63da76067a48c3775c47e202948b616 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Android: unblock passing testsAssam Boudjelthia2021-04-274-24/+0
| | | | | | | | | | | | | | | | | | Those tests don't fail anymore and show in CI as BPASS, so we can safely, hopefully, unblock them Task-number: QTBUG-87429 Fixes: QTBUG-68974 Fixes: QTBUG-69166 Fixes: QTBUG-87403 Fixes: QTBUG-87411 Fixes: QTBUG-69083 Fixes: QTBUG-69084 Fixes: QTBUG-87426 Pick-to: 6.1 Change-Id: I831b955116c0f465319b9c5fc726dd98804d1c00 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QTreeModel calling beginRemoveRows twiceLuca Beldi2021-04-261-0/+16
| | | | | | | | | | | | | For items that are children of other items, removeRows calls beginRemoveRows directly and then once again inside takeChild() The signal blocker that dates back to the monolitic import from Nokia prevents the model from emitting extra signals but the persistent indexes are corrupted nonetheless. Fixes: QTBUG-90030 Pick-to: 6.1 6.0 5.15 Change-Id: I5bc4b2598bf13247683b113faeec22471f1f04a4 Reviewed-by: David Faure <david.faure@kdab.com>
* Mark obsolete QMessageBox members as deprecatedVolker Hilsheimer2021-04-231-0/+9
| | | | | | | | | | | | | | | | Those overloads have been documented as obsolete, but never been deprecated. Add the deprecation macros to trigger warnings as of Qt 6.2. The overloads taking a single StandardButton should not be deprecated until Qt 7, as otherwise porting from old to new API will require an unnecessary cast to StandardButtons for calls with only a single enum value. The unit test explicitly tests the deprecated members, so disable warnings there. Fixes: QTBUG-92483 Change-Id: I283ddce4681eafda2378607f999946e56bbb777e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QLayout: mark unsetContentsMargins as the RESET functionGiuseppe D'Angelo2021-04-211-0/+17
| | | | | | | | | | | | | | | | contentsMargins is a Q_PROPERTY on a QLayout. Qt 6.1 introduced QLayout::unsetContentsMargins() to reset the contents margins to the "default" ones (that the user can't know); that's the textbook description of a RESET function for the property. Add some tests also for unsetContentsMargins. [ChangeLog][QtWidgets][QLayout] The unsetContentsMargins() function now acts as the RESET function for the contentsMargins property. Change-Id: I463d88363c11f4a15ad3d6af71401d8698de1d41 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Re-layout QProgressDialog when setting the cancel buttonQiang Li2021-04-191-0/+24
| | | | | | | | | | | | | | Setting a cancel button on QProgressDialog more than once caused the layout to be invalid. The layout was only applied when the dialog resizes or the style changes, but not when a new cancel button is set. The solution is to update the layout() before showing the dialog when adopting new child widgets. Fixes: QTBUG-19983 Pick-to: 6.0 6.1 Change-Id: Id8fb1ac56e94a9bd97d4559a2e8d4835856fd7d0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add the "Territory" enumerated type for QLocaleJiDe Zhang2021-04-153-6/+6
| | | | | | | | | | | | | | | | | | | The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix some warningsAndreas Buhr2021-03-311-1/+2
| | | | | Change-Id: Ief00228f83e16421fb4eec4c678632d5c996624f Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Android: Add select and copy capability to read-only text widgetsPiotr Mikolajczyk2021-03-301-0/+18
| | | | | | | | | | | | | | | | In case of a read-only text editing widget it was imposibble to copy text from it. In QtWidgets you could not even see the selection handless. Text selection in QtWidgets module was filtered depending on readOnly property of the widget. Additionally, in InputMethod the read-only state was translated into disabled. Patch also makes the edit menu to be aware of the read-only status of the control - the menu items are different for rw and ro controls. Task-number: QTBUG-91417 Change-Id: Ic7b27f78678eeaa87a38607af787f254db1383b8 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Replace QTextDocumentResourceProvider with a std::functionVolker Hilsheimer2021-03-301-17/+11
| | | | | | | | | | | | | | | | | | | | | | 376e3bd8ecf40881685714f6f19e12d68e92127e added the new class for Qt 6.1, but during header review we concluded that using a class introduces complexity wrt instance ownership and API design that can be avoided by using a std::function instead. The functionality is tied to QTextDocument, so the type definition and the default provider API is added there. Since std::function is not trivially copyable, the atomicity of the previous implementation is not maintained, and concurrent modifications of and access to the global default provider from multiple threads is not allowed. The relevant use case can be supported by implementing a resource provider that is thread safe. Task-number: QTBUG-90211 Fixes: QTBUG-92208 Pick-to: 6.1 Change-Id: I39215c5e51c7bd27f1dd29e1d9d908aecf754fb7 Reviewed-by: Kai Koehne <kai.koehne@qt.io>