summaryrefslogtreecommitdiffstats
path: root/src/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Widgets focus abstraction: Skip isFocusChainConsistent w/o logging catAxel Spoerl13 hours1-1/+6
| | | | | | | | | | | | | | | | | | QWidgetPrivate::isFocusChainConsistent() iterates over QApplication::allWidgets() to identify and log inconsistencies. In applications with many widgets, this has a major performance impact. Disable the check and return true, unless the logging category qt.widgets.focus is enabled. Adapt tst_QWidget::focusAbstraction() to enable the logging category. This amends 58d5d4b7c2faaeaa2c2ccdabb3da6d37f9db880a. Fixes: QTBUG-124666 Change-Id: Ia487b381ab45b052638b189bf56acaf4353b1a37 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Revert "QCommonStyle: paint arrows with anti-aliasing"Axel Spoerl13 hours1-4/+5
| | | | | | | | | | | This reverts commit 74e8f673b827c57ebf2bf802840c19e4a1ac848b. Reason for revert: the change as is makes the rendering of arrows in the styles unpleasantly blurry. Pick-to: 6.7 Change-Id: I59ccd7373631a550276465caffb7d3074ff5893c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QDialog: Add Q_ENUM to DialogCodeFriedemann Kleint34 hours1-0/+1
| | | | | | | This helps the dynamic Python bindings project. Change-Id: Ibe2c06f4a4e5fd9c3ca41884d811990ec9328b80 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Remove undefined method logicalIndexIngo Klöcker3 days1-2/+0
| | | | | | | The method isn't used and not even defined. Change-Id: If442806e8d4b7e5ac8f83bc783163c02bbabf47f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove obsolete commentIngo Klöcker3 days1-1/+0
| | | | | | | | The code this comment applied to was removed with b2ec0da95641d9cec006fa9699e6d082ad35db0b Change-Id: I15191c0e9f134375069647d1276a0d60d6360813 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: don't use a QImage when drawing arrowsChristian Ehrlicher5 days1-11/+8
| | | | | | | | | | Using a QImage as a paintDevice is not needed - directly paint on a QPixmap. Also use styleCachePixmap() which avoids the need for multiplying the size with the dpr. Change-Id: I114f78c20d2b92b4fd135c8f64b452fb81a02baf Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* QStyleHelper: pass devicePixelRatio to uniqueName()Christian Ehrlicher5 days5-11/+14
| | | | | | | | | | | QStyleHelper::uniqueName() took the size of the pixmap to cache but not the dpr. This might lead to a situation (e.g. in a multi-display environment) where we use a pixmap with the wrong dpr and get a pixelated result on the screen. Change-Id: Ifdebeddff3380931398b3284a7757b7da950caa9 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* QStyle: let styleCachePixmap() use the correct devicePixelRatioChristian Ehrlicher5 days2-29/+17
| | | | | | | | | | | | | The helper function styleCachePixmap() might not be using the correct dpr. It was written in a time when there was only one application-wide dpr available but nowadays we have to use the dpr from the paintDevice we paint on instead. As a drive-by replace the one usage of styleCacheImage() by styleCachePixmap() and remove the now superfluous function. Change-Id: I14eb3fd3bad7f9299d42b63b03fa1f68b4f81cd6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* QStylePrivate: remove unused member layoutSpacingIndexChristian Ehrlicher5 days1-4/+0
| | | | | | | The member layoutSpacingIndex is not used anywhere so it can be removed. Change-Id: I0d8bc3b0ce8cf7ab26c3fd11977cfc9bffc42106 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: paint arrows with anti-aliasingChristian Ehrlicher5 days1-5/+6
| | | | | | | | | | | | | | | The high-dpi painting fix for the arrow painting was missing QPainter::AntiAliasing flag so the rectangle had some artifacts with certain (small) sizes. Also there is no reason to move the center by 1 pixel to the top left anymore now that we're using decimal values. This amends 3936d254ca0e7259cd97238c31df8413d03fd475. Pick-to: 6.7 Fixes: QTBUG-124554 Task-number: QTBUG-114539 Change-Id: I8a34d7ed937db261ce652bd66234783fb3338cbb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QGestureManager: use gesture owner target if topLevelAt returns nullptrLiang Qi5 days1-1/+2
| | | | | | | | | | For security reason, Wayland doesn't provide global position for top level windows, so topLevelAt is not supported. Fixes: QTBUG-113404 Pick-to: 6.7 6.5 6.2 5.15 Change-Id: Id60b8b77a1843344db4d4e4c13382ad87adac806 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Set focus to the window container when contained window gains focusDoris Verria5 days3-35/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it is, when a QWindowContainer's embedded window gains focus, the container doesn't report having focus and QApplication::focusWidget() will be nullptr. This is because when the embedded window gets focus, the container will clearFocus() on the old focus widget. To be able to set focus to the next focus widget (eg: as a result of a key tab event sent to the container's parent window), the container checks if its embedded window is already focused, and if so, forwards focus to its nextInFocusChain(). That is why it keeps track of the (old) focusWindow. The problem with the current behavior is that if we want to make focus navigation via key tabbing work and return focus *from within the window* back to the normal widget focus chain, the encapsulating widget needs to remember its focusWidget(), in this case the window container, in order to be able to set focus to the next/PrevInFocusChain(). That is why we now set the focus to the window container whenever its contained window gains focus. This means that QApplication::focusWidget() will be the window container if the contained window has focus. In this way, we don't have to call clearFocus() on the old focus widget, or keep track of focus windows, because calling setFocus() on the container will handle that. It is worth noting and probably documenting the following caveats: - even though the window container will be the qApp's focusWidget(), it won't directly handle keyboard events, but the contained window will - we won't be able to respect the window container's focusPolicy in this case, since the contained window will be activated from interactions inside it, no matter the container's focusPolicy [ChangeLog][QtWidgets][QWindowContainer] The window container will become focused if the contained window becomes focused. This implies that the QApplication::focusWidget() will be the window container if the contained window is the focus window. Task-number: QTBUG-121789 Change-Id: I1050afc59780f7189a0d8e8c95bff27f96f38dbc Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Convert "Color Editor Factory" Example to snippetsMohammadHossein Qanbari8 days4-17/+36
| | | | | | | | | | The color editor factory example is removed and part of the codes are used as snippets. Fixes: QTBUG-119985 Pick-to: 6.7 6.6 Change-Id: I421e473e7db09a5af7543b80b87a338d8ff2ab7e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QStyleSheetStyle: Don't try to load a pixmap with an empty filenameChristian Ehrlicher9 days1-0/+3
| | | | | | | | | | QStyleSheetStyle::loadPixmap() might be called with an empty filename but then it should not try to load a file with an empty filename. Pick-to: 6.7 6.5 Fixes: QTBUG-123839 Change-Id: Ie01e9f75f025650b0802736bb589ebdc48e93696 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Convert Group Box Example to snippets and screenshotsMohammadHossein Qanbari9 days3-3/+20
| | | | | | | | | | | | | Remove the Group Box Example from the repository, eliminating the associated example codes, screenshot, and documentation file. The only relevant portion used in the QGroupBox class has been relocated to the existing snippet file. Additionally, all references to this example across other files have been removed. Fixes: QTBUG-119980 Pick-to: 6.7 6.6 Change-Id: I66f9dd9dab1fe64f2d20424af3acd135201827d2 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Replace expensive inherits with cheaper qobject_cast (1)Volker Hilsheimer9 days1-2/+2
| | | | | | | | | | | The accessibility implementations require the type to be fully defined anyway in order to call type-specific APIs, so there's no need to use inherits(). Use qobject_cast instead. Pick-to: 6.7 Change-Id: I5c013be57f48272a748451f4888911fe6aa6574e Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Add preliminary support for Qt for visionOSTor Arne Vestbø9 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | Qt already runs on Vision Pro as "Designed for iPad", using Qt for iOS. This change enables building Qt for visionOS directly, which opens the door to visionOS specific APIs and use-cases such as volumes and immersive spaces. The platform removes some APIs we depend on, notably UIScreen, so some code paths have been disabled or mocked to get something up and running. As our current window management approach on UIKit platforms depends on UIWindow and UIScreen there is currently no way to bring up QWindows. This will improve once we refactor our window management to use window scenes. To configure for visionOS, pass -platform macx-visionos-clang, and optionally add -sdk xrsimulator to build for the simulator. Change-Id: I4eda55fc3fd06e12d30a188928487cf68940ee07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QWidget: Remove un-needed nullptr check for oldtlwTor Arne Vestbø10 days1-2/+3
| | | | | | | | | | | | | | | | | | Added in 1bd755465efa27294362925f55306f88f1800936 We already access oldtlw and oldtlw->d_func() in other places, and the source of oldtlw is a call to QWidget::window(), which returns the widget itself if it doesn't have a parent. This should also fix a CodeChecker issue where it thinks that the other unchecked accesses to oldtlw are suspicious. Add assert just in case, so we catch it explicitly if for some reason this assumption doesn't hold in the future. Pick-to: 6.7 6.5 Change-Id: Iefa9b2df6b25a993afe87e4ee90fe9d2075ebbd0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Long live [[nodiscard]] QFile::openGiuseppe D'Angelo10 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having already caught some bugs in real code because of unchecked calls to QFile::open, this commit marks QFile::open (and open() in other file-I/O classes) as [[nodiscard]]. Since it's going to raise warnings, the plan is to keep the existing behavior up to and including the next LTS. Then the warnings will switch on by default. All of this is protected by system of macros to opt-in or opt-out the behavioral change at any time. A possible counter-argument for doing this is that QFile::open is also used for opening files in the the resource system, and that opening "cannot fail". It clearly can, if the resource is moved away or renamed; code should at a minimum use a Q_ASSERT in debug builds. Another counter-argument is the opening of file handles or descriptors; but again, that opening may fail in case the handle has been closed or if the flags are incompatible. --- Why not marking *every* open() override? Because some are not meant to be called directly -- for instance sockets are supposed to be open via calls to `connectToHost` or similar. One notable exception is QIODevice::open() itself. Although rarely called directly by user code (which just calls open() on a specific subclass, which likely has an override), it may be called: 1) By code that just takes a `QIODevice *` and does something with it. That code is arguably more rare than code using QFile directly. Still, being "generic" code, they have an extra responsibility when making sure to handle a possible opening failure. 2) By QIODevice subclasses, which are even more rare. However, they usually ignore the return from QIODevice::open() as it's unconditionally true. (QIODevice::open() doesn't use the protected virtual pattern.) I'll try and tackle QIODevice in a future commit. [ChangeLog][QtCore][QFileDevice] The open() functions of file-related I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked with the "nodiscard" attribute, in order to prevent a category of bugs where the return value of open() is not checked and the file is then used. In order to avoid warnings in existing code, the marking can be opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically enable nodiscard on these functions starting from Qt 6.10. Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStyle: deprecate PM_DialogButtons* enumsChristian Ehrlicher10 days3-14/+6
| | | | | | | | | | | | The threee enumerations - PM_DialogButtonsSeparator - PM_DialogButtonsButtonWidth - PM_DialogButtonsButtonHeight Are not documented since Qt3 times and also not used anywhere. Therefore deprecated them and remove the logic to handle them. Change-Id: Ia59fe15482e744123e7fbf04b8d44661afb58b5c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: fix infinite loop when resizing rows/columns on model resetVolker Hilsheimer10 days1-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | When a slot is connected to the modelReset signal before the model is set on the view, then such a slot might try to resize the columns or rows to fit the contents before the view had a chance to perform layout work. In that case, the while-loop that calculated the size hint of a rows (or column) by checking the size hint of each cell might not exit, as cached information about visual indexes would be invalid. To prevent this, don't loop over the cells if the actual last row/column of the model (after the reset) is less than the first (cached) visible row/column. Also, make sure we increase the counter for number of rows/columns processed with each iteration. Add a test (that loops infinitely without the fix, resulting in the test being killed by the framework), and make the 'actual' variables constant for clarity. Fixes: QTBUG-124301 Pick-to: 6.7 Change-Id: I0adb2f1e8a1e78760ef7c19e9686c9572eca8be6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Doc: don't use deprecated function in QMenu snippetsChristian Ehrlicher10 days1-2/+2
| | | | | | | | | | | QMouseEvent::globalPos() is deprecated - replace it with QMouseEvent::globalPosition().toPoint() Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-124343 Change-Id: I6f862a9a640da11d756dae58ffae8c6d7fc24e02 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
* QTableView: fix cornerWidget connectionChristian Ehrlicher14 days1-1/+1
| | | | | | | | | | | A click on the corner widget should select all items, not reset the selection. This was accidentally added with 3e144bdc7484968dcccbda8f35ad802c7fd7a42e. Pick-to: 6.7 Fixes: QTBUG-124267 Change-Id: Ie20b7cf0ff730214dca80116ad888f42c2b7a670 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Revert "QStyleSheetStyle: Propagate CE_ItemViewItem drawing to baseStyle"Axel Spoerl14 days1-2/+2
| | | | | | | | | | | This reverts commit f39f2bfe0b216252980c082b1771540dd00e6bd6. Reason for revert: Breaks styling of treeview indicators. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-123632 Change-Id: I7922f58a9a1ace40ba788571a297443c1900baf2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Implement QWindowContainer::minimumSizeHint()Jan Arve Sæther2024-04-122-0/+9
| | | | | | | | | | | | It will return the minimumSize of the underlying QWindow. The container can then be put inside QLayouts without risking to be shrunk to a smaller size than the QWindow::minimumSize. Whenever the QWindow::minimumWidth or QWindow::minimumHeight changes, we call QWindowContainer::updateGeometry(), which will make the layout re-query QWindowContainer::minimumSizeHint() again. Task-number: QTBUG-121798 Change-Id: Ib7ece7d9d75f2e4964ca9042d8d8b95ce3b17739 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QComboBox: Revert recreation of ComboBox Container on style changeWladimir Leuschner2024-04-111-17/+1
| | | | | | | | | | | | In commit 9da8d67b3bca1d40ae221a9c6be218fe57759724 a recreation of the ComboBox Container was introduced, since QWindows11Style depends on WA_TranslucentBackground flag, whereas the other styles don't set this flag. This leads to the destruction of user supplied views we don't own. Fixes: QTBUG-124191 Pick-to: 6.7 Change-Id: I4a693f612ddc299696b9de0d87c94d88c04d9b39 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* StyleSheet: respect a font weight set for header sectionsVolker Hilsheimer2024-04-111-3/+6
| | | | | | | | | | | | | | | | | | | | | | QCommonStyle sets the font for a selected header section to bold. This overrides the font weight a calling style might already have set, e.g. when a style sheet is applied to explicitly set a weight for a checked header section: QHeaderView::section:checked { font-size: 20px font-weight: normal } Since setting the weight on a font sets the respective resolve-mask bit, we can avoid overwriting a weight that is already set explicitly. Add baseline test coverage using a QTableWidget. Fixes: QTBUG-122180 Pick-to: 6.7 6.5 Change-Id: I8c6279ad2fd8c5718ebea26e27c64ae823625748 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QToolButton: Don't crash if deleted while in event handlerSergio Martins2024-04-111-1/+3
| | | | | | | | | | | | | | | | | If QToolButton::mouseReleaseEvent triggers its deletion then it will crash when dereferencing its d pointer. qabstractbutton.cpp already uses QPointer guards in many places but qtoolbutton.cpp was missing this one. While deleteLater() is still our recommendation, we shouldn't crash. It's not always obvious what led to the button's destruction, as the chain of indirections can be long. Change-Id: I4a33447fa4e90953370277eb57a161398ded9a9c Pick-to: 6.7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QLayout: Consume ChildRemoved event, when layout is disabledAxel Spoerl2024-04-101-2/+3
| | | | | | | | | | | | | | | QLayout::widgetEvent() returned early, when the layout was disabled. That suppressed ChildRemoved events and lead to a crash, when the layout was enabled again. Don't return early on ChildRemoved events. Add an autotest in tst_layout::removeWidget(). Fixes: QTBUG-124151 Pick-to: 6.7 6.5 6.2 Change-Id: Ib0a0bb73978d9fc2c9777d300cf38a8c4496b702 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Chris René Lerner <chris.lerner@qt.io>
* QStyleSheetStyle: Propagate CE_ItemViewItem drawing to baseStyleWladimir Leuschner2024-04-101-2/+2
| | | | | | | | | | | Currently the drawing of CE_ItemViewItem is propagated to QWindowsStyle, which leads to ignoring alternating rows in ItemViews. Propagating the drawing to baseStyle honors the set base style. Fixes: QTBUG-123632 Pick-to: 6.7 6.6 6.5 Change-Id: I656ee1c44029abf7233551303d469d38b6c848e3 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Widgets: Improve usage of string view typesAnton Kudryavtsev2024-04-084-13/+14
| | | | | | | Use string views in QFontDialog, QColorDialog and QCommonStyle Change-Id: I22f4b4694e2d18b784aaa85aebff8d92b8f0b871 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QWidget: fix link error in static buildZhao Yuhang2024-04-061-19/+19
| | | | | | | | | | | | QtQuick also uses "lcFocus" as a category name, which causes link errors in static builds when both QWidget and QtQuick are linked in one executable. Making it static is also a good solution, but here adding a "Widget" prefix seems more consistent. Change-Id: I0a6a02750bd347f62b67544b4044789612f0fa4d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* widgets: Invalidate RHI swapchain when window moves to new top levelTor Arne Vestbø2024-04-041-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a QWidget with an associated RHI swapchain (via its QWindow) is moved to a different top level window, that top level window has its own backing store, and QBackingStoreRhiSupport, which doesn't know anything about the fact that the window already has an associated swap chain in the original top level window's QBackingStoreRhiSupport. As having multiple swap chains for the same window is not supported on all RHI backends (Vulkan and DX in particular), we need to throw away the swap chain when detecting that the window is moved to a new top level. We do this by hooking into the existing WindowAboutToChangeInternal event delivery to renderToTexture children, which now delivers the event both to renderToTexture QWidget children as well as QWindows in the hierarchy. The condition of when to deliver the event has been updated to reflect whether the top level uses RHI for flushing, instead of only including renderToTexture children, as the former also includes setting QT_WIDGETS_RHI=1 explicitly. The event is then caught by QBackingStoreRhiSupportWindowWatcher, and handled the same way as for SurfaceAboutToBeDestroyed. Renaming qSendWindowChangeToTextureChildrenRecursively would make sense at this point, but to make cherry-picks easier we keep the current name for now. Fixes: QTBUG-120276 Pick-to: 6.7 6.5 Change-Id: Ic4c60e89be985f12a84e9f893c299e602b70851a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Abstract QWidget focus chain managementAxel Spoerl2024-04-042-136/+455
| | | | | | | | | | | | | | | | | | | The focus chain in widgets is implemented as a double-linked list, using QWidgetPrivate::focus_next and focus_prev as pointers to the next/previous widget in the focus chain. These pointers are manipulated directly at many places, which is error prone and difficult to read. Build an abstraction layer and remove direct usage of focus_next and focus_prev. Provide functions to insert and remove widgets to/from the focus chain. Add a test function to tst_QWidget. Task-number: QTBUG-121478 Change-Id: Ide6379c0197137e420352a2976912f2de8a8b338 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Decouple rate-limiting of paint-on-screen widgets from top level widgetTor Arne Vestbø2024-04-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of eacd58d4e78e7238ba5fcca90ba960aaf3ebd263, a mechanism was added to prevent posting redundant UpdateRequest events to the top level widget, managed by QWidgetRepaintManager. The mechanism relied on a boolean that was set when posting an update request event, and reset when processing the event for the top level widget, as part of QWidgetRepaintManager::sync(). However, for paint-on-screen widgets, we don't post an update request to the top level, we post it to the paint-on-screen widget directly. And when processing that event, we don't paint the widget though the normal QWidgetRepaintManager machinery, but instead call the paint event via QWidgetPrivate::paintOnScreen(). As a result, an update() on a paint-on-screen widget would result in never receiving updates for non-paint-on-screen widgets, as we assumed there was no reason to send further update requests. We could fix this by clearing the updateRequestSent flag as part of the paintOnScreen() code path, but that's incorrect as the flag represents whether the top level QWidgetRepaintManager needs an update request event or not, and would lead to missed updates to normal widgets until the paint-on-screen widget finishes its update. Instead, we only set updateRequestSent if we're posting update requests for non-paint-on-screen widgets, which in practice means the top level widget. The paint on screen logic in QWidgetRepaintManager::markDirty still takes care of rate-limiting the update requests to the paint-on-screen widget, by comparing the dirty area of the widget. There is definite room for improvement here, especially in the direction of handling update requests via QWindow::requestUpdate instead of manually posted events, but for now this will have to do. Fixes: QTBUG-80167 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ib5685de7ca2fd7cd7883a25bb7bc0255ea242d30 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMenu: clear popup screen after exec()Axel Spoerl2024-03-271-0/+1
| | | | | | | | | | | | | | | | 8cd7a3d4723ca414f3fe544704a0ccb752da94b8 remembered the current screen in QMenuPrivate::popupScreen. This QPointer member is not reset, after QMenu:exec(), which makes a re-used menu remember the wrong screen, if its next usage happens on another screen. Reset the member variable at the end of QMenuPrivate::exec(). This amends 8cd7a3d4723ca414f3fe544704a0ccb752da94b8. Fixes: QTBUG-118434 Pick-to: 6.7 6.6 6.5 Change-Id: I7457ca72166346f01cf71b2706ebc20ecd71173c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QMainWindowLayout: rewrite validateToolBarArea() to return by valueMarc Mutz2024-03-261-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Coverity complains that QToolBarAreaLayout's addToolBarBreak(QInternal::DockPosition) could access QToolBarAreaLayout::docks out of bounds if passed QInternal::DockCount. That is correct, but a valid pos seems to be a precondition for this function, judging from its sister functions, e.g. addToolBar(DockPosition, .) or insertItem(DockPosition, .), which also don't validate `pos`. All in-module callers of addToolBarBreak() only pass valid positions, and use validateToolBarArea() to ensure that. So it seems that Coverity doesn't grok the pass-by-in/out -parameter used by that function. That, or it doesn't track back far enough. Before attempting more drastic measures, first try rewriting the function to return-by-value instead, and see what Coverity has to say afterwards. As a drive-by, make validateToolBarArea() constexpr. Pick-to: 6.7 6.6 6.5 6.2 5.15 Coverity-Id: 444141 Coverity-Id: 444135 Change-Id: I5fcc664c3cea608429036cad75c37f5c38059733 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix multiscreen menu popup positioning corner caseMorten Sørvig2024-03-251-2/+9
| | | | | | | | | | | | | | | | | | | | | A QMenuBar may span multiple screens. Its menus will then open on the screen which the bottom middle of the action rect is at, and will snap to that screen's geometry if needed. However it can happen that the bottomLeft() of the action rect is on a different screen from the selected popup screen, in which case mapping this point to global coordinates can give incorrect coordinates if the screens have different scale factors. The x value will be corrected by the screen snapping if needed. Use the y from the screen test point, which will be correct for the selected screen. Task-number: QTBUG-73231 Change-Id: If9a39f6b832a64f2f701868f2be0d3a6468fe553 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Doc: Remove table for listing imagesVenugopal Shivashankar2024-03-221-15/+12
| | | | | | | Task-number: QTBUG-122580 Pick-to: 6.7 6.6 Change-Id: I7ca3d677262b48ce9e1d85bd9347ad5b15d1598f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Don't accept QFileDialog when disabled item is activatedKeith Kyzivat2024-03-211-2/+3
| | | | | | | | | | | | | On macOS, entries that do not match the filter are shown in the directory listing. Do not accept the dialog when these entries are double-clicked (activated). Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-120768 Change-Id: If8ff6c56f1d21861b4e30051c212c9497042ed0f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QGraphicsProxyWidget: use focus abstraction instead of focus_next/prevAxel Spoerl2024-03-181-5/+5
| | | | | | | | | | | Focus abstraction in QWidgetPrivate makes direct access to QWidget::focus_next and focus_prev an antipattern. Remove usage. Task-number: QTBUG-121478 Change-Id: I741e6875e686a9cfb4e6a113e7575c911a38e80c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QApplication: use focus abstraction instead of QWidget::focus_next/prevAxel Spoerl2024-03-181-2/+2
| | | | | | | | | | | Focus abstraction in QWidgetPrivate makes direct access to QWidget::focus_next and focus_prev an antipattern. Remove usage. Task-number: QTBUG-121478 Change-Id: Iaab97024c20b97a0d9850dce43816a432d4bc7a1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Documentation: Clarify palette/font/stylesheet inheritance/propagationAxel Spoerl2024-03-181-4/+13
| | | | | | | | | | | | | | | | Palette and font changes made by a style sheet are propagated to existing widgets and their children at change time. Palette and font changes made by setPalette() and setFont() are inherited by all existing and future children of the widget to which the call was made. Clarify this in the documentation. Fixes: QTBUG-122588 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ic40d96fc1e5e4507f84a33138303b7193948d3fe Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QWindows11Style: HighDPI aware qDrawPlainRoundedRectWladimir Leuschner2024-03-151-2/+5
| | | | | | Pick-to: 6.7 Change-Id: Ic9562a20bce59c265c539a1378f5f8fd8e9e9a17 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Move qt_blurImage to Qt GUIKai Uwe Broulik2024-03-141-307/+2
| | | | | | | | | | | | Allows to use it without Qt Widgets or Qt Graphics Views. Since anyone having imported this through Qt Widget will also be linking Qt Gui this should be compatible. qt_halfScaled is also unexported for lack of known users. Change-Id: I39406dfd4839ed46f8cbfd4651577ab6ece9932c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Reparent QWindow children when reparenting QWidgetTor Arne Vestbø2024-03-142-39/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a QWidget was reparented, we would take care to reparent its backing QWidgetWindow as well, into the nearest QWindow of the new QWidget parent. However we would only do this for the reparented widget itself, and not any of its child widgets. In the case where the widget has native children with their own QWindows, the widget itself may not (yet) be native, e.g. if it hasn't been shown yet, or if the user has set Qt::WA_DontCreateNativeAncestors. In these scenarios, we would be left with dangling QWindows, still hanging off their original QWindow parents, which would eventually lead to crashes. We now reparent both the QWindow of the reparented widget (as long as it's not about to be destroyed), and any QQWindow children we can reach. For each child hierarchy we can stop once we reach a QWindow, as the QWindow children of that window will follow along once we reparent the QWindow. QWindowContainer widgets don't usually have their own windowHandle(), but still manage a QWindow inside their parent widget hierarchy. These will not be reparented during QWidgetPrivate::setParent_sys(), but instead do their own reparenting later in QWidget::setParent via QWindowContainer::parentWasChanged(). The only exception to this is when the top level is about to be destroyed, in which case we let the window container know during QWidgetPrivate::setParent_sys(). Finally, although there should not be any leftover QWindows in the reparented widget once we have done the QWidgetWindow and QWindowContainer reparenting, we still do a pass over any remaining QWindows and reparent those too, since the original code included this as a possibility. We could make further improvements in this areas, such as moving the QWindowContainer::parentWasChanged() call, but the goal was to keep this change as minimal as possible so we can back-port it. Fixes: QTBUG-122747 Pick-to: 6.7.0 6.7 6.6 6.5 Change-Id: I4d1217fce4c3c48cf5f7bfbe9d561ab408ceebb2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMessageBox: Respect explicit accept/reject after closing dialogTor Arne Vestbø2024-03-141-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the dialog is closed by pressing a button, the button will be reflected via clickedButton(), and the result() will reflect either the QMessageBox::StandardButton value, or an opaque value for custom buttons. Depending on the role if the buttons, the accepted or rejected signals are emitted. If the user called accept() or rejecct() on a dialog that had already been closed by a button, we would as a result of 1f70c073d4325bc0eb9b0cec5156c3b89ce1b4df emit a signal based on the original button that was clicked, instead of respecting the newly triggered function. It's a questionable use-case, as the clickedButton() is still the original button e.g., but we should still avoid regressing this, so we now emit the signals based on the newly stored result code instead of using the clicked button as the source of truth. To allow this we had to change the opaque result() value for custom buttons to stay out of the QDialog::DialogCode enum, but this should be fine as the documentation explicitly says that this is an opaque value. Fixes: QTBUG-118226 Pick-to: 6.7 6.6 6.5 Change-Id: Ia2966cecc6694efce66493c401854402658332b4 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QMessageBox: ensure setTextFormat() also apply to informative textWang Zichong2024-03-141-2/+9
| | | | | | | | | | | QMessageBox::setTextFormat can set the text format for its text label, but the informative label will still use its default text format. This change allow the setTextFormat also apply to the informative label, thus user can use their preferred format like Markdown in the informative label. Task-number: QTBUG-122712 Change-Id: I6f7487b29712ca07cee27171453312ff1707eea3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QDoc: Drop default arguments from some \fn documentation stringsPaul Wicking2024-03-131-1/+1
| | | | | | | | | | | | | | | | | | | In the \fn commands for a limited number of methods in the documentation for Testlib and Widgets, `= 0` is passed as default argument instead of `= Qt::KeyboardModifiers()`. Until QDoc with Clang 17, inclusive, QDoc generated the correct signature. However, with Clang 18, QDoc outputs `= 0` in the documentation. While strictly speaking still correct, this change impacts the documentation negatively in terms of readability. Dropping the default argument from the \fn command ensures that QDoc generates the right signature with both Clang 17 and Clang 18. Task-number: QTBUG-123130 Pick-to: 6.7 Change-Id: I94ccec2f2c9a02241095fb5b18feb74aa55f97e1 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Don't show mnemonics in dockwidget titlesChristian Ehrlicher2024-03-091-1/+1
| | | | | | | | | | | | Dockwidget title accelerators doesn't work in dock widgets, so don't show them. This amends cc67b25579c1bb5ea9f5c1ca4c9b7997e66f19b9. Fixes: QTBUG-86407 Pick-to: 6.7 6.6 Change-Id: I83fb2da1304d1e2b5eedfc127e5db3d322756d06 Reviewed-by: Sune Vuorela <sune@vuorela.dk> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>