aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qquickmenu
Commit message (Collapse)AuthorAgeFilesLines
* Blacklist tst_QQuickMenu::popup on macOSTor Arne Vestbø2020-01-231-0/+2
| | | | | | | | It relies on moving the cursor. Task-number: QTBUG-76312 Change-Id: I317083b974d3e9e8d6d616dc3248ee64e0f36021 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix Flaky testsDimitrios Apostolou2019-07-221-20/+20
| | | | | | | | | | | | These tests where failing sometimes in our CI, because centerOnScreen() was invoked which asks the window manager to move the window, but does not wait for the event's completion. The solution is to do all that *before* the initial qWaitForWindowActive(). Fixes: QTBUG-73128 Change-Id: I06c1f85d5ff9657dccab50f29084f7624cd7e194 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix flaky tst_qquickmenu testMitch Curtis2019-05-071-2/+3
| | | | | | | | | | The important part of the "cascading" test is checking that the sub-sub menu eventually opens, so move the !visible check to the non-cascading branch of the if statement. Change-Id: I5a09bf0b5d45832f7b75c3e8c397fdb9e6fcc011 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
* Fix MenuItem width not matching Menu's available widthMitch Curtis2019-05-032-0/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Short version: There are currently two problems with MenuItems: - Mirrored MenuItems don't fill the Menu's available width. - MenuItem does not fill the Menu's available width when changed after Component completion. This patch fixes both of them by listening to geometry changes in both the contentItem and individual menu items, and setting the explicit width of those menu items when either changes. Longer version: The first problem can be seen whenever the MenuItem's implicitWidth changes: - QQmlEngine::retranslate() is called, causing all bindings to be re-evaluated - The MenuItem's font size changes - The MenuItem's icon size changes - etc. We fix this by making Menu listen to the width of each of its MenuItems and call resizeItem() if it doesn't have an explicit width. The second problem can be seen when e.g. resizing a Menu to account for new items that are wider and hence require more space. This can be fixed by listening to width changes in Menu's contentItem, which was actually done in earlier versions but (probably accidentally) removed in 482ecb0f. I had tried to solve both issues by setting the explicit width of MenuItem to the width of its Menu, or undefined if it has none (which means it reverts to its implicit width). However, this does not account for e.g. MenuSeparator and custom items that can be added to Menu - they should also have their width fill the Menu automatically if they don't have an explicit width set. Change-Id: I95dd0da0919a1e297f2e2030da746ff1f1a17644 Fixes: QTBUG-75051 Fixes: QTBUG-75142 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Make tst_qquickmenu run with all stylesMitch Curtis2019-05-033-92/+180
| | | | | | | | | This is a prerequisite for ensuring that an Imagine-style-specific fix works. Fixes: QTBUG-75141 Change-Id: Iafef3bf947151cb35b88a1230e3541d8e4e15fd9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickMenu: allow enter/return to be used to activate itemsMitch Curtis2019-02-281-1/+30
| | | | | | | | | | | Before this patch, only space was allowed. Windows 10 and macOS 10.14.2 both allow using enter to activate menu items. Change-Id: I64476347669ff73f233efd129563a18ba51618a5 Fixes: QTBUG-73354 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickMenu: don't give focus to disabled menu itemsMitch Curtis2019-02-042-0/+138
| | | | | | Change-Id: I7eb394ca3991eae585fbbd8e665c46b11ef64a07 Fixes: QTBUG-70181 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Menu: fix disabled sub-menu items being highlightedMitch Curtis2019-02-042-0/+202
| | | | | | | | | | | When a menu item with a sub-menu was triggered by key or mouse, it would open the sub-menu with the first menu item highlighted. This doesn't make sense for disabled menu items, so this patch makes it find the first enabled item. Change-Id: I9df1c750749e5a77b027b6f476b8ae1f5ea035bd Fixes: QTBUG-69540 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix Menu not being dismissed when the triggered item disables itselfMitch Curtis2019-02-042-0/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem Consider the following code: Menu { title: "Menu" Action { text: "Item" onTriggered: enabled = false } } A MenuItem (AbstractButton) is created for the Action, and when it is clicked, this function is called: void QQuickAbstractButtonPrivate::trigger() { Q_Q(QQuickAbstractButton); if (action && action->isEnabled()) QQuickActionPrivate::get(action)->trigger(q, false); else if (effectiveEnable) emit q->clicked(); } QQuickActionPrivate::get(action)->trigger(q, false) results in this function being called: void QQuickAbstractButtonPrivate::click() { Q_Q(QQuickAbstractButton); if (effectiveEnable) emit q->clicked(); } Since the action (and hence the menu item) was disabled in the signal handler, the effectiveEnable check fails and clicked() is not emitted. This causes the menu to not be dismissed. Solution Before calling QQuickActionPrivate::get(action)->trigger(), store the button's enabled state. If triggering the action causes the action to be disabled (due to the signal handler), we can then choose whether or not we emit QQuickAbstractButton::clicked(). Specifically, we emit clicked() if: - we were enabled before triggering the action, and - we have no associated action, or it's no longer enabled Task-number: QTBUG-69682 Change-Id: Ib4e3c313b776decc74089a6beffe415605c430be Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Revert all Menu delegate patchesv5.12.0-rc2v5.12.0-rc1v5.12.0Mitch Curtis2018-11-155-453/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* tst_qquickmenu: add a test for MenuItems before and after a Repeaterv5.12.0-beta4Mitch Curtis2018-11-022-1/+119
| | | | | | | | Just to verify that it works, as a similar test was added for Instantiator in another patch. Change-Id: I1ab55d98a3726bff1a2984db0d81ae444e05d630 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix Instantiator-created MenuItems disappearingMitch Curtis2018-11-023-0/+235
| | | | | | | | | | | | | | | When d5cb26bc fixed a bug in Menu, it also broke the use case of having an Instantiator create menu items. Using an Instantiator like this allows users to create a "Recent Files" menu, for example. The issue was that we would indiscriminately recreate items, even those owned by an Instantiator. This patch avoids recreating items owned by Instantiators. It also adds a logging category for Menu, to aid debugging. Fixes: QTBUG-71066 Change-Id: Ie0e46de1cbfaee81b43d63f3143435f2514371d5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Tie minor version of all imports to Qt's minor versionMitch Curtis2018-11-0214-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes all Qt Quick Controls 2 imports match the current Qt minor version, which is 12 as of this patch. It also updates all other Qt Quick imports to match. This will also make future version bumps easier as all version numbers in existing code/docs will match. The following commands were used to verify that no old versions remain: for i in `seq 0 11`; do git grep "import QtGraphicalEffects.*1.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick 2.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick.Layouts 1.$i$"; done for i in `seq 0 5`; do git grep "import QtQuick.Controls.*2.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick.Templates 2.$i as T$"; done [ChangeLog] From Qt 5.12 onwards, all import versions in Qt Quick Controls 2 follow the same minor version as Qt's minor version number. For example, the import version for Qt 5.12 is: "import QtQuick.Controls 2.12". Change-Id: I6d87573f20912e041d9c3b7c773cc7bf7b152ec3 Fixes: QTBUG-71095 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_qquickmenu: fix memory leakv5.12.0-beta2Mitch Curtis2018-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | takeItem() unparents the item, so we need to make sure it gets deleted. The leak was caught by valgrind: ==10039== 832 (32 direct, 800 indirect) bytes in 1 blocks are definitely lost in loss record 6,465 of 6,706 ==10039== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10039== by 0x112C1E: tst_QQuickMenu::count() (tst_qquickmenu.cpp:121) ==10039== by 0x12F313: tst_QQuickMenu::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (tst_qquickmenu.moc:156) ==10039== by 0x612B6B2: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:2305) ==10039== by 0x41B07CD: invoke (qmetaobject.h:123) ==10039== by 0x41B07CD: QTest::TestMethods::invokeTestOnData(int) const (qtestcase.cpp:915) ==10039== by 0x41B15BF: QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const (qtestcase.cpp:1114) ==10039== by 0x41B1D07: QTest::TestMethods::invokeTests(QObject*) const (qtestcase.cpp:1456) ==10039== by 0x41B2381: QTest::qRun() (qtestcase.cpp:1896) ==10039== by 0x41B24E1: QTest::qExec(QObject*, int, char**) (qtestcase.cpp:1783) ==10039== by 0x12F468: main (tst_qquickmenu.cpp:1505) Change-Id: I459c7897c1088c8b58152d2e0b5ceb8f3684e589 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Menu: ensure the correct delegates are used when created via ComponentMitch Curtis2018-09-053-0/+206
| | | | | | | | | | 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. Task-number: QTBUG-67559 Change-Id: I5f42129f49de861ff5f15d0069daeda0b4e5017c Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Menu: fix items not being scrollable when using WindowMitch Curtis2018-06-253-0/+174
| | | | | | | | | | Use Window.window instead of ApplicationWindow.window, as the former will always result in a window regardless of which type of window is in use. Task-number: QTBUG-68858 Change-Id: I3bdb60350d92b13621b0f4db9085bf067b6ff6e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10J-P Nurmi2017-09-276-0/+1293
| | | | | | | | | | Conflicts: .gitignore tests/auto/auto.pro tests/auto/qquickmenu/tst_qquickmenu.cpp tests/auto/qquickpopup/tst_qquickpopup.cpp Change-Id: I7e5a7b39d890796fd63a7b24ae19765ab41fecda
* Rename tst_menu to tst_QQuickMenuJ-P Nurmi2017-09-278-0/+965
Change-Id: I1c7e1a2b337e9d16bc6c9b098db08f29f1b9d1e6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>