diff options
Diffstat (limited to 'src/quickdialogs2/quickdialogs2')
-rw-r--r-- | src/quickdialogs2/quickdialogs2/CMakeLists.txt | 36 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-filedialog-gtk.png | bin | 39560 -> 0 bytes | |||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-fontdialog-gtk.png | bin | 32399 -> 0 bytes | |||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf | 40 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/doc/src/includes/fallback.qdocinc | 1 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickabstractdialog.cpp | 454 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickabstractdialog_p.h | 161 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp | 612 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickfiledialog_p.h | 165 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickfontdialog.cpp | 227 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qquickfontdialog_p.h | 101 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qtquickdialogs2foreign_p.h | 75 | ||||
-rw-r--r-- | src/quickdialogs2/quickdialogs2/qtquickdialogs2global_p.h | 68 |
13 files changed, 0 insertions, 1940 deletions
diff --git a/src/quickdialogs2/quickdialogs2/CMakeLists.txt b/src/quickdialogs2/quickdialogs2/CMakeLists.txt deleted file mode 100644 index b73561b4..00000000 --- a/src/quickdialogs2/quickdialogs2/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -##################################################################### -## QuickDialogs2 Module: -##################################################################### - -qt_internal_add_qml_module(QuickDialogs2 - URI "QtQuick.Dialogs" - VERSION "${PROJECT_VERSION}" - CLASS_NAME QtQuickDialogsPlugin - PLUGIN_TARGET qtquickdialogsplugin - SOURCES - qquickabstractdialog.cpp - qquickabstractdialog_p.h - qquickfiledialog.cpp - qquickfiledialog_p.h - qquickfontdialog.cpp - qquickfontdialog_p.h - qtquickdialogs2foreign_p.h - qtquickdialogs2global_p.h - DEFINES - QT_BUILD_QUICKDIALOGS2_LIB - QT_NO_CAST_FROM_ASCII - QT_NO_CAST_TO_ASCII - INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} - LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - Qt::QmlPrivate - Qt::QuickPrivate - Qt::QuickDialogs2UtilsPrivate - Qt::QuickDialogs2QuickImplPrivate -) - -qt_internal_add_docs(QuickDialogs2 - doc/qtquickdialogs.qdocconf -) diff --git a/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-filedialog-gtk.png b/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-filedialog-gtk.png Binary files differdeleted file mode 100644 index 9360d747..00000000 --- a/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-filedialog-gtk.png +++ /dev/null diff --git a/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-fontdialog-gtk.png b/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-fontdialog-gtk.png Binary files differdeleted file mode 100644 index 0c6217bd..00000000 --- a/src/quickdialogs2/quickdialogs2/doc/images/qtquickdialogs-fontdialog-gtk.png +++ /dev/null diff --git a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf b/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf deleted file mode 100644 index e53a5c22..00000000 --- a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf +++ /dev/null @@ -1,40 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) -include($QT_INSTALL_DOCS/config/exampleurl-qtquickcontrols2.qdocconf) - -project = QtQuickDialogs -description = Qt Quick Dialogs Reference Documentation -version = $QT_VERSION - -qhp.projects = QtQuickDialogs - -qhp.QtQuickDialogs.file = qtquickdialogs.qhp -qhp.QtQuickDialogs.namespace = org.qt-project.qtquickdialogs.$QT_VERSION_TAG -qhp.QtQuickDialogs.virtualFolder = qtquickdialogs -qhp.QtQuickDialogs.indexTitle = Qt Quick Dialogs -qhp.QtQuickDialogs.indexRoot = - -qhp.QtQuickDialogs.filterAttributes = qtquickdialogs $QT_VERSION qtrefdoc -qhp.QtQuickDialogs.customFilters.Qt.name = QtQuickDialogs $QT_VERSION -qhp.QtQuickDialogs.customFilters.Qt.filterAttributes = qtquickdialogs $QT_VERSION - -qhp.QtQuickDialogs.subprojects = qmltypes -qhp.QtQuickDialogs.subprojects.qmltypes.title = QML Types -qhp.QtQuickDialogs.subprojects.qmltypes.indexTitle = Qt Quick Dialogs QML Types -qhp.QtQuickDialogs.subprojects.qmltypes.selectors = qmlclass -qhp.QtQuickDialogs.subprojects.qmltypes.sortPages = true - -depends = qtcore qtgui qtdoc qtqml qtquick qtquickcontrols - -# This module has no documented C++ types, clear the module header -moduleheader = - -headerdirs += .. -sourcedirs += .. \ - src - -imagedirs += images - -navigation.landingpage = "Qt Quick Dialogs" -navigation.qmltypespage = "Qt Quick Dialogs QML Types" - -tagfile = qtquickdialogs.tags diff --git a/src/quickdialogs2/quickdialogs2/doc/src/includes/fallback.qdocinc b/src/quickdialogs2/quickdialogs2/doc/src/includes/fallback.qdocinc deleted file mode 100644 index f3a4a180..00000000 --- a/src/quickdialogs2/quickdialogs2/doc/src/includes/fallback.qdocinc +++ /dev/null @@ -1 +0,0 @@ -Qt Quick Dialogs uses a Qt Quick implementation as a fallback on platforms that do not have a native implementation available. diff --git a/src/quickdialogs2/quickdialogs2/qquickabstractdialog.cpp b/src/quickdialogs2/quickdialogs2/qquickabstractdialog.cpp deleted file mode 100644 index 262e2ee3..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickabstractdialog.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 "qquickabstractdialog_p.h" - -#include <QtCore/qloggingcategory.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtQuick/qquickitem.h> -#include <QtQuick/qquickwindow.h> -#include <QtQuickDialogs2QuickImpl/private/qquickdialogimplfactory_p.h> - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcDialogs, "qt.quick.dialogs") - -/*! - \internal - - A dialog that can be backed by different implementations. - - Each dialog has a handle to QPlatformDialogHelper, which is created in create(). - The helper acts as an intermediary between the QML-facing dialog object - and the native/widget/quick implementation: - - +------------+ +------------------------------------+ +-------------------------------------+ - | | | | | | - | FileDialog |----->| Native/Widget/Quick QPlatformFile- |----->| Native OS dialog/QQuickFileDialog/ | - | | | DialogHelper subclass | | QQuickFileDialogImpl | - | | | | | | - +------------+ +------------------------------------+ +-------------------------------------+ -*/ - -/*! - \qmltype Dialog - \inherits QtObject -//! \instantiates QQuickAbstractDialog - \inqmlmodule QtQuick.Dialogs - \since 6.2 - \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. -*/ - -/*! - \qmlsignal void QtQuick.Dialogs::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 QtQuick.Dialogs::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(lcDialogs) - -QQuickAbstractDialog::QQuickAbstractDialog(QPlatformTheme::DialogType type, QObject *parent) - : QObject(parent), - m_type(type) -{ -} - -QQuickAbstractDialog::~QQuickAbstractDialog() -{ - destroy(); -} - -QPlatformDialogHelper *QQuickAbstractDialog::handle() const -{ - return m_handle.get(); -} - -/*! - \qmldefault - \qmlproperty list<Object> QtQuick.Dialogs::Dialog::data - - This default property holds the list of all objects declared as children of - the dialog. -*/ -QQmlListProperty<QObject> QQuickAbstractDialog::data() -{ - return QQmlListProperty<QObject>(this, &m_data); -} - -/*! - \qmlproperty Window QtQuick.Dialogs::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 *QQuickAbstractDialog::parentWindow() const -{ - return m_parentWindow; -} - -void QQuickAbstractDialog::setParentWindow(QWindow *window) -{ - qCDebug(lcDialogs) << "set parent window to" << window; - if (m_parentWindow == window) - return; - - m_parentWindow = window; - emit parentWindowChanged(); -} - -/*! - \qmlproperty string QtQuick.Dialogs::Dialog::title - - This property holds the title of the dialog. -*/ -QString QQuickAbstractDialog::title() const -{ - return m_title; -} - -void QQuickAbstractDialog::setTitle(const QString &title) -{ - if (m_title == title) - return; - - m_title = title; - emit titleChanged(); -} - -/*! - \qmlproperty Qt::WindowFlags QtQuick.Dialogs::Dialog::flags - - This property holds the window flags of the dialog. The default value is \c Qt.Dialog. -*/ -Qt::WindowFlags QQuickAbstractDialog::flags() const -{ - return m_flags; -} - -void QQuickAbstractDialog::setFlags(Qt::WindowFlags flags) -{ - if (m_flags == flags) - return; - - m_flags = flags; - emit flagsChanged(); -} - -/*! - \qmlproperty Qt::WindowModality QtQuick.Dialogs::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 QQuickAbstractDialog::modality() const -{ - return m_modality; -} - -void QQuickAbstractDialog::setModality(Qt::WindowModality modality) -{ - if (m_modality == modality) - return; - - m_modality = modality; - emit modalityChanged(); -} - -/*! - \qmlproperty bool QtQuick.Dialogs::Dialog::visible - - This property holds the visibility of the dialog. The default value is \c false. - - \sa open(), close() -*/ -bool QQuickAbstractDialog::isVisible() const -{ - return m_handle && m_visible; -} - -void QQuickAbstractDialog::setVisible(bool visible) -{ - qCDebug(lcDialogs) << "setVisible called with" << visible; - - if (visible) { - // Don't try to open before component completion, as we won't have a window yet, - // and open() sets m_visible to false if it fails. - if (!m_complete) - m_visibleRequested = true; - else - open(); - } else { - close(); - } -} - -/*! - \qmlproperty StandardCode QtQuick.Dialogs::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. -*/ -QQuickAbstractDialog::StandardCode QQuickAbstractDialog::result() const -{ - return m_result; -} - -void QQuickAbstractDialog::setResult(StandardCode result) -{ - if (m_result == result) - return; - - m_result = result; - emit resultChanged(); -} - -/*! - \qmlmethod void QtQuick.Dialogs::Dialog::open() - - Opens the dialog. - - \sa visible, close() -*/ -void QQuickAbstractDialog::open() -{ - qCDebug(lcDialogs) << "open called"; - if (m_visible || !create()) - return; - - onShow(m_handle.get()); - m_visible = m_handle->show(m_flags, m_modality, m_parentWindow); - if (m_visible) - emit visibleChanged(); -} - -/*! - \qmlmethod void QtQuick.Dialogs::Dialog::close() - - Closes the dialog. - - \sa visible, open() -*/ -void QQuickAbstractDialog::close() -{ - if (!m_handle || !m_visible) - return; - - onHide(m_handle.get()); - m_handle->hide(); - m_visible = false; - emit visibleChanged(); -} - -/*! - \qmlmethod void QtQuick.Dialogs::Dialog::accept() - - Closes the dialog and emits the \l accepted() signal. - - \sa reject() -*/ -void QQuickAbstractDialog::accept() -{ - done(Accepted); -} - -/*! - \qmlmethod void QtQuick.Dialogs::Dialog::reject() - - Closes the dialog and emits the \l rejected() signal. - - \sa accept() -*/ -void QQuickAbstractDialog::reject() -{ - done(Rejected); -} - -/*! - \qmlmethod void QtQuick.Dialogs::Dialog::done(StandardCode result) - - Closes the dialog and sets the \a result. - - \sa accept(), reject(), result -*/ -void QQuickAbstractDialog::done(StandardCode result) -{ - close(); - setResult(result); - - if (result == Accepted) - emit accepted(); - else if (result == Rejected) - emit rejected(); -} - -void QQuickAbstractDialog::classBegin() -{ -} - -void QQuickAbstractDialog::componentComplete() -{ - qCDebug(lcDialogs) << "componentComplete"; - m_complete = true; - - if (!m_parentWindow) { - qCDebug(lcDialogs) << "- no parent window; searching for one"; - setParentWindow(findParentWindow()); - } - - if (m_visibleRequested) { - qCDebug(lcDialogs) << "visible was bound to true before component completion; opening dialog"; - open(); - m_visibleRequested = false; - } -} - -static const char *qmlTypeName(const QObject *object) -{ - return object->metaObject()->className() + qstrlen("QQuickPlatform"); -} - -bool QQuickAbstractDialog::create() -{ - qCDebug(lcDialogs) << qmlTypeName(this) << "attempting to create dialog backend of type" - << m_type << "with parent window" << m_parentWindow; - if (m_handle) - return m_handle.get(); - - qCDebug(lcDialogs) << "- attempting to create a native dialog"; - if (useNativeDialog()) - m_handle.reset(QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(m_type)); - - if (!m_handle) { - qCDebug(lcDialogs) << "- attempting to create a quick dialog"; - m_handle.reset(QQuickDialogImplFactory::createPlatformDialogHelper(m_type, this)); - } - - qCDebug(lcDialogs) << qmlTypeName(this) << "created ->" << m_handle.get(); - if (m_handle) { - onCreate(m_handle.get()); - connect(m_handle.get(), &QPlatformDialogHelper::accept, this, &QQuickAbstractDialog::accept); - connect(m_handle.get(), &QPlatformDialogHelper::reject, this, &QQuickAbstractDialog::reject); - } - return m_handle.get(); -} - -void QQuickAbstractDialog::destroy() -{ - m_handle.reset(); -} - -bool QQuickAbstractDialog::useNativeDialog() const -{ - if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)) { - qCDebug(lcDialogs) << " - Qt::AA_DontUseNativeDialogs was set; not using native dialog"; - return false; - } - - if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(m_type)) { - qCDebug(lcDialogs) << " - the platform theme told us a native dialog isn't available; not using native dialog"; - return false; - } - - return true; -} - -void QQuickAbstractDialog::onCreate(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -void QQuickAbstractDialog::onShow(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -void QQuickAbstractDialog::onHide(QPlatformDialogHelper *dialog) -{ - Q_UNUSED(dialog); -} - -QWindow *QQuickAbstractDialog::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 diff --git a/src/quickdialogs2/quickdialogs2/qquickabstractdialog_p.h b/src/quickdialogs2/quickdialogs2/qquickabstractdialog_p.h deleted file mode 100644 index 07e9ffbf..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickabstractdialog_p.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QQUICKABSTRACTDIALOG_P_H -#define QQUICKABSTRACTDIALOG_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 <memory> - -#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> - -#include "qtquickdialogs2global_p.h" - -QT_BEGIN_NAMESPACE - -class QWindow; -class QPlatformDialogHelper; - -class Q_QUICKDIALOGS2_PRIVATE_EXPORT QQuickAbstractDialog : 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(StandardCode result READ result WRITE setResult NOTIFY resultChanged FINAL) - Q_CLASSINFO("DefaultProperty", "data") - Q_MOC_INCLUDE(<QtGui/qwindow.h>) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(6, 2) - -public: - explicit QQuickAbstractDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr); - ~QQuickAbstractDialog(); - - 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) - - StandardCode result() const; - void setResult(StandardCode result); - -public Q_SLOTS: - void open(); - void close(); - virtual void accept(); - virtual void reject(); - virtual void done(StandardCode 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_visibleRequested = false; - bool m_visible = false; - bool m_complete = false; - StandardCode m_result = Rejected; - QWindow *m_parentWindow = nullptr; - QString m_title; - Qt::WindowFlags m_flags = Qt::Dialog; - Qt::WindowModality m_modality = Qt::WindowModal; - QPlatformTheme::DialogType m_type; - QList<QObject *> m_data; - std::unique_ptr<QPlatformDialogHelper> m_handle; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickAbstractDialog) - -#endif // QQUICKABSTRACTDIALOG_P_H diff --git a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp deleted file mode 100644 index f63cbbf0..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 "qquickfiledialog_p.h" - -#include <QtCore/qlist.h> -#include <QtCore/qloggingcategory.h> -#include <QtQml/qqmlfile.h> - -#include <QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h> - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcFileDialog, "qt.quick.dialogs.filedialog") - -/*! - \qmltype FileDialog - \inherits Dialog -//! \instantiates QQuickFileDialog - \inqmlmodule QtQuick.Dialogs - \since 6.2 - \brief A file dialog. - - The FileDialog type provides a QML API for file dialogs. - - \image qtquickdialogs-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 selectedFile and \l selectedFiles - 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 - - \include includes/fallback.qdocinc - - \sa FolderDialog, StandardPaths -*/ - -Q_DECLARE_LOGGING_CATEGORY(lcDialogs) - -QQuickFileDialog::QQuickFileDialog(QObject *parent) - : QQuickAbstractDialog(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 QtQuick.Dialogs::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. -*/ -QQuickFileDialog::FileMode QQuickFileDialog::fileMode() const -{ - return m_fileMode; -} - -void QQuickFileDialog::setFileMode(FileMode mode) -{ - qCDebug(lcFileDialog) << "setFileMode called with" << 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 QtQuick.Dialogs::FileDialog::selectedFile - \readonly - - This property holds the final accepted file. - - If there are multiple selected files, this property refers to the first - file. - - Unlike the \l currentFile property, the \c selectedFile 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 selectedFiles, currentFile, {Dialog::}{accepted()}, currentFolder -*/ -QUrl QQuickFileDialog::selectedFile() const -{ - return addDefaultSuffix(m_selectedFiles.value(0)); -} - -/*! - \qmlproperty list<url> QtQuick.Dialogs::FileDialog::selectedFiles - - This property holds the final accepted files. - - Unlike the \l currentFiles property, the \c selectedFiles 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()}, currentFolder -*/ -QList<QUrl> QQuickFileDialog::selectedFiles() const -{ - return addDefaultSuffixes(m_selectedFiles); -} - -void QQuickFileDialog::setSelectedFiles(const QList<QUrl> &selectedFiles) -{ - if (m_selectedFiles == selectedFiles) - return; - - bool firstChanged = m_selectedFiles.value(0) != selectedFiles.value(0); - m_selectedFiles = selectedFiles; - if (firstChanged) - emit selectedFileChanged(); - emit selectedFilesChanged(); -} - -/*! - \qmlproperty url QtQuick.Dialogs::FileDialog::currentFile - - This property holds the currently selected file in the dialog. - - Unlike the \l selectedFile 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 selectedFile, currentFiles, currentFolder -*/ -QUrl QQuickFileDialog::currentFile() const -{ - return currentFiles().value(0); -} - -void QQuickFileDialog::setCurrentFile(const QUrl &file) -{ - setCurrentFiles(QList<QUrl>() << file); -} - -/*! - \qmlproperty list<url> QtQuick.Dialogs::FileDialog::currentFiles - - This property holds the currently selected files in the dialog. - - Unlike the \l selectedFiles 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 selectedFiles, currentFile, currentFolder -*/ -QList<QUrl> QQuickFileDialog::currentFiles() const -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - return fileDialog->selectedFiles(); - return m_options->initiallySelectedFiles(); -} - -void QQuickFileDialog::setCurrentFiles(const QList<QUrl> ¤tFiles) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) { - for (const QUrl &file : currentFiles) - fileDialog->selectFile(file); - } - m_options->setInitiallySelectedFiles(currentFiles); -} - -/*! - \qmlproperty url QtQuick.Dialogs::FileDialog::currentFolder - - This property holds the folder where files are selected. It can be set to - control the initial directory that is shown when the dialog is opened. - - For selecting a folder, use FolderDialog instead. - - \sa FolderDialog -*/ -QUrl QQuickFileDialog::currentFolder() const -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - return fileDialog->directory(); - - // If we're not using a native file dialog and the folder is invalid, - // return the current directory. - if (!m_options->initialDirectory().isValid()) - return QUrl::fromLocalFile(QDir::currentPath()); - - return m_options->initialDirectory(); -} - -void QQuickFileDialog::setCurrentFolder(const QUrl ¤tFolder) -{ - qCDebug(lcFileDialog) << "setCurrentFolder called with" << currentFolder; - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) - fileDialog->setDirectory(currentFolder); - m_options->setInitialDirectory(currentFolder); -} - -/*! - \qmlproperty flags QtQuick.Dialogs::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 QQuickFileDialog::options() const -{ - return m_options->options(); -} - -void QQuickFileDialog::setOptions(QFileDialogOptions::FileDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -void QQuickFileDialog::resetOptions() -{ - setOptions({}); -} - -/*! - \qmlproperty list<string> QtQuick.Dialogs::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 - - Different platforms may restrict the files that can be selected in - different ways. For example, macOS will disable file entries that do not - match the filters, whereas Windows will hide them. - - \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 QQuickFileDialog::nameFilters() const -{ - return m_options->nameFilters(); -} - -void QQuickFileDialog::setNameFilters(const QStringList &filters) -{ - qCDebug(lcFileDialog).nospace() << "setNameFilters called with " << filters - << " (old filters were: " << m_options->nameFilters() << ")"; - 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 QQuickFileDialog::resetNameFilters() -{ - setNameFilters(QStringList()); -} - -/*! - \qmlproperty int QtQuick.Dialogs::FileDialog::selectedNameFilter.index - \qmlproperty string QtQuick.Dialogs::FileDialog::selectedNameFilter.name - \qmlproperty list<string> QtQuick.Dialogs::FileDialog::selectedNameFilter.extensions - \qmlproperty list<string> QtQuick.Dialogs::FileDialog::selectedNameFilter.globs - - 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"]}. - \row - \li [read-only] \b globs : list<string> - \li This property holds the list of globs of the selected filter. - In the example below, the list of globs of the first filter is - \c {["*.txt"]} and the second is \c {["*.html", "*.htm"]}. - - This property is useful in conjunction with \l {FolderListModel}'s - \l {FolderListModel::}{nameFilters} property, for example. - \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 -*/ -QQuickFileNameFilter *QQuickFileDialog::selectedNameFilter() const -{ - if (!m_selectedNameFilter) { - QQuickFileDialog *that = const_cast<QQuickFileDialog *>(this); - m_selectedNameFilter = new QQuickFileNameFilter(that); - m_selectedNameFilter->setOptions(m_options); - } - return m_selectedNameFilter; -} - -/*! - \qmlproperty string QtQuick.Dialogs::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 QQuickFileDialog::defaultSuffix() const -{ - return m_options->defaultSuffix(); -} - -void QQuickFileDialog::setDefaultSuffix(const QString &suffix) -{ - if (suffix == m_options->defaultSuffix()) - return; - - m_options->setDefaultSuffix(suffix); - emit defaultSuffixChanged(); -} - -void QQuickFileDialog::resetDefaultSuffix() -{ - setDefaultSuffix(QString()); -} - -/*! - \qmlproperty string QtQuick.Dialogs::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 QQuickFileDialog::acceptLabel() const -{ - return m_options->labelText(QFileDialogOptions::Accept); -} - -void QQuickFileDialog::setAcceptLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Accept)) - return; - - m_options->setLabelText(QFileDialogOptions::Accept, label); - emit acceptLabelChanged(); -} - -void QQuickFileDialog::resetAcceptLabel() -{ - setAcceptLabel(QString()); -} - -/*! - \qmlproperty string QtQuick.Dialogs::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 QQuickFileDialog::rejectLabel() const -{ - return m_options->labelText(QFileDialogOptions::Reject); -} - -void QQuickFileDialog::setRejectLabel(const QString &label) -{ - if (label == m_options->labelText(QFileDialogOptions::Reject)) - return; - - m_options->setLabelText(QFileDialogOptions::Reject, label); - emit rejectLabelChanged(); -} - -void QQuickFileDialog::resetRejectLabel() -{ - setRejectLabel(QString()); -} - -bool QQuickFileDialog::useNativeDialog() const -{ - if (!QQuickAbstractDialog::useNativeDialog()) - return false; - - if (m_options->testOption(QFileDialogOptions::DontUseNativeDialog)) { - qCDebug(lcDialogs) << " - the FileDialog was told not to use a native dialog; not using native dialog"; - return false; - } - - return true; -} - -void QQuickFileDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickFileDialog::currentFileChanged); - connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickFileDialog::currentFilesChanged); - connect(fileDialog, &QPlatformFileDialogHelper::directoryEntered, this, &QQuickFileDialog::currentFolderChanged); - fileDialog->setOptions(m_options); - } -} - -void QQuickFileDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - // Ensure that a name filter is always selected. - int index = selectedNameFilter()->index(); - if (index == -1) - index = 0; - const QString filter = m_options->nameFilters().value(index); - m_options->setInitiallySelectedNameFilter(filter); - - fileDialog->setOptions(m_options); // setOptions only assigns a member and isn't virtual - - connect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickFileNameFilter::update); - fileDialog->selectNameFilter(filter); - - const QUrl initialDir = m_options->initialDirectory(); - // If it's not valid, or it's a file and not a directory, we shouldn't set it. - if (m_firstShow && initialDir.isValid() && QDir(QQmlFile::urlToLocalFileOrQrc(initialDir)).exists()) - fileDialog->setDirectory(m_options->initialDirectory()); - } - if (m_firstShow) - m_firstShow = false; -} - -void QQuickFileDialog::onHide(QPlatformDialogHelper *dialog) -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) { - if (m_selectedNameFilter) - disconnect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickFileNameFilter::update); - } -} - -void QQuickFileDialog::accept() -{ - if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) { - // Take the currently selected files and make them the final set of files. - setSelectedFiles(fileDialog->selectedFiles()); - } - QQuickAbstractDialog::accept(); -} - -QUrl QQuickFileDialog::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> QQuickFileDialog::addDefaultSuffixes(const QList<QUrl> &files) const -{ - QList<QUrl> urls; - urls.reserve(files.size()); - for (const QUrl &file : files) - urls += addDefaultSuffix(file); - return urls; -} - -QT_END_NAMESPACE diff --git a/src/quickdialogs2/quickdialogs2/qquickfiledialog_p.h b/src/quickdialogs2/quickdialogs2/qquickfiledialog_p.h deleted file mode 100644 index 0dccbe72..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickfiledialog_p.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QQUICKFILEDIALOG_P_H -#define QQUICKFILEDIALOG_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 <QtQml/qqml.h> - -#include "qquickabstractdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickFileNameFilter; - -class Q_QUICKDIALOGS2_PRIVATE_EXPORT QQuickFileDialog : public QQuickAbstractDialog -{ - Q_OBJECT - Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL) - Q_PROPERTY(QUrl selectedFile READ selectedFile NOTIFY selectedFileChanged FINAL) - Q_PROPERTY(QList<QUrl> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged 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 currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged 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(QQuickFileNameFilter *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) - QML_NAMED_ELEMENT(FileDialog) - QML_ADDED_IN_VERSION(6, 2) - Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>) - -public: - explicit QQuickFileDialog(QObject *parent = nullptr); - - enum FileMode { - OpenFile, - OpenFiles, - SaveFile - }; - Q_ENUM(FileMode) - - FileMode fileMode() const; - void setFileMode(FileMode fileMode); - - QUrl selectedFile() const; - - QList<QUrl> selectedFiles() const; - - QUrl currentFile() const; - void setCurrentFile(const QUrl &file); - - QList<QUrl> currentFiles() const; - void setCurrentFiles(const QList<QUrl> ¤tFiles); - - QUrl currentFolder() const; - void setCurrentFolder(const QUrl ¤tFolder); - - QFileDialogOptions::FileDialogOptions options() const; - void setOptions(QFileDialogOptions::FileDialogOptions options); - void resetOptions(); - - QStringList nameFilters() const; - void setNameFilters(const QStringList &filters); - void resetNameFilters(); - - QQuickFileNameFilter *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 selectedFileChanged(); - void selectedFilesChanged(); - void currentFileChanged(); - void currentFilesChanged(); - void currentFolderChanged(); - 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; - - void setSelectedFiles(const QList<QUrl> &selectedFiles); - - FileMode m_fileMode; - QList<QUrl> m_selectedFiles; - bool m_firstShow = true; - QSharedPointer<QFileDialogOptions> m_options; - mutable QQuickFileNameFilter *m_selectedNameFilter; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickFileDialog) - -#endif // QQUICKFILEDIALOG_P_H diff --git a/src/quickdialogs2/quickdialogs2/qquickfontdialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfontdialog.cpp deleted file mode 100644 index 5bf59049..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickfontdialog.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QQUICKFONTDIALOG_CPP -#define QQUICKFONTDIALOG_CPP - -#include "qquickfontdialog_p.h" - -#include <QtCore/qloggingcategory.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FontDialog - \inherits Dialog -//! \instantiates QQuickFontDialog - \inqmlmodule QtQuick.Dialogs - \since 6.2 - \brief A font dialog. - - The FontDialog type provides a QML API for font dialogs. - - \image qtquickdialogs-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 selectedFont 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.selectedFont - } - \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 - - \include includes/fallback.qdocinc -*/ - -Q_LOGGING_CATEGORY(lcFontDialog, "qt.quick.dialogs.fontdialog") - -QQuickFontDialog::QQuickFontDialog(QObject *parent) - : QQuickAbstractDialog(QPlatformTheme::FontDialog, parent), - m_options(QFontDialogOptions::create()) -{ -} - -/*! - \qmlproperty font QtQuick.Dialogs::FontDialog::currentFont - - This property holds the currently selected font in the dialog. - - Unlike the \l selectedFont 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 selectedFont -*/ - -QFont QQuickFontDialog::currentFont() const -{ - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle())) - return fontDialog->currentFont(); - return QFont(); -} - -void QQuickFontDialog::setCurrentFont(const QFont &font) -{ - if (QPlatformFontDialogHelper *fontDialog = - qobject_cast<QPlatformFontDialogHelper *>(handle())) - fontDialog->setCurrentFont(font); -} - -/*! - \qmlproperty font QtQuick.Dialogs::FontDialog::selectedFont - - This property holds the final accepted font. - - Unlike the \l currentFont property, the \c selectedFont 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 Open - to accept a font. Alternatively, the \l {Dialog::}{accepted()} signal - can be handled to get the final selection. - - \sa currentFont, {Dialog::}{accepted()} -*/ - -QFont QQuickFontDialog::selectedFont() const -{ - return m_selectedFont; -} - -void QQuickFontDialog::setSelectedFont(const QFont &font) -{ - if (m_selectedFont == font) - return; - - m_selectedFont = font; - emit selectedFontChanged(); -} - -/*! - \qmlproperty flags QtQuick.Dialogs::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 Open and \uicontrol Cancel buttons (useful - for "live dialogs"). -*/ - -QFontDialogOptions::FontDialogOptions QQuickFontDialog::options() const -{ - return m_options->options(); -} - -void QQuickFontDialog::setOptions(QFontDialogOptions::FontDialogOptions options) -{ - if (options == m_options->options()) - return; - - m_options->setOptions(options); - emit optionsChanged(); -} - -void QQuickFontDialog::resetOptions() -{ - setOptions({}); -} - -bool QQuickFontDialog::useNativeDialog() const -{ - return QQuickAbstractDialog::useNativeDialog() - && !(m_options->testOption(QFontDialogOptions::DontUseNativeDialog)); -} - -void QQuickFontDialog::onCreate(QPlatformDialogHelper *dialog) -{ - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog)) { - connect(fontDialog, &QPlatformFontDialogHelper::currentFontChanged, this, - &QQuickFontDialog::currentFontChanged); - connect(fontDialog, &QPlatformFontDialogHelper::fontSelected, this, - &QQuickFontDialog::setSelectedFont); - fontDialog->setOptions(m_options); - } -} - -void QQuickFontDialog::onShow(QPlatformDialogHelper *dialog) -{ - m_options->setWindowTitle(title()); - if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog)) - fontDialog->setOptions(m_options); // setOptions only assigns a member and isn't virtual -} - -void QQuickFontDialog::accept() -{ - if (auto fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle())) - setSelectedFont(fontDialog->currentFont()); - QQuickAbstractDialog::accept(); -} - -QT_END_NAMESPACE - -#endif // QQUICKFONTDIALOG_CPP diff --git a/src/quickdialogs2/quickdialogs2/qquickfontdialog_p.h b/src/quickdialogs2/quickdialogs2/qquickfontdialog_p.h deleted file mode 100644 index c12cbd62..00000000 --- a/src/quickdialogs2/quickdialogs2/qquickfontdialog_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QQUICKFONTDIALOG_P_H -#define QQUICKFONTDIALOG_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 "qquickabstractdialog_p.h" - -#include <QtGui/qfont.h> - -QT_BEGIN_NAMESPACE - -class Q_QUICKDIALOGS2_PRIVATE_EXPORT QQuickFontDialog : public QQuickAbstractDialog -{ - Q_OBJECT - Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont NOTIFY selectedFontChanged) - Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged FINAL) - Q_PROPERTY(QFontDialogOptions::FontDialogOptions options READ options WRITE setOptions - RESET resetOptions NOTIFY optionsChanged) - Q_FLAGS(QFontDialogOptions::FontDialogOptions) - QML_NAMED_ELEMENT(FontDialog) - QML_ADDED_IN_VERSION(6, 2) - -public: - explicit QQuickFontDialog(QObject *parent = nullptr); - - void setCurrentFont(const QFont &font); - QFont currentFont() const; - - void setSelectedFont(const QFont &font); - QFont selectedFont() const; - - QFontDialogOptions::FontDialogOptions options() const; - void setOptions(QFontDialogOptions::FontDialogOptions options); - void resetOptions(); - -Q_SIGNALS: - void selectedFontChanged(); - 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_selectedFont; - QSharedPointer<QFontDialogOptions> m_options; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickFontDialog) - -#endif // QQUICKFONTDIALOG_P_H diff --git a/src/quickdialogs2/quickdialogs2/qtquickdialogs2foreign_p.h b/src/quickdialogs2/quickdialogs2/qtquickdialogs2foreign_p.h deleted file mode 100644 index 6337434f..00000000 --- a/src/quickdialogs2/quickdialogs2/qtquickdialogs2foreign_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QTQUICKDIALOGS2FOREIGN_P_H -#define QTQUICKDIALOGS2FOREIGN_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> -#include <QtQml/qqml.h> -#include <QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h> - -QT_BEGIN_NAMESPACE - -struct QPlatformDialogHelperForeign -{ - Q_GADGET - QML_ANONYMOUS - QML_FOREIGN(QPlatformDialogHelper) - QML_ADDED_IN_VERSION(6, 2) -}; - -struct QQuickFileNameFilterForeign -{ - Q_GADGET - QML_ANONYMOUS - QML_FOREIGN(QQuickFileNameFilter) - QML_ADDED_IN_VERSION(6, 2) -}; - -QT_END_NAMESPACE - -#endif // QTQUICKDIALOGS2FOREIGN_P_H diff --git a/src/quickdialogs2/quickdialogs2/qtquickdialogs2global_p.h b/src/quickdialogs2/quickdialogs2/qtquickdialogs2global_p.h deleted file mode 100644 index cae55a95..00000000 --- a/src/quickdialogs2/quickdialogs2/qtquickdialogs2global_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Dialogs 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 QTQUICKDIALOGS2GLOBAL_P_H -#define QTQUICKDIALOGS2GLOBAL_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/qglobal.h> -#include <QtQml/private/qqmlglobal_p.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_QUICKDIALOGS2_LIB) -# define Q_QUICKDIALOGS2_PRIVATE_EXPORT Q_DECL_EXPORT -# else -# define Q_QUICKDIALOGS2_PRIVATE_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_QUICKDIALOGS2_PRIVATE_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTQUICKDIALOGS2GLOBAL_P_H |