aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickmenu_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QQuickMenu: fix heap-use-after-freeMitch Curtis2020-09-291-0/+1
| | | | | | | | | | | | | | | The previous patch fixed a memory leak, which in turn exposed an issue caused by item change listeners not being removed before contentModel is destroyed. QQuickMenuPrivate::itemParentChanged() then tried to access that contentModel, resulting in a heap-use-after-free. This patch fixes the issue by removing all menu items before the menu is destroyed, ensuring that the change listeners are removed in time. Pick-to: 5.15 5.12 Task-number: QTBUG-86851 Change-Id: I3dc0a251d7fd9c05c384de6472e73493b2d5b664 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Register C++ types declarativelyMitch Curtis2020-08-261-23/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Adapt to the new way of registering C++ types. The types need to be seen at compile time so that code can be generated that invokes them. This patch: - Adds QML_* macros where applicable. - Adapts the build system files to the new way of registering modules. - Splits up the QtQuick.Controls[.*].impl files into their own plugins, as we can only register one QML module per .pro file. - Removes C++ type registration calls in every plugin. - Moves private types from src/quickcontrols2/quickcontrols2.pro to src/quickcontrols2/impl/quickcontrols2-impl.pro. Some of these types need to be exposed to QML, but quickcontrols2.pro is already in use to declare the QtQuick.Controls import (and also provides the public C++ QQuickStyle API), and the new QML_IMPORT_NAME/VERSION syntax only allows one module per project. As some of the types that need to be exposed to QML are also referenced by some C++ code (e.g. tests, etc.), we just move all of the private types to the new library. Follow-up patches will register the QML types declaratively. Task-number: QTBUG-82922 Change-Id: Iaf9ee106237d61701d57a8896f3822304c8151a6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Menu: remove deprecated removeItem(var) overloadMitch Curtis2020-05-111-2/+1
| | | | | | | | | [ChangeLog][Controls][Menu] The deprecated removeItem(var) function was removed. removeItem(Item) or takeItem(int) can be used instead. Change-Id: I79757c22b4f81e1b380798623bd1f15eb09c1647 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove old QQuickPalette implementationVitaly Fanaskov2020-03-181-1/+0
| | | | | | | | | | | | | | The existing implementation was removed in order to reduce massive code duplication and simplify color resolving process. Unit tests were fixed accordingly. See related changes in the qtdeclarative module for the further details. [ChangeLog][General] the palette API is a part of QQuickItem now. Change-Id: Ic94ab4632e626c11d9b26f035e2a8a119c9088ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Re-order revision 3 members and add explanatory commentsJ-P Nurmi2017-11-061-16/+20
| | | | | | | | | | | | We've come to realize that even though it's tempting to group similar properties together, organizing the API so that revisions are grouped together makes future maintenance more pleasant. It's a lot easier to to see what was added and when. The same was done for earlier revisions in 5.9 in commit 430fe83. Change-Id: I738d7fdadd348c21737228c37d0f31e39b37f8e7 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Make QQuickMenu::popup() available in C++J-P Nurmi2017-07-131-0/+3
| | | | | | | | | This is going to be used for sub-menus by QQuickMenu itself, by the upcoming QQuickMenuBar, and allows users to implement their own Menu navigation if desired. Change-Id: I29258e78fec27e8dd207ed649958df1a718bcd39 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add QQuickMenu::countJ-P Nurmi2017-07-121-0/+3
| | | | | | | [ChangeLog][Controls][Menu] Added "count" property. Change-Id: I42971a6bf8fd74b9f2d3df52f191b66cd7022b81 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add QQuickMenuPrivate::setParentMenu()J-P Nurmi2017-07-121-2/+3
| | | | | | | | To help propagating the cascade-property automatically, instead of doing it manually in openSubMenu() that we're trying to get rid of. Change-Id: I3a3d59cafccc85d6affc325eb60e717e22b8f812 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add QQuickMenu::dismiss()J-P Nurmi2017-07-111-0/+1
| | | | | | | | | [ChangeLog][Controls][Menu] Added a dismiss() method. Unlike close() that only closes a menu and its sub-menus, dismiss() closes the whole hierarchy of menus, including the parent menus. Change-Id: Ibde2102bbb542a5deefdf17843496b7b80021db4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickMenu: add actionAt() and menuAt() accessorsJ-P Nurmi2017-07-101-0/+2
| | | | | | | | | | | | This complements the add/insert/remove/take API that was added for actions and menus. Unlike for menu items, there was no convenient way to access a specific action or menu directly without accessing the respective item first. [ChangeLog][Controls][Menu] Added actionAt() and menuAt() accessors. Change-Id: I5515441626b3a04b05265d5b42afdaea8e256709 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickMenu: use key press instead of key release eventsJ-P Nurmi2017-07-101-1/+1
| | | | | | | | | | | | | In general, when shortcuts override key press events, the respective key release events are still sent. Therefore, in order to respect shortcuts, key navigation should be based on key press events. Key release -based navigation is also not going to work with nested menus in a menubar, because a leaf menu may need to propagate key events up to the parent menus and finally to the menubar, but only if keys are not actually handled. Change-Id: Ia040a387adc782d8828250fbed393ef1794f2148 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add Menu::currentIndexJ-P Nurmi2017-06-211-0/+5
| | | | | | | | | | | | | | De-couple current index management from the content item. Instead of manipulating the content item's current index directly from C++, offer a currentIndex property that can be visualized by the style, also when not using a ListView. This is essentially the same technique ComboBox uses to control the highlighted index in the popup ListView. [ChangeLog][Controls][Menu] Added currentIndex property for styling purposes. Change-Id: Idf7746d9c08fc9ca9a0dfd15225ebae5a29243c9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add QQuickMenu::add/insert/remove/takeAction()J-P Nurmi2017-06-131-0/+6
| | | | | | | | | [ChangeLog][Controls][Menu] Added addAction(), insertAction(), removeAction(), and takeAction() methods for adding and removing actions programmatically. Change-Id: I7d494ef1edc1cf384314fa90d97cfd2290d2e8a3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add QQuickMenu::add/insert/remove/takeMenu()J-P Nurmi2017-06-131-0/+5
| | | | | | | | | [ChangeLog][Controls][Menu] Added addMenu(), insertMenu(), removeMenu(), and takeMenu() methods for adding and removing sub-menus programmatically. Change-Id: Ibf39448cdf528f64695b1ee5f0781384b754ba22 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickMenu: add a little delay for opening sub-menus on hoverJ-P Nurmi2017-06-131-0/+2
| | | | | | | | | This improves the usability on desktop. When a menu has multiple sub- menu items, they don't all trigger a sub-menu (and close immediately) while moving mouse over the items. Change-Id: Ie4c9e409da8d6877e35506bffb94ed57f5985dcd Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add support for cascading sub-menusJ-P Nurmi2017-06-131-0/+10
| | | | | | | | | | | | | This commit adds initial support for cascading sub-menus by allowing one to nest declarative Menu declarations. A follow-up commit adds support for adding, inserting, and removing menus programmatically. [ChangeLog][Controls][Menu] Added support for cascading sub-menus. Task-number: QTBUG-60351 Change-Id: I0eee4f74d92a97c09333fcc4348b019782448535 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devJ-P Nurmi2017-06-081-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/controls/doc/src/qtquickcontrols2-index.qdoc src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc src/quicktemplates2/qquickapplicationwindow.cpp src/quicktemplates2/qquickmenu.cpp src/quicktemplates2/qquickmenu_p.h src/quicktemplates2/qquickpopup.cpp tests/auto/auto.pro Change-Id: I856a022d38abd84763127539f46ef032ddc53c3d
| * Add missing QQuickMenu::defaultFont()J-P Nurmi2017-06-071-0/+2
| | | | | | | | | | Change-Id: I74e512074cbc66378ffd71f8040ae8977a3ffeac Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | QQuickMenu: add argument to titleChanged()J-P Nurmi2017-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is a small preparation step for cascading sub-menus. A menu item that presents a sub-menu can connect the sub-menu's titleChanged() directly to its setText() slot. The same technique is used for menu items that present actions. Task-number: QTBUG-60351 Change-Id: Id2c840d108167679d3a61caf35cbb0afacb6afe4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Add missing revision for takeItem()J-P Nurmi2017-06-061-1/+1
| | | | | | | | | | Change-Id: Idac8b830efc228303346432d5bf0957b17a428a4 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* | QQuickMenu: removeItem(Item) and takeItem(int)J-P Nurmi2017-06-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deprecate removeItem(int) in favor of removeItem(Item) and takeItem(int) with clearer semantics. If one already has access to an item, one can pass it to removeItem() to get rid of it for good, instead of having to call destroy() by hand. If one knows the index instead, we provide a way to take the respective item out of the menu, and let the user decide what to do with it. This way we provide convenient ways to remove & destroy items in one go, and to take items out without destroying them. This nice pattern was once upon time planned for the QQC1 containers such as SplitView, and should have been used for the QQC2 containers, but was simply forgotten during the development... [ChangeLog][Controls][Menu] Deprecated removeItem(int) in favor of removeItem(Item) and takeItem(int) with clearer semantics. The former destroys the item, whereas the latter transfers ownership to the caller. Change-Id: Id2a07fb65019b2904a013c8bcc3154089d36a0ea Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Mark properties as FINALJ-P Nurmi2017-06-061-1/+1
| | | | | | | | | | | | | | | | | | This is a little optimization trick for the QML engine. We basically tell it to not lookup overridden/overshadowed properties further in subclasses/composite types. Change-Id: I04168c58d00c07e5a354259cabefb3664ffd95b3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | QQuickMenu: add support for declaring ActionsJ-P Nurmi2017-06-021-0/+6
| | | | | | | | | | | | | | | | | | [ChangeLog][Controls][Menu] Added support for declaring Actions. The new "delegate" property is used to define a Component that is used to create menu items that present the actions. Change-Id: If26f38f6910aa5592879703429a2b418193d5710 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Add QQuickMenu::popup()J-P Nurmi2017-06-021-0/+2
| | | | | | | | | | | | | | | | | | | | [ChangeLog][Controls][Menu] Added a popup() method that opens a menu at the mouse cursor on desktop platforms that have a mouse cursor available, and otherwise centers the menu over its parent item. Task-number: QTBUG-50471 Change-Id: I9456a48e71fde91f73cdb268fcdd69a8511a41a4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Implement defaultPalette()J-P Nurmi2017-05-261-0/+2
|/ | | | | Change-Id: I4345f6a3b61476287b6161d89b752735757f3a7e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Port from QT_NO_ACCESSIBILITY to QT_CONFIG(accessibility)J-P Nurmi2017-02-241-2/+2
| | | | | Change-Id: I03deebff661746d49e537af5b1c8899b938efb0d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Welcome to 2017J-P Nurmi2017-01-091-1/+1
| | | | | Change-Id: If68cff4efacc7dc5719c8b8e61937e85e9076870 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Q_QUICKTEMPLATES2_EXPORT => Q_QUICKTEMPLATES2_PRIVATE_EXPORTMitch Curtis2016-04-271-1/+1
| | | | | | | They're all private classes. Change-Id: I2f1463429109c5651f9cca5bc7aabe5cf0f79637 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Templates: update license headersJ-P Nurmi2016-04-141-2/+2
| | | | | | | This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. Change-Id: I39ef9cbb00f55a32b7a43f11ffbdfbb40b84e124 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
* Templates: rename the C++ module to qtquicktemplates2J-P Nurmi2016-04-131-0/+107
Change-Id: I146da903b46f5c2caf865e37291c25376b49021a Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>