diff options
-rw-r--r-- | examples/gallery/main.qml | 18 | ||||
-rw-r--r-- | src/controls/Menu.qml | 7 | ||||
-rw-r--r-- | src/controls/MenuBar.qml | 4 | ||||
-rw-r--r-- | src/controls/qtmenu.cpp | 6 | ||||
-rw-r--r-- | src/controls/qtmenu_p.h | 4 | ||||
-rw-r--r-- | src/controls/qtmenuitem.cpp | 4 | ||||
-rw-r--r-- | src/controls/qtmenuitem_p.h | 5 | ||||
-rw-r--r-- | src/styles/Desktop/MenuBarStyle.qml | 2 | ||||
-rw-r--r-- | src/styles/Desktop/MenuStyle.qml | 2 | ||||
-rw-r--r-- | src/styles/MenuBarStyle.qml | 2 |
10 files changed, 30 insertions, 24 deletions
diff --git a/examples/gallery/main.qml b/examples/gallery/main.qml index 3b5e1a7c..1db94223 100644 --- a/examples/gallery/main.qml +++ b/examples/gallery/main.qml @@ -161,7 +161,7 @@ ApplicationWindow { MenuItem { action: pasteAction } MenuSeparator {} Menu { - text: "Text Format" + title: "Text Format" MenuItem { action: a1 } MenuItem { action: a2 } MenuItem { action: a3 } @@ -169,25 +169,25 @@ ApplicationWindow { MenuItem { text: "Allow Hyphenation"; checkable: true } MenuSeparator { } Menu { - text: "More Stuff" + title: "More Stuff" MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } MenuSeparator { } Menu { - text: "More Stuff" + title: "More Stuff" MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } MenuSeparator { } Menu { - text: "More Stuff" + title: "More Stuff" MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } MenuSeparator { } Menu { - text: "More Stuff" + title: "More Stuff" MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } @@ -197,7 +197,7 @@ ApplicationWindow { } } Menu { - text: "Font Style" + title: "Font Style" MenuItem { text: "Bold"; checkable: true } MenuItem { text: "Italic"; checkable: true } MenuItem { text: "Underline"; checkable: true } @@ -220,7 +220,7 @@ ApplicationWindow { menuBar: MenuBar { Menu { - text: "&File" + title: "&File" MenuItem { action: openAction } MenuItem { text: "Close" @@ -229,7 +229,7 @@ ApplicationWindow { } } Menu { - text: "&Edit" + title: "&Edit" MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } @@ -245,7 +245,7 @@ ApplicationWindow { visible: false } Menu { - text: "Me Neither" + title: "Me Neither" visible: false } } diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml index cb6264f7..8641a0e1 100644 --- a/src/controls/Menu.qml +++ b/src/controls/Menu.qml @@ -51,7 +51,7 @@ import "Styles/Settings.js" as Settings \code Menu { - text: "Edit" + title: "Edit" MenuItem { text: "Cut" @@ -74,7 +74,7 @@ import "Styles/Settings.js" as Settings MenuSeparator { } Menu { - text: "More Stuff" + title: "More Stuff" MenuItem { text: "Do Nothing" @@ -246,9 +246,10 @@ MenuPrivate { id: menuItemLoader property var menuItem: modelData - property bool isSeparator: menuItem ? !menuItem.hasOwnProperty("text") : false + property bool isSeparator: menuItem ? !menuItem.hasOwnProperty("enabled") : true property bool hasSubmenu: menuItem ? !!menuItem["items"] : false property bool selected: !isSeparator && root.__currentIndex === index + property string text: hasSubmenu ? menuItem.title : !isSeparator ? menuItem.text : "" property int menuItemIndex: index diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index d8d4a78d..9abe5cea 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -54,13 +54,13 @@ import "Styles/Settings.js" as Settings \code MenuBar { Menu { - text: "File" + title: "File" MenuItem { text: "Open..." } MenuItem { text: "Close" } } Menu { - text: "Edit" + title: "Edit" MenuItem { text: "Cut" } MenuItem { text: "Copy" } MenuItem { text: "Paste" } diff --git a/src/controls/qtmenu.cpp b/src/controls/qtmenu.cpp index 688ecb65..1dbc64e4 100644 --- a/src/controls/qtmenu.cpp +++ b/src/controls/qtmenu.cpp @@ -82,9 +82,9 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty string Menu::text + \qmlproperty string Menu::title - Text for the menu as a submenu or in a menubar. + Title for the menu as a submenu or in a menubar. Mnemonics are supported by prefixing the shortcut letter with \&. For instance, \c "\&File" will bind the \c Alt-F shortcut to the @@ -142,6 +142,8 @@ QtMenu::QtMenu(QObject *parent) m_menuContentItem(0), m_popupVisible(false) { + connect(this, SIGNAL(__textChanged()), this, SIGNAL(titleChanged())); + m_platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); if (m_platformMenu) { connect(m_platformMenu, SIGNAL(aboutToHide()), this, SLOT(__closeMenu())); diff --git a/src/controls/qtmenu_p.h b/src/controls/qtmenu_p.h index 868e29e0..bb595328 100644 --- a/src/controls/qtmenu_p.h +++ b/src/controls/qtmenu_p.h @@ -58,6 +58,7 @@ class QQuickWindow; class QtMenu : public QtMenuText { Q_OBJECT + Q_PROPERTY(QString title READ text WRITE setText NOTIFY titleChanged) Q_PROPERTY(QQmlListProperty<QtMenuBase> items READ menuItems NOTIFY itemsChanged) Q_CLASSINFO("DefaultProperty", "items") Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged) @@ -87,6 +88,7 @@ Q_SIGNALS: void selectedIndexChanged(); void modelChanged(const QVariant &newModel); void itemsChanged(); + void titleChanged(); void __menuClosed(); void popupVisibleChanged(); @@ -95,8 +97,6 @@ public: QtMenu(QObject *parent = 0); virtual ~QtMenu(); - void setText(const QString &text); - int selectedIndex() const { return m_selectedIndex; } void setSelectedIndex(int index); diff --git a/src/controls/qtmenuitem.cpp b/src/controls/qtmenuitem.cpp index 24530344..2afd8f6d 100644 --- a/src/controls/qtmenuitem.cpp +++ b/src/controls/qtmenuitem.cpp @@ -192,7 +192,7 @@ void QtMenuText::updateText() platformItem()->setText(text()); syncWithPlatformMenu(); } - emit textChanged(); + emit __textChanged(); } void QtMenuText::updateEnabled() @@ -359,6 +359,8 @@ void QtMenuText::updateIcon() QtMenuItem::QtMenuItem(QObject *parent) : QtMenuText(parent), m_boundAction(0) { + connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged())); + connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered())); connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked())); if (platformItem()) diff --git a/src/controls/qtmenuitem_p.h b/src/controls/qtmenuitem_p.h index 2392872d..81b27c49 100644 --- a/src/controls/qtmenuitem_p.h +++ b/src/controls/qtmenuitem_p.h @@ -104,7 +104,6 @@ public: class QtMenuText: public QtMenuBase { Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) @@ -112,11 +111,11 @@ class QtMenuText: public QtMenuBase Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY __iconChanged) Q_SIGNALS: - void textChanged(); void enabledChanged(); void iconSourceChanged(); void iconNameChanged(); + void __textChanged(); void __iconChanged(); public: @@ -152,6 +151,7 @@ private: class QtMenuItem: public QtMenuText { Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged) Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) Q_PROPERTY(QtExclusiveGroup *exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup NOTIFY exclusiveGroupChanged) @@ -165,6 +165,7 @@ Q_SIGNALS: void triggered(); void toggled(bool checked); + void textChanged(); void checkableChanged(); void exclusiveGroupChanged(); void shortcutChanged(); diff --git a/src/styles/Desktop/MenuBarStyle.qml b/src/styles/Desktop/MenuBarStyle.qml index c181b6ca..5abd1711 100644 --- a/src/styles/Desktop/MenuBarStyle.qml +++ b/src/styles/Desktop/MenuBarStyle.qml @@ -59,7 +59,7 @@ Style { x: pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth") y: pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth") - text: menuItem.text + text: menuItem.title contentWidth: textWidth(text) contentHeight: textHeight(text) width: implicitWidth + pixelMetric("menubaritemspacing") diff --git a/src/styles/Desktop/MenuStyle.qml b/src/styles/Desktop/MenuStyle.qml index f40b42aa..2cbbe18f 100644 --- a/src/styles/Desktop/MenuStyle.qml +++ b/src/styles/Desktop/MenuStyle.qml @@ -75,7 +75,7 @@ Style { x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth") y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth") - text: isSeparator || !menuItem ? "" : menuItem.text + text: control.text property string textAndShorcut: text + (properties.shortcut ? "\t" + properties.shortcut : "") contentWidth: textWidth(textAndShorcut) contentHeight: textHeight(textAndShorcut) diff --git a/src/styles/MenuBarStyle.qml b/src/styles/MenuBarStyle.qml index 2ddee495..3d31db99 100644 --- a/src/styles/MenuBarStyle.qml +++ b/src/styles/MenuBarStyle.qml @@ -63,7 +63,7 @@ Style { Text { id: text - text: menuItem.text + text: menuItem.title anchors.centerIn: parent renderType: Text.NativeRendering color: selected ? __syspal.highlightedText : __syspal.windowText |