aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/MenuSeparator.qml57
-rw-r--r--src/imports/controls/controls.pri1
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.pngbin0 -> 5574 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-menuseparator.pngbin0 -> 5614 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml69
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml60
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc17
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc10
-rw-r--r--src/imports/controls/material/MenuSeparator.qml55
-rw-r--r--src/imports/controls/material/material.pri1
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp1
-rw-r--r--src/imports/controls/universal/MenuSeparator.qml60
-rw-r--r--src/imports/controls/universal/universal.pri1
-rw-r--r--src/imports/templates/qtquicktemplates2plugin.cpp2
-rw-r--r--src/quicktemplates2/qquickmenuseparator.cpp80
-rw-r--r--src/quicktemplates2/qquickmenuseparator_p.h75
-rw-r--r--src/quicktemplates2/quicktemplates2.pri2
-rw-r--r--tests/auto/menu/data/menuSeparator.qml73
-rw-r--r--tests/auto/menu/tst_menu.cpp45
-rw-r--r--tests/manual/testbench/main.qml6
20 files changed, 615 insertions, 0 deletions
diff --git a/src/imports/controls/MenuSeparator.qml b/src/imports/controls/MenuSeparator.qml
new file mode 100644
index 00000000..f74047bb
--- /dev/null
+++ b/src/imports/controls/MenuSeparator.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Templates 2.1 as T
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ padding: 2
+ topPadding: padding + 4
+ bottomPadding: padding + 4
+
+ //! [contentItem]
+ contentItem: Rectangle {
+ implicitWidth: 188
+ implicitHeight: 1
+ color: "#ccc"
+ }
+ //! [contentItem]
+}
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index 618a8650..9eeb2c1f 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -26,6 +26,7 @@ QML_CONTROLS = \
Label.qml \
Menu.qml \
MenuItem.qml \
+ MenuSeparator.qml \
Page.qml \
PageIndicator.qml \
Pane.qml \
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png
new file mode 100644
index 00000000..48785b73
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png
new file mode 100644
index 00000000..beb1cfeb
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml
new file mode 100644
index 00000000..b5d8b18b
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [file]
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+Item {
+ id: window
+ width: menu.contentItem.width
+ height: menu.contentItem.height
+ visible: true
+
+// Indent it like this so that the indenting in the generated doc is normal.
+Menu {
+ id: menu
+ contentItem.parent: window
+
+ MenuItem {
+ text: qsTr("New...")
+ }
+ MenuItem {
+ text: qsTr("Open...")
+ }
+ MenuItem {
+ text: qsTr("Save")
+ }
+
+ MenuSeparator {
+ padding: 0
+ topPadding: 12
+ bottomPadding: 12
+ contentItem: Rectangle {
+ implicitWidth: 200
+ implicitHeight: 1
+ color: "#1E000000"
+ }
+ }
+
+ MenuItem {
+ text: qsTr("Exit")
+ }
+}
+}
+//! [file]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml
new file mode 100644
index 00000000..d41d3cf9
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [file]
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+Item {
+ id: window
+ width: menu.contentItem.width
+ height: menu.contentItem.height
+ visible: true
+
+// Indent it like this so that the indenting in the generated doc is normal.
+Menu {
+ id: menu
+ contentItem.parent: window
+
+ MenuItem {
+ text: qsTr("New...")
+ }
+ MenuItem {
+ text: qsTr("Open...")
+ }
+ MenuItem {
+ text: qsTr("Save")
+ }
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: qsTr("Exit")
+ }
+}
+}
+//! [file]
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
index 08b419d7..d98b70d1 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
@@ -471,6 +471,23 @@
\l {Customizing Button}{Button}.
+ \section2 Customizing MenuSeparator
+
+ MenuSeparator consists of two visual items: \l {Control::background}{background}
+ and \l {Control::contentItem}{content item}.
+
+ \image qtquickcontrols2-menuseparator-custom.png
+
+ \quotefromfile qtquickcontrols2-menuseparator-custom.qml
+ \skipto import QtQuick 2.6
+ \printuntil import QtQuick.Controls 2.1
+ \skipto Menu
+ \printto contentItem.parent: window
+ \skipline contentItem.parent: window
+ \printuntil text: qsTr("Exit")
+ \printuntil }
+ \printuntil }
+
\section2 Customizing PageIndicator
PageIndicator consists of a \l {Control::background}{background}, \l {Control::contentItem}{content item}, and \l {PageIndicator::delegate}{delegate}.
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc
index 2f35fa3e..c4ef1c76 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc
@@ -39,6 +39,16 @@
sections offer guidelines for choosing the appropriate type of separator,
depending on the use case.
+ \section1 MenuSeparator Control
+
+ \image qtquickcontrols2-menuseparator.png
+
+ \l MenuSeparator should be used to separate items (typically MenuItem
+ controls) in a Menu. Grouping related menu items together makes it easier
+ for the user to interact with the menu. For example, a typical desktop
+ user interface might have \c Undo and \c Redo items in one group, and
+ \c Cut, \c Copy and \c Paste in another.
+
\section1 ToolSeparator Control
\image qtquickcontrols2-toolseparator.png
diff --git a/src/imports/controls/material/MenuSeparator.qml b/src/imports/controls/material/MenuSeparator.qml
new file mode 100644
index 00000000..c6ba401f
--- /dev/null
+++ b/src/imports/controls/material/MenuSeparator.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ topPadding: 8
+ bottomPadding: 8
+
+ contentItem: Rectangle {
+ implicitWidth: 200
+ implicitHeight: 1
+ color: control.Material.dividerColor
+ }
+}
diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri
index d4ad1d8e..437edeee 100644
--- a/src/imports/controls/material/material.pri
+++ b/src/imports/controls/material/material.pri
@@ -32,6 +32,7 @@ QML_FILES += \
$$PWD/Label.qml \
$$PWD/Menu.qml \
$$PWD/MenuItem.qml \
+ $$PWD/MenuSeparator.qml \
$$PWD/Page.qml \
$$PWD/PageIndicator.qml \
$$PWD/Pane.qml \
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index e9108934..ee35d61a 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -141,6 +141,7 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickContainer,1>(uri, 2, 1, "Container");
qmlRegisterType(selector.select(QStringLiteral("Dialog.qml")), uri, 2, 1, "Dialog");
qmlRegisterType(selector.select(QStringLiteral("DialogButtonBox.qml")), uri, 2, 1, "DialogButtonBox");
+ qmlRegisterType(selector.select(QStringLiteral("MenuSeparator.qml")), uri, 2, 1, "MenuSeparator");
qmlRegisterType(selector.select(QStringLiteral("ToolSeparator.qml")), uri, 2, 1, "ToolSeparator");
}
diff --git a/src/imports/controls/universal/MenuSeparator.qml b/src/imports/controls/universal/MenuSeparator.qml
new file mode 100644
index 00000000..d62d2b6c
--- /dev/null
+++ b/src/imports/controls/universal/MenuSeparator.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ padding: 12
+ topPadding: 9
+ bottomPadding: 10
+
+ contentItem: Rectangle {
+ implicitWidth: 188
+ implicitHeight: 1
+ color: control.Universal.baseMediumLowColor
+ }
+
+ background: Rectangle {
+ color: control.Universal.altMediumLowColor
+ }
+}
diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri
index 2be05ac2..72edbc32 100644
--- a/src/imports/controls/universal/universal.pri
+++ b/src/imports/controls/universal/universal.pri
@@ -16,6 +16,7 @@ QML_FILES += \
$$PWD/Label.qml \
$$PWD/Menu.qml \
$$PWD/MenuItem.qml \
+ $$PWD/MenuSeparator.qml \
$$PWD/Page.qml \
$$PWD/PageIndicator.qml \
$$PWD/Pane.qml \
diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp
index c19491c2..d2591414 100644
--- a/src/imports/templates/qtquicktemplates2plugin.cpp
+++ b/src/imports/templates/qtquicktemplates2plugin.cpp
@@ -56,6 +56,7 @@
#include <QtQuickTemplates2/private/qquicklabel_p.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
+#include <QtQuickTemplates2/private/qquickmenuseparator_p.h>
#include <QtQuickTemplates2/private/qquickoverlay_p.h>
#include <QtQuickTemplates2/private/qquickpage_p.h>
#include <QtQuickTemplates2/private/qquickpageindicator_p.h>
@@ -181,6 +182,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickDialog>(uri, 2, 1, "Dialog");
qmlRegisterType<QQuickDialogButtonBox>(uri, 2, 1, "DialogButtonBox");
qmlRegisterType<QQuickDialogButtonBoxAttached>();
+ qmlRegisterType<QQuickMenuSeparator>(uri, 2, 1, "MenuSeparator");
qmlRegisterType<QQuickPopup, 1>(uri, 2, 1, "Popup");
qmlRegisterType<QQuickRangeSlider, 1>(uri, 2, 1, "RangeSlider");
qmlRegisterType<QQuickSlider, 1>(uri, 2, 1, "Slider");
diff --git a/src/quicktemplates2/qquickmenuseparator.cpp b/src/quicktemplates2/qquickmenuseparator.cpp
new file mode 100644
index 00000000..9aea6a91
--- /dev/null
+++ b/src/quicktemplates2/qquickmenuseparator.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickmenuseparator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuSeparator
+ \inherits Control
+ \instantiates QQuickMenuSeparator
+ \inqmlmodule QtQuick.Controls
+ \since 5.8
+ \ingroup qtquickcontrols2-separators
+ \brief Separates a group of items in a menu from adjacent items.
+
+ MenuSeparator is used to visually distinguish between groups of items in a
+ menu by separating them with a line.
+
+ \image qtquickcontrols2-menuseparator.png
+
+ \quotefromfile qtquickcontrols2-menuseparator-custom.qml
+ \skipto import QtQuick 2.6
+ \printuntil import QtQuick.Controls 2.1
+ \skipto Menu
+ \printto contentItem.parent: window
+ \skipline contentItem.parent: window
+ \printuntil text: qsTr("Exit")
+ \printuntil }
+ \printuntil }
+
+ \sa {Customizing MenuSeparator}, {Separator Controls}
+*/
+
+QQuickMenuSeparator::QQuickMenuSeparator(QQuickItem *parent) :
+ QQuickControl(parent)
+{
+}
+
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickMenuSeparator::accessibleRole() const
+{
+ return QAccessible::Separator;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickmenuseparator_p.h b/src/quicktemplates2/qquickmenuseparator_p.h
new file mode 100644
index 00000000..95a8f8fa
--- /dev/null
+++ b/src/quicktemplates2/qquickmenuseparator_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKMENUSEPARATOR_P_H
+#define QQUICKMENUSEPARATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickcontrol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuSeparator : public QQuickControl
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickMenuSeparator(QQuickItem *parent = nullptr);
+
+protected:
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
+private:
+ Q_DISABLE_COPY(QQuickMenuSeparator)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickMenuSeparator)
+
+#endif // QQUICKMENUSEPARATOR_P_H
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 20c76d8a..f5e95aea 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -30,6 +30,7 @@ HEADERS += \
$$PWD/qquickmenu_p.h \
$$PWD/qquickmenu_p_p.h \
$$PWD/qquickmenuitem_p.h \
+ $$PWD/qquickmenuseparator_p.h \
$$PWD/qquickoverlay_p.h \
$$PWD/qquickpage_p.h \
$$PWD/qquickpageindicator_p.h \
@@ -88,6 +89,7 @@ SOURCES += \
$$PWD/qquicklabel.cpp \
$$PWD/qquickmenu.cpp \
$$PWD/qquickmenuitem.cpp \
+ $$PWD/qquickmenuseparator.cpp \
$$PWD/qquickoverlay.cpp \
$$PWD/qquickpage.cpp \
$$PWD/qquickpageindicator.cpp \
diff --git a/tests/auto/menu/data/menuSeparator.qml b/tests/auto/menu/data/menuSeparator.qml
new file mode 100644
index 00000000..913e8e98
--- /dev/null
+++ b/tests/auto/menu/data/menuSeparator.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+
+ MenuItem {
+ id: newMenuItem
+ text: qsTr("New")
+ }
+
+ MenuSeparator {
+ id: menuSeparator
+ }
+
+ MenuItem {
+ id: saveMenuItem
+ text: qsTr("Save")
+ }
+
+ Menu {
+ id: menu
+
+ Component.onCompleted: {
+ addItem(newMenuItem)
+ addItem(menuSeparator)
+ addItem(saveMenuItem)
+ }
+ }
+}
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp
index dc9c296a..28882f04 100644
--- a/tests/auto/menu/tst_menu.cpp
+++ b/tests/auto/menu/tst_menu.cpp
@@ -50,6 +50,7 @@
#include <QtQuickTemplates2/private/qquickbutton_p.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
+#include <QtQuickTemplates2/private/qquickmenuseparator_p.h>
using namespace QQuickVisualTestUtil;
@@ -65,6 +66,7 @@ private slots:
void contextMenuKeyboard();
void menuButton();
void addItem();
+ void menuSeparator();
};
void tst_menu::defaults()
@@ -272,6 +274,49 @@ void tst_menu::addItem()
QTRY_VERIFY(!menu->isVisible());
}
+void tst_menu::menuSeparator()
+{
+ QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml"));
+ QQuickApplicationWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
+ QVERIFY(menu);
+ menu->open();
+ QVERIFY(menu->isVisible());
+
+ QQuickMenuItem *newMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(0));
+ QVERIFY(newMenuItem);
+ QCOMPARE(newMenuItem->text(), QStringLiteral("New"));
+
+ QQuickMenuSeparator *menuSeparator = qobject_cast<QQuickMenuSeparator*>(menu->itemAt(1));
+ QVERIFY(menuSeparator);
+
+ QQuickMenuItem *saveMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(2));
+ QVERIFY(saveMenuItem);
+ QCOMPARE(saveMenuItem->text(), QStringLiteral("Save"));
+ QTRY_VERIFY(!QQuickItemPrivate::get(saveMenuItem)->culled); // QTBUG-53262
+
+ // Clicking on items should still close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ newMenuItem->mapToScene(QPointF(newMenuItem->width() / 2, newMenuItem->height() / 2)).toPoint());
+ QTRY_VERIFY(!menu->isVisible());
+
+ menu->open();
+ QVERIFY(menu->isVisible());
+
+ // Clicking on a separator shouldn't close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ menuSeparator->mapToScene(QPointF(menuSeparator->width() / 2, menuSeparator->height() / 2)).toPoint());
+ QVERIFY(menu->isVisible());
+
+ // Clicking on items should still close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint());
+ QTRY_VERIFY(!menu->isVisible());
+}
+
QTEST_MAIN(tst_menu)
#include "tst_menu.moc"
diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml
index b037bc3d..dd1a1de8 100644
--- a/tests/manual/testbench/main.qml
+++ b/tests/manual/testbench/main.qml
@@ -97,6 +97,12 @@ ApplicationWindow {
text: "Option 3"
checkable: true
}
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: "Option A"
+ }
}
}
ToolButton {