summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-12-04 01:34:27 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-12-07 13:41:36 +0000
commit80cde7c7ca22511494ae6d32b2023fb1e92ede4d (patch)
treec45ad49b498ccde716283675822ae674cfa5454c
parent12f699a0a66055b70acfcc4f6c957cebf19f4504 (diff)
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.cpp14
-rw-r--r--src/controls/qquickmenu_p.h3
-rw-r--r--src/controls/qquickmenupopupwindow.cpp16
-rw-r--r--src/controls/qquickmenupopupwindow_p.h3
4 files changed, 18 insertions, 18 deletions
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index 84f7b1aad..e7cd62b5d 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 f49f6d623..8e881fb4f 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 a578ea625..9385be46b 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 deb867b31..750b8207c 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