diff options
| author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-02-28 22:08:05 +0100 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-01 11:06:55 +0100 |
| commit | a3737d7481aba3b93e23fb0c26e6a4dc13b75658 (patch) | |
| tree | c2616c8b62108c33b3fb1e9591f6fdace1cd7335 /src/controls/qtmenu.cpp | |
| parent | edc559b1e0bea1b4eed247e8bf9ada672d7e9dc9 (diff) | |
MenuBar. Menu, MenuItem: Update documentation to new API
Also removed Menu.visibleParent since it had no apparent use. Likewise,
trigger(), and the triggered() signal are now only in MenuItem.
Change-Id: Ide194505664c60906019422a503b189250d6a86e
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/qtmenu.cpp')
| -rw-r--r-- | src/controls/qtmenu.cpp | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/src/controls/qtmenu.cpp b/src/controls/qtmenu.cpp index cbfb0108a..c7281774f 100644 --- a/src/controls/qtmenu.cpp +++ b/src/controls/qtmenu.cpp @@ -65,40 +65,72 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty readonly list Menu::menuItems + \qmlproperty readonly list Menu::items \default + + The list of items in the menu. + + \sa MenuItem, MenuSeparator */ /*! - \qmlproperty var Menu::model + \qmlproperty bool Menu::visible + + Whether the menu should be visible. This is only enabled when the menu is used as + a submenu. */ /*! - \qmlproperty int Menu::selectedIndex + \qmlproperty string Menu::text + + Text for the menu, whether in a \l MenuBar or as a submenu. + Accelerators are supported with the usual \& convention. +*/ + +/*! + \qmlproperty bool Menu::enabled + + Whether the menu is enabled, and responsive to user interaction as a submenu. */ /*! - \qmlproperty font Menu::font + \qmlproperty url Menu::iconSource + + Sets the icon file or resource url for the menu icon as a submenu. - Write-only. For styling purposes only. + \sa iconName */ /*! - \qmlproperty readonly bool Menu::popupVisible + \qmlproperty string Menu::iconName + + Sets the icon name for the menu icon. This will pick the icon + with the given name from the current theme. Only works as a submenu. + + \sa iconSource */ /*! - \qmlmethod void Menu::popup(referenceItem, x, y, atIndex) + \qmlproperty int Menu::selectedIndex - Pops up this menu at the given position relative to \c referenceItem. + The index for the last selected item in the menu. +*/ + +/*! + \qmlmethod void Menu::popup() + + Pops up this menu under the mouse cursor. It can block on some platforms, so test it accordingly. */ +/*! + \qmlproperty var Menu::model +*/ + QtMenu::QtMenu(QObject *parent) : QtMenuText(parent), m_selectedIndex(-1), m_highlightedIndex(0), - m_visualParent(0), m_hasNativeModel(false), m_minimumWidth(0), m_popupWindow(0), @@ -167,12 +199,9 @@ QQmlListProperty<QtMenuBase> QtMenu::menuItems() QQuickWindow *QtMenu::findParentWindow() { if (!m_parentWindow) { - m_parentWindow = m_visualParent ? m_visualParent->window() : 0; - if (!m_parentWindow) { - QQuickItem *parentAsItem = qobject_cast<QQuickItem *>(parent()); - m_parentWindow = visualItem() ? visualItem()->window() : // Menu as menu item case - parentAsItem ? parentAsItem->window() : 0; //Menu as context menu/popup case - } + QQuickItem *parentAsItem = qobject_cast<QQuickItem *>(parent()); + m_parentWindow = visualItem() ? visualItem()->window() : // Menu as menu item case + parentAsItem ? parentAsItem->window() : 0; //Menu as context menu/popup case } return m_parentWindow; } @@ -204,8 +233,8 @@ void QtMenu::__popup(qreal x, qreal y, int atItemIndex) if (m_platformMenu) { QPointF screenPosition(x, y); - if (m_visualParent) - screenPosition = m_visualParent->mapToScene(screenPosition); + if (visualItem()) + screenPosition = visualItem()->mapToScene(screenPosition); m_platformMenu->showPopup(parentWindow, screenPosition.toPoint(), atItem ? atItem->platformItem() : 0); } else { m_popupWindow = new QtMenuPopupWindow(); @@ -214,8 +243,8 @@ void QtMenu::__popup(qreal x, qreal y, int atItemIndex) connect(m_popupWindow, SIGNAL(visibleChanged(bool)), this, SLOT(windowVisibleChanged(bool))); if (parentWindow) { - if (m_visualParent) { - QPointF pos = m_visualParent->mapToItem(parentWindow->contentItem(), QPointF(x, y)); + if (visualItem()) { + QPointF pos = visualItem()->mapToItem(parentWindow->contentItem(), QPointF(x, y)); x = pos.x(); y = pos.y(); } @@ -239,14 +268,6 @@ void QtMenu::__popup(qreal x, qreal y, int atItemIndex) } } -void QtMenu::setVisualParent(QQuickItem *item) -{ - if (m_visualParent != item) { - m_visualParent = item; - emit visualParentChanged(); - } -} - void QtMenu::setMenuContentItem(QQuickItem *item) { if (m_menuContentItem != item) |
