From 9146d36552c2eb99166b773bb027d34c671d66e5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 28 Feb 2013 17:57:38 +0100 Subject: Create common base class for declarative dialogs QQuickAbstractFileDialog inherits QQuickAbstractDialog, and so can the future platform dialog types. Also some header comment corrections. Change-Id: I86bc6d975223979c19d94a3fd70e4b5130b73f47 Reviewed-by: Liang Qi --- src/imports/dialogs/DefaultFileDialog.qml | 57 +++--- src/imports/dialogs/WidgetFileDialog.qml | 65 +++--- src/imports/dialogs/dialogs.pro | 8 +- src/imports/dialogs/plugin.cpp | 97 ++++----- src/imports/dialogs/qml/Button.qml | 57 +++--- src/imports/dialogs/qml/TextField.qml | 57 +++--- src/imports/dialogs/qquickabstractdialog.cpp | 248 +++++++++++++++++++++++ src/imports/dialogs/qquickabstractdialog_p.h | 133 ++++++++++++ src/imports/dialogs/qquickabstractfiledialog.cpp | 58 +----- src/imports/dialogs/qquickabstractfiledialog_p.h | 38 +--- src/imports/dialogs/qquickfiledialog.cpp | 67 +----- src/imports/dialogs/qquickfiledialog_p.h | 10 +- src/imports/dialogs/qquickplatformfiledialog.cpp | 6 +- src/imports/dialogs/qquickplatformfiledialog_p.h | 2 +- 14 files changed, 576 insertions(+), 327 deletions(-) create mode 100644 src/imports/dialogs/qquickabstractdialog.cpp create mode 100644 src/imports/dialogs/qquickabstractdialog_p.h (limited to 'src/imports/dialogs') diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml index 80bf6b5cb1..9e05ace7b5 100644 --- a/src/imports/dialogs/DefaultFileDialog.qml +++ b/src/imports/dialogs/DefaultFileDialog.qml @@ -1,43 +1,42 @@ -/**************************************************************************** +/***************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** -****************************************************************************/ +*****************************************************************************/ import QtQuick 2.1 import QtQuick.Dialogs 1.0 diff --git a/src/imports/dialogs/WidgetFileDialog.qml b/src/imports/dialogs/WidgetFileDialog.qml index 837c7f8a57..c8f59d20a7 100644 --- a/src/imports/dialogs/WidgetFileDialog.qml +++ b/src/imports/dialogs/WidgetFileDialog.qml @@ -1,43 +1,42 @@ -/**************************************************************************** +/***************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtDeclarative 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** -****************************************************************************/ +*****************************************************************************/ import QtQuick 2.1 import QtQuick.PrivateWidgets 1.0 diff --git a/src/imports/dialogs/dialogs.pro b/src/imports/dialogs/dialogs.pro index 1a8ec05b85..784517f73e 100644 --- a/src/imports/dialogs/dialogs.pro +++ b/src/imports/dialogs/dialogs.pro @@ -4,15 +4,17 @@ TARGETPATH = QtQuick/Dialogs IMPORT_VERSION = 1.0 SOURCES += \ - plugin.cpp \ qquickabstractfiledialog.cpp \ qquickplatformfiledialog.cpp \ - qquickfiledialog.cpp + qquickfiledialog.cpp \ + qquickabstractdialog.cpp \ + plugin.cpp HEADERS += \ qquickabstractfiledialog_p.h \ qquickplatformfiledialog_p.h \ - qquickfiledialog_p.h + qquickfiledialog_p.h \ + qquickabstractdialog_p.h QML_FILES += \ DefaultFileDialog.qml \ diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp index 46bd0dcb9d..f7d72bf496 100644 --- a/src/imports/dialogs/plugin.cpp +++ b/src/imports/dialogs/plugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the plugins of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -48,6 +48,8 @@ //#define PURE_QML_ONLY +#define DIALOGS_MAJOR_MINOR 1, 0 + QT_BEGIN_NAMESPACE /*! @@ -73,66 +75,53 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin public: QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { } - virtual void initializeEngine(QQmlEngine *, const char *uri) { - bool needQml = false; - QDir qmlDir(baseUrl().toLocalFile()); - // If there is no support for native dialogs on the platform, we need to - // either re-use QFileDialog, or register a QML implementation instead. -#ifdef PURE_QML_ONLY - needQml = true; -#else - if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog)) { - needQml = true; - // If there is not a QApplication, there's no point in trying to load - // widget-based dialogs, because a runtime error will occur. - if (QCoreApplication::instance()->metaObject()->className() == QLatin1String("QApplication")) { - // Test whether PrivateWidgets can load. It's not currently possible - // to use the given engine for that, so we need to create a temporary one. - // That doesn't work in registerTypes either, which is why it's done here. - QString dialogQmlPath(qmlDir.filePath("WidgetFileDialog.qml")); - QQmlEngine tempEngine; - QQmlComponent widgetDialogComponent(&tempEngine); - QFile widgetDialogQmlFile(dialogQmlPath); - widgetDialogQmlFile.open(QIODevice::ReadOnly); - widgetDialogComponent.setData(widgetDialogQmlFile.readAll(), QUrl()); - - switch (widgetDialogComponent.status()) { - case QQmlComponent::Ready: - needQml = (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, 1, 0, "FileDialog") < 0); - // returns -1 unless we omit the module from qmldir, because otherwise - // QtQuick.Dialogs is already a protected namespace - // after the qmldir having been parsed. (QQmlImportDatabase::importPlugin) - // But omitting the module from qmldir results in this warning: - // "Module 'QtQuick.Dialogs' does not contain a module identifier directive - - // it cannot be protected from external registrations." - // TODO register all types in registerTypes, to avoid the warning - // But, in that case we cannot check for existence by trying to instantiate the component. - // So it will have to just look for a file (qmldir?) and assume - // that whatever modules are installed are also in working order. - break; - default: - break; - } - } - } -#endif - if (needQml) { - QString dialogQmlPath = qmlDir.filePath("DefaultFileDialog.qml"); - qmlRegisterType(uri, 1, 0, "AbstractFileDialog"); // implementation wrapper - // qDebug() << "registering FileDialog as " << dialogQmlPath << "success?" << - qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, 1, 0, "FileDialog"); - } - } - virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs")); + QDir qmlDir(baseUrl().toLocalFile()); + QDir widgetsDir(baseUrl().toLocalFile()); + // TODO: find the directory by searching rather than assuming a relative path + widgetsDir.cd("../PrivateWidgets"); + // Prefer the QPA dialog helpers if the platform supports them. + // Else if there is a QWidget-based implementation, check whether it's + // possible to instantiate it from Qt Quick. + // Otherwise fall back to a pure-QML implementation. + + // FileDialog #ifndef PURE_QML_ONLY - // Prefer the QPA file dialog helper if the platform supports it if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog)) - qmlRegisterType(uri, 1, 0, "FileDialog"); + qmlRegisterType(uri, DIALOGS_MAJOR_MINOR, "FileDialog"); + else #endif + registerWidgetOrQmlImplementation(widgetsDir, "WidgetFileDialog.qml", + qmlDir, "DefaultFileDialog.qml", "FileDialog", uri); } + +protected: + template + void registerWidgetOrQmlImplementation(QDir widgetsDir, QString widgetQmlFile, + QDir qmlDir, QString qmlFile, const char *qmlName, const char *uri) { + bool needQml = true; +#ifndef PURE_QML_ONLY + // If there is a qmldir and we have a QApplication instance (as opposed to a + // widget-free QGuiApplication), assume that the widget-based dialog will work. + if (widgetsDir.exists("qmldir") && !widgetQmlFile.isEmpty() && + !qstrcmp(QCoreApplication::instance()->metaObject()->className(), "QApplication")) { + QString dialogQmlPath = qmlDir.filePath(widgetQmlFile); + if (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, DIALOGS_MAJOR_MINOR, qmlName) >= 0) + needQml = false; + // qDebug() << "registering" << qmlName << " as " << dialogQmlPath << "success?" << needQml; + } +#endif + if (needQml) { + QString dialogQmlPath = qmlDir.filePath(qmlFile); + QByteArray abstractTypeName = QByteArray("Abstract") + qmlName; + qmlRegisterType(uri, DIALOGS_MAJOR_MINOR, abstractTypeName); // implementation wrapper + // qDebug() << "registering" << qmlName << " as " << dialogQmlPath << "success?" << + qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, DIALOGS_MAJOR_MINOR, qmlName); + } + } + }; QT_END_NAMESPACE diff --git a/src/imports/dialogs/qml/Button.qml b/src/imports/dialogs/qml/Button.qml index 42ee9f79e8..936c72c876 100644 --- a/src/imports/dialogs/qml/Button.qml +++ b/src/imports/dialogs/qml/Button.qml @@ -1,43 +1,42 @@ -/**************************************************************************** +/***************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** -****************************************************************************/ +*****************************************************************************/ import QtQuick 2.1 diff --git a/src/imports/dialogs/qml/TextField.qml b/src/imports/dialogs/qml/TextField.qml index 204eef71b9..da93239fd5 100644 --- a/src/imports/dialogs/qml/TextField.qml +++ b/src/imports/dialogs/qml/TextField.qml @@ -1,43 +1,42 @@ -/**************************************************************************** +/***************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 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 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** -****************************************************************************/ +*****************************************************************************/ import QtQuick 2.1 diff --git a/src/imports/dialogs/qquickabstractdialog.cpp b/src/imports/dialogs/qquickabstractdialog.cpp new file mode 100644 index 0000000000..abdc9e067c --- /dev/null +++ b/src/imports/dialogs/qquickabstractdialog.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 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 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickabstractdialog_p.h" +#include "qquickitem.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQuickAbstractDialog::QQuickAbstractDialog(QObject *parent) + : QObject(parent) + , m_parentWindow(0) + , m_visible(false) + , m_modality(Qt::WindowModal) + , m_qmlImplementation(0) + , m_dialogWindow(0) +{ +} + +QQuickAbstractDialog::~QQuickAbstractDialog() +{ +} + +void QQuickAbstractDialog::setVisible(bool v) +{ + if (m_visible == v) return; + m_visible = v; + if (helper()) { + if (v) { + Qt::WindowFlags flags = Qt::Dialog; + if (!title().isEmpty()) + flags |= Qt::WindowTitleHint; + m_visible = helper()->show(flags, m_modality, parentWindow()); + } else { + helper()->hide(); + } + } else { + // For a pure QML implementation, there is no helper. + // But m_implementation is probably either an Item or a Window at this point. + if (!m_dialogWindow) { + m_dialogWindow = qobject_cast(m_qmlImplementation); + if (!m_dialogWindow) { + QQuickItem *dlgItem = qobject_cast(m_qmlImplementation); + if (dlgItem) { + m_dialogWindow = dlgItem->window(); + // An Item-based dialog implementation doesn't come with a window, so + // we have to instantiate one iff the platform allows it. + if (!m_dialogWindow && QGuiApplicationPrivate::platformIntegration()-> + hasCapability(QPlatformIntegration::MultipleWindows)) { + QQuickWindow *win = new QQuickWindow; + ((QObject *)win)->setParent(this); // memory management only + m_dialogWindow = win; + dlgItem->setParentItem(win->contentItem()); + m_dialogWindow->setMinimumSize(QSize(dlgItem->width(), dlgItem->height())); + connect(win, SIGNAL(widthChanged(int)), this, SLOT(windowGeometryChanged())); + connect(win, SIGNAL(heightChanged(int)), this, SLOT(windowGeometryChanged())); + } + + QQuickItem *parentItem = qobject_cast(parent()); + // qDebug() << "item implementation" << dlgItem << "has window" << m_dialogWindow << "and parent" << parentItem; + + // If the platform does not support multiple windows, but the dialog is + // implemented as an Item, then just reparent it and make it visible. + // TODO QTBUG-29818: put it into a fake Item-based window, when we have a reusable self-decorated one. + if (parentItem && !m_dialogWindow) + dlgItem->setParentItem(parentItem); + } + } + if (m_dialogWindow) + connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool))); + } + if (m_dialogWindow) { + if (v) { + m_dialogWindow->setTransientParent(parentWindow()); + m_dialogWindow->setTitle(title()); + m_dialogWindow->setModality(m_modality); + } + m_dialogWindow->setVisible(v); + } + } + + emit visibilityChanged(); +} + +void QQuickAbstractDialog::setModality(Qt::WindowModality m) +{ + if (m_modality == m) return; + m_modality = m; + emit modalityChanged(); +} + +void QQuickAbstractDialog::accept() +{ + setVisible(false); + emit accepted(); +} + +void QQuickAbstractDialog::reject() +{ + setVisible(false); + emit rejected(); +} + +void QQuickAbstractDialog::visibleChanged(bool v) +{ + m_visible = v; + emit visibilityChanged(); +} + +void QQuickAbstractDialog::windowGeometryChanged() +{ + QQuickItem *content = qobject_cast(m_qmlImplementation); +qDebug() << Q_FUNC_INFO << m_dialogWindow << content; + if (m_dialogWindow && content) { + content->setWidth(m_dialogWindow->width()); + content->setHeight(m_dialogWindow->height()); + } +} + +QQuickWindow *QQuickAbstractDialog::parentWindow() +{ + QQuickItem *parentItem = qobject_cast(parent()); + if (parentItem) + m_parentWindow = parentItem->window(); + return m_parentWindow; +} + +void QQuickAbstractDialog::setQmlImplementation(QObject *obj) +{ + m_qmlImplementation = obj; + if (m_dialogWindow) { + disconnect(this, SLOT(visibleChanged(bool))); + // Can't necessarily delete because m_dialogWindow might have been provided by the QML. + m_dialogWindow = 0; + } +} + +int QQuickAbstractDialog::x() const +{ + if (m_dialogWindow) + return m_dialogWindow->x(); + return -1; +} + +int QQuickAbstractDialog::y() const +{ + if (m_dialogWindow) + return m_dialogWindow->y(); + return -1; +} + +int QQuickAbstractDialog::width() const +{ + if (m_dialogWindow) + return m_dialogWindow->width(); + return -1; +} + +int QQuickAbstractDialog::height() const +{ + if (m_dialogWindow) + return m_dialogWindow->height(); + return -1; +} + +void QQuickAbstractDialog::setX(int arg) +{ + if (helper()) { + // TODO + } else if (m_dialogWindow) { + m_dialogWindow->setX(arg); + } + emit geometryChanged(); +} + +void QQuickAbstractDialog::setY(int arg) +{ + if (helper()) { + // TODO + } else if (m_dialogWindow) { + m_dialogWindow->setY(arg); + } + emit geometryChanged(); +} + +void QQuickAbstractDialog::setWidth(int arg) +{ + if (helper()) { + // TODO + } else if (m_dialogWindow) { + m_dialogWindow->setWidth(arg); + } + emit geometryChanged(); +} + +void QQuickAbstractDialog::setHeight(int arg) +{ + if (helper()) { + // TODO + } else if (m_dialogWindow) { + m_dialogWindow->setHeight(arg); + } + emit geometryChanged(); +} + +QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractdialog_p.h b/src/imports/dialogs/qquickabstractdialog_p.h new file mode 100644 index 0000000000..2ad24f98e0 --- /dev/null +++ b/src/imports/dialogs/qquickabstractdialog_p.h @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 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 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.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 +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickAbstractDialog : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged) + Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(int x READ x WRITE setX NOTIFY geometryChanged) + Q_PROPERTY(int y READ y WRITE setY NOTIFY geometryChanged) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY geometryChanged) + Q_PROPERTY(int height READ height WRITE setHeight NOTIFY geometryChanged) + +public: + QQuickAbstractDialog(QObject *parent = 0); + virtual ~QQuickAbstractDialog(); + + bool isVisible() const { return m_visible; } + Qt::WindowModality modality() const { return m_modality; } + virtual QString title() const = 0; + QObject* qmlImplementation() { return m_qmlImplementation; } + + int x() const; + int y() const; + int width() const; + int height() const; + + virtual void setVisible(bool v); + virtual void setModality(Qt::WindowModality m); + virtual void setTitle(QString t) = 0; + void setQmlImplementation(QObject* obj); + void setX(int arg); + void setY(int arg); + void setWidth(int arg); + void setHeight(int arg); + +public Q_SLOTS: + void open() { setVisible(true); } + void close() { setVisible(false); } + +Q_SIGNALS: + void visibilityChanged(); + void geometryChanged(); + void modalityChanged(); + void titleChanged(); + void accepted(); + void rejected(); + +protected Q_SLOTS: + void accept(); + void reject(); + void visibleChanged(bool v); + void windowGeometryChanged(); + +protected: + virtual QPlatformDialogHelper *helper() = 0; + QQuickWindow *parentWindow(); + +protected: + QQuickWindow *m_parentWindow; + bool m_visible; + Qt::WindowModality m_modality; + +protected: // variables for pure-QML implementations only + QObject *m_qmlImplementation; + QWindow *m_dialogWindow; + + Q_DISABLE_COPY(QQuickAbstractDialog) +}; + +QT_END_NAMESPACE + +#endif // QQUICKABSTRACTDIALOG_P_H diff --git a/src/imports/dialogs/qquickabstractfiledialog.cpp b/src/imports/dialogs/qquickabstractfiledialog.cpp index 905cb5d030..32442de41f 100644 --- a/src/imports/dialogs/qquickabstractfiledialog.cpp +++ b/src/imports/dialogs/qquickabstractfiledialog.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -49,16 +49,14 @@ QT_BEGIN_NAMESPACE QQuickAbstractFileDialog::QQuickAbstractFileDialog(QObject *parent) - : QObject(parent) + : QQuickAbstractDialog(parent) , m_dlgHelper(0) - , m_parentWindow(0) , m_options(QSharedPointer(new QFileDialogOptions())) - , m_visible(false) - , m_modality(Qt::WindowModal) , m_selectExisting(true) , m_selectMultiple(false) , m_selectFolder(false) { + connect(this, SIGNAL(accepted()), this, SIGNAL(selectionAccepted())); } QQuickAbstractFileDialog::~QQuickAbstractFileDialog() @@ -67,27 +65,17 @@ QQuickAbstractFileDialog::~QQuickAbstractFileDialog() void QQuickAbstractFileDialog::setVisible(bool v) { - if (m_visible == v) return; - m_visible = v; - if (helper()) { - if (v) { - helper()->setOptions(m_options); - helper()->setFilter(); - m_visible = helper()->show(Qt::Dialog, m_modality, parentWindow()); - emit filterSelected(); - } else { - helper()->hide(); - } + if (helper() && v) { + m_dlgHelper->setOptions(m_options); + m_dlgHelper->setFilter(); + emit filterSelected(); } - - emit visibilityChanged(); + QQuickAbstractDialog::setVisible(v); } -void QQuickAbstractFileDialog::setModality(Qt::WindowModality m) +QString QQuickAbstractFileDialog::title() const { - if (m_modality == m) return; - m_modality = m; - emit modalityChanged(); + return m_options->windowTitle(); } void QQuickAbstractFileDialog::setTitle(QString t) @@ -177,24 +165,6 @@ QList QQuickAbstractFileDialog::fileUrls() return ret; } -void QQuickAbstractFileDialog::accept() -{ - setVisible(false); - emit accepted(); -} - -void QQuickAbstractFileDialog::reject() -{ - setVisible(false); - emit rejected(); -} - -void QQuickAbstractFileDialog::visibleChanged(bool v) -{ - m_visible = v; - emit visibilityChanged(); -} - void QQuickAbstractFileDialog::updateModes() { // The 4 possible modes are AnyFile, ExistingFile, Directory, ExistingFiles @@ -222,12 +192,4 @@ void QQuickAbstractFileDialog::updateModes() emit fileModeChanged(); } -QQuickWindow *QQuickAbstractFileDialog::parentWindow() -{ - QQuickItem *parentItem = qobject_cast(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - return m_parentWindow; -} - QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractfiledialog_p.h b/src/imports/dialogs/qquickabstractfiledialog_p.h index e9565108d6..965f1a7029 100644 --- a/src/imports/dialogs/qquickabstractfiledialog_p.h +++ b/src/imports/dialogs/qquickabstractfiledialog_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -57,32 +57,27 @@ #include #include #include +#include "qquickabstractdialog_p.h" QT_BEGIN_NAMESPACE -class QQuickAbstractFileDialog : public QObject +class QQuickAbstractFileDialog : public QQuickAbstractDialog { Q_OBJECT - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged) - Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) Q_PROPERTY(bool selectExisting READ selectExisting WRITE setSelectExisting NOTIFY fileModeChanged) Q_PROPERTY(bool selectMultiple READ selectMultiple WRITE setSelectMultiple NOTIFY fileModeChanged) Q_PROPERTY(bool selectFolder READ selectFolder WRITE setSelectFolder NOTIFY fileModeChanged) Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged) Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) Q_PROPERTY(QString selectedNameFilter READ selectedNameFilter WRITE selectNameFilter NOTIFY filterSelected) - Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY accepted) - Q_PROPERTY(QList fileUrls READ fileUrls NOTIFY accepted) - // TODO: QTBUG-29817: provide x y width and height (after QPlatformDialogHelper provides it) + Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY selectionAccepted) + Q_PROPERTY(QList fileUrls READ fileUrls NOTIFY selectionAccepted) public: QQuickAbstractFileDialog(QObject *parent = 0); virtual ~QQuickAbstractFileDialog(); - bool isVisible() const { return m_visible; } - Qt::WindowModality modality() const { return m_modality; } - QString title() const { return m_options->windowTitle(); } + virtual QString title() const; bool selectExisting() const { return m_selectExisting; } bool selectMultiple() const { return m_selectMultiple; } bool selectFolder() const { return m_selectFolder; } @@ -93,10 +88,7 @@ public: virtual QList fileUrls(); public Q_SLOTS: - void open() { setVisible(true); } - void close() { setVisible(false); } - virtual void setVisible(bool v); - void setModality(Qt::WindowModality m); + void setVisible(bool v); void setTitle(QString t); void setSelectExisting(bool s); void setSelectMultiple(bool s); @@ -106,32 +98,18 @@ public Q_SLOTS: void selectNameFilter(QString f); Q_SIGNALS: - void visibilityChanged(); - void modalityChanged(); - void titleChanged(); void folderChanged(); void nameFiltersChanged(); void filterSelected(); void fileModeChanged(); - void accepted(); - void rejected(); - -protected Q_SLOTS: - void accept(); - void reject(); - void visibleChanged(bool v); + void selectionAccepted(); protected: - virtual QPlatformFileDialogHelper *helper() = 0; void updateModes(); - QQuickWindow *parentWindow(); protected: QPlatformFileDialogHelper *m_dlgHelper; - QQuickWindow *m_parentWindow; QSharedPointer m_options; - bool m_visible; - Qt::WindowModality m_modality; bool m_selectExisting; bool m_selectMultiple; bool m_selectFolder; diff --git a/src/imports/dialogs/qquickfiledialog.cpp b/src/imports/dialogs/qquickfiledialog.cpp index 89b8b4cc5b..f78e8a6f8d 100644 --- a/src/imports/dialogs/qquickfiledialog.cpp +++ b/src/imports/dialogs/qquickfiledialog.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -42,7 +42,6 @@ #include "qquickfiledialog_p.h" #include #include -#include QT_BEGIN_NAMESPACE @@ -56,8 +55,10 @@ QT_BEGIN_NAMESPACE \internal AbstractFileDialog provides only the API for implementing a file dialog. - The implementation (e.g. a Window or Item) can be provided as \l implementation, - which is the default property (the only allowed child element). + The implementation (e.g. a Window or preferably an Item, in case it is + shown on a device that doesn't support multiple windows) can be provided as + \l implementation, which is the default property (the only allowed child + element). */ /*! @@ -77,8 +78,8 @@ QT_BEGIN_NAMESPACE \inmodule QtQuick.Dialogs \internal - The QQuickFileDialog class is a concrete subclass of \l - QQuickAbstractFileDialog, but it is abstract from the QML perspective + The QQuickFileDialog class is a concrete subclass of + \l QQuickAbstractFileDialog, but it is abstract from the QML perspective because it needs to enclose a graphical implementation. It exists in order to provide accessors and helper functions which the QML implementation will need. @@ -91,8 +92,6 @@ QT_BEGIN_NAMESPACE */ QQuickFileDialog::QQuickFileDialog(QObject *parent) : QQuickAbstractFileDialog(parent) - , m_implementation(0) - , m_dialogWindow(0) { } @@ -117,51 +116,6 @@ QList QQuickFileDialog::fileUrls() This property holds whether the dialog is visible. By default this is false. */ -void QQuickFileDialog::setVisible(bool v) -{ - if (m_visible == v) return; - m_visible = v; - // For a pure QML implementation, there is no helper. - // But m_implementation is probably either an Item or a Window at this point. - if (!m_dialogWindow) { - m_dialogWindow = qobject_cast(m_implementation); - if (!m_dialogWindow) { - QQuickItem *dlgItem = qobject_cast(m_implementation); - if (dlgItem) { - m_dialogWindow = dlgItem->window(); - // An Item-based dialog implementation doesn't come with a window, so - // we have to instantiate one iff the platform allows it. - if (!m_dialogWindow && QGuiApplicationPrivate::platformIntegration()-> - hasCapability(QPlatformIntegration::MultipleWindows)) { - QQuickWindow *win = new QQuickWindow; - m_dialogWindow = win; - dlgItem->setParentItem(win->contentItem()); - m_dialogWindow->setMinimumSize(QSize(dlgItem->width(), dlgItem->height())); - } - - QQuickItem *parentItem = qobject_cast(parent()); - // qDebug() << "item implementation" << dlgItem << "has window" << m_dialogWindow << "and parent" << parentItem; - - // If the platform does not support multiple windows, but the dialog is - // implemented as an Item, then just reparent it and make it visible. - // TODO QTBUG-29818: put it into a fake Item-based window, when we have a reusable self-decorated one. - if (parentItem && !m_dialogWindow) - dlgItem->setParentItem(parentItem); - } - } - if (m_dialogWindow) - connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool))); - } - if (m_dialogWindow) { - if (v) { - m_dialogWindow->setTransientParent(parentWindow()); - m_dialogWindow->setTitle(title()); - m_dialogWindow->setModality(m_modality); - } - m_dialogWindow->setVisible(v); - } - emit visibilityChanged(); -} /*! \qmlproperty bool AbstractFileDialog::filePaths @@ -219,12 +173,5 @@ QUrl QQuickFileDialog::pathFolder(const QString &path) The QML object which implements the actual file dialog. Should be either a \l Window or an \l Item. */ -void QQuickFileDialog::setImplementation(QObject *obj) -{ - m_implementation = obj; - if (m_dialogWindow) - disconnect(this, SLOT(visibleChanged(bool))); - m_dialogWindow = 0; -} QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickfiledialog_p.h b/src/imports/dialogs/qquickfiledialog_p.h index 0a660b316b..93e11f9e3e 100644 --- a/src/imports/dialogs/qquickfiledialog_p.h +++ b/src/imports/dialogs/qquickfiledialog_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -60,21 +60,17 @@ QT_BEGIN_NAMESPACE class QQuickFileDialog : public QQuickAbstractFileDialog { Q_OBJECT - Q_PROPERTY(QObject* implementation READ implementation WRITE setImplementation DESIGNABLE false) + Q_PROPERTY(QObject* implementation READ qmlImplementation WRITE setQmlImplementation DESIGNABLE false) Q_CLASSINFO("DefaultProperty", "implementation") // AbstractFileDialog in QML can have only one child public: explicit QQuickFileDialog(QObject *parent = 0); ~QQuickFileDialog(); - QObject* implementation() { return m_implementation; } virtual QList fileUrls(); signals: public Q_SLOTS: - void setImplementation(QObject* obj); - virtual void setVisible(bool v); - void clearSelection(); bool addSelection(QString path); @@ -85,8 +81,6 @@ protected: Q_INVOKABLE QUrl pathFolder(const QString &path); private: - QObject *m_implementation; - QWindow *m_dialogWindow; QStringList m_selections; Q_DISABLE_COPY(QQuickFileDialog) diff --git a/src/imports/dialogs/qquickplatformfiledialog.cpp b/src/imports/dialogs/qquickplatformfiledialog.cpp index fbc385f61d..d767f65499 100644 --- a/src/imports/dialogs/qquickplatformfiledialog.cpp +++ b/src/imports/dialogs/qquickplatformfiledialog.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE \inqmlmodule QtQuick.Dialogs 1 \ingroup qtquick-visual \brief Dialog component for choosing files from a local filesystem. - \since 5.1 + \since Qt 5.1 FileDialog provides a basic file chooser: it allows the user to select existing files and/or directories, or create new filenames. The dialog is @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE chooses a file: \qml - import QtQuick 2.0 + import QtQuick 2.1 import QtQuick.Dialogs 1.0 FileDialog { diff --git a/src/imports/dialogs/qquickplatformfiledialog_p.h b/src/imports/dialogs/qquickplatformfiledialog_p.h index 3559543319..5431836271 100644 --- a/src/imports/dialogs/qquickplatformfiledialog_p.h +++ b/src/imports/dialogs/qquickplatformfiledialog_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage -- cgit v1.2.3