diff options
author | Filippo Cucchetto <filippocucchetto@gmail.com> | 2015-12-04 01:34:27 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-12-07 13:41:36 +0000 |
commit | 80cde7c7ca22511494ae6d32b2023fb1e92ede4d (patch) | |
tree | c45ad49b498ccde716283675822ae674cfa5454c | |
parent | 12f699a0a66055b70acfcc4f6c957cebf19f4504 (diff) | |
download | qtquickcontrols-80cde7c7ca22511494ae6d32b2023fb1e92ede4d.tar.gz |
Moved menuBar function from QQuickMenuPopupWindow to QQuickmenuv5.6.0-beta1
Change-Id: I6628ac2b8b07634afc1062488a12788a4e3f66c0
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/controls/qquickmenu.cpp | 14 | ||||
-rw-r--r-- | src/controls/qquickmenu_p.h | 3 | ||||
-rw-r--r-- | src/controls/qquickmenupopupwindow.cpp | 16 | ||||
-rw-r--r-- | src/controls/qquickmenupopupwindow_p.h | 3 |
4 files changed, 18 insertions, 18 deletions
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp index 84f7b1aa..e7cd62b5 100644 --- a/src/controls/qquickmenu.cpp +++ b/src/controls/qquickmenu.cpp @@ -586,6 +586,20 @@ void QQuickMenu::destroyAllMenuPopups() { popup->setToBeDeletedLater(); } +QQuickMenuBar *QQuickMenu::menuBar() +{ + QObject *pi = parentMenuOrMenuBar(); + while (pi) { + if (QQuickMenuBar *menuBar = qobject_cast<QQuickMenuBar*>(pi)) + return menuBar; + else if (QQuickMenu *menu = qobject_cast<QQuickMenu*>(pi)) + pi = menu->parentMenuOrMenuBar(); + else + return 0; + } + return 0; +} + void QQuickMenu::__closeAndDestroy() { hideMenu(); diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h index f49f6d62..8e881fb4 100644 --- a/src/controls/qquickmenu_p.h +++ b/src/controls/qquickmenu_p.h @@ -51,6 +51,7 @@ class QPlatformMenu; class QQuickMenuPopupWindow; class QQuickMenuItemContainer; class QQuickWindow; +class QQuickMenuBar; typedef QQmlListProperty<QObject> QQuickMenuItems; @@ -152,6 +153,8 @@ public: void destroyMenuPopup(); void destroyAllMenuPopups(); + QQuickMenuBar *menuBar(); + protected Q_SLOTS: void updateSelectedIndex(); diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index a578ea62..9385be46 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -168,25 +168,11 @@ QQuickMenu *QQuickMenuPopupWindow::menu() const return m_menu; } -QQuickMenuBar *QQuickMenuPopupWindow::menuBar() const -{ - QObject *pi = menu()->parentMenuOrMenuBar(); - while (pi) { - if (QQuickMenuBar *menuBar = qobject_cast<QQuickMenuBar*>(pi)) - return menuBar; - else if (QQuickMenu *menu = qobject_cast<QQuickMenu*>(pi)) - pi = menu->parentMenuOrMenuBar(); - else - return 0; - } - return 0; -} - bool QQuickMenuPopupWindow::shouldForwardEventAfterDismiss(QMouseEvent *e) const { // If the event falls inside this item the event should not be forwarded. // For example for comboboxes or top menus of the menubar - QQuickMenuBar *mb = menuBar(); + QQuickMenuBar *mb = m_menu ? m_menu->menuBar() : Q_NULLPTR; QQuickItem *item = mb && !mb->isNative() ? mb->contentItem() : menu()->visualItem(); QWindow *window = transientParent(); if (item && window && item->window() == window) { diff --git a/src/controls/qquickmenupopupwindow_p.h b/src/controls/qquickmenupopupwindow_p.h index deb867b3..750b8207 100644 --- a/src/controls/qquickmenupopupwindow_p.h +++ b/src/controls/qquickmenupopupwindow_p.h @@ -77,9 +77,6 @@ private: QPointF m_initialPos; QPointer<QQuickWindow> m_logicalParentWindow; QQuickMenu *m_menu; - -private: - QQuickMenuBar *menuBar() const; }; QT_END_NAMESPACE |