diff options
| author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-02-27 14:02:22 +0100 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-01 11:05:58 +0100 |
| commit | b0d19a08b4f34859c8643495d1910690c48644c9 (patch) | |
| tree | 99c1df3b9763abaff24a1f1b8ff54c88b1f6c0d6 /src/controls/qtmenubar.cpp | |
| parent | 6215e42377fbe5bc0e67a08702bede2982a363d9 (diff) | |
| download | qtquickcontrols-b0d19a08b4f34859c8643495d1910690c48644c9.tar.gz | |
MenuBar, Menu, MenuItem, Action: New, reviewed API
Change-Id: Ic018c0d9c61ddf6fdf05750bf172cf5e306d0508
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/qtmenubar.cpp')
| -rw-r--r-- | src/controls/qtmenubar.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/controls/qtmenubar.cpp b/src/controls/qtmenubar.cpp index 242e6521..fafccf00 100644 --- a/src/controls/qtmenubar.cpp +++ b/src/controls/qtmenubar.cpp @@ -41,6 +41,7 @@ #include "qtmenubar_p.h" +#include <QtQuick/QQuickItem> #include "private/qguiapplication_p.h" #include <QtGui/qpa/qplatformtheme.h> #include <QtGui/qpa/qplatformmenu.h> @@ -59,10 +60,9 @@ QT_BEGIN_NAMESPACE \internal \inqmlmodule QtQuick.Controls 1.0 */ -QtMenuBar::QtMenuBar(QQuickItem *parent) - : QQuickItem(parent) +QtMenuBar::QtMenuBar(QObject *parent) + : QObject(parent), m_contentItem(0), m_parentWindow(0) { - connect(this, SIGNAL(parentChanged(QQuickItem *)), this, SLOT(updateParent(QQuickItem *))); m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); } @@ -75,15 +75,26 @@ QQmlListProperty<QtMenu> QtMenuBar::menus() return QQmlListProperty<QtMenu>(this, 0, &QtMenuBar::append_menu, &QtMenuBar::count_menu, &QtMenuBar::at_menu, 0); } -bool QtMenuBar::isNative() { +bool QtMenuBar::isNative() +{ return m_platformMenuBar != 0; } -void QtMenuBar::updateParent(QQuickItem *newParent) +void QtMenuBar::setContentItem(QQuickItem *item) +{ + if (item != m_contentItem) { + m_contentItem = item; + emit contentItemChanged(); + } +} + +void QtMenuBar::setParentWindow(QQuickWindow *newParentWindow) { - QWindow *newParentWindow = newParent ? newParent->window() : 0; - if (newParentWindow != window() && m_platformMenuBar) - m_platformMenuBar->handleReparent(newParentWindow); + if (newParentWindow != m_parentWindow) { + m_parentWindow = newParentWindow; + if (m_platformMenuBar) + m_platformMenuBar->handleReparent(m_parentWindow); + } } void QtMenuBar::append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu) @@ -95,7 +106,7 @@ void QtMenuBar::append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu) if (menuBar->m_platformMenuBar) menuBar->m_platformMenuBar->insertMenu(menu->platformMenu(), 0 /* append */); - menuBar->menuChanged(); + emit menuBar->menusChanged(); } } |
