aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-08-11 23:23:47 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-08-12 10:51:43 +0000
commitbd0f52bc1675f530b6ac5c0611ab12d7581265e1 (patch)
tree3b3098b4e936b833f9757d82f5fb52722006ccc6 /src/imports
parent9a6bdf52a387b9266f78f2576dfee9bbf7285730 (diff)
Platform: add MenuSeparator for convenience and consistency
Change-Id: I0c0aae219c81b9248a5a8a0fd0e78521cbe86360 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/platform/platform.pri2
-rw-r--r--src/imports/platform/qquickplatformmenu.cpp2
-rw-r--r--src/imports/platform/qquickplatformmenuitem.cpp2
-rw-r--r--src/imports/platform/qquickplatformmenuseparator.cpp65
-rw-r--r--src/imports/platform/qquickplatformmenuseparator_p.h67
-rw-r--r--src/imports/platform/qtlabsplatformplugin.cpp2
6 files changed, 139 insertions, 1 deletions
diff --git a/src/imports/platform/platform.pri b/src/imports/platform/platform.pri
index 14b39246..f6e0b99f 100644
--- a/src/imports/platform/platform.pri
+++ b/src/imports/platform/platform.pri
@@ -9,6 +9,7 @@ HEADERS += \
$$PWD/qquickplatformmenubar_p.h \
$$PWD/qquickplatformmenuitem_p.h \
$$PWD/qquickplatformmenuitemgroup_p.h \
+ $$PWD/qquickplatformmenuseparator_p.h \
$$PWD/qquickplatformmessagedialog_p.h \
$$PWD/qquickplatformsystemtrayicon_p.h
@@ -23,5 +24,6 @@ SOURCES += \
$$PWD/qquickplatformmenubar.cpp \
$$PWD/qquickplatformmenuitem.cpp \
$$PWD/qquickplatformmenuitemgroup.cpp \
+ $$PWD/qquickplatformmenuseparator.cpp \
$$PWD/qquickplatformmessagedialog.cpp \
$$PWD/qquickplatformsystemtrayicon.cpp
diff --git a/src/imports/platform/qquickplatformmenu.cpp b/src/imports/platform/qquickplatformmenu.cpp
index 4d381dbf..06ac88af 100644
--- a/src/imports/platform/qquickplatformmenu.cpp
+++ b/src/imports/platform/qquickplatformmenu.cpp
@@ -112,7 +112,7 @@ QT_BEGIN_NAMESPACE
\labs
- \sa MenuItem, MenuBar
+ \sa MenuItem, MenuSeparator, MenuBar
*/
/*!
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
index e5da667a..3b5d0f6b 100644
--- a/src/imports/platform/qquickplatformmenuitem.cpp
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -315,6 +315,8 @@ void QQuickPlatformMenuItem::setVisible(bool visible)
This property holds whether the item is a separator line. The default value
is \c false.
+
+ \sa MenuSeparator
*/
bool QQuickPlatformMenuItem::isSeparator() const
{
diff --git a/src/imports/platform/qquickplatformmenuseparator.cpp b/src/imports/platform/qquickplatformmenuseparator.cpp
new file mode 100644
index 00000000..908ea075
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuseparator.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform 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 "qquickplatformmenuseparator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuSeparator
+ \inherits MenuItem
+ \instantiates QQuickPlatformMenuSeparator
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native menu separator.
+
+ The MenuSeparator type is provided for convenience. It is a MenuItem
+ that has the \l {MenuItem::}{separator} property set to \c true by default.
+
+ \image qtlabsplatform-menubar.png
+
+ \labs
+
+ \sa Menu, MenuItem
+*/
+
+QQuickPlatformMenuSeparator::QQuickPlatformMenuSeparator(QObject *parent)
+ : QQuickPlatformMenuItem(parent)
+{
+ setSeparator(true);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenuseparator_p.h b/src/imports/platform/qquickplatformmenuseparator_p.h
new file mode 100644
index 00000000..ce5ed391
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuseparator_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform 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 QQUICKPLATFORMMENUSEPARATOR_P_H
+#define QQUICKPLATFORMMENUSEPARATOR_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 "qquickplatformmenuitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformMenuSeparator : public QQuickPlatformMenuItem
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickPlatformMenuSeparator(QObject *parent = nullptr);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenuSeparator)
+
+#endif // QQUICKPLATFORMMENUSEPARATOR_P_H
diff --git a/src/imports/platform/qtlabsplatformplugin.cpp b/src/imports/platform/qtlabsplatformplugin.cpp
index a9364bde..5e139268 100644
--- a/src/imports/platform/qtlabsplatformplugin.cpp
+++ b/src/imports/platform/qtlabsplatformplugin.cpp
@@ -48,6 +48,7 @@
#include "qquickplatformmenubar_p.h"
#include "qquickplatformmenuitem_p.h"
#include "qquickplatformmenuitemgroup_p.h"
+#include "qquickplatformmenuseparator_p.h"
#include "qquickplatformsystemtrayicon_p.h"
@@ -88,6 +89,7 @@ void QtLabsPlatformPlugin::registerTypes(const char *uri)
qmlRegisterType<QQuickPlatformMenuBar>(uri, 1, 0, "MenuBar");
qmlRegisterType<QQuickPlatformMenuItem>(uri, 1, 0, "MenuItem");
qmlRegisterType<QQuickPlatformMenuItemGroup>(uri, 1, 0, "MenuItemGroup");
+ qmlRegisterType<QQuickPlatformMenuSeparator>(uri, 1, 0, "MenuSeparator");
qmlRegisterType<QQuickPlatformSystemTrayIcon>(uri, 1, 0, "SystemTrayIcon");
}