diff options
-rw-r--r-- | examples/quickcontrols2/texteditor/qml/texteditor.qml | 4 | ||||
-rw-r--r-- | src/imports/platform/platform.pri | 2 | ||||
-rw-r--r-- | src/imports/platform/qquickplatformmenu.cpp | 2 | ||||
-rw-r--r-- | src/imports/platform/qquickplatformmenuitem.cpp | 2 | ||||
-rw-r--r-- | src/imports/platform/qquickplatformmenuseparator.cpp | 65 | ||||
-rw-r--r-- | src/imports/platform/qquickplatformmenuseparator_p.h | 67 | ||||
-rw-r--r-- | src/imports/platform/qtlabsplatformplugin.cpp | 2 | ||||
-rw-r--r-- | tests/auto/platform/data/tst_menuseparator.qml | 64 |
8 files changed, 204 insertions, 4 deletions
diff --git a/examples/quickcontrols2/texteditor/qml/texteditor.qml b/examples/quickcontrols2/texteditor/qml/texteditor.qml index 21a187ba..e2c8ad59 100644 --- a/examples/quickcontrols2/texteditor/qml/texteditor.qml +++ b/examples/quickcontrols2/texteditor/qml/texteditor.qml @@ -422,9 +422,7 @@ ApplicationWindow { onTriggered: textArea.paste() } - MenuItem { - separator: true - } + MenuSeparator {} MenuItem { text: qsTr("Font...") 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"); } diff --git a/tests/auto/platform/data/tst_menuseparator.qml b/tests/auto/platform/data/tst_menuseparator.qml new file mode 100644 index 00000000..b04a8f31 --- /dev/null +++ b/tests/auto/platform/data/tst_menuseparator.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "MenuSeparator" + + Component { + id: menuSeparator + MenuSeparator { } + } + + function test_separator() { + var separator = menuSeparator.createObject(testCase) + verify(separator) + + compare(separator.separator, true) + + separator.destroy() + } +} |