aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickmenubar.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove old QQuickPalette implementationVitaly Fanaskov2020-03-181-5/+5
| | | | | | | | | | | | | | 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>
* Doc: Fix qdoc warningsVenugopal Shivashankar2019-11-261-1/+1
| | | | | | | | | | | The warnings were about: - Undocumented function parameters - Instances of \instantiates that us an internal class - A few link issues Task-number: QTBUG-79827 Change-Id: I60094279c7da6bc446b5c63b7b4924b71cee4672 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QQuickMenuBar: let MenuBarItem lose highlight when Menu is dismissedWang Chuan2019-10-241-4/+4
| | | | | | | | | | | | | | | | When adding new MenuBarItem to MenuBar, MenuBar will first check the Menu pointer in MenuBarItem and then connect the Menu's signal [aboutToHide] to MenuBar's slot [onMenuAboutToHide] to unhighlight the MenuBarItem. In case of adding dynamic Menu, this operation will be performed before setting new Menu to MenuBarItem. So the Menu pointer in MenuBarItem is null, and the connection will not be performed. [ChangeLog][Controls][QQuickMenuBar] Fixed issue with dynamically menu bar items not losing their highlight when their menu was dismissed. Fixes: QTBUG-77306 Change-Id: Ibe987462505f65747b4290b3c206e9dfbcbbef57 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Doc: Replace the "Qt Quick Controls 2" instancesVenugopal Shivashankar2019-08-221-1/+1
| | | | | | | | | Now that Controls 1 is deprecated, it's ideal to use "Qt Quick Controls" instead of "Qt Quick Controls 2". Task-number: QTBUG-70333 Change-Id: Ie745db4b61071ddb5e06150d4e739cda74c59f41 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Revert all Menu delegate patchesv5.12.0-rc2v5.12.0-rc1v5.12.0Mitch Curtis2018-11-151-42/+7
| | | | | | | | | | | | | | | | | | | | | This reverts the following commits: d5cb26bc56a3b6f6e99c88654d4f7a65f43551ac - Menu: ensure the correct delegates are used when created via Component d923dd467c1aeb3e195a09949b04862084002f88 - MenuBar: ensure the correct delegates are used when created via Component d56c193eb4ceb640611d66f22e1f26aae91cd7d1 - QQuickPopupPositioner: avoid adding duplicate item change listeners 567a2de8cd493aabe0055d6dbc367b39447e70dd - Stabilize tst_qquickmenubar 953fbac6131823e4fce0eb4707a854469c4c04ff - Fix Instantiator-created MenuItems disappearing 936d31179d44220571ded15840bedeccb581c83b - tst_qquickmenu: add a test for MenuItems before and after a Repeater fc1832810f6c09505d9413685ed0b2d6295bea4a - QQuickMenuBar: fix menu not opening The fix for QTBUG-67559 has caused lots of issues, with the latest being a crash right before the 5.12 release. The bug that they fix is a P2, so it's not worth the hassle. The patches might be able to be resubmitted to dev after the crash is fixed. Change-Id: Ic192c7a302176bcdb2503b636b3462b10898a2ba Fixes: QTBUG-71770 Reviewed-by: J-P Nurmi <jpnurmi@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickMenuBar: fix menu not openingMitch Curtis2018-11-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a Menu is declared within a MenuBar, a MenuBarItem has to be created for it. Creation takes the following steps: - 1 Begin creation of the item - 1.1 Set the parent of the MenuBarItem to the MenuBar - 2 Set the menu on the item - 3 Complete creation of the item - 4 Add the item When setting the parent of the MenuBarItem, the following call stack can be observed: 1 QQuickContainer::itemChange qquickcontainer.cpp 757 0x7fff6e5f4544 2 QQuickItemPrivate::itemChange qquickitem.cpp 6213 0x7fff6aa226f7 3 QQuickItemPrivate::addChild qquickitem.cpp 2964 0x7fff6aa1e663 4 QQuickItem::setParentItem qquickitem.cpp 2753 0x7fff6aa0f57c 5 QQuickMenuBarPrivate::beginCreateItem qquickmenubar.cpp 100 0x7fff6e627c08 6 QQuickMenuBarPrivate::createItem qquickmenubar.cpp 115 0x7fff6e627c98 7 QQuickMenuBarPrivate::contentData_append qquickmenubar.cpp 263 0x7fff6e6285d9 In particular, the following function is called: void QQuickContainer::itemChange(ItemChange change, const ItemChangeData &data) { Q_D(QQuickContainer); QQuickControl::itemChange(change, data); if (change == QQuickItem::ItemChildAddedChange && isComponentComplete() && data.item != d->background && data.item != d->contentItem) { if (!QQuickItemPrivate::get(data.item)->isTransparentForPositioner() && d->contentModel->indexOf(data.item, nullptr) == -1) addItem(data.item); } } This check is for items that are added after component completion of the control (QQuickMenuBar), as there is a isComponentComplete() check. Before d923dd46, QQuickMenuBarItems were constructed the moment their QQuickMenus were appended to QQuickMenuBar's contentData, which was before component completion. This meant that the isComponentComplete() check above failed as expected and the item was instead added after its creation process was completed (step #4 in the list above): void QQuickMenuBarPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj) { QQuickMenuBar *menuBar = static_cast<QQuickMenuBar *>(prop->object); if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) obj = QQuickMenuBarPrivate::get(menuBar)->createItem(menu); QQuickContainerPrivate::contentData_append(prop, obj); // leads to addItem() being called } Part of the process of an item being added to QQuickMenuBar involves connecting to the signals of its corresponding QQuickMenu (if it has a menu). Quoting the code from QQuickMenuBar::itemAdded(): if (QQuickMenu *menu = menuBarItem->menu()) QObjectPrivate::connect(menu, &QQuickPopup::aboutToHide, d, &QQuickMenuBarPrivate::onMenuAboutToHide); After d923dd46, QQuickMenuBarItems are now constructed *after* component completion to ensure that delegates declared outside of the menu bar have been completed. This means that the isComponentComplete() check in QQuickContainer::itemChange() no longer fails and the item is added before its QQuickMenu is set on it (step #2). As a result, it never connects to the QQuickPopup::aboutToHide() signal and hence it stays activated/highlighted even after the menu has been dismissed, which results in having to click twice on the QQuickMenuBarItem to open the menu the next time. This patch fixes the issue by simply setting the menu on the item before setting its parent: - 1 Begin creation of the item - 1.1 Set the menu on the item - 1.2 Set the parent of the MenuBarItem to the MenuBar - 2 Complete creation of the item - 3 Add the item This ensures that the item has a menu and the connection is made. Change-Id: I93edf7e5a8616a851595ce28ed43f0348078f0b5 Fixes: QTBUG-71583 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12v5.12.0-beta3Liang Qi2018-10-151-3/+38
|\ | | | | | | | | | | | | | | | | Conflicts: src/quicktemplates2/qquickmenubar.cpp src/quicktemplates2/qquickmenubar_p.h src/quicktemplates2/qquickmenubar_p_p.h Change-Id: I5c2115f05826f68f1b1f5ce6762273cd91e6997e
| * MenuBar: ensure the correct delegates are used when created via ComponentMitch Curtis2018-10-021-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Don't add items until we're complete, as the delegate could change in the meantime. Instead, add them to contentData and create them when we're complete. A similar fix was already done for Menu in d5cb26bc. Task-number: QTBUG-67559 Change-Id: Idb43b7a69fcf1c1ad6396c73a3c090b92e460ab8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* | QQuickTheme: rename themeFont() and themePalette()J-P Nurmi2018-05-221-2/+2
| | | | | | | | | | | | | | We don't have the conflicting virtual getters anymore. Change-Id: Ia20bfa0a0b1aa67c35a23270eb0241018f8e0ada Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-05-071-8/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quicktemplates2/qquickabstractbutton_p_p.h src/quicktemplates2/qquickcombobox.cpp src/quicktemplates2/qquickcontainer.cpp src/quicktemplates2/qquickcontrol.cpp src/quicktemplates2/qquickcontrol_p_p.h src/quicktemplates2/qquickdialog_p_p.h src/quicktemplates2/qquickdialogbuttonbox.cpp src/quicktemplates2/qquickdialogbuttonbox_p_p.h src/quicktemplates2/qquickdrawer.cpp src/quicktemplates2/qquickmenubar.cpp src/quicktemplates2/qquickmenubar_p_p.h src/quicktemplates2/qquickpage.cpp src/quicktemplates2/qquickpage_p_p.h src/quicktemplates2/qquickpane.cpp src/quicktemplates2/qquickpane_p_p.h src/quicktemplates2/qquickpopup.cpp src/quicktemplates2/qquickpopup_p_p.h src/quicktemplates2/qquickrangeslider.cpp src/quicktemplates2/qquickscrollview.cpp src/quicktemplates2/qquickslider.cpp src/quicktemplates2/qquickspinbox.cpp src/quicktemplates2/qquickswipeview.cpp src/quicktemplates2/qquicktabbar.cpp src/quicktemplates2/qquicktextarea_p_p.h src/quicktemplates2/qquicktextfield_p_p.h src/quicktemplates2/qquicktheme_p.h Change-Id: I6e2b8fe99e51e3e26c87546aa66af045bc429ec4
| * Templates: use C++11 default member initializationJ-P Nurmi2018-05-041-12/+2
| | | | | | | | | | | | | | | | | | | | | | The code is more readable and less error-prone (this patch caught a few uninitialized members) when the members are initialized in the same place where they are declared. In many cases, empty default destructors can be entirely removed, and we get faster implicitly declared inline default constructors defined by the compiler. Change-Id: I14c5448afc901f9b2ac5965f28c1c26c0b646c08 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Control: add implicitContentWidth|Height propertiesJ-P Nurmi2018-04-131-4/+4
| | | | | | | | | | | | | | | | | | [ChangeLog][Controls][Control] Added implicitContentWidth and implicitContentHeight properties that can be used to simplify complex implicit size bindings. Change-Id: I6ccef572c013605058808ce2ad17f8bd82f49ef0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Promote contentWidth and contentHeight to QQuickContainerJ-P Nurmi2018-04-111-118/+16
| | | | | | | | | | | | | | | | | | | | Now we have contentWidth and contentHeight promoted/unified to QQuickPane and QQuickContainer, and all relevant types inherit the properties from there. The next step is to promote read-only versions all the way up to the QQuickControl base class. Change-Id: Ic6ed5d7b7852b0c7faaa59b9a261c360bc63fb6a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | QQuickMenuBar: refactor content size calculationJ-P Nurmi2018-04-111-50/+74
| | | | | | | | | | | | | | | | Align with the other containers to make it easier to eventually promote contentWidth and contentHeight to the base class, QQuickContainer. Change-Id: I45c28d6902ae3cdf36f25dae60272dbc47a04f16 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Use Q_PRIVATE_PROPERTY for QQmlListPropertyJ-P Nurmi2018-04-041-4/+8
| | | | | | | | | | | | | | | | Hide QQmlListProperty, which is close to unusable in C++, from the templates C++ API. Change-Id: I9720fc3297fc625076a8a7553245852b641bc65a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Add QQuickTheme::ScopeJ-P Nurmi2018-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | Replace the old enums that were originally copied from QPlatformTheme, including irrelevant entries for DockWidget, MdiSubWindow, MessageBox, with a unified enum that will be matched to cover everything needed for theming fonts and palettes for Qt Quick Controls 2. Task-number: QTBUG-67062 Change-Id: Ia99d092f28c00210c0c7f24d4241eb5a5d9ceb5b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-101-1/+3
|\| | | | | | | Change-Id: Id5cd236e14238612647f7a897886be0202863132
| * Doc: add a "Focus Management in Qt Quick Controls 2" pageMitch Curtis2018-03-061-1/+3
| | | | | | | | | | | | | | | | This will list each control that is a focus scope, and have some relevant information about focus in Qt Quick Controls 2. Change-Id: I3126452bf73f7d7730d0522d616d61ad0da0dd74 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* | Move QQuickControlPrivate::themeFont|Palette() to QQuickThemeJ-P Nurmi2018-02-151-2/+2
|/ | | | | | | | | | | | | | QPlatformTheme is too limited for our theming purposes. We need support for separate palettes (and later, icon colors) in dark and light themes. Also, the fact that Qt Quick Controls 2 injects a platform proxy theme does have undesired side effects in Qt Widgets and Qt Quick Controls 1. Therefore, we start separating QPlatformTheme and QQuickTheme. The first step is to eliminate some direct QPlatformTheme access in QQuickControl and route it via QQuickTheme instead. Task-number: QTBUG-51921 Change-Id: I055471a75ed6f26968796496efd1892975447c98 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix dereference after null checkJesus Fernandez2017-08-021-1/+4
| | | | | | | | | | CID 182271 (#1 of 1): Dereference after null check (FORWARD_NULL) 5. var_deref_model: Passing null pointer item to setParentItem, which dereferences it. Coverity-Id: 182271 Change-Id: Ifd7dcf58b58271c9b5e2f461f68153aaed4b97a2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Introduce MenuBarJ-P Nurmi2017-07-261-0/+656
MenuBar is an ordinary Item. It can be located basically anywhere, but the idea is to introduce a new ApplicationWindow::menuBar property in a follow-up commit. Currently the example snippets are using the header property. [ChangeLog][Controls][MenuBar] Introduced a MenuBar control. Task-number: QTBUG-60350 Change-Id: Ie66dc457a3d8edbe8362fab2a591dc49442c95e2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>