summaryrefslogtreecommitdiffstats
path: root/src/widgets
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Remove special cases in enter/leave event handlingVolker Hilsheimer2021-09-241-4/+2
| | | | | | | | | | The Cocoa QPA plugin no longer tracks popups, but dispatches enter/leave events when popups show and hide. So the special handling in tests and QWidgetWindow can go away now. Change-Id: Ib6ef00689de231996e5e57ecdd8fd0d4c861d68b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove fatuously true or false QT_VERSION checksEdward Welbourne2021-09-231-26/+0
| | | | | | | | | QT_VERSION is now at least QT_VERSION_CHECK(6, 3, 0), so remove all checks against Qt 6.0.0 or earlier. They are superfluous. Tidied up in some places in the process, particularly #include order. Change-Id: I2636b2fd13be5b976f5b043ef2f8cddc038a72a4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMessageBox: read geometry from the screen the message box belongs toRichard Moe Gustavsen2021-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The current implementation found a QScreen by using the position of the mouse in a call to QGuiApplication::screenAt(). From the documentation, this function is allowed to return nullptr if the position is outside the screen. From the stack track in the bug report, it seems very likely that the mentioned call returns nullptr. This is strengthen by the fact that the crash happens for messageboxes that are maximized, so that you need to click on the upper corner of the screen to close it. And then only when HiDPI scaling is in use at the same time. This patch will change the code to just use the screen that the widget is on instead. If no screen can be resolved, the call will default to primary screen. Fixes: QTBUG-96639 Pick-to: 6.2 Change-Id: I31f0301318b358be9619caa31cc831b9598d5f90 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deduplicate maybeQuitOnLastWindowClosed handlingTor Arne Vestbø2021-09-173-26/+38
| | | | | | | | | | | | | | | | | | The functionality now lives in QGuiApplication, and is triggered by QGuiApplication and QApplication after dispatching the close event to the window. The slight difference between how a Qt GUI and Qt Widget app determines if a window should contribute to the close-on-quit behavior has been abstracted into a QWindowPrivate helper. The additional checks that were in place for skipping out of the whole maybeQuitOnLastWindowClosed machinery have been kept. Task-number: QTBUG-53286 Change-Id: I81bd474755f9adb3a2b082621e5ecaa1c4726808 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Close QDialog via QWidget::close()Tor Arne Vestbø2021-09-163-8/+27
| | | | | | | | | | | | | | | By going via QWidget::close() we ensure that if there's a QWidgetWindow backing the dialog (which is almost always the case), we will plumb down to QWindow::close(), resulting in QEvent::Close events to the QWindow. Since we don't want QDialog subclasses to receive a call to a closeEvent override that they didn't receive before (and which they might interpret as rejection or cancellation), install a temporary event filter that eats the QCloseEvent resulting from the call to close(). Task-number: QTBUG-53286 Change-Id: Ie8f6f0cb3160acfd5865dc74f0a7b6d87f838724 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Always reset close-status of QWidget when trying to closeTor Arne Vestbø2021-09-151-5/+7
| | | | | | | | | | | | | | | | | Move the status setting and resetting back into handleClose so that we don't end up with it being set if handleClose is never called in response to a close attempt. This can happen when QWindow's platform window has already been destroyed. Since QWindow::close handles that case gracefully and returns true, we can safely call it multiple times. Add test coverage to verify that we get exactly those close event calls that we want. Change-Id: Ica77bf17c26d923c3b79b1e5a688addbc88a6277 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make the closeAllPopup helper virtual in QGuiApplicationVolker Hilsheimer2021-09-152-11/+13
| | | | | | | | | | | | | | QPA plugins might have to close popups for events that are not delivered to QWindow or QWidget instances. For instance, the Cocoa plugin has to explicilty close popups when the user clicks into the window frame. Expose this functionality through a virtual in QGuiApplicationPrivate, and move the QApplication implementation from a static helper into the override. Task-number: QTBUG-96450 Change-Id: I52be5710c8d7515b9ae2e4bbadb069df4b3ed546 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Compute NSWindow background color without checking styleMaskTor Arne Vestbø2021-09-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | The check for styleMask == NSWindowStyleMaskBorderless to decide whether to clear the NSWindow background was broken, as NSWindowStyleMaskBorderless has the value 0, but is only supposed to be compared to its companion NSWindowStyleMaskTitled (with value 1). A window can perfectly well be NSWindowStyleMaskBorderless and NSWindowStyleMaskMiniaturizable e.g., so by comparing directly to NSWindowStyleMaskBorderless instead of masking to the first bit first we ended up making miniaturizable windows non-translucent. We now check the Qt::FramelessWindowHint directly, and also whether the window is opaque. Ideally we'd have QWindow flags that could plumb WA_NoSystemBackground from Qt Widgets, as well as a background color property on QWindow to control the system background, but in the meantime we'll have to use the FramelessWindowHint heuristic. The QWidget docs have been updated to reflect this. Task-number: QTBUG-95042 Pick-to: 6.2 Change-Id: I0d40eecace60883c205ebb8c76cef1092cdf1144 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Close QWidget during destruction via QWindowTor Arne Vestbø2021-09-131-1/+5
| | | | | | | | | Ensures that the QWindow and platform machinery is involved in closing the widget. Change-Id: I4ca4ed0b1b31b835d62d2fc0a2158e34e15d710e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't hide QToolTip automatically when another window is closedTor Arne Vestbø2021-09-131-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QTipLabel has a global application event filter, looking for reasons to close the tooltip. To fix QTBUG-55523 an additional condition was added in 7c18cb4f83c4907b40abc0bf40c1573b02243b57 to also close the tooltip when intercepting QEvent::Close, but this was unnecessary, as the fix in 29205c53e46fb2fc9f8063a46fd5ef5e9be532db was sufficient. Furthermore, hiding the tooltip on close events turned out to cause issues when the closing widget/window was the tooltip itself, causing recursion. This was fixed by 24239aef35f856c4c06428077e3428cbfdc51775. (which unintentionally also changed behavior for WindowActivate, WindowDeactivate, FocusIn, and FocusOut due to the case fallthrough). As it turns out, there is another case that will close the tooltip prematurely, and that's when the Qt::UI_AnimateTooltip effect is enabled, which is the case on e.g. Windows. In that situation a QRollEffect widget is created for the duration of the effect, which is then closed after the effect finishes. When closing the effect via QWidget close, we'll end up with a close event, triggering QTipLabel to hide itself. Since the logic of hiding the tooltip when other windows close was never needed to fix the original issue in QTBUG-55523, we opt to remove it completely, instead of adding even more heuristics to the code. Task-number: QTBUG-55523 Change-Id: I8d341262c85fd2e8cf9c496974e46ae0e9245e5c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't exclude WA_DontShowOnScreen widgets for QWidgetWindow event processingTor Arne Vestbø2021-09-131-8/+8
| | | | | | | | | | | | | | | | | | The Qt::WA_DontShowOnScreen widget attribute does not limit whether a widget will be created (have a QWindow and corresponding QPlatformWindow). It only limits whether the widget will be shown. As a result, we need to respect and process incoming events on a QWindow level, just as any other window. Any considerations that may apply because of WA_DontShowOnScreen should happen further down in the event delivery. For example for the issue in 74aae00a4e8e70845e8092abbefa7830c386e66b, where QWidgetWindow::handleExposeEvent() cleared the WA_Mapped flag which was set by QWidgetPrivate::show_sys(). Change-Id: I187ebe14ea84538a3715f1d09fb1ba1ce93fcc82 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Update some links to Microsoft's documentationLuca Di Sera2021-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation links on `msdn.microsoft.com` and `msdn2.microsoft.com` now redirect to `docs.microsoft.com`. Some of the links in the documentation were to those domains. In particular: - An `\externalpage` link to the `Mitigating Cross-site Scripting With HTTP-only Cookies` article. - An `\externalpage` link to `Microsoft Actibe Accessibility Event Constants` - A link to the `RtlGetVersion` function in `qoperatingsystemversion.cpp` - A link to the `GetCommandLine` function in `qcoreapplication.cpp` - A link to the `KNOWNFOLDERID` constant in `qfiledialog.cpp` While the redirection works, our script to catch broken links on dev-snapshots builds of the documentation doesn't handle redirection correctly, reporting it as broken. Both to appease the broken-links script and to avoid an unneccesary redirection, the above links were modified to point to the equivalent address in the new domain. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I0e9a132f06af7fc43bca6c8ad2054feb6e3e27cd Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Set Qt::SubWindow on windows embedded by QWidget::createWindowContainerTor Arne Vestbø2021-09-101-0/+2
| | | | | | | | | | | | | | | The embedded window is parented into the containing QWindowContainer widget, which may either have a window handle itself, or is a child of a widget that has one (typically the top level). By setting Qt::SubWindow we inform clients about the embedded window's place in the world, allowing e.g. QPlatformIntegration::defaultWindowState to choose the correct state (Qt::WindowNoState) for the window instead of making it Qt::WindowMaximized on iOS. Pick-to: 6.2 6.2.0 Change-Id: Icf834192d99fee455aaba3c57bee1a4f1fde5025 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* macOS: Don't show QMessageBox::about(Qt) as modal windowsTor Arne Vestbø2021-09-091-0/+2
| | | | | | | | | | | | | | | | The system behavior is to not show these kinds of dialogs as modal, and we've documented that for QMessageBox. However, calling show() instead of exec() is not enough, as the default constructor of QMessageBox will set the modality of the widget to application-modal. We need to explicitly override this. [ChangLog][macOS] QMessageBox::about(Qt) now shows dialog non-modal, as documented. Pick-to: 6.2 Change-Id: I6bb59efb81feb23122276a9eede71b2f20c9d7c6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Split up close handling in QWidget into a pre and post stepTor Arne Vestbø2021-09-074-22/+31
| | | | | | | | | | If we are the one initiating the close (from Qt Widget land), we want to mark the widget as closing as early as possible. Clarified the role of close_helper by renaming it to handleClose. Change-Id: Iae250a0ae1583d743c59e99fcb99fdf18d2a1882 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Refactor QStatusBar to reduce memory allocationVolker Hilsheimer2021-09-071-80/+62
| | | | | | | | | | | | | | | | | | | Reading through the code contemplating what might have caused QTBUG-89141 brought up some opportunities for improvement. * updated coding style and variable names * use ranged for where possible and meaningful * replacing a QList of pointers to heap-allocated structs with a list of values Since the QList population code makes sure that we never have gaps (we only insert within the existing range), the test for null-entries is not needed, and was perhaps just precausion to avoid nullptr dereference. Task-number: QTBUG-89141 Change-Id: I4694d820427a221f1334d2428f50069751919aef Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Forward touchEvents to children inside QGraphicsProxyWidgetVolker Hilsheimer2021-09-063-13/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reapplies the fix from 1ecf2212fae176b78c9951a37df9e33eb24d4f2d, using QApplication::translateRawTouchEvent to dispatch the touch event received by the QGraphicsProxyWidget to the relevant child widgets under each touch point. In addition, limit the implicit grabbing of each touch point before sending the event to those cases where we have to: touch pads, and if the target widget comes from a closest-widget matching. And don't call the QTouchEvent override of QEvent::setAccepted() on QTouchEvent instances in QGraphicsView classes, as this will override each event point's acceptance state. This way, we can identify which touch points have been accepted after event delivery, any only implicitly grab those points that were. Otherwise, touch points not accepted by a proxied widget hierarchy will still be part of an accepted event, and be grabbed by the viewport of the QGraphicsView. This would then lead to infinite recursion when the QGraphicsProxyWidget passes the TouchUpdate event on to each touch point's grabber. Re-activate the test case, and extend it with more combinations. Refactor touch-event recording to make it easier to test multi-touch scenarios. Task-number: QTBUG-45737 Fixes: QTBUG-67819 Pick-to: 6.2 Change-Id: Id5611f4feecb43b9367d9c2c71ad863b117efbcb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Revert "Ensure versionless wrappers do not introduce a new variable scope"Craig Scott2021-09-061-4/+5
| | | | | | | | | | | | | This reverts commit 08180e76e6116f0ef66476ca00b2b676b3aa50da. Macros add another level of escaping that functions do not. The conversion of the versionless wrappers to macros may alter the behavior, so revert that change. Task-number: QTBUG-96219 Pick-to: 6.2 Change-Id: Ic5dcff3081123d957888584ba1d76ae0580d9083 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Partially modified to use C++11 standard nullptrchenbin2021-09-061-1/+1
| | | | | Change-Id: I0542c47d1979235206005bf603822b6ea415f2da Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: fix qdoc warning, add \inmodule for qdrawutil headerVolker Hilsheimer2021-09-051-0/+1
| | | | | Change-Id: Iddc0273778adf79250b4e767172b1202817507bb Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QMessageBox: Reset clickedButton for each invocation of the dialogTor Arne Vestbø2021-09-041-0/+1
| | | | | | | | | | When showing a messagebox that has already been show we don't want to keep around the clicked button of the previous invocation. Pick-to: 6.2 Change-Id: Ib6f6293d40ab338c550ea344094db871ccf45c46 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Doc: add more notes about full screen windows on macOSVolker Hilsheimer2021-09-031-3/+10
| | | | | | | Fixes: QTBUG-68069 Pick-to: 6.2 5.15 Change-Id: I8fc99f708cfa19a9c8cc8d13f6889549c79dd3b3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: fix qdoc warnings from wrong parameter typeVolker Hilsheimer2021-09-031-2/+2
| | | | | | | QWidget::addAction takes a QKeySequence, not a QShortcut. Change-Id: Ia10adcf50133b306d484a122ed17dddcf94372a6 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Remove unsupported customFiltersKai Köhne2021-09-031-4/+0
| | | | | | | | | | | customFilters defined in .qdocconf are not supported anymore by Qt Assistant since Qt 5.13. Therefore remove them from all .qdocconf files, also to avoid cargo-culting them to new help modules. Task-number: QTBUG-95987 Change-Id: I664391460637d2e859348da0338e1a4a3ee9f570 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QWidget: close the QWindow in QWidget::closeVolker Hilsheimer2021-09-022-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | We want to close the window, end full screen mode on macOS, and free platform resources. This is all done by QWindow::close. QWindow::close closes the platform window, triggering a closeEvent to QWidgetWindow, which then calls QWidgetPrivate::close_helper. This way, closing a window via QWidget::close, QWindow::close, or interactively by the user are all equivalent. The QCloseEvent generated by the widget needs to be spontaneous for window-system generated events (i.e. the user clicked the close button), and non-spontaneous if the window closes because of a call to QWindow::close. To keep track of whether the event originated in an explicit call to QWindow::close, add a boolean to the QWindowPrivate. Add a test case that verifies that the window resources is destroyed, and that events are delivered as they should. Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Fixes: QTBUG-46701 Pick-to: 6.2 Change-Id: Iacb6a2c8d5e880b16b0c8f0c9257ed94bed36f5b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QListView assert when the last row is moved in IconModeChunLin Wang2021-09-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | After the last row is moved, 0 will be returned when obtaining row and column data. At this time, QListView::doitemslayout will not call d->doitemslayout, so the QBspTree data structure will not be cleaned up, leaving a stale tree structure behind. This will trigger an assert during paintEvent handling if QListView is set to IconMode In QListView::ListMode the test for a valid model index doesn't use an assert. Call QListViewPrivate::clear explicitly if the column count is 0 so that the QBspTree and other data structures are cleared. Add a test case that simulates this scenario by implementing a model that returns a 0 column count for an index after the model structure was changed through a move of rows. Done-with: Volker Hilsheimer Fixes: QTBUG-95463 Pick-to: 5.15 6.1 6.2 Change-Id: I36419be5459b8ced930c619f538482ea1db4ad03 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-0111-22/+18
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFileDialogComboBox: member variable is not initializedYang Yuyin2021-08-312-11/+4
| | | | | | | | | | initialize d_ptr in the constructor Pick-to: 6.2 Change-Id: I5a8062dd0a81023e6c1a5858bb8603d279cdbcee Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Ensure versionless wrappers do not introduce a new variable scopeCraig Scott2021-08-311-5/+4
| | | | | | | | | | | | | | Using function instead of macro prevented the wrappers from being able to pass back any variables set in the wrapped function. In some cases, these variables were being explicitly passed back to the caller, but that isn't needed if you just make each wrapper a macro. This also makes things more future-proof because any newly introduced output variables will work without having to update the wrappers. Task-number: QTBUG-96121 Pick-to: 6.2 Change-Id: Ic4486de668694c06b47e466587b2cdcb969ea047 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Revert "Forward touchEvents to children inside QGraphicsProxyWidget"Volker Hilsheimer2021-08-302-12/+9
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 1ecf2212fae176b78c9951a37df9e33eb24d4f2d. The fix is not correct after all. TouchBegin goes to the correct widget with the fix, but following TouchUpdate and TouchEnd events now go to the viewport, as QApplication::translateRawTouchEvent always gives precedence to the widget that Qt recorded to be the touch grabber, which is the viewport. This results in infinite recursion, as the proxy widget trying to send the touch events to the embedded widget (expecting that translateRawTouchEvent will split it up) ends up sending the events back to the viewport. Leave the added test case as QEXPECT_FAIL, reactivate the (never run, hence unnoticed) test that the fix broke. Pick-to: 6.2 6.1 Task-number: QTBUG-45737 Task-number: QTBUG-67819 Change-Id: I4810affb3cd066743ae94ab7beb2f0c06b60d211 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QToolButton: reimplement the fix for QTBUG-95255Giuseppe D'Angelo2021-08-272-7/+10
| | | | | | | | | | | | | | | | | The code in 188d739400e10fc8571bbf2ec86d5cd338b04a5d uses a connect() to a lambda, passing UniqueConnection to avoid establishing the connection more than once. The problem is that UniqueConnection does not work with lambdas; it works only with "regular" PMFs to QObject subclasses. Re-do the same fix, but without a connection: use the checkStateSet() virtual from the base class that will notify us if setChecked() is being called on the tool button, and from there synchronize the state of the default action. Change-Id: Id512812c562cd6d20bc1a489753b33c269919d32 Fixes: QTBUG-95255 Pick-to: 6.2 6.1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGraphicsView: send timestamp information through QGraphicsSceneEventVolker Hilsheimer2021-08-264-0/+34
| | | | | | | | | | | | | | | | | Qt relies on event timestamp information to detect double click events. The information was not passed through QGraphicsSceneEvent, so the synthesized QMouseEvent delivered for the second press of a double click to an embedded widget was never recognized as a double click. This requires addition of a new setter/getter to QGraphicsSceneEvent. Event though not all QGraphicsSceneEvent instances will have a valid timestamp, this provides us with more flexibility than adding the API to several QGraphicsSceneEvent types (mouse, touch, wheel). Pick-to: 6.2 Fixes: QTBUG-96009 Change-Id: I343f25902286157f6d6670641dfad9c92dd44250 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Refactor QApplication::translateRawTouchEvent to take a QTouchEvent*Volker Hilsheimer2021-08-264-21/+11
| | | | | | | | | | | | Both call sites just pass the data from an existing QTouchEvent through, so just pass the QTouchEvent through instead. Amends 20d4f45a132606f7a910050d468519108486e9cf. Pick-to: 6.2 Change-Id: If3b9508b83311889b58e109e7f64743985b8b178 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Forward touchEvents to children inside QGraphicsProxyWidgetVolker Hilsheimer2021-08-263-12/+19
| | | | | | | | | | | | | | | | | | | | Just sending the event to the embedded widget is not enough, we have to perform hit-testing for the different touch points, and send the event to the child widget under the point. Fortunately, QApplicationPrivate::translateRawTouchEvent provides the logic that generates multiple events for groups of touch points. Since that helper always sent events spontaneously, add an optional parameter to allow sending of non-spontaneous events. Add a test case that simulates touch events to different widget configurations inside a QGraphicsProxyWidget. Fixes: QTBUG-67819 Task-number: QTBUG-45737 Pick-to: 6.2 6.1 5.15 Change-Id: Iffd5c84c64ee2ceadc7e31863675fdf227582c81 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QGraphicsProxyWidget: forward Window(De)Activate eventsVolker Hilsheimer2021-08-241-0/+4
| | | | | | | | | | | | | | | | | | The nested widget might be a QGraphicsView as well (documented to be supported), and QGraphicsScene maintains it's own activation status by counting Window(De)Activate events. We need to make sure that the embedded widget is informed about its activation status so that deeper nested children can receive focus. Forward WindowActivate/Deactivate events to the nested widget, which will pass it on to all its children. Add test case, which without this fix fails when verifying the inner scene's isActive state, or later when testing that focusInEvent is delivered to the embedded widget. Fixes: QTBUG-94091 Pick-to: 5.15 6.1 6.2 Change-Id: I4e0ecef50685ed081d15c7f76b6c1a4a40ed2682 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QLineEdit: account for the placeholderText when computing lineRectZhang Hao2021-08-231-3/+10
| | | | | | | | | | | | | | | If in a QLineEdit the placeholderText uses e.g. Tibetan language, then the height of font as reported by QFontMetrics might be less than the height of the boundingRect calculated for the placeholderText. This can cause the placeholderText to display incompletely. Fix this by using QFontMetrics::boundingRect instead of QFontMetrics::height when computing lineRect. Fixes: QTBUG-95341 Pick-to: 5.15 6.1 6.2 Change-Id: I9eef35fd89c5c1d79f6dd703355634d6905ca967 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Add global \versionlessCMakeCommandsNote qdoc macroJoerg Bornemann2021-08-231-3/+2
| | | | | | | | | | | | | | When documenting a CMake command, document the unversioned command 'qt_foo' and use '\versionlessCMakeCommandNote qt6_foo' to refer to the versioned command. This avoids duplicating the command signature. Use the new macro where applicable. Pick-to: 6.2 Task-number: QTBUG-95796 Change-Id: I2e4180fbda0b89acf3d8c036459f591eb2f46475 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Modify the internal rectangle drawing of CE_RubberBandTang Haixiang2021-08-231-4/+7
| | | | | | | | | | | | | | | | | adjusted(1, 1, -2, -2) makes the rectangle smaller, but when rect.x1-rect.x2 = 0. Then x1 + 1, x2-2 leads to x1> x2. This will make the rectangle flip in advance. So there is a difference between the updated area and the drawn area. Add a judgment, when the rectangle we get is large enough, draw the inner rectangle. Fixes: QTBUG-95716 Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io> Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Pick-to: 6.2 Change-Id: I0d081a4ad7aee4a563acb988c0ef19a646bf1eea Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QScroller::scrollTo failing in QGraphicsView with movable itemChunLin Wang2021-08-201-1/+1
| | | | | | | | | | | When forcing software scrolling through QScroller::scrollTo, it will start from (0, 0). QGraphicsViewPrivate::canStartScrollingAt should consider the locationof points, not just the flags of item. Fixes: QTBUG-70255 Pick-to: 5.15 6.1 6.2 Change-Id: Iebdd5568baa3bdb41c705204dadb2895cfe9c0e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Remove unnecessary type conversionZhang Qipeng2021-08-201-1/+1
| | | | | Change-Id: I3d1b998b84753706ee78ecb5e498f70e9f935fd5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Report ImAbsolutePosition for QLineEditTor Arne Vestbø2021-08-181-0/+1
| | | | | | | | | | | ImAbsolutePosition was added in f8dbed12266c42785c1e4758eed05833ec035f33, based on requirements on Android, but without an implementation for QLineEdit. It would seem sensible to fall back to the cursor position in this case, as QLineEdit doesn't support multiple blocks. Pick-to: 6.2 Change-Id: Iff1255270ceef069f03ce457df633d7b675f1a28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: don't overwrite data, fix refactoring error for vertical tabsVolker Hilsheimer2021-08-181-1/+1
| | | | | | | | | | | | | | | | | | | Amends 359616066e64eed947c6c91cb8902285ed79dd0d, which incorrectly changed - tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); + tab->data = QRect(0, miny, sz.width(), sz.height()); in the code laying out verticals tabs (correct done for the horizontal case). Since QDockWidget uses the user data for tabs to maintain the mapping between tabs and dock widget, this broke the layout logic. Fixes: QTBUG-95841 Pick-to: 6.2 6.1 Change-Id: Ie785e1205b426bbc4954b965f619f4c603490f76 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFileDialog: Use static const QRegularExpressionWaqar Ahmed2021-08-181-1/+1
| | | | | | | This avoids rebuilding the same pattern. Caught by clazy. Change-Id: Ibd0f2063617df1a9e975f58e34df556d1983afff Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QStyle: allow styles to control the margin around icons in QLineEditWang Peng2021-08-174-2/+8
| | | | | | | | | The styles can't control the margin of the icon container, and its value is hardcoded to a quarter of the iconSize, which is very unfriendly. Add a PixelMetric enum value to allow styles to control the margin. Change-Id: I21274b68d24150db7be78513fe9125f775aa2b00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGraphicsProxyWidget: fix propagation of high-precision eventsVolker Hilsheimer2021-08-165-12/+107
| | | | | | | | | | | | | | | | | | | | | | | | | In order to fix QTBUG-95552 properly we have to add APIs to QGraphicsSceneWheelEvent that informs QGraphicsProxyWidget about whether the event is a high-precision event where Qt grabs the wheel. If it is, then the wheel grabber will be the QGraphicsView's viewport, and any wheel event sent to any widget will be grabbed by it. This results in infinite recoursion, partly fixed in change I78400ceae8da7a4e22a988c06ed58f99f1a979f4. The proper fix is to re-grab the wheel by the embedded widget if it (or any of its children) accepts the ScrollBegin event (and if not, return the grab to the QGraphicsView). This fixes the scenarios that failed in the test case, so now scrolling through nested widgets and scrolling in nested widgets works as the user would expect. Fixes: QTBUG-95552 Pick-to: 6.2 Change-Id: I3e1f31cbff999c70f8c63c034f77cd2ae567d7e3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Don't crash in high-precision wheel scrolls on a QGraphicsProxyWidgetVolker Hilsheimer2021-08-162-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For high-precision wheel scrolling sequences, the widget that gets the first (typically ScrollBegin) event grabs the wheel. Qt directs all future wheel events within the same sequence (i.e. until ScrollEnd) to that widget. QGraphicsView passes wheel events through to the item under the mouse, and QGraphicsProxyWidget implements wheelEvent to forward a synthesized QWheelEvent to the embedded widget. Since QGraphicsView's viewport has already grabbed the wheel, any forwarded event would end up back in QGraphicsView, resulting in infinite recursion (if the assert doesn't fail first in debug builds). The correct fix requires that QGraphicsProxyWidget knows that this is a high-precision wheel event, allowing it to adjust the wheel grabber temporarily to the embedded widget. However, QGraphicsSceneWheelEvent doesn't provide this information. To fix the infinite recursion, mark the generated event as synthesized by Qt (but still send it spontaneously to enable propagarion within the proxy widget hierarchy). In QApplication's notification routine, interpret such events then to override the wheel grabber. Add a test case for the various scenarios. This 6.1 compatible fix does not pass all situations. A follow up commit that introduces the missing APIs to QGraphicsSceneWheelEvent then fixes those as well. Task-number: QTBUG-95552 Pick-to: 6.1 6.2 Change-Id: I78400ceae8da7a4e22a988c06ed58f99f1a979f4 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Accept the QWheelEvent before each propagation stepVolker Hilsheimer2021-08-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | Input events in Qt are accepted when constructed, and ignored by the default event handler (so overriding the event handler is enough to accept an event). Since we use the same QWheelEvent instance for each propagation step, we need to reset the event to be accepted before each delivery so that an earlier child ignoring the event doesn't result in the event being ignored without explicit acceptance. Amends the refactoring of wheel event delivery in 92df790f46b3a8b17aec2f385d6472fd3f8647f6. Task-number: QTBUG-95552 Task-number: QTBUG-79102 Task-number: QTBUG-67032 Pick-to: 6.1 6.2 Change-Id: Ib3f99792518364cf6e635cf4c6fda088051a7848 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* StyleSheet: Use rule for ComboBox in embedded QLineEditVolker Hilsheimer2021-08-121-6/+5
| | | | | | | | | | | | | | | | | An editable combobox uses an embedded QLineEdit as an implementation detail. That lineedit should use the rules that are set for the combobox to render itself, similar to what was already implemented for the lineedit used in a QAbstractSpinBox. The containerWidget helper function provides the logic for identifying the container of the rendered widget, returning the QAbstractSpinBox or the QComboBox for an embedded QLineEdit. Use that method rather than duplicating the logic. Pick-to: 6.2 6.1 5.15 Fixes: QTBUG-95631 Change-Id: I50bc92a62715608b11c2c923f8f9215f56bfd15e Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Close all popup windows when the screen is rotatedTang Haixiang2021-08-121-0/+2
| | | | | | | | | | | | | Changing the screen orientation will cause the menu position to be displayed incorrectly. When the screen is rotated, the geometry of the application changes. We can refer to the handling of the menu on Android or IOS. Close the popup window when the screen orientation changes. Fixes: QTBUG-95607 Pick-to: 6.2 Change-Id: I55e1cd6a8b89e375c6714a9163dfb1902d52f101 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Implement missing support for 'em' and 'ex' lengths in style sheetVolker Hilsheimer2021-08-102-23/+52
| | | | | | | | | | | | | | | | | | | | | | | | The Qt style sheet reference claimed that Length properties can be specified in 'em' or 'ex' units, but that was never implemented. Add the missing implementation. Since the sizes depend on the size of the font of the current element, we cannot convert the units in the CSS parser, but have to do so in the QRenderRule constructor, where we can make a decision about which font to use if the style sheet itself doesn't specify a font. Fall back to the widget font if possible; otherwise it will be the application default font. The implementation translates em into QFontMetrics.height, identical to what is already done in the QCssParser. This is in line with the CSS specification, but contradicts our previous documentation which stated that 'em' means "width of M". Fix the documentation. Fixes: QTBUG-8096 Pick-to: 6.2 Change-Id: I145e2504ae3b19101a0d0dd63653466b6c2cec1d Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>