From 385589ef458715fcaa533bbd01ca421dc1040eba Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Oct 2017 17:39:08 +0700 Subject: QCocoaMenu: Attach menu items when updating the menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of waiting for the menu delegate to update each item, we can attach an NSMenu to its NSMenuItem as soon as we update the current window's menubar. This is safe to do because we know that this is going to be the main menubar right after, so we're not orphaning any NSMenuItem from its NSMenu at the wrong moment. By doing this, we also ensure that all menus from the active menubar are reachable by the key-equivalent dispatching logic, even before we display the actual menu. This was shown in BigMenuCreator where, under the menubar's ASP and SAP menus, all A*S submenus would be disabled. Furthermore, on the same menus, SAP would show the same issue. Added test in Menurama as well. Change-Id: If6e7311072e6b53ad1cbced73623d1832aa0df8e Task-number: QTBUG-57076 Task-number: QTBUG-63712 Reviewed-by: Morten Johan Sørvig --- tests/manual/cocoa/menurama/mainwindow.cpp | 5 +++++ tests/manual/cocoa/menurama/mainwindow.ui | 1 + 2 files changed, 6 insertions(+) (limited to 'tests/manual/cocoa') diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp index 06867bd7c9..086fc1e2fa 100644 --- a/tests/manual/cocoa/menurama/mainwindow.cpp +++ b/tests/manual/cocoa/menurama/mainwindow.cpp @@ -37,6 +37,11 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); + auto *a = ui->menuStuff->addAction("Enabled Submenu (QTBUG-63172)"); + auto *qtbug63172_Menu = new QMenu; + qtbug63172_Menu->addAction("We're Good!"); + a->setMenu(qtbug63172_Menu); + startTimer(1000); connect(ui->menuAfter_aboutToShow, &QMenu::aboutToShow, [=] { diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui index 18cded70d2..4fb3e3420e 100644 --- a/tests/manual/cocoa/menurama/mainwindow.ui +++ b/tests/manual/cocoa/menurama/mainwindow.ui @@ -131,6 +131,7 @@ Click on "Dynamic Stuff" then move left and right to other menus. Disa + -- cgit v1.2.3 From 19b0ce5daa31e2ffebfcf2701143742302f1deb4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Apr 2017 21:13:52 -0700 Subject: Change almost all other uses of qrand() to QRandomGenerator The vast majority is actually switched to QRandomGenerator::bounded(), which gives a mostly uniform distribution over the [0, bound) range. There are very few floating point cases left, as many of those that did use floating point did not need to, after all. (I did leave some that were too ugly for me to understand) This commit also found a couple of calls to rand() instead of qrand(). This commit does not include changes to SSL code that continues to use qrand() (job for someone else): src/network/ssl/qsslkey_qt.cpp src/network/ssl/qsslsocket_mac.cpp tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll --- tests/manual/cocoa/nativewidgets/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/manual/cocoa') diff --git a/tests/manual/cocoa/nativewidgets/main.cpp b/tests/manual/cocoa/nativewidgets/main.cpp index bfa97aa62f..3923e30de7 100644 --- a/tests/manual/cocoa/nativewidgets/main.cpp +++ b/tests/manual/cocoa/nativewidgets/main.cpp @@ -37,7 +37,7 @@ class ColorWidget : public QWidget void changeColor() { - color.setHsv((qreal(qrand()) / RAND_MAX) * 50 + 200, s, s); + color.setHsv(QRandomGenerator::global()->bounded(50) + 200, s, s); } public: -- cgit v1.2.3