diff options
author | Mitch Curtis <[email protected]> | 2021-08-12 14:39:51 +0200 |
---|---|---|
committer | Mitch Curtis <[email protected]> | 2021-08-16 12:52:59 +0200 |
commit | 809339d1484cf556512534367b8170bc26baf072 (patch) | |
tree | 12871313b658f36d058b5ef25af1e247e9c46ce9 /src/labs | |
parent | b01b4f00eae8022c6a97d90f54dac395144ae095 (diff) |
Now that qtquickcontrols2 has been merged into qtdeclarative,
we should make it obvious that this repo should no longer be
used, by preventing it from being built.
Task-number: QTBUG-95173
Pick-to: 6.2
Change-Id: I95bd6a214f3d75a865ab163ee0a1f9ffbeb7a051
Reviewed-by: Alexandru Croitor <[email protected]>
Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'src/labs')
68 files changed, 0 insertions, 9423 deletions
diff --git a/src/labs/CMakeLists.txt b/src/labs/CMakeLists.txt deleted file mode 100644 index 72b278fe..00000000 --- a/src/labs/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(platform) - diff --git a/src/labs/platform/CMakeLists.txt b/src/labs/platform/CMakeLists.txt deleted file mode 100644 index 7fc542d3..00000000 --- a/src/labs/platform/CMakeLists.txt +++ /dev/null @@ -1,89 +0,0 @@ -##################################################################### -## qtlabsplatformplugin Plugin: -##################################################################### - -qt_internal_add_qml_module(qtlabsplatformplugin - URI "Qt.labs.platform" - VERSION "1.1" - CLASS_NAME QtLabsPlatformPlugin - PLUGIN_TARGET qtlabsplatformplugin - NO_PLUGIN_OPTIONAL - NO_GENERATE_PLUGIN_SOURCE - SOURCES - qquickplatformcolordialog.cpp qquickplatformcolordialog_p.h - qquickplatformdialog.cpp qquickplatformdialog_p.h - qquickplatformfiledialog.cpp qquickplatformfiledialog_p.h - qquickplatformfolderdialog.cpp qquickplatformfolderdialog_p.h - qquickplatformfontdialog.cpp qquickplatformfontdialog_p.h - qquickplatformicon.cpp qquickplatformicon_p.h - qquickplatformiconloader.cpp qquickplatformiconloader_p.h - qquickplatformmenu.cpp qquickplatformmenu_p.h - qquickplatformmenubar.cpp qquickplatformmenubar_p.h - qquickplatformmenuitem.cpp qquickplatformmenuitem_p.h - qquickplatformmenuitemgroup.cpp qquickplatformmenuitemgroup_p.h - qquickplatformmenuseparator.cpp qquickplatformmenuseparator_p.h - qquickplatformmessagedialog.cpp qquickplatformmessagedialog_p.h - qquickplatformstandardpaths.cpp qquickplatformstandardpaths_p.h - qtlabsplatformplugin.cpp - DEFINES - QT_NO_CAST_FROM_ASCII - QT_NO_CAST_TO_ASCII - LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - Qt::QmlPrivate - Qt::QuickPrivate - Qt::QuickTemplates2Private -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets - SOURCES - widgets/qwidgetplatform_p.h - LIBRARIES - Qt::Widgets -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_systemtrayicon AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformsystemtrayicon.cpp widgets/qwidgetplatformsystemtrayicon_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND (QT_FEATURE_colordialog OR QT_FEATURE_filedialog OR QT_FEATURE_fontdialog OR QT_FEATURE_messagebox) - SOURCES - widgets/qwidgetplatformdialog.cpp widgets/qwidgetplatformdialog_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_colordialog AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformcolordialog.cpp widgets/qwidgetplatformcolordialog_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_filedialog AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformfiledialog.cpp widgets/qwidgetplatformfiledialog_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_fontdialog AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformfontdialog.cpp widgets/qwidgetplatformfontdialog_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_menu AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformmenu.cpp widgets/qwidgetplatformmenu_p.h - widgets/qwidgetplatformmenuitem.cpp widgets/qwidgetplatformmenuitem_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION TARGET Qt::Widgets AND QT_FEATURE_messagebox AND TARGET Qt::Widgets # special case - SOURCES - widgets/qwidgetplatformmessagedialog.cpp widgets/qwidgetplatformmessagedialog_p.h -) - -qt_internal_extend_target(qtlabsplatformplugin CONDITION QT_FEATURE_systemtrayicon - SOURCES - qquickplatformsystemtrayicon.cpp qquickplatformsystemtrayicon_p.h -) - -qt_internal_add_docs(qtlabsplatformplugin - doc/qtlabsplatform.qdocconf -) diff --git a/src/labs/platform/doc/images/qtlabsplatform-colordialog-gtk.png b/src/labs/platform/doc/images/qtlabsplatform-colordialog-gtk.png Binary files differdeleted file mode 100644 index 12197f7f..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-colordialog-gtk.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-filedialog-gtk.png b/src/labs/platform/doc/images/qtlabsplatform-filedialog-gtk.png Binary files differdeleted file mode 100644 index 9360d747..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-filedialog-gtk.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-folderdialog-gtk.png b/src/labs/platform/doc/images/qtlabsplatform-folderdialog-gtk.png Binary files differdeleted file mode 100644 index 45f0585c..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-folderdialog-gtk.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-fontdialog-gtk.png b/src/labs/platform/doc/images/qtlabsplatform-fontdialog-gtk.png Binary files differdeleted file mode 100644 index 0c6217bd..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-fontdialog-gtk.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-menu.png b/src/labs/platform/doc/images/qtlabsplatform-menu.png Binary files differdeleted file mode 100644 index 7945b45f..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-menu.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-menubar.png b/src/labs/platform/doc/images/qtlabsplatform-menubar.png Binary files differdeleted file mode 100644 index 7faa8141..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-menubar.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-messagedialog-android.png b/src/labs/platform/doc/images/qtlabsplatform-messagedialog-android.png Binary files differdeleted file mode 100644 index 3986694f..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-messagedialog-android.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png b/src/labs/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png Binary files differdeleted file mode 100644 index b2d3cd37..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png b/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png Binary files differdeleted file mode 100644 index 670df8ed..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-message.png b/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-message.png Binary files differdeleted file mode 100644 index beaeed92..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon-message.png +++ /dev/null diff --git a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon.png b/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon.png Binary files differdeleted file mode 100644 index 2f7a851c..00000000 --- a/src/labs/platform/doc/images/qtlabsplatform-systemtrayicon.png +++ /dev/null diff --git a/src/labs/platform/doc/qtlabsplatform.qdocconf b/src/labs/platform/doc/qtlabsplatform.qdocconf deleted file mode 100644 index 54ed8204..00000000 --- a/src/labs/platform/doc/qtlabsplatform.qdocconf +++ /dev/null @@ -1,41 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) -include($QT_INSTALL_DOCS/config/exampleurl-qtquickcontrols2.qdocconf) - -project = QtLabsPlatform -description = Qt Labs Platform Reference Documentation -version = $QT_VERSION - -qhp.projects = QtLabsPlatform - -qhp.QtLabsPlatform.file = qtlabsplatform.qhp -qhp.QtLabsPlatform.namespace = org.qt-project.qtlabsplatform.$QT_VERSION_TAG -qhp.QtLabsPlatform.virtualFolder = qtlabsplatform -qhp.QtLabsPlatform.indexTitle = Qt Labs Platform -qhp.QtLabsPlatform.indexRoot = - -qhp.QtLabsPlatform.filterAttributes = qtlabsplatform $QT_VERSION qtrefdoc -qhp.QtLabsPlatform.customFilters.Qt.name = QtLabsPlatform $QT_VERSION -qhp.QtLabsPlatform.customFilters.Qt.filterAttributes = qtlabsplatform $QT_VERSION - -qhp.QtLabsPlatform.subprojects = qmltypes -qhp.QtLabsPlatform.subprojects.qmltypes.title = QML Types -qhp.QtLabsPlatform.subprojects.qmltypes.indexTitle = Qt Labs Platform QML Types -qhp.QtLabsPlatform.subprojects.qmltypes.selectors = qmlclass -qhp.QtLabsPlatform.subprojects.qmltypes.sortPages = true - -depends = qtcore qtgui qtdoc qtqml qtqmlmodels qtquick qtquickcontrols qtwidgets - -# This module has no documented C++ types, clear the module header -moduleheader = - -headerdirs += ../ -sourcedirs += ../ - -imagedirs += images - -navigation.landingpage = "Qt Labs Platform" -navigation.qmltypespage = "Qt Labs Platform QML Types" - -tagfile = qtlabsplatform.tags - -macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}" diff --git a/src/labs/platform/doc/src/includes/widgets.qdocinc b/src/labs/platform/doc/src/includes/widgets.qdocinc deleted file mode 100644 index 44ebba6d..00000000 --- a/src/labs/platform/doc/src/includes/widgets.qdocinc +++ /dev/null @@ -1,28 +0,0 @@ -//! [1] -The Qt Labs Platform module uses Qt Widgets as a fallback on platforms that -do not have a native implementation available. Therefore, applications that -use types from the Qt Labs Platform module should link to QtWidgets and use -\l QApplication instead of \l QGuiApplication. - -To link against the QtWidgets library, add the following to your qmake project -file: - -\code -QT += widgets -\endcode - -Create an instance of \l QApplication in \c main(): - -\code -#include <QApplication> -#include <QQmlApplicationEngine> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - return app.exec(); -} -\endcode -//! [1] diff --git a/src/labs/platform/doc/src/qt6-changes.qdoc b/src/labs/platform/doc/src/qt6-changes.qdoc deleted file mode 100644 index de1c7a29..00000000 --- a/src/labs/platform/doc/src/qt6-changes.qdoc +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qtquicklabsplatform-changes-qt6.html - \title Changes to Qt Quick Labs Platform - \ingroup changes-qt-5-to-6 - \brief Migrate Qt Quick Labs Platform to Qt 6. - - Qt 6 is a result of the conscious effort to make the framework more - efficient and easy to use. - - We try to maintain compatibility for all the public APIs in each release. - Some changes were inevitable in an effort to make Qt a better framework. - - In this topic we summarize those changes in Qt Quick Labs Platform, and - provide guidance to handle them. - - \section1 The Menu type - - The deprecated \c iconName and \c iconSource properties were removed. Use - the \l {Menu::}{icon} property instead. - - \section1 The MenuItem type - - The deprecated \c iconName and \c iconSource properties were removed. Use - the \l {MenuItem::}{icon} property instead. - - \section1 The SystemTrayIcon type - - The deprecated \c iconName and \c iconSource properties were removed. Use - the \l {SystemTrayIcon::}{icon} property instead. -*/ diff --git a/src/labs/platform/doc/src/qtlabsplatform-index.qdoc b/src/labs/platform/doc/src/qtlabsplatform-index.qdoc deleted file mode 100644 index c6eff0ba..00000000 --- a/src/labs/platform/doc/src/qtlabsplatform-index.qdoc +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qtlabsplatform-index.html - \title Qt Labs Platform - - \brief The experimental Qt Labs Platform module provides QML types for - native platform extensions. - - The experimental Qt Labs Platform module provides QML types for native - platform extensions. The module was introduced in Qt 5.8. - - \section1 QML Types - - \generatelist {qmltypesbymodule Qt.labs.platform} - - \labs - - \section1 Module Evolution - \l{Changes to Qt Quick Labs Platform} lists important changes in the - module API and functionality that were done for the Qt 6 series of Qt. - - \section1 Related Information - - \list - \li \l{Qt Quick} - \li \l{Qt Quick Controls} - \endlist -*/ diff --git a/src/labs/platform/doc/src/qtlabsplatform-qmltypes.qdoc b/src/labs/platform/doc/src/qtlabsplatform-qmltypes.qdoc deleted file mode 100644 index 51b7601a..00000000 --- a/src/labs/platform/doc/src/qtlabsplatform-qmltypes.qdoc +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule Qt.labs.platform 1.1 - \title Qt Labs Platform QML Types - \ingroup qmlmodules - \brief Provides QML types for native platform extensions. - - The experimental \l{Qt Labs Platform} module provides QML types for native - platform extensions. These QML types work in conjunction with \l{Qt Quick} - and \l{Qt Quick Controls}. - - The QML types can be imported into your application using the - following import statement in your .qml file: - - \qml - import Qt.labs.platform - \endqml - - \section1 QML Types - - \generatelist {qmltypesbymodule Qt.labs.platform} - - \labs - - \section1 Related Information - - \list - \li \l {Qt Quick Controls QML Types} - \endlist - - \noautolist -*/ diff --git a/src/labs/platform/platform.pri b/src/labs/platform/platform.pri deleted file mode 100644 index ec6e8616..00000000 --- a/src/labs/platform/platform.pri +++ /dev/null @@ -1,39 +0,0 @@ -HEADERS += \ - $$PWD/qquickplatformcolordialog_p.h \ - $$PWD/qquickplatformdialog_p.h \ - $$PWD/qquickplatformfiledialog_p.h \ - $$PWD/qquickplatformfolderdialog_p.h \ - $$PWD/qquickplatformfontdialog_p.h \ - $$PWD/qquickplatformicon_p.h \ - $$PWD/qquickplatformiconloader_p.h \ - $$PWD/qquickplatformmenu_p.h \ - $$PWD/qquickplatformmenubar_p.h \ - $$PWD/qquickplatformmenuitem_p.h \ - $$PWD/qquickplatformmenuitemgroup_p.h \ - $$PWD/qquickplatformmenuseparator_p.h \ - $$PWD/qquickplatformmessagedialog_p.h \ - $$PWD/qquickplatformstandardpaths_p.h - -SOURCES += \ - $$PWD/qquickplatformcolordialog.cpp \ - $$PWD/qquickplatformdialog.cpp \ - $$PWD/qquickplatformfiledialog.cpp \ - $$PWD/qquickplatformfolderdialog.cpp \ - $$PWD/qquickplatformfontdialog.cpp \ - $$PWD/qquickplatformicon.cpp \ - $$PWD/qquickplatformiconloader.cpp \ - $$PWD/qquickplatformmenu.cpp \ - $$PWD/qquickplatformmenubar.cpp \ - $$PWD/qquickplatformmenuitem.cpp \ - $$PWD/qquickplatformmenuitemgroup.cpp \ - $$PWD/qquickplatformmenuseparator.cpp \ - $$PWD/qquickplatformmessagedialog.cpp \ - $$PWD/qquickplatformstandardpaths.cpp - - -qtConfig(systemtrayicon) { - HEADERS += \ - $$PWD/qquickplatformsystemtrayicon_p.h - SOURCES += \ - $$PWD/qquickplatformsystemtrayicon.cpp -} diff --git a/src/labs/platform/qquickplatformcolordialog.cpp b/src/labs/platform/qquickplatformcolordialog.cpp deleted file mode 100644 index 04a5e079..00000000 --- a/src/labs/platform/qquickplatformcolordialog.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformcolordialog_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ColorDialog - \inherits Dialog -//! \instantiates QQuickPlatformColorDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native color dialog. - - The ColorDialog type provides a QML API for native platform color dialogs. - - \image qtlabsplatform-colordialog-gtk.png - - To show a color dialog, construct an instance of ColorDialog, set the - desired properties, and call \l {Dialog::}{open()}. The \l currentColor - property can be used to determine the currently selected color in the - dialog. The \l color property is updated only after the final selection - has been made by accepting the dialog. - - \code - MenuItem { - text: "Color" - onTriggered: colorDialog.open() - } - - ColorDialog { - id: colorDialog - currentColor: document.color - } - - MyDocument { - id: document - color: colorDialog.color - } - \endcode - - \section2 Availability - - A native platform color dialog is currently available on the following platforms: - - \list - \li macOS - \li Linux (when running with the GTK+ platform theme) - \endlist - - \input includes/widgets.qdocinc 1 - - \labs -*/ - -QQuickPlatformColorDialog::QQuickPlatformColorDialog(QObject *parent) - : QQuickPlatformDialog(QPlatformTheme::ColorDialog, parent), - m_options(QColorDialogOptions::create()) -{ -} - -/*! - \qmlproperty color Qt.labs.platform::ColorDialog::color - - This property holds the final accepted color. - - Unlike the \l currentColor property, the \c color property is not updated - while the user is selecting colors in the dialog, but only after the final - selection has been made. That is, when the user has clicked \uicontrol OK - to accept a color. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentColor, {Dialog::}{accepted()} -*/ -QColor QQuickPlatformColorDialog::color() const -{ - return m_color; -} - -void QQuickPlatformColorDialog::setColor(const QColor &color) -{ - if (m_color == color) - return; - - m_color = color; - setCurrentColor(color); - emit colorChanged(); -} - -/*! - \qmlproperty color Qt.labs.platform::ColorDialog::currentColor - - This property holds the currently selected color in the dialog. - - Unlike the \l color property, the \c currentColor property is updated - while the user is selecting colors in the dialog, even before the final - selection has been made. - - \sa color -*/ -QColor QQuickPlatformColorDialog::currentColor() const -{ - if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(handle())) - return colorDialog->currentColor(); - return m_currentColor; -} - -void QQuickPlatformColorDialog::setCurrentColor(const QColor &color) -{ - if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(handle())) - colorDialog->setCurrentColor(color); - m_currentColor = color; -} - -/*! - \qmlproperty flags Qt.labs.platform::ColorDialog::options - - This property holds the various options that affect the look and feel of the dialog. - - By default, all options are disabled. - - Options should be set before showing the dialog. Setting them while the dialog is - visible is not guaranteed to have an immediate effect on the dialog (depending on - the option and on the platform). - - Available options: - \value ColorDialog.ShowAlphaChannel Allow the user to select the alpha component of a color. - \value ColorDialog.NoButtons Don't display \uicontrol OK and \uicontrol Cancel buttons (useful for "live dialogs"). -*/ -QColorDialogOptions::ColorDialogOptions QQuickPlatformColorDialog::options() const -{ - return m_options->options(); -} - -void QQuickPlatformColorDialog::setOptions(QColorDialogOptions::ColorDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -bool QQuickPlatformColorDialog::useNativeDialog() const -{ - return QQuickPlatformDialog::useNativeDialog() - && !m_options->testOption(QColorDialogOptions::DontUseNativeDialog); -} - -void QQuickPlatformColorDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(dialog)) { - connect(colorDialog, &QPlatformColorDialogHelper::currentColorChanged, this, &QQuickPlatformColorDialog::currentColorChanged); - colorDialog->setOptions(m_options); - colorDialog->setCurrentColor(m_currentColor); - } -} - -void QQuickPlatformColorDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(dialog)) - colorDialog->setOptions(m_options); -} - -void QQuickPlatformColorDialog::accept() -{ - setColor(currentColor()); - QQuickPlatformDialog::accept(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformcolordialog_p.h b/src/labs/platform/qquickplatformcolordialog_p.h deleted file mode 100644 index 1df047d9..00000000 --- a/src/labs/platform/qquickplatformcolordialog_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMCOLORDIALOG_P_H -#define QQUICKPLATFORMCOLORDIALOG_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 "qquickplatformdialog_p.h" -#include <QtGui/qcolor.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformColorDialog : public QQuickPlatformDialog -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) - Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged FINAL) - Q_PROPERTY(QColorDialogOptions::ColorDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL) - Q_FLAGS(QColorDialogOptions::ColorDialogOptions) - -public: - explicit QQuickPlatformColorDialog(QObject *parent = nullptr); - - QColor color() const; - void setColor(const QColor &color); - - QColor currentColor() const; - void setCurrentColor(const QColor &color); - - QColorDialogOptions::ColorDialogOptions options() const; - void setOptions(QColorDialogOptions::ColorDialogOptions options); - -Q_SIGNALS: - void colorChanged(); - void currentColorChanged(); - void optionsChanged(); - -protected: - bool useNativeDialog() const override; - void onCreate(QPlatformDialogHelper *dialog) override; - void onShow(QPlatformDialogHelper *dialog) override; - void accept() override; - -private: - QColor m_color; - QColor m_currentColor; // TODO: QColorDialogOptions::initialColor - QSharedPointer<QColorDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformColorDialog) - -#endif // QQUICKPLATFORMCOLORDIALOG_P_H diff --git a/src/labs/platform/qquickplatformdialog.cpp b/src/labs/platform/qquickplatformdialog.cpp deleted file mode 100644 index 06a26237..00000000 --- a/src/labs/platform/qquickplatformdialog.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformdialog_p.h" - -#include <QtCore/qloggingcategory.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtQuick/qquickitem.h> -#include <QtQuick/qquickwindow.h> - -#include "widgets/qwidgetplatform_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Dialog - \inherits QtObject -//! \instantiates QQuickPlatformDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief The base class of native dialogs. - - The Dialog type provides common QML API for native platform dialogs. - - To show a native dialog, construct an instance of one of the concrete - Dialog implementations, set the desired properties, and call \l open(). - Dialog emits \l accepted() or \l rejected() when the user is done with - the dialog. - - \labs -*/ - -/*! - \qmlsignal void Qt.labs.platform::Dialog::accepted() - - This signal is emitted when the dialog has been accepted either - interactively or by calling \l accept(). - - \note This signal is \e not emitted when closing the dialog with \l close(). - - \sa rejected() -*/ - -/*! - \qmlsignal void Qt.labs.platform::Dialog::rejected() - - This signal is emitted when the dialog has been rejected either - interactively or by calling \l reject(). - - \note This signal is \e not emitted when closing the dialog with \l close(). - - \sa accepted() -*/ - -Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformDialogs) - -QQuickPlatformDialog::QQuickPlatformDialog(QPlatformTheme::DialogType type, QObject *parent) - : QObject(parent), - m_visible(false), - m_complete(false), - m_result(0), - m_parentWindow(nullptr), - m_flags(Qt::Dialog), - m_modality(Qt::WindowModal), - m_type(type), - m_handle(nullptr) -{ -} - -QQuickPlatformDialog::~QQuickPlatformDialog() -{ - destroy(); -} - -QPlatformDialogHelper *QQuickPlatformDialog::handle() const -{ - return m_handle; -} - -/*! - \qmldefault - \qmlproperty list<Object> Qt.labs.platform::Dialog::data - - This default property holds the list of all objects declared as children of - the dialog. -*/ -QQmlListProperty<QObject> QQuickPlatformDialog::data() -{ - return QQmlListProperty<QObject>(this, &m_data); -} - -/*! - \qmlproperty Window Qt.labs.platform::Dialog::parentWindow - - This property holds the parent window of the dialog. - - Unless explicitly set, the window is automatically resolved by iterating - the QML parent objects until a \l Window or an \l Item that has a window - is found. -*/ -QWindow *QQuickPlatformDialog::parentWindow() const -{ - return m_parentWindow; -} - -void QQuickPlatformDialog::setParentWindow(QWindow *window) -{ - if (m_parentWindow == window) - return; - - m_parentWindow = window; - emit parentWindowChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::Dialog::title - - This property holds the title of the dialog. -*/ -QString QQuickPlatformDialog::title() const -{ - return m_title; -} - -void QQuickPlatformDialog::setTitle(const QString &title) -{ - if (m_title == title) - return; - - m_title = title; - emit titleChanged(); -} - -/*! - \qmlproperty Qt::WindowFlags Qt.labs.platform::Dialog::flags - - This property holds the window flags of the dialog. The default value is \c Qt.Dialog. -*/ -Qt::WindowFlags QQuickPlatformDialog::flags() const -{ - return m_flags; -} - -void QQuickPlatformDialog::setFlags(Qt::WindowFlags flags) -{ - if (m_flags == flags) - return; - - m_flags = flags; - emit flagsChanged(); -} - -/*! - \qmlproperty Qt::WindowModality Qt.labs.platform::Dialog::modality - - This property holds the modality of the dialog. The default value is \c Qt.WindowModal. - - Available values: - \value Qt.NonModal The dialog is not modal and does not block input to other windows. - \value Qt.WindowModal The dialog is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. - \value Qt.ApplicationModal The dialog is modal to the application and blocks input to all windows. -*/ -Qt::WindowModality QQuickPlatformDialog::modality() const -{ - return m_modality; -} - -void QQuickPlatformDialog::setModality(Qt::WindowModality modality) -{ - if (m_modality == modality) - return; - - m_modality = modality; - emit modalityChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::Dialog::visible - - This property holds the visibility of the dialog. The default value is \c false. - - \sa open(), close() -*/ -bool QQuickPlatformDialog::isVisible() const -{ - return m_handle && m_visible; -} - -void QQuickPlatformDialog::setVisible(bool visible) -{ - if (visible) - open(); - else - close(); -} - -/*! - \qmlproperty int Qt.labs.platform::Dialog::result - - This property holds the result code. - - Standard result codes: - \value Dialog.Accepted - \value Dialog.Rejected - - \note MessageDialog sets the result to the value of the clicked standard - button instead of using the standard result codes. -*/ -int QQuickPlatformDialog::result() const -{ - return m_result; -} - -void QQuickPlatformDialog::setResult(int result) -{ - if (m_result == result) - return; - - m_result = result; - emit resultChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Dialog::open() - - Opens the dialog. - - \sa visible, close() -*/ -void QQuickPlatformDialog::open() -{ - if (m_visible || !create()) - return; - - onShow(m_handle); - m_visible = m_handle->show(m_flags, m_modality, m_parentWindow); - if (m_visible) - emit visibleChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Dialog::close() - - Closes the dialog. - - \sa visible, open() -*/ -void QQuickPlatformDialog::close() -{ - if (!m_handle || !m_visible) - return; - - onHide(m_handle); - m_handle->hide(); - m_visible = false; - emit visibleChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Dialog::accept() - - Closes the dialog and emits the \l accepted() signal. - - \sa reject() -*/ -void QQuickPlatformDialog::accept() -{ - done(Accepted); -} - -/*! - \qmlmethod void Qt.labs.platform::Dialog::reject() - - Closes the dialog and emits the \l rejected() signal. - - \sa accept() -*/ -void QQuickPlatformDialog::reject() -{ - done(Rejected); -} - -/*! - \qmlmethod void Qt.labs.platform::Dialog::done(int result) - - Closes the dialog and sets the \a result. - - \sa accept(), reject(), result -*/ -void QQuickPlatformDialog::done(int result) -{ - close(); - setResult(result); - - if (result == Accepted) - emit accepted(); - else if (result == Rejected) - emit rejected(); -} - -void QQuickPlatformDialog::classBegin() -{ -} - -void QQuickPlatformDialog::componentComplete() -{ - m_complete = true; - if (!m_parentWindow) - setParentWindow(findParentWindow()); -} - -static const char *qmlTypeName(const QObject *object) -{ - return object->metaObject()->className() + qstrlen("QQuickPlatform"); -} - -bool QQuickPlatformDialog::create() -{ - if (!m_handle) { - if (useNativeDialog()) - m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(m_type); - if (!m_handle) - m_handle = QWidgetPlatform::createDialog(m_type, this); - qCDebug(qtLabsPlatformDialogs) << qmlTypeName(this) << "->" << m_handle; - if (m_handle) { - onCreate(m_handle); - connect(m_handle, &QPlatformDialogHelper::accept, this, &QQuickPlatformDialog::accept); - connect(m_handle, &QPlatformDialogHelper::reject, this, &QQuickPlatformDialog::reject); - } - } - return m_handle; -} - -void QQuickPlatformDialog::destroy() -{ - delete m_handle; - m_handle = nullptr; -} - -bool QQuickPlatformDialog::useNativeDialog() const -{ - return !QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) - && QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(m_type); -} - -void QQuickPlatformDialog::onCreate(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -void QQuickPlatformDialog::onShow(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -void QQuickPlatformDialog::onHide(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -QWindow *QQuickPlatformDialog::findParentWindow() const -{ - QObject *obj = parent(); - while (obj) { - QWindow *window = qobject_cast<QWindow *>(obj); - if (window) - return window; - QQuickItem *item = qobject_cast<QQuickItem *>(obj); - if (item && item->window()) - return item->window(); - obj = obj->parent(); - } - return nullptr; -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformdialog_p.cpp" diff --git a/src/labs/platform/qquickplatformdialog_p.h b/src/labs/platform/qquickplatformdialog_p.h deleted file mode 100644 index 55a54937..00000000 --- a/src/labs/platform/qquickplatformdialog_p.h +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMDIALOG_P_H -#define QQUICKPLATFORMDIALOG_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 <QtCore/qobject.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQml/qqmllist.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QWindow; -class QPlatformDialogHelper; - -class QQuickPlatformDialog : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) - Q_PROPERTY(QWindow *parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL) - Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged FINAL) - Q_CLASSINFO("DefaultProperty", "data") - -public: - explicit QQuickPlatformDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr); - ~QQuickPlatformDialog(); - - QPlatformDialogHelper *handle() const; - - QQmlListProperty<QObject> data(); - - QWindow *parentWindow() const; - void setParentWindow(QWindow *window); - - QString title() const; - void setTitle(const QString &title); - - Qt::WindowFlags flags() const; - void setFlags(Qt::WindowFlags flags); - - Qt::WindowModality modality() const; - void setModality(Qt::WindowModality modality); - - bool isVisible() const; - void setVisible(bool visible); - - enum StandardCode { Rejected, Accepted }; - Q_ENUM(StandardCode) - - int result() const; - void setResult(int result); - -public Q_SLOTS: - void open(); - void close(); - virtual void accept(); - virtual void reject(); - virtual void done(int result); - -Q_SIGNALS: - void accepted(); - void rejected(); - void parentWindowChanged(); - void titleChanged(); - void flagsChanged(); - void modalityChanged(); - void visibleChanged(); - void resultChanged(); - -protected: - void classBegin() override; - void componentComplete() override; - - bool create(); - void destroy(); - - virtual bool useNativeDialog() const; - virtual void onCreate(QPlatformDialogHelper *dialog); - virtual void onShow(QPlatformDialogHelper *dialog); - virtual void onHide(QPlatformDialogHelper *dialog); - - QWindow *findParentWindow() const; - -private: - bool m_visible; - bool m_complete; - int m_result; - QWindow *m_parentWindow; - QString m_title; - Qt::WindowFlags m_flags; - Qt::WindowModality m_modality; - QPlatformTheme::DialogType m_type; - QList<QObject *> m_data; - QPlatformDialogHelper *m_handle; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformDialog) - -#endif // QQUICKPLATFORMDIALOG_P_H diff --git a/src/labs/platform/qquickplatformfiledialog.cpp b/src/labs/platform/qquickplatformfiledialog.cpp deleted file mode 100644 index 8bfcfc93..00000000 --- a/src/labs/platform/qquickplatformfiledialog.cpp +++ /dev/null @@ -1,662 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformfiledialog_p.h" - -#include <QtCore/qlist.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FileDialog - \inherits Dialog -//! \instantiates QQuickPlatformFileDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native file dialog. - - The FileDialog type provides a QML API for native platform file dialogs. - - \image qtlabsplatform-filedialog-gtk.png - - To show a file dialog, construct an instance of FileDialog, set the - desired properties, and call \l {Dialog::}{open()}. The \l currentFile - or \l currentFiles properties can be used to determine the currently - selected file(s) in the dialog. The \l file and \l files properties - are updated only after the final selection has been made by accepting - the dialog. - - \code - MenuItem { - text: "Open..." - onTriggered: fileDialog.open() - } - - FileDialog { - id: fileDialog - currentFile: document.source - folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) - } - - MyDocument { - id: document - source: fileDialog.file - } - \endcode - - \section2 Availability - - A native platform file dialog is currently available on the following platforms: - - \list - \li iOS - \li Linux (when running with the GTK+ platform theme) - \li macOS - \li Windows - \endlist - - \input includes/widgets.qdocinc 1 - - \labs - - \sa FolderDialog, StandardPaths -*/ - -QQuickPlatformFileDialog::QQuickPlatformFileDialog(QObject *parent) - : QQuickPlatformDialog(QPlatformTheme::FileDialog, parent), - m_fileMode(OpenFile), - m_options(QFileDialogOptions::create()), - m_selectedNameFilter(nullptr) -{ - m_options->setFileMode(QFileDialogOptions::ExistingFile); - m_options->setAcceptMode(QFileDialogOptions::AcceptOpen); -} - -/*! - \qmlproperty enumeration Qt.labs.platform::FileDialog::fileMode - - This property holds the mode of the dialog. - - Available values: - \value FileDialog.OpenFile The dialog is used to select an existing file (default). - \value FileDialog.OpenFiles The dialog is used to select multiple existing files. - \value FileDialog.SaveFile The dialog is used to select any file. The file does not have to exist. -*/ -QQuickPlatformFileDialog::FileMode QQuickPlatformFileDialog::fileMode() const -{ - return m_fileMode; -} - -void QQuickPlatformFileDialog::setFileMode(FileMode mode) -{ - if (mode == m_fileMode) - return; - - switch (mode) { - case OpenFile: - m_options->setFileMode(QFileDialogOptions::ExistingFile); - m_options->setAcceptMode(QFileDialogOptions::AcceptOpen); - break; - case OpenFiles: - m_options->setFileMode(QFileDialogOptions::ExistingFiles); - m_options->setAcceptMode(QFileDialogOptions::AcceptOpen); - break; - case SaveFile: - m_options->setFileMode(QFileDialogOptions::AnyFile); - m_options->setAcceptMode(QFileDialogOptions::AcceptSave); - break; - default: - break; - } - - m_fileMode = mode; - emit fileModeChanged(); -} - -/*! - \qmlproperty url Qt.labs.platform::FileDialog::file - - This property holds the final accepted file. - - Unlike the \l currentFile property, the \c file property is not updated - while the user is selecting files in the dialog, but only after the final - selection has been made. That is, when the user has clicked \uicontrol OK - to accept a file. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentFile, {Dialog::}{accepted()} -*/ -QUrl QQuickPlatformFileDialog::file() const -{ - return addDefaultSuffix(m_files.value(0)); -} - -void QQuickPlatformFileDialog::setFile(const QUrl &file) -{ - setFiles(QList<QUrl>() << file); -} - -/*! - \qmlproperty list<url> Qt.labs.platform::FileDialog::files - - This property holds the final accepted files. - - Unlike the \l currentFiles property, the \c files property is not updated - while the user is selecting files in the dialog, but only after the final - selection has been made. That is, when the user has clicked \uicontrol OK - to accept files. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentFiles, {Dialog::}{accepted()} -*/ -QList<QUrl> QQuickPlatformFileDialog::files() const -{ - return addDefaultSuffixes(m_files); -} - -void QQuickPlatformFileDialog::setFiles(const QList<QUrl> &files) -{ - if (m_files == files) - return; - - bool firstChanged = m_files.value(0) != files.value(0); - m_files = files; - if (firstChanged) - emit fileChanged(); - emit filesChanged(); -} - -/*! - \qmlproperty url Qt.labs.platform::FileDialog::currentFile - - This property holds the currently selected file in the dialog. - - Unlike the \l file property, the \c currentFile property is updated - while the user is selecting files in the dialog, even before the final - selection has been made. - - \sa file, currentFiles -*/ -QUrl QQuickPlatformFileDialog::currentFile() const -{ - return currentFiles().value(0); -} - -void QQuickPlatformFileDialog::setCurrentFile(const QUrl &file) -{ - setCurrentFiles(QList<QUrl>() << file); -} - -/*! - \qmlproperty list<url> Qt.labs.platform::FileDialog::currentFiles - - This property holds the currently selected files in the dialog. - - Unlike the \l files property, the \c currentFiles property is updated - while the user is selecting files in the dialog, even before the final - selection has been made. - - \sa files, currentFile -*/ -QList<QUrl> QQuickPlatformFileDialog::currentFiles() const -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - return fileDialog->selectedFiles(); - return m_options->initiallySelectedFiles(); -} - -void QQuickPlatformFileDialog::setCurrentFiles(const QList<QUrl> &files) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) { - for (const QUrl &file : files) - fileDialog->selectFile(file); - } - m_options->setInitiallySelectedFiles(files); -} - -/*! - \qmlproperty url Qt.labs.platform::FileDialog::folder - - This property holds the folder where files are selected. - For selecting a folder, use FolderDialog instead. - - \sa FolderDialog -*/ -QUrl QQuickPlatformFileDialog::folder() const -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - return fileDialog->directory(); - return m_options->initialDirectory(); -} - -void QQuickPlatformFileDialog::setFolder(const QUrl &folder) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - fileDialog->setDirectory(folder); - m_options->setInitialDirectory(folder); -} - -/*! - \qmlproperty flags Qt.labs.platform::FileDialog::options - - This property holds the various options that affect the look and feel of the dialog. - - By default, all options are disabled. - - Options should be set before showing the dialog. Setting them while the dialog is - visible is not guaranteed to have an immediate effect on the dialog (depending on - the option and on the platform). - - Available options: - \value FileDialog.DontResolveSymlinks Don't resolve symlinks in the file dialog. By default symlinks are resolved. - \value FileDialog.DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. By default confirmation is requested. - \value FileDialog.ReadOnly Indicates that the dialog doesn't allow creating directories. - \value FileDialog.HideNameFilterDetails Indicates if the file name filter details are hidden or not. -*/ -QFileDialogOptions::FileDialogOptions QQuickPlatformFileDialog::options() const -{ - return m_options->options(); -} - -void QQuickPlatformFileDialog::setOptions(QFileDialogOptions::FileDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -void QQuickPlatformFileDialog::resetOptions() -{ - setOptions({}); -} - -/*! - \qmlproperty list<string> Qt.labs.platform::FileDialog::nameFilters - - This property holds the filters that restrict the types of files that - can be selected. - - \code - FileDialog { - nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)"] - } - \endcode - - \note \b{*.*} is not a portable filter, because the historical assumption - that the file extension determines the file type is not consistent on every - operating system. It is possible to have a file with no dot in its name (for - example, \c Makefile). In a native Windows file dialog, \b{*.*} will match - such files, while in other types of file dialogs it may not. So it is better - to use \b{*} if you mean to select any file. - - \sa selectedNameFilter -*/ -QStringList QQuickPlatformFileDialog::nameFilters() const -{ - return m_options->nameFilters(); -} - -void QQuickPlatformFileDialog::setNameFilters(const QStringList &filters) -{ - if (filters == m_options->nameFilters()) - return; - - m_options->setNameFilters(filters); - if (m_selectedNameFilter) { - int index = m_selectedNameFilter->index(); - if (index < 0 || index >= filters.count()) - index = 0; - m_selectedNameFilter->update(filters.value(index)); - } - emit nameFiltersChanged(); -} - -void QQuickPlatformFileDialog::resetNameFilters() -{ - setNameFilters(QStringList()); -} - -/*! - \qmlproperty int Qt.labs.platform::FileDialog::selectedNameFilter.index - \qmlproperty string Qt.labs.platform::FileDialog::selectedNameFilter.name - \qmlproperty list<string> Qt.labs.platform::FileDialog::selectedNameFilter.extensions - - These properties hold the currently selected name filter. - - \table - \header - \li Name - \li Description - \row - \li \b index : int - \li This property determines which \l {nameFilters}{name filter} is selected. - The specified filter is selected when the dialog is opened. The value is - updated when the user selects another filter. - \row - \li [read-only] \b name : string - \li This property holds the name of the selected filter. In the - example below, the name of the first filter is \c {"Text files"} - and the second is \c {"HTML files"}. - \row - \li [read-only] \b extensions : list<string> - \li This property holds the list of extensions of the selected filter. - In the example below, the list of extensions of the first filter is - \c {["txt"]} and the second is \c {["html", "htm"]}. - \endtable - - \code - FileDialog { - id: fileDialog - selectedNameFilter.index: 1 - nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)"] - } - - MyDocument { - id: document - fileType: fileDialog.selectedNameFilter.extensions[0] - } - \endcode - - \sa nameFilters -*/ -QQuickPlatformFileNameFilter *QQuickPlatformFileDialog::selectedNameFilter() const -{ - if (!m_selectedNameFilter) { - QQuickPlatformFileDialog *that = const_cast<QQuickPlatformFileDialog *>(this); - m_selectedNameFilter = new QQuickPlatformFileNameFilter(that); - m_selectedNameFilter->setOptions(m_options); - } - return m_selectedNameFilter; -} - -/*! - \qmlproperty string Qt.labs.platform::FileDialog::defaultSuffix - - This property holds a suffix that is added to selected files that have - no suffix specified. The suffix is typically used to indicate the file - type (e.g. "txt" indicates a text file). - - If the first character is a dot ('.'), it is removed. -*/ -QString QQuickPlatformFileDialog::defaultSuffix() const -{ - return m_options->defaultSuffix(); -} - -void QQuickPlatformFileDialog::setDefaultSuffix(const QString &suffix) -{ - if (suffix == m_options->defaultSuffix()) - return; - - m_options->setDefaultSuffix(suffix); - emit defaultSuffixChanged(); -} - -void QQuickPlatformFileDialog::resetDefaultSuffix() -{ - setDefaultSuffix(QString()); -} - -/*! - \qmlproperty string Qt.labs.platform::FileDialog::acceptLabel - - This property holds the label text shown on the button that accepts the dialog. - - When set to an empty string, the default label of the underlying platform is used. - The default label is typically \uicontrol Open or \uicontrol Save depending on which - \l fileMode the dialog is used in. - - The default value is an empty string. - - \sa rejectLabel -*/ -QString QQuickPlatformFileDialog::acceptLabel() const -{ - return m_options->labelText(QFileDialogOptions::Accept); -} - -void QQuickPlatformFileDialog::setAcceptLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Accept)) - return; - - m_options->setLabelText(QFileDialogOptions::Accept, label); - emit acceptLabelChanged(); -} - -void QQuickPlatformFileDialog::resetAcceptLabel() -{ - setAcceptLabel(QString()); -} - -/*! - \qmlproperty string Qt.labs.platform::FileDialog::rejectLabel - - This property holds the label text shown on the button that rejects the dialog. - - When set to an empty string, the default label of the underlying platform is used. - The default label is typically \uicontrol Cancel. - - The default value is an empty string. - - \sa acceptLabel -*/ -QString QQuickPlatformFileDialog::rejectLabel() const -{ - return m_options->labelText(QFileDialogOptions::Reject); -} - -void QQuickPlatformFileDialog::setRejectLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Reject)) - return; - - m_options->setLabelText(QFileDialogOptions::Reject, label); - emit rejectLabelChanged(); -} - -void QQuickPlatformFileDialog::resetRejectLabel() -{ - setRejectLabel(QString()); -} - -bool QQuickPlatformFileDialog::useNativeDialog() const -{ - return QQuickPlatformDialog::useNativeDialog() - && !m_options->testOption(QFileDialogOptions::DontUseNativeDialog); -} - -void QQuickPlatformFileDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - // TODO: emit currentFileChanged only when the first entry in currentFiles changes - connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickPlatformFileDialog::currentFileChanged); - connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickPlatformFileDialog::currentFilesChanged); - connect(fileDialog, &QPlatformFileDialogHelper::directoryEntered, this, &QQuickPlatformFileDialog::folderChanged); - fileDialog->setOptions(m_options); - } -} - -void QQuickPlatformFileDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - fileDialog->setOptions(m_options); // setOptions only assigns a member and isn't virtual - if (m_firstShow && m_options->initialDirectory().isValid()) - fileDialog->setDirectory(m_options->initialDirectory()); - if (m_selectedNameFilter) { - const int index = m_selectedNameFilter->index(); - const QString filter = m_options->nameFilters().value(index); - m_options->setInitiallySelectedNameFilter(filter); - fileDialog->selectNameFilter(filter); - connect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickPlatformFileNameFilter::update); - } - } - if (m_firstShow) - m_firstShow = false; -} - -void QQuickPlatformFileDialog::onHide(QPlatformDialogHelper *dialog) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - if (m_selectedNameFilter) - disconnect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickPlatformFileNameFilter::update); - } -} - -void QQuickPlatformFileDialog::accept() -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - setFiles(fileDialog->selectedFiles()); - QQuickPlatformDialog::accept(); -} - -QUrl QQuickPlatformFileDialog::addDefaultSuffix(const QUrl &file) const -{ - QUrl url = file; - const QString path = url.path(); - const QString suffix = m_options->defaultSuffix(); - if (!suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) && path.lastIndexOf(QLatin1Char('.')) == -1) - url.setPath(path + QLatin1Char('.') + suffix); - return url; -} - -QList<QUrl> QQuickPlatformFileDialog::addDefaultSuffixes(const QList<QUrl> &files) const -{ - QList<QUrl> urls; - urls.reserve(files.size()); - for (const QUrl &file : files) - urls += addDefaultSuffix(file); - return urls; -} - -QQuickPlatformFileNameFilter::QQuickPlatformFileNameFilter(QObject *parent) - : QObject(parent), m_index(-1) -{ -} - -int QQuickPlatformFileNameFilter::index() const -{ - return m_index; -} - -void QQuickPlatformFileNameFilter::setIndex(int index) -{ - if (m_index == index) - return; - - m_index = index; - emit indexChanged(index); -} - -QString QQuickPlatformFileNameFilter::name() const -{ - return m_name; -} - -QStringList QQuickPlatformFileNameFilter::extensions() const -{ - return m_extensions; -} - -QSharedPointer<QFileDialogOptions> QQuickPlatformFileNameFilter::options() const -{ - return m_options; -} - -void QQuickPlatformFileNameFilter::setOptions(const QSharedPointer<QFileDialogOptions> &options) -{ - m_options = options; -} - -static QString extractName(const QString &filter) -{ - return filter.left(filter.indexOf(QLatin1Char('(')) - 1); -} - -static QString extractExtension(QStringView filter) -{ - return filter.mid(filter.indexOf(QLatin1Char('.')) + 1).toString(); -} - -static QStringList extractExtensions(QStringView filter) -{ - QStringList extensions; - const int from = filter.indexOf(QLatin1Char('(')); - const int to = filter.lastIndexOf(QLatin1Char(')')) - 1; - if (from >= 0 && from < to) { - const QStringView ref = filter.mid(from + 1, to - from); - const QList<QStringView> exts = ref.split(QLatin1Char(' '), Qt::SkipEmptyParts); - for (const QStringView &ref : exts) - extensions += extractExtension(ref); - } - - return extensions; -} - -void QQuickPlatformFileNameFilter::update(const QString &filter) -{ - const QStringList filters = nameFilters(); - - const int oldIndex = m_index; - const QString oldName = m_name; - const QStringList oldExtensions = m_extensions; - - m_index = filters.indexOf(filter); - m_name = extractName(filter); - m_extensions = extractExtensions(filter); - - if (oldIndex != m_index) - emit indexChanged(m_index); - if (oldName != m_name) - emit nameChanged(m_name); - if (oldExtensions != m_extensions) - emit extensionsChanged(m_extensions); -} - -QStringList QQuickPlatformFileNameFilter::nameFilters() const -{ - return m_options ? m_options->nameFilters() : QStringList(); -} - -QString QQuickPlatformFileNameFilter::nameFilter(int index) const -{ - return m_options ? m_options->nameFilters().value(index) : QString(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformfiledialog_p.h b/src/labs/platform/qquickplatformfiledialog_p.h deleted file mode 100644 index b867f3c8..00000000 --- a/src/labs/platform/qquickplatformfiledialog_p.h +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMFILEDIALOG_P_H -#define QQUICKPLATFORMFILEDIALOG_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 "qquickplatformdialog_p.h" -#include <QtCore/qurl.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformFileNameFilter; - -class QQuickPlatformFileDialog : public QQuickPlatformDialog -{ - Q_OBJECT - Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL) - Q_PROPERTY(QUrl file READ file WRITE setFile NOTIFY fileChanged FINAL) - Q_PROPERTY(QList<QUrl> files READ files WRITE setFiles NOTIFY filesChanged FINAL) - Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL) - Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL) - Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL) - Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL) - Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL) - Q_PROPERTY(QQuickPlatformFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT) - Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL) - Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL) - Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL) - Q_FLAGS(QFileDialogOptions::FileDialogOptions) - -public: - explicit QQuickPlatformFileDialog(QObject *parent = nullptr); - - enum FileMode { - OpenFile, - OpenFiles, - SaveFile - }; - Q_ENUM(FileMode) - - FileMode fileMode() const; - void setFileMode(FileMode fileMode); - - QUrl file() const; - void setFile(const QUrl &file); - - QList<QUrl> files() const; - void setFiles(const QList<QUrl> &files); - - QUrl currentFile() const; - void setCurrentFile(const QUrl &file); - - QList<QUrl> currentFiles() const; - void setCurrentFiles(const QList<QUrl> &files); - - QUrl folder() const; - void setFolder(const QUrl &folder); - - QFileDialogOptions::FileDialogOptions options() const; - void setOptions(QFileDialogOptions::FileDialogOptions options); - void resetOptions(); - - QStringList nameFilters() const; - void setNameFilters(const QStringList &filters); - void resetNameFilters(); - - QQuickPlatformFileNameFilter *selectedNameFilter() const; - - QString defaultSuffix() const; - void setDefaultSuffix(const QString &suffix); - void resetDefaultSuffix(); - - QString acceptLabel() const; - void setAcceptLabel(const QString &label); - void resetAcceptLabel(); - - QString rejectLabel() const; - void setRejectLabel(const QString &label); - void resetRejectLabel(); - -Q_SIGNALS: - void fileModeChanged(); - void fileChanged(); - void filesChanged(); - void currentFileChanged(); - void currentFilesChanged(); - void folderChanged(); - void optionsChanged(); - void nameFiltersChanged(); - void defaultSuffixChanged(); - void acceptLabelChanged(); - void rejectLabelChanged(); - -protected: - bool useNativeDialog() const override; - void onCreate(QPlatformDialogHelper *dialog) override; - void onShow(QPlatformDialogHelper *dialog) override; - void onHide(QPlatformDialogHelper *dialog) override; - void accept() override; - -private: - QUrl addDefaultSuffix(const QUrl &file) const; - QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const; - - FileMode m_fileMode; - QList<QUrl> m_files; - bool m_firstShow = true; - QSharedPointer<QFileDialogOptions> m_options; - mutable QQuickPlatformFileNameFilter *m_selectedNameFilter; -}; - -class QQuickPlatformFileNameFilter : public QObject -{ - Q_OBJECT - Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL) - Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL) - Q_PROPERTY(QStringList extensions READ extensions NOTIFY extensionsChanged FINAL) - -public: - explicit QQuickPlatformFileNameFilter(QObject *parent = nullptr); - - int index() const; - void setIndex(int index); - - QString name() const; - QStringList extensions() const; - - QSharedPointer<QFileDialogOptions> options() const; - void setOptions(const QSharedPointer<QFileDialogOptions> &options); - - void update(const QString &filter); - -Q_SIGNALS: - void indexChanged(int index); - void nameChanged(const QString &name); - void extensionsChanged(const QStringList &extensions); - -private: - QStringList nameFilters() const; - QString nameFilter(int index) const; - - int m_index; - QString m_name; - QStringList m_extensions; - QSharedPointer<QFileDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformFileDialog) - -#endif // QQUICKPLATFORMFILEDIALOG_P_H diff --git a/src/labs/platform/qquickplatformfolderdialog.cpp b/src/labs/platform/qquickplatformfolderdialog.cpp deleted file mode 100644 index a28dc828..00000000 --- a/src/labs/platform/qquickplatformfolderdialog.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformfolderdialog_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FolderDialog - \inherits Dialog -//! \instantiates QQuickPlatformFolderDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native folder dialog. - - The FolderDialog type provides a QML API for native platform folder dialogs. - - \image qtlabsplatform-folderdialog-gtk.png - - To show a folder dialog, construct an instance of FolderDialog, set the - desired properties, and call \l {Dialog::}{open()}. The \l currentFolder - property can be used to determine the currently selected folder in the - dialog. The \l folder property is updated only after the final selection - has been made by accepting the dialog. - - \code - MenuItem { - text: "Open..." - onTriggered: folderDialog.open() - } - - FolderDialog { - id: folderDialog - currentFolder: viewer.folder - folder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] - } - - MyViewer { - id: viewer - folder: folderDialog.folder - } - \endcode - - \section2 Availability - - A native platform folder dialog is currently available on the following platforms: - - \list - \li iOS - \li Linux (when running with the GTK+ platform theme) - \li macOS - \li Windows - \endlist - - \input includes/widgets.qdocinc 1 - - \labs - - \sa FileDialog, StandardPaths -*/ - -QQuickPlatformFolderDialog::QQuickPlatformFolderDialog(QObject *parent) - : QQuickPlatformDialog(QPlatformTheme::FileDialog, parent), - m_options(QFileDialogOptions::create()) -{ - m_options->setFileMode(QFileDialogOptions::Directory); - m_options->setAcceptMode(QFileDialogOptions::AcceptOpen); -} - -/*! - \qmlproperty url Qt.labs.platform::FolderDialog::folder - - This property holds the final accepted folder. - - Unlike the \l currentFolder property, the \c folder property is not updated - while the user is selecting folders in the dialog, but only after the final - selection has been made. That is, when the user has clicked \uicontrol OK - to accept a folder. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentFolder, {Dialog::}{accepted()} -*/ -QUrl QQuickPlatformFolderDialog::folder() const -{ - return m_folder; -} - -void QQuickPlatformFolderDialog::setFolder(const QUrl &folder) -{ - if (m_folder == folder) - return; - - m_folder = folder; - setCurrentFolder(folder); - emit folderChanged(); -} - -/*! - \qmlproperty url Qt.labs.platform::FolderDialog::currentFolder - - This property holds the currently selected folder in the dialog. - - Unlike the \l folder property, the \c currentFolder property is updated - while the user is selecting folders in the dialog, even before the final - selection has been made. - - \sa folder -*/ -QUrl QQuickPlatformFolderDialog::currentFolder() const -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - return fileDialog->directory(); - return m_options->initialDirectory(); -} - -void QQuickPlatformFolderDialog::setCurrentFolder(const QUrl &folder) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - fileDialog->setDirectory(folder); - m_options->setInitialDirectory(folder); -} - -/*! - \qmlproperty flags Qt.labs.platform::FolderDialog::options - - This property holds the various options that affect the look and feel of the dialog. - - By default, all options are disabled. - - Options should be set before showing the dialog. Setting them while the dialog is - visible is not guaranteed to have an immediate effect on the dialog (depending on - the option and on the platform). - - Available options: - \value FolderDialog.ShowDirsOnly Only show directories in the folder dialog. By default both folders and directories are shown. - \value FolderDialog.DontResolveSymlinks Don't resolve symlinks in the folder dialog. By default symlinks are resolved. - \value FolderDialog.ReadOnly Indicates that the dialog doesn't allow creating directories. -*/ -QFileDialogOptions::FileDialogOptions QQuickPlatformFolderDialog::options() const -{ - return m_options->options(); -} - -void QQuickPlatformFolderDialog::setOptions(QFileDialogOptions::FileDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -void QQuickPlatformFolderDialog::resetOptions() -{ - setOptions({}); -} - -/*! - \qmlproperty string Qt.labs.platform::FolderDialog::acceptLabel - - This property holds the label text shown on the button that accepts the dialog. - - When set to an empty string, the default label of the underlying platform is used. - The default label is typically \uicontrol Open. - - The default value is an empty string. - - \sa rejectLabel -*/ -QString QQuickPlatformFolderDialog::acceptLabel() const -{ - return m_options->labelText(QFileDialogOptions::Accept); -} - -void QQuickPlatformFolderDialog::setAcceptLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Accept)) - return; - - m_options->setLabelText(QFileDialogOptions::Accept, label); - emit acceptLabelChanged(); -} - -void QQuickPlatformFolderDialog::resetAcceptLabel() -{ - setAcceptLabel(QString()); -} - -/*! - \qmlproperty string Qt.labs.platform::FolderDialog::rejectLabel - - This property holds the label text shown on the button that rejects the dialog. - - When set to an empty string, the default label of the underlying platform is used. - The default label is typically \uicontrol Cancel. - - The default value is an empty string. - - \sa acceptLabel -*/ -QString QQuickPlatformFolderDialog::rejectLabel() const -{ - return m_options->labelText(QFileDialogOptions::Reject); -} - -void QQuickPlatformFolderDialog::setRejectLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Reject)) - return; - - m_options->setLabelText(QFileDialogOptions::Reject, label); - emit rejectLabelChanged(); -} - -void QQuickPlatformFolderDialog::resetRejectLabel() -{ - setRejectLabel(QString()); -} - -bool QQuickPlatformFolderDialog::useNativeDialog() const -{ - return QQuickPlatformDialog::useNativeDialog() - && !m_options->testOption(QFileDialogOptions::DontUseNativeDialog); -} - -void QQuickPlatformFolderDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - connect(fileDialog, &QPlatformFileDialogHelper::directoryEntered, this, &QQuickPlatformFolderDialog::currentFolderChanged); - fileDialog->setOptions(m_options); - } -} - -void QQuickPlatformFolderDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) - fileDialog->setOptions(m_options); -} - -void QQuickPlatformFolderDialog::accept() -{ - setFolder(currentFolder()); - QQuickPlatformDialog::accept(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformfolderdialog_p.h b/src/labs/platform/qquickplatformfolderdialog_p.h deleted file mode 100644 index 69878cb9..00000000 --- a/src/labs/platform/qquickplatformfolderdialog_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMFOLDERDIALOG_P_H -#define QQUICKPLATFORMFOLDERDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This folder is not part of the Qt API. It exists purely as an -// implementation detail. This header folder may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qquickplatformdialog_p.h" -#include <QtCore/qurl.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformFolderDialog : public QQuickPlatformDialog -{ - Q_OBJECT - Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL) - Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL) - Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL) - Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL) - Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL) - Q_FLAGS(QFileDialogOptions::FileDialogOptions) - -public: - explicit QQuickPlatformFolderDialog(QObject *parent = nullptr); - - QUrl folder() const; - void setFolder(const QUrl &folder); - - QUrl currentFolder() const; - void setCurrentFolder(const QUrl &folder); - - QFileDialogOptions::FileDialogOptions options() const; - void setOptions(QFileDialogOptions::FileDialogOptions options); - void resetOptions(); - - QString acceptLabel() const; - void setAcceptLabel(const QString &label); - void resetAcceptLabel(); - - QString rejectLabel() const; - void setRejectLabel(const QString &label); - void resetRejectLabel(); - -Q_SIGNALS: - void folderChanged(); - void currentFolderChanged(); - void optionsChanged(); - void acceptLabelChanged(); - void rejectLabelChanged(); - -protected: - bool useNativeDialog() const override; - void onCreate(QPlatformDialogHelper *dialog) override; - void onShow(QPlatformDialogHelper *dialog) override; - void accept() override; - -private: - QUrl m_folder; - QSharedPointer<QFileDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformFolderDialog) - -#endif // QQUICKPLATFORMFOLDERDIALOG_P_H diff --git a/src/labs/platform/qquickplatformfontdialog.cpp b/src/labs/platform/qquickplatformfontdialog.cpp deleted file mode 100644 index f3eca2c3..00000000 --- a/src/labs/platform/qquickplatformfontdialog.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformfontdialog_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FontDialog - \inherits Dialog -//! \instantiates QQuickPlatformFontDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native font dialog. - - The FontDialog type provides a QML API for native platform font dialogs. - - \image qtlabsplatform-fontdialog-gtk.png - - To show a font dialog, construct an instance of FontDialog, set the - desired properties, and call \l {Dialog::}{open()}. The \l currentFont - property can be used to determine the currently selected font in the - dialog. The \l font property is updated only after the final selection - has been made by accepting the dialog. - - \code - MenuItem { - text: "Font" - onTriggered: fontDialog.open() - } - - FontDialog { - id: fontDialog - currentFont.family: document.font - } - - MyDocument { - id: document - font: fontDialog.font - } - \endcode - - \section2 Availability - - A native platform font dialog is currently available on the following platforms: - - \list - \li macOS - \li Linux (when running with the GTK+ platform theme) - \endlist - - \input includes/widgets.qdocinc 1 - - \labs -*/ - -QQuickPlatformFontDialog::QQuickPlatformFontDialog(QObject *parent) - : QQuickPlatformDialog(QPlatformTheme::FontDialog, parent), - m_options(QFontDialogOptions::create()) -{ -} - -/*! - \qmlproperty font Qt.labs.platform::FontDialog::font - - This property holds the final accepted font. - - Unlike the \l currentFont property, the \c font property is not updated - while the user is selecting fonts in the dialog, but only after the final - selection has been made. That is, when the user has clicked \uicontrol OK - to accept a font. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentFont, {Dialog::}{accepted()} -*/ -QFont QQuickPlatformFontDialog::font() const -{ - return m_font; -} - -void QQuickPlatformFontDialog::setFont(const QFont &font) -{ - if (m_font == font) - return; - - m_font = font; - setCurrentFont(font); - emit fontChanged(); -} - -/*! - \qmlproperty font Qt.labs.platform::FontDialog::currentFont - - This property holds the currently selected font in the dialog. - - Unlike the \l font property, the \c currentFont property is updated - while the user is selecting fonts in the dialog, even before the final - selection has been made. - - \sa font -*/ -QFont QQuickPlatformFontDialog::currentFont() const -{ - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle())) - return fontDialog->currentFont(); - return m_currentFont; -} - -void QQuickPlatformFontDialog::setCurrentFont(const QFont &font) -{ - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle())) - fontDialog->setCurrentFont(font); - m_currentFont = font; -} - -/*! - \qmlproperty flags Qt.labs.platform::FontDialog::options - - This property holds the various options that affect the look and feel of the dialog. - - By default, all options are disabled. - - Options should be set before showing the dialog. Setting them while the dialog is - visible is not guaranteed to have an immediate effect on the dialog (depending on - the option and on the platform). - - Available options: - \value FontDialog.ScalableFonts Show scalable fonts. - \value FontDialog.NonScalableFonts Show non-scalable fonts. - \value FontDialog.MonospacedFonts Show monospaced fonts. - \value FontDialog.ProportionalFonts Show proportional fonts. - \value FontDialog.NoButtons Don't display \uicontrol OK and \uicontrol Cancel buttons (useful for "live dialogs"). -*/ -QFontDialogOptions::FontDialogOptions QQuickPlatformFontDialog::options() const -{ - return m_options->options(); -} - -void QQuickPlatformFontDialog::setOptions(QFontDialogOptions::FontDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -bool QQuickPlatformFontDialog::useNativeDialog() const -{ - return QQuickPlatformDialog::useNativeDialog() - && !m_options->testOption(QFontDialogOptions::DontUseNativeDialog); -} - -void QQuickPlatformFontDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog)) { - connect(fontDialog, &QPlatformFontDialogHelper::currentFontChanged, this, &QQuickPlatformFontDialog::currentFontChanged); - fontDialog->setOptions(m_options); - } -} - -void QQuickPlatformFontDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog)) - fontDialog->setOptions(m_options); -} - -void QQuickPlatformFontDialog::accept() -{ - setFont(currentFont()); - QQuickPlatformDialog::accept(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformfontdialog_p.h b/src/labs/platform/qquickplatformfontdialog_p.h deleted file mode 100644 index e7946477..00000000 --- a/src/labs/platform/qquickplatformfontdialog_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMFONTDIALOG_P_H -#define QQUICKPLATFORMFONTDIALOG_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 "qquickplatformdialog_p.h" -#include <QtGui/qfont.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformFontDialog : public QQuickPlatformDialog -{ - Q_OBJECT - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) - Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged FINAL) - Q_PROPERTY(QFontDialogOptions::FontDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL) - Q_FLAGS(QFontDialogOptions::FontDialogOptions) - -public: - explicit QQuickPlatformFontDialog(QObject *parent = nullptr); - - QFont font() const; - void setFont(const QFont &font); - - QFont currentFont() const; - void setCurrentFont(const QFont &font); - - QFontDialogOptions::FontDialogOptions options() const; - void setOptions(QFontDialogOptions::FontDialogOptions options); - -Q_SIGNALS: - void fontChanged(); - void currentFontChanged(); - void optionsChanged(); - -protected: - bool useNativeDialog() const override; - void onCreate(QPlatformDialogHelper *dialog) override; - void onShow(QPlatformDialogHelper *dialog) override; - void accept() override; - -private: - QFont m_font; - QFont m_currentFont; // TODO: QFontDialogOptions::initialFont - QSharedPointer<QFontDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformFontDialog) - -#endif // QQUICKPLATFORMFONTDIALOG_P_H diff --git a/src/labs/platform/qquickplatformicon.cpp b/src/labs/platform/qquickplatformicon.cpp deleted file mode 100644 index 7096ff8a..00000000 --- a/src/labs/platform/qquickplatformicon.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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 "qquickplatformicon_p.h" - -QT_BEGIN_NAMESPACE - -QUrl QQuickPlatformIcon::source() const -{ - return m_source; -} - -void QQuickPlatformIcon::setSource(const QUrl& source) -{ - m_source = source; -} - -QString QQuickPlatformIcon::name() const -{ - return m_name; -} - -void QQuickPlatformIcon::setName(const QString& name) -{ - m_name = name; -} - -bool QQuickPlatformIcon::isMask() const -{ - return m_mask; -} - -void QQuickPlatformIcon::setMask(bool mask) -{ - m_mask = mask; -} - -bool QQuickPlatformIcon::operator==(const QQuickPlatformIcon &other) const -{ - return m_source == other.m_source && m_name == other.m_name && m_mask == other.m_mask; -} - -bool QQuickPlatformIcon::operator!=(const QQuickPlatformIcon &other) const -{ - return !(*this == other); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformicon_p.h b/src/labs/platform/qquickplatformicon_p.h deleted file mode 100644 index 9add9d6e..00000000 --- a/src/labs/platform/qquickplatformicon_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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 QQUICKPLATFORMICON_P_H -#define QQUICKPLATFORMICON_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 <QtCore/qurl.h> -#include <QtCore/qstring.h> - -QT_BEGIN_NAMESPACE - -class QObject; - -class QQuickPlatformIcon -{ - Q_GADGET - Q_PROPERTY(QUrl source READ source WRITE setSource) - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(bool mask READ isMask WRITE setMask) - -public: - QUrl source() const; - void setSource(const QUrl &source); - - QString name() const; - void setName(const QString &name); - - bool isMask() const; - void setMask(bool mask); - - bool operator==(const QQuickPlatformIcon &other) const; - bool operator!=(const QQuickPlatformIcon &other) const; - -private: - bool m_mask = false; - QUrl m_source; - QString m_name; -}; - -QT_END_NAMESPACE - -#endif // QQUICKPLATFORMICON_P_H diff --git a/src/labs/platform/qquickplatformiconloader.cpp b/src/labs/platform/qquickplatformiconloader.cpp deleted file mode 100644 index c7b699b2..00000000 --- a/src/labs/platform/qquickplatformiconloader.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformiconloader_p.h" - -#include <QtCore/qobject.h> -#include <QtCore/qmetaobject.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -QQuickPlatformIconLoader::QQuickPlatformIconLoader(int slot, QObject *parent) - : m_parent(parent), - m_slot(slot), - m_enabled(false) -{ - Q_ASSERT(slot != -1 && parent); -} - -bool QQuickPlatformIconLoader::isEnabled() const -{ - return m_enabled; -} - -void QQuickPlatformIconLoader::setEnabled(bool enabled) -{ - m_enabled = enabled; - if (m_enabled) - loadIcon(); -} - -QIcon QQuickPlatformIconLoader::toQIcon() const -{ - QIcon fallback = QPixmap::fromImage(image()); - QIcon icon = QIcon::fromTheme(m_icon.name(), fallback); - icon.setIsMask(m_icon.isMask()); - return icon; -} - -QQuickPlatformIcon QQuickPlatformIconLoader::icon() const -{ - return m_icon; -} - -void QQuickPlatformIconLoader::setIcon(const QQuickPlatformIcon& icon) -{ - m_icon = icon; - if (m_enabled) - loadIcon(); -} - -void QQuickPlatformIconLoader::loadIcon() -{ - if (m_icon.source().isEmpty()) { - clear(m_parent); - } else { - load(qmlEngine(m_parent), m_icon.source()); - if (m_slot != -1 && isLoading()) { - connectFinished(m_parent, m_slot); - m_slot = -1; - } - } - - if (!isLoading()) - m_parent->metaObject()->method(m_slot).invoke(m_parent); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformiconloader_p.h b/src/labs/platform/qquickplatformiconloader_p.h deleted file mode 100644 index d284a513..00000000 --- a/src/labs/platform/qquickplatformiconloader_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMICONLOADER_P_H -#define QQUICKPLATFORMICONLOADER_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 <QtCore/qurl.h> -#include <QtCore/qstring.h> -#include <QtGui/qicon.h> -#include <QtQuick/private/qquickpixmapcache_p.h> - -#include "qquickplatformicon_p.h" - -QT_BEGIN_NAMESPACE - -class QObject; - -class QQuickPlatformIconLoader : public QQuickPixmap -{ -public: - QQuickPlatformIconLoader(int slot, QObject *parent); - - bool isEnabled() const; - void setEnabled(bool enabled); - - QIcon toQIcon() const; - - QQuickPlatformIcon icon() const; - void setIcon(const QQuickPlatformIcon &icon); - -private: - void loadIcon(); - - QObject *m_parent; - int m_slot; - bool m_enabled; - QQuickPlatformIcon m_icon; -}; - -QT_END_NAMESPACE - -#endif // QQUICKPLATFORMICONLOADER_P_H diff --git a/src/labs/platform/qquickplatformmenu.cpp b/src/labs/platform/qquickplatformmenu.cpp deleted file mode 100644 index 16dffd5e..00000000 --- a/src/labs/platform/qquickplatformmenu.cpp +++ /dev/null @@ -1,895 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 "qquickplatformmenu_p.h" -#include "qquickplatformmenubar_p.h" -#include "qquickplatformmenuitem_p.h" -#include "qquickplatformiconloader_p.h" - -#include <QtCore/qloggingcategory.h> -#include <QtGui/qicon.h> -#include <QtGui/qcursor.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtGui/private/qhighdpiscaling_p.h> -#include <QtQml/private/qqmlengine_p.h> -#include <QtQml/private/qv4scopedvalue_p.h> -#include <QtQml/private/qv4qobjectwrapper_p.h> -#include <QtQuick/qquickrendercontrol.h> -#include <QtQuick/qquickwindow.h> -#include <QtQuick/qquickitem.h> - -#include "widgets/qwidgetplatform_p.h" - -#if QT_CONFIG(systemtrayicon) -#include "qquickplatformsystemtrayicon_p.h" -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Menu - \inherits QtObject -//! \instantiates QQuickPlatformMenu - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native menu. - - The Menu type provides a QML API for native platform menu popups. - - \image qtlabsplatform-menu.png - - Menu can be used in a \l MenuBar, or as a stand-alone context menu. - The following example shows how to open a context menu on right mouse - click: - - \code - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.RightButton - onClicked: zoomMenu.open() - } - - Menu { - id: zoomMenu - - MenuItem { - text: qsTr("Zoom In") - shortcut: StandardKey.ZoomIn - onTriggered: zoomIn() - } - - MenuItem { - text: qsTr("Zoom Out") - shortcut: StandardKey.ZoomOut - onTriggered: zoomOut() - } - } - \endcode - - \section2 Submenus - - To create submenus, declare a Menu as a child of another Menu: - - \qml - Menu { - title: qsTr("Edit") - - Menu { - title: qsTr("Advanced") - - MenuItem { - text: qsTr("Auto-indent Selection") - onTriggered: autoIndentSelection() - } - - MenuItem { - text: qsTr("Rewrap Paragraph") - onTriggered: rewrapParagraph() - } - } - } - \endqml - - \section2 Dynamically Generating Menu Items - - It is possible to dynamically generate menu items. One of the easiest ways - to do so is with \l Instantiator. For example, to implement a - "Recent Files" submenu, where the items are based on a list of files stored - in settings, the following code could be used: - - \qml - Menu { - title: qsTr("File") - - Menu { - id: recentFilesSubMenu - title: qsTr("Recent Files") - enabled: recentFilesInstantiator.count > 0 - - Instantiator { - id: recentFilesInstantiator - model: settings.recentFiles - delegate: MenuItem { - text: settings.displayableFilePath(modelData) - onTriggered: loadFile(modelData) - } - - onObjectAdded: recentFilesSubMenu.insertItem(index, object) - onObjectRemoved: recentFilesSubMenu.removeItem(object) - } - - MenuSeparator {} - - MenuItem { - text: qsTr("Clear Recent Files") - onTriggered: settings.clearRecentFiles() - } - } - } - \endqml - - \section2 Availability - - A native platform menu is currently available on the following platforms: - - \list - \li macOS - \li iOS - \li Android - \li Linux (only available as a stand-alone context menu when running with the GTK+ platform theme) - \endlist - - \input includes/widgets.qdocinc 1 - - \labs - - \sa MenuItem, MenuSeparator, MenuBar -*/ - -/*! - \qmlsignal Qt.labs.platform::Menu::aboutToShow() - - This signal is emitted when the menu is about to be shown to the user. -*/ - -/*! - \qmlsignal Qt.labs.platform::Menu::aboutToHide() - - This signal is emitted when the menu is about to be hidden from the user. -*/ - -Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformMenus) - -QQuickPlatformMenu::QQuickPlatformMenu(QObject *parent) - : QObject(parent), - m_complete(false), - m_enabled(true), - m_visible(true), - m_minimumWidth(-1), - m_type(QPlatformMenu::DefaultMenu), - m_menuBar(nullptr), - m_parentMenu(nullptr), - m_systemTrayIcon(nullptr), - m_menuItem(nullptr), - m_iconLoader(nullptr), - m_handle(nullptr) -{ -} - -QQuickPlatformMenu::~QQuickPlatformMenu() -{ - if (m_menuBar) - m_menuBar->removeMenu(this); - if (m_parentMenu) - m_parentMenu->removeMenu(this); - - unparentSubmenus(); - - delete m_iconLoader; - m_iconLoader = nullptr; - delete m_handle; - m_handle = nullptr; -} - -void QQuickPlatformMenu::unparentSubmenus() -{ - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) { - if (QQuickPlatformMenu *subMenu = item->subMenu()) - subMenu->setParentMenu(nullptr); - item->setMenu(nullptr); - } -} - -QPlatformMenu *QQuickPlatformMenu::handle() const -{ - return m_handle; -} - -QPlatformMenu * QQuickPlatformMenu::create() -{ - if (!m_handle) { - if (m_menuBar && m_menuBar->handle()) - m_handle = m_menuBar->handle()->createMenu(); - else if (m_parentMenu && m_parentMenu->handle()) - m_handle = m_parentMenu->handle()->createSubMenu(); -#if QT_CONFIG(systemtrayicon) - else if (m_systemTrayIcon && m_systemTrayIcon->handle()) - m_handle = m_systemTrayIcon->handle()->createMenu(); -#endif - - // TODO: implement ^ - // - QCocoaMenuBar::createMenu() - // - QCocoaMenu::createSubMenu() - // - QCocoaSystemTrayIcon::createMenu() - if (!m_handle) - m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); - - if (!m_handle) - m_handle = QWidgetPlatform::createMenu(); - - qCDebug(qtLabsPlatformMenus) << "Menu ->" << m_handle; - - if (m_handle) { - connect(m_handle, &QPlatformMenu::aboutToShow, this, &QQuickPlatformMenu::aboutToShow); - connect(m_handle, &QPlatformMenu::aboutToHide, this, &QQuickPlatformMenu::aboutToHide); - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) - m_handle->insertMenuItem(item->create(), nullptr); - - if (m_menuItem) { - if (QPlatformMenuItem *handle = m_menuItem->create()) - handle->setMenu(m_handle); - } - } - } - return m_handle; -} - -void QQuickPlatformMenu::destroy() -{ - if (!m_handle) - return; - - // Ensure that all submenus are unparented before we are destroyed, - // so that they don't try to access a destroyed menu. - unparentSubmenus(); - - delete m_handle; - m_handle = nullptr; -} - -void QQuickPlatformMenu::sync() -{ - if (!m_complete || !create()) - return; - - m_handle->setText(m_title); - m_handle->setEnabled(m_enabled); - m_handle->setVisible(m_visible); - m_handle->setMinimumWidth(m_minimumWidth); - m_handle->setMenuType(m_type); - m_handle->setFont(m_font); - - if (m_menuBar && m_menuBar->handle()) - m_menuBar->handle()->syncMenu(m_handle); -#if QT_CONFIG(systemtrayicon) - else if (m_systemTrayIcon && m_systemTrayIcon->handle()) - m_systemTrayIcon->handle()->updateMenu(m_handle); -#endif - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) - item->sync(); -} - -/*! - \qmldefault - \qmlproperty list<Object> Qt.labs.platform::Menu::data - - This default property holds the list of all objects declared as children of - the menu. The data property includes objects that are not \l MenuItem instances, - such as \l Timer and \l QtObject. - - \sa items -*/ -QQmlListProperty<QObject> QQuickPlatformMenu::data() -{ - return QQmlListProperty<QObject>(this, nullptr, data_append, data_count, data_at, data_clear); -} - -/*! - \qmlproperty list<MenuItem> Qt.labs.platform::Menu::items - - This property holds the list of items in the menu. -*/ -QQmlListProperty<QQuickPlatformMenuItem> QQuickPlatformMenu::items() -{ - return QQmlListProperty<QQuickPlatformMenuItem>(this, nullptr, items_append, items_count, items_at, items_clear); -} - -/*! - \readonly - \qmlproperty MenuBar Qt.labs.platform::Menu::menuBar - - This property holds the menubar that the menu belongs to, or \c null if the - menu is not in a menubar. -*/ -QQuickPlatformMenuBar *QQuickPlatformMenu::menuBar() const -{ - return m_menuBar; -} - -void QQuickPlatformMenu::setMenuBar(QQuickPlatformMenuBar *menuBar) -{ - if (m_menuBar == menuBar) - return; - - m_menuBar = menuBar; - destroy(); - emit menuBarChanged(); -} - -/*! - \readonly - \qmlproperty Menu Qt.labs.platform::Menu::parentMenu - - This property holds the parent menu that the menu belongs to, or \c null if the - menu is not a sub-menu. -*/ -QQuickPlatformMenu *QQuickPlatformMenu::parentMenu() const -{ - return m_parentMenu; -} - -void QQuickPlatformMenu::setParentMenu(QQuickPlatformMenu *menu) -{ - if (m_parentMenu == menu) - return; - - m_parentMenu = menu; - destroy(); - emit parentMenuChanged(); -} - -/*! - \readonly - \qmlproperty SystemTrayIcon Qt.labs.platform::Menu::systemTrayIcon - - This property holds the system tray icon that the menu belongs to, or \c null - if the menu is not in a system tray icon. -*/ -QQuickPlatformSystemTrayIcon *QQuickPlatformMenu::systemTrayIcon() const -{ - return m_systemTrayIcon; -} - -void QQuickPlatformMenu::setSystemTrayIcon(QQuickPlatformSystemTrayIcon *icon) -{ - if (m_systemTrayIcon == icon) - return; - - m_systemTrayIcon = icon; - destroy(); - emit systemTrayIconChanged(); -} - -/*! - \readonly - \qmlproperty MenuItem Qt.labs.platform::Menu::menuItem - - This property holds the item that presents the menu (in a parent menu). -*/ -QQuickPlatformMenuItem *QQuickPlatformMenu::menuItem() const -{ - if (!m_menuItem) { - QQuickPlatformMenu *that = const_cast<QQuickPlatformMenu *>(this); - m_menuItem = new QQuickPlatformMenuItem(that); - m_menuItem->setSubMenu(that); - m_menuItem->setText(m_title); - m_menuItem->setIcon(icon()); - m_menuItem->setVisible(m_visible); - m_menuItem->setEnabled(m_enabled); - m_menuItem->componentComplete(); - } - return m_menuItem; -} - -/*! - \qmlproperty bool Qt.labs.platform::Menu::enabled - - This property holds whether the menu is enabled. The default value is \c true. -*/ -bool QQuickPlatformMenu::isEnabled() const -{ - return m_enabled; -} - -void QQuickPlatformMenu::setEnabled(bool enabled) -{ - if (m_enabled == enabled) - return; - - if (m_menuItem) - m_menuItem->setEnabled(enabled); - - m_enabled = enabled; - sync(); - emit enabledChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::Menu::visible - - This property holds whether the menu is visible. The default value is \c true. -*/ -bool QQuickPlatformMenu::isVisible() const -{ - return m_visible; -} - -void QQuickPlatformMenu::setVisible(bool visible) -{ - if (m_visible == visible) - return; - - if (m_menuItem) - m_menuItem->setVisible(visible); - - m_visible = visible; - sync(); - emit visibleChanged(); -} - -/*! - \qmlproperty int Qt.labs.platform::Menu::minimumWidth - - This property holds the minimum width of the menu. The default value is \c -1 (no minimum width). -*/ -int QQuickPlatformMenu::minimumWidth() const -{ - return m_minimumWidth; -} - -void QQuickPlatformMenu::setMinimumWidth(int width) -{ - if (m_minimumWidth == width) - return; - - m_minimumWidth = width; - sync(); - emit minimumWidthChanged(); -} - -/*! - \qmlproperty enumeration Qt.labs.platform::Menu::type - - This property holds the type of the menu. - - Available values: - \value Menu.DefaultMenu A normal menu (default). - \value Menu.EditMenu An edit menu with pre-populated cut, copy and paste items. -*/ -QPlatformMenu::MenuType QQuickPlatformMenu::type() const -{ - return m_type; -} - -void QQuickPlatformMenu::setType(QPlatformMenu::MenuType type) -{ - if (m_type == type) - return; - - m_type = type; - sync(); - emit typeChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::Menu::title - - This property holds the menu's title. -*/ -QString QQuickPlatformMenu::title() const -{ - return m_title; -} - -void QQuickPlatformMenu::setTitle(const QString &title) -{ - if (m_title == title) - return; - - if (m_menuItem) - m_menuItem->setText(title); - - m_title = title; - sync(); - emit titleChanged(); -} - -/*! - \qmlproperty font Qt.labs.platform::Menu::font - - This property holds the menu's font. - - \sa text -*/ -QFont QQuickPlatformMenu::font() const -{ - return m_font; -} - -void QQuickPlatformMenu::setFont(const QFont& font) -{ - if (m_font == font) - return; - - m_font = font; - sync(); - emit fontChanged(); -} - -/*! - \since Qt.labs.platform 1.1 (Qt 5.12) - \qmlproperty url Qt.labs.platform::Menu::icon.source - \qmlproperty string Qt.labs.platform::Menu::icon.name - \qmlproperty bool Qt.labs.platform::Menu::icon.mask - - This property holds the menu item's icon. -*/ -QQuickPlatformIcon QQuickPlatformMenu::icon() const -{ - if (!m_iconLoader) - return QQuickPlatformIcon(); - - return iconLoader()->icon(); -} - -void QQuickPlatformMenu::setIcon(const QQuickPlatformIcon &icon) -{ - if (iconLoader()->icon() == icon) - return; - - if (m_menuItem) - m_menuItem->setIcon(icon); - - iconLoader()->setIcon(icon); - emit iconChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::addItem(MenuItem item) - - Adds an \a item to the end of the menu. -*/ -void QQuickPlatformMenu::addItem(QQuickPlatformMenuItem *item) -{ - insertItem(m_items.count(), item); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::insertItem(int index, MenuItem item) - - Inserts an \a item at the specified \a index in the menu. -*/ -void QQuickPlatformMenu::insertItem(int index, QQuickPlatformMenuItem *item) -{ - if (!item || m_items.contains(item)) - return; - - m_items.insert(index, item); - m_data.append(item); - item->setMenu(this); - if (m_handle && item->create()) { - QQuickPlatformMenuItem *before = m_items.value(index + 1); - m_handle->insertMenuItem(item->handle(), before ? before->create() : nullptr); - } - sync(); - emit itemsChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::removeItem(MenuItem item) - - Removes an \a item from the menu. -*/ -void QQuickPlatformMenu::removeItem(QQuickPlatformMenuItem *item) -{ - if (!item || !m_items.removeOne(item)) - return; - - m_data.removeOne(item); - if (m_handle) - m_handle->removeMenuItem(item->handle()); - item->setMenu(nullptr); - sync(); - emit itemsChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::addMenu(Menu submenu) - - Adds a \a submenu to the end of the menu. -*/ -void QQuickPlatformMenu::addMenu(QQuickPlatformMenu *menu) -{ - insertMenu(m_items.count(), menu); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::insertMenu(int index, Menu submenu) - - Inserts a \a submenu at the specified \a index in the menu. -*/ -void QQuickPlatformMenu::insertMenu(int index, QQuickPlatformMenu *menu) -{ - if (!menu) - return; - - menu->setParentMenu(this); - insertItem(index, menu->menuItem()); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::removeMenu(Menu submenu) - - Removes a \a submenu from the menu. -*/ -void QQuickPlatformMenu::removeMenu(QQuickPlatformMenu *menu) -{ - if (!menu) - return; - - menu->setParentMenu(nullptr); - removeItem(menu->menuItem()); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::clear() - - Removes all items from the menu. -*/ -void QQuickPlatformMenu::clear() -{ - if (m_items.isEmpty()) - return; - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) { - m_data.removeOne(item); - if (m_handle) - m_handle->removeMenuItem(item->handle()); - item->setMenu(nullptr); - delete item; - } - - m_items.clear(); - sync(); - emit itemsChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::open(MenuItem item) - - Opens the menu at the current mouse position, optionally aligned to a menu \a item. -*/ - -/*! - \qmlmethod void Qt.labs.platform::Menu::open(Item target, MenuItem item) - - Opens the menu at the specified \a target item, optionally aligned to a menu \a item. -*/ -void QQuickPlatformMenu::open(QQmlV4Function *args) -{ - if (!m_handle) - return; - - if (args->length() > 2) { - args->v4engine()->throwTypeError(); - return; - } - - QV4::ExecutionEngine *v4 = args->v4engine(); - QV4::Scope scope(v4); - - QQuickItem *targetItem = nullptr; - if (args->length() > 0) { - QV4::ScopedValue value(scope, (*args)[0]); - QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>()); - if (object) - targetItem = qobject_cast<QQuickItem *>(object->object()); - } - - QQuickPlatformMenuItem *menuItem = nullptr; - if (args->length() > 1) { - QV4::ScopedValue value(scope, (*args)[1]); - QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>()); - if (object) - menuItem = qobject_cast<QQuickPlatformMenuItem *>(object->object()); - } - - QPoint offset; - QWindow *window = findWindow(targetItem, &offset); - - QRect targetRect; - if (targetItem) { - QRectF sceneBounds = targetItem->mapRectToScene(targetItem->boundingRect()); - targetRect = sceneBounds.toAlignedRect().translated(offset); - } else { -#if QT_CONFIG(cursor) - QPoint pos = QCursor::pos(); - if (window) - pos = window->mapFromGlobal(pos); - targetRect.moveTo(pos); -#endif - } - m_handle->showPopup(window, - QHighDpi::toNativePixels(targetRect, window), - menuItem ? menuItem->handle() : nullptr); -} - -/*! - \qmlmethod void Qt.labs.platform::Menu::close() - - Closes the menu. -*/ -void QQuickPlatformMenu::close() -{ - if (m_handle) - m_handle->dismiss(); -} - -void QQuickPlatformMenu::classBegin() -{ -} - -void QQuickPlatformMenu::componentComplete() -{ - m_complete = true; - if (m_handle && m_iconLoader) - m_iconLoader->setEnabled(true); - sync(); -} - -QQuickPlatformIconLoader *QQuickPlatformMenu::iconLoader() const -{ - if (!m_iconLoader) { - QQuickPlatformMenu *that = const_cast<QQuickPlatformMenu *>(this); - static int slot = staticMetaObject.indexOfSlot("updateIcon()"); - m_iconLoader = new QQuickPlatformIconLoader(slot, that); - m_iconLoader->setEnabled(m_complete); - } - return m_iconLoader; -} - -static QWindow *effectiveWindow(QWindow *window, QPoint *offset) -{ - QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window); - if (quickWindow) { - QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, offset); - if (renderWindow) - return renderWindow; - } - return window; -} - -QWindow *QQuickPlatformMenu::findWindow(QQuickItem *target, QPoint *offset) const -{ - if (target) - return effectiveWindow(target->window(), offset); - - if (m_menuBar && m_menuBar->window()) - return effectiveWindow(m_menuBar->window(), offset); - - QObject *obj = parent(); - while (obj) { - QWindow *window = qobject_cast<QWindow *>(obj); - if (window) - return effectiveWindow(window, offset); - - QQuickItem *item = qobject_cast<QQuickItem *>(obj); - if (item && item->window()) - return effectiveWindow(item->window(), offset); - - obj = obj->parent(); - } - return nullptr; -} - -void QQuickPlatformMenu::data_append(QQmlListProperty<QObject> *property, QObject *object) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - if (QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem *>(object)) - menu->addItem(item); - else if (QQuickPlatformMenu *subMenu = qobject_cast<QQuickPlatformMenu *>(object)) - menu->addMenu(subMenu); - else - menu->m_data.append(object); -} - -qsizetype QQuickPlatformMenu::data_count(QQmlListProperty<QObject> *property) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - return menu->m_data.count(); -} - -QObject *QQuickPlatformMenu::data_at(QQmlListProperty<QObject> *property, qsizetype index) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - return menu->m_data.value(index); -} - -void QQuickPlatformMenu::data_clear(QQmlListProperty<QObject> *property) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - menu->m_data.clear(); -} - -void QQuickPlatformMenu::items_append(QQmlListProperty<QQuickPlatformMenuItem> *property, QQuickPlatformMenuItem *item) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - menu->addItem(item); -} - -qsizetype QQuickPlatformMenu::items_count(QQmlListProperty<QQuickPlatformMenuItem> *property) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - return menu->m_items.count(); -} - -QQuickPlatformMenuItem *QQuickPlatformMenu::items_at(QQmlListProperty<QQuickPlatformMenuItem> *property, qsizetype index) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - return menu->m_items.value(index); -} - -void QQuickPlatformMenu::items_clear(QQmlListProperty<QQuickPlatformMenuItem> *property) -{ - QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object); - menu->clear(); -} - -void QQuickPlatformMenu::updateIcon() -{ - if (!m_handle || !m_iconLoader) - return; - - m_handle->setIcon(m_iconLoader->toQIcon()); - sync(); -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformmenu_p.cpp" diff --git a/src/labs/platform/qquickplatformmenu_p.h b/src/labs/platform/qquickplatformmenu_p.h deleted file mode 100644 index fc66b61b..00000000 --- a/src/labs/platform/qquickplatformmenu_p.h +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QQUICKPLATFORMMENU_P_H -#define QQUICKPLATFORMMENU_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 <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtGui/qfont.h> -#include <QtGui/qpa/qplatformmenu.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQml/qqmllist.h> -#include <QtQml/qqml.h> - -#include "qquickplatformicon_p.h" - -QT_BEGIN_NAMESPACE - -class QIcon; -class QWindow; -class QQuickItem; -class QPlatformMenu; -class QQmlV4Function; -class QQuickPlatformMenuBar; -class QQuickPlatformMenuItem; -class QQuickPlatformIconLoader; -class QQuickPlatformSystemTrayIcon; - -class QQuickPlatformMenu : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) - Q_PROPERTY(QQmlListProperty<QQuickPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL) - Q_PROPERTY(QQuickPlatformMenuBar *menuBar READ menuBar NOTIFY menuBarChanged FINAL) - Q_PROPERTY(QQuickPlatformMenu *parentMenu READ parentMenu NOTIFY parentMenuChanged FINAL) - Q_PROPERTY(QQuickPlatformSystemTrayIcon *systemTrayIcon READ systemTrayIcon NOTIFY systemTrayIconChanged FINAL) - Q_PROPERTY(QQuickPlatformMenuItem *menuItem READ menuItem CONSTANT FINAL) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged FINAL) - Q_PROPERTY(QPlatformMenu::MenuType type READ type WRITE setType NOTIFY typeChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) - Q_PROPERTY(QQuickPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) - Q_ENUMS(QPlatformMenu::MenuType) - Q_CLASSINFO("DefaultProperty", "data") - -public: - explicit QQuickPlatformMenu(QObject *parent = nullptr); - ~QQuickPlatformMenu(); - - QPlatformMenu *handle() const; - QPlatformMenu *create(); - void destroy(); - void sync(); - - QQmlListProperty<QObject> data(); - QQmlListProperty<QQuickPlatformMenuItem> items(); - - QQuickPlatformMenuBar *menuBar() const; - void setMenuBar(QQuickPlatformMenuBar *menuBar); - - QQuickPlatformMenu *parentMenu() const; - void setParentMenu(QQuickPlatformMenu *menu); - - QQuickPlatformSystemTrayIcon *systemTrayIcon() const; - void setSystemTrayIcon(QQuickPlatformSystemTrayIcon *icon); - - QQuickPlatformMenuItem *menuItem() const; - - bool isEnabled() const; - void setEnabled(bool enabled); - - bool isVisible() const; - void setVisible(bool visible); - - int minimumWidth() const; - void setMinimumWidth(int width); - - QPlatformMenu::MenuType type() const; - void setType(QPlatformMenu::MenuType type); - - QString title() const; - void setTitle(const QString &title); - - QFont font() const; - void setFont(const QFont &font); - - QQuickPlatformIcon icon() const; - void setIcon(const QQuickPlatformIcon &icon); - - Q_INVOKABLE void addItem(QQuickPlatformMenuItem *item); - Q_INVOKABLE void insertItem(int index, QQuickPlatformMenuItem *item); - Q_INVOKABLE void removeItem(QQuickPlatformMenuItem *item); - - Q_INVOKABLE void addMenu(QQuickPlatformMenu *menu); - Q_INVOKABLE void insertMenu(int index, QQuickPlatformMenu *menu); - Q_INVOKABLE void removeMenu(QQuickPlatformMenu *menu); - - Q_INVOKABLE void clear(); - -public Q_SLOTS: - void open(QQmlV4Function *args); - void close(); - -Q_SIGNALS: - void aboutToShow(); - void aboutToHide(); - - void itemsChanged(); - void menuBarChanged(); - void parentMenuChanged(); - void systemTrayIconChanged(); - void titleChanged(); - void enabledChanged(); - void visibleChanged(); - void minimumWidthChanged(); - void fontChanged(); - void typeChanged(); - Q_REVISION(2, 1) void iconChanged(); - -protected: - void classBegin() override; - void componentComplete() override; - - QQuickPlatformIconLoader *iconLoader() const; - - QWindow *findWindow(QQuickItem *target, QPoint *offset) const; - - static void data_append(QQmlListProperty<QObject> *property, QObject *object); - static qsizetype data_count(QQmlListProperty<QObject> *property); - static QObject *data_at(QQmlListProperty<QObject> *property, qsizetype index); - static void data_clear(QQmlListProperty<QObject> *property); - - static void items_append(QQmlListProperty<QQuickPlatformMenuItem> *property, QQuickPlatformMenuItem *item); - static qsizetype items_count(QQmlListProperty<QQuickPlatformMenuItem> *property); - static QQuickPlatformMenuItem *items_at(QQmlListProperty<QQuickPlatformMenuItem> *property, qsizetype index); - static void items_clear(QQmlListProperty<QQuickPlatformMenuItem> *property); - -private Q_SLOTS: - void updateIcon(); - -private: - void unparentSubmenus(); - - bool m_complete; - bool m_enabled; - bool m_visible; - int m_minimumWidth; - QPlatformMenu::MenuType m_type; - QString m_title; - QFont m_font; - QList<QObject *> m_data; - QList<QQuickPlatformMenuItem *> m_items; - QQuickPlatformMenuBar *m_menuBar; - QQuickPlatformMenu *m_parentMenu; - QQuickPlatformSystemTrayIcon *m_systemTrayIcon; - mutable QQuickPlatformMenuItem *m_menuItem; - mutable QQuickPlatformIconLoader *m_iconLoader; - QPlatformMenu *m_handle; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMenu) -Q_DECLARE_METATYPE(QPlatformMenu::MenuType) - -#endif // QQUICKPLATFORMMENU_P_H diff --git a/src/labs/platform/qquickplatformmenubar.cpp b/src/labs/platform/qquickplatformmenubar.cpp deleted file mode 100644 index 3b1f4b74..00000000 --- a/src/labs/platform/qquickplatformmenubar.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 "qquickplatformmenubar_p.h" -#include "qquickplatformmenu_p.h" - -#include <QtCore/qloggingcategory.h> -#include <QtGui/qpa/qplatformmenu.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtQuick/qquickwindow.h> -#include <QtQuick/qquickitem.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MenuBar - \inherits QtObject -//! \instantiates QQuickPlatformMenuBar - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native menubar. - - The MenuBar type provides a QML API for native platform menubars. - - \image qtlabsplatform-menubar.png - - A menubar consists of a list of drop-down menus. - - \code - MenuBar { - id: menuBar - - Menu { - id: fileMenu - title: qsTr("File") - // ... - } - - Menu { - id: editMenu - title: qsTr("&Edit") - // ... - } - - Menu { - id: viewMenu - title: qsTr("&View") - // ... - } - - Menu { - id: helpMenu - title: qsTr("&Help") - // ... - } - } - \endcode - - MenuBar is currently available on the following platforms: - - \list - \li macOS - \li Android - \li Linux (only available on desktop environments that provide a global D-Bus menu bar) - \endlist - - \labs - - \sa Menu -*/ - -Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformMenus) - -QQuickPlatformMenuBar::QQuickPlatformMenuBar(QObject *parent) - : QObject(parent), - m_complete(false), - m_window(nullptr), - m_handle(nullptr) -{ - m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); - qCDebug(qtLabsPlatformMenus) << "MenuBar ->" << m_handle; -} - -QQuickPlatformMenuBar::~QQuickPlatformMenuBar() -{ - for (QQuickPlatformMenu *menu : qAsConst(m_menus)) - menu->setMenuBar(nullptr); - delete m_handle; - m_handle = nullptr; -} - -QPlatformMenuBar *QQuickPlatformMenuBar::handle() const -{ - return m_handle; -} - -/*! - \qmldefault - \qmlproperty list<Object> Qt.labs.platform::MenuBar::data - - This default property holds the list of all objects declared as children of - the menubar. The data property includes objects that are not \l Menu instances, - such as \l Timer and \l QtObject. - - \sa menus -*/ -QQmlListProperty<QObject> QQuickPlatformMenuBar::data() -{ - return QQmlListProperty<QObject>(this, nullptr, data_append, data_count, data_at, data_clear); -} - -/*! - \qmlproperty list<Menu> Qt.labs.platform::MenuBar::menus - - This property holds the list of menus in the menubar. -*/ -QQmlListProperty<QQuickPlatformMenu> QQuickPlatformMenuBar::menus() -{ - return QQmlListProperty<QQuickPlatformMenu>(this, nullptr, menus_append, menus_count, menus_at, menus_clear); -} - -/*! - \qmlproperty Window Qt.labs.platform::MenuBar::window - - This property holds the menubar's window. - - Unless explicitly set, the window is automatically resolved by iterating - the QML parent objects until a \l Window or an \l Item that has a window - is found. -*/ -QWindow *QQuickPlatformMenuBar::window() const -{ - return m_window; -} - -void QQuickPlatformMenuBar::setWindow(QWindow *window) -{ - if (m_window == window) - return; - - if (m_handle) - m_handle->handleReparent(window); - - m_window = window; - emit windowChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuBar::addMenu(Menu menu) - - Adds a \a menu to end of the menubar. -*/ -void QQuickPlatformMenuBar::addMenu(QQuickPlatformMenu *menu) -{ - insertMenu(m_menus.count(), menu); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuBar::insertMenu(int index, Menu menu) - - Inserts a \a menu at the specified \a index in the menubar. -*/ -void QQuickPlatformMenuBar::insertMenu(int index, QQuickPlatformMenu *menu) -{ - if (!menu || m_menus.contains(menu)) - return; - - QQuickPlatformMenu *before = m_menus.value(index); - m_menus.insert(index, menu); - m_data.append(menu); - menu->setMenuBar(this); - if (m_handle) - m_handle->insertMenu(menu->create(), before ? before->handle() : nullptr); - menu->sync(); - emit menusChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuBar::removeMenu(Menu menu) - - Removes a \a menu from the menubar. -*/ -void QQuickPlatformMenuBar::removeMenu(QQuickPlatformMenu *menu) -{ - if (!menu || !m_menus.removeOne(menu)) - return; - - m_data.removeOne(menu); - if (m_handle) - m_handle->removeMenu(menu->handle()); - menu->setMenuBar(nullptr); - emit menusChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuBar::clear() - - Removes all menus from the menubar. -*/ -void QQuickPlatformMenuBar::clear() -{ - if (m_menus.isEmpty()) - return; - - for (QQuickPlatformMenu *menu : qAsConst(m_menus)) { - m_data.removeOne(menu); - if (m_handle) - m_handle->removeMenu(menu->handle()); - menu->setMenuBar(nullptr); - delete menu; - } - - m_menus.clear(); - emit menusChanged(); -} - -void QQuickPlatformMenuBar::classBegin() -{ -} - -void QQuickPlatformMenuBar::componentComplete() -{ - m_complete = true; - for (QQuickPlatformMenu *menu : qAsConst(m_menus)) - menu->sync(); - if (!m_window) - setWindow(findWindow()); -} - -QWindow *QQuickPlatformMenuBar::findWindow() const -{ - QObject *obj = parent(); - while (obj) { - QWindow *window = qobject_cast<QWindow *>(obj); - if (window) - return window; - QQuickItem *item = qobject_cast<QQuickItem *>(obj); - if (item && item->window()) - return item->window(); - obj = obj->parent(); - } - return nullptr; -} - -void QQuickPlatformMenuBar::data_append(QQmlListProperty<QObject> *property, QObject *object) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - QQuickPlatformMenu *menu = qobject_cast<QQuickPlatformMenu *>(object); - if (menu) - menuBar->addMenu(menu); - else - menuBar->m_data.append(object); -} - -qsizetype QQuickPlatformMenuBar::data_count(QQmlListProperty<QObject> *property) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - return menuBar->m_data.count(); -} - -QObject *QQuickPlatformMenuBar::data_at(QQmlListProperty<QObject> *property, qsizetype index) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - return menuBar->m_data.value(index); -} - -void QQuickPlatformMenuBar::data_clear(QQmlListProperty<QObject> *property) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - menuBar->m_data.clear(); -} - -void QQuickPlatformMenuBar::menus_append(QQmlListProperty<QQuickPlatformMenu> *property, QQuickPlatformMenu *menu) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - menuBar->addMenu(menu); -} - -qsizetype QQuickPlatformMenuBar::menus_count(QQmlListProperty<QQuickPlatformMenu> *property) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - return menuBar->m_menus.count(); -} - -QQuickPlatformMenu *QQuickPlatformMenuBar::menus_at(QQmlListProperty<QQuickPlatformMenu> *property, qsizetype index) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - return menuBar->m_menus.value(index); -} - -void QQuickPlatformMenuBar::menus_clear(QQmlListProperty<QQuickPlatformMenu> *property) -{ - QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object); - menuBar->clear(); -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformmenubar_p.cpp" diff --git a/src/labs/platform/qquickplatformmenubar_p.h b/src/labs/platform/qquickplatformmenubar_p.h deleted file mode 100644 index e644c86c..00000000 --- a/src/labs/platform/qquickplatformmenubar_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QQUICKPLATFORMMENUBAR_P_H -#define QQUICKPLATFORMMENUBAR_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 <QtCore/qobject.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQml/qqmllist.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QWindow; -class QPlatformMenuBar; -class QQuickPlatformMenu; - -class QQuickPlatformMenuBar : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) - Q_PROPERTY(QQmlListProperty<QQuickPlatformMenu> menus READ menus NOTIFY menusChanged FINAL) - Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged FINAL) - Q_CLASSINFO("DefaultProperty", "data") - -public: - explicit QQuickPlatformMenuBar(QObject *parent = nullptr); - ~QQuickPlatformMenuBar(); - - QPlatformMenuBar *handle() const; - - QQmlListProperty<QObject> data(); - QQmlListProperty<QQuickPlatformMenu> menus(); - - QWindow *window() const; - void setWindow(QWindow *window); - - Q_INVOKABLE void addMenu(QQuickPlatformMenu *menu); - Q_INVOKABLE void insertMenu(int index, QQuickPlatformMenu *menu); - Q_INVOKABLE void removeMenu(QQuickPlatformMenu *menu); - Q_INVOKABLE void clear(); - -Q_SIGNALS: - void menusChanged(); - void windowChanged(); - -protected: - void classBegin() override; - void componentComplete() override; - - QWindow *findWindow() const; - - static void data_append(QQmlListProperty<QObject> *property, QObject *object); - static qsizetype data_count(QQmlListProperty<QObject> *property); - static QObject *data_at(QQmlListProperty<QObject> *property, qsizetype index); - static void data_clear(QQmlListProperty<QObject> *property); - - static void menus_append(QQmlListProperty<QQuickPlatformMenu> *property, QQuickPlatformMenu *menu); - static qsizetype menus_count(QQmlListProperty<QQuickPlatformMenu> *property); - static QQuickPlatformMenu *menus_at(QQmlListProperty<QQuickPlatformMenu> *property, qsizetype index); - static void menus_clear(QQmlListProperty<QQuickPlatformMenu> *property); - -private: - bool m_complete; - QWindow *m_window; - QList<QObject *> m_data; - QList<QQuickPlatformMenu *> m_menus; - QPlatformMenuBar *m_handle; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMenuBar) - -#endif // QQUICKPLATFORMMENUBAR_P_H diff --git a/src/labs/platform/qquickplatformmenuitem.cpp b/src/labs/platform/qquickplatformmenuitem.cpp deleted file mode 100644 index 4f61d423..00000000 --- a/src/labs/platform/qquickplatformmenuitem.cpp +++ /dev/null @@ -1,641 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformmenuitem_p.h" -#include "qquickplatformmenu_p.h" -#include "qquickplatformmenuitemgroup_p.h" -#include "qquickplatformiconloader_p.h" - -#include <QtGui/qicon.h> -#if QT_CONFIG(shortcut) -#include <QtGui/qkeysequence.h> -#endif -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtQuickTemplates2/private/qquickshortcutcontext_p_p.h> - -#include "widgets/qwidgetplatform_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MenuItem - \inherits QtObject -//! \instantiates QQuickPlatformMenuItem - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native menu item. - - The MenuItem type provides a QML API for native platform menu items. - - \image qtlabsplatform-menu.png - - A menu item consists of an \l icon, \l text, and \l shortcut. - - \code - Menu { - id: zoomMenu - - MenuItem { - text: qsTr("Zoom In") - shortcut: StandardKey.ZoomIn - onTriggered: zoomIn() - } - - MenuItem { - text: qsTr("Zoom Out") - shortcut: StandardKey.ZoomOut - onTriggered: zoomOut() - } - } - \endcode - - \labs - - \sa Menu, MenuItemGroup -*/ - -/*! - \qmlsignal Qt.labs.platform::MenuItem::triggered() - - This signal is emitted when the menu item is triggered by the user. -*/ - -/*! - \qmlsignal Qt.labs.platform::MenuItem::hovered() - - This signal is emitted when the menu item is hovered by the user. -*/ - -QQuickPlatformMenuItem::QQuickPlatformMenuItem(QObject *parent) - : QObject(parent), - m_complete(false), - m_enabled(true), - m_visible(true), - m_separator(false), - m_checkable(false), - m_checked(false), - m_role(QPlatformMenuItem::TextHeuristicRole), - m_menu(nullptr), - m_subMenu(nullptr), - m_group(nullptr), - m_iconLoader(nullptr), - m_handle(nullptr) -{ -} - -QQuickPlatformMenuItem::~QQuickPlatformMenuItem() -{ - if (m_menu) - m_menu->removeItem(this); - if (m_group) - m_group->removeItem(this); -#if QT_CONFIG(shortcut) - if (m_shortcutId != -1) { - QKeySequence sequence; - if (m_shortcut.metaType().id() == QMetaType::Int) - sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt())); - else - sequence = QKeySequence::fromString(m_shortcut.toString()); - QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_shortcutId, this, sequence); - } -#endif - delete m_iconLoader; - m_iconLoader = nullptr; - delete m_handle; - m_handle = nullptr; -} - -QPlatformMenuItem *QQuickPlatformMenuItem::handle() const -{ - return m_handle; -} - -QPlatformMenuItem *QQuickPlatformMenuItem::create() -{ - if (!m_handle && m_menu && m_menu->handle()) { - m_handle = m_menu->handle()->createMenuItem(); - - // TODO: implement QCocoaMenu::createMenuItem() - if (!m_handle) - m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem(); - - if (!m_handle) - m_handle = QWidgetPlatform::createMenuItem(); - - if (m_handle) { - connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::activate); - connect(m_handle, &QPlatformMenuItem::hovered, this, &QQuickPlatformMenuItem::hovered); - } - } - return m_handle; -} - -void QQuickPlatformMenuItem::sync() -{ - if (!m_complete || !create()) - return; - - m_handle->setEnabled(isEnabled()); - m_handle->setVisible(isVisible()); - m_handle->setIsSeparator(m_separator); - m_handle->setCheckable(m_checkable); - m_handle->setChecked(m_checked); - m_handle->setRole(m_role); - m_handle->setText(m_text); - m_handle->setFont(m_font); - m_handle->setHasExclusiveGroup(m_group && m_group->isExclusive()); - if (m_subMenu) { - // Sync first as dynamically created menus may need to get the - // handle recreated - m_subMenu->sync(); - if (m_subMenu->handle()) - m_handle->setMenu(m_subMenu->handle()); - } - -#if QT_CONFIG(shortcut) - QKeySequence sequence; - if (m_shortcut.metaType().id() == QMetaType::Int) - sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt())); - else - sequence = QKeySequence::fromString(m_shortcut.toString()); - m_handle->setShortcut(sequence.toString()); -#endif - - if (m_menu && m_menu->handle()) - m_menu->handle()->syncMenuItem(m_handle); -} - -/*! - \readonly - \qmlproperty Menu Qt.labs.platform::MenuItem::menu - - This property holds the menu that the item belongs to, or \c null if the - item is not in a menu. -*/ -QQuickPlatformMenu *QQuickPlatformMenuItem::menu() const -{ - return m_menu; -} - -void QQuickPlatformMenuItem::setMenu(QQuickPlatformMenu *menu) -{ - if (m_menu == menu) - return; - - m_menu = menu; - emit menuChanged(); -} - -/*! - \readonly - \qmlproperty Menu Qt.labs.platform::MenuItem::subMenu - - This property holds the sub-menu that the item contains, or \c null if - the item is not a sub-menu item. -*/ -QQuickPlatformMenu *QQuickPlatformMenuItem::subMenu() const -{ - return m_subMenu; -} - -void QQuickPlatformMenuItem::setSubMenu(QQuickPlatformMenu *menu) -{ - if (m_subMenu == menu) - return; - - m_subMenu = menu; - sync(); - emit subMenuChanged(); -} - -/*! - \qmlproperty MenuItemGroup Qt.labs.platform::MenuItem::group - - This property holds the group that the item belongs to, or \c null if the - item is not in a group. -*/ -QQuickPlatformMenuItemGroup *QQuickPlatformMenuItem::group() const -{ - return m_group; -} - -void QQuickPlatformMenuItem::setGroup(QQuickPlatformMenuItemGroup *group) -{ - if (m_group == group) - return; - - bool wasEnabled = isEnabled(); - bool wasVisible = isVisible(); - - if (group) - group->addItem(this); - - m_group = group; - sync(); - emit groupChanged(); - - if (isEnabled() != wasEnabled) - emit enabledChanged(); - if (isVisible() != wasVisible) - emit visibleChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItem::enabled - - This property holds whether the item is enabled. The default value is \c true. - - Disabled items cannot be triggered by the user. They do not disappear from menus, - but they are displayed in a way which indicates that they are unavailable. For - example, they might be displayed using only shades of gray. - - When an item is disabled, it is not possible to trigger it through its \l shortcut. -*/ -bool QQuickPlatformMenuItem::isEnabled() const -{ - return m_enabled && (!m_group || m_group->isEnabled()); -} - -void QQuickPlatformMenuItem::setEnabled(bool enabled) -{ - if (m_enabled == enabled) - return; - - bool wasEnabled = isEnabled(); - m_enabled = enabled; - sync(); - if (isEnabled() != wasEnabled) - emit enabledChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItem::visible - - This property holds whether the item is visible. The default value is \c true. -*/ -bool QQuickPlatformMenuItem::isVisible() const -{ - return m_visible && (!m_group || m_group->isVisible()); -} - -void QQuickPlatformMenuItem::setVisible(bool visible) -{ - if (m_visible == visible) - return; - - bool wasVisible = isVisible(); - m_visible = visible; - sync(); - if (isVisible() != wasVisible) - emit visibleChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItem::separator - - This property holds whether the item is a separator line. The default value - is \c false. - - \sa MenuSeparator -*/ -bool QQuickPlatformMenuItem::isSeparator() const -{ - return m_separator; -} - -void QQuickPlatformMenuItem::setSeparator(bool separator) -{ - if (m_separator == separator) - return; - - m_separator = separator; - sync(); - emit separatorChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItem::checkable - - This property holds whether the item is checkable. - - A checkable menu item has an on/off state. For example, in a word processor, - a "Bold" menu item may be either on or off. A menu item that is not checkable - is a command item that is simply executed, e.g. file save. - - The default value is \c false. - - \sa checked, MenuItemGroup -*/ -bool QQuickPlatformMenuItem::isCheckable() const -{ - return m_checkable; -} - -void QQuickPlatformMenuItem::setCheckable(bool checkable) -{ - if (m_checkable == checkable) - return; - - m_checkable = checkable; - sync(); - emit checkableChanged(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItem::checked - - This property holds whether the item is checked (on) or unchecked (off). - The default value is \c false. - - \sa checkable, MenuItemGroup -*/ -bool QQuickPlatformMenuItem::isChecked() const -{ - return m_checked; -} - -void QQuickPlatformMenuItem::setChecked(bool checked) -{ - if (m_checked == checked) - return; - - if (checked && !m_checkable) - setCheckable(true); - - m_checked = checked; - sync(); - emit checkedChanged(); -} - -/*! - \qmlproperty enumeration Qt.labs.platform::MenuItem::role - - This property holds the role of the item. The role determines whether - the item should be placed into the application menu on macOS. - - Available values: - \value MenuItem.NoRole The item should not be put into the application menu - \value MenuItem.TextHeuristicRole The item should be put in the application menu based on the action's text (default) - \value MenuItem.ApplicationSpecificRole The item should be put in the application menu with an application-specific role - \value MenuItem.AboutQtRole The item handles the "About Qt" menu item. - \value MenuItem.AboutRole The item should be placed where the "About" menu item is in the application menu. The text of - the menu item will be set to "About <application name>". The application name is fetched from the - \c{Info.plist} file in the application's bundle (See \l{Qt for macOS - Deployment}). - \value MenuItem.PreferencesRole The item should be placed where the "Preferences..." menu item is in the application menu. - \value MenuItem.QuitRole The item should be placed where the Quit menu item is in the application menu. - - Specifying the role only has effect on items that are in the immediate - menus of a menubar, not in the submenus of those menus. For example, if - you have a "File" menu in your menubar and the "File" menu has a submenu, - specifying a role for the items in that submenu has no effect. They will - never be moved to the application menu. -*/ -QPlatformMenuItem::MenuRole QQuickPlatformMenuItem::role() const -{ - return m_role; -} - -void QQuickPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role) -{ - if (m_role == role) - return; - - m_role = role; - sync(); - emit roleChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::MenuItem::text - - This property holds the menu item's text. -*/ -QString QQuickPlatformMenuItem::text() const -{ - return m_text; -} - -void QQuickPlatformMenuItem::setText(const QString &text) -{ - if (m_text == text) - return; - - m_text = text; - sync(); - emit textChanged(); -} - -/*! - \qmlproperty keysequence Qt.labs.platform::MenuItem::shortcut - - This property holds the menu item's shortcut. - - The shortcut key sequence can be set to one of the - \l{QKeySequence::StandardKey}{standard keyboard shortcuts}, or it can be - specified by a string containing a sequence of up to four key presses - that are needed to \l{triggered}{trigger} the shortcut. - - The default value is an empty key sequence. - - \code - MenuItem { - shortcut: "Ctrl+E,Ctrl+W" - onTriggered: edit.wrapMode = TextEdit.Wrap - } - \endcode -*/ -QVariant QQuickPlatformMenuItem::shortcut() const -{ - return m_shortcut; -} - -bool QQuickPlatformMenuItem::event(QEvent *e) -{ -#if QT_CONFIG(shortcut) - if (e->type() == QEvent::Shortcut) { - QShortcutEvent *se = static_cast<QShortcutEvent *>(e); - if (se->shortcutId() == m_shortcutId) { - activate(); - return true; - } - } -#endif - return QObject::event(e); -} - -void QQuickPlatformMenuItem::setShortcut(const QVariant& shortcut) -{ - if (m_shortcut == shortcut) - return; - -#if QT_CONFIG(shortcut) - if (m_shortcutId != -1) { - QKeySequence sequence; - if (m_shortcut.metaType().id() == QMetaType::Int) - sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt())); - else - sequence = QKeySequence::fromString(m_shortcut.toString()); - QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_shortcutId, this, sequence); - } -#endif - m_shortcut = shortcut; - sync(); -#if QT_CONFIG(shortcut) - QKeySequence sequence; - if (m_shortcut.metaType().id() == QMetaType::Int) - sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt())); - else - sequence = QKeySequence::fromString(m_shortcut.toString()); - if (!sequence.isEmpty()) { - m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, - Qt::WindowShortcut, QQuickShortcutContext::matcher); - } else { - m_shortcutId = -1; - } -#endif - emit shortcutChanged(); -} - -/*! - \qmlproperty font Qt.labs.platform::MenuItem::font - - This property holds the menu item's font. - - \sa text -*/ -QFont QQuickPlatformMenuItem::font() const -{ - return m_font; -} - -void QQuickPlatformMenuItem::setFont(const QFont& font) -{ - if (m_font == font) - return; - - m_font = font; - sync(); - emit fontChanged(); -} - -/*! - \since Qt.labs.platform 1.1 (Qt 5.12) - \qmlproperty url Qt.labs.platform::MenuItem::icon.source - \qmlproperty string Qt.labs.platform::MenuItem::icon.name - \qmlproperty bool Qt.labs.platform::MenuItem::icon.mask - - This property holds the menu item's icon. - - \code - MenuItem { - icon.mask: true - icon.name: "edit-undo" - icon.source: "qrc:/images/undo.png" - } - \endcode - - \sa QIcon::fromTheme() -*/ -QQuickPlatformIcon QQuickPlatformMenuItem::icon() const -{ - if (!m_iconLoader) - return QQuickPlatformIcon(); - - return m_iconLoader->icon(); -} - -void QQuickPlatformMenuItem::setIcon(const QQuickPlatformIcon &icon) -{ - if (iconLoader()->icon() == icon) - return; - - iconLoader()->setIcon(icon); - emit iconChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuItem::toggle() - - Toggles the \l checked state to its opposite state. -*/ -void QQuickPlatformMenuItem::toggle() -{ - if (m_checkable) - setChecked(!m_checked); -} - -void QQuickPlatformMenuItem::classBegin() -{ -} - -void QQuickPlatformMenuItem::componentComplete() -{ - if (m_handle && m_iconLoader) - m_iconLoader->setEnabled(true); - m_complete = true; - sync(); -} - -QQuickPlatformIconLoader *QQuickPlatformMenuItem::iconLoader() const -{ - if (!m_iconLoader) { - QQuickPlatformMenuItem *that = const_cast<QQuickPlatformMenuItem *>(this); - static int slot = staticMetaObject.indexOfSlot("updateIcon()"); - m_iconLoader = new QQuickPlatformIconLoader(slot, that); - m_iconLoader->setEnabled(m_complete); - } - return m_iconLoader; -} - -void QQuickPlatformMenuItem::activate() -{ - toggle(); - emit triggered(); -} - -void QQuickPlatformMenuItem::updateIcon() -{ - if (!m_handle || !m_iconLoader) - return; - - m_handle->setIcon(m_iconLoader->toQIcon()); - sync(); -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformmenuitem_p.cpp" diff --git a/src/labs/platform/qquickplatformmenuitem_p.h b/src/labs/platform/qquickplatformmenuitem_p.h deleted file mode 100644 index 01b7482d..00000000 --- a/src/labs/platform/qquickplatformmenuitem_p.h +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMMENUITEM_P_H -#define QQUICKPLATFORMMENUITEM_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 <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtGui/qfont.h> -#include <QtGui/qpa/qplatformmenu.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQml/qqml.h> - -#include "qquickplatformicon_p.h" - -QT_BEGIN_NAMESPACE - -class QPlatformMenuItem; -class QQuickPlatformMenu; -class QQuickPlatformIconLoader; -class QQuickPlatformMenuItemGroup; - -class QQuickPlatformMenuItem : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQuickPlatformMenu *menu READ menu NOTIFY menuChanged FINAL) - Q_PROPERTY(QQuickPlatformMenu *subMenu READ subMenu NOTIFY subMenuChanged FINAL) - Q_PROPERTY(QQuickPlatformMenuItemGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator NOTIFY separatorChanged FINAL) - Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) - Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) - Q_PROPERTY(QPlatformMenuItem::MenuRole role READ role WRITE setRole NOTIFY roleChanged FINAL) - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) - Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) - Q_PROPERTY(QQuickPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) - Q_ENUMS(QPlatformMenuItem::MenuRole) - -public: - explicit QQuickPlatformMenuItem(QObject *parent = nullptr); - ~QQuickPlatformMenuItem(); - - QPlatformMenuItem *handle() const; - QPlatformMenuItem *create(); - void sync(); - - QQuickPlatformMenu *menu() const; - void setMenu(QQuickPlatformMenu* menu); - - QQuickPlatformMenu *subMenu() const; - void setSubMenu(QQuickPlatformMenu *menu); - - QQuickPlatformMenuItemGroup *group() const; - void setGroup(QQuickPlatformMenuItemGroup *group); - - bool isEnabled() const; - void setEnabled(bool enabled); - - bool isVisible() const; - void setVisible(bool visible); - - bool isSeparator() const; - void setSeparator(bool separator); - - bool isCheckable() const; - void setCheckable(bool checkable); - - bool isChecked() const; - void setChecked(bool checked); - - QPlatformMenuItem::MenuRole role() const; - void setRole(QPlatformMenuItem::MenuRole role); - - QString text() const; - void setText(const QString &text); - - QVariant shortcut() const; - void setShortcut(const QVariant& shortcut); - - QFont font() const; - void setFont(const QFont &font); - - QQuickPlatformIcon icon() const; - void setIcon(const QQuickPlatformIcon &icon); - -public Q_SLOTS: - void toggle(); - -Q_SIGNALS: - void triggered(); - void hovered(); - - void menuChanged(); - void subMenuChanged(); - void groupChanged(); - void enabledChanged(); - void visibleChanged(); - void separatorChanged(); - void checkableChanged(); - void checkedChanged(); - void roleChanged(); - void textChanged(); - void shortcutChanged(); - void fontChanged(); - Q_REVISION(2, 1) void iconChanged(); - -protected: - void classBegin() override; - void componentComplete() override; - - QQuickPlatformIconLoader *iconLoader() const; - - bool event(QEvent *e) override; -private Q_SLOTS: - void activate(); - void updateIcon(); - -private: - bool m_complete; - bool m_enabled; - bool m_visible; - bool m_separator; - bool m_checkable; - bool m_checked; - QPlatformMenuItem::MenuRole m_role; - QString m_text; - QVariant m_shortcut; - QFont m_font; - QQuickPlatformMenu *m_menu; - QQuickPlatformMenu *m_subMenu; - QQuickPlatformMenuItemGroup *m_group; - mutable QQuickPlatformIconLoader *m_iconLoader; - QPlatformMenuItem *m_handle; - int m_shortcutId = -1; - - friend class QQuickPlatformMenu; - friend class QQuickPlatformMenuItemGroup; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMenuItem) - -#endif // QQUICKPLATFORMMENUITEM_P_H diff --git a/src/labs/platform/qquickplatformmenuitemgroup.cpp b/src/labs/platform/qquickplatformmenuitemgroup.cpp deleted file mode 100644 index fcfcc664..00000000 --- a/src/labs/platform/qquickplatformmenuitemgroup.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Templates 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 "qquickplatformmenuitemgroup_p.h" -#include "qquickplatformmenuitem_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MenuItemGroup - \inherits QtObject -//! \instantiates QQuickPlatformMenuItemGroup - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A group for managing native menu items. - - The MenuItemGroup groups native menu items together. - - MenuItemGroup is exclusive by default. In an exclusive menu item - group, only one item can be checked at any time; checking another - item automatically unchecks the previously checked one. MenuItemGroup - can be configured as non-exclusive, which is particularly useful for - showing, hiding, enabling and disabling items together as a group. - - The most straight-forward way to use MenuItemGroup is to assign - a list of items. - - \code - Menu { - id: verticalMenu - title: qsTr("Vertical") - - MenuItemGroup { - id: verticalGroup - items: verticalMenu.items - } - - MenuItem { text: qsTr("Top"); checkable: true } - MenuItem { text: qsTr("Center"); checked: true } - MenuItem { text: qsTr("Bottom"); checkable: true } - } - \endcode - - The same menu may sometimes contain items that should not be included - in the same exclusive group. Such cases are best handled using the - \l {MenuItem::group}{group} property. - - \code - Menu { - id: horizontalMenu - title: qsTr("Horizontal") - - MenuItemGroup { - id: horizontalGroup - } - - MenuItem { - checked: true - text: qsTr("Left") - group: horizontalGroup - } - MenuItem { - checkable: true - text: qsTr("Center") - group: horizontalGroup - } - MenuItem { - text: qsTr("Right") - checkable: true - group: horizontalGroup - } - - MenuItem { separator: true } - MenuItem { text: qsTr("Justify"); checkable: true } - MenuItem { text: qsTr("Absolute"); checkable: true } - } - \endcode - - More advanced use cases can be handled using the addItem() and - removeItem() methods. - - \labs - - \sa MenuItem -*/ - -/*! - \qmlsignal Qt.labs.platform::MenuItemGroup::triggered(MenuItem item) - - This signal is emitted when an \a item in the group is triggered by the user. - - \sa MenuItem::triggered() -*/ - -/*! - \qmlsignal Qt.labs.platform::MenuItemGroup::hovered(MenuItem item) - - This signal is emitted when an \a item in the group is hovered by the user. - - \sa MenuItem::hovered() -*/ - -QQuickPlatformMenuItemGroup::QQuickPlatformMenuItemGroup(QObject *parent) - : QObject(parent), m_enabled(true), m_visible(true), m_exclusive(true), m_checkedItem(nullptr) -{ -} - -QQuickPlatformMenuItemGroup::~QQuickPlatformMenuItemGroup() -{ - clear(); -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItemGroup::enabled - - This property holds whether the group is enabled. The default value is \c true. - - The enabled state of the group affects the enabled state of each item in the group, - except that explicitly disabled items are not enabled even if the group is enabled. -*/ -bool QQuickPlatformMenuItemGroup::isEnabled() const -{ - return m_enabled; -} - -void QQuickPlatformMenuItemGroup::setEnabled(bool enabled) -{ - if (m_enabled == enabled) - return; - - m_enabled = enabled; - emit enabledChanged(); - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) { - if (item->m_enabled) { - item->sync(); - emit item->enabledChanged(); - } - } -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItemGroup::visible - - This property holds whether the group is visible. The default value is \c true. - - The visibility of the group affects the visibility of each item in the group, - except that explicitly hidden items are not visible even if the group is visible. -*/ -bool QQuickPlatformMenuItemGroup::isVisible() const -{ - return m_visible; -} - -void QQuickPlatformMenuItemGroup::setVisible(bool visible) -{ - if (m_visible == visible) - return; - - m_visible = visible; - emit visibleChanged(); - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) { - if (item->m_visible) { - item->sync(); - emit item->visibleChanged(); - } - } -} - -/*! - \qmlproperty bool Qt.labs.platform::MenuItemGroup::exclusive - - This property holds whether the group is exclusive. The default value is \c true. - - In an exclusive menu item group, only one item can be checked at any time; - checking another item automatically unchecks the previously checked one. -*/ -bool QQuickPlatformMenuItemGroup::isExclusive() const -{ - return m_exclusive; -} - -void QQuickPlatformMenuItemGroup::setExclusive(bool exclusive) -{ - if (m_exclusive == exclusive) - return; - - m_exclusive = exclusive; - emit exclusiveChanged(); - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) - item->sync(); -} - -/*! - \qmlproperty MenuItem Qt.labs.platform::MenuItemGroup::checkedItem - - This property holds the currently checked item in the group, or \c null if no item is checked. -*/ -QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::checkedItem() const -{ - return m_checkedItem; -} - -void QQuickPlatformMenuItemGroup::setCheckedItem(QQuickPlatformMenuItem *item) -{ - if (m_checkedItem == item) - return; - - if (m_checkedItem) - m_checkedItem->setChecked(false); - - m_checkedItem = item; - emit checkedItemChanged(); - - if (item) - item->setChecked(true); -} - -/*! - \qmlproperty list<MenuItem> Qt.labs.platform::MenuItemGroup::items - - This property holds the list of items in the group. -*/ -QQmlListProperty<QQuickPlatformMenuItem> QQuickPlatformMenuItemGroup::items() -{ - return QQmlListProperty<QQuickPlatformMenuItem>(this, nullptr, items_append, items_count, items_at, items_clear); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuItemGroup::addItem(MenuItem item) - - Adds an \a item to the group. -*/ -void QQuickPlatformMenuItemGroup::addItem(QQuickPlatformMenuItem *item) -{ - if (!item || m_items.contains(item)) - return; - - m_items.append(item); - item->setGroup(this); - - connect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent); - connect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem); - connect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem); - - if (m_exclusive && item->isChecked()) - setCheckedItem(item); - - emit itemsChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuItemGroup::removeItem(MenuItem item) - - Removes an \a item from the group. -*/ -void QQuickPlatformMenuItemGroup::removeItem(QQuickPlatformMenuItem *item) -{ - if (!item || !m_items.contains(item)) - return; - - m_items.removeOne(item); - item->setGroup(nullptr); - - disconnect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent); - disconnect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem); - disconnect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem); - - if (m_checkedItem == item) - setCheckedItem(nullptr); - - emit itemsChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::MenuItemGroup::clear() - - Removes all items from the group. -*/ -void QQuickPlatformMenuItemGroup::clear() -{ - if (m_items.isEmpty()) - return; - - for (QQuickPlatformMenuItem *item : qAsConst(m_items)) { - item->setGroup(nullptr); - disconnect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent); - disconnect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem); - disconnect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem); - } - - setCheckedItem(nullptr); - - m_items.clear(); - emit itemsChanged(); -} - -QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::findCurrent() const -{ - for (QQuickPlatformMenuItem *item : m_items) { - if (item->isChecked()) - return item; - } - return nullptr; -} - -void QQuickPlatformMenuItemGroup::updateCurrent() -{ - if (!m_exclusive) - return; - - QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender()); - if (item && item->isChecked()) - setCheckedItem(item); -} - -void QQuickPlatformMenuItemGroup::activateItem() -{ - QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender()); - if (item) - emit triggered(item); -} - -void QQuickPlatformMenuItemGroup::hoverItem() -{ - QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender()); - if (item) - emit hovered(item); -} - -void QQuickPlatformMenuItemGroup::items_append(QQmlListProperty<QQuickPlatformMenuItem> *prop, QQuickPlatformMenuItem *item) -{ - QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object); - group->addItem(item); -} - -qsizetype QQuickPlatformMenuItemGroup::items_count(QQmlListProperty<QQuickPlatformMenuItem> *prop) -{ - QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object); - return group->m_items.count(); -} - -QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::items_at(QQmlListProperty<QQuickPlatformMenuItem> *prop, qsizetype index) -{ - QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object); - return group->m_items.value(index); -} - -void QQuickPlatformMenuItemGroup::items_clear(QQmlListProperty<QQuickPlatformMenuItem> *prop) -{ - QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object); - group->clear(); -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformmenuitemgroup_p.cpp" diff --git a/src/labs/platform/qquickplatformmenuitemgroup_p.h b/src/labs/platform/qquickplatformmenuitemgroup_p.h deleted file mode 100644 index 7407d266..00000000 --- a/src/labs/platform/qquickplatformmenuitemgroup_p.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Templates 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 QQUICKPLATFORMMENUITEMGROUP_P_H -#define QQUICKPLATFORMMENUITEMGROUP_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 <QtCore/qobject.h> -#include <QtCore/qlist.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformMenuItem; -class QQuickPlatformMenuItemGroupPrivate; - -class QQuickPlatformMenuItemGroup : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL) - Q_PROPERTY(QQuickPlatformMenuItem *checkedItem READ checkedItem WRITE setCheckedItem NOTIFY checkedItemChanged FINAL) - Q_PROPERTY(QQmlListProperty<QQuickPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL) - -public: - explicit QQuickPlatformMenuItemGroup(QObject *parent = nullptr); - ~QQuickPlatformMenuItemGroup(); - - bool isEnabled() const; - void setEnabled(bool enabled); - - bool isVisible() const; - void setVisible(bool visible); - - bool isExclusive() const; - void setExclusive(bool exclusive); - - QQuickPlatformMenuItem *checkedItem() const; - void setCheckedItem(QQuickPlatformMenuItem *item); - - QQmlListProperty<QQuickPlatformMenuItem> items(); - - Q_INVOKABLE void addItem(QQuickPlatformMenuItem *item); - Q_INVOKABLE void removeItem(QQuickPlatformMenuItem *item); - Q_INVOKABLE void clear(); - -Q_SIGNALS: - void triggered(QQuickPlatformMenuItem *item); - void hovered(QQuickPlatformMenuItem *item); - - void enabledChanged(); - void visibleChanged(); - void exclusiveChanged(); - void checkedItemChanged(); - void itemsChanged(); - -private: - QQuickPlatformMenuItem *findCurrent() const; - void updateCurrent(); - void activateItem(); - void hoverItem(); - - static void items_append(QQmlListProperty<QQuickPlatformMenuItem> *prop, QQuickPlatformMenuItem *obj); - static qsizetype items_count(QQmlListProperty<QQuickPlatformMenuItem> *prop); - static QQuickPlatformMenuItem *items_at(QQmlListProperty<QQuickPlatformMenuItem> *prop, qsizetype index); - static void items_clear(QQmlListProperty<QQuickPlatformMenuItem> *prop); - - bool m_enabled; - bool m_visible; - bool m_exclusive; - QQuickPlatformMenuItem *m_checkedItem; - QList<QQuickPlatformMenuItem*> m_items; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMenuItemGroup) - -#endif // QQUICKPLATFORMMENUITEMGROUP_P_H diff --git a/src/labs/platform/qquickplatformmenuseparator.cpp b/src/labs/platform/qquickplatformmenuseparator.cpp deleted file mode 100644 index f29d5b9e..00000000 --- a/src/labs/platform/qquickplatformmenuseparator.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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/labs/platform/qquickplatformmenuseparator_p.h b/src/labs/platform/qquickplatformmenuseparator_p.h deleted file mode 100644 index 9fe973c5..00000000 --- a/src/labs/platform/qquickplatformmenuseparator_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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/labs/platform/qquickplatformmessagedialog.cpp b/src/labs/platform/qquickplatformmessagedialog.cpp deleted file mode 100644 index f2e0970c..00000000 --- a/src/labs/platform/qquickplatformmessagedialog.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformmessagedialog_p.h" - -#include <QtQml/qqmlinfo.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MessageDialog - \inherits Dialog -//! \instantiates QQuickPlatformMessageDialog - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A native message dialog. - - The MessageDialog type provides a QML API for native platform message dialogs. - - \image qtlabsplatform-messagedialog-android.png - - A message dialog is used to inform the user, or ask the user a question. - A message dialog displays a primary \l text to alert the user to a situation, - an \l {informativeText}{informative text} to further explain the alert or to - ask the user a question, and an optional \l {detailedText}{detailed text} to - provide even more data if the user requests it. A message box can also display - a configurable set of \l buttons for accepting a user response. - - To show a message dialog, construct an instance of MessageDialog, set the - desired properties, and call \l {Dialog::}{open()}. - - \code - MessageDialog { - buttons: MessageDialog.Ok - text: "The document has been modified." - } - \endcode - - The user must click the \uicontrol OK button to dismiss the message dialog. - A modal message dialog blocks the rest of the GUI until the message is - dismissed. - - A more elaborate approach than just alerting the user to an event is to - also ask the user what to do about it. Store the question in the - \l {informativeText}{informative text} property, and specify the \l buttons - property to the set of buttons you want as the set of user responses. The - buttons are specified by combining values using the bitwise OR operator. The - display order for the buttons is platform dependent. - - \code - MessageDialog { - text: "The document has been modified." - informativeText: "Do you want to save your changes?" - buttons: MessageDialog.Ok | MessageDialog.Cancel - - onAccepted: document.save() - } - \endcode - - \image qtlabsplatform-messagedialog-informative-android.png - - The \l clicked() signal passes the information of which button was clicked. - - A native platform message dialog is currently available on the following platforms: - - \list - \li iOS - \li Android - \endlist - - \input includes/widgets.qdocinc 1 - - \labs -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::clicked(button) - - This signal is emitted when a dialog \a button is clicked. - - \sa buttons -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::okClicked() - - This signal is emitted when \uicontrol Ok is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::saveClicked() - - This signal is emitted when \uicontrol Save is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::saveAllClicked() - - This signal is emitted when \uicontrol {Save All} is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::openClicked() - - This signal is emitted when \uicontrol Open is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::yesClicked() - - This signal is emitted when \uicontrol Yes is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::yesToAllClicked() - - This signal is emitted when \uicontrol {Yes To All} is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::noClicked() - - This signal is emitted when \uicontrol No is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::noToAllClicked() - - This signal is emitted when \uicontrol {No To All} is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::abortClicked() - - This signal is emitted when \uicontrol Abort is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::retryClicked() - - This signal is emitted when \uicontrol Retry is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::ignoreClicked() - - This signal is emitted when \uicontrol Ignore is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::closeClicked() - - This signal is emitted when \uicontrol Close is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::cancelClicked() - - This signal is emitted when \uicontrol Cancel is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::discardClicked() - - This signal is emitted when \uicontrol Discard is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::helpClicked() - - This signal is emitted when \uicontrol Help is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::applyClicked() - - This signal is emitted when \uicontrol Apply is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::resetClicked() - - This signal is emitted when \uicontrol Reset is clicked. -*/ - -/*! - \qmlsignal Qt.labs.platform::MessageDialog::restoreDefaultsClicked() - - This signal is emitted when \uicontrol {Restore Defaults} is clicked. -*/ - -QQuickPlatformMessageDialog::QQuickPlatformMessageDialog(QObject *parent) - : QQuickPlatformDialog(QPlatformTheme::MessageDialog, parent), - m_options(QMessageDialogOptions::create()) -{ -} - -/*! - \qmlproperty string Qt.labs.platform::MessageDialog::text - - This property holds the text to be displayed on the message dialog. - - \sa informativeText, detailedText -*/ -QString QQuickPlatformMessageDialog::text() const -{ - return m_options->text(); -} - -void QQuickPlatformMessageDialog::setText(const QString &text) -{ - if (m_options->text() == text) - return; - - m_options->setText(text); - emit textChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::MessageDialog::informativeText - - This property holds the informative text that provides a fuller description for the message. - - Informative text can be used to expand upon the \l text to give more information to the user. - - \sa text, detailedText -*/ -QString QQuickPlatformMessageDialog::informativeText() const -{ - return m_options->informativeText(); -} - -void QQuickPlatformMessageDialog::setInformativeText(const QString &text) -{ - if (m_options->informativeText() == text) - return; - - m_options->setInformativeText(text); - emit informativeTextChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::MessageDialog::detailedText - - This property holds the text to be displayed in the details area. - - \sa text, informativeText -*/ -QString QQuickPlatformMessageDialog::detailedText() const -{ - return m_options->detailedText(); -} - -void QQuickPlatformMessageDialog::setDetailedText(const QString &text) -{ - if (m_options->detailedText() == text) - return; - - m_options->setDetailedText(text); - emit detailedTextChanged(); -} - -/*! - \qmlproperty flags Qt.labs.platform::MessageDialog::buttons - - This property holds a combination of buttons that are used by the message dialog. - The default value is \c MessageDialog.NoButton. - - Possible flags: - \value MessageDialog.Ok An "OK" button defined with the \c AcceptRole. - \value MessageDialog.Open An "Open" button defined with the \c AcceptRole. - \value MessageDialog.Save A "Save" button defined with the \c AcceptRole. - \value MessageDialog.Cancel A "Cancel" button defined with the \c RejectRole. - \value MessageDialog.Close A "Close" button defined with the \c RejectRole. - \value MessageDialog.Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the \c DestructiveRole. - \value MessageDialog.Apply An "Apply" button defined with the \c ApplyRole. - \value MessageDialog.Reset A "Reset" button defined with the \c ResetRole. - \value MessageDialog.RestoreDefaults A "Restore Defaults" button defined with the \c ResetRole. - \value MessageDialog.Help A "Help" button defined with the \c HelpRole. - \value MessageDialog.SaveAll A "Save All" button defined with the \c AcceptRole. - \value MessageDialog.Yes A "Yes" button defined with the \c YesRole. - \value MessageDialog.YesToAll A "Yes to All" button defined with the \c YesRole. - \value MessageDialog.No A "No" button defined with the \c NoRole. - \value MessageDialog.NoToAll A "No to All" button defined with the \c NoRole. - \value MessageDialog.Abort An "Abort" button defined with the \c RejectRole. - \value MessageDialog.Retry A "Retry" button defined with the \c AcceptRole. - \value MessageDialog.Ignore An "Ignore" button defined with the \c AcceptRole. - \value MessageDialog.NoButton The dialog has no buttons. - - \sa clicked() -*/ -QPlatformDialogHelper::StandardButtons QQuickPlatformMessageDialog::buttons() const -{ - return m_options->standardButtons(); -} - -void QQuickPlatformMessageDialog::setButtons(QPlatformDialogHelper::StandardButtons buttons) -{ - if (m_options->standardButtons() == buttons) - return; - - m_options->setStandardButtons(buttons); - emit buttonsChanged(); -} - -void QQuickPlatformMessageDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformMessageDialogHelper *messageDialog = qobject_cast<QPlatformMessageDialogHelper *>(dialog)) { - connect(messageDialog, &QPlatformMessageDialogHelper::clicked, this, &QQuickPlatformMessageDialog::handleClick); - messageDialog->setOptions(m_options); - } -} - -void QQuickPlatformMessageDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformMessageDialogHelper *messageDialog = qobject_cast<QPlatformMessageDialogHelper *>(dialog)) - messageDialog->setOptions(m_options); -} - -void QQuickPlatformMessageDialog::handleClick(QPlatformDialogHelper::StandardButton button) -{ - done(button); - emit clicked(button); - - switch (button) { - case QPlatformDialogHelper::Ok: emit okClicked(); break; - case QPlatformDialogHelper::Save: emit saveClicked(); break; - case QPlatformDialogHelper::SaveAll: emit saveAllClicked(); break; - case QPlatformDialogHelper::Open: emit openClicked(); break; - case QPlatformDialogHelper::Yes: emit yesClicked(); break; - case QPlatformDialogHelper::YesToAll: emit yesToAllClicked(); break; - case QPlatformDialogHelper::No: emit noClicked(); break; - case QPlatformDialogHelper::NoToAll: emit noToAllClicked(); break; - case QPlatformDialogHelper::Abort: emit abortClicked(); break; - case QPlatformDialogHelper::Retry: emit retryClicked(); break; - case QPlatformDialogHelper::Ignore: emit ignoreClicked(); break; - case QPlatformDialogHelper::Close: emit closeClicked(); break; - case QPlatformDialogHelper::Cancel: emit cancelClicked(); break; - case QPlatformDialogHelper::Discard: emit discardClicked(); break; - case QPlatformDialogHelper::Help: emit helpClicked(); break; - case QPlatformDialogHelper::Apply: emit applyClicked(); break; - case QPlatformDialogHelper::Reset: emit resetClicked(); break; - case QPlatformDialogHelper::RestoreDefaults: emit restoreDefaultsClicked(); break; - default: qmlWarning(this) << "unknown button" << int(button); break; - } -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformmessagedialog_p.h b/src/labs/platform/qquickplatformmessagedialog_p.h deleted file mode 100644 index 9434a927..00000000 --- a/src/labs/platform/qquickplatformmessagedialog_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMMESSAGEDIALOG_P_H -#define QQUICKPLATFORMMESSAGEDIALOG_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 "qquickplatformdialog_p.h" -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQuickPlatformMessageDialog : public QQuickPlatformDialog -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) - Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged FINAL) - Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged FINAL) - Q_PROPERTY(QPlatformDialogHelper::StandardButtons buttons READ buttons WRITE setButtons NOTIFY buttonsChanged FINAL) - Q_FLAGS(QPlatformDialogHelper::StandardButtons) - -public: - explicit QQuickPlatformMessageDialog(QObject *parent = nullptr); - - QString text() const; - void setText(const QString &text); - - QString informativeText() const; - void setInformativeText(const QString &text); - - QString detailedText() const; - void setDetailedText(const QString &text); - - QPlatformDialogHelper::StandardButtons buttons() const; - void setButtons(QPlatformDialogHelper::StandardButtons buttons); - -Q_SIGNALS: - void textChanged(); - void informativeTextChanged(); - void detailedTextChanged(); - void buttonsChanged(); - void clicked(QPlatformDialogHelper::StandardButton button); - - void okClicked(); - void saveClicked(); - void saveAllClicked(); - void openClicked(); - void yesClicked(); - void yesToAllClicked(); - void noClicked(); - void noToAllClicked(); - void abortClicked(); - void retryClicked(); - void ignoreClicked(); - void closeClicked(); - void cancelClicked(); - void discardClicked(); - void helpClicked(); - void applyClicked(); - void resetClicked(); - void restoreDefaultsClicked(); - -protected: - void onCreate(QPlatformDialogHelper *dialog) override; - void onShow(QPlatformDialogHelper *dialog) override; - -private Q_SLOTS: - void handleClick(QPlatformDialogHelper::StandardButton button); - -private: - QSharedPointer<QMessageDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMessageDialog) - -#endif // QQUICKPLATFORMMESSAGEDIALOG_P_H diff --git a/src/labs/platform/qquickplatformstandardpaths.cpp b/src/labs/platform/qquickplatformstandardpaths.cpp deleted file mode 100644 index a6fff1c0..00000000 --- a/src/labs/platform/qquickplatformstandardpaths.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Platform module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickplatformstandardpaths_p.h" - -#include <QtQml/qqmlengine.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype StandardPaths - \inherits QtObject -//! \instantiates QQuickPlatformStandardPaths - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief Provides access to the standard system paths. - - The StandardPaths singleton type provides methods for querying the standard - system paths. The standard paths are mostly useful in conjunction with the - FileDialog and FolderDialog types. - - \qml - FileDialog { - folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) - } - \endqml - - \labs - - \sa FileDialog, FolderDialog, QStandardPaths -*/ - -static QList<QUrl> toUrlList(const QStringList &paths) -{ - QList<QUrl> urls; - urls.reserve(paths.size()); - for (const QString &path : paths) - urls += QUrl::fromLocalFile(path); - return urls; -} - -QQuickPlatformStandardPaths::QQuickPlatformStandardPaths(QObject *parent) - : QObject(parent) -{ -} - -QObject *QQuickPlatformStandardPaths::create(QQmlEngine *engine, QJSEngine *scriptEngine) -{ - Q_UNUSED(scriptEngine); - return new QQuickPlatformStandardPaths(engine); -} - -/*! - \qmlmethod string Qt.labs.platform::StandardPaths::displayName(StandardLocation type) - - \include standardpath/functiondocs.qdocinc displayName - - \sa QStandardPaths::displayName() -*/ -QString QQuickPlatformStandardPaths::displayName(QStandardPaths::StandardLocation type) -{ - return QStandardPaths::displayName(type); -} - -/*! - \qmlmethod url Qt.labs.platform::StandardPaths::findExecutable(string executableName, list<string> paths) - - \include standardpath/functiondocs.qdocinc findExecutable - - \sa QStandardPaths::findExecutable() -*/ -QUrl QQuickPlatformStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) -{ - return QUrl::fromLocalFile(QStandardPaths::findExecutable(executableName, paths)); -} - -/*! - \qmlmethod url Qt.labs.platform::StandardPaths::locate(StandardLocation type, string fileName, LocateOptions options) - - \include standardpath/functiondocs.qdocinc locate - - \sa QStandardPaths::locate() -*/ -QUrl QQuickPlatformStandardPaths::locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options) -{ - return QUrl::fromLocalFile(QStandardPaths::locate(type, fileName, options)); -} - -/*! - \qmlmethod list<url> Qt.labs.platform::StandardPaths::locateAll(StandardLocation type, string fileName, LocateOptions options) - - \include standardpath/functiondocs.qdocinc locateAll - - \sa QStandardPaths::locateAll() -*/ -QList<QUrl> QQuickPlatformStandardPaths::locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options) -{ - return toUrlList(QStandardPaths::locateAll(type, fileName, options)); -} - -/*! - \qmlmethod void Qt.labs.platform::StandardPaths::setTestModeEnabled(bool testMode) - - \include standardpath/functiondocs.qdocinc setTestModeEnabled - - \sa QStandardPaths::setTestModeEnabled() -*/ -void QQuickPlatformStandardPaths::setTestModeEnabled(bool testMode) -{ - QStandardPaths::setTestModeEnabled(testMode); -} - -/*! - \qmlmethod list<url> Qt.labs.platform::StandardPaths::standardLocations(StandardLocation type) - - \include standardpath/functiondocs.qdocinc standardLocations - - \sa QStandardPaths::standardLocations() -*/ -QList<QUrl> QQuickPlatformStandardPaths::standardLocations(QStandardPaths::StandardLocation type) -{ - return toUrlList(QStandardPaths::standardLocations(type)); -} - -/*! - \qmlmethod url Qt.labs.platform::StandardPaths::writableLocation(StandardLocation type) - - \include standardpath/functiondocs.qdocinc writableLocation - - \sa QStandardPaths::writableLocation() -*/ -QUrl QQuickPlatformStandardPaths::writableLocation(QStandardPaths::StandardLocation type) -{ - return QUrl::fromLocalFile(QStandardPaths::writableLocation(type)); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/qquickplatformstandardpaths_p.h b/src/labs/platform/qquickplatformstandardpaths_p.h deleted file mode 100644 index e2f4e11e..00000000 --- a/src/labs/platform/qquickplatformstandardpaths_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Platform module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKPLATFORMSTANDARDPATHS_P_H -#define QQUICKPLATFORMSTANDARDPATHS_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 <QtCore/qobject.h> -#include <QtCore/qstandardpaths.h> -#include <QtCore/qurl.h> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class QQmlEngine; -class QJSEngine; - -class QQuickPlatformStandardPaths : public QObject -{ - Q_OBJECT - Q_ENUMS(QStandardPaths::StandardLocation QStandardPaths::LocateOptions) - -public: - explicit QQuickPlatformStandardPaths(QObject *parent = nullptr); - - static QObject *create(QQmlEngine *engine, QJSEngine *scriptEngine); - - Q_INVOKABLE static QString displayName(QStandardPaths::StandardLocation type); - Q_INVOKABLE static QUrl findExecutable(const QString &executableName, const QStringList &paths = QStringList()); - Q_INVOKABLE static QUrl locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); - Q_INVOKABLE static QList<QUrl> locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); - Q_INVOKABLE static void setTestModeEnabled(bool testMode); - Q_INVOKABLE static QList<QUrl> standardLocations(QStandardPaths::StandardLocation type); - Q_INVOKABLE static QUrl writableLocation(QStandardPaths::StandardLocation type); - -private: - Q_DISABLE_COPY(QQuickPlatformStandardPaths) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformStandardPaths) -Q_DECLARE_METATYPE(QStandardPaths::StandardLocation) -Q_DECLARE_METATYPE(QStandardPaths::LocateOptions) - -#endif // QQUICKPLATFORMSTANDARDPATHS_P_H diff --git a/src/labs/platform/qquickplatformsystemtrayicon.cpp b/src/labs/platform/qquickplatformsystemtrayicon.cpp deleted file mode 100644 index b97e379f..00000000 --- a/src/labs/platform/qquickplatformsystemtrayicon.cpp +++ /dev/null @@ -1,443 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qquickplatformsystemtrayicon_p.h" -#include "qquickplatformmenu_p.h" -#include "qquickplatformiconloader_p.h" - -#include <QtCore/qloggingcategory.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/private/qguiapplication_p.h> - -#include "widgets/qwidgetplatform_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype SystemTrayIcon - \inherits QtObject -//! \instantiates QQuickPlatformSystemTrayIcon - \inqmlmodule Qt.labs.platform - \since 5.8 - \brief A system tray icon. - - The SystemTrayIcon type provides an icon for an application in the system tray. - - Many desktop platforms provide a special system tray or notification area, - where applications can display icons and notification messages. - - \image qtlabsplatform-systemtrayicon.png - - The following example shows how to create a system tray icon, and how to make - use of the \l activated() signal: - - \code - SystemTrayIcon { - visible: true - icon.source: "qrc:/images/tray-icon.png" - - onActivated: { - window.show() - window.raise() - window.requestActivate() - } - } - \endcode - - \section2 Tray menu - - SystemTrayIcon can have a menu that opens when the icon is activated. - - \image qtlabsplatform-systemtrayicon-menu.png - - The following example illustrates how to assign a \l Menu to a system tray icon: - - \code - SystemTrayIcon { - visible: true - icon.source: "qrc:/images/tray-icon.png" - - menu: Menu { - MenuItem { - text: qsTr("Quit") - onTriggered: Qt.quit() - } - } - } - \endcode - - \section2 Notification messages - - SystemTrayIcon can display notification messages. - - \image qtlabsplatform-systemtrayicon-message.png - - The following example presents how to show a notification message using - \l showMessage(), and how to make use of the \l messageClicked() signal: - - \code - SystemTrayIcon { - visible: true - icon.source: "qrc:/images/tray-icon.png" - - onMessageClicked: console.log("Message clicked") - Component.onCompleted: showMessage("Message title", "Something important came up. Click this to know more.") - } - \endcode - - \section2 Availability - - A native system tray icon is currently \l available on the following platforms: - - \list - \li All window managers and independent tray implementations for X11 that implement the - \l{http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html} - {freedesktop.org XEmbed system tray specification}. - \li All desktop environments that implement the - \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem} - {freedesktop.org D-Bus StatusNotifierItem specification}, including recent versions of KDE and Unity. - \li All supported versions of macOS. Note that the Growl notification system must be installed - for showMessage() to display messages on OS X prior to 10.8 (Mountain Lion). - \endlist - - \input includes/widgets.qdocinc 1 - - \labs - - \sa Menu -*/ - -/*! - \qmlsignal Qt.labs.platform::SystemTrayIcon::activated(ActivationReason reason) - - This signal is emitted when the system tray icon is activated by the user. The - \a reason argument specifies how the system tray icon was activated. - - Available reasons: - - \value SystemTrayIcon.Unknown Unknown reason - \value SystemTrayIcon.Context The context menu for the system tray icon was requested - \value SystemTrayIcon.DoubleClick The system tray icon was double clicked - \value SystemTrayIcon.Trigger The system tray icon was clicked - \value SystemTrayIcon.MiddleClick The system tray icon was clicked with the middle mouse button -*/ - -/*! - \qmlsignal Qt.labs.platform::SystemTrayIcon::messageClicked() - - This signal is emitted when a notification message is clicked by the user. - - \sa showMessage() -*/ - -Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformTray) - -QQuickPlatformSystemTrayIcon::QQuickPlatformSystemTrayIcon(QObject *parent) - : QObject(parent), - m_complete(false), - m_visible(false), - m_menu(nullptr), - m_iconLoader(nullptr), - m_handle(nullptr) -{ - m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon(); - if (!m_handle) - m_handle = QWidgetPlatform::createSystemTrayIcon(this); - qCDebug(qtLabsPlatformTray) << "SystemTrayIcon ->" << m_handle; - - if (m_handle) { - connect(m_handle, &QPlatformSystemTrayIcon::activated, this, &QQuickPlatformSystemTrayIcon::activated); - connect(m_handle, &QPlatformSystemTrayIcon::messageClicked, this, &QQuickPlatformSystemTrayIcon::messageClicked); - } -} - -QQuickPlatformSystemTrayIcon::~QQuickPlatformSystemTrayIcon() -{ - if (m_menu) - m_menu->setSystemTrayIcon(nullptr); - cleanup(); - delete m_iconLoader; - m_iconLoader = nullptr; - delete m_handle; - m_handle = nullptr; -} - -QPlatformSystemTrayIcon *QQuickPlatformSystemTrayIcon::handle() const -{ - return m_handle; -} - -/*! - \readonly - \qmlproperty bool Qt.labs.platform::SystemTrayIcon::available - - This property holds whether the system tray is available. -*/ -bool QQuickPlatformSystemTrayIcon::isAvailable() const -{ - return m_handle && m_handle->isSystemTrayAvailable(); -} - -/*! - \readonly - \qmlproperty bool Qt.labs.platform::SystemTrayIcon::supportsMessages - - This property holds whether the system tray icon supports notification messages. - - \sa showMessage() -*/ -bool QQuickPlatformSystemTrayIcon::supportsMessages() const -{ - return m_handle && m_handle->supportsMessages(); -} - -/*! - \qmlproperty bool Qt.labs.platform::SystemTrayIcon::visible - - This property holds whether the system tray icon is visible. - - The default value is \c false. -*/ -bool QQuickPlatformSystemTrayIcon::isVisible() const -{ - return m_visible; -} - -void QQuickPlatformSystemTrayIcon::setVisible(bool visible) -{ - if (m_visible == visible) - return; - - if (m_handle && m_complete) { - if (visible) - init(); - else - cleanup(); - } - - m_visible = visible; - emit visibleChanged(); -} - -/*! - \qmlproperty string Qt.labs.platform::SystemTrayIcon::tooltip - - This property holds the tooltip of the system tray icon. -*/ -QString QQuickPlatformSystemTrayIcon::tooltip() const -{ - return m_tooltip; -} - -void QQuickPlatformSystemTrayIcon::setTooltip(const QString &tooltip) -{ - if (m_tooltip == tooltip) - return; - - if (m_handle && m_complete) - m_handle->updateToolTip(tooltip); - - m_tooltip = tooltip; - emit tooltipChanged(); -} - -/*! - \qmlproperty Menu Qt.labs.platform::SystemTrayIcon::menu - - This property holds a menu for the system tray icon. -*/ -QQuickPlatformMenu *QQuickPlatformSystemTrayIcon::menu() const -{ - return m_menu; -} - -void QQuickPlatformSystemTrayIcon::setMenu(QQuickPlatformMenu *menu) -{ - if (m_menu == menu) - return; - - if (m_menu) - m_menu->setSystemTrayIcon(nullptr); - if (menu) { - menu->setSystemTrayIcon(this); - if (m_handle && m_complete && menu->create()) - m_handle->updateMenu(menu->handle()); - } - - m_menu = menu; - emit menuChanged(); -} - -/*! - \since Qt.labs.platform 1.1 (Qt 5.12) - \qmlproperty rect Qt.labs.platform::SystemTrayIcon::geometry - - This property holds the geometry of the system tray icon. -*/ -QRect QQuickPlatformSystemTrayIcon::geometry() const -{ - return m_handle ? m_handle->geometry() : QRect(); -} - -/*! - \since Qt.labs.platform 1.1 (Qt 5.12) - \qmlproperty url Qt.labs.platform::SystemTrayIcon::icon.source - \qmlproperty string Qt.labs.platform::SystemTrayIcon::icon.name - \qmlproperty bool Qt.labs.platform::SystemTrayIcon::icon.mask - - This property holds the system tray icon. - - \code - SystemTrayIcon { - icon.mask: true - icon.source: "qrc:/images/tray-icon.png" - } - \endcode -*/ -QQuickPlatformIcon QQuickPlatformSystemTrayIcon::icon() const -{ - if (!m_iconLoader) - return QQuickPlatformIcon(); - - return m_iconLoader->icon(); -} - -void QQuickPlatformSystemTrayIcon::setIcon(const QQuickPlatformIcon &icon) -{ - if (iconLoader()->icon() == icon) - return; - - iconLoader()->setIcon(icon); - emit iconChanged(); -} - -/*! - \qmlmethod void Qt.labs.platform::SystemTrayIcon::show() - - Shows the system tray icon. -*/ -void QQuickPlatformSystemTrayIcon::show() -{ - setVisible(true); -} - -/*! - \qmlmethod void Qt.labs.platform::SystemTrayIcon::hide() - - Hides the system tray icon. -*/ -void QQuickPlatformSystemTrayIcon::hide() -{ - setVisible(false); -} - -/*! - \qmlmethod void Qt.labs.platform::SystemTrayIcon::showMessage(string title, string message, MessageIcon icon, int msecs) - - Shows a system tray message with the given \a title, \a message and \a icon - for the time specified in \a msecs. - - \note System tray messages are dependent on the system configuration and user preferences, - and may not appear at all. Therefore, it should not be relied upon as the sole means for providing - critical information. - - \sa supportsMessages, messageClicked() -*/ -void QQuickPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, QPlatformSystemTrayIcon::MessageIcon icon, int msecs) -{ - if (m_handle) - m_handle->showMessage(title, msg, QIcon(), icon, msecs); -} - -void QQuickPlatformSystemTrayIcon::init() -{ - if (!m_handle) - return; - - m_handle->init(); - if (m_menu && m_menu->create()) - m_handle->updateMenu(m_menu->handle()); - m_handle->updateToolTip(m_tooltip); - if (m_iconLoader) - m_iconLoader->setEnabled(true); -} - -void QQuickPlatformSystemTrayIcon::cleanup() -{ - if (m_handle) - m_handle->cleanup(); - if (m_iconLoader) - m_iconLoader->setEnabled(false); -} - -void QQuickPlatformSystemTrayIcon::classBegin() -{ -} - -void QQuickPlatformSystemTrayIcon::componentComplete() -{ - m_complete = true; - if (m_visible) - init(); -} - -QQuickPlatformIconLoader *QQuickPlatformSystemTrayIcon::iconLoader() const -{ - if (!m_iconLoader) { - QQuickPlatformSystemTrayIcon *that = const_cast<QQuickPlatformSystemTrayIcon *>(this); - static int slot = staticMetaObject.indexOfSlot("updateIcon()"); - m_iconLoader = new QQuickPlatformIconLoader(slot, that); - m_iconLoader->setEnabled(m_complete); - } - return m_iconLoader; -} - -void QQuickPlatformSystemTrayIcon::updateIcon() -{ - if (!m_handle || !m_iconLoader) - return; - - const QRect oldGeometry = m_handle->geometry(); - - m_handle->updateIcon(m_iconLoader->toQIcon()); - - if (oldGeometry != m_handle->geometry()) - emit geometryChanged(); -} - -QT_END_NAMESPACE - -#include "moc_qquickplatformsystemtrayicon_p.cpp" diff --git a/src/labs/platform/qquickplatformsystemtrayicon_p.h b/src/labs/platform/qquickplatformsystemtrayicon_p.h deleted file mode 100644 index d7cc46c0..00000000 --- a/src/labs/platform/qquickplatformsystemtrayicon_p.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QQUICKPLATFORMSYSTEMTRAYICON_P_H -#define QQUICKPLATFORMSYSTEMTRAYICON_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 <QtCore/qurl.h> -#include <QtCore/qrect.h> -#include <QtGui/qpa/qplatformsystemtrayicon.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQml/qqml.h> - -#include "qquickplatformicon_p.h" - -QT_REQUIRE_CONFIG(systemtrayicon); - -QT_BEGIN_NAMESPACE - -class QQuickPlatformMenu; -class QQuickPlatformIconLoader; - -class QQuickPlatformSystemTrayIcon : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(bool available READ isAvailable CONSTANT FINAL) - Q_PROPERTY(bool supportsMessages READ supportsMessages CONSTANT FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged FINAL) - Q_PROPERTY(QQuickPlatformMenu *menu READ menu WRITE setMenu NOTIFY menuChanged FINAL) - Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged FINAL REVISION(1, 1)) - Q_PROPERTY(QQuickPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) - Q_ENUMS(QPlatformSystemTrayIcon::ActivationReason QPlatformSystemTrayIcon::MessageIcon) - -public: - explicit QQuickPlatformSystemTrayIcon(QObject *parent = nullptr); - ~QQuickPlatformSystemTrayIcon(); - - QPlatformSystemTrayIcon *handle() const; - - bool isAvailable() const; - bool supportsMessages() const; - - bool isVisible() const; - void setVisible(bool visible); - - QString tooltip() const; - void setTooltip(const QString &tooltip); - - QQuickPlatformMenu *menu() const; - void setMenu(QQuickPlatformMenu *menu); - - QRect geometry() const; - - QQuickPlatformIcon icon() const; - void setIcon(const QQuickPlatformIcon &icon); - -public Q_SLOTS: - void show(); - void hide(); - - void showMessage(const QString &title, const QString &message, - QPlatformSystemTrayIcon::MessageIcon iconType = QPlatformSystemTrayIcon::Information, int msecs = 10000); - -Q_SIGNALS: - void activated(QPlatformSystemTrayIcon::ActivationReason reason); - void messageClicked(); - void visibleChanged(); - void tooltipChanged(); - void menuChanged(); - Q_REVISION(2, 1) void geometryChanged(); - Q_REVISION(2, 1) void iconChanged(); - -protected: - void init(); - void cleanup(); - - void classBegin() override; - void componentComplete() override; - - QQuickPlatformIconLoader *iconLoader() const; - -private Q_SLOTS: - void updateIcon(); - -private: - bool m_complete; - bool m_visible; - QString m_tooltip; - QQuickPlatformMenu *m_menu; - mutable QQuickPlatformIconLoader *m_iconLoader; - QPlatformSystemTrayIcon *m_handle; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformSystemTrayIcon) -Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::ActivationReason) -Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::MessageIcon) - -#endif // QQUICKPLATFORMSYSTEMTRAYICON_P_H diff --git a/src/labs/platform/qtlabsplatformplugin.cpp b/src/labs/platform/qtlabsplatformplugin.cpp deleted file mode 100644 index 90bdb121..00000000 --- a/src/labs/platform/qtlabsplatformplugin.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Templates 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 <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <QtCore/qloggingcategory.h> - -#include "qquickplatformdialog_p.h" -#include "qquickplatformcolordialog_p.h" -#include "qquickplatformfiledialog_p.h" -#include "qquickplatformfolderdialog_p.h" -#include "qquickplatformfontdialog_p.h" -#include "qquickplatformmessagedialog_p.h" - -#include "qquickplatformmenu_p.h" -#include "qquickplatformmenubar_p.h" -#include "qquickplatformmenuitem_p.h" -#include "qquickplatformmenuitemgroup_p.h" -#include "qquickplatformmenuseparator_p.h" - -#include "qquickplatformstandardpaths_p.h" -#if QT_CONFIG(systemtrayicon) -# include "qquickplatformsystemtrayicon_p.h" -#endif - -#include "qquickplatformicon_p.h" - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(qtLabsPlatformDialogs, "qt.labs.platform.dialogs") -Q_LOGGING_CATEGORY(qtLabsPlatformMenus, "qt.labs.platform.menus") -Q_LOGGING_CATEGORY(qtLabsPlatformTray, "qt.labs.platform.tray") - -class QtLabsPlatformPlugin: public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - QtLabsPlatformPlugin(QObject *parent = nullptr); - void registerTypes(const char *uri) override; -}; - -QtLabsPlatformPlugin::QtLabsPlatformPlugin(QObject *parent) : QQmlExtensionPlugin(parent) -{ -} - -void QtLabsPlatformPlugin::registerTypes(const char *uri) -{ - qmlRegisterUncreatableType<QQuickPlatformDialog>(uri, 1, 0, "Dialog", QQuickPlatformDialog::tr("Dialog is an abstract base class")); - qmlRegisterType<QQuickPlatformColorDialog>(uri, 1, 0, "ColorDialog"); - qmlRegisterType<QQuickPlatformFileDialog>(uri, 1, 0, "FileDialog"); - qmlRegisterAnonymousType<QQuickPlatformFileNameFilter>(uri, 1); - qmlRegisterType<QQuickPlatformFolderDialog>(uri, 1, 0, "FolderDialog"); - qmlRegisterType<QQuickPlatformFontDialog>(uri, 1, 0, "FontDialog"); - qmlRegisterType<QQuickPlatformMessageDialog>(uri, 1, 0, "MessageDialog"); - - qmlRegisterType<QQuickPlatformMenu>(uri, 1, 0, "Menu"); - qmlRegisterType<QQuickPlatformMenuBar>(uri, 1, 0, "MenuBar"); - qmlRegisterType<QQuickPlatformMenuItem>(uri, 1, 0, "MenuItem"); - qmlRegisterType<QQuickPlatformMenuItem, 1>(uri, 1, 1, "MenuItem"); - qmlRegisterType<QQuickPlatformMenuItemGroup>(uri, 1, 0, "MenuItemGroup"); - qmlRegisterType<QQuickPlatformMenuSeparator>(uri, 1, 0, "MenuSeparator"); - qRegisterMetaType<QPlatformMenu::MenuType>(); - - qmlRegisterUncreatableType<QPlatformDialogHelper>(uri, 1, 0, "StandardButton", QQuickPlatformDialog::tr("Cannot create an instance of StandardButton")); - qmlRegisterSingletonType<QQuickPlatformStandardPaths>(uri, 1, 0, "StandardPaths", QQuickPlatformStandardPaths::create); - qRegisterMetaType<QStandardPaths::StandardLocation>(); - qRegisterMetaType<QStandardPaths::LocateOptions>(); - -#if QT_CONFIG(systemtrayicon) - qmlRegisterType<QQuickPlatformSystemTrayIcon>(uri, 1, 0, "SystemTrayIcon"); - qmlRegisterType<QQuickPlatformSystemTrayIcon, 1>(uri, 1, 1, "SystemTrayIcon"); - qRegisterMetaType<QPlatformSystemTrayIcon::ActivationReason>(); - qRegisterMetaType<QPlatformSystemTrayIcon::MessageIcon>(); -#endif - - qmlRegisterAnonymousType<QQuickPlatformIcon>(uri, 1); - qRegisterMetaType<QQuickPlatformIcon>(); -} - -QT_END_NAMESPACE - -#include "qtlabsplatformplugin.moc" diff --git a/src/labs/platform/widgets/qwidgetplatform_p.h b/src/labs/platform/widgets/qwidgetplatform_p.h deleted file mode 100644 index cbdaa24a..00000000 --- a/src/labs/platform/widgets/qwidgetplatform_p.h +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORM_P_H -#define QWIDGETPLATFORM_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 <QtCore/qdebug.h> -#include <QtCore/qcoreapplication.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <QtGui/qpa/qplatformsystemtrayicon.h> -#include <QtGui/qpa/qplatformmenu.h> - -#ifdef QT_WIDGETS_LIB -#include <QtWidgets/qtwidgetsglobal.h> -#if QT_CONFIG(colordialog) -#include "qwidgetplatformcolordialog_p.h" -#endif -#if QT_CONFIG(filedialog) -#include "qwidgetplatformfiledialog_p.h" -#endif -#if QT_CONFIG(fontdialog) -#include "qwidgetplatformfontdialog_p.h" -#endif -#if QT_CONFIG(messagebox) -#include "qwidgetplatformmessagedialog_p.h" -#endif -#if QT_CONFIG(menu) -#include "qwidgetplatformmenu_p.h" -#include "qwidgetplatformmenuitem_p.h" -#endif -#ifndef QT_NO_SYSTEMTRAYICON -#include "qwidgetplatformsystemtrayicon_p.h" -#endif -#endif - -QT_BEGIN_NAMESPACE - -#ifndef QT_WIDGETS_LIB -typedef QPlatformMenu QWidgetPlatformMenu; -typedef QPlatformMenuItem QWidgetPlatformMenuItem; -typedef QPlatformColorDialogHelper QWidgetPlatformColorDialog; -typedef QPlatformFileDialogHelper QWidgetPlatformFileDialog; -typedef QPlatformFontDialogHelper QWidgetPlatformFontDialog; -typedef QPlatformMessageDialogHelper QWidgetPlatformMessageDialog; -typedef QPlatformSystemTrayIcon QWidgetPlatformSystemTrayIcon; -#endif - -namespace QWidgetPlatform -{ - static inline bool isAvailable(const char *type) - { - if (!qApp->inherits("QApplication")) { - qCritical("\nERROR: No native %s implementation available." - "\nQt Labs Platform requires Qt Widgets on this setup." - "\nAdd 'QT += widgets' to .pro and create QApplication in main().\n", type); - return false; - } - return true; - } - - template<typename T> - static inline T *createWidget(const char *name, QObject *parent) - { - static bool available = isAvailable(name); -#ifdef QT_WIDGETS_LIB - if (available) - return new T(parent); -#else - Q_UNUSED(parent); - Q_UNUSED(available); -#endif - return nullptr; - } - - static inline QPlatformMenu *createMenu(QObject *parent = nullptr) { -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu) - return createWidget<QWidgetPlatformMenu>("Menu", parent); -#else - Q_UNUSED(parent); - return nullptr; -#endif - } - static inline QPlatformMenuItem *createMenuItem(QObject *parent = nullptr) { -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu) - return createWidget<QWidgetPlatformMenuItem>("MenuItem", parent); -#else - Q_UNUSED(parent); - return nullptr; -#endif - } - static inline QPlatformSystemTrayIcon *createSystemTrayIcon(QObject *parent = nullptr) { -#ifndef QT_NO_SYSTEMTRAYICON - return createWidget<QWidgetPlatformSystemTrayIcon>("SystemTrayIcon", parent); -#else - Q_UNUSED(parent); - return nullptr; -#endif - } - static inline QPlatformDialogHelper *createDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr) - { -#if !defined(QT_WIDGETS_LIB) || !(QT_CONFIG(colordialog) || QT_CONFIG(filedialog) || QT_CONFIG(fontdialog) || QT_CONFIG(messagebox)) - Q_UNUSED(parent); -#endif - switch (type) { -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog) - case QPlatformTheme::ColorDialog: return createWidget<QWidgetPlatformColorDialog>("ColorDialog", parent); -#endif -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) - case QPlatformTheme::FileDialog: return createWidget<QWidgetPlatformFileDialog>("FileDialog", parent); -#endif -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog) - case QPlatformTheme::FontDialog: return createWidget<QWidgetPlatformFontDialog>("FontDialog", parent); -#endif -#if defined(QT_WIDGETS_LIB) && QT_CONFIG(messagebox) - case QPlatformTheme::MessageDialog: return createWidget<QWidgetPlatformMessageDialog>("MessageDialog", parent); -#endif - default: break; - } - return nullptr; - } -} - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORM_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformcolordialog.cpp b/src/labs/platform/widgets/qwidgetplatformcolordialog.cpp deleted file mode 100644 index 6c0043ae..00000000 --- a/src/labs/platform/widgets/qwidgetplatformcolordialog.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformcolordialog_p.h" -#include "qwidgetplatformdialog_p.h" - -#include <QtWidgets/qcolordialog.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformColorDialog::QWidgetPlatformColorDialog(QObject *parent) - : m_dialog(new QColorDialog) -{ - setParent(parent); - - connect(m_dialog.data(), &QColorDialog::accepted, this, &QPlatformDialogHelper::accept); - connect(m_dialog.data(), &QColorDialog::rejected, this, &QPlatformDialogHelper::reject); - connect(m_dialog.data(), &QColorDialog::currentColorChanged, this, &QPlatformColorDialogHelper::currentColorChanged); -} - -QWidgetPlatformColorDialog::~QWidgetPlatformColorDialog() -{ -} - -QColor QWidgetPlatformColorDialog::currentColor() const -{ - return m_dialog->currentColor(); -} - -void QWidgetPlatformColorDialog::setCurrentColor(const QColor &color) -{ - m_dialog->setCurrentColor(color); -} - -void QWidgetPlatformColorDialog::exec() -{ - m_dialog->exec(); -} - -bool QWidgetPlatformColorDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - QSharedPointer<QColorDialogOptions> options = QPlatformColorDialogHelper::options(); - m_dialog->setWindowTitle(options->windowTitle()); - m_dialog->setOptions(static_cast<QColorDialog::ColorDialogOptions>(int(options->options())) | QColorDialog::DontUseNativeDialog); - - return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent); -} - -void QWidgetPlatformColorDialog::hide() -{ - m_dialog->hide(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformcolordialog_p.h b/src/labs/platform/widgets/qwidgetplatformcolordialog_p.h deleted file mode 100644 index 09ed5a1e..00000000 --- a/src/labs/platform/widgets/qwidgetplatformcolordialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMCOLORDIALOG_P_H -#define QWIDGETPLATFORMCOLORDIALOG_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 <QtGui/qpa/qplatformdialoghelper.h> - -QT_BEGIN_NAMESPACE - -class QColorDialog; - -class QWidgetPlatformColorDialog : public QPlatformColorDialogHelper -{ - Q_OBJECT - -public: - explicit QWidgetPlatformColorDialog(QObject *parent = nullptr); - ~QWidgetPlatformColorDialog(); - - QColor currentColor() const override; - void setCurrentColor(const QColor &color) override; - - void exec() override; - bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; - void hide() override; - -private: - QScopedPointer<QColorDialog> m_dialog; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMCOLORDIALOG_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformdialog.cpp b/src/labs/platform/widgets/qwidgetplatformdialog.cpp deleted file mode 100644 index 3a206839..00000000 --- a/src/labs/platform/widgets/qwidgetplatformdialog.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformdialog_p.h" - -#include <QtGui/qwindow.h> -#include <QtWidgets/qdialog.h> - -QT_BEGIN_NAMESPACE - -bool QWidgetPlatformDialog::show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - dialog->setWindowFlags(flags); - dialog->setWindowModality(modality); - - dialog->createWinId(); - QWindow *handle = dialog->windowHandle(); - Q_ASSERT(handle); - handle->setTransientParent(const_cast<QWindow *>(parent)); - - dialog->show(); - return true; -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformdialog_p.h b/src/labs/platform/widgets/qwidgetplatformdialog_p.h deleted file mode 100644 index d4f27655..00000000 --- a/src/labs/platform/widgets/qwidgetplatformdialog_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMDIALOG_P_H -#define QWIDGETPLATFORMDIALOG_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 <QtCore/qnamespace.h> - -QT_BEGIN_NAMESPACE - -class QDialog; -class QWindow; - -class QWidgetPlatformDialog -{ -public: - static bool show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent); -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMDIALOG_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp b/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp deleted file mode 100644 index 21ac6527..00000000 --- a/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformfiledialog_p.h" -#include "qwidgetplatformdialog_p.h" - -#include <QtWidgets/qfiledialog.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformFileDialog::QWidgetPlatformFileDialog(QObject *parent) - : m_dialog(new QFileDialog) -{ - setParent(parent); - - connect(m_dialog.data(), &QDialog::accepted, this, &QPlatformDialogHelper::accept); - connect(m_dialog.data(), &QDialog::rejected, this, &QPlatformDialogHelper::reject); - - connect(m_dialog.data(), &QFileDialog::fileSelected, [this](const QString &file) { - emit fileSelected(QUrl::fromLocalFile(file)); - }); - connect(m_dialog.data(), &QFileDialog::filesSelected, [this](const QList<QString> &files) { - QList<QUrl> urls; - urls.reserve(files.count()); - for (const QString &file : files) - urls += QUrl::fromLocalFile(file); - emit filesSelected(urls); - }); - connect(m_dialog.data(), &QFileDialog::currentChanged, [this](const QString &path) { - emit currentChanged(QUrl::fromLocalFile(path)); - }); - connect(m_dialog.data(), &QFileDialog::directoryEntered, this, &QWidgetPlatformFileDialog::directoryEntered); - connect(m_dialog.data(), &QFileDialog::filterSelected, this, &QWidgetPlatformFileDialog::filterSelected); -} - -QWidgetPlatformFileDialog::~QWidgetPlatformFileDialog() -{ -} - -bool QWidgetPlatformFileDialog::defaultNameFilterDisables() const -{ - return false; // TODO: ? -} - -void QWidgetPlatformFileDialog::setDirectory(const QUrl &directory) -{ - m_dialog->setDirectory(directory.toLocalFile()); -} - -QUrl QWidgetPlatformFileDialog::directory() const -{ - return m_dialog->directoryUrl(); -} - -void QWidgetPlatformFileDialog::selectFile(const QUrl &filename) -{ - m_dialog->selectUrl(filename); -} - -QList<QUrl> QWidgetPlatformFileDialog::selectedFiles() const -{ - return m_dialog->selectedUrls(); -} - -void QWidgetPlatformFileDialog::setFilter() -{ - // TODO: ? -} - -void QWidgetPlatformFileDialog::selectNameFilter(const QString &filter) -{ - m_dialog->selectNameFilter(filter); -} - -QString QWidgetPlatformFileDialog::selectedNameFilter() const -{ - return m_dialog->selectedNameFilter(); -} - -void QWidgetPlatformFileDialog::exec() -{ - m_dialog->exec(); -} - -bool QWidgetPlatformFileDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - QSharedPointer<QFileDialogOptions> options = QPlatformFileDialogHelper::options(); - m_dialog->setWindowTitle(options->windowTitle()); - m_dialog->setAcceptMode(static_cast<QFileDialog::AcceptMode>(options->acceptMode())); - m_dialog->setFileMode(static_cast<QFileDialog::FileMode>(options->fileMode())); - m_dialog->setOptions(static_cast<QFileDialog::Options>(int(options->options())) | QFileDialog::DontUseNativeDialog); - m_dialog->setNameFilters(options->nameFilters()); - m_dialog->setDefaultSuffix(options->defaultSuffix()); - if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) - m_dialog->setLabelText(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept)); - if (options->isLabelExplicitlySet(QFileDialogOptions::Reject)) - m_dialog->setLabelText(QFileDialog::Reject, options->labelText(QFileDialogOptions::Reject)); - - return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent); -} - -void QWidgetPlatformFileDialog::hide() -{ - m_dialog->hide(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformfiledialog_p.h b/src/labs/platform/widgets/qwidgetplatformfiledialog_p.h deleted file mode 100644 index 3dba6038..00000000 --- a/src/labs/platform/widgets/qwidgetplatformfiledialog_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMFILEDIALOG_P_H -#define QWIDGETPLATFORMFILEDIALOG_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 <QtGui/qpa/qplatformdialoghelper.h> - -QT_BEGIN_NAMESPACE - -class QFileDialog; - -class QWidgetPlatformFileDialog : public QPlatformFileDialogHelper -{ - Q_OBJECT - -public: - explicit QWidgetPlatformFileDialog(QObject *parent = nullptr); - ~QWidgetPlatformFileDialog(); - - bool defaultNameFilterDisables() const override; - void setDirectory(const QUrl &directory) override; - QUrl directory() const override; - void selectFile(const QUrl &filename) override; - QList<QUrl> selectedFiles() const override; - void setFilter() override; - void selectNameFilter(const QString &filter) override; - QString selectedNameFilter() const override; - - void exec() override; - bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; - void hide() override; - -private: - QScopedPointer<QFileDialog> m_dialog; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMFILEDIALOG_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformfontdialog.cpp b/src/labs/platform/widgets/qwidgetplatformfontdialog.cpp deleted file mode 100644 index 315e7c73..00000000 --- a/src/labs/platform/widgets/qwidgetplatformfontdialog.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformfontdialog_p.h" -#include "qwidgetplatformdialog_p.h" - -#include <QtWidgets/qfontdialog.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformFontDialog::QWidgetPlatformFontDialog(QObject *parent) - : m_dialog(new QFontDialog) -{ - setParent(parent); - - connect(m_dialog.data(), &QFontDialog::accepted, this, &QPlatformDialogHelper::accept); - connect(m_dialog.data(), &QFontDialog::rejected, this, &QPlatformDialogHelper::reject); - connect(m_dialog.data(), &QFontDialog::currentFontChanged, this, &QPlatformFontDialogHelper::currentFontChanged); -} - -QWidgetPlatformFontDialog::~QWidgetPlatformFontDialog() -{ -} - -QFont QWidgetPlatformFontDialog::currentFont() const -{ - return m_dialog->currentFont(); -} - -void QWidgetPlatformFontDialog::setCurrentFont(const QFont &font) -{ - m_dialog->setCurrentFont(font); -} - -void QWidgetPlatformFontDialog::exec() -{ - m_dialog->exec(); -} - -bool QWidgetPlatformFontDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - QSharedPointer<QFontDialogOptions> options = QPlatformFontDialogHelper::options(); - m_dialog->setWindowTitle(options->windowTitle()); - m_dialog->setOptions(static_cast<QFontDialog::FontDialogOptions>(int(options->options())) | QFontDialog::DontUseNativeDialog); - - return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent); -} - -void QWidgetPlatformFontDialog::hide() -{ - m_dialog->hide(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformfontdialog_p.h b/src/labs/platform/widgets/qwidgetplatformfontdialog_p.h deleted file mode 100644 index e5d13b31..00000000 --- a/src/labs/platform/widgets/qwidgetplatformfontdialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMFONTDIALOG_P_H -#define QWIDGETPLATFORMFONTDIALOG_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 <QtGui/qpa/qplatformdialoghelper.h> - -QT_BEGIN_NAMESPACE - -class QFontDialog; - -class QWidgetPlatformFontDialog : public QPlatformFontDialogHelper -{ - Q_OBJECT - -public: - explicit QWidgetPlatformFontDialog(QObject *parent = nullptr); - ~QWidgetPlatformFontDialog(); - - QFont currentFont() const override; - void setCurrentFont(const QFont &font) override; - - void exec() override; - bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override; - void hide() override; - -private: - QScopedPointer<QFontDialog> m_dialog; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMFONTDIALOG_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformmenu.cpp b/src/labs/platform/widgets/qwidgetplatformmenu.cpp deleted file mode 100644 index f04620a3..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmenu.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformmenu_p.h" -#include "qwidgetplatformmenuitem_p.h" - -#include <QtGui/qaction.h> -#include <QtGui/qwindow.h> -#include <QtWidgets/qmenu.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformMenu::QWidgetPlatformMenu(QObject *parent) - : m_menu(new QMenu) -{ - setParent(parent); - - connect(m_menu.data(), &QMenu::aboutToShow, this, &QPlatformMenu::aboutToShow); - connect(m_menu.data(), &QMenu::aboutToHide, this, &QPlatformMenu::aboutToHide); -} - -QWidgetPlatformMenu::~QWidgetPlatformMenu() -{ -} - -QMenu *QWidgetPlatformMenu::menu() const -{ - return m_menu.data(); -} - -void QWidgetPlatformMenu::insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) -{ - QWidgetPlatformMenuItem *widgetItem = qobject_cast<QWidgetPlatformMenuItem *>(item); - if (!widgetItem) - return; - - QWidgetPlatformMenuItem *widgetBefore = qobject_cast<QWidgetPlatformMenuItem *>(before); - m_menu->insertAction(widgetBefore ? widgetBefore->action() : nullptr, widgetItem->action()); - int index = m_items.indexOf(widgetBefore); - if (index < 0) - index = m_items.count(); - m_items.insert(index, widgetItem); -} - -void QWidgetPlatformMenu::removeMenuItem(QPlatformMenuItem *item) -{ - QWidgetPlatformMenuItem *widgetItem = qobject_cast<QWidgetPlatformMenuItem *>(item); - if (!widgetItem) - return; - - m_items.removeOne(widgetItem); - m_menu->removeAction(widgetItem->action()); -} - -void QWidgetPlatformMenu::syncMenuItem(QPlatformMenuItem *item) -{ - Q_UNUSED(item); -} - -void QWidgetPlatformMenu::syncSeparatorsCollapsible(bool enable) -{ - m_menu->setSeparatorsCollapsible(enable); -} - -void QWidgetPlatformMenu::setText(const QString &text) -{ - m_menu->setTitle(text); -} - -void QWidgetPlatformMenu::setIcon(const QIcon &icon) -{ - m_menu->setIcon(icon); -} - -void QWidgetPlatformMenu::setEnabled(bool enabled) -{ - m_menu->menuAction()->setEnabled(enabled); -} - -bool QWidgetPlatformMenu::isEnabled() const -{ - return m_menu->menuAction()->isEnabled(); -} - -void QWidgetPlatformMenu::setVisible(bool visible) -{ - m_menu->menuAction()->setVisible(visible); -} - -void QWidgetPlatformMenu::setMinimumWidth(int width) -{ - if (width > 0) - m_menu->setMinimumWidth(width); -} - -void QWidgetPlatformMenu::setFont(const QFont &font) -{ - m_menu->setFont(font); -} - -void QWidgetPlatformMenu::setMenuType(MenuType type) -{ - Q_UNUSED(type); -} - -void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item) -{ - m_menu->createWinId(); - QWindow *handle = m_menu->windowHandle(); - Q_ASSERT(handle); - handle->setTransientParent(const_cast<QWindow *>(window)); - - QPoint targetPos = targetRect.bottomLeft(); - if (window) - targetPos = window->mapToGlobal(targetPos); - - const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item); - m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr); -} - -void QWidgetPlatformMenu::dismiss() -{ - m_menu->close(); -} - -QPlatformMenuItem *QWidgetPlatformMenu::menuItemAt(int position) const -{ - return m_items.value(position); -} - -QPlatformMenuItem *QWidgetPlatformMenu::menuItemForTag(quintptr tag) const -{ - for (QWidgetPlatformMenuItem *item : m_items) { - if (item->tag() == tag) - return item; - } - return nullptr; -} - -QPlatformMenuItem *QWidgetPlatformMenu::createMenuItem() const -{ - return new QWidgetPlatformMenuItem; -} - -QPlatformMenu *QWidgetPlatformMenu::createSubMenu() const -{ - return new QWidgetPlatformMenu; -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformmenu_p.h b/src/labs/platform/widgets/qwidgetplatformmenu_p.h deleted file mode 100644 index 9d1ef57e..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmenu_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMMENU_P_H -#define QWIDGETPLATFORMMENU_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 <QtGui/qpa/qplatformmenu.h> - -QT_BEGIN_NAMESPACE - -class QMenu; -class QWidgetPlatformMenuItem; - -class QWidgetPlatformMenu : public QPlatformMenu -{ - Q_OBJECT - -public: - explicit QWidgetPlatformMenu(QObject *parent = nullptr); - ~QWidgetPlatformMenu(); - - QMenu *menu() const; - - void insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) override; - void removeMenuItem(QPlatformMenuItem *item) override; - void syncMenuItem(QPlatformMenuItem *item) override; - void syncSeparatorsCollapsible(bool enable) override; - - void setText(const QString &text) override; - void setIcon(const QIcon &icon) override; - void setEnabled(bool enabled) override; - bool isEnabled() const override; - void setVisible(bool visible) override; - void setMinimumWidth(int width) override; - void setFont(const QFont &font) override; - void setMenuType(MenuType type) override; - - void showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item) override; - void dismiss() override; - - QPlatformMenuItem *menuItemAt(int position) const override; - QPlatformMenuItem *menuItemForTag(quintptr tag) const override; - - QPlatformMenuItem *createMenuItem() const override; - QPlatformMenu *createSubMenu() const override; - -private: - QScopedPointer<QMenu> m_menu; - QList<QWidgetPlatformMenuItem *> m_items; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMMENU_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformmenuitem.cpp b/src/labs/platform/widgets/qwidgetplatformmenuitem.cpp deleted file mode 100644 index ea4de57f..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmenuitem.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformmenuitem_p.h" -#include "qwidgetplatformmenu_p.h" - -#include <QtGui/qaction.h> -#include <QtWidgets/qmenu.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformMenuItem::QWidgetPlatformMenuItem(QObject *parent) - : m_action(new QAction) -{ - setParent(parent); - connect(m_action.data(), &QAction::hovered, this, &QPlatformMenuItem::hovered); - connect(m_action.data(), &QAction::triggered, this, &QPlatformMenuItem::activated); -} - -QWidgetPlatformMenuItem::~QWidgetPlatformMenuItem() -{ -} - -QAction *QWidgetPlatformMenuItem::action() const -{ - return m_action.data(); -} - -void QWidgetPlatformMenuItem::setText(const QString &text) -{ - m_action->setText(text); -} - -void QWidgetPlatformMenuItem::setIcon(const QIcon &icon) -{ - m_action->setIcon(icon); -} - -void QWidgetPlatformMenuItem::setMenu(QPlatformMenu *menu) -{ - QWidgetPlatformMenu *widgetMenu = qobject_cast<QWidgetPlatformMenu *>(menu); - m_action->setMenu(widgetMenu ? widgetMenu->menu() : nullptr); -} - -void QWidgetPlatformMenuItem::setVisible(bool visible) -{ - m_action->setVisible(visible); -} - -void QWidgetPlatformMenuItem::setIsSeparator(bool separator) -{ - m_action->setSeparator(separator); -} - -void QWidgetPlatformMenuItem::setFont(const QFont &font) -{ - m_action->setFont(font); -} - -void QWidgetPlatformMenuItem::setRole(MenuRole role) -{ - m_action->setMenuRole(static_cast<QAction::MenuRole>(role)); -} - -void QWidgetPlatformMenuItem::setCheckable(bool checkable) -{ - m_action->setCheckable(checkable); -} - -void QWidgetPlatformMenuItem::setChecked(bool checked) -{ - m_action->setChecked(checked); -} - -#if QT_CONFIG(shortcut) -void QWidgetPlatformMenuItem::setShortcut(const QKeySequence &shortcut) -{ - m_action->setShortcut(shortcut); -} -#endif - -void QWidgetPlatformMenuItem::setEnabled(bool enabled) -{ - m_action->setEnabled(enabled); -} - -void QWidgetPlatformMenuItem::setIconSize(int size) -{ - Q_UNUSED(size); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformmenuitem_p.h b/src/labs/platform/widgets/qwidgetplatformmenuitem_p.h deleted file mode 100644 index 43b3fc17..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmenuitem_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMMENUITEM_P_H -#define QWIDGETPLATFORMMENUITEM_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 <QtGui/qpa/qplatformmenu.h> - -QT_BEGIN_NAMESPACE - -class QAction; - -class QWidgetPlatformMenuItem : public QPlatformMenuItem -{ - Q_OBJECT - -public: - explicit QWidgetPlatformMenuItem(QObject *parent = nullptr); - ~QWidgetPlatformMenuItem(); - - QAction *action() const; - - void setText(const QString &text) override; - void setIcon(const QIcon &icon) override; - void setMenu(QPlatformMenu *menu) override; - void setVisible(bool visible) override; - void setIsSeparator(bool separator) override; - void setFont(const QFont &font) override; - void setRole(MenuRole role) override; - void setCheckable(bool checkable) override; - void setChecked(bool checked) override; -#if QT_CONFIG(shortcut) - void setShortcut(const QKeySequence& shortcut) override; -#endif - void setEnabled(bool enabled) override; - void setIconSize(int size) override; - -private: - QScopedPointer<QAction> m_action; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMMENUITEM_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformmessagedialog.cpp b/src/labs/platform/widgets/qwidgetplatformmessagedialog.cpp deleted file mode 100644 index 365692dc..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmessagedialog.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformmessagedialog_p.h" -#include "qwidgetplatformdialog_p.h" - -#include <QtWidgets/qmessagebox.h> -#include <QtWidgets/qabstractbutton.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformMessageDialog::QWidgetPlatformMessageDialog(QObject *parent) - : m_dialog(new QMessageBox) -{ - setParent(parent); - - connect(m_dialog.data(), &QMessageBox::accepted, this, &QPlatformDialogHelper::accept); - connect(m_dialog.data(), &QMessageBox::rejected, this, &QPlatformDialogHelper::reject); - connect(m_dialog.data(), &QMessageBox::buttonClicked, [this](QAbstractButton *button) { - QMessageBox::ButtonRole role = m_dialog->buttonRole(button); - QMessageBox::StandardButton standardButton = m_dialog->standardButton(button); - emit clicked(static_cast<StandardButton>(standardButton), static_cast<ButtonRole>(role)); - }); -} - -QWidgetPlatformMessageDialog::~QWidgetPlatformMessageDialog() -{ -} -void QWidgetPlatformMessageDialog::exec() -{ - m_dialog->exec(); -} - -bool QWidgetPlatformMessageDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - QSharedPointer<QMessageDialogOptions> options = QPlatformMessageDialogHelper::options(); - m_dialog->setWindowTitle(options->windowTitle()); - m_dialog->setIcon(static_cast<QMessageBox::Icon>(options->icon())); - m_dialog->setText(options->text()); - m_dialog->setInformativeText(options->informativeText()); -#if QT_CONFIG(textedit) - m_dialog->setDetailedText(options->detailedText()); -#endif - m_dialog->setStandardButtons(static_cast<QMessageBox::StandardButtons>(int(options->standardButtons()))); - - return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent); -} - -void QWidgetPlatformMessageDialog::hide() -{ - m_dialog->hide(); -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformmessagedialog_p.h b/src/labs/platform/widgets/qwidgetplatformmessagedialog_p.h deleted file mode 100644 index 6581337a..00000000 --- a/src/labs/platform/widgets/qwidgetplatformmessagedialog_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMMESSAGEDIALOG_P_H -#define QWIDGETPLATFORMMESSAGEDIALOG_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 <QtGui/qpa/qplatformdialoghelper.h> - -QT_BEGIN_NAMESPACE - -class QMessageBox; - -class QWidgetPlatformMessageDialog : public QPlatformMessageDialogHelper -{ - Q_OBJECT - -public: - explicit QWidgetPlatformMessageDialog(QObject *parent = nullptr); - ~QWidgetPlatformMessageDialog(); - - void exec() override; - bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; - void hide() override; - -private: - QScopedPointer<QMessageBox> m_dialog; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMMESSAGEDIALOG_P_H diff --git a/src/labs/platform/widgets/qwidgetplatformsystemtrayicon.cpp b/src/labs/platform/widgets/qwidgetplatformsystemtrayicon.cpp deleted file mode 100644 index e406ff03..00000000 --- a/src/labs/platform/widgets/qwidgetplatformsystemtrayicon.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 "qwidgetplatformsystemtrayicon_p.h" -#include "qwidgetplatformmenu_p.h" - -#include <QtWidgets/qsystemtrayicon.h> - -QT_BEGIN_NAMESPACE - -QWidgetPlatformSystemTrayIcon::QWidgetPlatformSystemTrayIcon(QObject *parent) - : m_systray(new QSystemTrayIcon) -{ - setParent(parent); - - connect(m_systray.data(), &QSystemTrayIcon::messageClicked, this, &QPlatformSystemTrayIcon::messageClicked); - connect(m_systray.data(), &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) { - emit activated(static_cast<ActivationReason>(reason)); - }); -} - -QWidgetPlatformSystemTrayIcon::~QWidgetPlatformSystemTrayIcon() -{ -} - -void QWidgetPlatformSystemTrayIcon::init() -{ - m_systray->show(); -} - -void QWidgetPlatformSystemTrayIcon::cleanup() -{ - m_systray->hide(); -} - -void QWidgetPlatformSystemTrayIcon::updateIcon(const QIcon &icon) -{ - m_systray->setIcon(icon); -} - -void QWidgetPlatformSystemTrayIcon::updateToolTip(const QString &tooltip) -{ - m_systray->setToolTip(tooltip); -} - -void QWidgetPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu) -{ -#if QT_CONFIG(menu) - QWidgetPlatformMenu *widgetMenu = qobject_cast<QWidgetPlatformMenu *>(menu); - if (!widgetMenu) - return; - - m_systray->setContextMenu(widgetMenu->menu()); -#else - Q_UNUSED(menu); -#endif -} - -QRect QWidgetPlatformSystemTrayIcon::geometry() const -{ - return m_systray->geometry(); -} - -void QWidgetPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs) -{ - Q_UNUSED(icon); - m_systray->showMessage(title, msg, static_cast<QSystemTrayIcon::MessageIcon>(iconType), msecs); -} - -bool QWidgetPlatformSystemTrayIcon::isSystemTrayAvailable() const -{ - return QSystemTrayIcon::isSystemTrayAvailable(); -} - -bool QWidgetPlatformSystemTrayIcon::supportsMessages() const -{ - return QSystemTrayIcon::supportsMessages(); -} - -QPlatformMenu *QWidgetPlatformSystemTrayIcon::createMenu() const -{ - return new QWidgetPlatformMenu; -} - -QT_END_NAMESPACE diff --git a/src/labs/platform/widgets/qwidgetplatformsystemtrayicon_p.h b/src/labs/platform/widgets/qwidgetplatformsystemtrayicon_p.h deleted file mode 100644 index 11ea5377..00000000 --- a/src/labs/platform/widgets/qwidgetplatformsystemtrayicon_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QWIDGETPLATFORMSYSTEMTRAYICON_P_H -#define QWIDGETPLATFORMSYSTEMTRAYICON_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 <QtGui/qpa/qplatformsystemtrayicon.h> - -QT_REQUIRE_CONFIG(systemtrayicon); - -QT_BEGIN_NAMESPACE - -class QSystemTrayIcon; - -class QWidgetPlatformSystemTrayIcon : public QPlatformSystemTrayIcon -{ - Q_OBJECT - -public: - explicit QWidgetPlatformSystemTrayIcon(QObject *parent = nullptr); - ~QWidgetPlatformSystemTrayIcon(); - - void init() override; - void cleanup() override; - void updateIcon(const QIcon &icon) override; - void updateToolTip(const QString &tooltip) override; - void updateMenu(QPlatformMenu *menu) override; - QRect geometry() const override; - void showMessage(const QString &title, const QString &msg, - const QIcon &icon, MessageIcon iconType, int msecs) override; - - bool isSystemTrayAvailable() const override; - bool supportsMessages() const override; - - QPlatformMenu *createMenu() const override; - -private: - QScopedPointer<QSystemTrayIcon> m_systray; -}; - -QT_END_NAMESPACE - -#endif // QWIDGETPLATFORMSYSTEMTRAYICON_P_H diff --git a/src/labs/platform/widgets/widgets.pri b/src/labs/platform/widgets/widgets.pri deleted file mode 100644 index 54ad7187..00000000 --- a/src/labs/platform/widgets/widgets.pri +++ /dev/null @@ -1,56 +0,0 @@ -QT += widgets -DEPENDPATH += $$PWD - -HEADERS += \ - $$PWD/qwidgetplatform_p.h - -qtConfig(systemtrayicon) { - HEADERS += \ - $$PWD/qwidgetplatformsystemtrayicon_p.h - SOURCES += \ - $$PWD/qwidgetplatformsystemtrayicon.cpp -} - -qtConfig(colordialog) | qtConfig(filedialog) | qtConfig(fontdialog) | qtConfig(messagebox) { - HEADERS += \ - $$PWD/qwidgetplatformdialog_p.h - SOURCES += \ - $$PWD/qwidgetplatformdialog.cpp -} - -qtConfig(colordialog) { - HEADERS += \ - $$PWD/qwidgetplatformcolordialog_p.h - SOURCES += \ - $$PWD/qwidgetplatformcolordialog.cpp -} - -qtConfig(filedialog) { - HEADERS += \ - $$PWD/qwidgetplatformfiledialog_p.h - SOURCES += \ - $$PWD/qwidgetplatformfiledialog.cpp -} - -qtConfig(fontdialog) { - HEADERS += \ - $$PWD/qwidgetplatformfontdialog_p.h - SOURCES += \ - $$PWD/qwidgetplatformfontdialog.cpp -} - -qtConfig(menu) { - HEADERS += \ - $$PWD/qwidgetplatformmenu_p.h \ - $$PWD/qwidgetplatformmenuitem_p.h - SOURCES += \ - $$PWD/qwidgetplatformmenu.cpp \ - $$PWD/qwidgetplatformmenuitem.cpp -} - -qtConfig(messagebox) { - HEADERS += \ - $$PWD/qwidgetplatformmessagedialog_p.h - SOURCES += \ - $$PWD/qwidgetplatformmessagedialog.cpp -} |