summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenu.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Fix menu size in multiscreen setupsFriedemann Kleint2024-03-071-0/+12
| | | | | | | | | | | | | | | | | | During QMenuPrivate::popup() and QMenuBarPrivate::popupAction(), QMenuPrivate::popupGeometry() is called from updateActionRects() with screen = 0 several times (from sizeHint() and various event handlers triggered), which causes it to return the primary screen geometry always. To fix this for the non-QGraphicsView case, use the screen of the menu when it is visible or the screen stored in a newly introduced popupScreen member variable, which is set from a few places in QMenuPrivate::popup(). Fixes: QTBUG-118434 Pick-to: 6.7 6.6 6.5 Change-Id: I6b18593d313719d628b0856004197ac59f46c270 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Widgets: pass widget to QStyle::pixelMetric()Christian Ehrlicher2024-01-161-1/+1
| | | | | | | | | | | | Make sure to pass the widget to QStyle::pixelMetric() as some styles might use this (e.g. the new windows styles) to determine the correct pixel metric. Pick-to: 6.7 6.6 6.5 6.2 Task-number: QTBUG-1857 Change-Id: I5c32f5af8b284749732b610e56b4e3d8c8ed1946 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Harden QMenuPrivate::hideMenu() against menu argument becoming staleAxel Spoerl2023-08-141-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | QMenuPrivate::hideMenu() hides a menu and reposts events in case a new action has become the active one. For that purpose, it waits 20ms and 60ms for visual effects to be rendered. If the last action has been triggered, the menu's deleteLater slot has been called before hideMenu(). In that case, it gets deleted while events are processed during the waiting periods. Subsequently, menu becomes stale. This patch replaces the QMenu * argument with a QPointer. Early returns are inserted after waiting. QSignalBlocker is replaced by manual signal blocking, to prevent the signal blocker from recovering the state of a stale object, when it goes out of scope. An auto test is not added: The error scenario occurs, when a menu is triggered by keyboard input, while a mouse event is sent to the main window from outside the menu. Such a test scenario is complex to match and exposed to flakiness. Fixes: QTBUG-115597 Pick-to: 6.6 6.5 6.2 Change-Id: I4f937fe66fb1b5cf78ebee70fd0006712172cb12 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtWidgets: code tidies: use the 4-arg connect overloadGiuseppe D'Angelo2023-06-281-1/+1
| | | | | | | | The 3-arg connect is error-prone and makes the lifetime of the connection unclear. Change-Id: I4e518dd4a9733cc0a42b02639cce9c6136ad5afc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix missing references to 'Qt Widgets - Application Example'Tor Arne Vestbø2023-06-271-1/+1
| | | | | | | | Amends eda71105ff9a516059c6dd6643ff446a82edac81 Pick-to: 6.5 6.6 Change-Id: I44fa9acef37667d635d5770ce5d50fc52d92aa88 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMenu: don't crash when nested tear-off menus are closedVolker Hilsheimer2023-06-091-1/+3
| | | | | | | | | | | | | | | | QMenu's causedStack maintains a list of menus on the way to the menu, and might contain nullptr if one of the entries was a tear-off menu that got closed (and thus destroyed, due to DeleteOnClose). If the entry we get from the stack is nullptr, fall back to the passed- in parent widget pointer, and test for nullptr before accessing. Add a test case that crashes without the fix. Fixes: QTBUG-112217 Pick-to: 6.6 6.5 6.2 Change-Id: I958182db47c3cc8733e1780f7efef43881ffae11 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QMenu: guard for destruction when emitting action signalsVolker Hilsheimer2023-02-131-3/+13
| | | | | | | | | | | | | | If a slot connected to a QMenu-action destroys the QMenu, then we must not touch data members in subsequent code, and instead return immediately. We cannot use QBoolBlocker here, as that would reset the data member of QMenuPrivate even when trying to return early. Fixes: QTBUG-106718 Pick-to: 6.5 6.4 6.2 Change-Id: I6b5ea471b1bf1f9864e1384382100f8f6c01346f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add static_cast for QKeyEventLu YaNing2022-12-131-2/+2
| | | | | | | | Use static_cast to convert a QEvent to a QKeyEvent, replacing (QKeyEvent*)e Change-Id: I52ac3f46aec42600251cf737db2e71c04f2b45c7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAction: add QT_DEPRECATED_VERSION_6_0 to deprecated methodsIvan Solovev2022-07-211-1/+9
| | | | | | | | | And fix all the new warnings. Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I2a5791f495575d71d2344429aca3363f9922e31b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Improve widget painting under dpr>1 by enabling smooth pixmap scalingEirik Aavitsland2022-07-121-6/+6
| | | | | | | | | | | | | | | | | Smooth scaling of icons etc. give far better visual results, particularly with fractional dpr scaling. So enable this generally in QStylePainter, and make more of the relevant widgets use QStylePainter instead of QPainter directly. Differences can be seen in the widgets examples, e.g. textedit, gallery, stylesheet (Pagefold), mdi. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-96223 Fixes: QTBUG-101058 Change-Id: I3c34a455d097e5f6a6a09d3b020528b4fbda4d85 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-151-4/+4
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QMenu: Adjust the position of the submenuWang Fei2022-06-131-1/+1
| | | | | | | | | | When the submenu is about to exceed the screen, set the position of the submenu to the left border of the main menu Fixes: QTBUG-104050 Change-Id: I8935f1bfceb93cfa1097391689f4233991394978 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix QMenu size on first showThorbjørn Lund Martsum2022-05-231-0/+9
| | | | | | | | | | | | QWidget::metric is used to calculate the size of the menu, but it only respects a sceen from a Window handle, so we need to make sure such a thing is created. Task-number: QTBUG-103309 Pick-to: 6.2 6.3 Change-Id: Ie73e362cdcb3b59f46ad51c4901fdbeda7258baa Reviewed-by: Morten Kristensen <me@mortens.dev> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtWidgets: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-261-3/+3
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Remove mentioning of Fowler bookKai Köhne2022-01-171-2/+1
| | | | | | | | | It is out of print since years, and probably quite dated by now (released 1997). Pick-to: 6.3 Change-Id: I1653eb404713c15d70b8a15858e8c7d12b2e71cb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Widgets: setTransientParent() when a QMenu is a windowLiang Qi2021-12-081-0/+25
| | | | | | | | | | | | | On some platforms, such as X11 and Wayland with some compositors, QMenu could be a popup window, which should be set a transient parent to get relative position, which is requested by Wayland. Added transientParentWindow() for QMenuPrivate like QDialogPrivate. Fixes: QTBUG-68636 Pick-to: 6.2 Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QMenu::menuInAction as a static helperVolker Hilsheimer2021-11-011-0/+10
| | | | | | | | | | | | | | QAction::menu is deprecated, as it makes QAction (a QtGui class) depend on QtWidgets. The template hack works, but shouldn't become a permanent solution and is already deprecated. To get the QMenu out of a QAction that contains it, add a static helper to QMenu instead. QAction continues to store the menu pointer so that we don't have to use a dynamic property or an associative container in QMenu. Change-Id: Ieb6a2b1900d2fc2f16dd5a4a8ab7da98604642d3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* widgets: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I6b77f0ec043d08da3b7958d780dce9595daf97a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Document that hiding/disabling a menu is best done via the menuActionVolker Hilsheimer2021-08-101-1/+3
| | | | | | | Task-number: QTBUG-95072 Pick-to: 6.2 Change-Id: I83afe13b129a35b39c62abe553061cc4a390fd65 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QMenu/QToolBar: remove addAction() functionsMarc Mutz2021-07-131-117/+30
| | | | | | | | | | | | | | | | | | | | 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>
* Only scroll QMenu when there is a valid active actionZhang Hao2021-04-141-1/+1
| | | | | | | | | | | | | | When changing the active action via QMenu::setActiveAction the menu will scroll to the active action, but we were scrolling the menu also when the active action was null, resulting in the menu scrolling back to the top. We fix this by guarding the call to scrollMenu. Fixes: QTBUG-92096 Pick-to: 5.15 6.0 6.1 Change-Id: I998f99ddacec32640834d59a907d569fdda458f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Code tidiesZhang Hao2021-03-051-2/+1
| | | | | | | The return type goes on the same line of the rest of the signature. Change-Id: Icacf2e00ed2876c4c9b72b8f6c428c2e37ee42a7 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Redundant condition: tornoffZou Ya2021-03-041-1/+1
| | | | | | | | | | Redundant condition: tornoff. '!tornoff || (tornoff && scroll)' is equivalent to '!tornoff || scroll' Pick-to: 6.1 Change-Id: I8339faa4d53360db280173ee489e48eba4883b70 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix the tips still show when cursor move to another actionQiang Li2021-01-151-0/+2
| | | | | | | | | | | | In this case, the previous action's tip is still displayed when the cursor moves from one action with tip to another action without tip. Fixes: QTBUG-89082 Pick-to: 5.15 Pick-to: 6.0 Change-Id: I0a00595dc3d716725678487be9cbb363c4d3b392 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Simplify and fix issues with QMenuPrivate::moveWidgetToPlatformItemTor Arne Vestbø2021-01-041-12/+1
| | | | | | | | | | | | | | | | | View embedding when QWidget is involved is a bit finicky. This change breaks down the steps needed to embed it into an NSMenu item, and simplifies the process by not relying on a container widget. The main issue is that QCocoaWindow::recreateWindowIfNeeded() will potentially create an NSWindow for the embedded view, resulting in a stray view. To prevent this we set the Qt::SubWindow flag on the window, but QWidget tends to reset this flag when the widget doesn't have a parent, so we need to be careful about which order we do the setup. Pick-to: 6.0 5.15 Change-Id: I505f7c0a2d8e4350511fdb01a5e9b9c623a40a41 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Adjust the format of code blocks in function mouseReleaseEventQiang Li2020-12-031-1/+1
| | | | | | Pick-to: 6.0 Change-Id: I8441b1c4f22ec04e34e8c2c5e9ccc69d34c67e01 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix links to Application ExampleVolker Hilsheimer2020-12-021-1/+1
| | | | | | | | | | The example was renamed in 6cb36d825d365988ea7a601218bdd3a329290469. Pick-to: 6.0 Change-Id: Ic9daac60002c9988dfeb5c7dcde74edb69388f37 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QtWidgets: Propagate event device when translating mouse eventsFriedemann Kleint2020-11-271-1/+2
| | | | | | | | | | | There are a few places left over, for example the QTextEdit creating mouse events in a timer and notably QGraphicsView. Task-number: QTBUG-88678 Task-number: QTBUG-46412 Pick-to: 6.0 Change-Id: I7ed23911be3b86b4b39fb478b947ec3b7a60761f Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Ensure that QMenu is polished before setting the screen in popup()David Redondo2020-11-181-1/+2
| | | | | | | | | | | | | | Some styles alter the widget that will influence the underlying platform window. An example is when a style would want to draw the menu with some transparency and sets the Qt::WA_TranslucentBackground attribute. This needs to happen before the platform window is created. However calling QWidgetPrivate::setScreen will end up creating the window and the surface format will be fixed at this point. Pick-to: 5.15 Change-Id: I707cf1de5c1614382cffbea1aae8cdb01f7de44a Reviewed-by: Nate Graham Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-22/+22
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Change QWidget::enterEvent signature to take a QEnterEventVolker Hilsheimer2020-09-051-1/+1
| | | | | | | | | | | | | | | | | | | This is a source incompatible change for widget implementors. Leaving the old enterEvent as a virtual overload is problematic due to shadowing. Best to make a clean cut, widget reimplementors will get a compile time warning if they mark their override as such, or if they try to call the parent class implementation. Addresses ### Qt 6 comment. [ChangeLog][QtWidgets][QWidget] The virtual enterEvent handler now receives a QEnterEvent, which contains information about mouse position and button states, rather than a plain QEvent. Change-Id: I233f594fd79c0c090983b3db8532913d00132fde Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 via P1120 is deprecating arithmetic operations between unrelated enumeration types, and GCC 10 is already complaining. Hence, these operations might become illegal in C++23 or C++26 at the latest. A case of this that affects Qt is in key combinations: a QKeySequence can be constructed by summing / ORing modifiers and a key, for instance: Qt::CTRL + Qt::Key_A Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below) The problem is that the modifiers and the key belong to different enumerations (and there's 2 enumerations for the modifier, and one for the key). To solve this: add a dedicated class to represent a combination of keys, and operators between those enumerations to build instances of this class. I would've simply defined operator|, but again docs and pre-existing code use operator+ as well, so added both to at least tackle simple cases (modifier + key). Multiple modifiers create a problem: operator+ between them yields int, not the corresponding flags type (because operator+ is not overloaded for this use case): Qt::CTRL + Qt::SHIFT + Qt::Key_A \__________________/ / int / \______________/ int Not only this loses track of the datatypes involved, but it would also then "add" the key (with NO warnings, now its int + enum, so it's not mixing enums!) and yielding int again. I don't want to special-case this; the point of the class is that int is the wrong datatype. Everything works just fine when using operator| instead: Qt::CTRL | Qt::SHIFT | Qt::Key_A \__________________/ / Qt::Modifiers / \______________/ QKeyCombination So I'm defining operator+ so that the simple cases still work, but also deprecating it. Port some code around Qt to the new class. In certain cases, it's a huge win for clarity. In some others, I've just added the necessary casts to make it still compile without warnings, without attempting refactorings. [ChangeLog][QtCore][QKeyCombination] New class to represent a combination of a key and zero or more modifiers, to be used when defining shortcuts or similar. [ChangeLog][Potentially Source-Incompatible Changes] A keyboard modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using operator|, not operator+. The result is now an object of type QKeyCombination, that stores the key and the modifiers. Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove QMacNativeWidget and QMacCocoaViewContainerTor Arne Vestbø2020-08-281-5/+2
| | | | | | | | | | | | The functionality should be available via QWidget::winId(), and QWidget::createWindowContainer() + QWindow::fromWinId(). Any bugs in this area should be fixed by improving the general wrapping APIs. Fixes: QTBUG-83254 Change-Id: I86584a4a8138d17d65a50da39efd58039f10da91 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Rename QStyleOptionMenuItem::tabWidth to reservedShortcutWidthVolker Hilsheimer2020-08-271-4/+4
| | | | | | | As per ### Qt 6 comment, and the documentation for the variable. Change-Id: I58df784a72129dc97c5f13eb54e34cb7feb9748c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMenu: make less sensitive to mouse jitterVolker Hilsheimer2020-08-191-1/+1
| | | | | | | | | | | | | | On systems where a right-press brings up the menu, the next mouse move will select an action, even if it's just a move by a single pixel. This makes it too easy to activate an action on e.g a context menu accidentially when the button is released. Ignore the first couple of mouse moves, using the same logic that prevents accidental tearing off. Change-Id: Ib4dd448ef2d6ae915b48da62666aa95b37145d63 Fixes: QTBUG-57849 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Introduce QWidget::setScreenVolker Hilsheimer2020-08-171-1/+1
| | | | | | | | | | | | | | | | | | Follows the QWindow semantics, and is a replacement for creating a QWidget with a QDesktopScreenWidget as the parent. We can now remove much of the special handling of QDesktopWidget and the Qt::Desktop window type, and get rid of QDesktopScreenWidget. Add a manual test that allows local testing. Our CI environments only have a single screen, and no multi-head display server setup which is the primary case where QWidget::setScreen is interesting. For the more common case of a virtual desktop, QWidget::setScreen has no real impact (just as QWindow::setScreen doesn't). Change-Id: Id0099e069d316741bacd8c795c396ccad37be297 Fixes: QTBUG-85483 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Change QWindow/QWidget::map(To/From)(Global/Parent) to operate in floatFriedemann Kleint2020-07-141-3/+3
| | | | | | | | | | | | | | | Change the functions to operate in float and add the QPoint versions as overload calling them. This is more in-line with the event accessors using float and allows for removing some workarounds using a delta when converting touch points. Leave QPlatformWindow::map(To/From)Global() as is for now and add helpers for float. Change-Id: I2d46b8dbda8adff26539e358074b55073dc80b6f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove usage of QDesktopWidget(Private) from most places in QtWidgetsVolker Hilsheimer2020-07-071-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Call QGuiApplication and QScreen APIs directly to get geometries, and make use of QScreen::grabWindow grabbing the screen it's called on when called with WId == 0. This assumes that QGuiApplication::screen and QWidget::screen never return nullptr, which is already assumed in other places. In QSplashScreen, simplify the code to operate on the screen of the QSplashScreen itself. Remove the case that handles a QDesktopWidget parent - QSplashScreen doesn't have a constructor that takes a QWidget* parent anymore. In the QEffect implementation, we can rely on the widget pointer not being nullptr (it's tested in the free functions client code uses). Includes a few drive-by changes to coding style and logic in qtooltip.cpp, where the tip label placement now prefers the screen of the widget the label is created for, and uses the position only as a fallback. What remains is the special handling of QDesktopWidget and the Qt::Desktop type in QWidget and QApplication. Change-Id: I30b67bab8ae82ddfcc7bbbec3c10f6e935b74f06 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Use QList instead of QVector in widgetsJarek Kobus2020-07-021-7/+8
| | | | | | Task-number: QTBUG-84469 Change-Id: I3007734f8e4f164ece9dd8850ef007cbef9e12ef Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Remove deprecated QStyleOption::init()Christian Ehrlicher2020-06-211-5/+5
| | | | | | | | Even it was not marked as deprecated the replacement function initFrom() is available since Qt4 times (and init() is deprecated since then) Change-Id: I09a4ebbf66b01fbe7aec67691dc68d2e42d1cd78 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Always show a submenu on its parent menu's screenShawn Rutledge2020-06-161-1/+1
| | | | | | | | | | | | | | | QWidget::screen() was added in b455a863a1df61337f36f2e8b43101ca21514697 and this is another good use for it (in 5.15 and newer). Amends c068edcecf6876c7b57abbe302ad8b1347e4445e Pick-to: 5.15 Fixes: QTCREATORBUG-24195 Task-number: QTBUG-76162 Change-Id: Ifaafe9b45fafaae220da54bbf3bc7a568e7953f9 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Phase 2 of removing QDesktopWidgetVolker Hilsheimer2020-06-081-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove QDestopWidget public header, simplify the implementation that maintains a Qt::Desktop type QWidget for each QScreen, and turn QWidget's initial target screen into a QScreen pointer. QApplication::desktop() now takes an optional QScreen pointer, and returns a QWidget pointer, so that applications and widgets can get access to the root widget for a specific screen without having to resort to private APIs. QDesktopWidgetPrivate implementations to look up a screen for an index, widget, or point are now all inline functions that thinly wrap QGuiApplication::screens/screenAt calls. We should consider adding those as convenience APIs to QScreen instead. Note that QWidget::screen is assumed to return a valid pointer; there is code that handles the case that it returns nullptr (but also code that trusts that it never is nullptr), so this needs to be defined, verified with tests, and asserted. We can then simplify the code further. Change-Id: Ifc89be65a0dce265b6729feaf54121c35137cb94 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace calls to deprecated QEvent accessor functionsShawn Rutledge2020-06-081-13/+13
| | | | | | | Many of these were generated by clazy using the new qevent-accessors check. Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix build without features.menubarTasuku Suzuki2020-06-081-1/+8
| | | | | Change-Id: If7ad6f4c50936d2abf8b88859cb3a8a6189df152 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove dead code from src/widgetsVolker Hilsheimer2020-05-111-4/+0
| | | | | | | | Code that's removed via QT_VERSION(6, 0, 0) check is already no longer compiled. Change-Id: I70865f330a6260ac2e9cf2770d599a5b6f7bb7d4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QMenuPrivate::hideMenu - avoid deleting 'q' too earlyTimur Pocheptsov2020-05-081-0/+30
| | | | | | | | | | | | | | | | This function among other things enters a nested event loop twice. With enough luck processing events may end with posting deferred delete event for 'q' and then ... executing this event leaving the whole call tree with a dangling pointer. This is not very convenient, and we filter out such events to re-post them a bit later. Pick-to: 5.15 Fixes: QTBUG-82349 Change-Id: Ic620273b529b89f2bd57e25df1f91c2754940670 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>