diff options
216 files changed, 2355 insertions, 11644 deletions
diff --git a/.qmake.conf b/.qmake.conf index a0d132328a..88d13d1eef 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,5 +2,4 @@ load(qt_build_config) CONFIG += qt_example_installs CONFIG += warning_clean -MODULE_VERSION = 5.2.1 - +MODULE_VERSION = 5.3.0 diff --git a/dist/changes-5.3.0 b/dist/changes-5.3.0 new file mode 100644 index 0000000000..5cda809d97 --- /dev/null +++ b/dist/changes-5.3.0 @@ -0,0 +1,68 @@ +Qt 5.3 introduces many new features and improvements as well as bugfixes +over the 5.2.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.2 + +The Qt version 5.3 series is binary compatible with the 5.2.x series. +Applications compiled for 5.2 will continue to run with 5.3. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +Third party components +---------------------- + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + +- Signals declared in QML that take "var" parameters, are now using QJSValue + as C++ type for these parameters, instead of QVariant. + +**************************************************************************** +* Library * +**************************************************************************** + +QtQml +------ + +QtQuick +------ + +**************************************************************************** +* Database Drivers * +**************************************************************************** + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Compiler Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Tools * +**************************************************************************** + + +**************************************************************************** +* Plugins * +**************************************************************************** + diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro deleted file mode 100644 index 538e75686c..0000000000 --- a/examples/quick/dialogs/dialogs.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - systemdialogs diff --git a/examples/quick/dialogs/systemdialogs/ColorDialogs.qml b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml deleted file mode 100644 index 0cb42a01aa..0000000000 --- a/examples/quick/dialogs/systemdialogs/ColorDialogs.qml +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples 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.0 -import QtQuick.Dialogs 1.0 -import "../../shared" - -Rectangle { - width: 320 - height: 240 - color: palette.window - SystemPalette { id: palette } - clip: true - - //! [colordialog] - ColorDialog { - id: colorDialog - visible: colorDialogVisible.checked - modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal - title: "Choose a color" - color: "green" - showAlphaChannel: colorDialogAlpha.checked - onAccepted: { console.log("Accepted: " + color) } - onRejected: { console.log("Rejected") } - } - //! [colordialog] - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - font.bold: true - text: "Color dialog properties:" - } - CheckBox { - id: colorDialogModal - text: "Modal" - checked: true - Binding on checked { value: colorDialog.modality != Qt.NonModal } - } - CheckBox { - id: colorDialogAlpha - text: "Show alpha channel" - Binding on checked { value: colorDialog.showAlphaChannel } - } - CheckBox { - id: colorDialogVisible - text: "Visible" - Binding on checked { value: colorDialog.visible } - } - Row { - id: colorRow - spacing: parent.spacing - height: colorLabel.implicitHeight * 2.0 - Rectangle { - color: colorDialog.color - height: parent.height - width: height * 2 - border.color: "black" - MouseArea { - anchors.fill: parent - onClicked: colorDialog.open() - } - } - Text { - id: colorLabel - color: palette.windowText - text: "<b>current color:</b> " + colorDialog.color - anchors.verticalCenter: parent.verticalCenter - } - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: buttonRow.height * 1.2 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - id: buttonRow - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: implicitHeight - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.close() - } - Button { - text: "set to green" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.color = "green" - } - } - } -} diff --git a/examples/quick/dialogs/systemdialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml deleted file mode 100644 index d6ee1a13ca..0000000000 --- a/examples/quick/dialogs/systemdialogs/FileDialogs.qml +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples 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.0 -import QtQuick.Dialogs 1.0 -import QtQuick.Window 2.0 -import "../../shared" - -Rectangle { - width: 580 - height: 400 - color: palette.window - SystemPalette { id: palette } - clip: true - - //! [filedialog] - FileDialog { - id: fileDialog - visible: fileDialogVisible.checked - modality: fileDialogModal.checked ? Qt.WindowModal : Qt.NonModal - title: fileDialogSelectFolder.checked ? "Choose a folder" : - (fileDialogSelectMultiple.checked ? "Choose some files" : "Choose a file") - selectExisting: fileDialogSelectExisting.checked - selectMultiple: fileDialogSelectMultiple.checked - selectFolder: fileDialogSelectFolder.checked - nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ] - selectedNameFilter: "All files (*)" - onAccepted: { - console.log("Accepted: " + fileUrls) - if (fileDialogOpenFiles.checked) - for (var i = 0; i < fileUrls.length; ++i) - Qt.openUrlExternally(fileUrls[i]) - } - onRejected: { console.log("Rejected") } - } - //! [filedialog] - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - font.bold: true - text: "File dialog properties:" - } - CheckBox { - id: fileDialogModal - text: "Modal" - checked: true - Binding on checked { value: fileDialog.modality != Qt.NonModal } - } - CheckBox { - id: fileDialogSelectFolder - text: "Select Folder" - Binding on checked { value: fileDialog.selectFolder } - } - CheckBox { - id: fileDialogSelectExisting - text: "Select Existing Files" - checked: true - Binding on checked { value: fileDialog.selectExisting } - } - CheckBox { - id: fileDialogSelectMultiple - text: "Select Multiple Files" - Binding on checked { value: fileDialog.selectMultiple } - } - CheckBox { - id: fileDialogOpenFiles - text: "Open Files After Accepting" - } - CheckBox { - id: fileDialogVisible - text: "Visible" - Binding on checked { value: fileDialog.visible } - } - Text { - color: palette.windowText - text: "<b>current view folder:</b> " + fileDialog.folder - } - Text { - color: palette.windowText - text: "<b>name filters:</b> {" + fileDialog.nameFilters + "}" - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>current filter:</b>" + fileDialog.selectedNameFilter - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>chosen files:</b> " + fileDialog.fileUrls - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>chosen single path:</b> " + fileDialog.fileUrl - width: parent.width - wrapMode: Text.Wrap - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: buttonRow.height * 1.2 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - id: buttonRow - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: implicitHeight - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.close() - } - Button { - text: "go to /tmp" - anchors.verticalCenter: parent.verticalCenter - // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet. - onClicked: fileDialog.folder = (Qt.platform.os === "windows" ? "/c:/temp" : "/tmp") - } - } - } -} diff --git a/examples/quick/dialogs/systemdialogs/FontDialogs.qml b/examples/quick/dialogs/systemdialogs/FontDialogs.qml deleted file mode 100644 index 7d4328994b..0000000000 --- a/examples/quick/dialogs/systemdialogs/FontDialogs.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples 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.2 -import QtQuick.Dialogs 1.1 -import "../../shared" - -Rectangle { - width: 320 - height: 360 - color: palette.window - SystemPalette { id: palette } - clip: true - - FontDialog { - id: fontDialog - visible: fontDialogVisible.checked - modality: fontDialogModal.checked ? Qt.WindowModal : Qt.NonModal - scalableFonts: fontDialogScalableFonts.checked - nonScalableFonts: fontDialogNonScalableFonts.checked - monospacedFonts: fontDialogMonospacedFonts.checked - proportionalFonts: fontDialogProportionalFonts.checked - title: "Choose a font" - font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal }) - onAccepted: { console.log("Accepted: " + font) } - onRejected: { console.log("Rejected") } - } - - Column { - id: optionsColumn - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - font.bold: true - text: "Font dialog properties:" - } - CheckBox { - id: fontDialogModal - text: "Modal" - checked: true - Binding on checked { value: fontDialog.modality != Qt.NonModal } - } - CheckBox { - id: fontDialogScalableFonts - text: "Scalable fonts" - Binding on checked { value: fontDialog.scalableFonts } - } - CheckBox { - id: fontDialogNonScalableFonts - text: "Non scalable fonts" - Binding on checked { value: fontDialog.nonScalableFonts } - } - CheckBox { - id: fontDialogMonospacedFonts - text: "Monospaced fonts" - Binding on checked { value: fontDialog.monospacedFonts } - } - CheckBox { - id: fontDialogProportionalFonts - text: "Proportional fonts" - Binding on checked { value: fontDialog.proportionalFonts } - } - CheckBox { - id: fontDialogVisible - text: "Visible" - Binding on checked { value: fontDialog.visible } - } - Text { - text: "Current font:" - } - Text { - id: fontLabel - color: palette.windowText - text: "<b>" + fontDialog.font.family + " - " + fontDialog.font.pointSize + "</b>" - MouseArea { - anchors.fill: parent - onClicked: fontDialog.open() - } - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: buttonRow.height * 1.2 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - id: buttonRow - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: fontDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: fontDialog.close() - } - Button { - text: "set to default" - anchors.verticalCenter: parent.verticalCenter - onClicked: fontDialog.font = Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal }) - } - } - } -} diff --git a/examples/quick/dialogs/systemdialogs/MessageDialogs.qml b/examples/quick/dialogs/systemdialogs/MessageDialogs.qml deleted file mode 100644 index 9c70228046..0000000000 --- a/examples/quick/dialogs/systemdialogs/MessageDialogs.qml +++ /dev/null @@ -1,307 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples 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.Dialogs 1.1 -import QtQuick.Window 2.0 -import "../../shared" - -Rectangle { - width: 580 - height: 400 - color: palette.window - SystemPalette { id: palette } - clip: true - - //! [messagedialog] - MessageDialog { - id: messageDialog - visible: messageDialogVisible.checked - modality: messageDialogModal.checked ? Qt.WindowModal : Qt.NonModal - title: windowTitleField.text - text: customizeText.checked ? textField.text : "" - informativeText: customizeInformativeText.checked ? informativeTextField.text : "" - detailedText: customizeDetailedText.checked ? detailedTextField.text : "" - onButtonClicked: console.log("clicked button " + clickedButton) - onAccepted: lastChosen.text = "Accepted " + - (clickedButton == StandardButton.Ok ? "(OK)" : (clickedButton == StandardButton.Retry ? "(Retry)" : "(Ignore)")) - onRejected: lastChosen.text = "Rejected " + - (clickedButton == StandardButton.Close ? "(Close)" : (clickedButton == StandardButton.Abort ? "(Abort)" : "(Cancel)")) - onHelp: lastChosen.text = "Yelped for help!" - onYes: lastChosen.text = (clickedButton == StandardButton.Yes ? "Yeessss!!" : "Yes, now and always") - onNo: lastChosen.text = (clickedButton == StandardButton.No ? "Oh No." : "No, no, a thousand times no!") - onApply: lastChosen.text = "Apply" - onReset: lastChosen.text = "Reset" - } - //! [messagedialog] - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - font.bold: true - text: "Message dialog properties:" - } - CheckBox { - id: messageDialogModal - text: "Modal" - checked: true - Binding on checked { value: messageDialog.modality != Qt.NonModal } - } - CheckBox { - id: customizeTitle - text: "Window Title" - checked: true - width: parent.width - TextField { - id: windowTitleField - anchors.right: parent.right - width: informativeTextField.width - text: "Alert" - } - } - Row { - spacing: 8 - property bool updating: false - function updateIcon(icon, checked) { - if (updating) return - updating = true - messageDialog.icon = (checked ? icon : StandardIcon.NoIcon) - for (var i = 0; i < children.length; ++i) - if (children[i].icon !== icon) - children[i].checked = false - updating = false - } - - CheckBox { - id: iconInformation - text: "Information" - property int icon: StandardIcon.Information - onCheckedChanged: parent.updateIcon(icon, checked) - } - - CheckBox { - id: iconWarning - text: "Warning" - checked: true - property int icon: StandardIcon.Warning - onCheckedChanged: parent.updateIcon(icon, checked) - Component.onCompleted: parent.updateIcon(icon, true) - } - - CheckBox { - id: iconCritical - text: "Critical" - property int icon: StandardIcon.Critical - onCheckedChanged: parent.updateIcon(icon, checked) - } - - CheckBox { - id: iconQuestion - text: "Question" - property int icon: StandardIcon.Question - onCheckedChanged: parent.updateIcon(icon, checked) - } - } - - CheckBox { - id: customizeText - text: "Primary Text" - checked: true - width: parent.width - TextField { - id: textField - anchors.right: parent.right - width: informativeTextField.width - text: "Attention Please" - } - } - CheckBox { - id: customizeInformativeText - text: "Informative Text" - checked: true - width: parent.width - TextField { - id: informativeTextField - anchors.right: parent.right - width: parent.width - parent.row.spacing - parent.row.width - text: "Be alert!" - } - } - Text { - text: "Buttons:" - } - Flow { - spacing: 8 - width: parent.width - property bool updating: false - function updateButtons(button, checked) { - if (updating) return - updating = true - var buttons = 0 - for (var i = 0; i < children.length; ++i) - if (children[i].checked) - buttons |= children[i].button - if (!buttons) - buttons = StandardButton.Ok - messageDialog.standardButtons = buttons - updating = false - } - - CheckBox { - text: "Help" - property int button: StandardButton.Help - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Abort" - property int button: StandardButton.Abort - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Close" - property int button: StandardButton.Close - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Cancel" - property int button: StandardButton.Cancel - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "NoToAll" - property int button: StandardButton.NoToAll - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "No" - property int button: StandardButton.No - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "YesToAll" - property int button: StandardButton.YesToAll - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Yes" - property int button: StandardButton.Yes - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Ignore" - property int button: StandardButton.Ignore - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "Retry" - property int button: StandardButton.Retry - onCheckedChanged: parent.updateButtons(button, checked) - } - - CheckBox { - text: "OK" - checked: true - property int button: StandardButton.Ok - onCheckedChanged: parent.updateButtons(button, checked) - } - } - CheckBox { - id: customizeDetailedText - text: "Detailed Text" - checked: true - width: parent.width - TextField { - id: detailedTextField - anchors.right: parent.right - width: informativeTextField.width - text: "The world needs more lerts." - } - } - CheckBox { - id: messageDialogVisible - text: "Visible" - Binding on checked { value: messageDialog.visible } - } - Text { - id: lastChosen - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: buttonRow.height * 1.2 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - id: buttonRow - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: messageDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: messageDialog.close() - } - } - } -} diff --git a/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg b/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg Binary files differdeleted file mode 100644 index 4517a39308..0000000000 --- a/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg +++ /dev/null diff --git a/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc b/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc deleted file mode 100644 index 9788be7343..0000000000 --- a/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ -/*! - \title Qt Quick System Dialog Examples - \example systemdialogs - \brief This example demonstrates the system dialog types in QML - \image systemdialogs-example.jpg - \ingroup qtquickdialog_examples - - This example demonstrates the system dialogs in the \l{Qt Quick Dialogs} - module. The appearance and behavior is platform-dependent. - - A \l FileDialog is used to choose a single file, multiple files or a - single directory, depending on how it is configured. - \snippet systemdialogs/FileDialogs.qml filedialog - - A \l ColorDialog is used to choose a color, with or without alpha (transparency) - depending on how it is configured. - \snippet systemdialogs/ColorDialogs.qml colordialog - - The example can be built as a standalone executable, but each - type of dialog is demonstrated in a separate QML file which can - also be run separately with qmlscene. -*/ diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.pro b/examples/quick/dialogs/systemdialogs/systemdialogs.pro deleted file mode 100644 index 323ea2fac7..0000000000 --- a/examples/quick/dialogs/systemdialogs/systemdialogs.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp -RESOURCES += systemdialogs.qrc ../../shared/shared.qrc - -OTHER_FILES += \ - systemdialogs.qml \ - FileDialogs.qml \ - ColorDialogs.qml \ - FontDialogs.qml \ - MessageDialogs.qml - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs/systemdialogs -INSTALLS += target diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qrc b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc deleted file mode 100644 index 2193088cb9..0000000000 --- a/examples/quick/dialogs/systemdialogs/systemdialogs.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/dialogs/systemdialogs"> - <file>systemdialogs.qml</file> - <file>FileDialogs.qml</file> - <file>ColorDialogs.qml</file> - <file>FontDialogs.qml</file> - <file>MessageDialogs.qml</file> - </qresource> -</RCC> diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index c6b7ee1c34..186988716c 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -21,7 +21,6 @@ SUBDIRS = quick-accessibility \ customitems \ imageprovider \ window \ - dialogs \ particles \ demos diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qml b/examples/quick/views/listview/displaymargin.qml index 1600e88812..c3402f6baa 100644 --- a/examples/quick/dialogs/systemdialogs/systemdialogs.qml +++ b/examples/quick/views/listview/displaymargin.qml @@ -37,35 +37,57 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +import QtQuick 2.3 -import QtQuick 2.2 -import "../../shared" +Item { + width: 480; height: 320 -TabSet { - width: 580 - height: 440 + ListView { + id: view + anchors.top: header.bottom + anchors.bottom: footer.top + width: parent.width - FileDialogs { - property string title: "File Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png - } + cacheBuffer: 0 + displayMarginBeginning: 40 + displayMarginEnd: 40 - ColorDialogs { - property string title: "Color Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png + model: 100 + delegate: Rectangle { + objectName: "delegate" + width: parent.width + height: 25 + color: index % 2 ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + color: "white" + text: "Item " + (index + 1) + } + } } - FontDialogs { - property string title: "Font Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png + Rectangle { + id: header + width: parent.width; height: 40 + color: "#AAFF0000" + + Text { + anchors.centerIn: parent + font.pixelSize: 24 + text: "Header" + } } - MessageDialogs { - property string title: "Message Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png + Rectangle { + id: footer + anchors.bottom: parent.bottom + width: parent.width; height: 40 + color: "#AAFF0000" + + Text { + anchors.centerIn: parent + font.pixelSize: 24 + text: "Footer" + } } } diff --git a/examples/quick/views/views.qml b/examples/quick/views/views.qml index 1bc6f6a3d8..2fbf9c5470 100644 --- a/examples/quick/views/views.qml +++ b/examples/quick/views/views.qml @@ -58,6 +58,7 @@ Item { addExample("Packages", "Transitions between a ListView and GridView", Qt.resolvedUrl("package/view.qml")) addExample("PathView", "A simple PathView", Qt.resolvedUrl("pathview/pathview-example.qml")) addExample("ObjectModel", "Using a ObjectModel", Qt.resolvedUrl("objectmodel/objectmodel.qml")) + addExample("Display Margins", "A ListView with display margins", Qt.resolvedUrl("listview/displaymargin.qml")) } } } diff --git a/examples/quick/views/views.qrc b/examples/quick/views/views.qrc index 434fa788bf..52abb68659 100644 --- a/examples/quick/views/views.qrc +++ b/examples/quick/views/views.qrc @@ -65,5 +65,6 @@ <file>visualdatamodel/dragselection.qml</file> <file>objectmodel/objectmodel.qml</file> <file>views.qml</file> + <file>listview/displaymargin.qml</file> </qresource> </RCC> diff --git a/src/imports/dialogs-private/dialogs-private.pro b/src/imports/dialogs-private/dialogs-private.pro deleted file mode 100644 index 7f04617ef5..0000000000 --- a/src/imports/dialogs-private/dialogs-private.pro +++ /dev/null @@ -1,17 +0,0 @@ -CXX_MODULE = qml -TARGET = dialogsprivateplugin -TARGETPATH = QtQuick/Dialogs/Private -IMPORT_VERSION = 1.1 - -SOURCES += \ - qquickfontlistmodel.cpp \ - qquickwritingsystemlistmodel.cpp \ - dialogsprivateplugin.cpp - -HEADERS += \ - qquickfontlistmodel_p.h \ - qquickwritingsystemlistmodel_p.h - -QT += gui-private core-private qml-private - -load(qml_plugin) diff --git a/src/imports/dialogs-private/qmldir b/src/imports/dialogs-private/qmldir deleted file mode 100644 index c371f8bb8c..0000000000 --- a/src/imports/dialogs-private/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtQuick.Dialogs.Private -plugin dialogsprivateplugin -typeinfo plugins.qmltypes -classname QtQuick2DialogsPrivatePlugin diff --git a/src/imports/dialogs-private/qquickfontlistmodel.cpp b/src/imports/dialogs-private/qquickfontlistmodel.cpp deleted file mode 100644 index 96d1824ef6..0000000000 --- a/src/imports/dialogs-private/qquickfontlistmodel.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickfontlistmodel_p.h" -#include <QtGui/qfontdatabase.h> -#include <QtQml/qqmlcontext.h> -#include <private/qqmlengine_p.h> -#include <private/qv8engine_p.h> -#include <private/qv4value_p.h> -#include <private/qv4engine_p.h> -#include <private/qv4object_p.h> - -QT_BEGIN_NAMESPACE - -using namespace QV4; - -class QQuickFontListModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickFontListModel) - -public: - QQuickFontListModelPrivate(QQuickFontListModel *q) - : q_ptr(q), ws(QFontDatabase::Any) - , options(QSharedPointer<QFontDialogOptions>(new QFontDialogOptions())) - {} - - QQuickFontListModel *q_ptr; - QFontDatabase db; - QFontDatabase::WritingSystem ws; - QSharedPointer<QFontDialogOptions> options; - QStringList families; - QHash<int, QByteArray> roleNames; - ~QQuickFontListModelPrivate() {} - void init(); -}; - - -void QQuickFontListModelPrivate::init() -{ - Q_Q(QQuickFontListModel); - - families = db.families(); - - emit q->rowCountChanged(); - emit q->writingSystemChanged(); -} - -QQuickFontListModel::QQuickFontListModel(QObject *parent) - : QAbstractListModel(parent), d_ptr(new QQuickFontListModelPrivate(this)) -{ - Q_D(QQuickFontListModel); - d->roleNames[FontFamilyRole] = "family"; - d->init(); -} - -QQuickFontListModel::~QQuickFontListModel() -{ -} - -QVariant QQuickFontListModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickFontListModel); - QVariant rv; - - if (index.row() >= d->families.size()) - return rv; - - switch (role) - { - case FontFamilyRole: - rv = d->families.at(index.row()); - break; - default: - break; - } - return rv; -} - -QHash<int, QByteArray> QQuickFontListModel::roleNames() const -{ - Q_D(const QQuickFontListModel); - return d->roleNames; -} - -int QQuickFontListModel::rowCount(const QModelIndex &parent) const -{ - Q_D(const QQuickFontListModel); - Q_UNUSED(parent); - return d->families.size(); -} - -QModelIndex QQuickFontListModel::index(int row, int , const QModelIndex &) const -{ - return createIndex(row, 0); -} - -QString QQuickFontListModel::writingSystem() const -{ - Q_D(const QQuickFontListModel); - return QFontDatabase::writingSystemName(d->ws); -} - -void QQuickFontListModel::setWritingSystem(const QString &wSystem) -{ - Q_D(QQuickFontListModel); - - if (wSystem == writingSystem()) - return; - - QList<QFontDatabase::WritingSystem> wss; - wss << QFontDatabase::Any; - wss << d->db.writingSystems(); - QFontDatabase::WritingSystem ws; - foreach (ws, wss) { - if (wSystem == QFontDatabase::writingSystemName(ws)) { - d->ws = ws; - updateFamilies(); - return; - } - } -} - -void QQuickFontListModel::updateFamilies() -{ - Q_D(QQuickFontListModel); - - beginResetModel(); - const QFontDialogOptions::FontDialogOptions scalableMask = (QFontDialogOptions::FontDialogOptions)(QFontDialogOptions::ScalableFonts | QFontDialogOptions::NonScalableFonts); - const QFontDialogOptions::FontDialogOptions spacingMask = (QFontDialogOptions::FontDialogOptions)(QFontDialogOptions::ProportionalFonts | QFontDialogOptions::MonospacedFonts); - const QFontDialogOptions::FontDialogOptions options = d->options->options(); - - d->families.clear(); - foreach (const QString &family, d->db.families(d->ws)) { - if ((options & scalableMask) && (options & scalableMask) != scalableMask) { - if (bool(options & QFontDialogOptions::ScalableFonts) != d->db.isSmoothlyScalable(family)) - continue; - } - if ((options & spacingMask) && (options & spacingMask) != spacingMask) { - if (bool(options & QFontDialogOptions::MonospacedFonts) != d->db.isFixedPitch(family)) - continue; - } - d->families << family; - } - endResetModel(); -} - -bool QQuickFontListModel::scalableFonts() const -{ - Q_D(const QQuickFontListModel); - return d->options->testOption(QFontDialogOptions::ScalableFonts); -} - -bool QQuickFontListModel::nonScalableFonts() const -{ - Q_D(const QQuickFontListModel); - return d->options->testOption(QFontDialogOptions::NonScalableFonts); -} - -bool QQuickFontListModel::monospacedFonts() const -{ - Q_D(const QQuickFontListModel); - return d->options->testOption(QFontDialogOptions::MonospacedFonts); -} - -bool QQuickFontListModel::proportionalFonts() const -{ - Q_D(const QQuickFontListModel); - return d->options->testOption(QFontDialogOptions::ProportionalFonts); -} - -QQmlV4Handle QQuickFontListModel::get(int idx) const -{ - Q_D(const QQuickFontListModel); - - if (idx < 0 || idx >= count()) - return QQmlV4Handle(Encode::undefined()); - - QQmlEngine *engine = qmlContext(this)->engine(); - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Scope scope(v4engine); - ScopedObject o(scope, v4engine->newObject()); - ScopedString s(scope); - for (int ii = 0; ii < d->roleNames.keys().count(); ++ii) { - Property *p = o->insertMember((s = v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1])), PropertyAttributes()); - p->value = v8engine->fromVariant(data(index(idx, 0), Qt::UserRole + ii + 1)); - } - - return QQmlV4Handle(o); -} - -QQmlV4Handle QQuickFontListModel::pointSizes() -{ - QQmlEngine *engine = qmlContext(this)->engine(); - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Scope scope(v4engine); - - QList<int> pss = QFontDatabase::standardSizes(); - int size = pss.size(); - - Scoped<QV4::ArrayObject> a(scope, v4engine->newArrayObject()); - a->arrayReserve(size); - a->arrayDataLen = size; - for (int i = 0; i < size; ++i) - a->arrayData[i].value = Primitive::fromInt32(pss.at(i)); - a->setArrayLengthUnchecked(size); - - return QQmlV4Handle(ScopedValue(scope, a.asReturnedValue())); -} - -void QQuickFontListModel::classBegin() -{ -} - -void QQuickFontListModel::componentComplete() -{ -} - -void QQuickFontListModel::setScalableFonts(bool arg) -{ - Q_D(QQuickFontListModel); - d->options->setOption(QFontDialogOptions::ScalableFonts, arg); - updateFamilies(); - emit scalableFontsChanged(); -} - -void QQuickFontListModel::setNonScalableFonts(bool arg) -{ - Q_D(QQuickFontListModel); - d->options->setOption(QFontDialogOptions::NonScalableFonts, arg); - updateFamilies(); - emit nonScalableFontsChanged(); -} - -void QQuickFontListModel::setMonospacedFonts(bool arg) -{ - Q_D(QQuickFontListModel); - d->options->setOption(QFontDialogOptions::MonospacedFonts, arg); - updateFamilies(); - emit monospacedFontsChanged(); -} - -void QQuickFontListModel::setProportionalFonts(bool arg) -{ - Q_D(QQuickFontListModel); - d->options->setOption(QFontDialogOptions::ProportionalFonts, arg); - updateFamilies(); - emit proportionalFontsChanged(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs-private/qquickfontlistmodel_p.h b/src/imports/dialogs-private/qquickfontlistmodel_p.h deleted file mode 100644 index 3e2e7f7132..0000000000 --- a/src/imports/dialogs-private/qquickfontlistmodel_p.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKFONTLISTMODEL_P_H -#define QQUICKFONTLISTMODEL_P_H - -#include <QtCore/qstringlist.h> -#include <QtCore/qabstractitemmodel.h> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <QtQml/qqmlparserstatus.h> -#include <private/qv8engine_p.h> - -QT_BEGIN_NAMESPACE - -class QModelIndex; - -class QQuickFontListModelPrivate; - -class QQuickFontListModel : public QAbstractListModel, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QString writingSystem READ writingSystem WRITE setWritingSystem NOTIFY writingSystemChanged) - - Q_PROPERTY(bool scalableFonts READ scalableFonts WRITE setScalableFonts NOTIFY scalableFontsChanged) - Q_PROPERTY(bool nonScalableFonts READ nonScalableFonts WRITE setNonScalableFonts NOTIFY nonScalableFontsChanged) - Q_PROPERTY(bool monospacedFonts READ monospacedFonts WRITE setMonospacedFonts NOTIFY monospacedFontsChanged) - Q_PROPERTY(bool proportionalFonts READ proportionalFonts WRITE setProportionalFonts NOTIFY proportionalFontsChanged) - - Q_PROPERTY(int count READ count NOTIFY rowCountChanged) - -public: - QQuickFontListModel(QObject *parent = 0); - ~QQuickFontListModel(); - - enum Roles { - FontFamilyRole = Qt::UserRole + 1 - }; - - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual QHash<int, QByteArray> roleNames() const; - - int count() const { return rowCount(QModelIndex()); } - - QString writingSystem() const; - void setWritingSystem(const QString& writingSystem); - - bool scalableFonts() const; - bool nonScalableFonts() const; - bool monospacedFonts() const; - bool proportionalFonts() const; - - Q_INVOKABLE QQmlV4Handle get(int index) const; - Q_INVOKABLE QQmlV4Handle pointSizes(); - - virtual void classBegin(); - virtual void componentComplete(); - -public Q_SLOTS: - void setScalableFonts(bool arg); - void setNonScalableFonts(bool arg); - void setMonospacedFonts(bool arg); - void setProportionalFonts(bool arg); - -Q_SIGNALS: - void scalableFontsChanged(); - void nonScalableFontsChanged(); - void monospacedFontsChanged(); - void proportionalFontsChanged(); - void writingSystemChanged(); - void rowCountChanged() const; - -protected: - void updateFamilies(); - -private: - Q_DISABLE_COPY(QQuickFontListModel) - Q_DECLARE_PRIVATE(QQuickFontListModel) - QScopedPointer<QQuickFontListModelPrivate> d_ptr; - -}; - -QT_END_NAMESPACE - -#endif // QQUICKFONTLISTMODEL_P_H diff --git a/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp b/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp deleted file mode 100644 index f2b4ff8b8f..0000000000 --- a/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickwritingsystemlistmodel_p.h" -#include <QtGui/qfontdatabase.h> -#include <QtQml/qqmlcontext.h> -#include <private/qqmlengine_p.h> -#include <private/qv8engine_p.h> -#include <private/qv4value_p.h> -#include <private/qv4engine_p.h> -#include <private/qv4object_p.h> - -QT_BEGIN_NAMESPACE - -using namespace QV4; - -class QQuickWritingSystemListModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickWritingSystemListModel) - -public: - QQuickWritingSystemListModelPrivate(QQuickWritingSystemListModel *q) - : q_ptr(q) - {} - - QQuickWritingSystemListModel *q_ptr; - QList<QFontDatabase::WritingSystem> wss; - QHash<int, QByteArray> roleNames; - ~QQuickWritingSystemListModelPrivate() {} - void init(); -}; - - -void QQuickWritingSystemListModelPrivate::init() -{ - Q_Q(QQuickWritingSystemListModel); - wss << QFontDatabase::Any; - QFontDatabase db; - wss << db.writingSystems(); - - emit q->rowCountChanged(); - emit q->writingSystemsChanged(); -} - -QQuickWritingSystemListModel::QQuickWritingSystemListModel(QObject *parent) - : QAbstractListModel(parent), d_ptr(new QQuickWritingSystemListModelPrivate(this)) -{ - Q_D(QQuickWritingSystemListModel); - d->roleNames[WritingSystemNameRole] = "name"; - d->roleNames[WritingSystemSampleRole] = "sample"; - d->init(); -} - -QQuickWritingSystemListModel::~QQuickWritingSystemListModel() -{ -} - -QVariant QQuickWritingSystemListModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickWritingSystemListModel); - QVariant rv; - - if (index.row() >= d->wss.size()) - return rv; - - switch (role) - { - case WritingSystemNameRole: - rv = QFontDatabase::writingSystemName(d->wss.at(index.row())); - break; - case WritingSystemSampleRole: - rv = QFontDatabase::writingSystemSample(d->wss.at(index.row())); - break; - default: - break; - } - return rv; -} - -QHash<int, QByteArray> QQuickWritingSystemListModel::roleNames() const -{ - Q_D(const QQuickWritingSystemListModel); - return d->roleNames; -} - -int QQuickWritingSystemListModel::rowCount(const QModelIndex &parent) const -{ - Q_D(const QQuickWritingSystemListModel); - Q_UNUSED(parent); - return d->wss.size(); -} - -QModelIndex QQuickWritingSystemListModel::index(int row, int , const QModelIndex &) const -{ - return createIndex(row, 0); -} - -QStringList QQuickWritingSystemListModel::writingSystems() const -{ - Q_D(const QQuickWritingSystemListModel); - QStringList result; - QFontDatabase::WritingSystem ws; - foreach (ws, d->wss) - result.append(QFontDatabase::writingSystemName(ws)); - - return result; -} - -QQmlV4Handle QQuickWritingSystemListModel::get(int idx) const -{ - Q_D(const QQuickWritingSystemListModel); - - if (idx < 0 || idx >= count()) - return QQmlV4Handle(Encode::undefined()); - - QQmlEngine *engine = qmlContext(this)->engine(); - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Scope scope(v4engine); - ScopedObject o(scope, v4engine->newObject()); - ScopedString s(scope); - for (int ii = 0; ii < d->roleNames.keys().count(); ++ii) { - Property *p = o->insertMember((s = v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1])), PropertyAttributes()); - p->value = v8engine->fromVariant(data(index(idx, 0), Qt::UserRole + ii + 1)); - } - - return QQmlV4Handle(o); -} - -void QQuickWritingSystemListModel::classBegin() -{ -} - -void QQuickWritingSystemListModel::componentComplete() -{ -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs-private/qquickwritingsystemlistmodel_p.h b/src/imports/dialogs-private/qquickwritingsystemlistmodel_p.h deleted file mode 100644 index 31058bbf78..0000000000 --- a/src/imports/dialogs-private/qquickwritingsystemlistmodel_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKWRITINGSYSTEMLISTMODEL_P_H -#define QQUICKWRITINGSYSTEMLISTMODEL_P_H - -#include <QtCore/qstringlist.h> -#include <QtCore/qabstractitemmodel.h> -#include <QtQml/qqmlparserstatus.h> -#include <private/qv8engine_p.h> - -QT_BEGIN_NAMESPACE - -class QModelIndex; - -class QQuickWritingSystemListModelPrivate; - -class QQuickWritingSystemListModel : public QAbstractListModel, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QStringList writingSystems READ writingSystems NOTIFY writingSystemsChanged) - - Q_PROPERTY(int count READ count NOTIFY rowCountChanged) - -public: - QQuickWritingSystemListModel(QObject *parent = 0); - ~QQuickWritingSystemListModel(); - - enum Roles { - WritingSystemNameRole = Qt::UserRole + 1, - WritingSystemSampleRole = Qt::UserRole + 2 - }; - - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual QHash<int, QByteArray> roleNames() const; - - int count() const { return rowCount(QModelIndex()); } - - QStringList writingSystems() const; - - Q_INVOKABLE QQmlV4Handle get(int index) const; - - virtual void classBegin(); - virtual void componentComplete(); - -Q_SIGNALS: - void writingSystemsChanged(); - void rowCountChanged() const; - -private: - Q_DISABLE_COPY(QQuickWritingSystemListModel) - Q_DECLARE_PRIVATE(QQuickWritingSystemListModel) - QScopedPointer<QQuickWritingSystemListModelPrivate> d_ptr; - -}; - -QT_END_NAMESPACE - -#endif // QQUICKWRITINGSYSTEMLISTMODEL_P_H diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml deleted file mode 100644 index 4913e332d7..0000000000 --- a/src/imports/dialogs/DefaultColorDialog.qml +++ /dev/null @@ -1,362 +0,0 @@ -/***************************************************************************** -** -** 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: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.Window 2.1 -import QtQuick.Dialogs 1.0 -import "qml" - -AbstractColorDialog { - id: root - property bool __valueSet: true // guard to prevent binding loops - function __setControlsFromColor() { - __valueSet = false - hueSlider.value = root.currentHue - saturationSlider.value = root.currentSaturation - lightnessSlider.value = root.currentLightness - alphaSlider.value = root.currentAlpha - crosshairs.x = root.currentLightness * paletteMap.width - crosshairs.y = (1.0 - root.currentSaturation) * paletteMap.height - __valueSet = true - } - onCurrentColorChanged: __setControlsFromColor() - onSelectionAccepted: root.color = root.currentColor - - Rectangle { - id: content - property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - implicitHeight: Math.min(maxSize, Screen.pixelDensity * (usePaletteMap ? 100 : 50)) - implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5 - color: palette.window - focus: root.visible - property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3 - property real spacing: 8 - property real outerSpacing: 12 - property bool usePaletteMap: true - - Keys.onPressed: { - event.accepted = true - switch (event.key) { - case Qt.Key_Return: - case Qt.Key_Select: - accept() - break - case Qt.Key_Escape: - case Qt.Key_Back: - reject() - break - case Qt.Key_C: - if (event.modifiers & Qt.ControlModifier) - colorField.copyAll() - break - case Qt.Key_V: - if (event.modifiers & Qt.ControlModifier) { - colorField.paste() - root.currentColor = colorField.text - } - break - default: - // do nothing - event.accepted = false - break - } - } - - // set the preferred width based on height, to avoid "letterboxing" the paletteMap - onHeightChanged: implicitHeight = Math.max((usePaletteMap ? 480 : bottomMinHeight), height) - - SystemPalette { id: palette } - - Item { - id: paletteFrame - visible: content.usePaletteMap - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: content.outerSpacing - } - height: Math.min(content.height - content.bottomMinHeight, content.width - content.outerSpacing * 2) - - Image { - id: paletteMap - x: (parent.width - width) / 2 - width: height - onWidthChanged: root.__setControlsFromColor() - height: parent.height - source: "images/checkers.png" - fillMode: Image.Tile - - // note we smoothscale the shader from a smaller version to improve performance - ShaderEffect { - id: map - width: 64 - height: 64 - opacity: alphaSlider.value - scale: paletteMap.width / width; - layer.enabled: true - layer.smooth: true - anchors.centerIn: parent - property real hue: hueSlider.value - - fragmentShader: " - varying mediump vec2 qt_TexCoord0; - uniform highp float qt_Opacity; - uniform highp float hue; - - highp float hueToIntensity(highp float v1, highp float v2, highp float h) { - h = fract(h); - if (h < 1.0 / 6.0) - return v1 + (v2 - v1) * 6.0 * h; - else if (h < 1.0 / 2.0) - return v2; - else if (h < 2.0 / 3.0) - return v1 + (v2 - v1) * 6.0 * (2.0 / 3.0 - h); - - return v1; - } - - highp vec3 HSLtoRGB(highp vec3 color) { - highp float h = color.x; - highp float l = color.z; - highp float s = color.y; - - if (s < 1.0 / 256.0) - return vec3(l, l, l); - - highp float v1; - highp float v2; - if (l < 0.5) - v2 = l * (1.0 + s); - else - v2 = (l + s) - (s * l); - - v1 = 2.0 * l - v2; - - highp float d = 1.0 / 3.0; - highp float r = hueToIntensity(v1, v2, h + d); - highp float g = hueToIntensity(v1, v2, h); - highp float b = hueToIntensity(v1, v2, h - d); - return vec3(r, g, b); - } - - void main() { - lowp vec4 c = vec4(1.0); - c.rgb = HSLtoRGB(vec3(hue, 1.0 - qt_TexCoord0.t, qt_TexCoord0.s)); - gl_FragColor = c * qt_Opacity; - } - " - } - - MouseArea { - id: mapMouseArea - anchors.fill: parent - onPositionChanged: { - if (pressed && containsMouse) { - var xx = Math.max(0, Math.min(mouse.x, parent.width)) - var yy = Math.max(0, Math.min(mouse.y, parent.height)) - saturationSlider.value = 1.0 - yy / parent.height - lightnessSlider.value = xx / parent.width - // TODO if we constrain the movement here, can avoid the containsMouse test - crosshairs.x = mouse.x - crosshairs.radius - crosshairs.y = mouse.y - crosshairs.radius - } - } - onPressed: positionChanged(mouse) - } - - Image { - id: crosshairs - property int radius: width / 2 // truncated to int - source: "images/crosshairs.png" - } - - BorderImage { - anchors.fill: parent - anchors.margins: -1 - anchors.leftMargin: -2 - source: "images/sunken_frame.png" - border.left: 8 - border.right: 8 - border.top: 8 - border.bottom: 8 - } - } - } - - Column { - id: sliders - anchors { - top: paletteFrame.bottom - left: parent.left - right: parent.right - margins: content.outerSpacing - } - spacing: content.spacing - - ColorSlider { - id: hueSlider - value: 0.5 - onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) - text: qsTr("Hue") - trackDelegate: Rectangle { - rotation: -90 - transformOrigin: Item.TopLeft - gradient: Gradient { - GradientStop {position: 0.000; color: Qt.rgba(1, 0, 0, 1)} - GradientStop {position: 0.167; color: Qt.rgba(1, 1, 0, 1)} - GradientStop {position: 0.333; color: Qt.rgba(0, 1, 0, 1)} - GradientStop {position: 0.500; color: Qt.rgba(0, 1, 1, 1)} - GradientStop {position: 0.667; color: Qt.rgba(0, 0, 1, 1)} - GradientStop {position: 0.833; color: Qt.rgba(1, 0, 1, 1)} - GradientStop {position: 1.000; color: Qt.rgba(1, 0, 0, 1)} - } - } - } - - ColorSlider { - id: saturationSlider - visible: !content.usePaletteMap - value: 0.5 - onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) - text: qsTr("Saturation") - trackDelegate: Rectangle { - rotation: -90 - transformOrigin: Item.TopLeft - gradient: Gradient { - GradientStop { position: 0; color: Qt.hsla(hueSlider.value, 0.0, lightnessSlider.value, 1.0) } - GradientStop { position: 1; color: Qt.hsla(hueSlider.value, 1.0, lightnessSlider.value, 1.0) } - } - } - } - - ColorSlider { - id: lightnessSlider - visible: !content.usePaletteMap - value: 0.5 - onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) - text: qsTr("Luminosity") - trackDelegate: Rectangle { - rotation: -90 - transformOrigin: Item.TopLeft - gradient: Gradient { - GradientStop { position: 0; color: "black" } - GradientStop { position: 0.5; color: Qt.hsla(hueSlider.value, saturationSlider.value, 0.5, 1.0) } - GradientStop { position: 1; color: "white" } - } - } - } - - ColorSlider { - id: alphaSlider - minimum: 0.0 - maximum: 1.0 - value: 1.0 - onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) - text: qsTr("Alpha") - visible: root.showAlphaChannel - trackDelegate: Item { - rotation: -90 - transformOrigin: Item.TopLeft - Image { - anchors {fill: parent} - source: "images/checkers.png" - fillMode: Image.TileVertically - } - Rectangle { - anchors.fill: parent - gradient: Gradient { - GradientStop { position: 0; color: "transparent" } - GradientStop { position: 1; color: Qt.hsla(hueSlider.value, - saturationSlider.value, - lightnessSlider.value, 1.0) } - } } - } - } - } - - Item { - id: buttonRow - height: Math.max(buttonsOnly.height, copyIcon.height) - width: parent.width - anchors { - left: parent.left - right: parent.right - bottom: content.bottom - margins: content.outerSpacing - } - Row { - spacing: content.spacing - height: parent.height - TextField { - id: colorField - text: root.currentColor.toString() - anchors.verticalCenter: parent.verticalCenter - onAccepted: root.currentColor = text - Component.onCompleted: width = implicitWidth + 10 - } - Image { - id: copyIcon - anchors.verticalCenter: parent.verticalCenter - source: "images/copy.png" - MouseArea { - anchors.fill: parent - onClicked: colorField.copyAll() - } - } - } - Row { - id: buttonsOnly - spacing: content.spacing - anchors.right: parent.right - Button { - id: cancelButton - text: "Cancel" - onClicked: root.reject() - } - Button { - id: okButton - text: "OK" - onClicked: root.accept() - } - } - } - } -} diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml deleted file mode 100644 index 0a5eabddf2..0000000000 --- a/src/imports/dialogs/DefaultFileDialog.qml +++ /dev/null @@ -1,385 +0,0 @@ -/***************************************************************************** -** -** 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: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.Dialogs 1.0 -import QtQuick.Window 2.1 -import Qt.labs.folderlistmodel 2.0 -import "qml" - -AbstractFileDialog { - id: root - onVisibleChanged: { - if (visible) { - __selectedIndices = [] - __lastClickedIdx = -1 - currentPathField.visible = false - } - } - onFolderChanged: view.model.folder = folder - - property real __textX: titleBar.height - property SystemPalette __palette - property var __selectedIndices: [] - property int __lastClickedIdx: -1 - - function __dirDown(path) { - view.model.folder = path - __lastClickedIdx = -1 - __selectedIndices = [] - } - function __dirUp() { - view.model.folder = view.model.parentFolder - __lastClickedIdx = -1 - __selectedIndices = [] - } - function __up(extend) { - if (view.currentIndex > 0) - --view.currentIndex - else - view.currentIndex = 0 - if (extend) { - if (__selectedIndices.indexOf(view.currentIndex) < 0) { - var selCopy = __selectedIndices - selCopy.push(view.currentIndex) - __selectedIndices = selCopy - } - } else - __selectedIndices = [view.currentIndex] - } - function __down(extend) { - if (view.currentIndex < view.model.count - 1) - ++view.currentIndex - else - view.currentIndex = view.model.count - 1 - if (extend) { - if (__selectedIndices.indexOf(view.currentIndex) < 0) { - var selCopy = __selectedIndices - selCopy.push(view.currentIndex) - __selectedIndices = selCopy - } - } else - __selectedIndices = [view.currentIndex] - } - function __acceptSelection() { - clearSelection() - if (selectFolder && __selectedIndices.length == 0) - addSelection(folder) - else if (__selectedIndices.length > 0) { - __selectedIndices.map(function(idx) { - if (view.model.isFolder(idx)) { - if (selectFolder) - addSelection(view.model.get(idx, "fileURL")) - } else { - if (!selectFolder) - addSelection(view.model.get(idx, "fileURL")) - } - }) - } else { - addSelection(pathToUrl(currentPathField.text)) - } - accept() - } - - Rectangle { - id: content - property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - // TODO: QTBUG-29817 geometry from AbstractFileDialog - implicitWidth: Math.min(maxSize, Screen.pixelDensity * 100) - implicitHeight: Math.min(maxSize, Screen.pixelDensity * 80) - color: __palette.window - focus: root.visible && !currentPathField.visible - property real spacing: 6 - property real outerSpacing: 12 - SystemPalette { id: __palette } - - Component { - id: folderDelegate - Rectangle { - id: wrapper - function launch() { - if (view.model.isFolder(index)) { - __dirDown(filePath) - } else { - root.__acceptSelection() - } - } - width: content.width - height: nameText.implicitHeight * 1.5 - color: "transparent" - Rectangle { - id: itemHighlight - visible: root.__selectedIndices.indexOf(index) >= 0 - anchors.fill: parent - color: __palette.highlight - } - Image { - id: icon - source: "images/folder.png" - height: wrapper.height - y * 2; width: height - x: (root.__textX - width) / 2 - y: 2 - visible: view.model.isFolder(index) - } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: root.__textX - color: itemHighlight.visible ? __palette.highlightedText : __palette.windowText - elide: Text.ElideRight - } - MouseArea { - id: mouseRegion - anchors.fill: parent - onDoubleClicked: { - __selectedIndices = [index] - root.__lastClickedIdx = index - launch() - } - onClicked: { - view.currentIndex = index - if (mouse.modifiers & Qt.ControlModifier && root.selectMultiple) { - // modifying the contents of __selectedIndices doesn't notify, - // so we have to re-assign the variable - var selCopy = __selectedIndices - var existingIdx = selCopy.indexOf(index) - if (existingIdx >= 0) - selCopy.splice(existingIdx, 1) - else - selCopy.push(index) - __selectedIndices = selCopy - } else if (mouse.modifiers & Qt.ShiftModifier && root.selectMultiple) { - if (root.__lastClickedIdx >= 0) { - var sel = [] - if (index > __lastClickedIdx) { - for (var i = root.__lastClickedIdx; i <= index; i++) - sel.push(i) - } else { - for (var i = root.__lastClickedIdx; i >= index; i--) - sel.push(i) - } - __selectedIndices = sel - } - } else { - __selectedIndices = [index] - root.__lastClickedIdx = index - } - } - } - } - } - - Keys.onPressed: { - event.accepted = true - switch (event.key) { - case Qt.Key_Up: - root.__up(event.modifiers & Qt.ShiftModifier && root.selectMultiple) - break - case Qt.Key_Down: - root.__down(event.modifiers & Qt.ShiftModifier && root.selectMultiple) - break - case Qt.Key_Left: - root.__dirUp() - break - case Qt.Key_Return: - case Qt.Key_Select: - case Qt.Key_Right: - if (view.currentItem) - view.currentItem.launch() - else - root.__acceptSelection() - break - case Qt.Key_Back: - case Qt.Key_Escape: - reject() - break - case Qt.Key_C: - if (event.modifiers & Qt.ControlModifier) - currentPathField.copyAll() - break - case Qt.Key_V: - if (event.modifiers & Qt.ControlModifier) { - currentPathField.visible = true - currentPathField.paste() - } - break - default: - // do nothing - event.accepted = false - break - } - } - - ListView { - id: view - anchors.top: titleBar.bottom - anchors.bottom: bottomBar.top - clip: true - x: 0 - width: parent.width - model: FolderListModel { - onFolderChanged: { - root.folder = folder - currentPathField.text = root.urlToPath(view.model.folder) - } - } - delegate: folderDelegate - highlight: Rectangle { - color: "transparent" - border.color: Qt.darker(__palette.window, 1.3) - } - highlightMoveDuration: 0 - highlightMoveVelocity: -1 - } - - MouseArea { - anchors.fill: view - enabled: currentPathField.visible - onClicked: currentPathField.visible = false - } - - - Item { - id: titleBar - width: parent.width - height: currentPathField.height * 1.5 - Rectangle { - anchors.fill: parent - color: Qt.darker(__palette.window, 1.1) - border.color: Qt.darker(__palette.window, 1.3) - } - Rectangle { - id: upButton - width: root.__textX - height: titleBar.height - color: "transparent" - - Image { - id: upButtonImage - anchors.centerIn: parent; source: "images/up.png" - } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: parent.height - onClicked: if (view.model.parentFolder !== "") __dirUp() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: __palette.highlight } - } - ] - } - Text { - id: currentPathText - anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: __textX; anchors.rightMargin: content.spacing - text: root.urlToPath(view.model.folder) - color: __palette.text - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - MouseArea { - anchors.fill: parent - onClicked: currentPathField.visible = true - } - } - TextField { - id: currentPathField - anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: __textX; anchors.rightMargin: content.spacing - visible: false - focus: visible - onAccepted: { - root.clearSelection() - if (root.addSelection(root.pathToUrl(text))) - root.accept() - else - view.model.folder = root.pathFolder(text) - } - onDownPressed: currentPathField.visible = false - onBackPressed: reject() - onEscapePressed: reject() - } - } - Rectangle { - id: bottomBar - width: parent.width - height: buttonRow.height + buttonRow.spacing * 2 - anchors.bottom: parent.bottom - color: Qt.darker(__palette.window, 1.1) - border.color: Qt.darker(__palette.window, 1.3) - - Row { - id: buttonRow - anchors.right: parent.right - anchors.rightMargin: spacing - anchors.verticalCenter: parent.verticalCenter - spacing: content.spacing - TextField { - id: filterField - text: root.selectedNameFilter - visible: !selectFolder - width: bottomBar.width - cancelButton.width - okButton.width - parent.spacing * 5 - anchors.verticalCenter: parent.verticalCenter - onAccepted: { - root.selectNameFilter(text) - view.model.nameFilters = text - } - } - Button { - id: cancelButton - text: "Cancel" - onClicked: root.reject() - } - Button { - id: okButton - text: "OK" - onClicked: { - if (view.model.isFolder(view.currentIndex) && !selectFolder) - __dirDown(view.model.get(view.currentIndex, "filePath")) - else - root.__acceptSelection() - } - } - } - } - } -} diff --git a/src/imports/dialogs/DefaultFontDialog.qml b/src/imports/dialogs/DefaultFontDialog.qml deleted file mode 100644 index 29feed342f..0000000000 --- a/src/imports/dialogs/DefaultFontDialog.qml +++ /dev/null @@ -1,483 +0,0 @@ -/***************************************************************************** -** -** 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 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.Window 2.1 -import QtQuick.Dialogs 1.1 -import QtQuick.Dialogs.Private 1.1 -import "qml" - -AbstractFontDialog { - id: root - - property alias font: content.externalFont - - Rectangle { - id: content - implicitWidth: Math.min(Screen.desktopAvailableWidth, implicitHeight * 1.2) - implicitHeight: Math.min(Screen.desktopAvailableHeight, settingsBottom.implicitHeight * 3) - color: palette.window - focus: root.visible - property real spacing: 6 - property real outerSpacing: 12 - property real listMargins: 4 - property real delegateHeightMultiplier: 1.5 - property real extraWidth: width > 400 ? width - 400 : 0 - property real extraHeight: height > initialHeight ? height - initialHeight : 0 - property real initialHeight: -1 - onHeightChanged: if (visible && initialHeight < 0) initialHeight = height - - property color borderColor: Qt.darker(palette.button, 1.5) - - property font font: Qt.font({ family: "Helvetica", pointSize: 24, weight: Font.Normal }) - property font externalFont - property string writingSystem - property string writingSystemSample - property var pointSizes - - onFontChanged: externalFont = font - - onExternalFontChanged: { - if (content.font != content.externalFont) { - font = externalFont - wsListView.reset() - fontListView.reset() - weightListView.reset() - } - } - - Keys.onPressed: { - event.accepted = true - switch (event.key) { - case Qt.Key_Return: - case Qt.Key_Select: - root.font = content.font - root.accept() - break - case Qt.Key_Escape: - case Qt.Key_Back: - reject() - break - default: - // do nothing - event.accepted = false - break - } - } - - SystemPalette { id: palette } - - Column { - id: contentColumn - anchors.fill: parent - anchors.margins: content.outerSpacing - spacing: content.outerSpacing - - Grid { - id: settingsTop - columns: 3 - spacing: content.spacing - width: parent.width - height: parent.height - buttonRow.height - settingsBottom.height - parent.spacing * 2 - property real columnHeight: height - writingSystemLabel.height - spacing - - Text { id: writingSystemLabel; text: qsTr("Writing System"); font.bold: true } - Text { id: fontNameLabel; text: qsTr("Font"); font.bold: true } - Text { id: sizeLabel; text: qsTr("Size"); font.bold: true } - Rectangle { - id: wsColumn - radius: 3 - color: palette.window - border.color: content.borderColor - implicitWidth: Math.max(writingSystemLabel.implicitWidth, 100) + content.extraWidth / 5 - height: parent.columnHeight - clip: true - ListView { - id: wsListView - anchors.fill: parent - anchors.margins: content.listMargins - anchors.topMargin: 2 - highlightMoveDuration: 0 - onHeightChanged: positionViewAtIndex(currentIndex, ListView.Contain) - function reset() { - if (wsModel.count > 0) { - content.writingSystem = wsModel.get(0).name; - fontModel.writingSystem = content.writingSystem; - content.writingSystemSample = wsModel.get(0).sample; - } - } - - model: WritingSystemListModel { - id: wsModel - Component.onCompleted: wsListView.reset() - } - highlight: Rectangle { - color: palette.highlight - x: 2 - wsListView.anchors.margins - width: wsListView.parent.width - 4 - } - delegate: Item { - width: parent.width - height: wsText.height * content.delegateHeightMultiplier - Text { - id: wsText - text: name - width: parent.width - elide: Text.ElideRight - color: index === wsListView.currentIndex ? palette.highlightedText : palette.windowText - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: { - wsListView.currentIndex = index; - content.writingSystem = wsModel.get(wsListView.currentIndex).name; - fontModel.writingSystem = content.writingSystem; - content.writingSystemSample = wsModel.get(wsListView.currentIndex).sample; - } - } - } - } - } - Rectangle { - radius: 3 - color: palette.window - border.color: content.borderColor - implicitWidth: Math.max(fontNameLabel.implicitWidth, parent.width - wsColumn.implicitWidth - pointSizesColumn.implicitWidth - parent.spacing * 2) - height: parent.columnHeight - clip: true - ListView { - id: fontListView - anchors.fill: parent - anchors.margins: content.listMargins - anchors.topMargin: 2 - highlightMoveDuration: 0 - onHeightChanged: positionViewAtIndex(currentIndex, ListView.Contain) - function reset() { - fontModel.findIndex() - content.pointSizes = fontModel.pointSizes() - fontModel.findPointSizesIndex() - } - - model: FontListModel { - id: fontModel - scalableFonts: root.scalableFonts - nonScalableFonts: root.nonScalableFonts - monospacedFonts: root.monospacedFonts - proportionalFonts: root.proportionalFonts - Component.onCompleted: fontListView.reset() - onModelReset: { findIndex(); } - function findIndex() { - if (fontModel.count <= 0) - return - - if (content.font.family == "") { - content.font.family = fontModel.get(0).family - fontListView.currentIndex = 0 - } else { - var find = false - for (var i = 0; i < fontModel.count; ++i) { - if (content.font.family == fontModel.get(i).family) { - find = true - fontListView.currentIndex = i - break - } - } - if (find == false) { - content.font.family = fontModel.get(0).family - fontListView.currentIndex = 0 - } - } - } - function findPointSizesIndex() { - if (content.pointSizes.length <= 0) - return - - var find = false - for (var i = 0; i < content.pointSizes.length; ++i) { - if (content.font.pointSize == content.pointSizes[i]) { - find = true - pointSizesListView.currentIndex = i - break - } - } - if (find == false) { - content.font.pointSize = content.pointSizes[0] - pointSizesListView.currentIndex = 0 - } - } - } - highlight: Rectangle { - color: palette.highlight - x: 2 - fontListView.anchors.margins - width: fontListView.parent.width - 4 - } - delegate: Item { - width: parent.width - height: fontText.height * content.delegateHeightMultiplier - Text { - id: fontText - text: family - width: parent.width - elide: Text.ElideRight - color: index === fontListView.currentIndex ? palette.highlightedText : palette.windowText - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: { - fontListView.currentIndex = index - content.font.family = fontModel.get(fontListView.currentIndex).family - } - } - } - } - } - Rectangle { - id: pointSizesColumn - radius: 3 - color: palette.window - border.color: content.borderColor - implicitWidth:sizeLabel.implicitWidth * 2 - height: parent.columnHeight - clip: true - ListView { - id: pointSizesListView - anchors.fill: parent - anchors.margins: content.listMargins - anchors.topMargin: 2 - highlightMoveDuration: 0 - onHeightChanged: positionViewAtIndex(currentIndex, ListView.Contain) - model: content.pointSizes - highlight: Rectangle { - color: palette.highlight - x: 2 - pointSizesListView.anchors.margins - width: pointSizesListView.parent.width - 4 - } - delegate: Item { - width: parent.width - height: pointSizesText.height * content.delegateHeightMultiplier - Text { - id: pointSizesText - text: content.pointSizes[index] - width: parent.width - elide: Text.ElideRight - color: index === pointSizesListView.currentIndex ? palette.highlightedText : palette.windowText - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: { - pointSizesListView.currentIndex = index - content.font.pointSize = content.pointSizes[pointSizesListView.currentIndex] - } - } - } - } - } - } - - Grid { - id: settingsBottom - columns: 3 - spacing: content.spacing - width: parent.width - height: initialHeight + content.extraHeight / 4 - property real initialHeight - property real secondRowHeight: height - weightLabel.height - spacing - Component.onCompleted: initialHeight = implicitHeight - - Text { id: weightLabel; text: qsTr("Weight"); font.bold: true } - Text { id: optionsLabel; text: qsTr("Style"); font.bold: true } - Text { id: sampleLabel; text: qsTr("Sample"); font.bold: true } - Rectangle { - id: weightColumn - radius: 3 - color: palette.window - border.color: content.borderColor - implicitWidth: optionsColumn.implicitWidth - implicitHeight: optionsColumn.implicitHeight - height: parent.secondRowHeight - clip: true - ListView { - id: weightListView - anchors.fill: parent - anchors.margins: content.listMargins - anchors.topMargin: 2 - highlightMoveDuration: 0 - onHeightChanged: positionViewAtIndex(currentIndex, ListView.Contain) - function reset() { - weightModel.findIndex() - } - - model: ListModel { - id: weightModel - ListElement { - name: "Light" - weight: Font.Light - } - ListElement { - name: "Normal" - weight: Font.Normal - } - ListElement { - name: "DemiBold" - weight: Font.DemiBold - } - ListElement { - name: "Bold" - weight: Font.Bold - } - ListElement { - name: "Black" - weight: Font.Black - } - Component.onCompleted: weightListView.reset() - function findIndex() { - var find = false - for (var i = 0; i < weightModel.count; ++i) { - if (content.font.weight == weightModel.get(i).weight) { - find = true - weightListView.currentIndex = i - break - } - } - if (find == false) { - content.font.weight = weightModel.get(1).family - fontListView.currentIndex = 1 - } - } - } - highlight: Rectangle { - color: palette.highlight - x: 2 - weightListView.anchors.margins - width: weightListView.parent.width - 4 - } - delegate: Item { - width: parent.width - height: weightText.height * content.delegateHeightMultiplier - Text { - id: weightText - text: name - width: parent.width - elide: Text.ElideRight - color: index === weightListView.currentIndex ? palette.highlightedText : palette.windowText - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: { - weightListView.currentIndex = index - content.font.weight = weightModel.get(weightListView.currentIndex).weight - } - } - } - } - } - Column { - id: optionsColumn - spacing: 4 - CheckBox { - id: italicCheckBox - text: qsTr("Italic") - checked: content.font.italic - onClicked: { content.font.italic = italicCheckBox.checked } - } - CheckBox { - id: underlineCheckBox - text: qsTr("Underline") - checked: content.font.underline - onClicked: { content.font.underline = underlineCheckBox.checked } - } - CheckBox { - id: overlineCheckBox - text: qsTr("Overline") - checked: content.font.overline - onClicked: { content.font.overline = overlineCheckBox.checked } - } - CheckBox { - id: strikeoutCheckBox - text: qsTr("Strikeout") - checked: content.font.strikeout - onClicked: { content.font.strikeout = strikeoutCheckBox.checked } - } - } - Rectangle { - clip: true - implicitWidth: sample.implicitWidth + parent.spacing - implicitHeight: optionsColumn.implicitHeight - width: parent.width - weightColumn.width - optionsColumn.width - parent.spacing * 2 - height: parent.secondRowHeight - color: palette.window - border.color: content.borderColor - Text { - id: sample - anchors.centerIn: parent - font: content.font - text: content.writingSystemSample - } - } - } - - Item { - id: buttonRow - height: buttonsOnly.height - width: parent.width - Row { - id: buttonsOnly - spacing: content.spacing - anchors.right: parent.right - Button { - text: qsTr("Cancel") - onClicked: root.reject() - } - Button { - text: qsTr("OK") - onClicked: { - root.font = content.font - root.accept() - } - } - } - } - } - } -} - diff --git a/src/imports/dialogs/DefaultMessageDialog.qml b/src/imports/dialogs/DefaultMessageDialog.qml deleted file mode 100644 index ba29469b5e..0000000000 --- a/src/imports/dialogs/DefaultMessageDialog.qml +++ /dev/null @@ -1,330 +0,0 @@ -/***************************************************************************** -** -** 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: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.Window 2.1 -import QtQuick.Dialogs 1.1 -import "qml" - -AbstractMessageDialog { - id: root - - Rectangle { - id: content - property real spacing: 6 - property real outerSpacing: 12 - property real buttonsRowImplicitWidth: Screen.pixelDensity * 50 - implicitHeight: contentColumn.implicitHeight + outerSpacing * 2 - onImplicitHeightChanged: root.height = implicitHeight - implicitWidth: Math.min(Screen.desktopAvailableWidth * 0.9, Math.max( - mainText.implicitWidth, buttonsRowImplicitWidth) + outerSpacing * 2); - onImplicitWidthChanged: root.width = implicitWidth - color: palette.window - focus: root.visible - Keys.onPressed: { - event.accepted = true - if (event.modifiers === Qt.ControlModifier) - switch (event.key) { - case Qt.Key_A: - detailedText.selectAll() - break - case Qt.Key_C: - detailedText.copy() - break - } else switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - reject() - break - case Qt.Key_Enter: - case Qt.Key_Return: - accept() - break - } - } - - Column { - id: contentColumn - spacing: content.spacing - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: content.outerSpacing - } - - SystemPalette { id: palette } - - Item { - width: parent.width - height: Math.max(icon.height, mainText.height + informativeText.height + content.spacing) - Image { - id: icon - source: root.standardIconSource - } - - Text { - id: mainText - anchors { - left: icon.right - leftMargin: content.spacing - right: parent.right - } - text: root.text - font.weight: Font.Bold - wrapMode: Text.WordWrap - } - - Text { - id: informativeText - anchors { - left: icon.right - right: parent.right - top: mainText.bottom - leftMargin: content.spacing - topMargin: content.spacing - } - text: root.informativeText - wrapMode: Text.WordWrap - } - } - - - Flow { - id: buttons - spacing: content.spacing - layoutDirection: Qt.RightToLeft - width: parent.width + content.outerSpacing - x: -content.outerSpacing - Button { - id: okButton - text: "OK" - onClicked: root.click(StandardButton.Ok) - visible: root.standardButtons & StandardButton.Ok - } - Button { - id: openButton - text: "Open" - onClicked: root.click(StandardButton.Open) - visible: root.standardButtons & StandardButton.Open - } - Button { - id: saveButton - text: "Save" - onClicked: root.click(StandardButton.Save) - visible: root.standardButtons & StandardButton.Save - } - Button { - id: saveAllButton - text: "Save All" - onClicked: root.click(StandardButton.SaveAll) - visible: root.standardButtons & StandardButton.SaveAll - } - Button { - id: retryButton - text: "Retry" - onClicked: root.click(StandardButton.Retry) - visible: root.standardButtons & StandardButton.Retry - } - Button { - id: ignoreButton - text: "Ignore" - onClicked: root.click(StandardButton.Ignore) - visible: root.standardButtons & StandardButton.Ignore - } - Button { - id: applyButton - text: "Apply" - onClicked: root.click(StandardButton.Apply) - visible: root.standardButtons & StandardButton.Apply - } - Button { - id: yesButton - text: "Yes" - onClicked: root.click(StandardButton.Yes) - visible: root.standardButtons & StandardButton.Yes - } - Button { - id: yesAllButton - text: "Yes to All" - onClicked: root.click(StandardButton.YesToAll) - visible: root.standardButtons & StandardButton.YesToAll - } - Button { - id: noButton - text: "No" - onClicked: root.click(StandardButton.No) - visible: root.standardButtons & StandardButton.No - } - Button { - id: noAllButton - text: "No to All" - onClicked: root.click(StandardButton.NoToAll) - visible: root.standardButtons & StandardButton.NoToAll - } - Button { - id: discardButton - text: "Discard" - onClicked: root.click(StandardButton.Discard) - visible: root.standardButtons & StandardButton.Discard - } - Button { - id: resetButton - text: "Reset" - onClicked: root.click(StandardButton.Reset) - visible: root.standardButtons & StandardButton.Reset - } - Button { - id: restoreDefaultsButton - text: "Restore Defaults" - onClicked: root.click(StandardButton.RestoreDefaults) - visible: root.standardButtons & StandardButton.RestoreDefaults - } - Button { - id: cancelButton - text: "Cancel" - onClicked: root.click(StandardButton.Cancel) - visible: root.standardButtons & StandardButton.Cancel - } - Button { - id: abortButton - text: "Abort" - onClicked: root.click(StandardButton.Abort) - visible: root.standardButtons & StandardButton.Abort - } - Button { - id: closeButton - text: "Close" - onClicked: root.click(StandardButton.Close) - visible: root.standardButtons & StandardButton.Close - } - Button { - id: moreButton - text: "Show Details..." - onClicked: content.state = (content.state === "" ? "expanded" : "") - visible: root.detailedText.length > 0 - } - Button { - id: helpButton - text: "Help" - onClicked: root.click(StandardButton.Help) - visible: root.standardButtons & StandardButton.Help - } - onVisibleChildrenChanged: calculateImplicitWidth() - } - } - - Item { - id: details - width: parent.width - implicitHeight: detailedText.implicitHeight + content.spacing - height: 0 - clip: true - - anchors { - left: parent.left - right: parent.right - top: contentColumn.bottom - topMargin: content.spacing - leftMargin: content.outerSpacing - rightMargin: content.outerSpacing - } - - Flickable { - id: flickable - contentHeight: detailedText.height - anchors.fill: parent - anchors.topMargin: content.spacing - anchors.bottomMargin: content.outerSpacing - TextEdit { - id: detailedText - text: root.detailedText - width: details.width - wrapMode: Text.WordWrap - readOnly: true - selectByMouse: true - } - } - - Component { - id: edgeFade - EdgeFade { - fadeColor: palette.window - topThreshold: flickable.atYBeginning ? 0 : content.spacing * 3 - bottomThreshold: flickable.atYEnd ? 0 : content.spacing * 3 - } - } - - Loader { - sourceComponent: flickable.height < flickable.contentHeight ? edgeFade : undefined - anchors.fill: parent - } - - } - - states: [ - State { - name: "expanded" - PropertyChanges { - target: details - height: content.height - contentColumn.height - content.spacing - content.outerSpacing - } - PropertyChanges { - target: content - implicitHeight: contentColumn.implicitHeight + content.spacing * 2 + - detailedText.implicitHeight + content.outerSpacing * 2 - } - PropertyChanges { - target: moreButton - text: "Hide Details" - } - } - ] - } - function calculateImplicitWidth() { - if (buttons.visibleChildren.length < 2) - return; - var calcWidth = 0; - for (var i = 0; i < buttons.visibleChildren.length; ++i) - calcWidth += Math.max(100, buttons.visibleChildren[i].implicitWidth) + content.spacing - content.buttonsRowImplicitWidth = content.outerSpacing + calcWidth - } - Component.onCompleted: calculateImplicitWidth() -} diff --git a/src/imports/dialogs/WidgetColorDialog.qml b/src/imports/dialogs/WidgetColorDialog.qml deleted file mode 100644 index ed7c7ab77a..0000000000 --- a/src/imports/dialogs/WidgetColorDialog.qml +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** -** -** 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: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 - -QtColorDialog { } diff --git a/src/imports/dialogs/WidgetFileDialog.qml b/src/imports/dialogs/WidgetFileDialog.qml deleted file mode 100644 index c8f59d20a7..0000000000 --- a/src/imports/dialogs/WidgetFileDialog.qml +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** -** -** 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: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 - -QtFileDialog { } diff --git a/src/imports/dialogs/WidgetFontDialog.qml b/src/imports/dialogs/WidgetFontDialog.qml deleted file mode 100644 index 69f98b28a2..0000000000 --- a/src/imports/dialogs/WidgetFontDialog.qml +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** -** -** 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: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.2 -import QtQuick.PrivateWidgets 1.1 - -QtFontDialog { } diff --git a/src/imports/dialogs/WidgetMessageDialog.qml b/src/imports/dialogs/WidgetMessageDialog.qml deleted file mode 100644 index 8bc3eccfd7..0000000000 --- a/src/imports/dialogs/WidgetMessageDialog.qml +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** -** -** 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: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.1 - -QtMessageDialog { } diff --git a/src/imports/dialogs/dialogs.pro b/src/imports/dialogs/dialogs.pro deleted file mode 100644 index 1abad55883..0000000000 --- a/src/imports/dialogs/dialogs.pro +++ /dev/null @@ -1,97 +0,0 @@ -CXX_MODULE = qml -TARGET = dialogplugin -TARGETPATH = QtQuick/Dialogs -IMPORT_VERSION = 1.1 - -QMAKE_DOCS = $$PWD/doc/qtquickdialogs.qdocconf - -SOURCES += \ - qquickabstractmessagedialog.cpp \ - qquickplatformmessagedialog.cpp \ - qquickmessagedialog.cpp \ - qquickabstractfiledialog.cpp \ - qquickplatformfiledialog.cpp \ - qquickfiledialog.cpp \ - qquickabstractcolordialog.cpp \ - qquickplatformcolordialog.cpp \ - qquickcolordialog.cpp \ - qquickabstractfontdialog.cpp \ - qquickplatformfontdialog.cpp \ - qquickfontdialog.cpp \ - qquickabstractdialog.cpp \ - plugin.cpp - -HEADERS += \ - qquickabstractmessagedialog_p.h \ - qquickplatformmessagedialog_p.h \ - qquickmessagedialog_p.h \ - qquickdialogassets_p.h \ - qquickabstractfiledialog_p.h \ - qquickplatformfiledialog_p.h \ - qquickfiledialog_p.h \ - qquickabstractcolordialog_p.h \ - qquickplatformcolordialog_p.h \ - qquickcolordialog_p.h \ - qquickabstractfontdialog_p.h \ - qquickplatformfontdialog_p.h \ - qquickfontdialog_p.h \ - qquickabstractdialog_p.h - -DIALOGS_QML_FILES += \ - DefaultMessageDialog.qml \ - WidgetMessageDialog.qml \ - DefaultFileDialog.qml \ - WidgetFileDialog.qml \ - DefaultColorDialog.qml \ - WidgetColorDialog.qml \ - DefaultFontDialog.qml \ - WidgetFontDialog.qml \ - qml/Button.qml \ - qml/CheckBox.qml \ - qml/ColorSlider.qml \ - qml/EdgeFade.qml \ - qml/DefaultWindowDecoration.qml \ - qml/TextField.qml \ - qml/qmldir \ - images/critical.png \ - images/information.png \ - images/question.png \ - images/warning.png \ - images/checkers.png \ - images/checkmark.png \ - images/copy.png \ - images/crosshairs.png \ - images/slider_handle.png \ - images/sunken_frame.png \ - images/window_border.png \ - images/folder.png \ - images/up.png - -QT += quick-private gui gui-private core core-private qml - -# Create the resource file -GENERATED_RESOURCE_FILE = $$OUT_PWD/dialogs.qrc - -RESOURCE_CONTENT = \ - "<RCC>" \ - "<qresource prefix=\"/QtQuick/Dialogs\">" - -for(resourcefile, DIALOGS_QML_FILES) { - resourcefileabsolutepath = $$absolute_path($$resourcefile) - relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_) - relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD) - RESOURCE_CONTENT += "<file alias=\"$$relativepath_in\">$$relativepath_out</file>" -} - -RESOURCE_CONTENT += \ - "</qresource>" \ - "</RCC>" - -write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.") - -RESOURCES += $$GENERATED_RESOURCE_FILE - -# In case of a debug build, deploy the QML files too -CONFIG(debug, debug|release): QML_FILES += $$DIALOGS_QML_FILES - -load(qml_plugin) diff --git a/src/imports/dialogs/doc/images/critical.png b/src/imports/dialogs/doc/images/critical.png Binary files differdeleted file mode 100644 index dc9c5aebf4..0000000000 --- a/src/imports/dialogs/doc/images/critical.png +++ /dev/null diff --git a/src/imports/dialogs/doc/images/information.png b/src/imports/dialogs/doc/images/information.png Binary files differdeleted file mode 100644 index 0a2eb87d10..0000000000 --- a/src/imports/dialogs/doc/images/information.png +++ /dev/null diff --git a/src/imports/dialogs/doc/images/question.png b/src/imports/dialogs/doc/images/question.png Binary files differdeleted file mode 100644 index 2dd92fd791..0000000000 --- a/src/imports/dialogs/doc/images/question.png +++ /dev/null diff --git a/src/imports/dialogs/doc/images/replacefile.png b/src/imports/dialogs/doc/images/replacefile.png Binary files differdeleted file mode 100644 index d1479fa944..0000000000 --- a/src/imports/dialogs/doc/images/replacefile.png +++ /dev/null diff --git a/src/imports/dialogs/doc/images/warning.png b/src/imports/dialogs/doc/images/warning.png Binary files differdeleted file mode 100644 index cba78f6bea..0000000000 --- a/src/imports/dialogs/doc/images/warning.png +++ /dev/null diff --git a/src/imports/dialogs/doc/qtquickdialogs.qdocconf b/src/imports/dialogs/doc/qtquickdialogs.qdocconf deleted file mode 100644 index 1bad67790f..0000000000 --- a/src/imports/dialogs/doc/qtquickdialogs.qdocconf +++ /dev/null @@ -1,41 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) - -project = QtQuickDialogs -description = Qt Quick Dialogs Reference Documentation -url = http://qt-project.org/doc/qt-$QT_VER -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 = qtquickdialogsqmltypes -qhp.QtQuickDialogs.subprojects.qtquickdialogsqmltypes.title = QML Types -qhp.QtQuickDialogs.subprojects.qtquickdialogsqmltypes.indexTitle = Qt Quick Dialogs QML Types -qhp.QtQuickDialogs.subprojects.qtquickdialogsqmltypes.selectors = fake:qmlclass -qhp.QtQuickDialogs.subprojects.qtquickdialogsqmltypes.sortPages = true - -depends = qtqml qtquick qtgui qtwidgets qtdoc - -exampledirs += ../../../../examples/quick/dialogs - -examplesinstallpath = quick/dialogs - -headerdirs += .. - -sourcedirs += .. - -imagedirs += images - -excludedirs += ../qml - -navigation.landingpage = "Qt Quick Dialogs" -navigation.qmltypespage = "Qt Quick Dialogs QML Types" diff --git a/src/imports/dialogs/doc/src/qtquickdialogs-examples.qdoc b/src/imports/dialogs/doc/src/qtquickdialogs-examples.qdoc deleted file mode 100644 index ee277f48dc..0000000000 --- a/src/imports/dialogs/doc/src/qtquickdialogs-examples.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \group qtquickdialog_examples - \ingroup qtquickexamples - \title Qt Quick Examples - Dialogs - \brief A Collection of examples for \l{Qt Quick Dialogs}, written in QML. - - These examples show how to use the \l{Qt Quick Dialogs}. -*/ - diff --git a/src/imports/dialogs/doc/src/qtquickdialogs-index.qdoc b/src/imports/dialogs/doc/src/qtquickdialogs-index.qdoc deleted file mode 100644 index 5a1223b04d..0000000000 --- a/src/imports/dialogs/doc/src/qtquickdialogs-index.qdoc +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \group dialogs - \title Dialogs -*/ - -/*! - \page qtquickdialogs-index.html - \title Qt Quick Dialogs - - \brief Qt Quick Dialogs submodule - - The module is new in Qt 5.1. - - \section1 Dialogs - - \annotatedlist dialogs - - \section1 Related information - - \section2 Examples - \list - \li \l{Qt Quick Examples - Dialogs}{Dialogs Examples} - \endlist - - \section2 Reference - \list - \li \l{Qt Quick Dialogs QML Types}{QML Types} - \endlist - -*/ - diff --git a/src/imports/dialogs/images/checkers.png b/src/imports/dialogs/images/checkers.png Binary files differdeleted file mode 100644 index 458d33de9d..0000000000 --- a/src/imports/dialogs/images/checkers.png +++ /dev/null diff --git a/src/imports/dialogs/images/checkmark.png b/src/imports/dialogs/images/checkmark.png Binary files differdeleted file mode 100644 index 821aafccdd..0000000000 --- a/src/imports/dialogs/images/checkmark.png +++ /dev/null diff --git a/src/imports/dialogs/images/copy.png b/src/imports/dialogs/images/copy.png Binary files differdeleted file mode 100644 index 2aeb28288f..0000000000 --- a/src/imports/dialogs/images/copy.png +++ /dev/null diff --git a/src/imports/dialogs/images/critical.png b/src/imports/dialogs/images/critical.png Binary files differdeleted file mode 100644 index dc9c5aebf4..0000000000 --- a/src/imports/dialogs/images/critical.png +++ /dev/null diff --git a/src/imports/dialogs/images/crosshairs.png b/src/imports/dialogs/images/crosshairs.png Binary files differdeleted file mode 100644 index 9a61946eca..0000000000 --- a/src/imports/dialogs/images/crosshairs.png +++ /dev/null diff --git a/src/imports/dialogs/images/folder.png b/src/imports/dialogs/images/folder.png Binary files differdeleted file mode 100644 index e53e2ad464..0000000000 --- a/src/imports/dialogs/images/folder.png +++ /dev/null diff --git a/src/imports/dialogs/images/information.png b/src/imports/dialogs/images/information.png Binary files differdeleted file mode 100644 index 0a2eb87d10..0000000000 --- a/src/imports/dialogs/images/information.png +++ /dev/null diff --git a/src/imports/dialogs/images/question.png b/src/imports/dialogs/images/question.png Binary files differdeleted file mode 100644 index 2dd92fd791..0000000000 --- a/src/imports/dialogs/images/question.png +++ /dev/null diff --git a/src/imports/dialogs/images/slider_handle.png b/src/imports/dialogs/images/slider_handle.png Binary files differdeleted file mode 100644 index e3b9654392..0000000000 --- a/src/imports/dialogs/images/slider_handle.png +++ /dev/null diff --git a/src/imports/dialogs/images/sunken_frame.png b/src/imports/dialogs/images/sunken_frame.png Binary files differdeleted file mode 100644 index 178c3092d2..0000000000 --- a/src/imports/dialogs/images/sunken_frame.png +++ /dev/null diff --git a/src/imports/dialogs/images/up.png b/src/imports/dialogs/images/up.png Binary files differdeleted file mode 100644 index b05f8025d0..0000000000 --- a/src/imports/dialogs/images/up.png +++ /dev/null diff --git a/src/imports/dialogs/images/warning.png b/src/imports/dialogs/images/warning.png Binary files differdeleted file mode 100644 index cba78f6bea..0000000000 --- a/src/imports/dialogs/images/warning.png +++ /dev/null diff --git a/src/imports/dialogs/images/window_border.png b/src/imports/dialogs/images/window_border.png Binary files differdeleted file mode 100644 index 431af8545d..0000000000 --- a/src/imports/dialogs/images/window_border.png +++ /dev/null diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp deleted file mode 100644 index 70e12093b6..0000000000 --- a/src/imports/dialogs/plugin.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** 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 <QtQml/qqml.h> -#include <QtQml/qqmlextensionplugin.h> -#include "qquickmessagedialog_p.h" -#include "qquickabstractmessagedialog_p.h" -#include "qquickdialogassets_p.h" -#include "qquickplatformmessagedialog_p.h" -#include "qquickfiledialog_p.h" -#include "qquickabstractfiledialog_p.h" -#include "qquickplatformfiledialog_p.h" -#include "qquickcolordialog_p.h" -#include "qquickabstractcolordialog_p.h" -#include "qquickplatformcolordialog_p.h" -#include "qquickfontdialog_p.h" -#include "qquickabstractfontdialog_p.h" -#include "qquickplatformfontdialog_p.h" -#include <private/qguiapplication_p.h> -#include <qpa/qplatformintegration.h> - -//#define PURE_QML_ONLY -//#define DEBUG_REGISTRATION - -static void initResources() -{ - Q_INIT_RESOURCE(dialogs); -} - -QT_BEGIN_NAMESPACE - -/*! - \qmlmodule QtQuick.Dialogs 1.1 - \title Qt Quick Dialogs QML Types - \ingroup qmlmodules - \brief Provides QML types for standard file, color picker and message dialogs - - This QML module contains types for creating and interacting with system dialogs. - - To use the types in this module, import the module with the following line: - - \code - import QtQuick.Dialogs 1.1 - \endcode -*/ - -class QtQuick2DialogsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") - -public: - QtQuick2DialogsPlugin() : QQmlExtensionPlugin(), m_useResources(true) { } - - virtual void initializeEngine(QQmlEngine *engine, const char * uri) { -#ifdef DEBUG_REGISTRATION - qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl; -#else - Q_UNUSED(uri) -#endif - QQuickAbstractDialog::m_decorationComponent = - new QQmlComponent(engine, m_decorationComponentUrl, QQmlComponent::Asynchronous); - } - - virtual void registerTypes(const char *uri) { - initResources(); - -#ifdef DEBUG_REGISTRATION - qDebug() << Q_FUNC_INFO << uri; -#endif - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs")); - bool hasTopLevelWindows = QGuiApplicationPrivate::platformIntegration()-> - hasCapability(QPlatformIntegration::MultipleWindows); - QDir qmlDir(baseUrl().toLocalFile()); - QDir widgetsDir(baseUrl().toLocalFile()); - // TODO: find the directory by searching rather than assuming a relative path - widgetsDir.cd("../PrivateWidgets"); - - // If at least one file was actually installed, then use installed qml files instead of resources. - // This makes debugging and incremental development easier, whereas the "normal" installation - // uses resources to save space and cut down on the number of files to deploy. - if (qmlDir.exists(QString("DefaultFileDialog.qml"))) - m_useResources = false; - m_decorationComponentUrl = m_useResources ? - QUrl("qrc:/QtQuick/Dialogs/qml/DefaultWindowDecoration.qml") : - QUrl::fromLocalFile(qmlDir.filePath(QString("qml/DefaultWindowDecoration.qml"))); - - // 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. - - // MessageDialog - qmlRegisterUncreatableType<QQuickStandardButton>(uri, 1, 1, "StandardButton", - QLatin1String("Do not create objects of type StandardButton")); - qmlRegisterUncreatableType<QQuickStandardIcon>(uri, 1, 1, "StandardIcon", - QLatin1String("Do not create objects of type StandardIcon")); -#ifndef PURE_QML_ONLY - if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::MessageDialog)) - qmlRegisterType<QQuickPlatformMessageDialog>(uri, 1, 0, "MessageDialog"); - else -#endif - registerWidgetOrQmlImplementation<QQuickMessageDialog>(widgetsDir, qmlDir, "MessageDialog", uri, hasTopLevelWindows, 1, 1); - - // FileDialog -#ifndef PURE_QML_ONLY - if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog)) - qmlRegisterType<QQuickPlatformFileDialog>(uri, 1, 0, "FileDialog"); - else -#endif - registerWidgetOrQmlImplementation<QQuickFileDialog>(widgetsDir, qmlDir, "FileDialog", uri, hasTopLevelWindows, 1, 0); - - // ColorDialog -#ifndef PURE_QML_ONLY - if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::ColorDialog)) - qmlRegisterType<QQuickPlatformColorDialog>(uri, 1, 0, "ColorDialog"); - else -#endif - registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, qmlDir, "ColorDialog", uri, hasTopLevelWindows, 1, 0); - - // FontDialog -#ifndef PURE_QML_ONLY - if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FontDialog)) - qmlRegisterType<QQuickPlatformFontDialog>(uri, 1, 1, "FontDialog"); - else -#endif - registerWidgetOrQmlImplementation<QQuickFontDialog>(widgetsDir, qmlDir, "FontDialog", uri, hasTopLevelWindows, 1, 1); - } - -protected: - template <class WrapperType> - void registerWidgetOrQmlImplementation(QDir widgetsDir, QDir qmlDir, - const char *qmlName, const char *uri, bool hasTopLevelWindows, int versionMajor, int versionMinor) { - // qDebug() << "QtQuick2DialogsPlugin::registerWidgetOrQmlImplementation" << uri << qmlName << ": QML in" << qmlDir.absolutePath() - // << "using resources?" << m_useResources << "; widgets in" << widgetsDir.absolutePath(); - bool needQmlImplementation = true; - -#ifdef PURE_QML_ONLY - Q_UNUSED(widgetsDir) - Q_UNUSED(hasTopLevelWindows) -#else - // 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 (hasTopLevelWindows && widgetsDir.exists("qmldir") && - QCoreApplication::instance()->inherits("QApplication")) { - QUrl dialogQmlPath = m_useResources ? - QUrl(QString("qrc:/QtQuick/Dialogs/Widget%1.qml").arg(qmlName)) : - QUrl::fromLocalFile(qmlDir.filePath(QString("Widget%1.qml").arg(qmlName))); - if (qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName) >= 0) { - needQmlImplementation = false; -#ifdef DEBUG_REGISTRATION - qDebug() << " registering" << qmlName << " as " << dialogQmlPath << "success?" << !needQmlImplementation; -#endif - } - } -#endif - if (needQmlImplementation) { - QByteArray abstractTypeName = QByteArray("Abstract") + qmlName; - qmlRegisterType<WrapperType>(uri, versionMajor, versionMinor, abstractTypeName); // implementation wrapper - QUrl dialogQmlPath = m_useResources ? - QUrl(QString("qrc:/QtQuick/Dialogs/Default%1.qml").arg(qmlName)) : - QUrl::fromLocalFile(qmlDir.filePath(QString("Default%1.qml").arg(qmlName))); -#ifdef DEBUG_REGISTRATION - qDebug() << " registering" << qmlName << " as " << dialogQmlPath << "success?" << -#endif - qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName); - } - } - - QUrl m_decorationComponentUrl; - bool m_useResources; -}; - -QT_END_NAMESPACE - -#include "plugin.moc" diff --git a/src/imports/dialogs/plugins.qmltypes b/src/imports/dialogs/plugins.qmltypes deleted file mode 100644 index d5db4b93bd..0000000000 --- a/src/imports/dialogs/plugins.qmltypes +++ /dev/null @@ -1,654 +0,0 @@ -import QtQuick.tooling 1.1 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump -nonrelocatable -omit-prefix=__ QtQuick.Dialogs 1.1' - -Module { - Component { - name: "QQuickAbstractColorDialog" - prototype: "QQuickAbstractDialog" - Property { name: "showAlphaChannel"; type: "bool" } - Property { name: "color"; type: "QColor" } - Property { name: "currentColor"; type: "QColor" } - Property { name: "currentHue"; type: "double"; isReadonly: true } - Property { name: "currentSaturation"; type: "double"; isReadonly: true } - Property { name: "currentLightness"; type: "double"; isReadonly: true } - Property { name: "currentAlpha"; type: "double"; isReadonly: true } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setColor" - Parameter { name: "arg"; type: "QColor" } - } - Method { - name: "setCurrentColor" - Parameter { name: "currentColor"; type: "QColor" } - } - Method { - name: "setShowAlphaChannel" - Parameter { name: "arg"; type: "bool" } - } - } - Component { - name: "QQuickAbstractDialog" - prototype: "QObject" - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - } - Component { - name: "QQuickAbstractFileDialog" - prototype: "QQuickAbstractDialog" - Property { name: "selectExisting"; type: "bool" } - Property { name: "selectMultiple"; type: "bool" } - Property { name: "selectFolder"; type: "bool" } - Property { name: "folder"; type: "QUrl" } - Property { name: "nameFilters"; type: "QStringList" } - Property { name: "selectedNameFilter"; type: "string" } - Property { name: "fileUrl"; type: "QUrl"; isReadonly: true } - Property { name: "fileUrls"; type: "QList<QUrl>"; isReadonly: true } - Signal { name: "filterSelected" } - Signal { name: "fileModeChanged" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setSelectExisting" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectMultiple" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectFolder" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setFolder" - Parameter { name: "f"; type: "QUrl" } - } - Method { - name: "setNameFilters" - Parameter { name: "f"; type: "QStringList" } - } - Method { - name: "selectNameFilter" - Parameter { name: "f"; type: "string" } - } - } - Component { - name: "QQuickAbstractFontDialog" - prototype: "QQuickAbstractDialog" - Property { name: "scalableFonts"; type: "bool" } - Property { name: "nonScalableFonts"; type: "bool" } - Property { name: "monospacedFonts"; type: "bool" } - Property { name: "proportionalFonts"; type: "bool" } - Property { name: "font"; type: "QFont" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setFont" - Parameter { name: "arg"; type: "QFont" } - } - Method { - name: "setScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setNonScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setMonospacedFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setProportionalFonts" - Parameter { name: "arg"; type: "bool" } - } - } - Component { - name: "QQuickAbstractMessageDialog" - prototype: "QQuickAbstractDialog" - Enum { - name: "Icon" - values: { - "NoIcon": 0, - "Information": 1, - "Warning": 2, - "Critical": 3, - "Question": 4 - } - } - Enum { - name: "StandardButton" - values: { - "NoButton": 0, - "Ok": 1024, - "Save": 2048, - "SaveAll": 4096, - "Open": 8192, - "Yes": 16384, - "YesToAll": 32768, - "No": 65536, - "NoToAll": 131072, - "Abort": 262144, - "Retry": 524288, - "Ignore": 1048576, - "Close": 2097152, - "Cancel": 4194304, - "Discard": 8388608, - "Help": 16777216, - "Apply": 33554432, - "Reset": 67108864, - "RestoreDefaults": 134217728 - } - } - Enum { - name: "StandardButtons" - values: { - "NoButton": 0, - "Ok": 1024, - "Save": 2048, - "SaveAll": 4096, - "Open": 8192, - "Yes": 16384, - "YesToAll": 32768, - "No": 65536, - "NoToAll": 131072, - "Abort": 262144, - "Retry": 524288, - "Ignore": 1048576, - "Close": 2097152, - "Cancel": 4194304, - "Discard": 8388608, - "Help": 16777216, - "Apply": 33554432, - "Reset": 67108864, - "RestoreDefaults": 134217728 - } - } - Property { name: "text"; type: "string" } - Property { name: "informativeText"; type: "string" } - Property { name: "detailedText"; type: "string" } - Property { name: "icon"; type: "Icon" } - Property { name: "standardIconSource"; type: "QUrl"; isReadonly: true } - Property { name: "standardButtons"; type: "StandardButtons" } - Property { name: "clickedButton"; type: "StandardButton"; isReadonly: true } - Signal { name: "buttonClicked" } - Signal { name: "discard" } - Signal { name: "help" } - Signal { name: "yes" } - Signal { name: "no" } - Signal { name: "apply" } - Signal { name: "reset" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setInformativeText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setDetailedText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setIcon" - Parameter { name: "icon"; type: "Icon" } - } - Method { - name: "setStandardButtons" - Parameter { name: "buttons"; type: "StandardButtons" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QMessageDialogOptions::StandardButton" } - Parameter { type: "QMessageDialogOptions::ButtonRole" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QQuickAbstractMessageDialog::StandardButton" } - } - } - Component { - name: "QQuickColorDialog" - defaultProperty: "implementation" - prototype: "QQuickAbstractColorDialog" - exports: ["QtQuick.Dialogs/AbstractColorDialog 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "implementation"; type: "QObject"; isPointer: true } - } - Component { - name: "QQuickFileDialog" - defaultProperty: "implementation" - prototype: "QQuickAbstractFileDialog" - exports: ["QtQuick.Dialogs/AbstractFileDialog 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "implementation"; type: "QObject"; isPointer: true } - Method { name: "clearSelection" } - Method { - name: "addSelection" - type: "bool" - Parameter { name: "path"; type: "QUrl" } - } - } - Component { - name: "QQuickFontDialog" - defaultProperty: "implementation" - prototype: "QQuickAbstractFontDialog" - exports: ["QtQuick.Dialogs/AbstractFontDialog 1.1"] - exportMetaObjectRevisions: [0] - Property { name: "implementation"; type: "QObject"; isPointer: true } - } - Component { - name: "QQuickMessageDialog" - defaultProperty: "implementation" - prototype: "QQuickAbstractMessageDialog" - exports: ["QtQuick.Dialogs/AbstractMessageDialog 1.1"] - exportMetaObjectRevisions: [0] - Property { name: "implementation"; type: "QObject"; isPointer: true } - } - Component { - name: "QQuickStandardButton" - exports: ["QtQuick.Dialogs/StandardButton 1.1"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QQuickStandardIcon" - exports: ["QtQuick.Dialogs/StandardIcon 1.1"] - exportMetaObjectRevisions: [0] - } - Component { - prototype: "QObject" - name: "QtQuick.Dialogs/ColorDialog" - exports: ["QtQuick.Dialogs/ColorDialog 1.0"] - exportMetaObjectRevisions: [0] - defaultProperty: "implementation" - Property { name: "showAlphaChannel"; type: "bool" } - Property { name: "color"; type: "QColor" } - Property { name: "currentColor"; type: "QColor" } - Property { name: "currentHue"; type: "double"; isReadonly: true } - Property { name: "currentSaturation"; type: "double"; isReadonly: true } - Property { name: "currentLightness"; type: "double"; isReadonly: true } - Property { name: "currentAlpha"; type: "double"; isReadonly: true } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setColor" - Parameter { name: "arg"; type: "QColor" } - } - Method { - name: "setCurrentColor" - Parameter { name: "currentColor"; type: "QColor" } - } - Method { - name: "setShowAlphaChannel" - Parameter { name: "arg"; type: "bool" } - } - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - Property { name: "implementation"; type: "QObject"; isPointer: true } - } - Component { - prototype: "QObject" - name: "QtQuick.Dialogs/FileDialog" - exports: ["QtQuick.Dialogs/FileDialog 1.0"] - exportMetaObjectRevisions: [0] - defaultProperty: "implementation" - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - Property { name: "selectExisting"; type: "bool" } - Property { name: "selectMultiple"; type: "bool" } - Property { name: "selectFolder"; type: "bool" } - Property { name: "folder"; type: "QUrl" } - Property { name: "nameFilters"; type: "QStringList" } - Property { name: "selectedNameFilter"; type: "string" } - Property { name: "fileUrl"; type: "QUrl"; isReadonly: true } - Property { name: "fileUrls"; type: "QList<QUrl>"; isReadonly: true } - Signal { name: "filterSelected" } - Signal { name: "fileModeChanged" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setSelectExisting" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectMultiple" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectFolder" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setFolder" - Parameter { name: "f"; type: "QUrl" } - } - Method { - name: "setNameFilters" - Parameter { name: "f"; type: "QStringList" } - } - Method { - name: "selectNameFilter" - Parameter { name: "f"; type: "string" } - } - Property { name: "implementation"; type: "QObject"; isPointer: true } - Method { name: "clearSelection" } - Method { - name: "addSelection" - type: "bool" - Parameter { name: "path"; type: "QUrl" } - } - } - Component { - prototype: "QObject" - name: "QtQuick.Dialogs/FontDialog" - exports: ["QtQuick.Dialogs/FontDialog 1.1"] - exportMetaObjectRevisions: [1] - defaultProperty: "implementation" - Property { name: "font"; type: "QFont" } - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - Property { name: "scalableFonts"; type: "bool" } - Property { name: "nonScalableFonts"; type: "bool" } - Property { name: "monospacedFonts"; type: "bool" } - Property { name: "proportionalFonts"; type: "bool" } - Property { name: "font"; type: "QFont" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setFont" - Parameter { name: "arg"; type: "QFont" } - } - Method { - name: "setScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setNonScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setMonospacedFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setProportionalFonts" - Parameter { name: "arg"; type: "bool" } - } - Property { name: "implementation"; type: "QObject"; isPointer: true } - } - Component { - prototype: "QObject" - name: "QtQuick.Dialogs/MessageDialog" - exports: ["QtQuick.Dialogs/MessageDialog 1.1"] - exportMetaObjectRevisions: [1] - defaultProperty: "implementation" - Method { name: "calculateImplicitWidth"; type: "QVariant" } - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - Property { name: "text"; type: "string" } - Property { name: "informativeText"; type: "string" } - Property { name: "detailedText"; type: "string" } - Property { name: "icon"; type: "Icon" } - Property { name: "standardIconSource"; type: "QUrl"; isReadonly: true } - Property { name: "standardButtons"; type: "StandardButtons" } - Property { name: "clickedButton"; type: "StandardButton"; isReadonly: true } - Signal { name: "buttonClicked" } - Signal { name: "discard" } - Signal { name: "help" } - Signal { name: "yes" } - Signal { name: "no" } - Signal { name: "apply" } - Signal { name: "reset" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setInformativeText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setDetailedText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setIcon" - Parameter { name: "icon"; type: "Icon" } - } - Method { - name: "setStandardButtons" - Parameter { name: "buttons"; type: "StandardButtons" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QMessageDialogOptions::StandardButton" } - Parameter { type: "QMessageDialogOptions::ButtonRole" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QQuickAbstractMessageDialog::StandardButton" } - } - Property { name: "implementation"; type: "QObject"; isPointer: true } - } -} diff --git a/src/imports/dialogs/qml/Button.qml b/src/imports/dialogs/qml/Button.qml deleted file mode 100644 index f48264d5ff..0000000000 --- a/src/imports/dialogs/qml/Button.qml +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** -** -** 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: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.Window 2.1 - -Item { - id: container - - property alias text: buttonLabel.text - property alias label: buttonLabel - signal clicked - property alias containsMouse: mouseArea.containsMouse - property alias pressed: mouseArea.pressed - implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) - implicitWidth: visible ? Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) : 0 - height: implicitHeight - width: implicitWidth - - SystemPalette { id: palette } - - Rectangle { - id: frame - anchors.fill: parent - color: palette.button - gradient: Gradient { - GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button } - GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } - } - antialiasing: true - radius: height / 6 - border.color: Qt.darker(palette.button, 1.5) - border.width: 1 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - hoverEnabled: true - } - - Text { - id: buttonLabel - text: container.text - color: palette.buttonText - anchors.centerIn: parent - } -} diff --git a/src/imports/dialogs/qml/CheckBox.qml b/src/imports/dialogs/qml/CheckBox.qml deleted file mode 100644 index 32b0e6ff70..0000000000 --- a/src/imports/dialogs/qml/CheckBox.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** 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: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 - -Item { - id: root - implicitHeight: frame.height - implicitWidth: row.implicitWidth - width: implicitWidth - height: implicitHeight - property alias text: label.text - property bool checked - property alias pressed: mouseArea.pressed - signal clicked - - SystemPalette { id: palette } - - Row { - id: row - anchors.verticalCenter: parent.verticalCenter - spacing: 6 - Rectangle { - id: frame - gradient: Gradient { - GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button } - GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } - } - height: label.implicitHeight * 1.5 - width: height - anchors.margins: 1 - radius: 3 - antialiasing: true - border.color: Qt.darker(palette.button, 1.5) - Image { - id: theX - source: "../images/checkmark.png" - anchors.fill: frame - anchors.margins: frame.width / 5 - fillMode: Image.PreserveAspectFit - smooth: true - visible: checked - } - } - Text { - id: label - color: palette.text - anchors.verticalCenter: frame.verticalCenter - } - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - parent.checked = !parent.checked - parent.clicked() - } - } -} diff --git a/src/imports/dialogs/qml/ColorSlider.qml b/src/imports/dialogs/qml/ColorSlider.qml deleted file mode 100755 index 8fc9717380..0000000000 --- a/src/imports/dialogs/qml/ColorSlider.qml +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Graphical Effects module. -** -** $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 - -Item { - id: colorSlider - - property real value: 1 - property real maximum: 1 - property real minimum: 0 - property string text: "" - property bool pressed: mouseArea.pressed - property bool integer: false - property Component trackDelegate - property string handleSource: "../images/slider_handle.png" - - width: parent.width - height: handle.height + textText.implicitHeight - - function updatePos() { - if (maximum > minimum) { - var pos = (track.width - 10) * (value - minimum) / (maximum - minimum) + 5; - return Math.min(Math.max(pos, 5), track.width - 5) - 10; - } else { - return 5; - } - } - - SystemPalette { id: palette } - - Column { - id: column - width: parent.width - spacing: 12 - Text { - id: textText - anchors.horizontalCenter: parent.horizontalCenter - text: colorSlider.text - anchors.left: parent.left - color: palette.windowText - } - - Item { - id: track - height: 8 - anchors.left: parent.left - anchors.right: parent.right - - Loader { - sourceComponent: trackDelegate - width: parent.height - height: parent.width - y: width - } - - BorderImage { - source: "../images/sunken_frame.png" - border.left: 8 - border.right: 8 - border.top:8 - border.bottom: 8 - anchors.fill: track - anchors.margins: -1 - anchors.topMargin: -2 - anchors.leftMargin: -2 - } - - Image { - id: handle - anchors.verticalCenter: parent.verticalCenter - smooth: true - source: "../images/slider_handle.png" - x: updatePos() - 8 - z: 1 - } - - MouseArea { - id: mouseArea - anchors {left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter} - height: handle.height - width: handle.width - preventStealing: true - - onPressed: { - var handleX = Math.max(0, Math.min(mouseX, mouseArea.width)) - var realValue = (maximum - minimum) * handleX / mouseArea.width + minimum; - value = colorSlider.integer ? Math.round(realValue) : realValue; - } - - onPositionChanged: { - if (pressed) { - var handleX = Math.max(0, Math.min(mouseX, mouseArea.width)) - var realValue = (maximum - minimum) * handleX / mouseArea.width + minimum; - value = colorSlider.integer ? Math.round(realValue) : realValue; - } - } - } - } - } -} diff --git a/src/imports/dialogs/qml/DefaultWindowDecoration.qml b/src/imports/dialogs/qml/DefaultWindowDecoration.qml deleted file mode 100644 index ec930101d2..0000000000 --- a/src/imports/dialogs/qml/DefaultWindowDecoration.qml +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** -** -** 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: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 - -Rectangle { - color: "#80000000" - anchors.fill: parent - z: 1000000 - property alias content: borderImage.content - property bool dismissOnOuterClick: true - signal dismissed - MouseArea { - anchors.fill: parent - enabled: dismissOnOuterClick - onClicked: dismissed() - BorderImage { - id: borderImage - property Item content - - MouseArea { anchors.fill: parent } - - width: content ? content.width + 15 : 0 - height: content ? content.height + 15 : 0 - onWidthChanged: content.x = 5 - onHeightChanged: content.y = 5 - border { left: 10; top: 10; right: 10; bottom: 10 } - clip: true - source: "../images/window_border.png" - anchors.centerIn: parent - onContentChanged: if (content) content.parent = borderImage - } - } -} diff --git a/src/imports/dialogs/qml/EdgeFade.qml b/src/imports/dialogs/qml/EdgeFade.qml deleted file mode 100644 index 376aa151e6..0000000000 --- a/src/imports/dialogs/qml/EdgeFade.qml +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** -** -** 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: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 - -ShaderEffect { - property color fadeColor - property real topThreshold: 10 - property real bottomThreshold: 10 - property real _topRatio: topThreshold / height - property real _bottomRatio: bottomThreshold / height - z: 1 - fragmentShader: " - varying lowp vec2 qt_TexCoord0; - uniform lowp vec4 fadeColor; - uniform highp float _topRatio; - uniform highp float _bottomRatio; - - void main() { - highp float bottomEnd = 1. - _bottomRatio; - gl_FragColor = fadeColor * - (qt_TexCoord0.y < _topRatio ? 1. - qt_TexCoord0.y / _topRatio : - (qt_TexCoord0.y > bottomEnd ? (qt_TexCoord0.y - bottomEnd) / _bottomRatio : 0.)); - } - " -} diff --git a/src/imports/dialogs/qml/TextField.qml b/src/imports/dialogs/qml/TextField.qml deleted file mode 100644 index e67155086c..0000000000 --- a/src/imports/dialogs/qml/TextField.qml +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** -** -** 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: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 - -Item { - id: root - - property alias textInput: textInput - property alias text: textInput.text - signal accepted - signal downPressed - signal backPressed - signal escapePressed - implicitWidth: textInput.implicitWidth + rect.radius * 2 - implicitHeight: textInput.implicitHeight - - function copyAll() { - textInput.selectAll() - textInput.copy() - } - - function paste() { - textInput.selectAll() - textInput.paste() - } - - SystemPalette { id: palette } - height: textInput.implicitHeight + 8 - clip: true - - Rectangle { - id: rect - anchors.fill: parent - radius: height / 4 - color: palette.button - border.color: Qt.darker(palette.button, 1.5) - } - - TextInput { - id: textInput - color: palette.text - anchors.fill: parent - anchors.leftMargin: rect.radius - anchors.rightMargin: rect.radius - verticalAlignment: Text.AlignVCenter - onAccepted: root.accepted() - Keys.onDownPressed: root.downPressed() - Keys.onBackPressed: root.backPressed() - Keys.onEscapePressed: root.escapePressed() - } -} diff --git a/src/imports/dialogs/qml/qmldir b/src/imports/dialogs/qml/qmldir deleted file mode 100644 index 9d273b1c4b..0000000000 --- a/src/imports/dialogs/qml/qmldir +++ /dev/null @@ -1,5 +0,0 @@ -Button 1.0 Button.qml -CheckBox 1.1 CheckBox.qml -ColorSlider 1.0 ColorSlider.qml -EdgeFade 1.0 EdgeFade.qml -TextField 1.0 TextField.qml diff --git a/src/imports/dialogs/qmldir b/src/imports/dialogs/qmldir deleted file mode 100644 index b4ae1a059c..0000000000 --- a/src/imports/dialogs/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtQuick.Dialogs -plugin dialogplugin -classname QtQuick2DialogsPlugin -typeinfo plugins.qmltypes diff --git a/src/imports/dialogs/qquickabstractcolordialog.cpp b/src/imports/dialogs/qquickabstractcolordialog.cpp deleted file mode 100644 index 1931bde905..0000000000 --- a/src/imports/dialogs/qquickabstractcolordialog.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractcolordialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -QQuickAbstractColorDialog::QQuickAbstractColorDialog(QObject *parent) - : QQuickAbstractDialog(parent) - , m_dlgHelper(0) - , m_options(QSharedPointer<QColorDialogOptions>(new QColorDialogOptions())) -{ - // On the Mac, modality doesn't work unless you call exec(). But this is a reasonable default anyway. - m_modality = Qt::NonModal; - connect(this, SIGNAL(accepted()), this, SIGNAL(selectionAccepted())); -} - -QQuickAbstractColorDialog::~QQuickAbstractColorDialog() -{ -} - -void QQuickAbstractColorDialog::setVisible(bool v) -{ - if (helper() && v) { - m_dlgHelper->setOptions(m_options); - // Due to the fact that QColorDialogOptions doesn't have currentColor... - m_dlgHelper->setCurrentColor(m_color); - } - QQuickAbstractDialog::setVisible(v); - // QTBUG-35206 -#if defined(Q_OS_WIN) - if (m_dialogWindow) - m_dialogWindow->setWidth(m_dialogWindow->width() + 1); -#endif -} - -void QQuickAbstractColorDialog::setModality(Qt::WindowModality m) -{ -#ifdef Q_OS_MAC - // On the Mac, modality doesn't work unless you call exec() - m_modality = Qt::NonModal; - emit modalityChanged(); - return; -#endif - QQuickAbstractDialog::setModality(m); -} - -QString QQuickAbstractColorDialog::title() const -{ - return m_options->windowTitle(); -} - -bool QQuickAbstractColorDialog::showAlphaChannel() const -{ - return m_options->testOption(QColorDialogOptions::ShowAlphaChannel); -} - -void QQuickAbstractColorDialog::setTitle(const QString &t) -{ - if (m_options->windowTitle() == t) return; - m_options->setWindowTitle(t); - emit titleChanged(); -} - -void QQuickAbstractColorDialog::setColor(QColor arg) -{ - if (m_dlgHelper) - m_dlgHelper->setCurrentColor(arg); - // m_options->setCustomColor or setStandardColor don't make sense here - if (m_color != arg) { - m_color = arg; - emit colorChanged(); - } - setCurrentColor(arg); -} - -void QQuickAbstractColorDialog::setCurrentColor(QColor currentColor) -{ - if (m_currentColor != currentColor) { - m_currentColor = currentColor; - emit currentColorChanged(); - } -} - -void QQuickAbstractColorDialog::setShowAlphaChannel(bool arg) -{ - m_options->setOption(QColorDialogOptions::ShowAlphaChannel, arg); - emit showAlphaChannelChanged(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h deleted file mode 100644 index ad2c7ce1ed..0000000000 --- a/src/imports/dialogs/qquickabstractcolordialog_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCOLORDIALOG_P_H -#define QQUICKABSTRACTCOLORDIALOG_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 <QtQml> -#include <QQuickView> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <qpa/qplatformtheme.h> -#include "qquickabstractdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickAbstractColorDialog : public QQuickAbstractDialog -{ - Q_OBJECT - Q_PROPERTY(bool showAlphaChannel READ showAlphaChannel WRITE setShowAlphaChannel NOTIFY showAlphaChannelChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged) - Q_PROPERTY(qreal currentHue READ currentHue NOTIFY currentColorChanged) - Q_PROPERTY(qreal currentSaturation READ currentSaturation NOTIFY currentColorChanged) - Q_PROPERTY(qreal currentLightness READ currentLightness NOTIFY currentColorChanged) - Q_PROPERTY(qreal currentAlpha READ currentAlpha NOTIFY currentColorChanged) - -public: - QQuickAbstractColorDialog(QObject *parent = 0); - virtual ~QQuickAbstractColorDialog(); - - virtual QString title() const; - bool showAlphaChannel() const; - QColor color() const { return m_color; } - QColor currentColor() const { return m_currentColor; } - qreal currentHue() const { return m_currentColor.hslHueF(); } - qreal currentSaturation() const { return m_currentColor.hslSaturationF(); } - qreal currentLightness() const { return m_currentColor.lightnessF(); } - qreal currentAlpha() const { return m_currentColor.alphaF(); } - -public Q_SLOTS: - void setVisible(bool v); - void setModality(Qt::WindowModality m); - void setTitle(const QString &t); - void setColor(QColor arg); - void setCurrentColor(QColor currentColor); - void setShowAlphaChannel(bool arg); - -Q_SIGNALS: - void showAlphaChannelChanged(); - void colorChanged(); - void currentColorChanged(); - void selectionAccepted(); - -protected: - QPlatformColorDialogHelper *m_dlgHelper; - QSharedPointer<QColorDialogOptions> m_options; - QColor m_color; - QColor m_currentColor; - - Q_DISABLE_COPY(QQuickAbstractColorDialog) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCOLORDIALOG_P_H diff --git a/src/imports/dialogs/qquickabstractdialog.cpp b/src/imports/dialogs/qquickabstractdialog.cpp deleted file mode 100644 index 9bb2388741..0000000000 --- a/src/imports/dialogs/qquickabstractdialog.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/**************************************************************************** -** -** 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 <private/qguiapplication_p.h> -#include <QWindow> -#include <QQmlComponent> -#include <QQuickWindow> -#include <qpa/qplatformintegration.h> - -QT_BEGIN_NAMESPACE - -QQmlComponent *QQuickAbstractDialog::m_decorationComponent(0); - -QQuickAbstractDialog::QQuickAbstractDialog(QObject *parent) - : QObject(parent) - , m_parentWindow(0) - , m_visible(false) - , m_modality(Qt::WindowModal) - , m_qmlImplementation(0) - , m_dialogWindow(0) - , m_contentItem(0) - , m_windowDecoration(0) - , m_hasNativeWindows(QGuiApplicationPrivate::platformIntegration()-> - hasCapability(QPlatformIntegration::MultipleWindows) && - QGuiApplicationPrivate::platformIntegration()-> - hasCapability(QPlatformIntegration::WindowManagement)) - , m_hasAspiredPosition(false) -{ -} - -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<QWindow *>(m_qmlImplementation); - if (!m_dialogWindow) { - m_contentItem = qobject_cast<QQuickItem *>(m_qmlImplementation); - if (m_contentItem) { - if (m_hasNativeWindows) - m_dialogWindow = m_contentItem->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 && m_hasNativeWindows) { - QQuickWindow *win = new QQuickWindow; - ((QObject *)win)->setParent(this); // memory management only - m_dialogWindow = win; - m_contentItem->setParentItem(win->contentItem()); - m_dialogWindow->setMinimumSize(QSize(m_contentItem->implicitWidth(), m_contentItem->implicitHeight())); - connect(win, SIGNAL(widthChanged(int)), this, SLOT(windowGeometryChanged())); - connect(win, SIGNAL(heightChanged(int)), this, SLOT(windowGeometryChanged())); - } - - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - - // If the platform does not support multiple windows, but the dialog is - // implemented as an Item, then try to decorate it as a fake window and make it visible. - if (parentItem && !m_dialogWindow && !m_windowDecoration) { - if (m_decorationComponent) { - if (m_decorationComponent->isLoading()) - connect(m_decorationComponent, SIGNAL(statusChanged(QQmlComponent::Status)), - this, SLOT(decorationLoaded())); - else - decorationLoaded(); - } - // Window decoration wasn't possible, so just reparent it into the scene - else { - m_contentItem->setParentItem(parentItem); - m_contentItem->setZ(10000); - } - } - } - } - if (m_dialogWindow) { - // "grow up" to the size and position expected to achieve - if (!m_sizeAspiration.isNull()) { - if (m_hasAspiredPosition) - m_dialogWindow->setGeometry(m_sizeAspiration); - else { - if (m_sizeAspiration.width() > 0) - m_dialogWindow->setWidth(m_sizeAspiration.width()); - if (m_sizeAspiration.height() > 0) - m_dialogWindow->setHeight(m_sizeAspiration.height()); - } - } - connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool))); - connect(m_dialogWindow, SIGNAL(xChanged(int)), this, SLOT(setX(int))); - connect(m_dialogWindow, SIGNAL(yChanged(int)), this, SLOT(setY(int))); - connect(m_dialogWindow, SIGNAL(widthChanged(int)), this, SLOT(setWidth(int))); - connect(m_dialogWindow, SIGNAL(heightChanged(int)), this, SLOT(setHeight(int))); - } - } - if (m_windowDecoration) { - m_windowDecoration->setVisible(v); - } else 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::decorationLoaded() -{ - bool ok = false; - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - while (parentItem->parentItem() && !parentItem->parentItem()->inherits("QQuickRootItem")) - parentItem = parentItem->parentItem(); - if (m_decorationComponent->isError()) { - qWarning() << m_decorationComponent->errors(); - } else { - QObject *decoration = m_decorationComponent->create(); - m_windowDecoration = qobject_cast<QQuickItem *>(decoration); - if (m_windowDecoration) { - m_windowDecoration->setParentItem(parentItem); - // Give the window decoration its content to manage - QVariant contentVariant; - contentVariant.setValue<QQuickItem*>(m_contentItem); - m_windowDecoration->setProperty("content", contentVariant); - connect(m_windowDecoration, SIGNAL(dismissed()), this, SLOT(reject())); - ok = true; - } else { - qWarning() << m_decorationComponent->url() << - "cannot be used as a window decoration because it's not an Item"; - delete m_windowDecoration; - delete m_decorationComponent; - m_decorationComponent = 0; - } - } - // Window decoration wasn't possible, so just reparent it into the scene - if (!ok) { - m_contentItem->setParentItem(parentItem); - m_contentItem->setZ(10000); - } -} - -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<QQuickItem*>(m_qmlImplementation); - if (m_dialogWindow && content) { - content->setWidth(m_dialogWindow->width()); - content->setHeight(m_dialogWindow->height()); - } -} - -QQuickWindow *QQuickAbstractDialog::parentWindow() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(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 m_sizeAspiration.x(); -} - -int QQuickAbstractDialog::y() const -{ - if (m_dialogWindow) - return m_dialogWindow->y(); - return m_sizeAspiration.y(); -} - -int QQuickAbstractDialog::width() const -{ - if (m_dialogWindow) - return m_dialogWindow->width(); - return m_sizeAspiration.width(); -} - -int QQuickAbstractDialog::height() const -{ - if (m_dialogWindow) - return m_dialogWindow->height(); - return m_sizeAspiration.height(); -} - -void QQuickAbstractDialog::setX(int arg) -{ - m_hasAspiredPosition = true; - m_sizeAspiration.setX(arg); - if (helper()) { - // TODO - } else if (m_dialogWindow) { - if (sender() != m_dialogWindow) - m_dialogWindow->setX(arg); - } else if (m_contentItem) { - m_contentItem->setX(arg); - } - emit geometryChanged(); -} - -void QQuickAbstractDialog::setY(int arg) -{ - m_hasAspiredPosition = true; - m_sizeAspiration.setY(arg); - if (helper()) { - // TODO - } else if (m_dialogWindow) { - if (sender() != m_dialogWindow) - m_dialogWindow->setY(arg); - } else if (m_contentItem) { - m_contentItem->setY(arg); - } - emit geometryChanged(); -} - -void QQuickAbstractDialog::setWidth(int arg) -{ - m_sizeAspiration.setWidth(arg); - if (helper()) { - // TODO - } else if (m_dialogWindow) { - if (sender() != m_dialogWindow) - m_dialogWindow->setWidth(arg); - } else if (m_contentItem) { - m_contentItem->setWidth(arg); - } - emit geometryChanged(); -} - -void QQuickAbstractDialog::setHeight(int arg) -{ - m_sizeAspiration.setHeight(arg); - if (helper()) { - // TODO - } else if (m_dialogWindow) { - if (sender() != m_dialogWindow) - m_dialogWindow->setHeight(arg); - } else if (m_contentItem) { - m_contentItem->setHeight(arg); - } - emit geometryChanged(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractdialog_p.h b/src/imports/dialogs/qquickabstractdialog_p.h deleted file mode 100644 index 8ffa166c5b..0000000000 --- a/src/imports/dialogs/qquickabstractdialog_p.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** 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 <QtQml> -#include <QQuickView> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <qpa/qplatformtheme.h> - -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(bool isWindow READ isWindow CONSTANT) - 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(const QString &t) = 0; - void setQmlImplementation(QObject* obj); - bool isWindow() const { return m_hasNativeWindows; } - -public Q_SLOTS: - void open() { setVisible(true); } - void close() { setVisible(false); } - void setX(int arg); - void setY(int arg); - void setWidth(int arg); - void setHeight(int arg); - -Q_SIGNALS: - void visibilityChanged(); - void geometryChanged(); - void modalityChanged(); - void titleChanged(); - void accepted(); - void rejected(); - -protected Q_SLOTS: - void decorationLoaded(); - virtual void accept(); - virtual 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; - QQuickItem *m_contentItem; - QQuickItem *m_windowDecoration; - bool m_hasNativeWindows; - QRect m_sizeAspiration; - bool m_hasAspiredPosition; - - static QQmlComponent *m_decorationComponent; - - friend class QtQuick2DialogsPlugin; - - 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 deleted file mode 100644 index 0cac801311..0000000000 --- a/src/imports/dialogs/qquickabstractfiledialog.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractfiledialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -QQuickAbstractFileDialog::QQuickAbstractFileDialog(QObject *parent) - : QQuickAbstractDialog(parent) - , m_dlgHelper(0) - , m_options(QSharedPointer<QFileDialogOptions>(new QFileDialogOptions())) - , m_selectExisting(true) - , m_selectMultiple(false) - , m_selectFolder(false) -{ - updateModes(); - connect(this, SIGNAL(accepted()), this, SIGNAL(selectionAccepted())); -} - -QQuickAbstractFileDialog::~QQuickAbstractFileDialog() -{ -} - -void QQuickAbstractFileDialog::setVisible(bool v) -{ - if (helper() && v) { - m_dlgHelper->setOptions(m_options); - m_dlgHelper->setFilter(); - emit filterSelected(); - } - QQuickAbstractDialog::setVisible(v); -} - -QString QQuickAbstractFileDialog::title() const -{ - return m_options->windowTitle(); -} - -void QQuickAbstractFileDialog::setTitle(const QString &t) -{ - if (m_options->windowTitle() == t) return; - m_options->setWindowTitle(t); - emit titleChanged(); -} - -void QQuickAbstractFileDialog::setSelectExisting(bool selectExisting) -{ - if (selectExisting == m_selectExisting) return; - m_selectExisting = selectExisting; - updateModes(); -} - -void QQuickAbstractFileDialog::setSelectMultiple(bool selectMultiple) -{ - if (selectMultiple == m_selectMultiple) return; - m_selectMultiple = selectMultiple; - updateModes(); -} - -void QQuickAbstractFileDialog::setSelectFolder(bool selectFolder) -{ - if (selectFolder == m_selectFolder) return; - m_selectFolder = selectFolder; - updateModes(); -} - -QUrl QQuickAbstractFileDialog::folder() -{ - if (m_dlgHelper && !m_dlgHelper->directory().isEmpty()) - return m_dlgHelper->directory(); - return m_options->initialDirectory(); -} - -void QQuickAbstractFileDialog::setFolder(const QUrl &f) -{ - if (m_dlgHelper) - m_dlgHelper->setDirectory(f); - m_options->setInitialDirectory(f); - emit folderChanged(); -} - -void QQuickAbstractFileDialog::setNameFilters(const QStringList &f) -{ - m_options->setNameFilters(f); - if (f.isEmpty()) - selectNameFilter(QString()); - else if (!f.contains(selectedNameFilter())) - selectNameFilter(f.first()); - emit nameFiltersChanged(); -} - -QString QQuickAbstractFileDialog::selectedNameFilter() -{ - QString ret; - if (m_dlgHelper) - ret = m_dlgHelper->selectedNameFilter(); - if (ret.isEmpty()) - return m_options->initiallySelectedNameFilter(); - return ret; -} - -void QQuickAbstractFileDialog::selectNameFilter(const QString &f) -{ - // This should work whether the dialog is currently being shown already, or ahead of time. - m_options->setInitiallySelectedNameFilter(f); - if (m_dlgHelper) - m_dlgHelper->selectNameFilter(f); - emit filterSelected(); -} - -QUrl QQuickAbstractFileDialog::fileUrl() -{ - QList<QUrl> urls = fileUrls(); - return (urls.count() == 1) ? urls[0] : QUrl(); -} - -QList<QUrl> QQuickAbstractFileDialog::fileUrls() -{ - if (m_dlgHelper) - return m_dlgHelper->selectedFiles(); - return QList<QUrl>(); -} - -void QQuickAbstractFileDialog::updateModes() -{ - // The 4 possible modes are AnyFile, ExistingFile, Directory, ExistingFiles - // Assume AnyFile until we find a reason to the contrary - QFileDialogOptions::FileMode mode = QFileDialogOptions::AnyFile; - - if (m_selectFolder) { - mode = QFileDialogOptions::Directory; - m_options->setOption(QFileDialogOptions::ShowDirsOnly); - m_selectMultiple = false; - m_selectExisting = true; - setNameFilters(QStringList()); - } else if (m_selectExisting) { - mode = m_selectMultiple ? - QFileDialogOptions::ExistingFiles : QFileDialogOptions::ExistingFile; - m_options->setOption(QFileDialogOptions::ShowDirsOnly, false); - } else if (m_selectMultiple) { - m_selectExisting = true; - } - if (!m_selectExisting) - m_selectMultiple = false; - m_options->setFileMode(mode); - m_options->setAcceptMode(m_selectExisting ? - QFileDialogOptions::AcceptOpen : QFileDialogOptions::AcceptSave); - emit fileModeChanged(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractfiledialog_p.h b/src/imports/dialogs/qquickabstractfiledialog_p.h deleted file mode 100644 index 5ce48e8055..0000000000 --- a/src/imports/dialogs/qquickabstractfiledialog_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTFILEDIALOG_P_H -#define QQUICKABSTRACTFILEDIALOG_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 <QtQml> -#include <QQuickView> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <qpa/qplatformtheme.h> -#include "qquickabstractdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickAbstractFileDialog : public QQuickAbstractDialog -{ - Q_OBJECT - 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(QUrl 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 selectionAccepted) - Q_PROPERTY(QList<QUrl> fileUrls READ fileUrls NOTIFY selectionAccepted) - -public: - QQuickAbstractFileDialog(QObject *parent = 0); - virtual ~QQuickAbstractFileDialog(); - - virtual QString title() const; - bool selectExisting() const { return m_selectExisting; } - bool selectMultiple() const { return m_selectMultiple; } - bool selectFolder() const { return m_selectFolder; } - QUrl folder(); - QStringList nameFilters() const { return m_options->nameFilters(); } - QString selectedNameFilter(); - QUrl fileUrl(); - virtual QList<QUrl> fileUrls(); - -public Q_SLOTS: - void setVisible(bool v); - void setTitle(const QString &t); - void setSelectExisting(bool s); - void setSelectMultiple(bool s); - void setSelectFolder(bool s); - void setFolder(const QUrl &f); - void setNameFilters(const QStringList &f); - void selectNameFilter(const QString &f); - -Q_SIGNALS: - void folderChanged(); - void nameFiltersChanged(); - void filterSelected(); - void fileModeChanged(); - void selectionAccepted(); - -protected: - void updateModes(); - -protected: - QPlatformFileDialogHelper *m_dlgHelper; - QSharedPointer<QFileDialogOptions> m_options; - bool m_selectExisting; - bool m_selectMultiple; - bool m_selectFolder; - - Q_DISABLE_COPY(QQuickAbstractFileDialog) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTFILEDIALOG_P_H diff --git a/src/imports/dialogs/qquickabstractfontdialog.cpp b/src/imports/dialogs/qquickabstractfontdialog.cpp deleted file mode 100644 index 29dd15e8cc..0000000000 --- a/src/imports/dialogs/qquickabstractfontdialog.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractfontdialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -QQuickAbstractFontDialog::QQuickAbstractFontDialog(QObject *parent) - : QQuickAbstractDialog(parent) - , m_dlgHelper(0) - , m_options(QSharedPointer<QFontDialogOptions>(new QFontDialogOptions())) -{ - // On the Mac, modality doesn't work unless you call exec(). But this is a reasonable default anyway. - m_modality = Qt::NonModal; - connect(this, SIGNAL(accepted()), this, SIGNAL(selectionAccepted())); -} - -QQuickAbstractFontDialog::~QQuickAbstractFontDialog() -{ -} - -void QQuickAbstractFontDialog::setVisible(bool v) -{ - if (helper() && v) { - m_dlgHelper->setOptions(m_options); - // Due to the fact that QFontDialogOptions doesn't have currentFont... - m_dlgHelper->setCurrentFont(m_font); - } - QQuickAbstractDialog::setVisible(v); -} - -void QQuickAbstractFontDialog::setModality(Qt::WindowModality m) -{ -#ifdef Q_OS_MAC - // On the Mac, modality doesn't work unless you call exec() - m_modality = Qt::NonModal; - emit modalityChanged(); - return; -#endif - QQuickAbstractDialog::setModality(m); -} - -QString QQuickAbstractFontDialog::title() const -{ - return m_options->windowTitle(); -} - -bool QQuickAbstractFontDialog::scalableFonts() const -{ - return m_options->testOption(QFontDialogOptions::ScalableFonts); -} - -bool QQuickAbstractFontDialog::nonScalableFonts() const -{ - return m_options->testOption(QFontDialogOptions::NonScalableFonts); -} - -bool QQuickAbstractFontDialog::monospacedFonts() const -{ - return m_options->testOption(QFontDialogOptions::MonospacedFonts); -} - -bool QQuickAbstractFontDialog::proportionalFonts() const -{ - return m_options->testOption(QFontDialogOptions::ProportionalFonts); -} - -void QQuickAbstractFontDialog::setTitle(const QString &t) -{ - if (m_options->windowTitle() == t) return; - m_options->setWindowTitle(t); - emit titleChanged(); -} - -void QQuickAbstractFontDialog::setFont(const QFont &arg) -{ - if (m_font != arg) { - m_font = arg; - emit fontChanged(); - } -} - -void QQuickAbstractFontDialog::setScalableFonts(bool arg) -{ - m_options->setOption(QFontDialogOptions::ScalableFonts, arg); - emit scalableFontsChanged(); -} - -void QQuickAbstractFontDialog::setNonScalableFonts(bool arg) -{ - m_options->setOption(QFontDialogOptions::NonScalableFonts, arg); - emit nonScalableFontsChanged(); -} - -void QQuickAbstractFontDialog::setMonospacedFonts(bool arg) -{ - m_options->setOption(QFontDialogOptions::MonospacedFonts, arg); - emit monospacedFontsChanged(); -} - -void QQuickAbstractFontDialog::setProportionalFonts(bool arg) -{ - m_options->setOption(QFontDialogOptions::ProportionalFonts, arg); - emit proportionalFontsChanged(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractfontdialog_p.h b/src/imports/dialogs/qquickabstractfontdialog_p.h deleted file mode 100644 index 858a0d3eac..0000000000 --- a/src/imports/dialogs/qquickabstractfontdialog_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTFONTDIALOG_P_H -#define QQUICKABSTRACTFONTDIALOG_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 <QtQml> -#include <QQuickView> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <QtGui/qfont.h> -#include <qpa/qplatformtheme.h> -#include "qquickabstractdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickAbstractFontDialog : public QQuickAbstractDialog -{ - Q_OBJECT - Q_PROPERTY(bool scalableFonts READ scalableFonts WRITE setScalableFonts NOTIFY scalableFontsChanged) - Q_PROPERTY(bool nonScalableFonts READ nonScalableFonts WRITE setNonScalableFonts NOTIFY nonScalableFontsChanged) - Q_PROPERTY(bool monospacedFonts READ monospacedFonts WRITE setMonospacedFonts NOTIFY monospacedFontsChanged) - Q_PROPERTY(bool proportionalFonts READ proportionalFonts WRITE setProportionalFonts NOTIFY proportionalFontsChanged) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) - -public: - QQuickAbstractFontDialog(QObject *parent = 0); - virtual ~QQuickAbstractFontDialog(); - - virtual QString title() const; - bool scalableFonts() const; - bool nonScalableFonts() const; - bool monospacedFonts() const; - bool proportionalFonts() const; - QFont font() const { return m_font; } - -public Q_SLOTS: - void setVisible(bool v); - void setModality(Qt::WindowModality m); - void setTitle(const QString &t); - void setFont(const QFont &arg); - void setScalableFonts(bool arg); - void setNonScalableFonts(bool arg); - void setMonospacedFonts(bool arg); - void setProportionalFonts(bool arg); - -Q_SIGNALS: - void scalableFontsChanged(); - void nonScalableFontsChanged(); - void monospacedFontsChanged(); - void proportionalFontsChanged(); - void fontChanged(); - void selectionAccepted(); - -protected: - QPlatformFontDialogHelper *m_dlgHelper; - QSharedPointer<QFontDialogOptions> m_options; - QFont m_font; - - Q_DISABLE_COPY(QQuickAbstractFontDialog) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTFONTDIALOG_P_H diff --git a/src/imports/dialogs/qquickabstractmessagedialog.cpp b/src/imports/dialogs/qquickabstractmessagedialog.cpp deleted file mode 100644 index a44464962a..0000000000 --- a/src/imports/dialogs/qquickabstractmessagedialog.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractmessagedialog_p.h" -#include <QtGui/qpa/qplatformdialoghelper.h> - -QT_BEGIN_NAMESPACE - -QQuickAbstractMessageDialog::QQuickAbstractMessageDialog(QObject *parent) - : QQuickAbstractDialog(parent) - , m_dlgHelper(0) - , m_options(QSharedPointer<QMessageDialogOptions>(new QMessageDialogOptions())) - , m_clickedButton(NoButton) -{ -} - -QQuickAbstractMessageDialog::~QQuickAbstractMessageDialog() -{ -} - -void QQuickAbstractMessageDialog::setVisible(bool v) -{ - if (helper() && v) - m_dlgHelper->setOptions(m_options); - if (v) - m_clickedButton = NoButton; - QQuickAbstractDialog::setVisible(v); -} - -void QQuickAbstractMessageDialog::setTitle(const QString &arg) -{ - if (arg != m_options->windowTitle()) { - m_options->setWindowTitle(arg); - emit titleChanged(); - } -} - -void QQuickAbstractMessageDialog::setText(const QString &arg) -{ - if (arg != m_options->text()) { - m_options->setText(arg); - emit textChanged(); - } -} - -void QQuickAbstractMessageDialog::setInformativeText(const QString &arg) -{ - if (arg != m_options->informativeText()) { - m_options->setInformativeText(arg); - emit informativeTextChanged(); - } -} - -void QQuickAbstractMessageDialog::setDetailedText(const QString &arg) -{ - if (arg != m_options->detailedText()) { - m_options->setDetailedText(arg); - emit detailedTextChanged(); - } -} - -void QQuickAbstractMessageDialog::setIcon(QQuickAbstractMessageDialog::Icon icon) -{ - if (static_cast<int>(icon) != static_cast<int>(m_options->icon())) { - m_options->setIcon(static_cast<QMessageDialogOptions::Icon>(icon)); - emit iconChanged(); - } -} - -QUrl QQuickAbstractMessageDialog::standardIconSource() -{ - switch (m_options->icon()) { - case QMessageDialogOptions::Information: - return QUrl("images/information.png"); - break; - case QMessageDialogOptions::Warning: - return QUrl("images/warning.png"); - break; - case QMessageDialogOptions::Critical: - return QUrl("images/critical.png"); - break; - case QMessageDialogOptions::Question: - return QUrl("images/question.png"); - break; - default: - return QUrl(); - break; - } -} - -void QQuickAbstractMessageDialog::setStandardButtons(StandardButtons buttons) -{ - if (buttons != m_options->standardButtons()) { - m_options->setStandardButtons(static_cast<QMessageDialogOptions::StandardButtons>(static_cast<int>(buttons))); - emit standardButtonsChanged(); - } -} - -void QQuickAbstractMessageDialog::click(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role) -{ - setVisible(false); - m_clickedButton = static_cast<StandardButton>(button); - emit buttonClicked(); - switch (role) { - case QMessageDialogOptions::AcceptRole: - emit accept(); - break; - case QMessageDialogOptions::RejectRole: - emit reject(); - break; - case QMessageDialogOptions::DestructiveRole: - emit discard(); - break; - case QMessageDialogOptions::HelpRole: - emit help(); - break; - case QMessageDialogOptions::YesRole: - emit yes(); - break; - case QMessageDialogOptions::NoRole: - emit no(); - break; - case QMessageDialogOptions::ApplyRole: - emit apply(); - break; - case QMessageDialogOptions::ResetRole: - emit reset(); - break; - default: - qWarning("unhandled MessageDialog button %d with role %d", button, role); - } -} - -void QQuickAbstractMessageDialog::click(QQuickAbstractMessageDialog::StandardButton button) -{ - click(static_cast<QMessageDialogOptions::StandardButton>(button), - static_cast<QMessageDialogOptions::ButtonRole>( - QMessageDialogOptions::buttonRole(static_cast<QMessageDialogOptions::StandardButton>(button)))); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickabstractmessagedialog_p.h b/src/imports/dialogs/qquickabstractmessagedialog_p.h deleted file mode 100644 index f2427bb2e0..0000000000 --- a/src/imports/dialogs/qquickabstractmessagedialog_p.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTMESSAGEDIALOG_P_H -#define QQUICKABSTRACTMESSAGEDIALOG_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 <QtQml> -#include <QQuickView> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include <qpa/qplatformtheme.h> -#include "qquickabstractdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickAbstractMessageDialog : public QQuickAbstractDialog -{ - Q_OBJECT - - Q_ENUMS(Icon) - Q_ENUMS(StandardButton) - Q_FLAGS(StandardButtons) - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged) - Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged) - Q_PROPERTY(Icon icon READ icon WRITE setIcon NOTIFY iconChanged) - Q_PROPERTY(QUrl standardIconSource READ standardIconSource NOTIFY iconChanged) - Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged) - Q_PROPERTY(StandardButton clickedButton READ clickedButton NOTIFY buttonClicked) - -public: - QQuickAbstractMessageDialog(QObject *parent = 0); - virtual ~QQuickAbstractMessageDialog(); - - virtual QString title() const { return m_options->windowTitle(); } - QString text() const { return m_options->text(); } - QString informativeText() const { return m_options->informativeText(); } - QString detailedText() const { return m_options->detailedText(); } - - enum Icon { - NoIcon = QMessageDialogOptions::NoIcon, - Information = QMessageDialogOptions::Information, - Warning = QMessageDialogOptions::Warning, - Critical = QMessageDialogOptions::Critical, - Question = QMessageDialogOptions::Question - }; - - Icon icon() const { return static_cast<Icon>(m_options->icon()); } - - QUrl standardIconSource(); - - enum StandardButton { - NoButton = QMessageDialogOptions::NoButton, - Ok = QMessageDialogOptions::Ok, - Save = QMessageDialogOptions::Save, - SaveAll = QMessageDialogOptions::SaveAll, - Open = QMessageDialogOptions::Open, - Yes = QMessageDialogOptions::Yes, - YesToAll = QMessageDialogOptions::YesToAll, - No = QMessageDialogOptions::No, - NoToAll = QMessageDialogOptions::NoToAll, - Abort = QMessageDialogOptions::Abort, - Retry = QMessageDialogOptions::Retry, - Ignore = QMessageDialogOptions::Ignore, - Close = QMessageDialogOptions::Close, - Cancel = QMessageDialogOptions::Cancel, - Discard = QMessageDialogOptions::Discard, - Help = QMessageDialogOptions::Help, - Apply = QMessageDialogOptions::Apply, - Reset = QMessageDialogOptions::Reset, - RestoreDefaults = QMessageDialogOptions::RestoreDefaults - }; - Q_DECLARE_FLAGS(StandardButtons, StandardButton) - - StandardButtons standardButtons() const { return static_cast<StandardButtons>(static_cast<int>(m_options->standardButtons())); } - - StandardButton clickedButton() const { return m_clickedButton; } - -public Q_SLOTS: - virtual void setVisible(bool v); - virtual void setTitle(const QString &arg); - void setText(const QString &arg); - void setInformativeText(const QString &arg); - void setDetailedText(const QString &arg); - void setIcon(Icon icon); - void setStandardButtons(StandardButtons buttons); - void click(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole); - void click(QQuickAbstractMessageDialog::StandardButton button); - -Q_SIGNALS: - void textChanged(); - void informativeTextChanged(); - void detailedTextChanged(); - void iconChanged(); - void standardButtonsChanged(); - void buttonClicked(); - void discard(); - void help(); - void yes(); - void no(); - void apply(); - void reset(); - -protected: - QPlatformMessageDialogHelper *m_dlgHelper; - QSharedPointer<QMessageDialogOptions> m_options; - StandardButton m_clickedButton; - - Q_DISABLE_COPY(QQuickAbstractMessageDialog) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAbstractMessageDialog::StandardButtons) - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTMESSAGEDIALOG_P_H diff --git a/src/imports/dialogs/qquickcolordialog.cpp b/src/imports/dialogs/qquickcolordialog.cpp deleted file mode 100644 index d0e0e11b07..0000000000 --- a/src/imports/dialogs/qquickcolordialog.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickcolordialog_p.h" -#include <QQuickItem> -#include <private/qguiapplication_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AbstractColorDialog - \instantiates QQuickColorDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup qtquick-visual - \brief API wrapper for QML file dialog implementations - \since 5.1 - \internal - - AbstractColorDialog provides only the API for implementing a color dialog. - 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). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractColorDialog::accepted - - This signal is emitted by \l accept(). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractColorDialog::rejected - - This signal is emitted by \l reject(). -*/ - -/*! - \class QQuickColorDialog - \inmodule QtQuick.Dialogs - \internal - - The QQuickColorDialog class is a concrete subclass of - \l QQuickAbstractColorDialog, 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. - - \since 5.1 -*/ - -/*! - Constructs a file dialog wrapper with parent window \a parent. -*/ -QQuickColorDialog::QQuickColorDialog(QObject *parent) - : QQuickAbstractColorDialog(parent) -{ -} - - -/*! - Destroys the file dialog wrapper. -*/ -QQuickColorDialog::~QQuickColorDialog() -{ -} - -/*! - \qmlproperty bool AbstractColorDialog::visible - - This property holds whether the dialog is visible. By default this is false. -*/ - -/*! - \qmlproperty QObject AbstractColorDialog::implementation - - The QML object which implements the actual file dialog. Should be either a - \l Window or an \l Item. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickcolordialog_p.h b/src/imports/dialogs/qquickcolordialog_p.h deleted file mode 100644 index ff6953fc0f..0000000000 --- a/src/imports/dialogs/qquickcolordialog_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKCOLORDIALOG_P_H -#define QQUICKCOLORDIALOG_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 "qquickabstractcolordialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickColorDialog : public QQuickAbstractColorDialog -{ - Q_OBJECT - Q_PROPERTY(QObject* implementation READ qmlImplementation WRITE setQmlImplementation DESIGNABLE false) - Q_CLASSINFO("DefaultProperty", "implementation") // AbstractColorDialog in QML can have only one child - -public: - explicit QQuickColorDialog(QObject *parent = 0); - ~QQuickColorDialog(); - -protected: - virtual QPlatformColorDialogHelper *helper() { return 0; } - - Q_DISABLE_COPY(QQuickColorDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickColorDialog *) - -#endif // QQUICKCOLORDIALOG_P_H diff --git a/src/imports/dialogs/qquickfiledialog.cpp b/src/imports/dialogs/qquickfiledialog.cpp deleted file mode 100644 index 2ee4afc5d2..0000000000 --- a/src/imports/dialogs/qquickfiledialog.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickfiledialog_p.h" -#include <QQuickItem> -#include <private/qguiapplication_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AbstractFileDialog - \instantiates QQuickFileDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup qtquick-visual - \brief API wrapper for QML file dialog implementations - \since 5.1 - \internal - - AbstractFileDialog provides only the API for implementing a file dialog. - 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). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractFileDialog::accepted - - This signal is emitted by \l accept(). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractFileDialog::rejected - - This signal is emitted by \l reject(). -*/ - -/*! - \class QQuickFileDialog - \inmodule QtQuick.Dialogs - \internal - - 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. - - \since 5.1 -*/ - -/*! - Constructs a file dialog wrapper with parent window \a parent. -*/ -QQuickFileDialog::QQuickFileDialog(QObject *parent) - : QQuickAbstractFileDialog(parent) -{ -} - - -/*! - Destroys the file dialog wrapper. -*/ -QQuickFileDialog::~QQuickFileDialog() -{ -} - -QList<QUrl> QQuickFileDialog::fileUrls() -{ - return m_selections; -} - -/*! - \qmlproperty bool AbstractFileDialog::visible - - This property holds whether the dialog is visible. By default this is false. -*/ - -/*! - \qmlproperty bool AbstractFileDialog::fileUrls - - A list of files to be populated as the user chooses. -*/ - -/*! - \brief Clears \l fileUrls -*/ -void QQuickFileDialog::clearSelection() -{ - m_selections.clear(); -} - -/*! - \brief Adds one file to \l fileUrls - - \l path should be given as an absolute file:// path URL. - Returns true on success, false if the given path is - not valid given the current property settings. -*/ -bool QQuickFileDialog::addSelection(const QUrl &path) -{ - QFileInfo info(path.toLocalFile()); - if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) { - if (m_selectFolder) - m_selections.append(pathFolder(path.toLocalFile())); - else - m_selections.append(path); - return true; - } - return false; -} - -/*! - \brief get a file's directory as a URL - - If \a path points to a directory, just convert it to a URL. - If \a path points to a file, convert the file's directory to a URL. -*/ -QUrl QQuickFileDialog::pathFolder(const QString &path) -{ - QFileInfo info(path); - if (info.exists() && info.isDir()) - return QUrl::fromLocalFile(path); - return QUrl::fromLocalFile(QFileInfo(path).absolutePath()); -} - -/*! - \qmlproperty QObject AbstractFileDialog::implementation - - The QML object which implements the actual file dialog. Should be either a - \l Window or an \l Item. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickfiledialog_p.h b/src/imports/dialogs/qquickfiledialog_p.h deleted file mode 100644 index a4c7939fda..0000000000 --- a/src/imports/dialogs/qquickfiledialog_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qquickabstractfiledialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickFileDialog : public QQuickAbstractFileDialog -{ - Q_OBJECT - 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(); - virtual QList<QUrl> fileUrls(); - -Q_SIGNALS: - -public Q_SLOTS: - void clearSelection(); - bool addSelection(const QUrl &path); - -protected: - virtual QPlatformFileDialogHelper *helper() { return 0; } - Q_INVOKABLE QString urlToPath(const QUrl &url) { return url.toLocalFile(); } - Q_INVOKABLE QUrl pathToUrl(const QString &path) { return QUrl::fromLocalFile(path); } - Q_INVOKABLE QUrl pathFolder(const QString &path); - -private: - QList<QUrl> m_selections; - - Q_DISABLE_COPY(QQuickFileDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickFileDialog *) - -#endif // QQUICKFILEDIALOG_P_H diff --git a/src/imports/dialogs/qquickfontdialog.cpp b/src/imports/dialogs/qquickfontdialog.cpp deleted file mode 100644 index 2f3c6d83bb..0000000000 --- a/src/imports/dialogs/qquickfontdialog.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickfontdialog_p.h" -#include <QQuickItem> -#include <private/qguiapplication_p.h> -#include <qpa/qplatformintegration.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AbstractFontDialog - \instantiates QQuickFontDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup qtquick-visual - \brief API wrapper for QML font dialog implementations - \since 5.2 - \internal - - AbstractFontDialog provides only the API for implementing a font dialog. - 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). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractFontDialog::accepted - - The \a accepted signal is emitted by \l accept(). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractFontDialog::rejected - - The \a accepted signal is emitted by \l reject(). -*/ - -/*! - \class QQuickFontDialog - \inmodule QtQuick.Dialogs - \internal - - The QQuickFontDialog class is a concrete subclass of \l - QQuickAbstractFontDialog, 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. - - \since 5.2 -*/ - -/*! - Constructs a font dialog wrapper with parent window \a parent. -*/ -QQuickFontDialog::QQuickFontDialog(QObject *parent) - : QQuickAbstractFontDialog(parent) -{ -} - - -/*! - Destroys the font dialog wrapper. -*/ -QQuickFontDialog::~QQuickFontDialog() -{ -} - -/*! - \qmlproperty bool AbstractFontDialog::visible - - This property holds whether the dialog is visible. By default this is false. -*/ - -/*! - \qmlproperty QObject AbstractFontDialog::implementation - - The QML object which implements the actual font dialog. Should be either a - \l Window or an \l Item. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickfontdialog_p.h b/src/imports/dialogs/qquickfontdialog_p.h deleted file mode 100644 index a8e2d82e6f..0000000000 --- a/src/imports/dialogs/qquickfontdialog_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qquickabstractfontdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickFontDialog : public QQuickAbstractFontDialog -{ - Q_OBJECT - Q_PROPERTY(QObject* implementation READ qmlImplementation WRITE setQmlImplementation DESIGNABLE false) - Q_CLASSINFO("DefaultProperty", "implementation") - -public: - explicit QQuickFontDialog(QObject *parent = 0); - ~QQuickFontDialog(); - -protected: - virtual QPlatformFontDialogHelper *helper() { return 0; } - - Q_DISABLE_COPY(QQuickFontDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickFontDialog *) - -#endif // QQUICKFONTDIALOG_P_H diff --git a/src/imports/dialogs/qquickmessagedialog.cpp b/src/imports/dialogs/qquickmessagedialog.cpp deleted file mode 100644 index 43b6ca09b4..0000000000 --- a/src/imports/dialogs/qquickmessagedialog.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickmessagedialog_p.h" -#include <QQuickItem> -#include <private/qguiapplication_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AbstractMessageDialog - \instantiates QQuickMessageDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup qtquick-visual - \brief API wrapper for QML message dialog implementations - \since 5.2 - \internal - - AbstractMessageDialog provides only the API for implementing a message dialog. - 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). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractMessageDialog::accepted - - This signal is emitted by \l accept(). -*/ - -/*! - \qmlsignal QtQuick::Dialogs::AbstractMessageDialog::rejected - - This signal is emitted by \l reject(). -*/ - -/*! - \class QQuickMessageDialog - \inmodule QtQuick.Dialogs - \internal - - The QQuickMessageDialog class is a concrete subclass of - \l QQuickAbstractMessageDialog, 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. - - \since 5.2 -*/ - -/*! - Constructs a message dialog wrapper with parent window \a parent. -*/ -QQuickMessageDialog::QQuickMessageDialog(QObject *parent) - : QQuickAbstractMessageDialog(parent) -{ - connect(this, SIGNAL(buttonClicked()), this, SLOT(clicked())); -} - - -/*! - Destroys the message dialog wrapper. -*/ -QQuickMessageDialog::~QQuickMessageDialog() -{ -} - -/*! - \qmlproperty bool AbstractMessageDialog::visible - - This property holds whether the dialog is visible. By default this is false. -*/ - -/*! - \qmlproperty QObject AbstractMessageDialog::implementation - - The QML object which implements the actual message dialog. Should be either a - \l Window or an \l Item. -*/ - - -void QQuickMessageDialog::clicked() { - switch (m_clickedButton) { - // This mapping from buttons to roles is the same as - // documented for enum QMessageBox::StandardButton - case Ok: - case Open: - case Save: - case SaveAll: - case Retry: - case Ignore: - accept(); - break; - case Cancel: - case Close: - case Abort: - reject(); - break; - case Discard: - emit discard(); - close(); - break; - case Help: - emit help(); - break; - case Yes: - case YesToAll: - emit yes(); - close(); - break; - case No: - case NoToAll: - emit no(); - close(); - break; - case Apply: - emit apply(); - break; - case Reset: - case RestoreDefaults: - emit reset(); - break; - default: - qWarning("StandardButton %d has no role", m_clickedButton); - } -} - -void QQuickMessageDialog::accept() { - // enter key is treated like OK - if (m_clickedButton == NoButton) - m_clickedButton = Ok; - QQuickAbstractMessageDialog::accept(); -} - -void QQuickMessageDialog::reject() { - // escape key is treated like cancel - if (m_clickedButton == NoButton) - m_clickedButton = Cancel; - QQuickAbstractMessageDialog::reject(); -} - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickmessagedialog_p.h b/src/imports/dialogs/qquickmessagedialog_p.h deleted file mode 100644 index b21d8cba42..0000000000 --- a/src/imports/dialogs/qquickmessagedialog_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKMESSAGEDIALOG_P_H -#define QQUICKMESSAGEDIALOG_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 "qquickabstractmessagedialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickMessageDialog : public QQuickAbstractMessageDialog -{ - Q_OBJECT - Q_PROPERTY(QObject* implementation READ qmlImplementation WRITE setQmlImplementation DESIGNABLE false) - Q_CLASSINFO("DefaultProperty", "implementation") // AbstractMessageDialog in QML can have only one child - -public: - explicit QQuickMessageDialog(QObject *parent = 0); - ~QQuickMessageDialog(); - -protected: - virtual QPlatformDialogHelper *helper() { return 0; } - -protected Q_SLOTS: - virtual void accept(); - virtual void reject(); - void clicked(); - -private: - Q_DISABLE_COPY(QQuickMessageDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickMessageDialog *) - -#endif // QQUICKMESSAGEDIALOG_P_H diff --git a/src/imports/dialogs/qquickplatformcolordialog.cpp b/src/imports/dialogs/qquickplatformcolordialog.cpp deleted file mode 100644 index 11ddbfe6c7..0000000000 --- a/src/imports/dialogs/qquickplatformcolordialog.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickplatformcolordialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickView> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ColorDialog - \instantiates QQuickPlatformColorDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup dialogs - \brief Dialog component for choosing a color. - \since 5.1 - - ColorDialog allows the user to select a color. The dialog is initially - invisible. You need to set the properties as desired first, then set - \l visible to true or call \l open(). - - Here is a minimal example to open a color dialog and exit after the user - chooses a color: - - \qml - import QtQuick 2.1 - import QtQuick.Dialogs 1.0 - - ColorDialog { - id: colorDialog - title: "Please choose a color" - onAccepted: { - console.log("You chose: " + colorDialog.color) - Qt.quit() - } - onRejected: { - console.log("Canceled") - Qt.quit() - } - Component.onCompleted: visible = true - } - \endqml - - A ColorDialog window is automatically transient for its parent window. So - whether you declare the dialog inside an \l Item or inside a \l Window, the - dialog will appear centered over the window containing the item, or over - the Window that you declared. - - The implementation of ColorDialog will be a platform color dialog if - possible. If that isn't possible, then it will try to instantiate a - \l QColorDialog. If that also isn't possible, then it will fall back to a QML - implementation, DefaultColorDialog.qml. In that case you can customize the - appearance by editing this file. DefaultColorDialog.qml contains a Rectangle - to hold the dialog's contents, because certain embedded systems do not - support multiple top-level windows. When the dialog becomes visible, it - will automatically be wrapped in a Window if possible, or simply reparented - on top of the main window if there can only be one window. -*/ - -/*! - \qmlsignal QtQuick::Dialogs::ColorDialog::accepted - - This handler is called when the user has finished using the - dialog. You can then inspect the \l color property to get the selection. - - Example: - - \qml - ColorDialog { - onAccepted: { console.log("Selected color: " + color) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::ColorDialog::rejected - - This handler is called when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickPlatformColorDialog - \inmodule QtQuick.Dialogs - \internal - - \brief The QQuickPlatformColorDialog class provides a color dialog - - The dialog is implemented via the QPlatformColorDialogHelper when possible; - otherwise it falls back to a QColorDialog or a QML implementation. - - \since 5.1 -*/ - -/*! - Constructs a color dialog with parent window \a parent. -*/ -QQuickPlatformColorDialog::QQuickPlatformColorDialog(QObject *parent) : - QQuickAbstractColorDialog(parent) -{ -} - -/*! - Destroys the color dialog. -*/ -QQuickPlatformColorDialog::~QQuickPlatformColorDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformColorDialogHelper *QQuickPlatformColorDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()-> - usePlatformNativeDialog(QPlatformTheme::ColorDialog) ) { - m_dlgHelper = static_cast<QPlatformColorDialogHelper *>(QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(QPlatformTheme::ColorDialog)); - if (!m_dlgHelper) - return m_dlgHelper; - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - connect(m_dlgHelper, SIGNAL(currentColorChanged(QColor)), this, SLOT(setCurrentColor(QColor))); - connect(m_dlgHelper, SIGNAL(colorSelected(QColor)), this, SLOT(setColor(QColor))); - } - - return m_dlgHelper; -} - -/*! - \qmlproperty bool ColorDialog::visible - - This property holds whether the dialog is visible. By default this is - false. - - \sa modality -*/ - -/*! - \qmlproperty Qt::WindowModality ColorDialog::modality - - Whether the dialog should be shown modal with respect to the window - containing the dialog's parent Item, modal with respect to the whole - application, or non-modal. - - By default it is \l NonModal. - - Modality does not mean that there are any blocking calls to wait for the - dialog to be accepted or rejected; it's only that the user will be - prevented from interacting with the parent window and/or the application - windows at the same time. - - On MacOS the color dialog is only allowed to be non-modal. -*/ - -/*! - \qmlmethod void ColorDialog::open() - - Shows the dialog to the user. It is equivalent to setting \l visible to - true. -*/ - -/*! - \qmlmethod void ColorDialog::close() - - Closes the dialog. -*/ - -/*! - \qmlproperty string ColorDialog::title - - The title of the dialog window. -*/ - -/*! - \qmlproperty bool ColorDialog::showAlphaChannel - - Whether the dialog will provide a means of changing the opacity. - - By default, this property is true. This property must be set to the desired - value before opening the dialog. Usually the alpha channel is represented - by an additional slider control. -*/ - -/*! - \qmlproperty color ColorDialog::color - - The color which the user selected. - - \note This color is not always the same as the color held by the - currentColor property since the user can choose different colors before - finally selecting the one to use. - - \sa currentColor -*/ - -/*! - \qmlproperty color ColorDialog::currentColor - - The color which the user has currently selected. - - For the color that is set when the dialog is accepted, use the \l color - property. - - \sa color -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickplatformcolordialog_p.h b/src/imports/dialogs/qquickplatformcolordialog_p.h deleted file mode 100644 index 55d301da8b..0000000000 --- a/src/imports/dialogs/qquickplatformcolordialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKPLATFORMCOLORDIALOG_P_H -#define QQUICKPLATFORMCOLORDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qquickabstractcolordialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickPlatformColorDialog : public QQuickAbstractColorDialog -{ - Q_OBJECT - -public: - QQuickPlatformColorDialog(QObject *parent = 0); - virtual ~QQuickPlatformColorDialog(); - -protected: - QPlatformColorDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickPlatformColorDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformColorDialog *) - -#endif // QQUICKPLATFORMCOLORDIALOG_P_H diff --git a/src/imports/dialogs/qquickplatformfiledialog.cpp b/src/imports/dialogs/qquickplatformfiledialog.cpp deleted file mode 100644 index 066aabe336..0000000000 --- a/src/imports/dialogs/qquickplatformfiledialog.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickplatformfiledialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickView> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FileDialog - \instantiates QQuickPlatformFileDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup dialogs - \brief Dialog component for choosing files from a local filesystem. - \since 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 - initially invisible. You need to set the properties as desired first, then - set \l visible to true or call \l open(). - - Here is a minimal example to open a file dialog and exit after the user - chooses a file: - - \qml - import QtQuick 2.1 - import QtQuick.Dialogs 1.0 - - FileDialog { - id: fileDialog - title: "Please choose a file" - onAccepted: { - console.log("You chose: " + fileDialog.fileUrls) - Qt.quit() - } - onRejected: { - console.log("Canceled") - Qt.quit() - } - Component.onCompleted: visible = true - } - \endqml - - A FileDialog window is automatically transient for its parent window. So - whether you declare the dialog inside an \l Item or inside a \l Window, the - dialog will appear centered over the window containing the item, or over - the Window that you declared. - - The implementation of FileDialog will be a platform file dialog if - possible. If that isn't possible, then it will try to instantiate a - \l QFileDialog. If that also isn't possible, then it will fall back to a QML - implementation, DefaultFileDialog.qml. In that case you can customize the - appearance by editing this file. DefaultFileDialog.qml contains a Rectangle - to hold the dialog's contents, because certain embedded systems do not - support multiple top-level windows. When the dialog becomes visible, it - will automatically be wrapped in a Window if possible, or simply reparented - on top of the main window if there can only be one window. -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FileDialog::accepted - - This handler is called when the user has finished using the - dialog. You can then inspect the \l fileUrl or \l fileUrls properties to - get the selection. - - Example: - - \qml - FileDialog { - onAccepted: { console.log("Selected file: " + fileUrl) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FileDialog::rejected - - This handler is called when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickPlatformFileDialog - \inmodule QtQuick.Dialogs - \internal - - \brief The QQuickPlatformFileDialog class provides a file dialog - - The dialog is implemented via the QPlatformFileDialogHelper when possible; - otherwise it falls back to a QFileDialog or a QML implementation. - - \since 5.1 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickPlatformFileDialog::QQuickPlatformFileDialog(QObject *parent) : - QQuickAbstractFileDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickPlatformFileDialog::~QQuickPlatformFileDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()-> - usePlatformNativeDialog(QPlatformTheme::FileDialog) ) { - m_dlgHelper = static_cast<QPlatformFileDialogHelper *>(QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(QPlatformTheme::FileDialog)); - if (!m_dlgHelper) - return m_dlgHelper; - connect(m_dlgHelper, SIGNAL(directoryEntered(QUrl)), this, SIGNAL(folderChanged())); - connect(m_dlgHelper, SIGNAL(filterSelected(QString)), this, SIGNAL(filterSelected())); - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - } - - return m_dlgHelper; -} - -/*! - \qmlproperty bool FileDialog::visible - - This property holds whether the dialog is visible. By default this is - false. - - \sa modality -*/ - -/*! - \qmlproperty Qt::WindowModality FileDialog::modality - - Whether the dialog should be shown modal with respect to the window - containing the dialog's parent Item, modal with respect to the whole - application, or non-modal. - - By default it is \c Qt.WindowModal. - - Modality does not mean that there are any blocking calls to wait for the - dialog to be accepted or rejected; it's only that the user will be - prevented from interacting with the parent window and/or the application - windows at the same time. You probably need to write an onAccepted handler - to actually load or save the chosen file. -*/ - -/*! - \qmlmethod void FileDialog::open() - - Shows the dialog to the user. It is equivalent to setting \l visible to - true. -*/ - -/*! - \qmlmethod void FileDialog::close() - - Closes the dialog. -*/ - -/*! - \qmlproperty string FileDialog::title - - The title of the dialog window. -*/ - -/*! - \qmlproperty bool FileDialog::selectExisting - - Whether only existing files or directories can be selected. - - By default, this property is true. This property must be set to the desired - value before opening the dialog. Setting this property to false implies - that the dialog is for naming a file to which to save something, or naming - a folder to be created; therefore \l selectMultiple must be false. -*/ - -/*! - \qmlproperty bool FileDialog::selectMultiple - - Whether more than one filename can be selected. - - By default, this property is false. This property must be set to the - desired value before opening the dialog. Setting this property to true - implies that \l selectExisting must be true. -*/ - -/*! - \qmlproperty bool FileDialog::selectFolder - - Whether the selected item should be a folder. - - By default, this property is false. This property must be set to the - desired value before opening the dialog. Setting this property to true - implies that \l selectMultiple must be false and \l selectExisting must be - true. -*/ - -/*! - \qmlproperty url FileDialog::folder - - The path to the currently selected folder. Setting this property before - invoking open() will cause the file browser to be initially positioned on - the specified folder. - - The value of this property is also updated after the dialog is closed. - - By default, this property is false. -*/ - -/*! - \qmlproperty list<string> FileDialog::nameFilters - - A list of strings to be used as file name filters. Each string can be a - space-separated list of filters; filters may include the ? and * wildcards. - The list of filters can also be enclosed in parentheses and a textual - description of the filter can be provided. - - For example: - - \qml - FileDialog { - nameFilters: [ "Image files (*.jpg *.png)", "All files (*)" ] - } - \endqml - - \note Directories are not excluded by filters. - \sa selectedNameFilter -*/ - -/*! - \qmlproperty string FileDialog::selectedNameFilter - - Which of the \l nameFilters is currently selected. - - This property can be set before the dialog is visible, to set the default - name filter, and can also be set while the dialog is visible to set the - current name filter. It is also updated when the user selects a different - filter. -*/ - -/*! - \qmlproperty url FileDialog::fileUrl - - The path of the file which was selected by the user. - - \note This property is set only if exactly one file was selected. In all - other cases, it will be empty. - - \sa fileUrls -*/ - -/*! - \qmlproperty list<url> FileDialog::fileUrls - - The list of file paths which were selected by the user. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickplatformfontdialog.cpp b/src/imports/dialogs/qquickplatformfontdialog.cpp deleted file mode 100644 index 46ad5eb8df..0000000000 --- a/src/imports/dialogs/qquickplatformfontdialog.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickplatformfontdialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickView> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype FontDialog - \instantiates QQuickPlatformFontDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup qtquick-visual - \ingroup dialogs - \brief Dialog component for choosing a font. - \since 5.2 - - FontDialog allows the user to select a font. The dialog is initially - invisible. You need to set the properties as desired first, then set - \l visible to true or call \l open(). - - Here is a minimal example to open a font dialog and exit after the user - chooses a font: - - \qml - import QtQuick 2.2 - import QtQuick.Dialogs 1.1 - - FontDialog { - id: fontDialog - title: "Please choose a font" - font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal }) - onAccepted: { - console.log("You chose: " + fontDialog.font) - Qt.quit() - } - onRejected: { - console.log("Canceled") - Qt.quit() - } - Component.onCompleted: visible = true - } - \endqml - - A FontDialog window is automatically transient for its parent window. So - whether you declare the dialog inside an \l Item or inside a \l Window, the - dialog will appear centered over the window containing the item, or over - the Window that you declared. - - The implementation of FontDialog will be a platform font dialog if - possible. If that isn't possible, then it will try to instantiate a - \l QFontDialog. If that also isn't possible, then it will fall back to a QML - implementation, DefaultFontDialog.qml. In that case you can customize the - appearance by editing this file. DefaultFontDialog.qml contains a Rectangle - to hold the dialog's contents, because certain embedded systems do not - support multiple top-level windows. When the dialog becomes visible, it - will automatically be wrapped in a Window if possible, or simply reparented - on top of the main window if there can only be one window. -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FontDialog::accepted - - The \a accepted signal is emitted when the user has finished using the - dialog. You can then inspect the \a font property to get the selection. - - Example: - - \qml - FontDialog { - onAccepted: { console.log("Selected font: " + font) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FontDialog::rejected - - The \a rejected signal is emitted when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickPlatformFontDialog - \inmodule QtQuick.Dialogs - \internal - - \brief The QQuickPlatformFontDialog class provides a font dialog - - The dialog is implemented via the QQuickPlatformFontDialogHelper when possible; - otherwise it falls back to a QFontDialog or a QML implementation. - - \since 5.2 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickPlatformFontDialog::QQuickPlatformFontDialog(QObject *parent) : - QQuickAbstractFontDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickPlatformFontDialog::~QQuickPlatformFontDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()-> - usePlatformNativeDialog(QPlatformTheme::FontDialog) ) { - m_dlgHelper = static_cast<QPlatformFontDialogHelper *>(QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(QPlatformTheme::FontDialog)); - if (!m_dlgHelper) - return m_dlgHelper; - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - connect(m_dlgHelper, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(setFont(const QFont&))); - connect(m_dlgHelper, SIGNAL(fontSelected(const QFont&)), this, SLOT(setFont(const QFont&))); - } - - return m_dlgHelper; -} - -/*! - \qmlproperty bool FontDialog::visible - - This property holds whether the dialog is visible. By default this is - false. - - \sa modality -*/ - -/*! - \qmlproperty Qt::WindowModality FontDialog::modality - - Whether the dialog should be shown modal with respect to the window - containing the dialog's parent Item, modal with respect to the whole - application, or non-modal. - - By default it is \l WindowModal. - - Modality does not mean that there are any blocking calls to wait for the - dialog to be accepted or rejected; it's only that the user will be - prevented from interacting with the parent window and/or the application - windows at the same time. You probably need to write an onAccepted handler - to actually load or save the chosen file. -*/ - -/*! - \qmlmethod void FontDialog::open() - - Shows the dialog to the user. It is equivalent to setting \l visible to - true. -*/ - -/*! - \qmlmethod void FontDialog::close() - - Closes the dialog. -*/ - -/*! - \qmlproperty string FontDialog::title - - The title of the dialog window. -*/ - -/*! - \qmlproperty bool FontDialog::scalableFonts - - Whether the dialog will show scalable fonts or not. -*/ - -/*! - \qmlproperty bool FontDialog::nonScalableFonts - - Whether the dialog will show non scalable fonts or not. -*/ - -/*! - \qmlproperty bool FontDialog::monospacedFonts - - Whether the dialog will show monospaced fonts or not. -*/ - -/*! - \qmlproperty bool FontDialog::proportionalFonts - - Whether the dialog will show proportional fonts or not. -*/ - -/*! - \qmlproperty font FontDialog::font - - The font which the user selected. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickplatformfontdialog_p.h b/src/imports/dialogs/qquickplatformfontdialog_p.h deleted file mode 100644 index 743b24ad87..0000000000 --- a/src/imports/dialogs/qquickplatformfontdialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKPLATFORMFONTDIALOG_P_H -#define QQUICKPLATFORMFONTDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qquickabstractfontdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickPlatformFontDialog : public QQuickAbstractFontDialog -{ - Q_OBJECT - -public: - QQuickPlatformFontDialog(QObject *parent = 0); - virtual ~QQuickPlatformFontDialog(); - -protected: - QPlatformFontDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickPlatformFontDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformFontDialog *) - -#endif // QQUICKPLATFORMFONTDIALOG_P_H diff --git a/src/imports/dialogs/qquickplatformmessagedialog.cpp b/src/imports/dialogs/qquickplatformmessagedialog.cpp deleted file mode 100644 index 65114100d2..0000000000 --- a/src/imports/dialogs/qquickplatformmessagedialog.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickplatformmessagedialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <QWindow> -#include <QQuickView> -#include <QQuickWindow> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MessageDialog - \instantiates QQuickPlatformMessageDialog - \inqmlmodule QtQuick.Dialogs 1 - \ingroup dialogs - \brief Dialog component for displaying popup messages. - \since 5.2 - - The most basic use case for a MessageDialog is a popup alert. It also - allows the user to respond in various ways depending on which buttons are - enabled. The dialog is initially invisible. You need to set the properties - as desired first, then set \l visible to \c true or call \l open(). - - Here is a minimal example to show an alert and exit after the user - responds: - - \qml - import QtQuick 2.2 - import QtQuick.Dialogs 1.1 - - MessageDialog { - id: messageDialog - title: "May I have your attention please" - text: "It's so cool that you are using Qt Quick." - onAccepted: { - console.log("And of course you could only agree.") - Qt.quit() - } - Component.onCompleted: visible = true - } - \endqml - - There are several possible handlers depending on which \l standardButtons - the dialog has and the \l {QMessageBox::ButtonRole} {ButtonRole} of each. - For example, the \l {rejected} {onRejected} handler will be called if the - user presses a \gui Cancel, \gui Close or \gui Abort button. - - A MessageDialog window is automatically transient for its parent window. So - whether you declare the dialog inside an \l Item or inside a \l Window, the - dialog will appear centered over the window containing the item, or over - the Window that you declared. - - The implementation of MessageDialog will be a platform message dialog if - possible. If that isn't possible, then it will try to instantiate a - \l QMessageBox. If that also isn't possible, then it will fall back to a QML - implementation, \c DefaultMessageDialog.qml. In that case you can customize - the appearance by editing this file. \c DefaultMessageDialog.qml contains a - \l Rectangle to hold the dialog's contents, because certain embedded systems - do not support multiple top-level windows. When the dialog becomes visible, - it will automatically be wrapped in a \l Window if possible, or simply - reparented on top of the main window if there can only be one window. -*/ - -/*! - \qmlsignal MessageDialog::accepted() - - This handler is called when the user has pressed any button which has the - \l {QMessageBox::AcceptRole} {AcceptRole}: \gui OK, \gui Open, \gui Save, - \gui {Save All}, \gui Retry or \gui Ignore. -*/ - -/*! - \qmlsignal MessageDialog::rejected() - - This handler is called when the user has dismissed the dialog, by closing - the dialog window, by pressing a \gui Cancel, \gui Close or \gui Abort - button on the dialog, or by pressing the back button or the escape key. -*/ - -/*! - \qmlsignal MessageDialog::discard() - - This handler is called when the user has pressed the \gui Discard button. -*/ - -/*! - \qmlsignal MessageDialog::help() - - This handler is called when the user has pressed the \gui Help button. - Depending on platform, the dialog may not be automatically dismissed - because the help that your application provides may need to be relevant to - the text shown in this dialog in order to assist the user in making a - decision. However on other platforms it's not possible to show a dialog and - a help window at the same time. If you want to be sure that the dialog will - close, you can set \l visible to \c false in your handler. -*/ - -/*! - \qmlsignal MessageDialog::yes() - - This handler is called when the user has pressed any button which has - the \l {QMessageBox::YesRole} {YesRole}: \gui Yes or \gui {Yes to All}. -*/ - -/*! - \qmlsignal MessageDialog::no() - - This handler is called when the user has pressed any button which has - the \l {QMessageBox::NoRole} {NoRole}: \gui No or \gui {No to All}. -*/ - -/*! - \qmlsignal MessageDialog::apply() - - This handler is called when the user has pressed the \gui Apply button. -*/ - -/*! - \qmlsignal MessageDialog::reset() - - This handler is called when the user has pressed any button which has - the \l {QMessageBox::ResetRole} {ResetRole}: \gui Reset or \gui {Restore Defaults}. -*/ - -/*! - \class QQuickPlatformMessageDialog - \inmodule QtQuick.Dialogs - \internal - - \brief The QQuickPlatformMessageDialog class provides a message dialog - - The dialog is implemented via the QPlatformMessageDialogHelper when possible; - otherwise it falls back to a QMessageBox or a QML implementation. - - \since 5.2 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickPlatformMessageDialog::QQuickPlatformMessageDialog(QObject *parent) : - QQuickAbstractMessageDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickPlatformMessageDialog::~QQuickPlatformMessageDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformMessageDialogHelper *QQuickPlatformMessageDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()-> - usePlatformNativeDialog(QPlatformTheme::MessageDialog) ) { - m_dlgHelper = static_cast<QPlatformMessageDialogHelper *>(QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(QPlatformTheme::MessageDialog)); - if (!m_dlgHelper) - return m_dlgHelper; - // accept() shouldn't be emitted. reject() happens only if the dialog is - // dismissed by closing the window rather than by one of its button widgets. - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - connect(m_dlgHelper, SIGNAL(clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)), - this, SLOT(click(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole))); - } - - return m_dlgHelper; -} - -/*! - \qmlproperty bool MessageDialog::visible - - This property holds whether the dialog is visible. By default this is - \c false. - - \sa modality -*/ - -/*! - \qmlproperty Qt::WindowModality MessageDialog::modality - - Whether the dialog should be shown modal with respect to the window - containing the dialog's parent Item, modal with respect to the whole - application, or non-modal. - - By default it is \c Qt.WindowModal. - - Modality does not mean that there are any blocking calls to wait for the - dialog to be accepted or rejected; it's only that the user will be - prevented from interacting with the parent window and/or the application - windows until the dialog is dismissed. -*/ - -/*! - \qmlmethod void MessageDialog::open() - - Shows the dialog to the user. It is equivalent to setting \l visible to - \c true. -*/ - -/*! - \qmlmethod void MessageDialog::close() - - Closes the dialog. -*/ - -/*! - \qmlproperty string MessageDialog::title - - The title of the dialog window. -*/ - -/*! - \qmlproperty string MessageDialog::text - - The primary text to be displayed. -*/ - -/*! - \qmlproperty string MessageDialog::informativeText - - The informative text that provides a fuller description for the message. - - Informative text can be used to supplement the \c text to give more - information to the user. Depending on the platform, it may appear in a - smaller font below the text, or simply appended to the text. - - \sa {MessageDialog::text}{text} -*/ - -/*! - \qmlproperty string MessageDialog::detailedText - - The text to be displayed in the details area, which is hidden by default. - The user will then be able to press the \gui {Show Details...} button to - make it visible. - - \sa {MessageDialog::text}{text} -*/ - -/*! - \enum QQuickStandardIcon::Icon - - This enum specifies a standard icon to be used on a dialog. -*/ - -/*! - \qmlproperty QQuickStandardIcon::Icon MessageDialog::icon - - The icon of the message box can be specified with one of these values: - - \table - \row - \li no icon - \li \l StandardIcon.NoIcon - \li For an unadorned text alert. - \row - \li \inlineimage ../images/question.png "Question icon" - \li \l StandardIcon.Question - \li For asking a question during normal operations. - \row - \li \image information.png - \li \l StandardIcon.Information - \li For reporting information about normal operations. - \row - \li \image warning.png - \li \l StandardIcon.Warning - \li For reporting non-critical errors. - \row - \li \image critical.png - \li \l StandardIcon.Critical - \li For reporting critical errors. - \endtable - - The default is \c StandardIcon.NoIcon. - - The enum values are the same as in \l QMessageBox::Icon. -*/ - -// TODO after QTBUG-35019 is fixed: fix links to this module's enums -// rather than linking to those in QMessageBox -/*! - \enum QQuickStandardButton::StandardButton - - This enum specifies a button with a standard label to be used on a dialog. -*/ - -/*! - \qmlproperty StandardButtons MessageDialog::standardButtons - - The MessageDialog has a row of buttons along the bottom, each of which has - a \l {QMessageBox::ButtonRole} {ButtonRole} that determines which signal - will be emitted when the button is pressed. You can also find out which - specific button was pressed after the fact via the \l clickedButton - property. You can control which buttons are available by setting - standardButtons to a bitwise-or combination of the following flags: - - \table - \row \li StandardButton.Ok \li An \gui OK button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \row \li StandardButton.Open \li An \gui Open button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \row \li StandardButton.Save \li A \gui Save button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \row \li StandardButton.Cancel \li A \gui Cancel button defined with the \l {QMessageBox::RejectRole} {RejectRole}. - \row \li StandardButton.Close \li A \gui Close button defined with the \l {QMessageBox::RejectRole} {RejectRole}. - \row \li StandardButton.Discard \li A \gui Discard or \gui {Don't Save} button, depending on the platform, - defined with the \l {QMessageBox::DestructiveRole} {DestructiveRole}. - \row \li StandardButton.Apply \li An \gui Apply button defined with the \l {QMessageBox::ApplyRole} {ApplyRole}. - \row \li StandardButton.Reset \li A \gui Reset button defined with the \l {QMessageBox::ResetRole} {ResetRole}. - \row \li StandardButton.RestoreDefaults \li A \gui {Restore Defaults} button defined with the \l {QMessageBox::ResetRole} {ResetRole}. - \row \li StandardButton.Help \li A \gui Help button defined with the \l {QMessageBox::HelpRole} {HelpRole}. - \row \li StandardButton.SaveAll \li A \gui {Save All} button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \row \li StandardButton.Yes \li A \gui Yes button defined with the \l {QMessageBox::YesRole} {YesRole}. - \row \li StandardButton.YesToAll \li A \gui {Yes to All} button defined with the \l {QMessageBox::YesRole} {YesRole}. - \row \li StandardButton.No \li A \gui No button defined with the \l {QMessageBox::NoRole} {NoRole}. - \row \li StandardButton.NoToAll \li A \gui {No to All} button defined with the \l {QMessageBox::NoRole} {NoRole}. - \row \li StandardButton.Abort \li An \gui Abort button defined with the \l {QMessageBox::RejectRole} {RejectRole}. - \row \li StandardButton.Retry \li A \gui Retry button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \row \li StandardButton.Ignore \li An \gui Ignore button defined with the \l {QMessageBox::AcceptRole} {AcceptRole}. - \endtable - - For example the following dialog will ask a question with 5 possible answers: - - \qml - import QtQuick 2.2 - import QtQuick.Dialogs 1.1 - - MessageDialog { - title: "Overwrite?" - icon: StandardIcon.Question - text: "file.txt already exists. Replace?" - detailedText: "To replace a file means that its existing contents will be lost. " + - "The file that you are copying now will be copied over it instead." - standardButtons: StandardButton.Yes | StandardButton.YesToAll | - StandardButton.No | StandardButton.NoToAll | StandardButton.Abort - Component.onCompleted: visible = true - onYes: console.log("copied") - onNo: console.log("didn't copy") - onRejected: console.log("aborted") - } - \endqml - - \image replacefile.png - - The default is \c StandardButton.Ok. - - The enum values are the same as in \l QMessageBox::StandardButtons. -*/ - -QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickplatformmessagedialog_p.h b/src/imports/dialogs/qquickplatformmessagedialog_p.h deleted file mode 100644 index 61f055bb38..0000000000 --- a/src/imports/dialogs/qquickplatformmessagedialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKPLATFORMMESSAGEDIALOG_P_H -#define QQUICKPLATFORMMESSAGEDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qquickabstractmessagedialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickPlatformMessageDialog : public QQuickAbstractMessageDialog -{ - Q_OBJECT - -public: - QQuickPlatformMessageDialog(QObject *parent = 0); - virtual ~QQuickPlatformMessageDialog(); - -protected: - QPlatformMessageDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickPlatformMessageDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformMessageDialog *) - -#endif // QQUICKPLATFORMMESSAGEDIALOG_P_H diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 3f15755211..f1d262a6c3 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -11,11 +11,7 @@ qtHaveModule(quick) { qtquick2 \ particles \ window \ - dialogs-private \ - dialogs \ testlib } qtHaveModule(xmlpatterns) : SUBDIRS += xmllistmodel - -qtHaveModule(quick):qtHaveModule(widgets): SUBDIRS += widgets diff --git a/src/imports/widgets/plugins.qmltypes b/src/imports/widgets/plugins.qmltypes deleted file mode 100644 index a67443c5b7..0000000000 --- a/src/imports/widgets/plugins.qmltypes +++ /dev/null @@ -1,302 +0,0 @@ -import QtQuick.tooling 1.1 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtQuick.PrivateWidgets 1.1' - -Module { - Component { - name: "QQuickAbstractColorDialog" - prototype: "QQuickAbstractDialog" - Property { name: "showAlphaChannel"; type: "bool" } - Property { name: "color"; type: "QColor" } - Property { name: "currentColor"; type: "QColor" } - Property { name: "currentHue"; type: "double"; isReadonly: true } - Property { name: "currentSaturation"; type: "double"; isReadonly: true } - Property { name: "currentLightness"; type: "double"; isReadonly: true } - Property { name: "currentAlpha"; type: "double"; isReadonly: true } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setColor" - Parameter { name: "arg"; type: "QColor" } - } - Method { - name: "setCurrentColor" - Parameter { name: "currentColor"; type: "QColor" } - } - Method { - name: "setShowAlphaChannel" - Parameter { name: "arg"; type: "bool" } - } - } - Component { - name: "QQuickAbstractDialog" - prototype: "QObject" - Property { name: "visible"; type: "bool" } - Property { name: "modality"; type: "Qt::WindowModality" } - Property { name: "title"; type: "string" } - Property { name: "isWindow"; type: "bool"; isReadonly: true } - Property { name: "x"; type: "int" } - Property { name: "y"; type: "int" } - Property { name: "width"; type: "int" } - Property { name: "height"; type: "int" } - Signal { name: "visibilityChanged" } - Signal { name: "geometryChanged" } - Signal { name: "accepted" } - Signal { name: "rejected" } - Method { name: "open" } - Method { name: "close" } - Method { - name: "setX" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setY" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setWidth" - Parameter { name: "arg"; type: "int" } - } - Method { - name: "setHeight" - Parameter { name: "arg"; type: "int" } - } - } - Component { - name: "QQuickAbstractFileDialog" - prototype: "QQuickAbstractDialog" - Property { name: "selectExisting"; type: "bool" } - Property { name: "selectMultiple"; type: "bool" } - Property { name: "selectFolder"; type: "bool" } - Property { name: "folder"; type: "QUrl" } - Property { name: "nameFilters"; type: "QStringList" } - Property { name: "selectedNameFilter"; type: "string" } - Property { name: "fileUrl"; type: "QUrl"; isReadonly: true } - Property { name: "fileUrls"; type: "QList<QUrl>"; isReadonly: true } - Signal { name: "filterSelected" } - Signal { name: "fileModeChanged" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setSelectExisting" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectMultiple" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setSelectFolder" - Parameter { name: "s"; type: "bool" } - } - Method { - name: "setFolder" - Parameter { name: "f"; type: "QUrl" } - } - Method { - name: "setNameFilters" - Parameter { name: "f"; type: "QStringList" } - } - Method { - name: "selectNameFilter" - Parameter { name: "f"; type: "string" } - } - } - Component { - name: "QQuickAbstractFontDialog" - prototype: "QQuickAbstractDialog" - Property { name: "scalableFonts"; type: "bool" } - Property { name: "nonScalableFonts"; type: "bool" } - Property { name: "monospacedFonts"; type: "bool" } - Property { name: "proportionalFonts"; type: "bool" } - Property { name: "font"; type: "QFont" } - Signal { name: "selectionAccepted" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setModality" - Parameter { name: "m"; type: "Qt::WindowModality" } - } - Method { - name: "setTitle" - Parameter { name: "t"; type: "string" } - } - Method { - name: "setFont" - Parameter { name: "arg"; type: "QFont" } - } - Method { - name: "setScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setNonScalableFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setMonospacedFonts" - Parameter { name: "arg"; type: "bool" } - } - Method { - name: "setProportionalFonts" - Parameter { name: "arg"; type: "bool" } - } - } - Component { - name: "QQuickAbstractMessageDialog" - prototype: "QQuickAbstractDialog" - exports: ["QtQuick.PrivateWidgets/QtMessageDialog 1.1"] - exportMetaObjectRevisions: [0] - Enum { - name: "Icon" - values: { - "NoIcon": 0, - "Information": 1, - "Warning": 2, - "Critical": 3, - "Question": 4 - } - } - Enum { - name: "StandardButton" - values: { - "NoButton": 0, - "Ok": 1024, - "Save": 2048, - "SaveAll": 4096, - "Open": 8192, - "Yes": 16384, - "YesToAll": 32768, - "No": 65536, - "NoToAll": 131072, - "Abort": 262144, - "Retry": 524288, - "Ignore": 1048576, - "Close": 2097152, - "Cancel": 4194304, - "Discard": 8388608, - "Help": 16777216, - "Apply": 33554432, - "Reset": 67108864, - "RestoreDefaults": 134217728 - } - } - Enum { - name: "StandardButtons" - values: { - "NoButton": 0, - "Ok": 1024, - "Save": 2048, - "SaveAll": 4096, - "Open": 8192, - "Yes": 16384, - "YesToAll": 32768, - "No": 65536, - "NoToAll": 131072, - "Abort": 262144, - "Retry": 524288, - "Ignore": 1048576, - "Close": 2097152, - "Cancel": 4194304, - "Discard": 8388608, - "Help": 16777216, - "Apply": 33554432, - "Reset": 67108864, - "RestoreDefaults": 134217728 - } - } - Property { name: "text"; type: "string" } - Property { name: "informativeText"; type: "string" } - Property { name: "detailedText"; type: "string" } - Property { name: "icon"; type: "Icon" } - Property { name: "standardIconSource"; type: "QUrl"; isReadonly: true } - Property { name: "standardButtons"; type: "StandardButtons" } - Property { name: "clickedButton"; type: "StandardButton"; isReadonly: true } - Signal { name: "buttonClicked" } - Signal { name: "discard" } - Signal { name: "help" } - Signal { name: "yes" } - Signal { name: "no" } - Signal { name: "apply" } - Signal { name: "reset" } - Method { - name: "setVisible" - Parameter { name: "v"; type: "bool" } - } - Method { - name: "setTitle" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setInformativeText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setDetailedText" - Parameter { name: "arg"; type: "string" } - } - Method { - name: "setIcon" - Parameter { name: "icon"; type: "Icon" } - } - Method { - name: "setStandardButtons" - Parameter { name: "buttons"; type: "StandardButtons" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QMessageDialogOptions::StandardButton" } - Parameter { type: "QMessageDialogOptions::ButtonRole" } - } - Method { - name: "click" - Parameter { name: "button"; type: "QQuickAbstractMessageDialog::StandardButton" } - } - } - Component { - name: "QQuickQColorDialog" - prototype: "QQuickAbstractColorDialog" - exports: ["QtQuick.PrivateWidgets/QtColorDialog 1.0"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QQuickQFileDialog" - prototype: "QQuickAbstractFileDialog" - exports: ["QtQuick.PrivateWidgets/QtFileDialog 1.0"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QQuickQFontDialog" - prototype: "QQuickAbstractFontDialog" - exports: ["QtQuick.PrivateWidgets/QtFontDialog 1.1"] - exportMetaObjectRevisions: [0] - } -} diff --git a/src/imports/widgets/qmessageboxhelper_p.h b/src/imports/widgets/qmessageboxhelper_p.h deleted file mode 100644 index 4f1070f97d..0000000000 --- a/src/imports/widgets/qmessageboxhelper_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 QMESSAGEBOXHELPER_P_H -#define QMESSAGEBOXHELPER_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 <QMessageBox> -#include "../dialogs/qquickabstractmessagedialog_p.h" - -QT_BEGIN_NAMESPACE - -class QMessageBoxHelper : public QPlatformMessageDialogHelper -{ - Q_OBJECT -public: - QMessageBoxHelper() { - connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept())); - connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject())); - connect(&m_dialog, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); - } - - virtual void exec() { m_dialog.exec(); } - - virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) { - m_dialog.winId(); - QWindow *window = m_dialog.windowHandle(); - Q_ASSERT(window); - window->setTransientParent(parent); - window->setFlags(f); - m_dialog.setWindowModality(m); - m_dialog.setWindowTitle(QPlatformMessageDialogHelper::options()->windowTitle()); - m_dialog.setIcon(static_cast<QMessageBox::Icon>(QPlatformMessageDialogHelper::options()->icon())); - if (!QPlatformMessageDialogHelper::options()->text().isNull()) - m_dialog.setText(QPlatformMessageDialogHelper::options()->text()); - if (!QPlatformMessageDialogHelper::options()->informativeText().isNull()) - m_dialog.setInformativeText(QPlatformMessageDialogHelper::options()->informativeText()); - if (!QPlatformMessageDialogHelper::options()->detailedText().isNull()) - m_dialog.setDetailedText(QPlatformMessageDialogHelper::options()->detailedText()); - m_dialog.setStandardButtons(static_cast<QMessageBox::StandardButtons>(static_cast<int>( - QPlatformMessageDialogHelper::options()->standardButtons()))); - m_dialog.show(); - return m_dialog.isVisible(); - } - - virtual void hide() { m_dialog.hide(); } - - QMessageBox m_dialog; - -public Q_SLOTS: - void buttonClicked(QAbstractButton* button) { - emit clicked(static_cast<QMessageDialogOptions::StandardButton>(m_dialog.standardButton(button)), - static_cast<QMessageDialogOptions::ButtonRole>(m_dialog.buttonRole(button))); - } -}; - -QT_END_NAMESPACE - -#endif // QMESSAGEBOXHELPER_P_H diff --git a/src/imports/widgets/qmldir b/src/imports/widgets/qmldir deleted file mode 100644 index da63c98e61..0000000000 --- a/src/imports/widgets/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtQuick.PrivateWidgets -plugin widgetsplugin -classname QtQuick2PrivateWidgetsPlugin -typeinfo plugins.qmltypes diff --git a/src/imports/widgets/qquickqcolordialog.cpp b/src/imports/widgets/qquickqcolordialog.cpp deleted file mode 100644 index ee27d147e7..0000000000 --- a/src/imports/widgets/qquickqcolordialog.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 "qquickqcolordialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <private/qqmlcontext_p.h> -#include <QWindow> -#include <QQuickWindow> -#include <QColorDialog> - -QT_BEGIN_NAMESPACE - -class QColorDialogHelper : public QPlatformColorDialogHelper -{ -public: - QColorDialogHelper() : - QPlatformColorDialogHelper() - { - connect(&m_dialog, SIGNAL(currentColorChanged(const QColor&)), this, SIGNAL(currentColorChanged(const QColor&))); - connect(&m_dialog, SIGNAL(colorSelected(const QColor&)), this, SIGNAL(colorSelected(const QColor&))); - connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept())); - connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject())); - } - - virtual void setCurrentColor(const QColor &c) { m_dialog.setCurrentColor(c); } - virtual QColor currentColor() const { return m_dialog.currentColor(); } - - virtual void exec() { m_dialog.exec(); } - - virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) { - m_dialog.winId(); - QWindow *window = m_dialog.windowHandle(); - Q_ASSERT(window); - window->setTransientParent(parent); - window->setFlags(f); - m_dialog.setWindowModality(m); - m_dialog.setWindowTitle(QPlatformColorDialogHelper::options()->windowTitle()); - m_dialog.setOptions((QColorDialog::ColorDialogOptions)((int)(QPlatformColorDialogHelper::options()->options()))); - m_dialog.show(); - return m_dialog.isVisible(); - } - - virtual void hide() { m_dialog.hide(); } - -private: - QColorDialog m_dialog; -}; - -/*! - \qmltype QtColorDialog - \instantiates QQuickQColorDialog - \inqmlmodule QtQuick.PrivateWidgets 1 - \ingroup qtquick-visual - \brief Dialog component for choosing a color. - \since 5.1 - \internal - - QtColorDialog provides a means to instantiate and manage a QColorDialog. - It is not recommended to be used directly; it is an implementation - detail of \l ColorDialog in the \l QtQuick.Dialogs module. - - To use this type, you will need to import the module with the following line: - \code - import QtQuick.PrivateWidgets 1.0 - \endcode -*/ - -/*! - \qmlsignal QtQuick::Dialogs::ColorDialog::accepted - - The \a accepted signal is emitted when the user has finished using the - dialog. You can then inspect the \a color property to get the selection. - - Example: - - \qml - ColorDialog { - onAccepted: { console.log("Selected color: " + color) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::ColorDialog::rejected - - The \a rejected signal is emitted when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickQColorDialog - \inmodule QtQuick.PrivateWidgets - \internal - - \brief The QQuickQColorDialog class is a wrapper for a QColorDialog. - - \since 5.1 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickQColorDialog::QQuickQColorDialog(QObject *parent) - : QQuickAbstractColorDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickQColorDialog::~QQuickQColorDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformColorDialogHelper *QQuickQColorDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if (!m_dlgHelper) { - m_dlgHelper = new QColorDialogHelper(); - connect(m_dlgHelper, SIGNAL(currentColorChanged(const QColor&)), this, SLOT(setCurrentColor(QColor))); - connect(m_dlgHelper, SIGNAL(colorSelected(const QColor&)), this, SLOT(setColor(QColor))); - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - } - - return m_dlgHelper; -} - -QT_END_NAMESPACE diff --git a/src/imports/widgets/qquickqcolordialog_p.h b/src/imports/widgets/qquickqcolordialog_p.h deleted file mode 100644 index 3fb0476299..0000000000 --- a/src/imports/widgets/qquickqcolordialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 QQUICKQCOLORDIALOG_P_H -#define QQUICKQCOLORDIALOG_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 "../dialogs/qquickabstractcolordialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickQColorDialog : public QQuickAbstractColorDialog -{ - Q_OBJECT - -public: - QQuickQColorDialog(QObject *parent = 0); - virtual ~QQuickQColorDialog(); - -protected: - QPlatformColorDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickQColorDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickQColorDialog *) - -#endif // QQUICKQCOLORDIALOG_P_H diff --git a/src/imports/widgets/qquickqfiledialog.cpp b/src/imports/widgets/qquickqfiledialog.cpp deleted file mode 100644 index c3991b4f3c..0000000000 --- a/src/imports/widgets/qquickqfiledialog.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 "qquickqfiledialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <private/qqmlcontext_p.h> -#include <QWindow> -#include <QQuickWindow> -#include <QFileDialog> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype QtFileDialog - \instantiates QQuickQFileDialog - \inqmlmodule QtQuick.PrivateWidgets 1 - \ingroup qtquick-visual - \brief Dialog component for choosing files from a local filesystem. - \since 5.1 - \internal - - QtFileDialog provides a means to instantiate and manage a QFileDialog. - It is not recommended to be used directly; it is an implementation - detail of \l FileDialog in the \l QtQuick.Dialogs module. - - To use this type, you will need to import the module with the following line: - \code - import QtQuick.PrivateWidgets 1.0 - \endcode -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FileDialog::accepted - - The \a accepted signal is emitted when the user has finished using the - dialog. You can then inspect the \a fileUrl or \a fileUrls properties to - get the selection. - - Example: - - \qml - FileDialog { - onAccepted: { console.log("Selected file: " + fileUrl) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FileDialog::rejected - - The \a rejected signal is emitted when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickQFileDialog - \inmodule QtQuick.PrivateWidgets - \internal - - \brief The QQuickQFileDialog class is a wrapper for a QFileDialog. - - \since 5.1 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickQFileDialog::QQuickQFileDialog(QObject *parent) - : QQuickAbstractFileDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickQFileDialog::~QQuickQFileDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformFileDialogHelper *QQuickQFileDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if (!m_dlgHelper) { - m_dlgHelper = new QFileDialogHelper(); - connect(m_dlgHelper, SIGNAL(directoryEntered(const QUrl &)), this, SIGNAL(folderChanged())); - connect(m_dlgHelper, SIGNAL(filterSelected(const QString &)), this, SIGNAL(filterSelected())); - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - } - - return m_dlgHelper; -} - -QFileDialogHelper::QFileDialogHelper() : - QPlatformFileDialogHelper() -{ - connect(&m_dialog, SIGNAL(currentChanged(const QString&)), this, SLOT(currentChanged(const QString&))); - connect(&m_dialog, SIGNAL(directoryEntered(const QString&)), this, SLOT(directoryEntered(const QString&))); - connect(&m_dialog, SIGNAL(fileSelected(const QString&)), this, SLOT(fileSelected(const QString&))); - connect(&m_dialog, SIGNAL(filesSelected(const QStringList&)), this, SLOT(filesSelected(const QStringList&))); - connect(&m_dialog, SIGNAL(filterSelected(const QString&)), this, SIGNAL(filterSelected(const QString&))); - connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept())); - connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject())); -} - -QList<QUrl> QFileDialogHelper::selectedFiles() const -{ - return m_dialog.selectedUrls(); -} - -void QFileDialogHelper::setFilter() { - m_dialog.setWindowTitle(QPlatformFileDialogHelper::options()->windowTitle()); - if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::LookIn)) - m_dialog.setLabelText(m_dialog.LookIn, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::LookIn)); - if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::FileName)) - m_dialog.setLabelText(m_dialog.FileName, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::FileName)); - if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::FileType)) - m_dialog.setLabelText(m_dialog.FileType, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::FileType)); - if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::Accept)) - m_dialog.setLabelText(m_dialog.Accept, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::Accept)); - if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::Reject)) - m_dialog.setLabelText(m_dialog.Reject, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::Reject)); - m_dialog.setFilter(QPlatformFileDialogHelper::options()->filter()); - m_dialog.setNameFilters(QPlatformFileDialogHelper::options()->nameFilters()); - m_dialog.selectNameFilter(QPlatformFileDialogHelper::options()->initiallySelectedNameFilter()); - m_dialog.setFileMode(QFileDialog::FileMode(QPlatformFileDialogHelper::options()->fileMode())); - m_dialog.setOptions((QFileDialog::Options)((int)(QPlatformFileDialogHelper::options()->options()))); - m_dialog.setAcceptMode(QFileDialog::AcceptMode(QPlatformFileDialogHelper::options()->acceptMode())); -} - -bool QFileDialogHelper::show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) { - m_dialog.winId(); - QWindow *window = m_dialog.windowHandle(); - Q_ASSERT(window); - window->setTransientParent(parent); - window->setFlags(f); - m_dialog.setWindowModality(m); - m_dialog.show(); - return m_dialog.isVisible(); -} - -void QFileDialogHelper::currentChanged(const QString& path) -{ - emit QPlatformFileDialogHelper::currentChanged(QUrl::fromLocalFile(path)); -} - -void QFileDialogHelper::directoryEntered(const QString& path) -{ - emit QPlatformFileDialogHelper::directoryEntered(QUrl::fromLocalFile(path)); -} - -void QFileDialogHelper::fileSelected(const QString& path) -{ - emit QPlatformFileDialogHelper::fileSelected(QUrl::fromLocalFile(path)); -} - -void QFileDialogHelper::filesSelected(const QStringList& paths) -{ - QList<QUrl> pathUrls; - foreach (const QString &path, paths) - pathUrls << QUrl::fromLocalFile(path); - emit QPlatformFileDialogHelper::filesSelected(pathUrls); -} - -QT_END_NAMESPACE diff --git a/src/imports/widgets/qquickqfiledialog_p.h b/src/imports/widgets/qquickqfiledialog_p.h deleted file mode 100644 index 2bd364eba0..0000000000 --- a/src/imports/widgets/qquickqfiledialog_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 QQUICKQFILEDIALOG_P_H -#define QQUICKQFILEDIALOG_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 <QFileDialog> -#include "../dialogs/qquickabstractfiledialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickQFileDialog : public QQuickAbstractFileDialog -{ - Q_OBJECT - -public: - QQuickQFileDialog(QObject *parent = 0); - virtual ~QQuickQFileDialog(); - -protected: - QPlatformFileDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickQFileDialog) -}; - -class QFileDialogHelper : public QPlatformFileDialogHelper -{ - Q_OBJECT -public: - QFileDialogHelper(); - - bool defaultNameFilterDisables() const Q_DECL_OVERRIDE { return true; } - void setDirectory(const QUrl &dir) Q_DECL_OVERRIDE { m_dialog.setDirectoryUrl(dir); } - QUrl directory() const Q_DECL_OVERRIDE { return m_dialog.directoryUrl(); } - void selectFile(const QUrl &f) Q_DECL_OVERRIDE { m_dialog.selectUrl(f); } - QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE; - void setFilter() Q_DECL_OVERRIDE; - void selectNameFilter(const QString &f) Q_DECL_OVERRIDE { m_dialog.selectNameFilter(f); } - QString selectedNameFilter() const Q_DECL_OVERRIDE { return m_dialog.selectedNameFilter(); } - void exec() Q_DECL_OVERRIDE { m_dialog.exec(); } - bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) Q_DECL_OVERRIDE; - void hide() Q_DECL_OVERRIDE { m_dialog.hide(); } - -private Q_SLOTS: - void currentChanged(const QString& path); - void directoryEntered(const QString& path); - void fileSelected(const QString& path); - void filesSelected(const QStringList& paths); - -private: - QFileDialog m_dialog; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickQFileDialog *) - -#endif // QQUICKQFILEDIALOG_P_H diff --git a/src/imports/widgets/qquickqfontdialog.cpp b/src/imports/widgets/qquickqfontdialog.cpp deleted file mode 100644 index 6d637e1ddb..0000000000 --- a/src/imports/widgets/qquickqfontdialog.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickqfontdialog_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <private/qqmlcontext_p.h> -#include <QWindow> -#include <QQuickWindow> -#include <QFontDialog> - -QT_BEGIN_NAMESPACE - -class QFontDialogHelper : public QPlatformFontDialogHelper -{ -public: - QFontDialogHelper() : - QPlatformFontDialogHelper() - { - connect(&m_dialog, SIGNAL(currentFontChanged(const QFont &)), this, SIGNAL(currentFontChanged(const QFont &))); - connect(&m_dialog, SIGNAL(fontSelected(const QFont &)), this, SIGNAL(fontSelected(const QFont &))); - connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept())); - connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject())); - } - - virtual void setCurrentFont(const QFont &font) { m_dialog.setCurrentFont(font); } - virtual QFont currentFont() const { return m_dialog.currentFont(); } - - virtual void exec() { m_dialog.exec(); } - - virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) { - m_dialog.winId(); - QWindow *window = m_dialog.windowHandle(); - Q_ASSERT(window); - window->setTransientParent(parent); - window->setFlags(f); - m_dialog.windowHandle()->setTransientParent(parent); - m_dialog.windowHandle()->setFlags(f); - m_dialog.setWindowModality(m); - m_dialog.setWindowTitle(QPlatformFontDialogHelper::options()->windowTitle()); - m_dialog.setOptions((QFontDialog::FontDialogOptions)((int)(QPlatformFontDialogHelper::options()->options()))); - m_dialog.show(); - return m_dialog.isVisible(); - } - - virtual void hide() { m_dialog.hide(); } - -private: - QFontDialog m_dialog; -}; - -/*! - \qmltype QtFontDialog - \instantiates QQuickQFontDialog - \inqmlmodule QtQuick.PrivateWidgets 1 - \ingroup qtquick-visual - \brief Dialog component for choosing files from a local filesystem. - \since 5.2 - \internal - - QtFontDialog provides a means to instantiate and manage a QFontDialog. - It is not recommended to be used directly; it is an implementation - detail of \l FontDialog in the \l QtQuick.Dialogs module. - - To use this type, you will need to import the module with the following line: - \code - import QtQuick.PrivateWidgets 1.1 - \endcode -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FontDialog::accepted - - The \a accepted signal is emitted when the user has finished using the - dialog. You can then inspect the \a filePath or \a filePaths properties to - get the selection. - - Example: - - \qml - FontDialog { - onAccepted: { console.log("Selected file: " + filePath) } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::FontDialog::rejected - - The \a rejected signal is emitted when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickQFontDialog - \inmodule QtQuick.PrivateWidgets - \internal - - \brief The QQuickQFontDialog class is a wrapper for a QFontDialog. - - \since 5.2 -*/ - -/*! - Constructs a file dialog with parent window \a parent. -*/ -QQuickQFontDialog::QQuickQFontDialog(QObject *parent) - : QQuickAbstractFontDialog(parent) -{ -} - -/*! - Destroys the file dialog. -*/ -QQuickQFontDialog::~QQuickQFontDialog() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformFontDialogHelper *QQuickQFontDialog::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if (!m_dlgHelper) { - m_dlgHelper = new QFontDialogHelper(); - connect(m_dlgHelper, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(setFont(const QFont &))); - connect(m_dlgHelper, SIGNAL(fontSelected(const QFont &)), this, SLOT(setFont(const QFont &))); - connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); - connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - } - - return m_dlgHelper; -} - -QT_END_NAMESPACE diff --git a/src/imports/widgets/qquickqfontdialog_p.h b/src/imports/widgets/qquickqfontdialog_p.h deleted file mode 100644 index 6efd15995b..0000000000 --- a/src/imports/widgets/qquickqfontdialog_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKQFONTDIALOG_P_H -#define QQUICKQFONTDIALOG_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 "../dialogs/qquickabstractfontdialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickQFontDialog : public QQuickAbstractFontDialog -{ - Q_OBJECT - -public: - QQuickQFontDialog(QObject *parent = 0); - virtual ~QQuickQFontDialog(); - -protected: - QPlatformFontDialogHelper *helper(); - - Q_DISABLE_COPY(QQuickQFontDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickQFontDialog *) - -#endif // QQUICKQFONTDIALOG_P_H diff --git a/src/imports/widgets/qquickqmessagebox.cpp b/src/imports/widgets/qquickqmessagebox.cpp deleted file mode 100644 index 1b92efc5ef..0000000000 --- a/src/imports/widgets/qquickqmessagebox.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 "qquickqmessagebox_p.h" -#include "qmessageboxhelper_p.h" -#include "qquickitem.h" - -#include <private/qguiapplication_p.h> -#include <private/qqmlcontext_p.h> -#include <QWindow> -#include <QQuickWindow> -#include <QMessageBox> -#include <QAbstractButton> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype QtMessageDialog - \instantiates QQuickQMessageBox - \inqmlmodule QtQuick.PrivateWidgets 1 - \ingroup qtquick-visual - \brief Dialog component for choosing a color. - \since 5.2 - \internal - - QtMessageDialog provides a means to instantiate and manage a QMessageBox. - It is not recommended to be used directly; it is an implementation - detail of \l MessageDialog in the \l QtQuick.Dialogs module. - - To use this type, you will need to import the module with the following line: - \code - import QtQuick.PrivateWidgets 1.1 - \endcode -*/ - -/*! - \qmlsignal QtQuick::Dialogs::MessageDialog::accepted - - The \a accepted signal is emitted when the user has pressed the OK button - on the dialog. - - Example: - - \qml - MessageDialog { - onAccepted: { console.log("accepted") } - } - \endqml -*/ - -/*! - \qmlsignal QtQuick::Dialogs::MessageDialog::rejected - - The \a rejected signal is emitted when the user has dismissed the dialog, - either by closing the dialog window or by pressing the Cancel button. -*/ - -/*! - \class QQuickQMessageBox - \inmodule QtQuick.PrivateWidgets - \internal - - \brief The QQuickQMessageBox class is a wrapper for a QMessageBox. - - \since 5.2 -*/ - -/*! - Constructs a message dialog with parent window \a parent. -*/ -QQuickQMessageBox::QQuickQMessageBox(QObject *parent) - : QQuickAbstractMessageDialog(parent) -{ -} - -/*! - Destroys the message dialog. -*/ -QQuickQMessageBox::~QQuickQMessageBox() -{ - if (m_dlgHelper) - m_dlgHelper->hide(); - delete m_dlgHelper; -} - -QPlatformDialogHelper *QQuickQMessageBox::helper() -{ - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); - - if (!QQuickAbstractMessageDialog::m_dlgHelper) { - QMessageBoxHelper* helper = new QMessageBoxHelper(); - QQuickAbstractMessageDialog::m_dlgHelper = helper; - // accept() shouldn't be emitted. reject() happens only if the dialog is - // dismissed by closing the window rather than by one of its button widgets. - connect(helper, SIGNAL(accept()), this, SLOT(accept())); - connect(helper, SIGNAL(reject()), this, SLOT(reject())); - connect(helper, SIGNAL(clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)), - this, SLOT(click(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole))); - } - - return QQuickAbstractMessageDialog::m_dlgHelper; -} - -QT_END_NAMESPACE diff --git a/src/imports/widgets/qquickqmessagebox_p.h b/src/imports/widgets/qquickqmessagebox_p.h deleted file mode 100644 index be91f1d02b..0000000000 --- a/src/imports/widgets/qquickqmessagebox_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 QQUICKQMESSAGEBOX_P_H -#define QQUICKQMESSAGEBOX_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 "../dialogs/qquickabstractmessagedialog_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickQMessageBox : public QQuickAbstractMessageDialog -{ -public: - QQuickQMessageBox(QObject *parent = 0); - virtual ~QQuickQMessageBox(); - -protected: - virtual QPlatformDialogHelper *helper(); - -protected: - Q_DISABLE_COPY(QQuickQMessageBox) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickQMessageBox *) - -#endif // QQUICKQMESSAGEBOX_P_H diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro deleted file mode 100644 index 5320838082..0000000000 --- a/src/imports/widgets/widgets.pro +++ /dev/null @@ -1,32 +0,0 @@ -CXX_MODULE = qml -TARGET = widgetsplugin -TARGETPATH = QtQuick/PrivateWidgets -IMPORT_VERSION = 1.1 - -SOURCES += \ - qquickqmessagebox.cpp \ - ../dialogs/qquickabstractmessagedialog.cpp \ - qquickqfiledialog.cpp \ - ../dialogs/qquickabstractfiledialog.cpp \ - qquickqcolordialog.cpp \ - ../dialogs/qquickabstractcolordialog.cpp \ - qquickqfontdialog.cpp \ - ../dialogs/qquickabstractfontdialog.cpp \ - ../dialogs/qquickabstractdialog.cpp \ - widgetsplugin.cpp - -HEADERS += \ - qquickqmessagebox_p.h \ - qmessageboxhelper_p.h \ - ../dialogs/qquickabstractmessagedialog_p.h \ - qquickqfiledialog_p.h \ - ../dialogs/qquickabstractfiledialog_p.h \ - qquickqcolordialog_p.h \ - ../dialogs/qquickabstractcolordialog_p.h \ - qquickqfontdialog_p.h \ - ../dialogs/qquickabstractfontdialog_p.h \ - ../dialogs/qquickabstractdialog_p.h - -QT += quick-private gui-private core-private qml-private widgets - -load(qml_plugin) diff --git a/src/imports/widgets/widgetsplugin.cpp b/src/imports/widgets/widgetsplugin.cpp deleted file mode 100644 index 05c3a5e86c..0000000000 --- a/src/imports/widgets/widgetsplugin.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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 <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include "qquickqmessagebox_p.h" -#include "qquickqfiledialog_p.h" -#include "qquickqcolordialog_p.h" -#include "qquickqfontdialog_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmlmodule QtQuick.PrivateWidgets 1 - \title QWidget QML Types - \ingroup qmlmodules - \brief Provides QML types for certain QWidgets - \internal - - This QML module contains types which should not be depended upon in Qt Quick - applications, but are available if the Widgets module is linked. It is - recommended to load components from this module conditionally, if at all, - and to provide fallback implementations in case they fail to load. - - \code - import QtQuick.PrivateWidgets 1.1 - \endcode - - \since 5.1 -*/ - -class QtQuick2PrivateWidgetsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") - -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.PrivateWidgets")); - - qmlRegisterType<QQuickQMessageBox>(uri, 1, 1, "QtMessageDialog"); - qmlRegisterType<QQuickQFileDialog>(uri, 1, 0, "QtFileDialog"); - qmlRegisterType<QQuickQColorDialog>(uri, 1, 0, "QtColorDialog"); - qmlRegisterType<QQuickQFontDialog>(uri, 1, 1, "QtFontDialog"); - } -}; - -QT_END_NAMESPACE - -#include "widgetsplugin.moc" diff --git a/src/plugins/accessible/shared/qqmlaccessible.cpp b/src/plugins/accessible/shared/qqmlaccessible.cpp index d08f9bdb2c..ecf4e56acf 100644 --- a/src/plugins/accessible/shared/qqmlaccessible.cpp +++ b/src/plugins/accessible/shared/qqmlaccessible.cpp @@ -185,7 +185,7 @@ void QQmlAccessible::doAction(const QString &actionName) // use the "stepSize" property on the item if (QAccessibleValueInterface *valueIface = valueInterface()) { QVariant valueV = valueIface->currentValue(); - qreal newValue = valueV.toInt(); + qreal newValue = valueV.toReal(); QVariant stepSizeV = object()->property("stepSize"); qreal stepSize = stepSizeV.isValid() ? stepSizeV.toReal() : qreal(1.0); diff --git a/src/qml/compiler/compiler.pri b/src/qml/compiler/compiler.pri index df4f5e8dc3..b2569f9111 100644 --- a/src/qml/compiler/compiler.pri +++ b/src/qml/compiler/compiler.pri @@ -15,7 +15,8 @@ HEADERS += \ $$PWD/qv4ssa_p.h \ $$PWD/qv4regalloc_p.h \ $$PWD/qqmlcodegenerator_p.h \ - $$PWD/qv4isel_masm_p.h + $$PWD/qv4isel_masm_p.h \ + $$PWD/qqmltypecompiler_p.h SOURCES += \ $$PWD/qv4compileddata.cpp \ @@ -28,6 +29,7 @@ SOURCES += \ $$PWD/qv4ssa.cpp \ $$PWD/qv4regalloc.cpp \ $$PWD/qqmlcodegenerator.cpp \ - $$PWD/qv4isel_masm.cpp + $$PWD/qv4isel_masm.cpp \ + $$PWD/qqmltypecompiler.cpp include(../../3rdparty/masm/masm.pri) diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 13b23fde68..a4da07ab66 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -82,8 +82,9 @@ QStringList Signal::parameterStringList(const QStringList &stringPool) const return result; } -QQmlCodeGenerator::QQmlCodeGenerator() - : _object(0) +QQmlCodeGenerator::QQmlCodeGenerator(const QSet<QString> &illegalNames) + : illegalNames(illegalNames) + , _object(0) , jsGenerator(0) { } @@ -292,10 +293,8 @@ bool QQmlCodeGenerator::sanityCheckFunctionNames() if (name.at(0).isUpper()) COMPILE_EXCEPTION(function->identifierToken, tr("Method names cannot begin with an upper case letter")); -#if 0 // ### - if (enginePrivate->v8engine()->illegalNames().contains(currSlot.name.toString())) - COMPILE_EXCEPTION(&currSlot, tr("Illegal method name")); -#endif + if (illegalNames.contains(name)) + COMPILE_EXCEPTION(function->identifierToken, tr("Illegal method name")); } return true; } @@ -589,10 +588,8 @@ bool QQmlCodeGenerator::visit(AST::UiPublicMember *node) if (signalName.at(0).isUpper()) COMPILE_EXCEPTION(node->identifierToken, tr("Signal names cannot begin with an upper case letter")); -#if 0 // ### cannot access identifier table from separate thread - if (enginePrivate->v8engine()->illegalNames().contains(currSig.name.toString())) - COMPILE_EXCEPTION(&currSig, tr("Illegal signal name")); -#endif + if (illegalNames.contains(signalName)) + COMPILE_EXCEPTION(node->identifierToken, tr("Illegal signal name")); _object->qmlSignals->append(signal); } else { @@ -739,6 +736,10 @@ bool QQmlCodeGenerator::visit(AST::UiSourceElement *node) if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) { _functions << funDecl; Function *f = New<Function>(); + f->functionDeclaration = funDecl; + AST::SourceLocation loc = funDecl->firstSourceLocation(); + f->location.line = loc.startLine; + f->location.column = loc.startColumn; f->index = _functions.size() - 1; _object->functions->append(f); } else { @@ -926,12 +927,11 @@ bool QQmlCodeGenerator::setId(AST::Statement *value) COMPILE_EXCEPTION(loc, tr( "IDs must contain only letters, numbers, and underscores")); } -#if 0 // ### - if (enginePrivate->v8engine()->illegalNames().contains(str)) - COMPILE_EXCEPTION(v, tr( "ID illegally masks global JavaScript property")); -#endif + QString idQString(str.toString()); + if (illegalNames.contains(idQString)) + COMPILE_EXCEPTION(loc, tr( "ID illegally masks global JavaScript property")); - _object->idIndex = registerString(str.toString()); + _object->idIndex = registerString(idQString); _object->locationOfIdProperty.line = loc.startLine; _object->locationOfIdProperty.column = loc.startColumn; @@ -987,13 +987,8 @@ bool QQmlCodeGenerator::sanityCheckPropertyName(const AST::SourceLocation &nameL if (name.at(0).isUpper()) COMPILE_EXCEPTION(nameLocation, tr("Property names cannot begin with an upper case letter")); -#if 0 // ### how to check against illegalNames when in separate thread? - if (enginePrivate->v8engine()->illegalNames().contains(prop.name.toString())) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Illegal property name")); - } -#endif + if (illegalNames.contains(name)) + COMPILE_EXCEPTION(nameLocation, tr("Illegal property name")); return true; } @@ -1625,11 +1620,16 @@ SignalHandlerConverter::SignalHandlerConverter(QQmlEnginePrivate *enginePrivate, bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclarations() { - foreach (QmlObject *obj, parsedQML->objects) { + for (int objectIndex = 0; objectIndex < parsedQML->objects.count(); ++objectIndex) { + QmlObject * const obj = parsedQML->objects.at(objectIndex); QString elementName = stringAt(obj->inheritedTypeNameIndex); if (elementName.isEmpty()) continue; - QQmlPropertyCache *cache = unit->resolvedTypes[obj->inheritedTypeNameIndex].createPropertyCache(QQmlEnginePrivate::get(enginePrivate)); + QQmlCompiledData::TypeReference &tr = unit->resolvedTypes[obj->inheritedTypeNameIndex]; + if (tr.type && tr.type->customParser()) + continue; + QQmlPropertyCache *cache = unit->propertyCaches.value(objectIndex); + Q_ASSERT(cache); if (!convertSignalHandlerExpressionsToFunctionDeclarations(obj, elementName, cache)) return false; } diff --git a/src/qml/compiler/qqmlcodegenerator_p.h b/src/qml/compiler/qqmlcodegenerator_p.h index 0a0e4f2d5b..18193eea2b 100644 --- a/src/qml/compiler/qqmlcodegenerator_p.h +++ b/src/qml/compiler/qqmlcodegenerator_p.h @@ -135,6 +135,8 @@ struct Binding : public QV4::CompiledData::Binding struct Function { + AST::FunctionDeclaration *functionDeclaration; + QV4::CompiledData::Location location; int index; // index in parsedQML::functions Function *next; }; @@ -207,7 +209,7 @@ struct Q_QML_EXPORT QQmlCodeGenerator : public AST::Visitor { Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator) public: - QQmlCodeGenerator(); + QQmlCodeGenerator(const QSet<QString> &illegalNames); bool generateFromQml(const QString &code, const QUrl &url, const QString &urlString, ParsedQML *output); static bool isSignalPropertyName(const QString &name); @@ -280,6 +282,8 @@ public: QList<QQmlError> errors; + QSet<QString> illegalNames; + QList<QV4::CompiledData::Import*> _imports; QList<Pragma*> _pragmas; QList<QmlObject*> _objects; diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp new file mode 100644 index 0000000000..7ff5570f14 --- /dev/null +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the tools applications 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 "qqmltypecompiler_p.h" + +#include <private/qqmlcompiler_p.h> +#include <private/qqmlobjectcreator_p.h> + +QT_BEGIN_NAMESPACE + +QQmlTypeCompiler::QQmlTypeCompiler(QQmlEnginePrivate *engine, QQmlCompiledData *compiledData, QQmlTypeData *typeData, QtQml::ParsedQML *parsedQML) + : engine(engine) + , compiledData(compiledData) + , typeData(typeData) + , parsedQML(parsedQML) +{ +} + +bool QQmlTypeCompiler::compile() +{ + compiledData->importCache = new QQmlTypeNameCache; + + foreach (const QString &ns, typeData->namespaces()) + compiledData->importCache->add(ns); + + // Add any Composite Singletons that were used to the import cache + foreach (const QQmlTypeData::TypeReference &singleton, typeData->compositeSingletons()) + compiledData->importCache->add(singleton.type->qmlTypeName(), singleton.type->sourceUrl(), singleton.prefix); + + typeData->imports().populateCache(compiledData->importCache); + compiledData->importCache->addref(); + + const QHash<int, QQmlTypeData::TypeReference> &resolvedTypes = typeData->resolvedTypeRefs(); + for (QHash<int, QQmlTypeData::TypeReference>::ConstIterator resolvedType = resolvedTypes.constBegin(), end = resolvedTypes.constEnd(); + resolvedType != end; ++resolvedType) { + QQmlCompiledData::TypeReference ref; + if (resolvedType->typeData) { + ref.component = resolvedType->typeData->compiledData(); + ref.component->addref(); + } else { + ref.type = resolvedType->type; + Q_ASSERT(ref.type); + } + ref.majorVersion = resolvedType->majorVersion; + ref.minorVersion = resolvedType->minorVersion; + compiledData->resolvedTypes.insert(resolvedType.key(), ref); + } + + // Build property caches and VME meta object data + + const int objectCount = parsedQML->objects.count(); + compiledData->datas.reserve(objectCount); + compiledData->propertyCaches.reserve(objectCount); + + QQmlPropertyCacheCreator propertyCacheBuilder(engine, + parsedQML->jsGenerator.strings, compiledData->url, + &typeData->imports(), &compiledData->resolvedTypes); + + for (int i = 0; i < objectCount; ++i) { + const QtQml::QmlObject *obj = parsedQML->objects.at(i); + + QByteArray vmeMetaObjectData; + QQmlPropertyCache *propertyCache = 0; + + // If the object has no type, then it's probably a nested object definition as part + // of a group property. + const bool objectHasType = !propertyCacheBuilder.stringAt(obj->inheritedTypeNameIndex).isEmpty(); + if (objectHasType) { + if (!propertyCacheBuilder.create(obj, &propertyCache, &vmeMetaObjectData)) { + errors << propertyCacheBuilder.errors; + return false; + } + } + + compiledData->datas << vmeMetaObjectData; + if (propertyCache) + propertyCache->addref(); + compiledData->propertyCaches << propertyCache; + + if (i == parsedQML->indexOfRootObject) { + Q_ASSERT(propertyCache); + compiledData->rootPropertyCache = propertyCache; + propertyCache->addref(); + } + } + + { + SignalHandlerConverter converter(engine, parsedQML, compiledData); + if (!converter.convertSignalHandlerExpressionsToFunctionDeclarations()) { + errors << converter.errors; + return false; + } + } + + // Collect imported scripts + const QList<QQmlTypeData::ScriptReference> &scripts = typeData->resolvedScripts(); + compiledData->scripts.reserve(scripts.count()); + for (int scriptIndex = 0; scriptIndex < scripts.count(); ++scriptIndex) { + const QQmlTypeData::ScriptReference &script = scripts.at(scriptIndex); + + QString qualifier = script.qualifier; + QString enclosingNamespace; + + const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.')); + if (lastDotIndex != -1) { + enclosingNamespace = qualifier.left(lastDotIndex); + qualifier = qualifier.mid(lastDotIndex+1); + } + + compiledData->importCache->add(qualifier, scriptIndex, enclosingNamespace); + QQmlScriptData *scriptData = script.script->scriptData(); + scriptData->addref(); + compiledData->scripts << scriptData; + } + + // Compile JS binding expressions and signal handlers + + JSCodeGen jsCodeGen(typeData->finalUrlString(), parsedQML->code, &parsedQML->jsModule, &parsedQML->jsParserEngine, parsedQML->program, compiledData->importCache); + const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(parsedQML->functions); + + QV4::ExecutionEngine *v4 = engine->v4engine(); + + QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(engine, v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator)); + isel->setUseFastLookups(false); + QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/false); + + // Generate QML compiled type data structures + + QmlUnitGenerator qmlGenerator; + QV4::CompiledData::QmlUnit *qmlUnit = qmlGenerator.generate(*parsedQML, runtimeFunctionIndices); + + if (jsUnit) { + Q_ASSERT(!jsUnit->data); + jsUnit->ownsData = false; + jsUnit->data = &qmlUnit->header; + } + + compiledData->compilationUnit = jsUnit; + if (compiledData->compilationUnit) + compiledData->compilationUnit->ref(); + compiledData->qmlUnit = qmlUnit; // ownership transferred to m_compiledData + + // Resolve component boundaries and aliases + + { + // Scan for components, determine their scopes and resolve aliases within the scope. + QQmlComponentAndAliasResolver resolver(compiledData->url, compiledData->qmlUnit, compiledData->resolvedTypes, compiledData->propertyCaches, + &compiledData->datas, &compiledData->objectIndexToIdForRoot, &compiledData->objectIndexToIdPerComponent); + if (!resolver.resolve()) { + errors << resolver.errors; + return false; + } + } + + // Add to type registry of composites + if (compiledData->isCompositeType()) + engine->registerInternalCompositeType(compiledData); + else { + const QV4::CompiledData::Object *obj = qmlUnit->objectAt(qmlUnit->indexOfRootObject); + QQmlCompiledData::TypeReference typeRef = compiledData->resolvedTypes.value(obj->inheritedTypeNameIndex); + if (typeRef.component) { + compiledData->metaTypeId = typeRef.component->metaTypeId; + compiledData->listMetaTypeId = typeRef.component->listMetaTypeId; + } else { + compiledData->metaTypeId = typeRef.type->typeId(); + compiledData->listMetaTypeId = typeRef.type->qListTypeId(); + } + } + + // Sanity check property bindings + QQmlPropertyValidator validator(compiledData->url, compiledData->qmlUnit, compiledData->resolvedTypes, + compiledData->propertyCaches, compiledData->objectIndexToIdPerComponent, + &compiledData->customParserData); + if (!validator.validate()) { + errors << validator.errors; + return false; + } + + return errors.isEmpty(); +} + +QT_END_NAMESPACE diff --git a/src/imports/dialogs/qquickdialogassets_p.h b/src/qml/compiler/qqmltypecompiler_p.h index 406b68a66d..9592e5d611 100644 --- a/src/imports/dialogs/qquickdialogassets_p.h +++ b/src/qml/compiler/qqmltypecompiler_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 tools applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -38,28 +38,38 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#ifndef QQMLTYPECOMPILER_P_H +#define QQMLTYPECOMPILER_P_H -#ifndef QQUICKDIALOGASSETS_P_H -#define QQUICKDIALOGASSETS_P_H - -#include <private/qtquickglobal_p.h> -#include <QtGui/qpa/qplatformdialoghelper.h> -#include "qquickabstractmessagedialog_p.h" +#include <qglobal.h> +#include <qqmlerror.h> QT_BEGIN_NAMESPACE -class QQuickStandardButton -{ - Q_GADGET - Q_ENUMS(QQuickAbstractMessageDialog::StandardButton) -}; +class QQmlEnginePrivate; +class QQmlCompiledData; +class QQmlError; +class QQmlTypeData; + +namespace QtQml { +struct ParsedQML; +} -class QQuickStandardIcon +struct QQmlTypeCompiler { - Q_GADGET - Q_ENUMS(QQuickAbstractMessageDialog::Icon) + QQmlTypeCompiler(QQmlEnginePrivate *engine, QQmlCompiledData *compiledData, QQmlTypeData *typeData, QtQml::ParsedQML *parsedQML); + + bool compile(); + + QList<QQmlError> errors; + +private: + QQmlEnginePrivate *engine; + QQmlCompiledData *compiledData; + QQmlTypeData *typeData; + QtQml::ParsedQML *parsedQML; }; QT_END_NAMESPACE -#endif // QQUICKDIALOGASSETS_P_H +#endif // QQMLTYPECOMPILER_P_H diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index 35097bae49..e8038f1db3 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -1069,12 +1069,12 @@ void InstructionSelection::getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR: // get data, ScratchRegister holds index addr = _as->loadTempAddress(Assembler::ReturnValueRegister, tbase); _as->load64(addr, Assembler::ReturnValueRegister); - Address arrayDataLen(Assembler::ReturnValueRegister, qOffsetOf(Object, arrayDataLen)); + Address dataLen(Assembler::ReturnValueRegister, qOffsetOf(Object, arrayData) + qOffsetOf(Object::ArrayData, length)); Assembler::Jump outOfRange; if (needNegativeCheck) outOfRange = _as->branch32(Assembler::LessThan, Assembler::ScratchRegister, Assembler::TrustedImm32(0)); - Assembler::Jump outOfRange2 = _as->branch32(Assembler::GreaterThanOrEqual, Assembler::ScratchRegister, arrayDataLen); - Address arrayData(Assembler::ReturnValueRegister, qOffsetOf(Object, arrayData)); + Assembler::Jump outOfRange2 = _as->branch32(Assembler::GreaterThanOrEqual, Assembler::ScratchRegister, dataLen); + Address arrayData(Assembler::ReturnValueRegister, qOffsetOf(Object, arrayData) + qOffsetOf(Object::ArrayData, data)); _as->load64(arrayData, Assembler::ReturnValueRegister); Q_ASSERT(sizeof(Property) == (1<<4)); _as->lshift64(Assembler::TrustedImm32(4), Assembler::ScratchRegister); diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 629c255b48..9879f2a85b 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -51,7 +51,6 @@ ArgumentsObject::ArgumentsObject(CallContext *context) , context(context) , fullyCreated(false) { - type = Type_ArgumentsObject; flags &= ~SimpleArray; ExecutionEngine *v4 = context->engine; @@ -67,13 +66,12 @@ ArgumentsObject::ArgumentsObject(CallContext *context) arrayReserve(context->callData->argc); for (int i = 0; i < context->callData->argc; ++i) - arrayData[i].value = context->callData->args[i]; - arrayDataLen = context->callData->argc; + arrayData.data[i].value = context->callData->args[i]; + arrayData.length = context->callData->argc; fullyCreated = true; } else { Q_ASSERT(CalleePropertyIndex == internalClass->find(context->engine->id_callee)); memberData[CalleePropertyIndex].value = context->function->asReturnedValue(); - isNonStrictArgumentsObject = true; } Q_ASSERT(LengthPropertyIndex == internalClass->find(context->engine->id_length)); Property *lp = memberData + ArrayObject::LengthPropertyIndex; @@ -99,14 +97,14 @@ void ArgumentsObject::fullyCreate() context->engine->requireArgumentsAccessors(numAccessors); for (uint i = 0; i < (uint)numAccessors; ++i) { mappedArguments.append(context->callData->args[i]); - arrayData[i] = context->engine->argumentsAccessors.at(i); - arrayAttributes[i] = Attr_Accessor; + arrayData.data[i] = context->engine->argumentsAccessors.at(i); + arrayData.attributes[i] = Attr_Accessor; } for (uint i = numAccessors; i < argCount; ++i) { - arrayData[i] = Property::fromValue(context->callData->args[i]); - arrayAttributes[i] = Attr_Data; + arrayData.data[i] = Property::fromValue(context->callData->args[i]); + arrayData.attributes[i] = Attr_Data; } - arrayDataLen = argCount; + arrayData.length = argCount; fullyCreated = true; } @@ -117,26 +115,24 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const Scope scope(ctx); uint pidx = propertyIndexFromArrayIndex(index); - Property *pd = arrayData + pidx; + Property *pd = arrayData.data + pidx; Property map; PropertyAttributes mapAttrs; bool isMapped = false; if (pd && index < (uint)mappedArguments.size()) - isMapped = arrayAttributes && arrayAttributes[pidx].isAccessor() && pd->getter() == context->engine->argumentsAccessors.at(index).getter(); + isMapped = arrayData.attributes && arrayData.attributes[pidx].isAccessor() && pd->getter() == context->engine->argumentsAccessors.at(index).getter(); if (isMapped) { map = *pd; - mapAttrs = arrayAttributes[pidx]; - arrayAttributes[pidx] = Attr_Data; + mapAttrs = arrayData.attributes[pidx]; + arrayData.attributes[pidx] = Attr_Data; pd->value = mappedArguments.at(index); } - isNonStrictArgumentsObject = false; bool strict = ctx->strictMode; ctx->strictMode = false; bool result = Object::__defineOwnProperty__(ctx, index, desc, attrs); ctx->strictMode = strict; - isNonStrictArgumentsObject = true; if (isMapped && attrs.isData()) { ScopedCallData callData(scope, 1); @@ -146,7 +142,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const if (attrs.isWritable()) { *pd = map; - arrayAttributes[pidx] = mapAttrs; + arrayData.attributes[pidx] = mapAttrs; } } diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index d306fae92b..42b749cbb5 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -77,12 +77,17 @@ struct ArgumentsSetterFunction: FunctionObject struct ArgumentsObject: Object { Q_MANAGED + Q_MANAGED_TYPE(ArgumentsObject) CallContext *context; bool fullyCreated; QVector<SafeValue> mappedArguments; ArgumentsObject(CallContext *context); ~ArgumentsObject() {} + static bool isNonStrictArgumentsObject(Managed *m) { + return m->internalClass->vtable->type == Type_ArgumentsObject && + !static_cast<ArgumentsObject *>(m)->context->strictMode; + } enum { LengthPropertyIndex = 0, diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 296471692c..0fc7f2ddb9 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -73,8 +73,8 @@ ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData) len = callData->argc; a->arrayReserve(len); for (unsigned int i = 0; i < len; ++i) - a->arrayData[i].value = callData->args[i]; - a->arrayDataLen = len; + a->arrayData.data[i].value = callData->args[i]; + a->arrayData.length = len; } a->setArrayLengthUnchecked(len); @@ -308,18 +308,18 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) return Encode(newLen); } - if (!instance->protoHasArray() && instance->arrayDataLen <= len) { + if (!instance->protoHasArray() && instance->arrayData.length <= len) { for (int i = 0; i < ctx->callData->argc; ++i) { - if (!instance->sparseArray) { - if (len >= instance->arrayAlloc) + if (!instance->arrayData.sparse) { + if (len >= instance->arrayData.alloc) instance->arrayReserve(len + 1); - instance->arrayData[len].value = ctx->callData->args[i]; - if (instance->arrayAttributes) - instance->arrayAttributes[len] = Attr_Data; - instance->arrayDataLen = len + 1; + instance->arrayData.data[len].value = ctx->callData->args[i]; + if (instance->arrayData.attributes) + instance->arrayData.attributes[len] = Attr_Data; + instance->arrayData.length = len + 1; } else { uint j = instance->allocArrayValue(ctx->callData->args[i]); - instance->sparseArray->push_back(j, len); + instance->arrayData.sparse->push_back(j, len); } ++len; } @@ -384,23 +384,23 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) Property *front = 0; uint pidx = instance->propertyIndexFromArrayIndex(0); - if (pidx < UINT_MAX && !instance->arrayData[pidx].value.isEmpty()) - front = instance->arrayData + pidx; - - ScopedValue result(scope, front ? instance->getValue(front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data) : Encode::undefined()); - - if (!instance->protoHasArray() && instance->arrayDataLen <= len) { - if (!instance->sparseArray) { - if (instance->arrayDataLen) { - ++instance->arrayOffset; - ++instance->arrayData; - --instance->arrayDataLen; - --instance->arrayAlloc; - if (instance->arrayAttributes) - ++instance->arrayAttributes; + if (pidx < UINT_MAX && !instance->arrayData.data[pidx].value.isEmpty()) + front = instance->arrayData.data + pidx; + + ScopedValue result(scope, front ? instance->getValue(front, instance->arrayData.attributes ? instance->arrayData.attributes[pidx] : Attr_Data) : Encode::undefined()); + + if (!instance->protoHasArray() && instance->arrayData.length <= len) { + if (!instance->arrayData.sparse) { + if (instance->arrayData.length) { + ++instance->arrayData.offset; + ++instance->arrayData.data; + --instance->arrayData.length; + --instance->arrayData.alloc; + if (instance->arrayData.attributes) + ++instance->arrayData.attributes; } } else { - uint idx = instance->sparseArray->pop_front(); + uint idx = instance->arrayData.sparse->pop_front(); instance->freeArrayValue(idx); } } else { @@ -505,10 +505,10 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) newArray->arrayReserve(deleteCount); for (uint i = 0; i < deleteCount; ++i) { - newArray->arrayData[i].value = instance->getIndexed(start + i); + newArray->arrayData.data[i].value = instance->getIndexed(start + i); if (scope.hasException()) return Encode::undefined(); - newArray->arrayDataLen = i + 1; + newArray->arrayData.length = i + 1; } newArray->setArrayLengthUnchecked(deleteCount); @@ -571,26 +571,26 @@ ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx) uint len = getLength(ctx, instance); ScopedValue v(scope); - if (!instance->protoHasArray() && instance->arrayDataLen <= len) { + if (!instance->protoHasArray() && instance->arrayData.length <= len) { for (int i = ctx->callData->argc - 1; i >= 0; --i) { v = ctx->argument(i); - if (!instance->sparseArray) { - if (!instance->arrayOffset) + if (!instance->arrayData.sparse) { + if (!instance->arrayData.offset) instance->getArrayHeadRoom(); - --instance->arrayOffset; - --instance->arrayData; - ++instance->arrayDataLen; - ++instance->arrayAlloc; - if (instance->arrayAttributes) { - --instance->arrayAttributes; - *instance->arrayAttributes = Attr_Data; + --instance->arrayData.offset; + --instance->arrayData.data; + ++instance->arrayData.length; + ++instance->arrayData.alloc; + if (instance->arrayData.attributes) { + --instance->arrayData.attributes; + *instance->arrayData.attributes = Attr_Data; } - instance->arrayData->value = v.asReturnedValue(); + instance->arrayData.data->value = v.asReturnedValue(); } else { uint idx = instance->allocArrayValue(v); - instance->sparseArray->push_front(idx); + instance->arrayData.sparse->push_front(idx); } } } else { diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 05a0e66e09..f5d8106f06 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -53,6 +53,13 @@ using namespace QV4; const ManagedVTable ExecutionContext::static_vtbl = { + ExecutionContext::IsExecutionContext, + ExecutionContext::IsString, + ExecutionContext::IsObject, + ExecutionContext::IsFunctionObject, + ExecutionContext::IsErrorObject, + 0, + ExecutionContext::MyType, call, construct, markObjects, diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 4eb89ad905..851f024a60 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -70,6 +70,10 @@ struct WithContext; struct Q_QML_EXPORT ExecutionContext : public Managed { Q_MANAGED + Q_MANAGED_TYPE(ExecutionContext) + enum { + IsExecutionContext = true + }; enum ContextType { Type_GlobalContext = 0x1, diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 5d0c8ccf8e..2b6aa21ac2 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -647,7 +647,6 @@ DateObject::DateObject(ExecutionEngine *engine, const QDateTime &date) : Object(engine->dateClass) { setVTable(&static_vtbl); - type = Type_DateObject; value.setDouble(date.isValid() ? date.toMSecsSinceEpoch() : qSNaN()); } diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 9c451dd251..244553b1d4 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -53,9 +53,9 @@ namespace QV4 { struct DateObject: Object { Q_MANAGED + Q_MANAGED_TYPE(DateObject) SafeValue value; DateObject(ExecutionEngine *engine, const ValueRef date): Object(engine->dateClass) { - type = Type_DateObject; value = date; } DateObject(ExecutionEngine *engine, const QDateTime &value); @@ -64,8 +64,7 @@ struct DateObject: Object { protected: DateObject(InternalClass *ic): Object(ic) { - setVTable(&static_vtbl); - type = Type_DateObject; + Q_ASSERT(internalClass->vtable == &static_vtbl); value = Primitive::fromDouble(qSNaN()); } }; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 539bc5ddd6..384254f896 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -195,9 +195,9 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) identifierTable = new IdentifierTable(this); emptyClass = new (classPool.allocate(sizeof(InternalClass))) InternalClass(this); - executionContextClass = emptyClass->changeVTable(&ExecutionContext::static_vtbl); - stringClass = emptyClass->changeVTable(&String::static_vtbl); - regExpValueClass = emptyClass->changeVTable(&RegExp::static_vtbl); + executionContextClass = InternalClass::create(this, &ExecutionContext::static_vtbl, 0); + stringClass = InternalClass::create(this, &String::static_vtbl, 0); + regExpValueClass = InternalClass::create(this, &RegExp::static_vtbl, 0); id_undefined = newIdentifier(QStringLiteral("undefined")); id_null = newIdentifier(QStringLiteral("null")); @@ -230,7 +230,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) id_toString = newIdentifier(QStringLiteral("toString")); id_valueOf = newIdentifier(QStringLiteral("valueOf")); - ObjectPrototype *objectPrototype = new (memoryManager) ObjectPrototype(emptyClass->changeVTable(&ObjectPrototype::static_vtbl)); + ObjectPrototype *objectPrototype = new (memoryManager) ObjectPrototype(InternalClass::create(this, &ObjectPrototype::static_vtbl, 0)); objectClass = InternalClass::create(this, &Object::static_vtbl, objectPrototype); Q_ASSERT(objectClass->vtable == &Object::static_vtbl); @@ -249,16 +249,16 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) initRootContext(); - StringPrototype *stringPrototype = new (memoryManager) StringPrototype(objectClass); + StringPrototype *stringPrototype = new (memoryManager) StringPrototype(InternalClass::create(this, &StringPrototype::static_vtbl, objectPrototype)); stringObjectClass = InternalClass::create(this, &String::static_vtbl, stringPrototype); - NumberPrototype *numberPrototype = new (memoryManager) NumberPrototype(objectClass); + NumberPrototype *numberPrototype = new (memoryManager) NumberPrototype(InternalClass::create(this, &NumberPrototype::static_vtbl, objectPrototype)); numberClass = InternalClass::create(this, &NumberObject::static_vtbl, numberPrototype); - BooleanPrototype *booleanPrototype = new (memoryManager) BooleanPrototype(objectClass); + BooleanPrototype *booleanPrototype = new (memoryManager) BooleanPrototype(InternalClass::create(this, &BooleanPrototype::static_vtbl, objectPrototype)); booleanClass = InternalClass::create(this, &BooleanObject::static_vtbl, booleanPrototype); - DatePrototype *datePrototype = new (memoryManager) DatePrototype(objectClass); + DatePrototype *datePrototype = new (memoryManager) DatePrototype(InternalClass::create(this, &DatePrototype::static_vtbl, objectPrototype)); dateClass = InternalClass::create(this, &DateObject::static_vtbl, datePrototype); FunctionPrototype *functionPrototype = new (memoryManager) FunctionPrototype(InternalClass::create(this, &FunctionPrototype::static_vtbl, objectPrototype)); @@ -269,14 +269,14 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) protoClass = objectClass->addMember(id_constructor, Attr_NotEnumerable, &index); Q_ASSERT(index == FunctionObject::Index_ProtoConstructor); - RegExpPrototype *regExpPrototype = new (memoryManager) RegExpPrototype(objectClass); + RegExpPrototype *regExpPrototype = new (memoryManager) RegExpPrototype(InternalClass::create(this, &RegExpPrototype::static_vtbl, objectPrototype)); regExpClass = InternalClass::create(this, &RegExpObject::static_vtbl, regExpPrototype); regExpExecArrayClass = arrayClass->addMember(id_index, Attr_Data, &index); Q_ASSERT(index == RegExpObject::Index_ArrayIndex); regExpExecArrayClass = regExpExecArrayClass->addMember(id_input, Attr_Data, &index); Q_ASSERT(index == RegExpObject::Index_ArrayInput); - ErrorPrototype *errorPrototype = new (memoryManager) ErrorPrototype(objectClass); + ErrorPrototype *errorPrototype = new (memoryManager) ErrorPrototype(InternalClass::create(this, &ErrorObject::static_vtbl, objectPrototype)); errorClass = InternalClass::create(this, &ErrorObject::static_vtbl, errorPrototype); EvalErrorPrototype *evalErrorPrototype = new (memoryManager) EvalErrorPrototype(errorClass); evalErrorClass = InternalClass::create(this, &EvalErrorObject::static_vtbl, evalErrorPrototype); @@ -357,8 +357,8 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) globalObject->defineDefaultProperty(QStringLiteral("TypeError"), typeErrorCtor); globalObject->defineDefaultProperty(QStringLiteral("URIError"), uRIErrorCtor); ScopedObject o(scope); - globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = new (memoryManager) MathObject(this))); - globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = new (memoryManager) JsonObject(this))); + globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = new (memoryManager) MathObject(QV4::InternalClass::create(this, &MathObject::static_vtbl, objectPrototype)))); + globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = new (memoryManager) JsonObject(QV4::InternalClass::create(this, &JsonObject::static_vtbl, objectPrototype)))); globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Primitive::undefinedValue()); globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN())); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index cf5c06dd41..f5d21b2f30 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -76,8 +76,6 @@ ErrorObject::ErrorObject(InternalClass *ic) : Object(ic) , stack(0) { - type = Type_ErrorObject; - Scope scope(engine()); ScopedValue protectThis(scope, this); @@ -89,7 +87,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const ValueRef message, ErrorType t) : Object(ic) , stack(0) { - type = Type_ErrorObject; subtype = t; Scope scope(engine()); @@ -113,7 +110,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, ErrorObject: : Object(ic) , stack(0) { - type = Type_ErrorObject; subtype = t; Scope scope(engine()); @@ -137,7 +133,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QStrin : Object(ic) , stack(0) { - type = Type_ErrorObject; subtype = t; Scope scope(engine()); diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index def776d3b6..560b003062 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -52,6 +52,10 @@ struct SyntaxErrorObject; struct ErrorObject: Object { Q_MANAGED + Q_MANAGED_TYPE(ErrorObject) + enum { + IsErrorObject = true + }; enum ErrorType { Error, diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 6e5c137e0b..4538884bce 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -112,7 +112,6 @@ FunctionObject::FunctionObject(InternalClass *ic) { name = ic->engine->id_undefined; - type = Type_FunctionObject; needsActivation = false; strictMode = false; } @@ -130,7 +129,6 @@ void FunctionObject::init(const StringRef n, bool createProto) Scope s(internalClass->engine); ScopedValue protectThis(s, this); - type = Type_FunctionObject; needsActivation = true; strictMode = false; #ifndef QT_NO_DEBUG @@ -355,9 +353,9 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) for (quint32 i = 0; i < len; ++i) callData->args[i] = arr->getIndexed(i); } else { - int alen = qMin(len, arr->arrayDataLen); + int alen = qMin(len, arr->arrayData.length); for (int i = 0; i < alen; ++i) - callData->args[i] = arr->arrayData[i].value; + callData->args[i] = arr->arrayData.data[i].value; for (quint32 i = alen; i < len; ++i) callData->args[i] = Primitive::undefinedValue(); } diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 96534cb68c..0168e13a6f 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -94,6 +94,10 @@ struct Lookup; struct Q_QML_EXPORT FunctionObject: Object { Q_MANAGED + Q_MANAGED_TYPE(FunctionObject) + enum { + IsFunctionObject = true + }; // Used with Managed::subType enum FunctionType { RegularFunction = 0, diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 29ede3d104..761a180722 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -183,6 +183,8 @@ InternalClass *InternalClass::changeMember(String *string, PropertyAttributes da InternalClass *InternalClass::create(ExecutionEngine *engine, const ManagedVTable *vtable, Object *proto) { InternalClass *c = engine->emptyClass->changeVTable(vtable); + if (!proto) + return c; return c->changePrototype(proto); } diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 6633435668..787e5300f5 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -66,6 +66,8 @@ static int indent = 0; #endif +DEFINE_MANAGED_VTABLE(JsonObject); + class JsonParser { public: @@ -884,12 +886,10 @@ QString Stringify::JA(ArrayObjectRef a) } -JsonObject::JsonObject(ExecutionEngine *engine) - : Object(engine) +JsonObject::JsonObject(InternalClass *ic) + : Object(ic) { - type = Type_JSONObject; - - Scope scope(engine); + Scope scope(ic->engine); ScopedObject protectThis(scope, this); defineDefaultProperty(QStringLiteral("parse"), method_parse, 2); @@ -1058,8 +1058,8 @@ QV4::ReturnedValue JsonObject::fromJsonArray(ExecutionEngine *engine, const QJso Scoped<ArrayObject> a(scope, engine->newArrayObject()); a->arrayReserve(size); for (int i = 0; i < size; i++) { - a->arrayData[i].value = fromJsonValue(engine, array.at(i)); - a->arrayDataLen = i + 1; + a->arrayData.data[i].value = fromJsonValue(engine, array.at(i)); + a->arrayData.length = i + 1; } a->setArrayLengthUnchecked(size); return a.asReturnedValue(); diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index 3bcbdeadbf..b37b28b078 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -51,10 +51,12 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct JsonObject : Object { + Q_MANAGED_TYPE(JsonObject) + Q_MANAGED private: typedef QSet<QV4::Object *> V4ObjectSet; public: - JsonObject(ExecutionEngine *engine); + JsonObject(InternalClass *ic); static ReturnedValue method_parse(CallContext *ctx); static ReturnedValue method_stringify(CallContext *ctx); diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index fef7489110..47f9195322 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -47,6 +47,13 @@ using namespace QV4; const ManagedVTable Managed::static_vtbl = { + Managed::IsExecutionContext, + Managed::IsString, + Managed::IsObject, + Managed::IsFunctionObject, + Managed::IsErrorObject, + 0, + Managed::MyType, call, construct, 0 /*markObjects*/, @@ -101,7 +108,7 @@ ExecutionEngine *Managed::engine() const QString Managed::className() const { const char *s = 0; - switch (Type(type)) { + switch (Type(internalClass->vtable->type)) { case Type_Invalid: case Type_String: return QString(); @@ -157,18 +164,23 @@ QString Managed::className() const case Type_ArgumentsObject: s = "Arguments"; break; - case Type_JSONObject: + case Type_JsonObject: s = "JSON"; break; case Type_MathObject: s = "Math"; break; + + case Type_ExecutionContext: + s = "__ExecutionContext"; + break; case Type_ForeachIteratorObject: s = "__ForeachIterator"; break; case Type_RegExp: - s = "RegExp"; + s = "__RegExp"; break; + case Type_QmlSequence: s = "QmlSequence"; break; diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 63972688a7..124392197f 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -53,8 +53,8 @@ QT_BEGIN_NAMESPACE namespace QV4 { #define Q_MANAGED_CHECK \ - template <typename T> inline void qt_check_for_QMANAGED_macro(const T &_q_argument) const \ - { int i = qYouForgotTheQ_MANAGED_Macro(this, &_q_argument); i = i + 1; } + template <typename T> inline void qt_check_for_QMANAGED_macro(const T *_q_argument) const \ + { int i = qYouForgotTheQ_MANAGED_Macro(this, _q_argument); i = i + 1; } template <typename T> inline int qYouForgotTheQ_MANAGED_Macro(T, T) { return 0; } @@ -69,6 +69,9 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} template <typename T> \ QV4::Returned<T> *asReturned() { return QV4::Returned<T>::create(this); } \ +#define Q_MANAGED_TYPE(type) \ + public: \ + enum { MyType = Type_##type }; struct GCDeletable { @@ -80,6 +83,13 @@ struct GCDeletable struct ManagedVTable { + uint isExecutionContext : 1; + uint isString : 1; + uint isObject : 1; + uint isFunctionObject : 1; + uint isErrorObject : 1; + uint unused : 19; + uint type : 8; ReturnedValue (*call)(Managed *, CallData *data); ReturnedValue (*construct)(Managed *, CallData *data); void (*markObjects)(Managed *, ExecutionEngine *e); @@ -103,6 +113,13 @@ struct ManagedVTable #define DEFINE_MANAGED_VTABLE(classname) \ const QV4::ManagedVTable classname::static_vtbl = \ { \ + classname::IsExecutionContext, \ + classname::IsString, \ + classname::IsObject, \ + classname::IsFunctionObject, \ + classname::IsErrorObject, \ + 0, \ + classname::MyType, \ call, \ construct, \ markObjects, \ @@ -123,9 +140,46 @@ const QV4::ManagedVTable classname::static_vtbl = \ #classname \ } +#define DEFINE_MANAGED_VTABLE_WITH_NAME(classname, name) \ +const QV4::ManagedVTable classname::static_vtbl = \ +{ \ + classname::IsExecutionContext, \ + classname::IsString, \ + classname::IsObject, \ + classname::IsFunctionObject, \ + classname::IsErrorObject, \ + 0, \ + classname::MyType, \ + call, \ + construct, \ + markObjects, \ + destroy, \ + 0, \ + get, \ + getIndexed, \ + put, \ + putIndexed, \ + query, \ + queryIndexed, \ + deleteProperty, \ + deleteIndexedProperty, \ + getLookup, \ + setLookup, \ + isEqualTo, \ + advanceIterator, \ + #name \ +} + #define DEFINE_MANAGED_VTABLE_WITH_DELETABLES(classname) \ const QV4::ManagedVTable classname::static_vtbl = \ { \ + classname::IsExecutionContext, \ + classname::IsString, \ + classname::IsObject, \ + classname::IsFunctionObject, \ + classname::IsErrorObject, \ + 0, \ + classname::MyType, \ call, \ construct, \ markObjects, \ @@ -149,6 +203,13 @@ const QV4::ManagedVTable classname::static_vtbl = \ struct Q_QML_EXPORT Managed { Q_MANAGED + enum { + IsExecutionContext = false, + IsString = false, + IsObject = false, + IsFunctionObject = false, + IsErrorObject = false + }; private: void *operator new(size_t); Managed(const Managed &other); @@ -183,13 +244,16 @@ public: Type_RegExpObject, Type_ErrorObject, Type_ArgumentsObject, - Type_JSONObject, + Type_JsonObject, Type_MathObject, + + Type_ExecutionContext, Type_ForeachIteratorObject, Type_RegExp, Type_QmlSequence }; + Q_MANAGED_TYPE(Invalid) ExecutionEngine *engine() const; @@ -199,7 +263,7 @@ public: if (!this || !internalClass) return 0; #if !defined(QT_NO_QOBJECT_CHECK) - reinterpret_cast<T *>(this)->qt_check_for_QMANAGED_macro(*reinterpret_cast<T *>(this)); + static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(this)); #endif return internalClass->vtable == &T::static_vtbl ? static_cast<T *>(this) : 0; } @@ -209,26 +273,26 @@ public: if (!this) return 0; #if !defined(QT_NO_QOBJECT_CHECK) - reinterpret_cast<T *>(this)->qt_check_for_QMANAGED_macro(*reinterpret_cast<T *>(const_cast<Managed *>(this))); + static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(const_cast<Managed *>(this))); #endif return internalClass->vtable == &T::static_vtbl ? static_cast<const T *>(this) : 0; } - String *asString() { return type == Type_String ? reinterpret_cast<String *>(this) : 0; } - Object *asObject() { return type != Type_String ? reinterpret_cast<Object *>(this) : 0; } - ArrayObject *asArrayObject() { return type == Type_ArrayObject ? reinterpret_cast<ArrayObject *>(this) : 0; } - FunctionObject *asFunctionObject() { return type == Type_FunctionObject ? reinterpret_cast<FunctionObject *>(this) : 0; } - BooleanObject *asBooleanObject() { return type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; } - NumberObject *asNumberObject() { return type == Type_NumberObject ? reinterpret_cast<NumberObject *>(this) : 0; } - StringObject *asStringObject() { return type == Type_StringObject ? reinterpret_cast<StringObject *>(this) : 0; } - DateObject *asDateObject() { return type == Type_DateObject ? reinterpret_cast<DateObject *>(this) : 0; } - ErrorObject *asErrorObject() { return type == Type_ErrorObject ? reinterpret_cast<ErrorObject *>(this) : 0; } - ArgumentsObject *asArgumentsObject() { return type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; } + String *asString() { return internalClass->vtable->isString ? reinterpret_cast<String *>(this) : 0; } + Object *asObject() { return internalClass->vtable->isObject ? reinterpret_cast<Object *>(this) : 0; } + ArrayObject *asArrayObject() { return internalClass->vtable->type == Type_ArrayObject ? reinterpret_cast<ArrayObject *>(this) : 0; } + FunctionObject *asFunctionObject() { return internalClass->vtable->isFunctionObject ? reinterpret_cast<FunctionObject *>(this) : 0; } + BooleanObject *asBooleanObject() { return internalClass->vtable->type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; } + NumberObject *asNumberObject() { return internalClass->vtable->type == Type_NumberObject ? reinterpret_cast<NumberObject *>(this) : 0; } + StringObject *asStringObject() { return internalClass->vtable->type == Type_StringObject ? reinterpret_cast<StringObject *>(this) : 0; } + DateObject *asDateObject() { return internalClass->vtable->type == Type_DateObject ? reinterpret_cast<DateObject *>(this) : 0; } + ErrorObject *asErrorObject() { return internalClass->vtable->isErrorObject ? reinterpret_cast<ErrorObject *>(this) : 0; } + ArgumentsObject *asArgumentsObject() { return internalClass->vtable->type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; } - bool isListType() const { return type == Type_QmlSequence; } + bool isListType() const { return internalClass->vtable->type == Type_QmlSequence; } - bool isArrayObject() const { return type == Type_ArrayObject; } - bool isStringObject() const { return type == Type_StringObject; } + bool isArrayObject() const { return internalClass->vtable->type == Type_ArrayObject; } + bool isStringObject() const { return internalClass->vtable->type == Type_StringObject; } QString className() const; @@ -272,10 +336,6 @@ public: static void setLookup(Managed *m, Lookup *l, const ValueRef v); static bool isEqualTo(Managed *m, Managed *other); - uint internalType() const { - return type; - } - ReturnedValue asReturnedValue() { return Value::fromManaged(this).asReturnedValue(); } @@ -291,12 +351,12 @@ public: uchar markBit : 1; uchar inUse : 1; uchar extensible : 1; // used by Object - uchar isNonStrictArgumentsObject : 1; + uchar _unused : 1; uchar needsActivation : 1; // used by FunctionObject uchar strictMode : 1; // used by FunctionObject uchar bindingKeyFlag : 1; uchar hasAccessorProperty : 1; - uchar type; + uchar _type; mutable uchar subtype; uchar flags; }; diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 5a7af1f041..6225d6b4ae 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -51,14 +51,14 @@ using namespace QV4; +DEFINE_MANAGED_VTABLE(MathObject); + static const double qt_PI = 2.0 * ::asin(1.0); -MathObject::MathObject(ExecutionEngine *engine) - : Object(engine) +MathObject::MathObject(InternalClass *ic) + : Object(ic) { - type = Type_MathObject; - - Scope scope(engine); + Scope scope(ic->engine); ScopedObject protectThis(scope, this); defineReadonlyProperty(QStringLiteral("E"), Primitive::fromDouble(::exp(1.0))); diff --git a/src/qml/jsruntime/qv4mathobject_p.h b/src/qml/jsruntime/qv4mathobject_p.h index 6fe3db3950..45f8e7cd2e 100644 --- a/src/qml/jsruntime/qv4mathobject_p.h +++ b/src/qml/jsruntime/qv4mathobject_p.h @@ -49,7 +49,9 @@ namespace QV4 { struct MathObject: Object { - MathObject(ExecutionEngine *engine); + Q_MANAGED + Q_MANAGED_TYPE(MathObject) + MathObject(InternalClass *ic); static ReturnedValue method_abs(CallContext *context); static ReturnedValue method_acos(CallContext *context); diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index f67efaffb9..625e34de07 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -275,6 +275,7 @@ Managed *MemoryManager::alloc(std::size_t size) if (size >= MemoryManager::Data::MaxItemSize) { // we use malloc for this MemoryManager::Data::LargeItem *item = static_cast<MemoryManager::Data::LargeItem *>(malloc(size + sizeof(MemoryManager::Data::LargeItem))); + memset(item, 0, size + sizeof(MemoryManager::Data::LargeItem)); item->next = m_d->largeItems; m_d->largeItems = item; return item->managed(); @@ -520,6 +521,7 @@ void MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size, m->internalClass->vtable->collectDeletables(m, deletable); m->internalClass->vtable->destroy(m); + memset(m, 0, size); m->setNextFree(*f); #ifdef V4_USE_VALGRIND VALGRIND_DISABLE_ERROR_REPORTING; diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 106525d412..fc54933aca 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -72,37 +72,31 @@ DEFINE_MANAGED_VTABLE(Object); Object::Object(ExecutionEngine *engine) : Managed(engine->objectClass) , memberDataAlloc(InlinePropertySize), memberData(inlineProperties) - , arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0) { - type = Type_Object; flags = SimpleArray; - memset(memberData, 0, sizeof(Property)*memberDataAlloc); } Object::Object(InternalClass *ic) : Managed(ic) , memberDataAlloc(InlinePropertySize), memberData(inlineProperties) - , arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0) { Q_ASSERT(internalClass->vtable && internalClass->vtable != &Managed::static_vtbl); - type = Type_Object; flags = SimpleArray; if (internalClass->size >= memberDataAlloc) { memberDataAlloc = internalClass->size; memberData = new Property[memberDataAlloc]; } - memset(memberData, 0, sizeof(Property)*memberDataAlloc); } Object::~Object() { if (memberData != inlineProperties) delete [] memberData; - delete [] (arrayData - (sparseArray ? 0 : arrayOffset)); - if (arrayAttributes) - delete [] (arrayAttributes - (sparseArray ? 0 : arrayOffset)); - delete sparseArray; + delete [] (arrayData.data - (arrayData.sparse ? 0 : arrayData.offset)); + if (arrayData.attributes) + delete [] (arrayData.attributes - (arrayData.sparse ? 0 : arrayData.offset)); + delete arrayData.sparse; _data = 0; } @@ -259,13 +253,13 @@ void Object::markObjects(Managed *that, ExecutionEngine *e) } } if (o->flags & SimpleArray) { - for (uint i = 0; i < o->arrayDataLen; ++i) - o->arrayData[i].value.mark(e); + for (uint i = 0; i < o->arrayData.length; ++i) + o->arrayData.data[i].value.mark(e); return; } else { - for (uint i = 0; i < o->arrayDataLen; ++i) { - const Property &pd = o->arrayData[i]; - if (o->arrayAttributes && o->arrayAttributes[i].isAccessor()) { + for (uint i = 0; i < o->arrayData.length; ++i) { + const Property &pd = o->arrayData.data[i]; + if (o->arrayData.attributes && o->arrayData.attributes[i].isAccessor()) { if (pd.getter()) pd.getter()->mark(e); if (pd.setter()) @@ -326,10 +320,10 @@ Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs) { uint pidx = propertyIndexFromArrayIndex(index); if (pidx < UINT_MAX) { - Property *p = arrayData + pidx; - if (!p->value.isEmpty() && !(arrayAttributes && arrayAttributes[pidx].isGeneric())) { + Property *p = arrayData.data + pidx; + if (!p->value.isEmpty() && !(arrayData.attributes && arrayData.attributes[pidx].isGeneric())) { if (attrs) - *attrs = arrayAttributes ? arrayAttributes[pidx] : PropertyAttributes(Attr_Data); + *attrs = arrayData.attributes ? arrayData.attributes[pidx] : PropertyAttributes(Attr_Data); return p; } } @@ -374,10 +368,10 @@ Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attr while (o) { uint pidx = o->propertyIndexFromArrayIndex(index); if (pidx < UINT_MAX) { - Property *p = o->arrayData + pidx; + Property *p = o->arrayData.data + pidx; if (!p->value.isEmpty()) { if (attrs) - *attrs = o->arrayAttributes ? o->arrayAttributes[pidx] : PropertyAttributes(Attr_Data); + *attrs = o->arrayData.attributes ? o->arrayData.attributes[pidx] : PropertyAttributes(Attr_Data); return p; } } @@ -465,9 +459,9 @@ PropertyAttributes Object::queryIndexed(const Managed *m, uint index) const Object *o = static_cast<const Object *>(m); uint pidx = o->propertyIndexFromArrayIndex(index); if (pidx < UINT_MAX) { - if (o->arrayAttributes) - return o->arrayAttributes[pidx]; - if (!o->arrayData[pidx].value.isEmpty()) + if (o->arrayData.attributes) + return o->arrayData.attributes[pidx]; + if (!o->arrayData.data[pidx].value.isEmpty()) return Attr_Data; } if (o->isStringObject()) { @@ -578,9 +572,9 @@ Property *Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name while (it->arrayNode != o->sparseArrayEnd()) { int k = it->arrayNode->key(); uint pidx = it->arrayNode->value; - Property *p = o->arrayData + pidx; + Property *p = o->arrayData.data + pidx; it->arrayNode = it->arrayNode->nextNode(); - PropertyAttributes a = o->arrayAttributes ? o->arrayAttributes[pidx] : PropertyAttributes(Attr_Data); + PropertyAttributes a = o->arrayData.attributes ? o->arrayData.attributes[pidx] : PropertyAttributes(Attr_Data); if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) { it->arrayIndex = k + 1; *index = k; @@ -593,10 +587,10 @@ Property *Object::advanceIterator(Managed *m, ObjectIterator *it, StringRef name it->arrayIndex = UINT_MAX; } // dense arrays - while (it->arrayIndex < o->arrayDataLen) { + while (it->arrayIndex < o->arrayData.length) { uint pidx = o->propertyIndexFromArrayIndex(it->arrayIndex); - Property *p = o->arrayData + pidx; - PropertyAttributes a = o->arrayAttributes ? o->arrayAttributes[pidx] : PropertyAttributes(Attr_Data); + Property *p = o->arrayData.data + pidx; + PropertyAttributes a = o->arrayData.attributes ? o->arrayData.attributes[pidx] : PropertyAttributes(Attr_Data); ++it->arrayIndex; if (!p->value.isEmpty() && (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable())) { @@ -659,10 +653,10 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) while (o) { uint pidx = o->propertyIndexFromArrayIndex(index); if (pidx < UINT_MAX) { - if (!o->arrayData[pidx].value.isEmpty()) { - pd = o->arrayData + pidx; - if (o->arrayAttributes) - attrs = o->arrayAttributes[pidx]; + if (!o->arrayData.data[pidx].value.isEmpty()) { + pd = o->arrayData.data + pidx; + if (o->arrayData.attributes) + attrs = o->arrayData.attributes[pidx]; break; } } @@ -785,9 +779,9 @@ void Object::internalPutIndexed(uint index, const ValueRef value) PropertyAttributes attrs; uint pidx = propertyIndexFromArrayIndex(index); - if (pidx < UINT_MAX && !arrayData[pidx].value.isEmpty()) { - pd = arrayData + pidx; - attrs = arrayAttributes ? arrayAttributes[pidx] : PropertyAttributes(Attr_Data); + if (pidx < UINT_MAX && !arrayData.data[pidx].value.isEmpty()) { + pd = arrayData.data + pidx; + attrs = arrayData.attributes ? arrayData.attributes[pidx] : PropertyAttributes(Attr_Data); } if (!pd && isStringObject()) { @@ -882,16 +876,16 @@ bool Object::internalDeleteIndexedProperty(uint index) uint pidx = propertyIndexFromArrayIndex(index); if (pidx == UINT_MAX) return true; - if (arrayData[pidx].value.isEmpty()) + if (arrayData.data[pidx].value.isEmpty()) return true; - if (!arrayAttributes || arrayAttributes[pidx].isConfigurable()) { - arrayData[pidx].value = Primitive::emptyValue(); - if (arrayAttributes) - arrayAttributes[pidx].clear(); - if (sparseArray) { - arrayData[pidx].value.int_32 = arrayFreeList; - arrayFreeList = pidx; + if (!arrayData.attributes || arrayData.attributes[pidx].isConfigurable()) { + arrayData.data[pidx].value = Primitive::emptyValue(); + if (arrayData.attributes) + arrayData.attributes[pidx].clear(); + if (arrayData.sparse) { + arrayData.data[pidx].value.int_32 = arrayData.freeList; + arrayData.freeList = pidx; } return true; } @@ -975,14 +969,14 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop if (isArrayObject() && index >= arrayLength() && !internalClass->propertyData[ArrayObject::LengthPropertyIndex].isWritable()) goto reject; - if (isNonStrictArgumentsObject) + if (ArgumentsObject::isNonStrictArgumentsObject(this)) return static_cast<ArgumentsObject *>(this)->defineOwnProperty(ctx, index, p, attrs); // Clause 1 { uint pidx = propertyIndexFromArrayIndex(index); - if (pidx < UINT_MAX && !arrayData[pidx].value.isEmpty()) - current = arrayData + pidx; + if (pidx < UINT_MAX && !arrayData.data[pidx].value.isEmpty()) + current = arrayData.data + pidx; if (!current && isStringObject()) current = static_cast<StringObject *>(this)->getIndex(index); } @@ -1014,8 +1008,8 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, Property *current, con PropertyAttributes cattrs = Attr_Data; if (!member.isNull()) cattrs = internalClass->propertyData[current - memberData]; - else if (arrayAttributes) - cattrs = arrayAttributes[current - arrayData]; + else if (arrayData.attributes) + cattrs = arrayData.attributes[current - arrayData.data]; // clause 6 if (p.isSubset(attrs, *current, cattrs)) @@ -1073,8 +1067,8 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, Property *current, con } else { if (cattrs != Attr_Data) ensureArrayAttributes(); - if (arrayAttributes) - arrayAttributes[current - arrayData] = cattrs; + if (arrayData.attributes) + arrayData.attributes[current - arrayData.data] = cattrs; } if (attrs.isAccessor()) hasAccessorProperty = 1; @@ -1108,17 +1102,17 @@ void Object::copyArrayData(Object *other) arraySet(i, (v = other->getIndexed(i))); } } else { - arrayReserve(other->arrayDataLen); - arrayDataLen = other->arrayDataLen; - memcpy(arrayData, other->arrayData, arrayDataLen*sizeof(Property)); + arrayReserve(other->arrayData.length); + arrayData.length = other->arrayData.length; + memcpy(arrayData.data, other->arrayData.data, arrayData.length*sizeof(Property)); } - arrayOffset = 0; + arrayData.offset = 0; - if (other->sparseArray) { + if (other->arrayData.sparse) { flags &= ~SimpleArray; - sparseArray = new SparseArray(*other->sparseArray); - arrayFreeList = other->arrayFreeList; + arrayData.sparse = new SparseArray(*other->arrayData.sparse); + arrayData.freeList = other->arrayData.freeList; } setArrayLengthUnchecked(other->arrayLength()); @@ -1142,27 +1136,27 @@ ReturnedValue Object::arrayIndexOf(const ValueRef v, uint fromIndex, uint endInd if (exists && __qmljs_strict_equal(value, v)) return Encode(i); } - } else if (sparseArray) { - for (SparseArrayNode *n = sparseArray->lowerBound(fromIndex); n != sparseArray->end() && n->key() < endIndex; n = n->nextNode()) { - value = o->getValue(arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data); + } else if (arrayData.sparse) { + for (SparseArrayNode *n = arrayData.sparse->lowerBound(fromIndex); n != arrayData.sparse->end() && n->key() < endIndex; n = n->nextNode()) { + value = o->getValue(arrayData.data + n->value, arrayData.attributes ? arrayData.attributes[n->value] : Attr_Data); if (scope.hasException()) return Encode::undefined(); if (__qmljs_strict_equal(value, v)) return Encode(n->key()); } } else { - if (endIndex > arrayDataLen) - endIndex = arrayDataLen; - Property *pd = arrayData; + if (endIndex > arrayData.length) + endIndex = arrayData.length; + Property *pd = arrayData.data; Property *end = pd + endIndex; pd += fromIndex; while (pd < end) { if (!pd->value.isEmpty()) { - value = o->getValue(pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data); + value = o->getValue(pd, arrayData.attributes ? arrayData.attributes[pd - arrayData.data] : Attr_Data); if (scope.hasException()) return Encode::undefined(); if (__qmljs_strict_equal(value, v)) - return Encode((uint)(pd - arrayData)); + return Encode((uint)(pd - arrayData.data)); } ++pd; } @@ -1172,47 +1166,47 @@ ReturnedValue Object::arrayIndexOf(const ValueRef v, uint fromIndex, uint endInd void Object::arrayConcat(const ArrayObject *other) { - int newLen = arrayDataLen + other->arrayLength(); - if (other->sparseArray) + int newLen = arrayData.length + other->arrayLength(); + if (other->arrayData.sparse) initSparse(); // ### copy attributes as well! - if (sparseArray) { - if (other->sparseArray) { - for (const SparseArrayNode *it = other->sparseArray->begin(); it != other->sparseArray->end(); it = it->nextNode()) - arraySet(arrayDataLen + it->key(), other->arrayData + it->value); + if (arrayData.sparse) { + if (other->arrayData.sparse) { + for (const SparseArrayNode *it = other->arrayData.sparse->begin(); it != other->arrayData.sparse->end(); it = it->nextNode()) + arraySet(arrayData.length + it->key(), other->arrayData.data + it->value); } else { - int oldSize = arrayDataLen; + int oldSize = arrayData.length; arrayReserve(oldSize + other->arrayLength()); - memcpy(arrayData + oldSize, other->arrayData, other->arrayLength()*sizeof(Property)); - if (arrayAttributes) - std::fill(arrayAttributes + oldSize, arrayAttributes + oldSize + other->arrayLength(), PropertyAttributes(Attr_Data)); + memcpy(arrayData.data + oldSize, other->arrayData.data, other->arrayLength()*sizeof(Property)); + if (arrayData.attributes) + std::fill(arrayData.attributes + oldSize, arrayData.attributes + oldSize + other->arrayLength(), PropertyAttributes(Attr_Data)); for (uint i = 0; i < other->arrayLength(); ++i) { - SparseArrayNode *n = sparseArray->insert(arrayDataLen + i); + SparseArrayNode *n = arrayData.sparse->insert(arrayData.length + i); n->value = oldSize + i; } } } else { uint oldSize = arrayLength(); - arrayReserve(oldSize + other->arrayDataLen); - if (oldSize > arrayDataLen) { - for (uint i = arrayDataLen; i < oldSize; ++i) - arrayData[i].value = Primitive::emptyValue(); + arrayReserve(oldSize + other->arrayData.length); + if (oldSize > arrayData.length) { + for (uint i = arrayData.length; i < oldSize; ++i) + arrayData.data[i].value = Primitive::emptyValue(); } - if (other->arrayAttributes) { - for (uint i = 0; i < other->arrayDataLen; ++i) { + if (other->arrayData.attributes) { + for (uint i = 0; i < other->arrayData.length; ++i) { bool exists; - arrayData[oldSize + i].value = const_cast<ArrayObject *>(other)->getIndexed(i, &exists); - arrayDataLen = oldSize + i + 1; - if (arrayAttributes) - arrayAttributes[oldSize + i] = Attr_Data; + arrayData.data[oldSize + i].value = const_cast<ArrayObject *>(other)->getIndexed(i, &exists); + arrayData.length = oldSize + i + 1; + if (arrayData.attributes) + arrayData.attributes[oldSize + i] = Attr_Data; if (!exists) - arrayData[oldSize + i].value = Primitive::emptyValue(); + arrayData.data[oldSize + i].value = Primitive::emptyValue(); } } else { - arrayDataLen = oldSize + other->arrayDataLen; - memcpy(arrayData + oldSize, other->arrayData, other->arrayDataLen*sizeof(Property)); - if (arrayAttributes) - std::fill(arrayAttributes + oldSize, arrayAttributes + oldSize + other->arrayDataLen, PropertyAttributes(Attr_Data)); + arrayData.length = oldSize + other->arrayData.length; + memcpy(arrayData.data + oldSize, other->arrayData.data, other->arrayData.length*sizeof(Property)); + if (arrayData.attributes) + std::fill(arrayData.attributes + oldSize, arrayData.attributes + oldSize + other->arrayData.length, PropertyAttributes(Attr_Data)); } } setArrayLengthUnchecked(newLen); @@ -1220,36 +1214,36 @@ void Object::arrayConcat(const ArrayObject *other) void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint len) { - if (!arrayDataLen) + if (!arrayData.length) return; - if (sparseArray) { + if (arrayData.sparse) { context->throwUnimplemented(QStringLiteral("Object::sort unimplemented for sparse arrays")); return; } - if (len > arrayDataLen) - len = arrayDataLen; + if (len > arrayData.length) + len = arrayData.length; // The spec says the sorting goes through a series of get,put and delete operations. // this implies that the attributes don't get sorted around. // behavior of accessor properties is implementation defined. We simply turn them all // into data properties and then sort. This is in line with the sentence above. - if (arrayAttributes) { + if (arrayData.attributes) { for (uint i = 0; i < len; i++) { - if ((arrayAttributes && arrayAttributes[i].isGeneric()) || arrayData[i].value.isEmpty()) { + if ((arrayData.attributes && arrayData.attributes[i].isGeneric()) || arrayData.data[i].value.isEmpty()) { while (--len > i) - if (!((arrayAttributes && arrayAttributes[len].isGeneric())|| arrayData[len].value.isEmpty())) + if (!((arrayData.attributes && arrayData.attributes[len].isGeneric())|| arrayData.data[len].value.isEmpty())) break; - arrayData[i].value = getValue(arrayData + len, arrayAttributes[len]); - arrayData[len].value = Primitive::emptyValue(); - if (arrayAttributes) { - arrayAttributes[i] = Attr_Data; - arrayAttributes[len].clear(); + arrayData.data[i].value = getValue(arrayData.data + len, arrayData.attributes[len]); + arrayData.data[len].value = Primitive::emptyValue(); + if (arrayData.attributes) { + arrayData.attributes[i] = Attr_Data; + arrayData.attributes[len].clear(); } - } else if (arrayAttributes[i].isAccessor()) { - arrayData[i].value = getValue(arrayData + i, arrayAttributes[i]); - arrayAttributes[i] = Attr_Data; + } else if (arrayData.attributes[i].isAccessor()) { + arrayData.data[i].value = getValue(arrayData.data + i, arrayData.attributes[i]); + arrayData.attributes[i] = Attr_Data; } } } @@ -1263,38 +1257,38 @@ void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const Va if (!len) return; - Property *begin = arrayData; + Property *begin = arrayData.data; std::sort(begin, begin + len, lessThan); } void Object::initSparse() { - if (!sparseArray) { + if (!arrayData.sparse) { flags &= ~SimpleArray; - sparseArray = new SparseArray; - for (uint i = 0; i < arrayDataLen; ++i) { - if (!((arrayAttributes && arrayAttributes[i].isGeneric()) || arrayData[i].value.isEmpty())) { - SparseArrayNode *n = sparseArray->insert(i); - n->value = i + arrayOffset; + arrayData.sparse = new SparseArray; + for (uint i = 0; i < arrayData.length; ++i) { + if (!((arrayData.attributes && arrayData.attributes[i].isGeneric()) || arrayData.data[i].value.isEmpty())) { + SparseArrayNode *n = arrayData.sparse->insert(i); + n->value = i + arrayData.offset; } } - uint off = arrayOffset; - if (!arrayOffset) { - arrayFreeList = arrayDataLen; + uint off = arrayData.offset; + if (!arrayData.offset) { + arrayData.freeList = arrayData.length; } else { - arrayFreeList = 0; - arrayData -= off; - arrayAlloc += off; + arrayData.freeList = 0; + arrayData.data -= off; + arrayData.alloc += off; int o = off; for (int i = 0; i < o - 1; ++i) { - arrayData[i].value = Primitive::fromInt32(i + 1); + arrayData.data[i].value = Primitive::fromInt32(i + 1); } - arrayData[o - 1].value = Primitive::fromInt32(arrayDataLen + off); + arrayData.data[o - 1].value = Primitive::fromInt32(arrayData.length + off); } - for (uint i = arrayDataLen + off; i < arrayAlloc; ++i) { - arrayData[i].value = Primitive::fromInt32(i + 1); + for (uint i = arrayData.length + off; i < arrayData.alloc; ++i) { + arrayData.data[i].value = Primitive::fromInt32(i + 1); } } } @@ -1303,39 +1297,39 @@ void Object::arrayReserve(uint n) { if (n < 8) n = 8; - if (n >= arrayAlloc) { + if (n >= arrayData.alloc) { uint off; - if (sparseArray) { - assert(arrayFreeList == arrayAlloc); + if (arrayData.sparse) { + assert(arrayData.freeList == arrayData.alloc); // ### FIXME - arrayDataLen = arrayAlloc; + arrayData.length = arrayData.alloc; off = 0; } else { - off = arrayOffset; + off = arrayData.offset; } - arrayAlloc = qMax(n, 2*arrayAlloc); - Property *newArrayData = new Property[arrayAlloc + off]; - if (arrayData) { - memcpy(newArrayData + off, arrayData, sizeof(Property)*arrayDataLen); - delete [] (arrayData - off); + arrayData.alloc = qMax(n, 2*arrayData.alloc); + Property *newArrayData = new Property[arrayData.alloc + off]; + if (arrayData.data) { + memcpy(newArrayData + off, arrayData.data, sizeof(Property)*arrayData.length); + delete [] (arrayData.data - off); } - arrayData = newArrayData + off; - if (sparseArray) { - for (uint i = arrayFreeList; i < arrayAlloc; ++i) { - arrayData[i].value = Primitive::emptyValue(); - arrayData[i].value = Primitive::fromInt32(i + 1); + arrayData.data = newArrayData + off; + if (arrayData.sparse) { + for (uint i = arrayData.freeList; i < arrayData.alloc; ++i) { + arrayData.data[i].value = Primitive::emptyValue(); + arrayData.data[i].value = Primitive::fromInt32(i + 1); } } - if (arrayAttributes) { - PropertyAttributes *newAttrs = new PropertyAttributes[arrayAlloc]; - memcpy(newAttrs, arrayAttributes, sizeof(PropertyAttributes)*arrayDataLen); - delete [] (arrayAttributes - off); + if (arrayData.attributes) { + PropertyAttributes *newAttrs = new PropertyAttributes[arrayData.alloc]; + memcpy(newAttrs, arrayData.attributes, sizeof(PropertyAttributes)*arrayData.length); + delete [] (arrayData.attributes - off); - arrayAttributes = newAttrs; - if (sparseArray) { - for (uint i = arrayFreeList; i < arrayAlloc; ++i) - arrayAttributes[i] = Attr_Invalid; + arrayData.attributes = newAttrs; + if (arrayData.sparse) { + for (uint i = arrayData.freeList; i < arrayData.alloc; ++i) + arrayData.attributes[i] = Attr_Invalid; } } } @@ -1343,17 +1337,17 @@ void Object::arrayReserve(uint n) void Object::ensureArrayAttributes() { - if (arrayAttributes) + if (arrayData.attributes) return; flags &= ~SimpleArray; - uint off = sparseArray ? 0 : arrayOffset; - arrayAttributes = new PropertyAttributes[arrayAlloc + off]; - arrayAttributes += off; - for (uint i = 0; i < arrayDataLen; ++i) - arrayAttributes[i] = Attr_Data; - for (uint i = arrayDataLen; i < arrayAlloc; ++i) - arrayAttributes[i] = Attr_Invalid; + uint off = arrayData.sparse ? 0 : arrayData.offset; + arrayData.attributes = new PropertyAttributes[arrayData.alloc + off]; + arrayData.attributes += off; + for (uint i = 0; i < arrayData.length; ++i) + arrayData.attributes[i] = Attr_Data; + for (uint i = arrayData.length; i < arrayData.alloc; ++i) + arrayData.attributes[i] = Attr_Invalid; } @@ -1365,48 +1359,48 @@ bool Object::setArrayLength(uint newLen) { uint oldLen = arrayLength(); bool ok = true; if (newLen < oldLen) { - if (sparseArray) { - SparseArrayNode *begin = sparseArray->lowerBound(newLen); - if (begin != sparseArray->end()) { - SparseArrayNode *it = sparseArray->end()->previousNode(); + if (arrayData.sparse) { + SparseArrayNode *begin = arrayData.sparse->lowerBound(newLen); + if (begin != arrayData.sparse->end()) { + SparseArrayNode *it = arrayData.sparse->end()->previousNode(); while (1) { - Property &pd = arrayData[it->value]; - if (arrayAttributes) { - if (!arrayAttributes[it->value].isConfigurable()) { + Property &pd = arrayData.data[it->value]; + if (arrayData.attributes) { + if (!arrayData.attributes[it->value].isConfigurable()) { ok = false; newLen = it->key() + 1; break; } else { - arrayAttributes[it->value].clear(); + arrayData.attributes[it->value].clear(); } } pd.value.tag = Value::Empty_Type; - pd.value.int_32 = arrayFreeList; - arrayFreeList = it->value; + pd.value.int_32 = arrayData.freeList; + arrayData.freeList = it->value; bool brk = (it == begin); SparseArrayNode *prev = it->previousNode(); - sparseArray->erase(it); + arrayData.sparse->erase(it); if (brk) break; it = prev; } } } else { - Property *it = arrayData + arrayDataLen; - const Property *begin = arrayData + newLen; + Property *it = arrayData.data + arrayData.length; + const Property *begin = arrayData.data + newLen; while (--it >= begin) { - if (arrayAttributes) { - if (!arrayAttributes[it - arrayData].isEmpty() && !arrayAttributes[it - arrayData].isConfigurable()) { + if (arrayData.attributes) { + if (!arrayData.attributes[it - arrayData.data].isEmpty() && !arrayData.attributes[it - arrayData.data].isConfigurable()) { ok = false; - newLen = it - arrayData + 1; + newLen = it - arrayData.data + 1; break; } else { - arrayAttributes[it - arrayData].clear(); + arrayData.attributes[it - arrayData.data].clear(); } it->value = Primitive::emptyValue(); } } - arrayDataLen = newLen; + arrayData.length = newLen; } } else { if (newLen >= 0x100000) @@ -1432,8 +1426,8 @@ ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) int len = list.count(); arrayReserve(len); for (int ii = 0; ii < len; ++ii) { - arrayData[ii].value = Encode(engine->newString(list.at(ii))); - arrayDataLen = ii + 1; + arrayData.data[ii].value = Encode(engine->newString(list.at(ii))); + arrayData.length = ii + 1; } setArrayLengthUnchecked(len); } @@ -1442,7 +1436,6 @@ void ArrayObject::init(ExecutionEngine *engine) { Q_UNUSED(engine); - type = Type_ArrayObject; memberData[LengthPropertyIndex].value = Primitive::fromInt32(0); } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 23f2f682fd..5f6cd879de 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -102,18 +102,25 @@ struct URIErrorPrototype; struct Q_QML_EXPORT Object: Managed { Q_MANAGED + Q_MANAGED_TYPE(Object) + enum { + IsObject = true + }; uint memberDataAlloc; Property *memberData; - union { - uint arrayFreeList; - uint arrayOffset; + struct ArrayData { + union { + uint freeList; + uint offset; + }; + uint length; + uint alloc; + PropertyAttributes *attributes; + Property *data; + SparseArray *sparse; }; - uint arrayDataLen; - uint arrayAlloc; - PropertyAttributes *arrayAttributes; - Property *arrayData; - SparseArray *sparseArray; + ArrayData arrayData; enum { InlinePropertySize = 4 @@ -173,42 +180,42 @@ struct Q_QML_EXPORT Object: Managed { // Array handling uint allocArrayValue() { - uint idx = arrayFreeList; - if (arrayAlloc <= arrayFreeList) - arrayReserve(arrayAlloc + 1); - arrayFreeList = arrayData[arrayFreeList].value.uint_32; - if (arrayAttributes) - arrayAttributes[idx].setType(PropertyAttributes::Data); + uint idx = arrayData.freeList; + if (arrayData.alloc <= arrayData.freeList) + arrayReserve(arrayData.alloc + 1); + arrayData.freeList = arrayData.data[arrayData.freeList].value.uint_32; + if (arrayData.attributes) + arrayData.attributes[idx].setType(PropertyAttributes::Data); return idx; } uint allocArrayValue(const ValueRef v) { uint idx = allocArrayValue(); - Property *pd = &arrayData[idx]; + Property *pd = &arrayData.data[idx]; pd->value = *v; return idx; } void freeArrayValue(int idx) { - Property &pd = arrayData[idx]; + Property &pd = arrayData.data[idx]; pd.value.tag = Value::Empty_Type; - pd.value.int_32 = arrayFreeList; - arrayFreeList = idx; - if (arrayAttributes) - arrayAttributes[idx].clear(); + pd.value.int_32 = arrayData.freeList; + arrayData.freeList = idx; + if (arrayData.attributes) + arrayData.attributes[idx].clear(); } void getArrayHeadRoom() { - assert(!sparseArray && !arrayOffset); - arrayOffset = qMax(arrayDataLen >> 2, (uint)16); - Property *newArray = new Property[arrayOffset + arrayAlloc]; - memcpy(newArray + arrayOffset, arrayData, arrayDataLen*sizeof(Property)); - delete [] arrayData; - arrayData = newArray + arrayOffset; - if (arrayAttributes) { - PropertyAttributes *newAttrs = new PropertyAttributes[arrayOffset + arrayAlloc]; - memcpy(newAttrs + arrayOffset, arrayAttributes, arrayDataLen*sizeof(PropertyAttributes)); - delete [] arrayAttributes; - arrayAttributes = newAttrs + arrayOffset; + assert(!arrayData.sparse && !arrayData.offset); + arrayData.offset = qMax(arrayData.length >> 2, (uint)16); + Property *newArray = new Property[arrayData.offset + arrayData.alloc]; + memcpy(newArray + arrayData.offset, arrayData.data, arrayData.length*sizeof(Property)); + delete [] arrayData.data; + arrayData.data = newArray + arrayData.offset; + if (arrayData.attributes) { + PropertyAttributes *newAttrs = new PropertyAttributes[arrayData.offset + arrayData.alloc]; + memcpy(newAttrs + arrayData.offset, arrayData.attributes, arrayData.length*sizeof(PropertyAttributes)); + delete [] arrayData.attributes; + arrayData.attributes = newAttrs + arrayData.offset; } } @@ -228,12 +235,12 @@ public: uint propertyIndexFromArrayIndex(uint index) const { - if (!sparseArray) { - if (index >= arrayDataLen) + if (!arrayData.sparse) { + if (index >= arrayData.length) return UINT_MAX; return index; } else { - SparseArrayNode *n = sparseArray->findNode(index); + SparseArrayNode *n = arrayData.sparse->findNode(index); if (!n) return UINT_MAX; return n->value; @@ -244,25 +251,25 @@ public: uint pidx = propertyIndexFromArrayIndex(index); if (pidx == UINT_MAX) return 0; - return arrayData + pidx; + return arrayData.data + pidx; } Property *nonSparseArrayAt(uint index) const { - if (sparseArray) + if (arrayData.sparse) return 0; - if (index >= arrayDataLen) + if (index >= arrayData.length) return 0; - return arrayData + index; + return arrayData.data + index; } void push_back(const ValueRef v); - SparseArrayNode *sparseArrayBegin() { return sparseArray ? sparseArray->begin() : 0; } - SparseArrayNode *sparseArrayEnd() { return sparseArray ? sparseArray->end() : 0; } + SparseArrayNode *sparseArrayBegin() { return arrayData.sparse ? arrayData.sparse->begin() : 0; } + SparseArrayNode *sparseArrayEnd() { return arrayData.sparse ? arrayData.sparse->end() : 0; } void arrayConcat(const ArrayObject *other); - void arraySort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint arrayDataLen); - ReturnedValue arrayIndexOf(const ValueRef v, uint fromIndex, uint arrayDataLen, ExecutionContext *ctx, Object *o); + void arraySort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint dataLen); + ReturnedValue arrayIndexOf(const ValueRef v, uint fromIndex, uint dataLen, ExecutionContext *ctx, Object *o); void arrayReserve(uint n); void ensureArrayAttributes(); @@ -272,7 +279,7 @@ public: Scoped<Object> p(scope, this); while ((p = p->prototype())) - if (p->arrayDataLen) + if (p->arrayData.length) return true; return false; @@ -328,40 +335,39 @@ private: struct BooleanObject: Object { Q_MANAGED + Q_MANAGED_TYPE(BooleanObject) SafeValue value; BooleanObject(ExecutionEngine *engine, const ValueRef val) : Object(engine->booleanClass) { - type = Type_BooleanObject; value = val; } protected: BooleanObject(InternalClass *ic) : Object(ic) { - setVTable(&static_vtbl); - type = Type_BooleanObject; + Q_ASSERT(internalClass->vtable == &static_vtbl); value = Encode(false); } }; struct NumberObject: Object { Q_MANAGED + Q_MANAGED_TYPE(NumberObject) SafeValue value; NumberObject(ExecutionEngine *engine, const ValueRef val) : Object(engine->numberClass) { - type = Type_NumberObject; value = val; } protected: NumberObject(InternalClass *ic) : Object(ic) { - setVTable(&static_vtbl); - type = Type_NumberObject; + Q_ASSERT(internalClass->vtable == &static_vtbl); value = Encode((int)0); } }; struct ArrayObject: Object { Q_MANAGED + Q_MANAGED_TYPE(ArrayObject) enum { LengthPropertyIndex = 0 }; @@ -397,14 +403,14 @@ inline void Object::setArrayLengthUnchecked(uint l) inline void Object::push_back(const ValueRef v) { uint idx = arrayLength(); - if (!sparseArray) { - if (idx >= arrayAlloc) + if (!arrayData.sparse) { + if (idx >= arrayData.alloc) arrayReserve(idx + 1); - arrayData[idx].value = *v; - arrayDataLen = idx + 1; + arrayData.data[idx].value = *v; + arrayData.length = idx + 1; } else { uint idx = allocArrayValue(v); - sparseArray->push_back(idx, arrayLength()); + arrayData.sparse->push_back(idx, arrayLength()); } setArrayLengthUnchecked(idx + 1); } @@ -414,33 +420,33 @@ inline Property *Object::arrayInsert(uint index, PropertyAttributes attributes) hasAccessorProperty = 1; Property *pd; - if (!sparseArray && (index < 0x1000 || index < arrayDataLen + (arrayDataLen >> 2))) { - if (index >= arrayAlloc) + if (!arrayData.sparse && (index < 0x1000 || index < arrayData.length + (arrayData.length >> 2))) { + if (index >= arrayData.alloc) arrayReserve(index + 1); - if (index >= arrayDataLen) { + if (index >= arrayData.length) { // mark possible hole in the array - for (uint i = arrayDataLen; i < index; ++i) { - arrayData[i].value = Primitive::emptyValue(); - if (arrayAttributes) - arrayAttributes[i].clear(); + for (uint i = arrayData.length; i < index; ++i) { + arrayData.data[i].value = Primitive::emptyValue(); + if (arrayData.attributes) + arrayData.attributes[i].clear(); } - arrayDataLen = index + 1; + arrayData.length = index + 1; } - pd = arrayData + index; + pd = arrayData.data + index; } else { initSparse(); - SparseArrayNode *n = sparseArray->insert(index); + SparseArrayNode *n = arrayData.sparse->insert(index); if (n->value == UINT_MAX) n->value = allocArrayValue(); - pd = arrayData + n->value; + pd = arrayData.data + n->value; } if (index >= arrayLength()) setArrayLengthUnchecked(index + 1); - if (arrayAttributes || attributes != Attr_Data) { - if (!arrayAttributes) + if (arrayData.attributes || attributes != Attr_Data) { + if (!arrayData.attributes) ensureArrayAttributes(); attributes.resolve(); - arrayAttributes[pd - arrayData] = attributes; + arrayData.attributes[pd - arrayData.data] = attributes; } return pd; } diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 04fa504991..f7a5cd7531 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -58,7 +58,7 @@ ObjectIterator::ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const current = o; tmpDynamicProperty.value = Primitive::undefinedValue(); - if (object && object->isNonStrictArgumentsObject) { + if (object && object->asArgumentsObject()) { Scope scope(object->engine()); Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate(); } @@ -76,7 +76,7 @@ ObjectIterator::ObjectIterator(Scope &scope, const ObjectRef o, uint flags) current = o; tmpDynamicProperty.value = Primitive::undefinedValue(); - if (object && object->isNonStrictArgumentsObject) { + if (object && object->asArgumentsObject()) { Scope scope(object->engine()); Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate(); } diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index 6c333b328c..33228cefaa 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -86,11 +86,11 @@ struct Q_QML_EXPORT ObjectIterator struct ForEachIteratorObject: Object { Q_MANAGED + Q_MANAGED_TYPE(ForeachIteratorObject) ObjectIterator it; ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o) : Object(ctx->engine), it(workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { setVTable(&static_vtbl); - type = Type_ForeachIteratorObject; } ReturnedValue nextPropertyName() { return it.nextPropertyNameAsString(); } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 7ca790b970..31287d0e9f 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -105,9 +105,9 @@ ReturnedValue ObjectCtor::call(Managed *m, CallData *callData) void ObjectPrototype::init(ExecutionEngine *v4, ObjectRef ctor) { Scope scope(v4); - ScopedObject o(scope); + ScopedObject o(scope, this); - ctor->defineReadonlyProperty(v4->id_prototype, (o = this)); + ctor->defineReadonlyProperty(v4->id_prototype, o); ctor->defineReadonlyProperty(v4->id_length, Primitive::fromInt32(1)); ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2); @@ -157,7 +157,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(CallContext *ctx) if (!O) return ctx->throwTypeError(); - if (O->isNonStrictArgumentsObject) + if (ArgumentsObject::isNonStrictArgumentsObject(O.getPointer())) Scoped<ArgumentsObject>(scope, O)->fullyCreate(); ScopedValue v(scope, ctx->argument(1)); @@ -272,9 +272,9 @@ ReturnedValue ObjectPrototype::method_seal(CallContext *ctx) o->internalClass = o->internalClass->sealed(); o->ensureArrayAttributes(); - for (uint i = 0; i < o->arrayDataLen; ++i) { - if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty())) - o->arrayAttributes[i].setConfigurable(false); + for (uint i = 0; i < o->arrayData.length; ++i) { + if (!(o->arrayData.attributes[i].isGeneric() || o->arrayData.data[i].value.isEmpty())) + o->arrayData.attributes[i].setConfigurable(false); } return o.asReturnedValue(); @@ -287,7 +287,7 @@ ReturnedValue ObjectPrototype::method_freeze(CallContext *ctx) if (!o) return ctx->throwTypeError(); - if (o->isNonStrictArgumentsObject) + if (ArgumentsObject::isNonStrictArgumentsObject(o.getPointer())) Scoped<ArgumentsObject>(scope, o)->fullyCreate(); o->extensible = false; @@ -295,11 +295,11 @@ ReturnedValue ObjectPrototype::method_freeze(CallContext *ctx) o->internalClass = o->internalClass->frozen(); o->ensureArrayAttributes(); - for (uint i = 0; i < o->arrayDataLen; ++i) { - if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty())) - o->arrayAttributes[i].setConfigurable(false); - if (o->arrayAttributes[i].isData()) - o->arrayAttributes[i].setWritable(false); + for (uint i = 0; i < o->arrayData.length; ++i) { + if (!(o->arrayData.attributes[i].isGeneric() || o->arrayData.data[i].value.isEmpty())) + o->arrayData.attributes[i].setConfigurable(false); + if (o->arrayData.attributes[i].isData()) + o->arrayData.attributes[i].setWritable(false); } return o.asReturnedValue(); } @@ -328,15 +328,15 @@ ReturnedValue ObjectPrototype::method_isSealed(CallContext *ctx) if (o->internalClass != o->internalClass->sealed()) return Encode(false); - if (!o->arrayDataLen) + if (!o->arrayData.length) return Encode(true); - if (!o->arrayAttributes) + if (!o->arrayData.attributes) return Encode(false); - for (uint i = 0; i < o->arrayDataLen; ++i) { - if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty())) - if (o->arrayAttributes[i].isConfigurable()) + for (uint i = 0; i < o->arrayData.length; ++i) { + if (!(o->arrayData.attributes[i].isGeneric() || o->arrayData.data[i].value.isEmpty())) + if (o->arrayData.attributes[i].isConfigurable()) return Encode(false); } @@ -356,15 +356,15 @@ ReturnedValue ObjectPrototype::method_isFrozen(CallContext *ctx) if (o->internalClass != o->internalClass->frozen()) return Encode(false); - if (!o->arrayDataLen) + if (!o->arrayData.length) return Encode(true); - if (!o->arrayAttributes) + if (!o->arrayData.attributes) return Encode(false); - for (uint i = 0; i < o->arrayDataLen; ++i) { - if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty())) - if (o->arrayAttributes[i].isConfigurable() || o->arrayAttributes[i].isWritable()) + for (uint i = 0; i < o->arrayData.length; ++i) { + if (!(o->arrayData.attributes[i].isGeneric() || o->arrayData.data[i].value.isEmpty())) + if (o->arrayData.attributes[i].isConfigurable() || o->arrayData.attributes[i].isWritable()) return Encode(false); } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 61f92a0f5c..4293cca327 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1690,8 +1690,8 @@ QV4::ReturnedValue CallArgument::toValue(QV8Engine *engine) QV4::Scoped<ArrayObject> array(scope, v4->newArrayObject()); array->arrayReserve(list.count()); for (int ii = 0; ii < list.count(); ++ii) { - array->arrayData[ii].value = QV4::QObjectWrapper::wrap(v4, list.at(ii)); - array->arrayDataLen = ii + 1; + array->arrayData.data[ii].value = QV4::QObjectWrapper::wrap(v4, list.at(ii)); + array->arrayData.length = ii + 1; } array->setArrayLengthUnchecked(list.count()); return array.asReturnedValue(); diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 41ff9f9741..8544970347 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -99,8 +99,6 @@ RegExp::RegExp(ExecutionEngine* engine, const QString &pattern, bool ignoreCase, , m_ignoreCase(ignoreCase) , m_multiLine(multiline) { - type = Type_RegExpObject; - if (!engine) return; const char* error = 0; diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index 9041ff2ef4..d8e9930876 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -94,6 +94,7 @@ public: class RegExp : public Managed { Q_MANAGED + Q_MANAGED_TYPE(RegExp) public: static RegExp* create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); ~RegExp(); diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 468fb34d76..e8d92efb58 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -76,6 +76,7 @@ RegExpObject::RegExpObject(InternalClass *ic) , value(RegExp::create(ic->engine, QString(), false, false)) , global(false) { + Q_ASSERT(internalClass->vtable == &static_vtbl); init(ic->engine); } @@ -143,7 +144,6 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, const QRegExp &re) void RegExpObject::init(ExecutionEngine *engine) { setVTable(&static_vtbl); - type = Type_RegExpObject; Scope scope(engine); ScopedObject protectThis(scope, this); @@ -347,8 +347,8 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) for (int i = 0; i < len; ++i) { int start = matchOffsets[i * 2]; int end = matchOffsets[i * 2 + 1]; - array->arrayData[i].value = (start != -1 && end != -1) ? ctx->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined(); - array->arrayDataLen = i + 1; + array->arrayData.data[i].value = (start != -1 && end != -1) ? ctx->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined(); + array->arrayData.length = i + 1; } array->setArrayLengthUnchecked(len); diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 0129f8d396..bd91e8f693 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -67,6 +67,7 @@ class RegExp; struct RegExpObject: Object { Q_MANAGED + Q_MANAGED_TYPE(RegExpObject) // needs to be compatible with the flags in qv4jsir_p.h enum Flags { RegExp_Global = 0x01, diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 011607f0ba..304a4a4f0e 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -591,9 +591,9 @@ ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object, if (idx < UINT_MAX) { uint pidx = o->propertyIndexFromArrayIndex(idx); if (pidx < UINT_MAX) { - if (!o->arrayAttributes || o->arrayAttributes[pidx].isData()) { - if (!o->arrayData[pidx].value.isEmpty()) - return o->arrayData[pidx].value.asReturnedValue(); + if (!o->arrayData.attributes || o->arrayData.attributes[pidx].isData()) { + if (!o->arrayData.data[pidx].value.isEmpty()) + return o->arrayData.data[pidx].value.asReturnedValue(); } } @@ -617,19 +617,19 @@ void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const Val if (idx < UINT_MAX) { uint pidx = o->propertyIndexFromArrayIndex(idx); if (pidx < UINT_MAX) { - if (o->arrayAttributes && !o->arrayAttributes[pidx].isEmpty() && !o->arrayAttributes[pidx].isWritable()) { + if (o->arrayData.attributes && !o->arrayData.attributes[pidx].isEmpty() && !o->arrayData.attributes[pidx].isWritable()) { if (ctx->strictMode) ctx->throwTypeError(); return; } - Property *p = o->arrayData + pidx; - if (!o->arrayAttributes || o->arrayAttributes[pidx].isData()) { + Property *p = o->arrayData.data + pidx; + if (!o->arrayData.attributes || o->arrayData.attributes[pidx].isData()) { p->value = *value; return; } - if (o->arrayAttributes[pidx].isAccessor()) { + if (o->arrayData.attributes[pidx].isAccessor()) { FunctionObject *setter = p->setter(); if (!setter) { if (ctx->strictMode) @@ -1131,8 +1131,8 @@ ReturnedValue __qmljs_builtin_define_array(ExecutionContext *ctx, Value *values, // This should rather be done when required a->arrayReserve(length); if (length) { - a->arrayDataLen = length; - Property *pd = a->arrayData; + a->arrayData.length = length; + Property *pd = a->arrayData.data; for (uint i = 0; i < length; ++i) { pd->value = values[i]; ++pd; diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 8b0e31cb71..988762c842 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -166,6 +166,7 @@ template <typename Container> class QQmlSequence : public QV4::Object { Q_MANAGED + Q_MANAGED_TYPE(QmlSequence) public: QQmlSequence(QV4::ExecutionEngine *engine, const Container &container) : QV4::Object(InternalClass::create(engine, &static_vtbl, engine->sequencePrototype.asObject())) @@ -174,7 +175,6 @@ public: , m_propertyIndex(-1) , m_isReference(false) { - type = Type_QmlSequence; flags &= ~SimpleArray; QV4::Scope scope(engine); QV4::ScopedObject protectThis(scope, this); @@ -188,7 +188,6 @@ public: , m_propertyIndex(propertyIndex) , m_isReference(true) { - type = Type_QmlSequence; flags &= ~SimpleArray; QV4::Scope scope(engine); QV4::ScopedObject protectThis(scope, this); diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index ee325db4c2..b199c86d78 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -390,8 +390,8 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) array->arrayReserve(seqLength); for (quint32 ii = 0; ii < seqLength; ++ii) { value = deserialize(data, engine); - array->arrayData[ii].value = value.asReturnedValue(); - array->arrayDataLen = ii + 1; + array->arrayData.data[ii].value = value.asReturnedValue(); + array->arrayData.length = ii + 1; } array->setArrayLengthUnchecked(seqLength); QVariant seqVariant = QV4::SequencePrototype::toVariant(array, sequenceType, &succeeded); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index e5633eb06f..b97b23bf44 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -103,6 +103,13 @@ static uint toArrayIndex(const char *ch, const char *end, bool *ok) const ManagedVTable String::static_vtbl = { + String::IsExecutionContext, + String::IsString, + String::IsObject, + String::IsFunctionObject, + String::IsErrorObject, + 0, + String::MyType, call, construct, markObjects, @@ -233,10 +240,9 @@ bool String::isEqualTo(Managed *t, Managed *o) if (t == o) return true; - if (o->type != Type_String) + if (!o->internalClass->vtable->isString) return false; - Q_ASSERT(t->type == Type_String); String *that = static_cast<String *>(t); String *other = static_cast<String *>(o); if (that->hashValue() != other->hashValue()) @@ -257,7 +263,6 @@ String::String(ExecutionEngine *engine, const QString &text) { _text->ref.ref(); len = _text->size; - type = Type_String; subtype = StringType_Unknown; } @@ -267,7 +272,6 @@ String::String(ExecutionEngine *engine, String *l, String *r) , stringHash(UINT_MAX), largestSubLength(qMax(l->largestSubLength, r->largestSubLength)) , len(l->len + r->len) { - type = Type_String; subtype = StringType_Unknown; if (!l->largestSubLength && l->len > largestSubLength) diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 64e15b04c2..7e2824d8a0 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -53,6 +53,11 @@ struct Identifier; struct Q_QML_EXPORT String : public Managed { Q_MANAGED + Q_MANAGED_TYPE(String) + enum { + IsString = true + }; + enum StringType { StringType_Unknown, StringType_Regular, @@ -63,7 +68,7 @@ struct Q_QML_EXPORT String : public Managed { String() : Managed(0), _text(QStringData::sharedNull()), identifier(0) , stringHash(UINT_MAX), largestSubLength(0), len(0) - { type = Type_String; subtype = StringType_Unknown; } + { subtype = StringType_Unknown; } String(ExecutionEngine *engine, const QString &text); String(ExecutionEngine *engine, String *l, String *n); ~String() { diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index d468fb6b83..3d90c812c4 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -80,8 +80,7 @@ DEFINE_MANAGED_VTABLE(StringObject); StringObject::StringObject(InternalClass *ic) : Object(ic) { - setVTable(&static_vtbl); - type = Type_StringObject; + Q_ASSERT(internalClass->vtable == &static_vtbl); Scope scope(engine()); ScopedObject protectThis(scope, this); @@ -97,7 +96,6 @@ StringObject::StringObject(ExecutionEngine *engine, const ValueRef val) : Object(engine->stringObjectClass) { setVTable(&static_vtbl); - type = Type_StringObject; Scope scope(engine); ScopedObject protectThis(scope, this); @@ -147,7 +145,7 @@ Property *StringObject::advanceIterator(Managed *m, ObjectIterator *it, StringRe *index = it->arrayIndex; ++it->arrayIndex; if (attrs) - *attrs = s->arrayAttributes ? s->arrayAttributes[it->arrayIndex] : PropertyAttributes(Attr_NotWritable|Attr_NotConfigurable); + *attrs = s->arrayData.attributes ? s->arrayData.attributes[it->arrayIndex] : PropertyAttributes(Attr_NotWritable|Attr_NotConfigurable); return s->__getOwnProperty__(*index); } it->arrayNode = s->sparseArrayBegin(); diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index e8e46b85e7..b91cc48e36 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -51,6 +51,7 @@ namespace QV4 { struct StringObject: Object { Q_MANAGED + Q_MANAGED_TYPE(StringObject) SafeValue value; mutable Property tmpProperty; diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 680c7465ca..b93fcbe4bd 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -64,13 +64,13 @@ inline bool Value::isString() const { if (!isManaged()) return false; - return managed() && managed()->type == Managed::Type_String; + return managed() && managed()->internalClass->vtable->isString; } inline bool Value::isObject() const { if (!isManaged()) return false; - return managed() && managed()->type != Managed::Type_String; + return managed() && managed()->internalClass->vtable->isObject; } inline bool Value::isPrimitive() const diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 3dd9d6a14d..6717c97d88 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -2882,7 +2882,7 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod Object::DynamicProperty::Type dtype; int metaType; } builtinTypes[] = { - { Object::DynamicProperty::Var, QMetaType::QVariant }, + { Object::DynamicProperty::Var, qMetaTypeId<QJSValue>() }, { Object::DynamicProperty::Variant, QMetaType::QVariant }, { Object::DynamicProperty::Int, QMetaType::Int }, { Object::DynamicProperty::Bool, QMetaType::Bool }, diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index 516f6653ca..d410d396e3 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -157,6 +157,8 @@ public: // index in first hash is component index, hash inside maps from object index in that scope to integer id QHash<int, QHash<int, int> > objectIndexToIdPerComponent; QHash<int, int> objectIndexToIdForRoot; + // hash key is object index + QHash<int, QByteArray> customParserData; QVector<int> customParserBindings; // index is binding identifier, value is compiled function index. bool isComponent(int objectIndex) const { return objectIndexToIdPerComponent.contains(objectIndex); } diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 21bcd3569c..5813415347 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1056,7 +1056,11 @@ void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, p->compiledData = d->cc; p->compiledData->addref(); - p->vme.init(contextData, d->cc, d->start, d->creationContext); + if (enginePriv->useNewCompiler) { + p->creator.reset(new QmlObjectCreator(contextData, d->cc)); + p->subComponentToCreate = d->start; + } else + p->vme.init(contextData, d->cc, d->start, d->creationContext); enginePriv->incubate(incubator, forContextData); } diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index 19e49009ce..0cc62fb988 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -230,6 +230,13 @@ void QQmlCustomParser::clearErrors() exceptions.clear(); } +QByteArray QQmlCustomParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) +{ + Q_UNUSED(qmlUnit) + Q_UNUSED(bindings) + return QByteArray(); +} + /*! Reports an error with the given \a description. @@ -256,7 +263,6 @@ void QQmlCustomParser::error(const QString& description) void QQmlCustomParser::error(const QQmlCustomParserProperty& prop, const QString& description) { QQmlError error; - QString exceptionDescription; error.setLine(prop.location().line); error.setColumn(prop.location().column); error.setDescription(description); @@ -271,7 +277,6 @@ void QQmlCustomParser::error(const QQmlCustomParserProperty& prop, const QString void QQmlCustomParser::error(const QQmlCustomParserNode& node, const QString& description) { QQmlError error; - QString exceptionDescription; error.setLine(node.location().line); error.setColumn(node.location().column); error.setDescription(description); @@ -279,6 +284,20 @@ void QQmlCustomParser::error(const QQmlCustomParserNode& node, const QString& de } /*! + Reports an error in parsing \a binding, with the given \a description. + + An error is generated referring to the position of \a node in the source file. +*/ +void QQmlCustomParser::error(const QV4::CompiledData::Binding *binding, const QString &description) +{ + QQmlError error; + error.setLine(binding->location.line); + error.setColumn(binding->location.column); + error.setDescription(description); + exceptions << error; +} + +/*! If \a script is a simple enumeration expression (eg. Text.AlignLeft), returns the integer equivalent (eg. 1), and sets \a ok to true. diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h index 27f7e00b31..3004b0f50c 100644 --- a/src/qml/qml/qqmlcustomparser_p.h +++ b/src/qml/qml/qqmlcustomparser_p.h @@ -126,6 +126,7 @@ public: Flags flags() const { return m_flags; } virtual QByteArray compile(const QList<QQmlCustomParserProperty> &)=0; + virtual QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings); // ### make pure virtual virtual void setCustomData(QObject *, const QByteArray &)=0; QList<QQmlError> errors() const { return exceptions; } @@ -134,6 +135,7 @@ protected: void error(const QString& description); void error(const QQmlCustomParserProperty&, const QString& description); void error(const QQmlCustomParserNode&, const QString& description); + void error(const QV4::CompiledData::Binding *binding, const QString& description); int evaluateEnum(const QByteArray&, bool *ok) const; diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index ade4634c2d..52bf1d8b3e 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -46,6 +46,7 @@ #include "qqmlcompiler_p.h" #include "qqmlexpression_p.h" #include "qqmlmemoryprofiler_p.h" +#include "qqmlobjectcreator_p.h" // XXX TODO // - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and @@ -292,7 +293,14 @@ void QQmlIncubatorPrivate::incubate(QQmlVME::Interrupt &i) if (progress == QQmlIncubatorPrivate::Execute) { enginePriv->referenceScarceResources(); - QObject *tresult = vme.execute(&errors, i); + QObject *tresult = 0; + if (enginePriv->useNewCompiler) { + tresult = creator->create(subComponentToCreate); + if (!tresult) + errors = creator->errors; + } else { + tresult = vme.execute(&errors, i); + } enginePriv->dereferenceScarceResources(); if (watcher.hasRecursed()) @@ -335,7 +343,11 @@ void QQmlIncubatorPrivate::incubate(QQmlVME::Interrupt &i) if (watcher.hasRecursed()) return; - QQmlContextData *ctxt = vme.complete(i); + QQmlContextData *ctxt = 0; + if (enginePriv->useNewCompiler) + ctxt = creator->finalize(); + else + ctxt = vme.complete(i); if (ctxt) { rootContext = ctxt; progress = QQmlIncubatorPrivate::Completed; @@ -566,6 +578,7 @@ void QQmlIncubator::clear() d->vme.reset(); d->vmeGuard.clear(); + d->creator.reset(0); Q_ASSERT(d->compiledData == 0); Q_ASSERT(d->waitingOnMe.data() == 0); diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h index e7246ce3b2..a8b549bd28 100644 --- a/src/qml/qml/qqmlincubator_p.h +++ b/src/qml/qml/qqmlincubator_p.h @@ -88,7 +88,12 @@ public: QPointer<QObject> result; QQmlGuardedContextData rootContext; QQmlCompiledData *compiledData; + // --- old compiler QQmlVME vme; + // --- new compiler + QScopedPointer<QmlObjectCreator> creator; + int subComponentToCreate; + // --- QQmlVMEGuard vmeGuard; QExplicitlySharedDataPointer<QQmlIncubatorPrivate> waitingOnMe; diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 36e0da5b60..94cf268858 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -62,7 +62,6 @@ public: : QV4::Object(engine) { setVTable(&static_vtbl); - type = Type_Object; } QLocale locale; @@ -555,12 +554,12 @@ QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::CallContext *ctx) QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject()); result->arrayReserve(days.size()); - result->arrayDataLen = days.size(); + result->arrayData.length = days.size(); for (int i = 0; i < days.size(); ++i) { int day = days.at(i); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) day = 0; - result->arrayData[i].value = QV4::Primitive::fromInt32(day); + result->arrayData.data[i].value = QV4::Primitive::fromInt32(day); } result->setArrayLengthUnchecked(days.size()); @@ -578,8 +577,8 @@ QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::CallContext *ctx) QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject()); result->arrayReserve(langs.size()); for (int i = 0; i < langs.size(); ++i) { - result->arrayData[i].value = ctx->engine->newString(langs.at(i)); - result->arrayDataLen = i + 1; + result->arrayData.data[i].value = ctx->engine->newString(langs.at(i)); + result->arrayData.length = i + 1; } result->setArrayLengthUnchecked(langs.size()); diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index ed0c0afd6f..437e920d1a 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -664,7 +664,7 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const { // Add any enum values defined by 'related' classes if (metaObject->d.relatedMetaObjects) { - const QMetaObject **related = metaObject->d.relatedMetaObjects; + const QMetaObject * const *related = metaObject->d.relatedMetaObjects; if (related) { while (*related) insertEnums(*related++); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 3798129e8b..69ccd4c0ce 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -55,6 +55,7 @@ #include <QQmlComponent> #include <private/qqmlcomponent_p.h> #include <private/qqmlcodegenerator_p.h> +#include <private/qqmlcustomparser_p.h> QT_USE_NAMESPACE @@ -76,6 +77,14 @@ QQmlCompilePass::QQmlCompilePass(const QUrl &url, const QV4::CompiledData::QmlUn { } +QQmlCompilePass::QQmlCompilePass(const QUrl &url, const QStringList &stringTable) + : url(url) + , qmlUnit(0) + , stringTable(stringTable) +{ + +} + void QQmlCompilePass::recordError(const QV4::CompiledData::Location &location, const QString &description) { QQmlError error; @@ -94,32 +103,32 @@ void QQmlCompilePass::recordError(const QV4::CompiledData::Location &location, c static QAtomicInt classIndexCounter(0); -QQmlPropertyCacheCreator::QQmlPropertyCacheCreator(QQmlEnginePrivate *enginePrivate, const QV4::CompiledData::QmlUnit *unit, const QUrl &url, const QQmlImports *imports, +QQmlPropertyCacheCreator::QQmlPropertyCacheCreator(QQmlEnginePrivate *enginePrivate, const QStringList &stringTable, const QUrl &url, const QQmlImports *imports, QHash<int, QQmlCompiledData::TypeReference> *resolvedTypes) - : QQmlCompilePass(url, unit) + : QQmlCompilePass(url, stringTable) , enginePrivate(enginePrivate) , imports(imports) , resolvedTypes(resolvedTypes) { } -bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQmlPropertyCache **resultCache, QByteArray *vmeMetaObjectData) +bool QQmlPropertyCacheCreator::create(const QtQml::QmlObject *obj, QQmlPropertyCache **resultCache, QByteArray *vmeMetaObjectData) { Q_ASSERT(!stringAt(obj->inheritedTypeNameIndex).isEmpty()); QQmlCompiledData::TypeReference typeRef = resolvedTypes->value(obj->inheritedTypeNameIndex); QQmlPropertyCache *baseTypeCache = typeRef.createPropertyCache(QQmlEnginePrivate::get(enginePrivate)); Q_ASSERT(baseTypeCache); - if (obj->nProperties == 0 && obj->nSignals == 0 && obj->nFunctions == 0) { + if (obj->properties->count == 0 && obj->qmlSignals->count == 0 && obj->functions->count == 0) { *resultCache = baseTypeCache; vmeMetaObjectData->clear(); return true; } QQmlPropertyCache *cache = baseTypeCache->copyAndReserve(QQmlEnginePrivate::get(enginePrivate), - obj->nProperties, - obj->nFunctions + obj->nProperties + obj->nSignals, - obj->nSignals + obj->nProperties); + obj->properties->count, + obj->functions->count + obj->properties->count + obj->qmlSignals->count, + obj->qmlSignals->count + obj->properties->count); *resultCache = cache; vmeMetaObjectData->clear(); @@ -128,7 +137,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml QV4::CompiledData::Property::Type dtype; int metaType; } builtinTypes[] = { - { QV4::CompiledData::Property::Var, QMetaType::QVariant }, + { QV4::CompiledData::Property::Var, qMetaTypeId<QJSValue>() }, { QV4::CompiledData::Property::Variant, QMetaType::QVariant }, { QV4::CompiledData::Property::Int, QMetaType::Int }, { QV4::CompiledData::Property::Bool, QMetaType::Bool }, @@ -176,9 +185,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml int aliasCount = 0; int varPropCount = 0; - const QV4::CompiledData::Property *p = obj->propertyTable(); - for (quint32 i = 0; i < obj->nProperties; ++i, ++p) { - + for (QtQml::QmlProperty *p = obj->properties->first; p; p = p->next) { if (p->type == QV4::CompiledData::Property::Alias) aliasCount++; else if (p->type == QV4::CompiledData::Property::Var) @@ -195,8 +202,8 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml typedef QQmlVMEMetaData VMD; QByteArray &dynamicData = *vmeMetaObjectData = QByteArray(sizeof(QQmlVMEMetaData) - + obj->nProperties * sizeof(VMD::PropertyData) - + obj->nFunctions * sizeof(VMD::MethodData) + + obj->properties->count * sizeof(VMD::PropertyData) + + obj->functions->count * sizeof(VMD::MethodData) + aliasCount * sizeof(VMD::AliasData), 0); int effectivePropertyIndex = cache->propertyIndexCacheStart; @@ -232,8 +239,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml if (ii == NSS_Var && varPropCount == 0) continue; else if (ii == NSS_Alias && aliasCount == 0) continue; - const QV4::CompiledData::Property *p = obj->propertyTable(); - for (quint32 i = 0; i < obj->nProperties; ++i, ++p) { + for (QtQml::QmlProperty *p = obj->properties->first; p; p = p->next) { if ((ii == NSS_Normal && (p->type == QV4::CompiledData::Property::Alias || p->type == QV4::CompiledData::Property::Var)) || ((ii == NSS_Var) && (p->type != QV4::CompiledData::Property::Var)) || @@ -251,9 +257,8 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml } // Dynamic signals - for (uint i = 0; i < obj->nSignals; ++i) { - const QV4::CompiledData::Signal *s = obj->signalAt(i); - const int paramCount = s->nParameters; + for (QtQml::Signal *s = obj->qmlSignals->first; s; s = s->next) { + const int paramCount = s->parameters->count; QList<QByteArray> names; QVarLengthArray<int, 10> paramTypes(paramCount?(paramCount + 1):0); @@ -261,8 +266,8 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml if (paramCount) { paramTypes[0] = paramCount; - for (int i = 0; i < paramCount; ++i) { - const QV4::CompiledData::Parameter *param = s->parameterAt(i); + QtQml::SignalParameter *param = s->parameters->first; + for (int i = 0; i < paramCount; ++i, param = param->next) { names.append(stringAt(param->nameIndex).toUtf8()); if (param->type < builtinTypeCount) { // built-in type @@ -310,27 +315,26 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml // Dynamic slots - const quint32 *functionIndex = obj->functionOffsetTable(); - for (quint32 i = 0; i < obj->nFunctions; ++i, ++functionIndex) { - const QV4::CompiledData::Function *s = qmlUnit->header.functionAt(*functionIndex); - int paramCount = s->nFormals; + for (QtQml::Function *s = obj->functions->first; s; s = s->next) { + AST::FunctionDeclaration *astFunction = s->functionDeclaration; quint32 flags = QQmlPropertyData::IsFunction | QQmlPropertyData::IsVMEFunction; - if (paramCount) + if (astFunction->formals) flags |= QQmlPropertyData::HasArguments; - QString slotName = stringAt(s->nameIndex); + QString slotName = astFunction->name.toString(); if (seenSignals.contains(slotName)) COMPILE_EXCEPTION(s, tr("Duplicate method name: invalid override of property change signal or superclass signal")); // Note: we don't append slotName to the seenSignals list, since we don't // protect against overriding change signals or methods with properties. - const quint32 *formalsIndices = s->formalsTable(); QList<QByteArray> parameterNames; - parameterNames.reserve(paramCount); - for (int i = 0; i < paramCount; ++i) - parameterNames << stringAt(formalsIndices[i]).toUtf8(); + AST::FormalParameterList *param = astFunction->formals; + while (param) { + parameterNames << param->name.toUtf8(); + param = param->next; + } cache->appendMethod(slotName, flags, effectiveMethodIndex++, parameterNames); } @@ -338,8 +342,8 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml // Dynamic properties (except var and aliases) int effectiveSignalIndex = cache->signalHandlerIndexCacheStart; - /* const QV4::CompiledData::Property* */ p = obj->propertyTable(); - for (quint32 i = 0; i < obj->nProperties; ++i, ++p) { + int propertyIdx = 0; + for (QtQml::QmlProperty *p = obj->properties->first; p; p = p->next, ++propertyIdx) { if (p->type == QV4::CompiledData::Property::Alias || p->type == QV4::CompiledData::Property::Var) @@ -402,7 +406,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml QString propertyName = stringAt(p->nameIndex); - if (i == obj->indexOfDefaultProperty) cache->_defaultPropertyName = propertyName; + if (propertyIdx == obj->indexOfDefaultProperty) cache->_defaultPropertyName = propertyName; cache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++, propertyType, effectiveSignalIndex); @@ -414,8 +418,8 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml } // Now do var properties - /* const QV4::CompiledData::Property* */ p = obj->propertyTable(); - for (quint32 i = 0; i < obj->nProperties; ++i, ++p) { + propertyIdx = 0; + for (QtQml::QmlProperty *p = obj->properties->first; p; p = p->next, ++propertyIdx) { if (p->type != QV4::CompiledData::Property::Var) continue; @@ -430,7 +434,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml ((QQmlVMEMetaData *)dynamicData.data())->varPropertyCount++; QString propertyName = stringAt(p->nameIndex); - if (i == obj->indexOfDefaultProperty) cache->_defaultPropertyName = propertyName; + if (propertyIdx == obj->indexOfDefaultProperty) cache->_defaultPropertyName = propertyName; cache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++, QMetaType::QVariant, effectiveSignalIndex); @@ -441,12 +445,17 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml ((QQmlVMEMetaData *)dynamicData.data())->aliasCount = aliasCount; // Dynamic slot data - comes after the property data - /*const quint32* */functionIndex = obj->functionOffsetTable(); - for (quint32 i = 0; i < obj->nFunctions; ++i, ++functionIndex) { - const QV4::CompiledData::Function *s = qmlUnit->header.functionAt(*functionIndex); + for (QtQml::Function *s = obj->functions->first; s; s = s->next) { + AST::FunctionDeclaration *astFunction = s->functionDeclaration; + int formalsCount = 0; + AST::FormalParameterList *param = astFunction->formals; + while (param) { + formalsCount++; + param = param->next; + } VMD::MethodData methodData = { /* runtimeFunctionIndex*/ 0, // ### - int(s->nFormals), + formalsCount, /* s->location.start.line */0 }; // ### VMD *vmd = (QQmlVMEMetaData *)dynamicData.data(); @@ -478,6 +487,7 @@ QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledD , propertyCaches(compiledData->propertyCaches) , vmeMetaObjectData(compiledData->datas) , compiledData(compiledData) + , rootContext(0) , _qobject(0) , _qobjectForBindings(0) , _valueTypeProperty(0) @@ -512,6 +522,9 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent) context->imports->addref(); context->setParent(parentContext); + if (!rootContext) + rootContext = context; + QVector<QQmlContextData::ObjectIdMapping> mapping(objectIndexToId.count()); for (QHash<int, int>::ConstIterator it = objectIndexToId.constBegin(), end = objectIndexToId.constEnd(); it != end; ++it) { @@ -537,6 +550,10 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent) context->importedScripts = parentContext->importedScripts; } + QVector<QQmlParserStatus*> parserStatusCallbacks; + parserStatusCallbacks.resize(qmlUnit->nObjects); + qSwap(_parserStatusCallbacks, parserStatusCallbacks); + QObject *instance = createInstance(objectToCreate, parent); if (instance) { QQmlData *ddata = QQmlData::get(instance); @@ -546,6 +563,10 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent) context->contextObject = instance; } + + qSwap(_parserStatusCallbacks, parserStatusCallbacks); + allParserStatusCallbacks.prepend(parserStatusCallbacks); + return instance; } @@ -1225,6 +1246,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) bool isComponent = false; QObject *instance = 0; + QQmlCustomParser *customParser = 0; if (compiledData->isComponent(index)) { isComponent = true; @@ -1242,6 +1264,16 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex))); return 0; } + + const int parserStatusCast = type->parserStatusCast(); + if (parserStatusCast != -1) { + QQmlParserStatus *parserStatus = reinterpret_cast<QQmlParserStatus*>(reinterpret_cast<char *>(instance) + parserStatusCast); + parserStatus->classBegin(); + _parserStatusCallbacks[index] = parserStatus; + parserStatus->d = &_parserStatusCallbacks[index]; + } + + customParser = type->customParser(); } else { Q_ASSERT(typeRef.component); if (typeRef.component->qmlUnit->isSingleton()) @@ -1258,6 +1290,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) if (subCreator.componentAttached) subCreator.componentAttached->add(&componentAttached); allCreatedBindings << subCreator.allCreatedBindings; + allParserStatusCallbacks << subCreator.allParserStatusCallbacks; } // ### use no-event variant if (parent) @@ -1285,6 +1318,11 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) if (idEntry != objectIndexToId.constEnd()) context->setIdProperty(idEntry.value(), instance); + if (customParser) { + QByteArray data = compiledData->customParserData.value(index); + customParser->setCustomData(instance, data); + } + if (!isComponent) { QQmlRefPointer<QQmlPropertyCache> cache = propertyCaches.value(index); Q_ASSERT(!cache.isNull()); @@ -1296,7 +1334,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) return instance; } -void QmlObjectCreator::finalize() +QQmlContextData *QmlObjectCreator::finalize() { { QQmlTrace trace("VME Binding Enable"); @@ -1321,6 +1359,28 @@ void QmlObjectCreator::finalize() } } + if (true /* ### componentCompleteEnabled()*/) { // the qml designer does the component complete later + QQmlTrace trace("VME Component Complete"); + for (QLinkedList<QVector<QQmlParserStatus*> >::ConstIterator it = allParserStatusCallbacks.constBegin(), end = allParserStatusCallbacks.constEnd(); + it != end; ++it) { + const QVector<QQmlParserStatus *> &parserStatusCallbacks = *it; + for (int i = parserStatusCallbacks.count() - 1; i >= 0; --i) { + QQmlParserStatus *status = parserStatusCallbacks.at(i); + + if (status && status->d) { + status->d = 0; + status->componentComplete(); + } + + #if 0 // ### + if (watcher.hasRecursed() || interrupt.shouldInterrupt()) + return 0; + #endif + } + } + allParserStatusCallbacks.clear(); + } + { QQmlTrace trace("VME Component.onCompleted Callbacks"); while (componentAttached) { @@ -1339,6 +1399,8 @@ void QmlObjectCreator::finalize() #endif } } + + return rootContext; } bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, @@ -1424,7 +1486,7 @@ QQmlComponentAndAliasResolver::QQmlComponentAndAliasResolver(const QUrl &url, co bool QQmlComponentAndAliasResolver::resolve() { - Q_ASSERT(componentRoots.isEmpty()); + QVector<int> componentRoots; // Find objects that are Components. This is missing an extra pass // that finds implicitly defined components, i.e. @@ -1444,30 +1506,29 @@ bool QQmlComponentAndAliasResolver::resolve() continue; componentRoots.append(i); - // Sanity checks: There can be only an (optional) id property and - // a default property, that defines the component tree. - } - std::sort(componentRoots.begin(), componentRoots.end()); + if (obj->nFunctions > 0) + COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions.")); + if (obj->nProperties > 0) + COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new properties.")); + if (obj->nSignals > 0) + COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new signals.")); - // For each component's tree, remember to which component the children - // belong to - for (int i = 0; i < componentRoots.count(); ++i) { - const QV4::CompiledData::Object *component = qmlUnit->objectAt(componentRoots.at(i)); + if (obj->nBindings == 0) + COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification")); + + const QV4::CompiledData::Binding *rootBinding = obj->bindingTable(); + if (obj->nBindings > 1 || rootBinding->type != QV4::CompiledData::Binding::Type_Object) + COMPILE_EXCEPTION(rootBinding, tr("Component elements may not contain properties other than id")); - if (component->nFunctions > 0) - COMPILE_EXCEPTION(component, tr("Component objects cannot declare new functions.")); - if (component->nProperties > 0) - COMPILE_EXCEPTION(component, tr("Component objects cannot declare new properties.")); - if (component->nSignals > 0) - COMPILE_EXCEPTION(component, tr("Component objects cannot declare new signals.")); + componentBoundaries.append(rootBinding->value.objectIndex); + } - if (component->nBindings == 0) - COMPILE_EXCEPTION(component, tr("Cannot create empty component specification")); + std::sort(componentBoundaries.begin(), componentBoundaries.end()); + for (int i = 0; i < componentRoots.count(); ++i) { + const QV4::CompiledData::Object *component = qmlUnit->objectAt(componentRoots.at(i)); const QV4::CompiledData::Binding *rootBinding = component->bindingTable(); - if (component->nBindings > 1 || rootBinding->type != QV4::CompiledData::Binding::Type_Object) - COMPILE_EXCEPTION(rootBinding, tr("Component elements may not contain properties other than id")); _componentIndex = i; _idToObjectIndex.clear(); @@ -1500,11 +1561,6 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex) { const QV4::CompiledData::Object *obj = qmlUnit->objectAt(objectIndex); - // Only include creatable types. Everything else is synthetic, such as group property - // objects. - if (_componentIndex != -1 && !stringAt(obj->inheritedTypeNameIndex).isEmpty()) - objectIndexToComponentIndex.insert(objectIndex, _componentIndex); - QString id = stringAt(obj->idIndex); if (!id.isEmpty()) { if (_idToObjectIndex.contains(obj->idIndex)) { @@ -1530,7 +1586,7 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex) continue; // Stop at Component boundary - if (std::binary_search(componentRoots.constBegin(), componentRoots.constEnd(), binding->value.objectIndex)) + if (std::binary_search(componentBoundaries.constBegin(), componentBoundaries.constEnd(), binding->value.objectIndex)) continue; if (!collectIdsAndAliases(binding->value.objectIndex)) @@ -1689,11 +1745,13 @@ bool QQmlComponentAndAliasResolver::resolveAliases() QQmlPropertyValidator::QQmlPropertyValidator(const QUrl &url, const QV4::CompiledData::QmlUnit *qmlUnit, const QHash<int, QQmlCompiledData::TypeReference> &resolvedTypes, - const QList<QQmlPropertyCache *> &propertyCaches, const QHash<int, QHash<int, int> > &objectIndexToIdPerComponent) + const QList<QQmlPropertyCache *> &propertyCaches, const QHash<int, QHash<int, int> > &objectIndexToIdPerComponent, + QHash<int, QByteArray> *customParserData) : QQmlCompilePass(url, qmlUnit) , resolvedTypes(resolvedTypes) , propertyCaches(propertyCaches) , objectIndexToIdPerComponent(objectIndexToIdPerComponent) + , customParserData(customParserData) { } @@ -1718,6 +1776,12 @@ bool QQmlPropertyValidator::validate() bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, int objectIndex, QQmlPropertyCache *propertyCache) { + QQmlCustomParser *customParser = 0; + QQmlCompiledData::TypeReference objectType = resolvedTypes.value(obj->inheritedTypeNameIndex); + if (objectType.type) + customParser = objectType.type->customParser(); + QList<const QV4::CompiledData::Binding*> customBindings; + PropertyResolver propertyResolver(propertyCache); QQmlPropertyData *defaultProperty = propertyCache->defaultProperty(); @@ -1725,8 +1789,11 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, const QV4::CompiledData::Binding *binding = obj->bindingTable(); for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) { if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty - || binding->type == QV4::CompiledData::Binding::Type_GroupProperty) + || binding->type == QV4::CompiledData::Binding::Type_GroupProperty) { + if (customParser) + customBindings << binding; continue; + } const QString name = stringAt(binding->propertyNameIndex); @@ -1735,13 +1802,15 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, bool notInRevision = false; QQmlPropertyData *pd = 0; if (!name.isEmpty()) { - pd = propertyResolver.property(name, ¬InRevision); + if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) + pd = propertyResolver.signal(name, ¬InRevision); + else + pd = propertyResolver.property(name, ¬InRevision); if (notInRevision) { QString typeName = stringAt(obj->inheritedTypeNameIndex); - QQmlCompiledData::TypeReference type = resolvedTypes.value(objectIndex); - if (type.type) { - COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(typeName).arg(name).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); + if (objectType.type) { + COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(typeName).arg(name).arg(objectType.type->module()).arg(objectType.majorVersion).arg(objectType.minorVersion)); } else { COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available due to component versioning.").arg(typeName).arg(name)); } @@ -1752,6 +1821,10 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, } if (!pd) { + if (customParser) { + customBindings << binding; + continue; + } if (bindingToDefaultProperty) { COMPILE_EXCEPTION(binding, tr("Cannot assign to non-existent default property")); } else { @@ -1760,5 +1833,20 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, } } + if (customParser && !customBindings.isEmpty()) { + customParser->clearErrors(); + QByteArray data = customParser->compile(qmlUnit, customBindings); + customParserData->insert(objectIndex, data); + const QList<QQmlError> parserErrors = customParser->errors(); + if (!parserErrors.isEmpty()) { + foreach (QQmlError error, parserErrors) { + error.setUrl(url); + errors << error; + } + return false; + } + } + return true; } + diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index ec4b362491..d395f0238f 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -54,25 +54,27 @@ class QQmlAbstractBinding; struct QQmlCompilePass { QQmlCompilePass(const QUrl &url, const QV4::CompiledData::QmlUnit *unit); + QQmlCompilePass(const QUrl &url, const QStringList &stringTable); QList<QQmlError> errors; + QString stringAt(int idx) const { return qmlUnit ? qmlUnit->header.stringAt(idx): stringTable.at(idx); } protected: - QString stringAt(int idx) const { return qmlUnit->header.stringAt(idx); } void recordError(const QV4::CompiledData::Location &location, const QString &description); const QUrl url; const QV4::CompiledData::QmlUnit *qmlUnit; + const QStringList stringTable; }; class QQmlPropertyCacheCreator : public QQmlCompilePass { Q_DECLARE_TR_FUNCTIONS(QQmlPropertyCacheCreator) public: - QQmlPropertyCacheCreator(QQmlEnginePrivate *enginePrivate, const QV4::CompiledData::QmlUnit *qmlUnit, + QQmlPropertyCacheCreator(QQmlEnginePrivate *enginePrivate, const QStringList &stringTable, const QUrl &url, const QQmlImports *imports, QHash<int, QQmlCompiledData::TypeReference> *resolvedTypes); - bool create(const QV4::CompiledData::Object *obj, QQmlPropertyCache **cache, QByteArray *vmeMetaObjectData); + bool create(const QtQml::QmlObject *obj, QQmlPropertyCache **cache, QByteArray *vmeMetaObjectData); protected: QQmlEnginePrivate *enginePrivate; @@ -93,9 +95,6 @@ public: bool resolve(); - QVector<int> componentRoots; - QHash<int, int> objectIndexToComponentIndex; - protected: bool collectIdsAndAliases(int objectIndex); bool resolveAliases(); @@ -103,6 +102,9 @@ protected: bool isComponentType(int typeNameIndex) const { return resolvedTypes.value(typeNameIndex).type == 0; } + // indices of objects that are of type QQmlComponent + QVector<int> componentBoundaries; + int _componentIndex; QHash<int, int> _idToObjectIndex; QHash<int, int> *_objectIndexToIdInScope; @@ -122,7 +124,8 @@ public: QQmlPropertyValidator(const QUrl &url, const QV4::CompiledData::QmlUnit *qmlUnit, const QHash<int, QQmlCompiledData::TypeReference> &resolvedTypes, const QList<QQmlPropertyCache *> &propertyCaches, - const QHash<int, QHash<int, int> > &objectIndexToIdPerComponent); + const QHash<int, QHash<int, int> > &objectIndexToIdPerComponent, + QHash<int, QByteArray> *customParserData); bool validate(); @@ -134,6 +137,7 @@ private: const QHash<int, QQmlCompiledData::TypeReference> &resolvedTypes; const QList<QQmlPropertyCache *> &propertyCaches; const QHash<int, QHash<int, int> > objectIndexToIdPerComponent; + QHash<int, QByteArray> *customParserData; }; class QmlObjectCreator : public QQmlCompilePass @@ -143,7 +147,7 @@ public: QmlObjectCreator(QQmlContextData *contextData, QQmlCompiledData *compiledData); QObject *create(int subComponentIndex = -1, QObject *parent = 0); - void finalize(); + QQmlContextData *finalize(); QQmlComponentAttached *componentAttached; QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks; @@ -168,7 +172,9 @@ private: const QList<QByteArray> vmeMetaObjectData; QHash<int, int> objectIndexToId; QLinkedList<QVector<QQmlAbstractBinding*> > allCreatedBindings; + QLinkedList<QVector<QQmlParserStatus*> > allParserStatusCallbacks; QQmlCompiledData *compiledData; + QQmlContextData *rootContext; QObject *_qobject; QObject *_qobjectForBindings; @@ -180,6 +186,7 @@ private: QVector<QQmlAbstractBinding*> _createdBindings; QQmlListProperty<void> _currentList; QV4::ExecutionContext *_qmlContext; + QVector<QQmlParserStatus*> _parserStatusCallbacks; }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlparserstatus.h b/src/qml/qml/qqmlparserstatus.h index d3447e7752..1d63afd978 100644 --- a/src/qml/qml/qqmlparserstatus.h +++ b/src/qml/qml/qqmlparserstatus.h @@ -62,6 +62,7 @@ private: friend class QQmlComponent; friend class QQmlComponentPrivate; friend class QQmlEnginePrivate; + friend class QmlObjectCreator; QQmlParserStatus **d; }; diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 6c40557886..d026b95201 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -1140,7 +1140,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(QQmlEngine *engine, const { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); bool unnamedParameter = false; - const QV4::IdentifierHash<bool> &illegalNames = ep->v8engine()->illegalNames(); + const QSet<QString> &illegalNames = ep->v8engine()->illegalNames(); QString error; QString parameters; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 6eda55e35b..9e23b0b1a5 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -52,6 +52,7 @@ #include <private/qqmlprofilerservice_p.h> #include <private/qqmlmemoryprofiler_p.h> #include <private/qqmlcodegenerator_p.h> +#include <private/qqmltypecompiler_p.h> #include <QtCore/qdir.h> #include <QtCore/qfile.h> @@ -2154,8 +2155,9 @@ void QQmlTypeData::dataReceived(const Data &data) if (data.isFile()) preparseData = data.asFile()->metaData(QLatin1String("qml:preparse")); if (m_useNewCompiler) { - parsedQML.reset(new QtQml::ParsedQML(QV8Engine::getV4(typeLoader()->engine())->debugger != 0)); - QQmlCodeGenerator compiler; + QQmlEngine *qmlEngine = typeLoader()->engine(); + parsedQML.reset(new QtQml::ParsedQML(QV8Engine::getV4(qmlEngine)->debugger != 0)); + QQmlCodeGenerator compiler(QV8Engine::get(qmlEngine)->illegalNames()); if (!compiler.generateFromQml(code, finalUrl(), finalUrlString(), parsedQML.data())) { setError(compiler.errors); return; @@ -2305,173 +2307,9 @@ void QQmlTypeData::compile() QQmlCompilingProfiler prof(m_compiledData->name); if (m_useNewCompiler) { - m_compiledData->importCache = new QQmlTypeNameCache; - - foreach (const QString &ns, m_namespaces) - m_compiledData->importCache->add(ns); - - // Add any Composite Singletons that were used to the import cache - for (int i = 0; i < compositeSingletons().count(); ++i) { - m_compiledData->importCache->add(compositeSingletons().at(i).type->qmlTypeName(), - compositeSingletons().at(i).type->sourceUrl(), compositeSingletons().at(i).prefix); - } - - m_imports.populateCache(m_compiledData->importCache); - m_compiledData->importCache->addref(); - - QQmlEngine *engine = typeLoader()->engine(); - QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); - - for (QHash<int, TypeReference>::ConstIterator resolvedType = m_resolvedTypes.constBegin(), end = m_resolvedTypes.constEnd(); - resolvedType != end; ++resolvedType) { - QQmlCompiledData::TypeReference ref; - if (resolvedType->typeData) { - ref.component = resolvedType->typeData->compiledData(); - ref.component->addref(); - } else { - ref.type = resolvedType->type; - Q_ASSERT(ref.type); - } - ref.majorVersion = resolvedType->majorVersion; - ref.minorVersion = resolvedType->minorVersion; - m_compiledData->resolvedTypes.insert(resolvedType.key(), ref); - } - - { - SignalHandlerConverter converter(QQmlEnginePrivate::get(engine), - parsedQML.data(), - m_compiledData); - if (!converter.convertSignalHandlerExpressionsToFunctionDeclarations()) { - setError(converter.errors); - m_compiledData->release(); - m_compiledData = 0; - return; - } - } - - // Collect imported scripts - m_compiledData->scripts.reserve(m_scripts.count()); - for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) { - const ScriptReference &script = m_scripts.at(scriptIndex); - - QString qualifier = script.qualifier; - QString enclosingNamespace; - - const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.')); - if (lastDotIndex != -1) { - enclosingNamespace = qualifier.left(lastDotIndex); - qualifier = qualifier.mid(lastDotIndex+1); - } - - m_compiledData->importCache->add(qualifier, scriptIndex, enclosingNamespace); - QQmlScriptData *scriptData = script.script->scriptData(); - scriptData->addref(); - m_compiledData->scripts << scriptData; - } - - // Compile JS binding expressions and signal handlers - - JSCodeGen jsCodeGen(finalUrlString(), parsedQML->code, &parsedQML->jsModule, &parsedQML->jsParserEngine, parsedQML->program, m_compiledData->importCache); - const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(parsedQML->functions); - - QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine()); - - QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(enginePrivate, v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator)); - isel->setUseFastLookups(false); - QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/false); - - // Generate QML compiled type data structures - - QmlUnitGenerator qmlGenerator; - QV4::CompiledData::QmlUnit *qmlUnit = qmlGenerator.generate(*parsedQML.data(), runtimeFunctionIndices); - - if (jsUnit) { - Q_ASSERT(!jsUnit->data); - jsUnit->ownsData = false; - jsUnit->data = &qmlUnit->header; - } - - m_compiledData->compilationUnit = jsUnit; - if (m_compiledData->compilationUnit) - m_compiledData->compilationUnit->ref(); - m_compiledData->qmlUnit = qmlUnit; // ownership transferred to m_compiledData - - QList<QQmlError> errors; - - // Build property caches and VME meta object data - - m_compiledData->datas.reserve(qmlUnit->nObjects); - m_compiledData->propertyCaches.reserve(qmlUnit->nObjects); - - QQmlPropertyCacheCreator propertyCacheBuilder(enginePrivate, - qmlUnit, m_compiledData->url, - &m_imports, &m_compiledData->resolvedTypes); - - for (quint32 i = 0; i < qmlUnit->nObjects; ++i) { - const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i); - - QByteArray vmeMetaObjectData; - QQmlPropertyCache *propertyCache = 0; - - // If the object has no type, then it's probably a nested object definition as part - // of a group property. - const bool objectHasType = !parsedQML->jsGenerator.strings.at(obj->inheritedTypeNameIndex).isEmpty(); - if (objectHasType) { - if (!propertyCacheBuilder.create(obj, &propertyCache, &vmeMetaObjectData)) { - errors << propertyCacheBuilder.errors; - break; - } - } - - m_compiledData->datas << vmeMetaObjectData; - if (propertyCache) - propertyCache->addref(); - m_compiledData->propertyCaches << propertyCache; - - if (i == qmlUnit->indexOfRootObject) { - Q_ASSERT(propertyCache); - m_compiledData->rootPropertyCache = propertyCache; - propertyCache->addref(); - } - } - - // Resolve component boundaries and aliases - - if (errors.isEmpty()) { - // Scan for components, determine their scopes and resolve aliases within the scope. - QQmlComponentAndAliasResolver resolver(m_compiledData->url, m_compiledData->qmlUnit, m_compiledData->resolvedTypes, m_compiledData->propertyCaches, - &m_compiledData->datas, &m_compiledData->objectIndexToIdForRoot, &m_compiledData->objectIndexToIdPerComponent); - if (!resolver.resolve()) - errors << resolver.errors; - } - - if (errors.isEmpty()) { - // Add to type registry of composites - if (m_compiledData->isCompositeType()) - QQmlEnginePrivate::get(engine)->registerInternalCompositeType(m_compiledData); - else { - const QV4::CompiledData::Object *obj = qmlUnit->objectAt(qmlUnit->indexOfRootObject); - QQmlCompiledData::TypeReference typeRef = m_compiledData->resolvedTypes.value(obj->inheritedTypeNameIndex); - if (typeRef.component) { - m_compiledData->metaTypeId = typeRef.component->metaTypeId; - m_compiledData->listMetaTypeId = typeRef.component->listMetaTypeId; - } else { - m_compiledData->metaTypeId = typeRef.type->typeId(); - m_compiledData->listMetaTypeId = typeRef.type->qListTypeId(); - } - } - } - - // Sanity check property bindings - if (errors.isEmpty()) { - QQmlPropertyValidator validator(m_compiledData->url, m_compiledData->qmlUnit, m_compiledData->resolvedTypes, - m_compiledData->propertyCaches, m_compiledData->objectIndexToIdPerComponent); - if (!validator.validate()) - errors << validator.errors; - } - - if (!errors.isEmpty()) { - setError(errors); + QQmlTypeCompiler compiler(QQmlEnginePrivate::get(typeLoader()->engine()), m_compiledData, this, parsedQML.data()); + if (!compiler.compile()) { + setError(compiler.errors); m_compiledData->release(); m_compiledData = 0; } diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index b93cf2942d..a022162a7c 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -425,7 +425,12 @@ public: const QQmlScript::Parser &parser() const; + // old compiler: const QList<TypeReference> &resolvedTypes() const; + // new compiler: + const QHash<int, TypeReference> &resolvedTypeRefs() const { return m_resolvedTypes; } + // --- + const QList<ScriptReference> &resolvedScripts() const; const QSet<QString> &namespaces() const; const QList<TypeReference> &compositeSingletons() const; diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 33f5a00a6c..1e7fdbc316 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -197,8 +197,8 @@ static QV4::ReturnedValue arrayFromStringList(QV8Engine *engine, const QStringLi int len = list.count(); a->arrayReserve(len); for (int ii = 0; ii < len; ++ii) { - a->arrayData[ii].value = QV4::Encode(e->newString(list.at(ii))); - a->arrayDataLen = ii + 1; + a->arrayData.data[ii].value = QV4::Encode(e->newString(list.at(ii))); + a->arrayData.length = ii + 1; } a->setArrayLengthUnchecked(len); return a.asReturnedValue(); @@ -212,8 +212,8 @@ static QV4::ReturnedValue arrayFromVariantList(QV8Engine *engine, const QVariant int len = list.count(); a->arrayReserve(len); for (int ii = 0; ii < len; ++ii) { - a->arrayData[ii].value = engine->fromVariant(list.at(ii)); - a->arrayDataLen = ii + 1; + a->arrayData.data[ii].value = engine->fromVariant(list.at(ii)); + a->arrayData.length = ii + 1; } a->setArrayLengthUnchecked(len); return a.asReturnedValue(); @@ -326,8 +326,8 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant) QV4::Scoped<QV4::ArrayObject> a(scope, m_v4Engine->newArrayObject()); a->arrayReserve(list.count()); for (int ii = 0; ii < list.count(); ++ii) { - a->arrayData[ii].value = QV4::QObjectWrapper::wrap(m_v4Engine, list.at(ii)); - a->arrayDataLen = ii + 1; + a->arrayData.data[ii].value = QV4::QObjectWrapper::wrap(m_v4Engine, list.at(ii)); + a->arrayData.length = ii + 1; } a->setArrayLengthUnchecked(list.count()); return a.asReturnedValue(); @@ -361,7 +361,7 @@ QNetworkAccessManager *QV8Engine::networkAccessManager() return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager(); } -const QV4::IdentifierHash<bool> &QV8Engine::illegalNames() const +const QSet<QString> &QV8Engine::illegalNames() const { return m_illegalNames; } @@ -437,9 +437,8 @@ void QV8Engine::initializeGlobal() qt_add_sqlexceptions(m_v4Engine); { - m_illegalNames = QV4::IdentifierHash<bool>(m_v4Engine); for (uint i = 0; i < m_v4Engine->globalObject->internalClass->size; ++i) - m_illegalNames.add(m_v4Engine->globalObject->internalClass->nameMap.at(i)->toQString(), true); + m_illegalNames.insert(m_v4Engine->globalObject->internalClass->nameMap.at(i)->toQString()); } { @@ -542,8 +541,8 @@ QV4::ReturnedValue QV8Engine::variantListToJS(const QVariantList &lst) QV4::Scoped<QV4::ArrayObject> a(scope, m_v4Engine->newArrayObject()); a->arrayReserve(lst.size()); for (int i = 0; i < lst.size(); i++) { - a->arrayData[i].value = variantToJS(lst.at(i)); - a->arrayDataLen = i + 1; + a->arrayData.data[i].value = variantToJS(lst.at(i)); + a->arrayData.length = i + 1; } a->setArrayLengthUnchecked(lst.size()); return a.asReturnedValue(); diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index e37b0d4920..5d1005b479 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -217,7 +217,7 @@ public: virtual QNetworkAccessManager *networkAccessManager(); // Return the list of illegal id names (the names of the properties on the global object) - const QV4::IdentifierHash<bool> &illegalNames() const; + const QSet<QString> &illegalNames() const; void gc(); @@ -268,7 +268,7 @@ protected: QVector<Deletable *> m_extensionData; Deletable *m_listModelData; - QV4::IdentifierHash<bool> m_illegalNames; + QSet<QString> m_illegalNames; QElapsedTimer m_time; QHash<QString, qint64> m_startedTimers; diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp index 5e6a1a084a..b8920deb21 100644 --- a/src/qml/types/qqmlconnections.cpp +++ b/src/qml/types/qqmlconnections.cpp @@ -251,6 +251,44 @@ QQmlConnectionsParser::compile(const QList<QQmlCustomParserProperty> &props) return rv; } +QByteArray QQmlConnectionsParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) +{ + QByteArray rv; + QDataStream ds(&rv, QIODevice::WriteOnly); + + for (int ii = 0; ii < props.count(); ++ii) { + const QV4::CompiledData::Binding *binding = props.at(ii); + QString propName = qmlUnit->header.stringAt(binding->propertyNameIndex); + int propLine = binding->location.line; + int propColumn = binding->location.column; + + if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { + error(props.at(ii), QQmlConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); + return QByteArray(); + } + + + if (binding->type >= QV4::CompiledData::Binding::Type_Object) { + const QV4::CompiledData::Object *target = qmlUnit->objectAt(binding->value.objectIndex); + if (!qmlUnit->header.stringAt(target->inheritedTypeNameIndex).isEmpty()) + error(binding, QQmlConnections::tr("Connections: nested objects not allowed")); + else + error(binding, QQmlConnections::tr("Connections: syntax error")); + return QByteArray(); + } if (binding->type != QV4::CompiledData::Binding::Type_Script) { + error(binding, QQmlConnections::tr("Connections: script expected")); + return QByteArray(); + } else { + ds << propName; + ds << binding->valueAsString(&qmlUnit->header); + ds << propLine; + ds << propColumn; + } + } + + return rv; +} + void QQmlConnectionsParser::setCustomData(QObject *object, const QByteArray &data) { diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h index 9bc668e5f4..2579e4c239 100644 --- a/src/qml/types/qqmlconnections_p.h +++ b/src/qml/types/qqmlconnections_p.h @@ -85,6 +85,7 @@ class QQmlConnectionsParser : public QQmlCustomParser { public: virtual QByteArray compile(const QList<QQmlCustomParserProperty> &); + virtual QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props); virtual void setCustomData(QObject *, const QByteArray &); }; diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 7276c0e5c6..32ebb93279 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1863,11 +1863,16 @@ void QQmlDelegateModelItem::incubateObject( incubatorPriv->compiledData = componentPriv->cc; incubatorPriv->compiledData->addref(); - incubatorPriv->vme.init( - context, - componentPriv->cc, - componentPriv->start, - componentPriv->creationContext); + if (enginePriv->useNewCompiler) { + incubatorPriv->creator.reset(new QmlObjectCreator(context, componentPriv->cc)); + incubatorPriv->subComponentToCreate = componentPriv->start; + } else { + incubatorPriv->vme.init( + context, + componentPriv->cc, + componentPriv->start, + componentPriv->creationContext); + } enginePriv->incubate(*incubationTask, forContext); } diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index b3a2c9f46a..763dd5251b 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -180,7 +180,7 @@ QQuickCanvasItemPrivate::QQuickCanvasItemPrivate() , renderTarget(QQuickCanvasItem::Image) , renderStrategy(QQuickCanvasItem::Immediate) { - antialiasing = true; + implicitAntialiasing = true; } QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate() @@ -642,7 +642,7 @@ void QQuickCanvasItem::updatePolish() Q_D(QQuickCanvasItem); if (d->context && d->renderStrategy != QQuickCanvasItem::Cooperative) - d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing); + d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, antialiasing()); if (d->animationCallbacks.size() > 0 && isVisible()) { QMap<int, QV4::PersistentValue> animationCallbacks = d->animationCallbacks; @@ -705,7 +705,7 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData node->setFiltering(QSGTexture::Nearest); if (d->renderStrategy == QQuickCanvasItem::Cooperative) { - d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing); + d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, antialiasing()); d->context->flush(); } diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 1107425575..8587da5ac3 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -630,8 +630,8 @@ void QQuickGridViewPrivate::updateViewport() void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex) { if (visibleItems.count()) { - const qreal from = isContentFlowReversed() ? -position() - size() : position(); - const qreal to = isContentFlowReversed() ? -position() : position() + size(); + const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning; + const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd; FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.first()); qreal rowPos = firstItem->rowPos(); @@ -1534,7 +1534,35 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight) of additional memory usage. It is not a substitute for creating efficient delegates; the fewer objects and bindings in a delegate, the faster a view may be scrolled. + + The cacheBuffer operates outside of any display margins specified by + displayMarginBeginning or displayMarginEnd. +*/ + +/*! + \qmlproperty int QtQuick::GridView::displayMarginBeginning + \qmlproperty int QtQuick::GridView::displayMarginEnd + \since QtQuick 2.3 + + This property allows delegates to be displayed outside of the view geometry. + + If this value is non-zero, the view will create extra delegates before the + start of the view, or after the end. The view will create as many delegates + as it can fit into the pixel size specified. + + For example, if in a vertical view the delegate is 20 pixels high, + there are 3 columns, and + \c displayMarginBeginning and \c displayMarginEnd are both set to 40, + then 6 delegates above and 6 delegates below will be created and shown. + + The default value is 0. + + This property is meant for allowing certain UI configurations, + and not as a performance optimization. If you wish to create delegates + outside of the view geometry for performance reasons, you probably + want to use the cacheBuffer property instead. */ + void QQuickGridView::setHighlightMoveDuration(int duration) { Q_D(QQuickGridView); @@ -2000,8 +2028,8 @@ void QQuickGridView::viewportMoved(Qt::Orientations orient) d->refillOrLayout(); // Set visibility of items to eliminate cost of items outside the visible area. - qreal from = d->isContentFlowReversed() ? -d->position()-d->size() : d->position(); - qreal to = d->isContentFlowReversed() ? -d->position() : d->position()+d->size(); + qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning; + qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd; for (int i = 0; i < d->visibleItems.count(); ++i) { FxGridItemSG *item = static_cast<FxGridItemSG*>(d->visibleItems.at(i)); QQuickItemPrivate::get(item->item)->setCulled(item->rowPos() + d->rowSize() < from || item->rowPos() > to); @@ -2350,7 +2378,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Insert &ch // Insert items before the visible item. int insertionIdx = index; int i = count - 1; - int from = tempPos - buffer; + int from = tempPos - buffer - displayMarginBeginning; while (i >= 0) { if (rowPos > from && insertionIdx < visibleIndex) { @@ -2387,7 +2415,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Insert &ch } } else { int i = 0; - int to = buffer+tempPos+size()-1; + int to = buffer+displayMarginEnd+tempPos+size()-1; while (i < count && rowPos <= to + rowSize()*(columns - colNum)/qreal(columns+1)) { FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp index 0708304051..62ac72d244 100644 --- a/src/quick/items/qquickimage.cpp +++ b/src/quick/items/qquickimage.cpp @@ -62,6 +62,13 @@ public: { } + void updateTexture(QSGTexture *texture) { + if (m_texture == texture) + return; + m_texture = texture; + emit textureChanged(); + } + QSGTexture *texture() const { if (m_texture) { m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); @@ -542,7 +549,7 @@ QSGTextureProvider *QQuickImage::textureProvider() const QQuickImagePrivate *dd = const_cast<QQuickImagePrivate *>(d); dd->provider = new QQuickImageTextureProvider; dd->provider->m_smooth = d->smooth; - dd->provider->m_texture = d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window()); + dd->provider->updateTexture(d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window())); } return d->provider; @@ -557,7 +564,7 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) // Copy over the current texture state into the texture provider... if (d->provider) { d->provider->m_smooth = d->smooth; - d->provider->m_texture = texture; + d->provider->updateTexture(texture); } if (!texture || width() <= 0 || height() <= 0) { diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index c308a7230a..110a8b7586 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2703,6 +2703,8 @@ QQuickItemPrivate::QQuickItemPrivate() , culled(false) , hasCursor(false) , activeFocusOnTab(false) + , implicitAntialiasing(false) + , antialiasingValid(false) , dirtyAttributes(0) , nextDirtyItem(0) , prevDirtyItem(0) @@ -4474,96 +4476,6 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e) } #endif // QT_NO_IM -void QQuickItemPrivate::deliverFocusEvent(QFocusEvent *e) -{ - Q_Q(QQuickItem); - - if (e->type() == QEvent::FocusIn) { - q->focusInEvent(e); - } else { - q->focusOutEvent(e); - } -} - -void QQuickItemPrivate::deliverMouseEvent(QMouseEvent *e) -{ - Q_Q(QQuickItem); - - Q_ASSERT(e->isAccepted()); - - switch (e->type()) { - default: - Q_ASSERT(!"Unknown event type"); - case QEvent::MouseMove: - q->mouseMoveEvent(e); - break; - case QEvent::MouseButtonPress: - q->mousePressEvent(e); - break; - case QEvent::MouseButtonRelease: - q->mouseReleaseEvent(e); - break; - case QEvent::MouseButtonDblClick: - q->mouseDoubleClickEvent(e); - break; - } -} - -#ifndef QT_NO_WHEELEVENT -void QQuickItemPrivate::deliverWheelEvent(QWheelEvent *e) -{ - Q_Q(QQuickItem); - q->wheelEvent(e); -} -#endif - -void QQuickItemPrivate::deliverTouchEvent(QTouchEvent *e) -{ - Q_Q(QQuickItem); - q->touchEvent(e); -} - -void QQuickItemPrivate::deliverHoverEvent(QHoverEvent *e) -{ - Q_Q(QQuickItem); - switch (e->type()) { - default: - Q_ASSERT(!"Unknown event type"); - case QEvent::HoverEnter: - q->hoverEnterEvent(e); - break; - case QEvent::HoverLeave: - q->hoverLeaveEvent(e); - break; - case QEvent::HoverMove: - q->hoverMoveEvent(e); - break; - } -} - -#ifndef QT_NO_DRAGANDDROP -void QQuickItemPrivate::deliverDragEvent(QEvent *e) -{ - Q_Q(QQuickItem); - switch (e->type()) { - default: - Q_ASSERT(!"Unknown event type"); - case QEvent::DragEnter: - q->dragEnterEvent(static_cast<QDragEnterEvent *>(e)); - break; - case QEvent::DragLeave: - q->dragLeaveEvent(static_cast<QDragLeaveEvent *>(e)); - break; - case QEvent::DragMove: - q->dragMoveEvent(static_cast<QDragMoveEvent *>(e)); - break; - case QEvent::Drop: - q->dropEvent(static_cast<QDropEvent *>(e)); - break; - } -} -#endif // QT_NO_DRAGANDDROP - /*! Called when \a change occurs for this item. @@ -5569,6 +5481,9 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt } } break; + case QQuickItem::ItemAntialiasingHasChanged: + q->itemChange(change, data); + break; } } @@ -5662,37 +5577,65 @@ void QQuickItem::setActiveFocusOnTab(bool activeFocusOnTab) /*! \qmlproperty bool QtQuick::Item::antialiasing - Primarily used in Rectangle and image based elements to decide if the item should - use antialiasing or not. Items with antialiasing enabled require more memory and - are potentially slower to render. + Used by visual elements to decide if the item should use antialiasing or not. + In some cases items with antialiasing require more memory and are potentially + slower to render (see \l {Antialiasing} for more details). - The default is false. + The default is false, but may be overridden by derived elements. */ /*! \property QQuickItem::antialiasing \brief Specifies whether the item is antialiased or not - Primarily used in Rectangle and image based elements to decide if the item should - use antialiasing or not. Items with antialiasing enabled require more memory and - are potentially slower to render. + Used by visual elements to decide if the item should use antialiasing or not. + In some cases items with antialiasing require more memory and are potentially + slower to render (see \l {Antialiasing} for more details). - The default is false. + The default is false, but may be overridden by derived elements. */ bool QQuickItem::antialiasing() const { Q_D(const QQuickItem); - return d->antialiasing; + return d->antialiasingValid ? d->antialiasing : d->implicitAntialiasing; } -void QQuickItem::setAntialiasing(bool antialiasing) + +void QQuickItem::setAntialiasing(bool aa) { Q_D(QQuickItem); - if (d->antialiasing == antialiasing) + + bool changed = (aa != antialiasing()); + d->antialiasingValid = true; + + if (!changed) return; - d->antialiasing = antialiasing; + d->antialiasing = aa; d->dirty(QQuickItemPrivate::Antialiasing); - emit antialiasingChanged(antialiasing); + d->itemChange(ItemAntialiasingHasChanged, d->antialiasing); + + emit antialiasingChanged(antialiasing()); +} + +void QQuickItem::resetAntialiasing() +{ + Q_D(QQuickItem); + if (!d->antialiasingValid) + return; + + d->antialiasingValid = false; + + if (d->implicitAntialiasing != d->antialiasing) + emit antialiasingChanged(antialiasing()); +} + +void QQuickItemPrivate::setImplicitAntialiasing(bool antialiasing) +{ + Q_Q(QQuickItem); + bool prev = q->antialiasing(); + implicitAntialiasing = antialiasing; + if (componentComplete && (q->antialiasing() != prev)) + emit q->antialiasingChanged(q->antialiasing()); } /*! @@ -6535,6 +6478,17 @@ void QQuickItemPrivate::incrementCursorCount(int delta) #endif } +void QQuickItemPrivate::markObjects(QV4::ExecutionEngine *e) +{ + Q_Q(QQuickItem); + QQmlData *ddata = QQmlData::get(q); + if (ddata) + ddata->jsWrapper.markOnce(e); + + foreach (QQuickItem *child, childItems) + QQuickItemPrivate::get(child)->markObjects(e); +} + #ifndef QT_NO_CURSOR /*! @@ -6977,18 +6931,17 @@ QRectF QQuickItem::mapRectFromScene(const QRectF &rect) const */ bool QQuickItem::event(QEvent *ev) { + Q_D(QQuickItem); + + switch (ev->type()) { #if 0 - if (ev->type() == QEvent::PolishRequest) { - Q_D(QQuickItem); + case QEvent::PolishRequest: d->polishScheduled = false; updatePolish(); - return true; - } else { - return QObject::event(ev); - } + break; #endif #ifndef QT_NO_IM - if (ev->type() == QEvent::InputMethodQuery) { + case QEvent::InputMethodQuery: { QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev); Qt::InputMethodQueries queries = query->queries(); for (uint i = 0; i < 32; ++i) { @@ -6999,20 +6952,79 @@ bool QQuickItem::event(QEvent *ev) } } query->accept(); - return true; - } else if (ev->type() == QEvent::InputMethod) { + break; + } + case QEvent::InputMethod: inputMethodEvent(static_cast<QInputMethodEvent *>(ev)); - return true; - } else + break; #endif // QT_NO_IM - if (ev->type() == QEvent::StyleAnimationUpdate) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + case QEvent::TouchCancel: + touchEvent(static_cast<QTouchEvent*>(ev)); + break; + case QEvent::StyleAnimationUpdate: if (isVisible()) { ev->accept(); update(); } - return true; + break; + case QEvent::HoverEnter: + hoverEnterEvent(static_cast<QHoverEvent*>(ev)); + break; + case QEvent::HoverLeave: + hoverLeaveEvent(static_cast<QHoverEvent*>(ev)); + break; + case QEvent::HoverMove: + hoverMoveEvent(static_cast<QHoverEvent*>(ev)); + break; + case QEvent::KeyPress: + case QEvent::KeyRelease: + d->deliverKeyEvent(static_cast<QKeyEvent*>(ev)); + break; + case QEvent::FocusIn: + focusInEvent(static_cast<QFocusEvent*>(ev)); + break; + case QEvent::FocusOut: + focusOutEvent(static_cast<QFocusEvent*>(ev)); + break; + case QEvent::MouseMove: + mouseMoveEvent(static_cast<QMouseEvent*>(ev)); + break; + case QEvent::MouseButtonPress: + mousePressEvent(static_cast<QMouseEvent*>(ev)); + break; + case QEvent::MouseButtonRelease: + mouseReleaseEvent(static_cast<QMouseEvent*>(ev)); + break; + case QEvent::MouseButtonDblClick: + mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev)); + break; +#ifndef QT_NO_WHEELEVENT + case QEvent::Wheel: + wheelEvent(static_cast<QWheelEvent*>(ev)); + break; +#endif +#ifndef QT_NO_DRAGANDDROP + case QEvent::DragEnter: + dragEnterEvent(static_cast<QDragEnterEvent*>(ev)); + break; + case QEvent::DragLeave: + dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev)); + break; + case QEvent::DragMove: + dragMoveEvent(static_cast<QDragMoveEvent*>(ev)); + break; + case QEvent::Drop: + dropEvent(static_cast<QDropEvent*>(ev)); + break; +#endif // QT_NO_DRAGANDDROP + default: + return QObject::event(ev); } - return QObject::event(ev); + + return true; } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index 2500a2d33a..c666af2729 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -141,7 +141,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus Q_PROPERTY(QQmlListProperty<QQuickTransform> transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) - Q_PROPERTY(bool antialiasing READ antialiasing WRITE setAntialiasing NOTIFY antialiasingChanged) + Q_PROPERTY(bool antialiasing READ antialiasing WRITE setAntialiasing NOTIFY antialiasingChanged RESET resetAntialiasing) Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged) Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged) @@ -172,7 +172,8 @@ public: ItemParentHasChanged, // value.item ItemOpacityHasChanged, // value.realValue ItemActiveFocusHasChanged, // value.boolValue - ItemRotationHasChanged // value.realValue + ItemRotationHasChanged, // value.realValue + ItemAntialiasingHasChanged // value.boolValue }; union ItemChangeData { @@ -267,6 +268,7 @@ public: bool antialiasing() const; void setAntialiasing(bool); + void resetAntialiasing(); Flags flags() const; void setFlag(Flag flag, bool enabled = true); diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 44eabcf0d5..96cb9e8843 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -422,6 +422,8 @@ public: bool hasCursor:1; // Bit 32 bool activeFocusOnTab:1; + bool implicitAntialiasing:1; + bool antialiasingValid:1; enum DirtyType { TransformOrigin = 0x00000001, @@ -521,6 +523,8 @@ public: virtual void implicitWidthChanged(); virtual void implicitHeightChanged(); + void setImplicitAntialiasing(bool antialiasing); + void resolveLayoutMirror(); void setImplicitLayoutMirror(bool mirror, bool inherit); void setLayoutMirror(bool mirror); @@ -540,16 +544,6 @@ public: #ifndef QT_NO_IM void deliverInputMethodEvent(QInputMethodEvent *); #endif - void deliverFocusEvent(QFocusEvent *); - void deliverMouseEvent(QMouseEvent *); -#ifndef QT_NO_WHEELEVENT - void deliverWheelEvent(QWheelEvent *); -#endif - void deliverTouchEvent(QTouchEvent *); - void deliverHoverEvent(QHoverEvent *); -#ifndef QT_NO_DRAGANDDROP - void deliverDragEvent(QEvent *); -#endif bool calcEffectiveVisible() const; bool setEffectiveVisibleRecur(bool); @@ -589,6 +583,9 @@ public: virtual void mirrorChange() {} void incrementCursorCount(int delta); + + // recursive helper to let a visual parent mark its visual children + void markObjects(QV4::ExecutionEngine *e); }; /* diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index a5b78b28e1..96746223ce 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -184,6 +184,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType<QQuickTranslate>(uri,major,minor,"Translate"); qmlRegisterType<QQuickRotation>(uri,major,minor,"Rotation"); qmlRegisterType<QQuickScale>(uri,major,minor,"Scale"); + qmlRegisterType<QQuickMatrix4x4>(uri,2,4,"Matrix4x4"); qmlRegisterType<QQuickText>(uri,major,minor,"Text"); qmlRegisterType<QQuickTextEdit>(uri,major,minor,"TextEdit"); qmlRegisterType<QQuickTextEdit,1>(uri,2,1,"TextEdit"); @@ -261,6 +262,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType<QQuickItem, 1>(uri, 2, 1,"Item"); qmlRegisterType<QQuickGrid, 1>(uri, 2, 1, "Grid"); qmlRegisterUncreatableType<QQuickItemView, 1>(uri, 2, 1, "ItemView", QQuickItemView::tr("ItemView is an abstract base class")); + qmlRegisterUncreatableType<QQuickItemView, 2>(uri, 2, 3, "ItemView", QQuickItemView::tr("ItemView is an abstract base class")); qmlRegisterType<QQuickListView, 1>(uri, 2, 1, "ListView"); qmlRegisterType<QQuickGridView, 1>(uri, 2, 1, "GridView"); qmlRegisterType<QQuickTextEdit, 1>(uri, 2, 1, "TextEdit"); diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index d7b984788e..f5c0e3b8d2 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -459,6 +459,41 @@ void QQuickItemView::setCacheBuffer(int b) } } +int QQuickItemView::displayMarginBeginning() const +{ + Q_D(const QQuickItemView); + return d->displayMarginBeginning; +} + +void QQuickItemView::setDisplayMarginBeginning(int margin) +{ + Q_D(QQuickItemView); + if (d->displayMarginBeginning != margin) { + d->displayMarginBeginning = margin; + if (isComponentComplete()) { + d->refillOrLayout(); + } + emit displayMarginBeginningChanged(); + } +} + +int QQuickItemView::displayMarginEnd() const +{ + Q_D(const QQuickItemView); + return d->displayMarginEnd; +} + +void QQuickItemView::setDisplayMarginEnd(int margin) +{ + Q_D(QQuickItemView); + if (d->displayMarginEnd != margin) { + d->displayMarginEnd = margin; + if (isComponentComplete()) { + d->refillOrLayout(); + } + emit displayMarginEndChanged(); + } +} Qt::LayoutDirection QQuickItemView::layoutDirection() const { @@ -1443,6 +1478,7 @@ void QQuickItemView::componentComplete() QQuickItemViewPrivate::QQuickItemViewPrivate() : itemCount(0) , buffer(QML_VIEW_DEFAULTCACHEBUFFER), bufferMode(BufferBefore | BufferAfter) + , displayMarginBeginning(0), displayMarginEnd(0) , layoutDirection(Qt::LeftToRight), verticalLayoutDirection(QQuickItemView::TopToBottom) , moveReason(Other) , visibleIndex(0) @@ -1682,9 +1718,9 @@ void QQuickItemViewPrivate::refill() { qreal s = qMax(size(), qreal(0.)); if (isContentFlowReversed()) - refill(-position()-s, -position()); + refill(-position()-displayMarginBeginning-s, -position()+displayMarginEnd); else - refill(position(), position()+s); + refill(position()-displayMarginBeginning, position()+displayMarginEnd+s); } void QQuickItemViewPrivate::refill(qreal from, qreal to) diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h index 17d150f480..ad026a3152 100644 --- a/src/quick/items/qquickitemview_p.h +++ b/src/quick/items/qquickitemview_p.h @@ -63,6 +63,8 @@ class Q_AUTOTEST_EXPORT QQuickItemView : public QQuickFlickable Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) + Q_PROPERTY(int displayMarginBeginning READ displayMarginBeginning WRITE setDisplayMarginBeginning NOTIFY displayMarginBeginningChanged REVISION 2) + Q_PROPERTY(int displayMarginEnd READ displayMarginEnd WRITE setDisplayMarginEnd NOTIFY displayMarginEndChanged REVISION 2) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged) @@ -133,6 +135,12 @@ public: int cacheBuffer() const; void setCacheBuffer(int); + int displayMarginBeginning() const; + void setDisplayMarginBeginning(int); + + int displayMarginEnd() const; + void setDisplayMarginEnd(int); + Qt::LayoutDirection layoutDirection() const; void setLayoutDirection(Qt::LayoutDirection); Qt::LayoutDirection effectiveLayoutDirection() const; @@ -218,6 +226,8 @@ Q_SIGNALS: void keyNavigationWrapsChanged(); void cacheBufferChanged(); + void displayMarginBeginningChanged(); + void displayMarginEndChanged(); void layoutDirectionChanged(); void effectiveLayoutDirectionChanged(); diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index e0f08fd50f..af7c23c02e 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -257,6 +257,8 @@ public: int itemCount; int buffer; int bufferMode; + int displayMarginBeginning; + int displayMarginEnd; Qt::LayoutDirection layoutDirection; QQuickItemView::VerticalLayoutDirection verticalLayoutDirection; diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 9f2f90a2a7..2dd61e386f 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -777,8 +777,8 @@ void QQuickListViewPrivate::visibleItemsChanged() void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex) { if (!visibleItems.isEmpty()) { - const qreal from = isContentFlowReversed() ? -position() - size() : position(); - const qreal to = isContentFlowReversed() ? -position() : position() + size(); + const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning; + const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd; FxViewItem *firstItem = *visibleItems.constBegin(); bool fixedCurrent = currentItem && firstItem->item == currentItem->item; @@ -892,12 +892,12 @@ void QQuickListViewPrivate::createHighlight() highlightWidthAnimator = new QSmoothedAnimation; highlightWidthAnimator->velocity = highlightResizeVelocity; highlightWidthAnimator->userDuration = highlightResizeDuration; - highlightWidthAnimator->target = QQmlProperty(item, "width"); + highlightWidthAnimator->target = QQmlProperty(item, QStringLiteral("width")); highlightHeightAnimator = new QSmoothedAnimation; highlightHeightAnimator->velocity = highlightResizeVelocity; highlightHeightAnimator->userDuration = highlightResizeDuration; - highlightHeightAnimator->target = QQmlProperty(item, "height"); + highlightHeightAnimator->target = QQmlProperty(item, QStringLiteral("height")); highlight = newHighlight; changed = true; @@ -2145,8 +2145,33 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation) of additional memory usage. It is not a substitute for creating efficient delegates; the fewer objects and bindings in a delegate, the faster a view can be scrolled. + + The cacheBuffer operates outside of any display margins specified by + displayMarginBeginning or displayMarginEnd. */ +/*! + \qmlproperty int QtQuick::ListView::displayMarginBeginning + \qmlproperty int QtQuick::ListView::displayMarginEnd + \since QtQuick 2.3 + + This property allows delegates to be displayed outside of the view geometry. + + If this value is non-zero, the view will create extra delegates before the + start of the view, or after the end. The view will create as many delegates + as it can fit into the pixel size specified. + + For example, if in a vertical view the delegate is 20 pixels high and + \c displayMarginBeginning and \c displayMarginEnd are both set to 40, + then 2 delegates above and 2 delegates below will be created and shown. + + The default value is 0. + + This property is meant for allowing certain UI configurations, + and not as a performance optimization. If you wish to create delegates + outside of the view geometry for performance reasons, you probably + want to use the cacheBuffer property instead. +*/ /*! \qmlpropertygroup QtQuick::ListView::section @@ -2703,8 +2728,8 @@ void QQuickListView::viewportMoved(Qt::Orientations orient) d->refillOrLayout(); // Set visibility of items to eliminate cost of items outside the visible area. - qreal from = d->isContentFlowReversed() ? -d->position()-d->size() : d->position(); - qreal to = d->isContentFlowReversed() ? -d->position() : d->position()+d->size(); + qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning; + qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd; for (int i = 0; i < d->visibleItems.count(); ++i) { FxViewItem *item = static_cast<FxListItemSG*>(d->visibleItems.at(i)); QQuickItemPrivate::get(item->item)->setCulled(item->endPosition() < from || item->position() > to); @@ -2910,7 +2935,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Insert &ch // there are no visible items except items marked for removal index = visibleItems.count(); } else if (visibleItems.at(i)->index + 1 == modelIndex - && visibleItems.at(i)->endPosition() <= buffer+tempPos+size()) { + && visibleItems.at(i)->endPosition() <= buffer+displayMarginEnd+tempPos+size()) { // Special case of appending an item to the model. index = visibleItems.count(); } else { @@ -2939,7 +2964,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Insert &ch // Insert items before the visible item. int insertionIdx = index; int i = 0; - int from = tempPos - buffer; + int from = tempPos - displayMarginBeginning - buffer; for (i = count-1; i >= 0; --i) { if (pos > from && insertionIdx < visibleIndex) { @@ -2970,7 +2995,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Insert &ch } } else { int i = 0; - int to = buffer+tempPos+size(); + int to = buffer+displayMarginEnd+tempPos+size(); for (i = 0; i < count && pos <= to; ++i) { FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 7a4b359d91..f07571d3cc 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -49,6 +49,7 @@ #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qevent.h> +#include <QtGui/qstylehints.h> #include <float.h> @@ -56,8 +57,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING) -static const int PressAndHoldDelay = 800; - QQuickMouseAreaPrivate::QQuickMouseAreaPrivate() : enabled(true), hovered(false), longPress(false), moved(false), stealMouse(false), doubleClick(false), preventStealing(false), @@ -627,7 +626,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event) #endif setHovered(true); d->startScene = event->windowPos(); - d->pressAndHoldTimer.start(PressAndHoldDelay, this); + d->pressAndHoldTimer.start(qApp->styleHints()->mousePressAndHoldInterval(), this); setKeepMouseGrab(d->stealMouse); event->setAccepted(setPressed(event->button(), true)); } diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 8fe306b006..6b273dcd43 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -43,6 +43,7 @@ #include <QtQuick/qquickwindow.h> #include <private/qsgadaptationlayer_p.h> #include <private/qquickitem_p.h> +#include <private/qguiapplication_p.h> #include <QEvent> #include <QMouseEvent> #include <math.h> @@ -675,6 +676,10 @@ bool QQuickMultiPointTouchArea::sendMouseEvent(QMouseEvent *event) QMouseEvent mouseEvent(event->type(), localPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); mouseEvent.setAccepted(false); + QGuiApplicationPrivate::setMouseEventCapsAndVelocity(&mouseEvent, + QGuiApplicationPrivate::mouseEventCaps(event), + QGuiApplicationPrivate::mouseEventVelocity(event)); + QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, Qt::MouseEventSynthesizedByQt); switch (mouseEvent.type()) { case QEvent::MouseMove: diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index 48f79a2192..ee1b66f2b5 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -321,6 +321,16 @@ void QQuickRectangle::doUpdate() } /*! + \qmlproperty bool QtQuick::Rectangle::antialiasing + + Used to decide if the Rectangle should use antialiasing or not. + \l {Antialiasing} provides information on the performance implications + of this property. + + The default is true for Rectangles with a radius, and false otherwise. +*/ + +/*! \qmlpropertygroup QtQuick::Rectangle::border \qmlproperty int QtQuick::Rectangle::border.width \qmlproperty color QtQuick::Rectangle::border.color @@ -409,6 +419,8 @@ void QQuickRectangle::setRadius(qreal radius) return; d->radius = radius; + d->setImplicitAntialiasing(radius != 0.0); + update(); emit radiusChanged(); } @@ -476,7 +488,7 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData } rectangle->setRadius(d->radius); - rectangle->setAntialiasing(d->antialiasing || d->radius > 0); + rectangle->setAntialiasing(antialiasing()); QGradientStops stops; if (d->gradient) { diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index ad904a2579..beb2039924 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -88,6 +88,7 @@ QQuickTextPrivate::QQuickTextPrivate() , truncated(false), hAlignImplicit(true), rightToLeftText(false) , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false), formatModifiesFontSize(false) { + implicitAntialiasing = true; } QQuickTextPrivate::ExtraData::ExtraData() @@ -114,6 +115,7 @@ QQuickTextDocumentWithImageResources::QQuickTextDocumentWithImageResources(QQuic { setUndoRedoEnabled(false); documentLayout()->registerHandler(QTextFormat::ImageObject, this); + connect(this, SIGNAL(baseUrlChanged(QUrl)), this, SLOT(reset())); } QQuickTextDocumentWithImageResources::~QQuickTextDocumentWithImageResources() @@ -125,14 +127,13 @@ QQuickTextDocumentWithImageResources::~QQuickTextDocumentWithImageResources() QVariant QQuickTextDocumentWithImageResources::loadResource(int type, const QUrl &name) { QQmlContext *context = qmlContext(parent()); - QUrl url = m_baseUrl.resolved(name); if (type == QTextDocument::ImageResource) { - QQuickPixmap *p = loadPixmap(context, url); + QQuickPixmap *p = loadPixmap(context, name); return p->image(); } - return QTextDocument::loadResource(type,url); // The *resolved* URL + return QTextDocument::loadResource(type, name); } void QQuickTextDocumentWithImageResources::requestFinished() @@ -144,14 +145,6 @@ void QQuickTextDocumentWithImageResources::requestFinished() } } -void QQuickTextDocumentWithImageResources::clear() -{ - clearResources(); - - QTextDocument::clear(); -} - - QSizeF QQuickTextDocumentWithImageResources::intrinsicSize( QTextDocument *, int, const QTextFormat &format) { @@ -166,7 +159,7 @@ QSizeF QQuickTextDocumentWithImageResources::intrinsicSize( QSizeF size(width, height); if (!hasWidth || !hasHeight) { QQmlContext *context = qmlContext(parent()); - QUrl url = m_baseUrl.resolved(QUrl(imageFormat.name())); + QUrl url = baseUrl().resolved(QUrl(imageFormat.name())); QQuickPixmap *p = loadPixmap(context, url); if (!p->isReady()) { @@ -204,19 +197,16 @@ void QQuickTextDocumentWithImageResources::drawObject( QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format) { QQmlContext *context = qmlContext(parent()); - QUrl url = m_baseUrl.resolved(QUrl(format.name())); + QUrl url = baseUrl().resolved(QUrl(format.name())); QQuickPixmap *p = loadPixmap(context, url); return p->image(); } -void QQuickTextDocumentWithImageResources::setBaseUrl(const QUrl &url, bool clear) +void QQuickTextDocumentWithImageResources::reset() { - m_baseUrl = url; - if (clear) { - clearResources(); - markContentsDirty(0, characterCount()); - } + clearResources(); + markContentsDirty(0, characterCount()); } QQuickPixmap *QQuickTextDocumentWithImageResources::loadPixmap( @@ -297,6 +287,15 @@ qreal QQuickTextPrivate::getImplicitHeight() const return implicitHeight; } +/*! + \qmlproperty bool QtQuick::Text::antialiasing + + Used to decide if the Text should use antialiasing or not. Only Text + with renderType of Text.NativeRendering can disable antialiasing. + + The default is true. +*/ + void QQuickText::q_imagesLoaded() { Q_D(QQuickText); @@ -620,8 +619,9 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, textLine->setHeight(0); textLine->setLineOffset(lineOffset); - // use the text item's width by default if it has one and wrap is on - if (q->widthValid() && q->wrapMode() != QQuickText::NoWrap) + // use the text item's width by default if it has one and wrap is on or text must be aligned + if (q->widthValid() && (q->wrapMode() != QQuickText::NoWrap || + q->effectiveHAlign() != QQuickText::AlignLeft)) textLine->setWidth(q->width()); else textLine->setWidth(INT_MAX); @@ -959,7 +959,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) // If the horizontal alignment is not left and the width was not valid we need to relayout // now that we know the maximum line width. - if (!implicitWidthValid && lineCount > 1 && q->effectiveHAlign() != QQuickText::AlignLeft) { + if (!implicitWidthValid && unwrappedLineCount > 1 && q->effectiveHAlign() != QQuickText::AlignLeft) { widthExceeded = false; heightExceeded = false; continue; @@ -1415,6 +1415,9 @@ void QQuickText::setFont(const QFont &font) QFont oldFont = d->font; d->font = font; + if (!antialiasing()) + d->font.setStyleStrategy(QFont::NoAntialias); + if (d->font.pointSizeF() != -1) { // 0.5pt resolution qreal size = qRound(d->font.pointSizeF()*2.0); @@ -1434,6 +1437,21 @@ void QQuickText::setFont(const QFont &font) emit fontChanged(d->sourceFont); } +void QQuickText::itemChange(ItemChange change, const ItemChangeData &value) +{ + Q_D(QQuickText); + Q_UNUSED(value); + if (change == ItemAntialiasingHasChanged) { + if (!antialiasing()) + d->font.setStyleStrategy(QFont::NoAntialias); + else + d->font.setStyleStrategy(QFont::PreferAntialias); + d->implicitWidthValid = false; + d->implicitHeightValid = false; + d->updateLayout(); + } +} + /*! \qmlproperty string QtQuick::Text::text diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index 489ef58344..d55dc7e287 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -241,6 +241,7 @@ Q_SIGNALS: protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); + virtual void itemChange(ItemChange change, const ItemChangeData &value); virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 1f6cd3eab5..12113f416c 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -195,16 +195,13 @@ public: void setText(const QString &); int resourcesLoading() const { return outstanding; } - void clearResources(); - - void clear(); - QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format); void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format); QImage image(const QTextImageFormat &format); - void setBaseUrl(const QUrl &url, bool clear = true); +public Q_SLOTS: + void clearResources(); Q_SIGNALS: void imagesLoaded(); @@ -215,11 +212,11 @@ protected: QQuickPixmap *loadPixmap(QQmlContext *context, const QUrl &name); private Q_SLOTS: + void reset(); void requestFinished(); private: QHash<QUrl, QQuickPixmap *> m_resources; - QUrl m_baseUrl; int outstanding; static QSet<QUrl> errors; diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index ffc732621d..c342c79ce5 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -830,7 +830,7 @@ void QQuickTextEdit::setBaseUrl(const QUrl &url) if (baseUrl() != url) { d->baseUrl = url; - d->document->setBaseUrl(url, d->richText); + d->document->setBaseUrl(url); emit baseUrlChanged(); } } @@ -1281,7 +1281,7 @@ void QQuickTextEdit::componentComplete() Q_D(QQuickTextEdit); QQuickImplicitSizeItem::componentComplete(); - d->document->setBaseUrl(baseUrl(), d->richText); + d->document->setBaseUrl(baseUrl()); #ifndef QT_NO_TEXTHTML_PARSER if (d->richText) d->control->setHtml(d->text); diff --git a/src/quick/items/qquicktranslate.cpp b/src/quick/items/qquicktranslate.cpp index f1b716cf5b..5c61fb33f8 100644 --- a/src/quick/items/qquicktranslate.cpp +++ b/src/quick/items/qquicktranslate.cpp @@ -458,4 +458,79 @@ void QQuickRotation::applyTo(QMatrix4x4 *matrix) const matrix->translate(-d->origin); } +class QQuickMatrix4x4Private : public QQuickTransformPrivate +{ +public: + QQuickMatrix4x4Private() + : matrix() {} + QMatrix4x4 matrix; +}; + +/*! + \qmltype Matrix4x4 + \instantiates QQuickMatrix4x4 + \inqmlmodule QtQuick + \ingroup qtquick-visual-transforms + \brief Provides a way to apply a 4x4 tranformation matrix to an \l Item + + The Matrix4x4 type provides a way to apply a transformation to an + \l Item through a 4x4 matrix. + + It allows for a combination of rotation, scale, translatation and shearing + by using just one tranformation provided in a 4x4-matrix. + + The following example rotates a Rectangle 45 degress (PI/4): + + \qml + Rectangle { + width: 100 + height: 100 + color: "red" + + transform: Matrix4x4 { + property real a: Math.PI / 4 + matrix: Qt.matrix4x4(Math.cos(a), -Math.sin(a), 0, 0, + Math.sin(a), Math.cos(a), 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1) + } + } + \endqml +*/ +QQuickMatrix4x4::QQuickMatrix4x4(QObject *parent) + : QQuickTransform(*new QQuickMatrix4x4Private, parent) +{ +} + +QQuickMatrix4x4::~QQuickMatrix4x4() +{ +} + +/*! + \qmlproperty QMatrix4x4 QtQuick::Matrix4x4::matrix + + 4x4-matrix which will be used in the tranformation of an \l Item +*/ +QMatrix4x4 QQuickMatrix4x4::matrix() const +{ + Q_D(const QQuickMatrix4x4); + return d->matrix; +} + +void QQuickMatrix4x4::setMatrix(const QMatrix4x4 &matrix) +{ + Q_D(QQuickMatrix4x4); + if (d->matrix == matrix) + return; + d->matrix = matrix; + update(); + emit matrixChanged(); +} + +void QQuickMatrix4x4::applyTo(QMatrix4x4 *matrix) const +{ + Q_D(const QQuickMatrix4x4); + *matrix *= d->matrix; +} + QT_END_NAMESPACE diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h index d7843fe103..dd93275a28 100644 --- a/src/quick/items/qquicktranslate_p.h +++ b/src/quick/items/qquicktranslate_p.h @@ -148,6 +148,29 @@ private: Q_DECLARE_PRIVATE(QQuickRotation) }; +class QQuickMatrix4x4Private; +class Q_AUTOTEST_EXPORT QQuickMatrix4x4 : public QQuickTransform +{ + Q_OBJECT + + Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged) +public: + QQuickMatrix4x4(QObject *parent = 0); + ~QQuickMatrix4x4(); + + QMatrix4x4 matrix() const; + void setMatrix(const QMatrix4x4& matrix); + + void applyTo(QMatrix4x4 *matrix) const; + +Q_SIGNALS: + void matrixChanged(); + +private: + Q_DECLARE_PRIVATE(QQuickMatrix4x4) +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickTranslate) diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index d1fe489dcb..61f0f9bec2 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -56,6 +56,26 @@ QT_BEGIN_NAMESPACE +DEFINE_MANAGED_VTABLE(QQuickRootItemMarker); + +QQuickRootItemMarker::QQuickRootItemMarker(QQuickViewPrivate *view) + : QV4::Object(QQmlEnginePrivate::getV4Engine(view->engine.data())) + , view(view) +{ + setVTable(&static_vtbl); +} + +void QQuickRootItemMarker::markObjects(QV4::Managed *that, QV4::ExecutionEngine *e) +{ + QQuickItem *root = static_cast<QQuickRootItemMarker*>(that)->view->root; + if (root) { + QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(root); + rootPrivate->markObjects(e); + } + + QV4::Object::markObjects(that, e); +} + void QQuickViewPrivate::init(QQmlEngine* e) { Q_Q(QQuickView); @@ -68,6 +88,13 @@ void QQuickViewPrivate::init(QQmlEngine* e) if (!engine.data()->incubationController()) engine.data()->setIncubationController(q->incubationController()); + { + QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine.data()); + QV4::Scope scope(v4); + QV4::Scoped<QQuickRootItemMarker> v(scope, new (v4->memoryManager) QQuickRootItemMarker(this)); + rootItemMarker = v; + } + if (QQmlDebugService::isDebuggingEnabled()) QQmlInspectorService::instance()->addView(q); } diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 170c93a6cf..e18b45dfbe 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -51,12 +51,17 @@ #include <QtCore/QWeakPointer> #include <QtQml/qqmlengine.h> +#include <private/qv4object_p.h> #include "qquickwindow_p.h" #include "qquickitemchangelistener_p.h" QT_BEGIN_NAMESPACE +namespace QV4 { +struct ExecutionEngine; +} + class QQmlContext; class QQmlError; class QQuickItem; @@ -94,6 +99,23 @@ public: QQuickView::ResizeMode resizeMode; QSize initialSize; QElapsedTimer frameTimer; + QV4::PersistentValue rootItemMarker; +}; + +struct QQuickRootItemMarker : public QV4::Object +{ + Q_MANAGED + + QQuickRootItemMarker(QQuickViewPrivate *view); + + static void destroy(Managed *that) + { + static_cast<QQuickRootItemMarker*>(that)->~QQuickRootItemMarker(); + } + + static void markObjects(Managed *that, QV4::ExecutionEngine *e); + + QQuickViewPrivate *view; }; QT_END_NAMESPACE diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index d286ccff0c..b8c180e2fd 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -470,6 +470,7 @@ static QMouseEvent *touchToMouseEvent(QEvent::Type type, const QTouchEvent::Touc transformedVelocity = transformMatrix.mapVector(p.velocity()).toVector2D(); } QGuiApplicationPrivate::setMouseEventCapsAndVelocity(me, event->device()->capabilities(), transformedVelocity); + QGuiApplicationPrivate::setMouseEventSource(me, Qt::MouseEventSynthesizedByQt); return me; } @@ -523,7 +524,7 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e item->grabMouse(); item->grabTouchPoints(QVector<int>() << touchMouseId); - QQuickItemPrivate::get(item)->deliverMouseEvent(mousePress.data()); + QCoreApplication::sendEvent(item, mousePress.data()); event->setAccepted(mousePress->isAccepted()); if (!mousePress->isAccepted()) { touchMouseId = -1; @@ -536,7 +537,7 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e if (mousePress->isAccepted() && checkIfDoubleClicked(event->timestamp())) { QScopedPointer<QMouseEvent> mouseDoubleClick(touchToMouseEvent(QEvent::MouseButtonDblClick, p, event, item)); - QQuickItemPrivate::get(item)->deliverMouseEvent(mouseDoubleClick.data()); + QCoreApplication::sendEvent(item, mouseDoubleClick.data()); event->setAccepted(mouseDoubleClick->isAccepted()); if (mouseDoubleClick->isAccepted()) { return true; @@ -557,7 +558,7 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e if (p.state() & Qt::TouchPointMoved) { if (mouseGrabberItem) { QScopedPointer<QMouseEvent> me(touchToMouseEvent(QEvent::MouseMove, p, event, mouseGrabberItem)); - QQuickItemPrivate::get(item)->deliverMouseEvent(me.data()); + QCoreApplication::sendEvent(item, me.data()); event->setAccepted(me->isAccepted()); if (me->isAccepted()) { itemForTouchPointId[p.id()] = mouseGrabberItem; // N.B. the mouseGrabberItem may be different after returning from sendEvent() @@ -587,7 +588,7 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e touchMouseId = -1; if (mouseGrabberItem) { QScopedPointer<QMouseEvent> me(touchToMouseEvent(QEvent::MouseButtonRelease, p, event, mouseGrabberItem)); - QQuickItemPrivate::get(item)->deliverMouseEvent(me.data()); + QCoreApplication::sendEvent(item, me.data()); if (mouseGrabberItem) // might have ungrabbed due to event mouseGrabberItem->ungrabMouse(); return me->isAccepted(); @@ -1325,6 +1326,7 @@ QMouseEvent *QQuickWindowPrivate::cloneMouseEvent(QMouseEvent *event, QPointF *t event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); QGuiApplicationPrivate::setMouseEventCapsAndVelocity(me, caps, velocity); + QGuiApplicationPrivate::setMouseEventSource(me, QGuiApplicationPrivate::mouseEventSource(event)); me->setTimestamp(event->timestamp()); return me; } @@ -1401,6 +1403,12 @@ bool QQuickWindowPrivate::deliverMouseEvent(QMouseEvent *event) void QQuickWindow::mousePressEvent(QMouseEvent *event) { Q_D(QQuickWindow); + + if (event->source() == Qt::MouseEventSynthesizedBySystem) { + event->accept(); + return; + } + #ifdef MOUSE_DEBUG qWarning() << "QQuickWindow::mousePressEvent()" << event->localPos() << event->button() << event->buttons(); #endif @@ -1412,6 +1420,12 @@ void QQuickWindow::mousePressEvent(QMouseEvent *event) void QQuickWindow::mouseReleaseEvent(QMouseEvent *event) { Q_D(QQuickWindow); + + if (event->source() == Qt::MouseEventSynthesizedBySystem) { + event->accept(); + return; + } + #ifdef MOUSE_DEBUG qWarning() << "QQuickWindow::mouseReleaseEvent()" << event->localPos() << event->button() << event->buttons(); #endif @@ -1430,6 +1444,12 @@ void QQuickWindow::mouseReleaseEvent(QMouseEvent *event) void QQuickWindow::mouseDoubleClickEvent(QMouseEvent *event) { Q_D(QQuickWindow); + + if (event->source() == Qt::MouseEventSynthesizedBySystem) { + event->accept(); + return; + } + #ifdef MOUSE_DEBUG qWarning() << "QQuickWindow::mouseDoubleClickEvent()" << event->localPos() << event->button() << event->buttons(); #endif @@ -1465,6 +1485,12 @@ bool QQuickWindowPrivate::sendHoverEvent(QEvent::Type type, QQuickItem *item, void QQuickWindow::mouseMoveEvent(QMouseEvent *event) { Q_D(QQuickWindow); + + if (event->source() == Qt::MouseEventSynthesizedBySystem) { + event->accept(); + return; + } + #ifdef MOUSE_DEBUG qWarning() << "QQuickWindow::mouseMoveEvent()" << event->localPos() << event->button() << event->buttons(); #endif @@ -1813,11 +1839,11 @@ bool QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QTouchEv itemForTouchPointId[id] = item; // Deliver the touch event to the given item - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - itemPrivate->deliverTouchEvent(touchEvent.data()); + QCoreApplication::sendEvent(item, touchEvent.data()); touchEventAccepted = touchEvent->isAccepted(); // If the touch event wasn't accepted, synthesize a mouse event and see if the item wants it. + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); if (!touchEventAccepted && (itemPrivate->acceptedMouseButtons() & Qt::LeftButton)) { // send mouse event event->setAccepted(translateTouchToMouse(item, event)); @@ -2235,16 +2261,12 @@ bool QQuickWindow::sendEvent(QQuickItem *item, QEvent *e) case QEvent::KeyPress: case QEvent::KeyRelease: e->accept(); - QQuickItemPrivate::get(item)->deliverKeyEvent(static_cast<QKeyEvent *>(e)); + QCoreApplication::sendEvent(item, e); while (!e->isAccepted() && (item = item->parentItem())) { e->accept(); - QQuickItemPrivate::get(item)->deliverKeyEvent(static_cast<QKeyEvent *>(e)); + QCoreApplication::sendEvent(item, e); } break; - case QEvent::FocusIn: - case QEvent::FocusOut: - QQuickItemPrivate::get(item)->deliverFocusEvent(static_cast<QFocusEvent *>(e)); - break; case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: @@ -2253,7 +2275,7 @@ bool QQuickWindow::sendEvent(QQuickItem *item, QEvent *e) if (!d->sendFilteredMouseEvent(item->parentItem(), item, e)) { // accept because qml items by default accept and have to explicitly opt out of accepting e->accept(); - QQuickItemPrivate::get(item)->deliverMouseEvent(static_cast<QMouseEvent *>(e)); + QCoreApplication::sendEvent(item, e); } break; case QEvent::UngrabMouse: @@ -2264,30 +2286,26 @@ bool QQuickWindow::sendEvent(QQuickItem *item, QEvent *e) break; #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: - QQuickItemPrivate::get(item)->deliverWheelEvent(static_cast<QWheelEvent *>(e)); - break; #endif +#ifndef QT_NO_DRAGANDDROP + case QEvent::DragEnter: + case QEvent::DragMove: + case QEvent::DragLeave: + case QEvent::Drop: +#endif + case QEvent::FocusIn: + case QEvent::FocusOut: case QEvent::HoverEnter: case QEvent::HoverLeave: case QEvent::HoverMove: - QQuickItemPrivate::get(item)->deliverHoverEvent(static_cast<QHoverEvent *>(e)); + case QEvent::TouchCancel: + QCoreApplication::sendEvent(item, e); break; case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: d->sendFilteredTouchEvent(item->parentItem(), item, static_cast<QTouchEvent *>(e)); break; - case QEvent::TouchCancel: - QQuickItemPrivate::get(item)->deliverTouchEvent(static_cast<QTouchEvent *>(e)); - break; -#ifndef QT_NO_DRAGANDDROP - case QEvent::DragEnter: - case QEvent::DragMove: - case QEvent::DragLeave: - case QEvent::Drop: - QQuickItemPrivate::get(item)->deliverDragEvent(e); - break; -#endif default: break; } diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index 460e2ca554..407b80915d 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -185,7 +185,8 @@ void QQuickBehavior::write(const QVariant &value) return; } - if (d->animation->isRunning() && value == d->targetValue) + bool behaviorActive = d->animation->isRunning(); + if (behaviorActive && value == d->targetValue) return; d->targetValue = value; @@ -201,6 +202,14 @@ void QQuickBehavior::write(const QVariant &value) // to the item, so we need to read the value after. const QVariant ¤tValue = d->property.read(); + // Don't unnecessarily wake up the animation system if no real animation + // is needed (value has not changed). If the Behavior was already + // running, let it continue as normal to ensure correct behavior and state. + if (!behaviorActive && d->targetValue == currentValue) { + QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + return; + } + QQuickStateOperation::ActionList actions; QQuickStateAction action; action.property = d->property; diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index bca40e9acd..4a8025c254 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -124,7 +124,7 @@ void tst_QQmlDebugClient::state() QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable); // duplicate plugin name - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\""); QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn); QCOMPARE(client2.state(), QQmlDebugClient::NotConnected); diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 1c1d84f37b..c50bb10035 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -164,7 +164,7 @@ void tst_QQmlDebugService::state() QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable); - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\""); QQmlDebugTestService duplicate("tst_QQmlDebugService::state()"); QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected); } @@ -183,7 +183,7 @@ void tst_QQmlDebugService::sendMessage() QByteArray resp = client.waitForResponse(); QCOMPARE(resp, msg); - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\""); QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()"); duplicate.sendMessage("msg"); } diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml index 7e85312692..cd68fb9b82 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml @@ -91,4 +91,15 @@ QtObject { testObjectWithAliasHandler.count++ return testObjectWithAliasHandler.testSuccess } + + signal signalWithClosureArgument(var f) + onSignalWithClosureArgument: f() + + function testSignalWithClosureArgument() { + var testSuccess = false + signalWithClosureArgument(function() { + testSuccess = true + }) + return testSuccess + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c45750caac..ea7259c597 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -6069,6 +6069,9 @@ void tst_qqmlecmascript::signalHandlers() QMetaObject::invokeMethod(o, "testAliasSignalHandler", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); + QMetaObject::invokeMethod(o, "testSignalWithClosureArgument", Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result.toBool(), true); + delete o; } diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp index 44fbb0a982..c3d8a1502c 100644 --- a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp +++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp @@ -203,7 +203,7 @@ void tst_qqmlerror::debug() error.setLine(92); error.setColumn(13); - QTest::ignoreMessage(QtWarningMsg, "http://www.qt-project.org/main.qml:92:13: An Error "); + QTest::ignoreMessage(QtWarningMsg, "http://www.qt-project.org/main.qml:92:13: An Error"); qWarning() << error; } diff --git a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp index 793da64734..2d7e0a8594 100644 --- a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp +++ b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp @@ -63,7 +63,7 @@ void tst_qqmlglobal::initTestCase() void tst_qqmlglobal::colorProviderWarning() { - const QLatin1String expected("Warning: QQml_colorProvider: no color provider has been set! "); + const QLatin1String expected("Warning: QQml_colorProvider: no color provider has been set!"); QTest::ignoreMessage(QtWarningMsg, expected.data()); QQml_colorProvider(); } diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 0cd4360e67..9d62aa2984 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -500,7 +500,7 @@ void tst_qqmlinstruction::dump() << "8\t\tSTORE_INTEGER\t\t5\t9" << "9\t\tSTORE_BOOL\t\t6\ttrue" << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\"" - << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.qt-project.org\") " + << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.qt-project.org\")" << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\"" << "13\t\tSTORE_DATE\t\t10\t9" << "14\t\tSTORE_TIME\t\t11" diff --git a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp index d5e85f478d..143164841f 100644 --- a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp +++ b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp @@ -1725,11 +1725,11 @@ void tst_qqmllistcompositor::changeDebug() void tst_qqmllistcompositor::groupDebug() { - QTest::ignoreMessage(QtDebugMsg, "Default "); + QTest::ignoreMessage(QtDebugMsg, "Default"); qDebug() << C::Default; - QTest::ignoreMessage(QtDebugMsg, "Cache "); + QTest::ignoreMessage(QtDebugMsg, "Cache"); qDebug() << C::Cache; - QTest::ignoreMessage(QtDebugMsg, "Group3 "); + QTest::ignoreMessage(QtDebugMsg, "Group3"); qDebug() << Selection; } diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp index b1f83fcd6c..b0c7c5e81a 100644 --- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -329,11 +329,11 @@ void tst_QQmlMetaObject::method_data() << (QList<QByteArray>() << "int" << "bool" << "double") << (QList<QByteArray>() << "foo" << "bar" << "baz"); QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml" - << "testSignal(QVariant,QVariant)" + << "testSignal(QVariant,QJSValue)" << QMetaMethod::Signal << int(QMetaType::Void) << "void" - << (QList<int>() << QMetaType::QVariant << QMetaType::QVariant) - << (QList<QByteArray>() << "QVariant" << "QVariant") + << (QList<int>() << QMetaType::QVariant << qMetaTypeId<QJSValue>()) + << (QList<QByteArray>() << "QVariant" << "QJSValue") << (QList<QByteArray>() << "foo" << "bar"); QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml" << "testSignal(QColor,QDateTime,QUrl)" diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 62b64a3ef1..669ae7d5ea 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -123,21 +123,21 @@ void tst_QQmlPropertyMap::insert() //inserting property names same with existing method(signal, slot, method) names is not allowed //QQmlPropertyMap has an invokable keys() method - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("keys"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("keys"))); QVERIFY(map.value(QLatin1String("keys")).isNull()); //QQmlPropertyMap has a deleteLater() slot - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("deleteLater"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("deleteLater"))); QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); //QQmlPropertyMap has an valueChanged() signal - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("valueChanged"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("valueChanged"))); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 7c0507dce3..5b8695f8f8 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -804,7 +804,7 @@ void tst_qqmlvaluetypes::font() // Test pixelSize and pointSize { QQmlComponent component(&engine, testFileUrl("font_write.3.qml")); - QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size."); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); @@ -814,7 +814,7 @@ void tst_qqmlvaluetypes::font() } { QQmlComponent component(&engine, testFileUrl("font_write.4.qml")); - QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size."); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); diff --git a/examples/quick/dialogs/systemdialogs/main.cpp b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml index f6723bb35b..9cf22dc7a1 100644 --- a/examples/quick/dialogs/systemdialogs/main.cpp +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml @@ -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 examples of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -37,5 +37,35 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(dialogs/systemdialogs/systemdialogs) + +import QtQuick 2.0 + +Item { + width: 400; height: 400 + + property alias animRunning: springAnim.running + + Rectangle { + objectName: "myRect" + color: "green" + width: 20; height: 20 + + property bool triggered: false + + onXChanged: { + if (!triggered && x > 50 && x < 80) { + triggered = true + x = x //set same value + } + } + + Behavior on x { + SpringAnimation { + id: springAnim + spring: 3 + damping: 0.2 + mass: .5 + } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml new file mode 100644 index 0000000000..db076bca9a --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + + property int behaviorCount: 0 + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + ScriptAction { script: ++behaviorCount } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index c40abbd55f..5deda2d96b 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -81,6 +81,7 @@ private slots: void delayedRegistration(); void startOnCompleted(); void multipleChangesToValueType(); + void currentValue(); }; void tst_qquickbehaviors::simpleBehavior() @@ -495,6 +496,59 @@ void tst_qquickbehaviors::multipleChangesToValueType() QTRY_COMPARE(text->property("font").value<QFont>(), value); } +//QTBUG-21549 +void tst_qquickbehaviors::currentValue() +{ + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug21549.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + + QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect"); + QVERIFY(target); + + QCOMPARE(target->x(), qreal(0)); + + target->setProperty("x", 50); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(50)); + + target->setProperty("x", 50); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(50)); + + target->setX(100); + target->setProperty("x", 100); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(100)); + + delete item; + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug21549-2.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + + QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect"); + QVERIFY(target); + + QCOMPARE(target->x(), qreal(0)); + + target->setProperty("x", 100); + + // the spring animation should smoothly transition to the new value triggered + // in the QML (which should be between 50 and 80); + QTRY_COMPARE(item->property("animRunning").toBool(), true); + QTRY_COMPARE(item->property("animRunning").toBool(), false); + QVERIFY(target->x() > qreal(50) && target->x() < qreal(80)); + + delete item; + } +} + QTEST_MAIN(tst_qquickbehaviors) #include "tst_qquickbehaviors.moc" diff --git a/src/imports/dialogs/qquickplatformfiledialog_p.h b/tests/auto/quick/qquickgridview/data/displayMargin.qml index 5431836271..1086b8defd 100644 --- a/src/imports/dialogs/qquickplatformfiledialog_p.h +++ b/tests/auto/quick/qquickgridview/data/displayMargin.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Jolla Ltd. ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQuick.Dialogs module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -39,40 +39,47 @@ ** ****************************************************************************/ -#ifndef QQUICKPLATFORMFILEDIALOG_P_H -#define QQUICKPLATFORMFILEDIALOG_P_H +import QtQuick 2.3 -// -// 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. -// +Item { + width: 400; height: 400 -#include "qquickabstractfiledialog_p.h" + GridView { + id: view + anchors.top: header.bottom + anchors.bottom: footer.top + width: parent.width -QT_BEGIN_NAMESPACE + cellWidth: 50 + cellHeight: 25 -class QQuickPlatformFileDialog : public QQuickAbstractFileDialog -{ - Q_OBJECT + cacheBuffer: 0 + displayMarginBeginning: 60 + displayMarginEnd: 60 -public: - QQuickPlatformFileDialog(QObject *parent = 0); - virtual ~QQuickPlatformFileDialog(); + model: 200 + delegate: Rectangle { + objectName: "delegate" + width: 50 + height: 25 + color: index % 2 ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + text: index + } + } + } -protected: - QPlatformFileDialogHelper *helper(); + Rectangle { + id: header + width: parent.width; height: 60 + color: "#80FF0000" + } - Q_DISABLE_COPY(QQuickPlatformFileDialog) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickPlatformFileDialog *) - -#endif // QQUICKPLATFORMFILEDIALOG_P_H + Rectangle { + id: footer + anchors.bottom: parent.bottom + width: parent.width; height: 60 + color: "#80FF0000" + } +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index f1adb7858f..2ee98c6c61 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -207,6 +207,8 @@ private slots: void moved_topToBottom_RtL_BtT(); void moved_topToBottom_RtL_BtT_data(); + void displayMargin(); + private: QList<int> toIntList(const QVariantList &list); void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes); @@ -6307,6 +6309,43 @@ void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QLi } } +void tst_QQuickGridView::displayMargin() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("displayMargin.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickGridView *gridview = window->rootObject()->findChild<QQuickGridView*>(); + QVERIFY(gridview != 0); + + QQuickItem *content = gridview->contentItem(); + QVERIFY(content != 0); + + QQuickItem *item0; + QQuickItem *item97; + + QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0)); + QCOMPARE(delegateVisible(item0), true); + + // the 97th item should be within the end margin + QVERIFY(item97 = findItem<QQuickItem>(content, "delegate", 96)); + QCOMPARE(delegateVisible(item97), true); + + // GridView staggers item creation, so the 118th item should be outside the end margin. + QVERIFY(findItem<QQuickItem>(content, "delegate", 117) == 0); + + // the first delegate should still be within the begin margin + gridview->positionViewAtIndex(20, QQuickGridView::Beginning); + QCOMPARE(delegateVisible(item0), true); + + // the first delegate should now be outside the begin margin + gridview->positionViewAtIndex(36, QQuickGridView::Beginning); + QCOMPARE(delegateVisible(item0), false); + + delete window; +} + QTEST_MAIN(tst_QQuickGridView) #include "tst_qquickgridview.moc" diff --git a/tests/auto/quick/qquickitem/data/visualParentOwnership.qml b/tests/auto/quick/qquickitem/data/visualParentOwnership.qml new file mode 100644 index 0000000000..644d14ba43 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/visualParentOwnership.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + Component { + id: factory + Item {} + } + + property Item keepAliveProperty; + + function createItemWithoutParent() { + return factory.createObject(/*parent*/ null); + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index ad3c4fc208..f4f2374183 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -49,6 +49,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QDebug> #include <QTimer> +#include <QQmlEngine> #include "../../shared/util.h" class TestItem : public QQuickItem @@ -167,6 +168,8 @@ private slots: void acceptedMouseButtons(); + void visualParentOwnership(); + private: enum PaintOrderOp { @@ -1754,6 +1757,68 @@ void tst_qquickitem::acceptedMouseButtons() QCOMPARE(item.releaseCount, 3); } +static void gc(QQmlEngine &engine) +{ + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +void tst_qquickitem::visualParentOwnership() +{ + QQuickView view; + view.setSource(testFileUrl("visualParentOwnership.qml")); + + QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject()); + QVERIFY(root); + + QVariant newObject; + { + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> newItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!newItem.isNull()); + + QVERIFY(!newItem->parent()); + QVERIFY(!newItem->parentItem()); + + newItem->setParentItem(root); + + gc(*view.engine()); + + QVERIFY(!newItem.isNull()); + newItem->setParentItem(0); + + gc(*view.engine()); + QVERIFY(newItem.isNull()); + } + { + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> firstItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!firstItem.isNull()); + + firstItem->setParentItem(root); + + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> secondItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!firstItem.isNull()); + + secondItem->setParentItem(firstItem); + + gc(*view.engine()); + + delete firstItem; + + root->setProperty("keepAliveProperty", newObject); + + gc(*view.engine()); + QVERIFY(!secondItem.isNull()); + + root->setProperty("keepAliveProperty", QVariant()); + + gc(*view.engine()); + QVERIFY(secondItem.isNull()); + } +} QTEST_MAIN(tst_qquickitem) diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 8a4ed5ae4c..64795f9ebe 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -1972,6 +1972,8 @@ void tst_QQuickItem::transforms_data() QTest::addColumn<QTransform>("transform"); QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") << QTransform(1,0,0,0,1,0,10,20,1); + QTest::newRow("matrix4x4") << QByteArray("Matrix4x4 { matrix: Qt.matrix4x4(1,0,0,10, 0,1,0,15, 0,0,1,0, 0,0,0,1) }") + << QTransform(1,0,0,0,1,0,10,15,1); QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") << QTransform(0,1,0,-1,0,0,0,0,1); QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") @@ -1985,7 +1987,7 @@ void tst_QQuickItem::transforms() QFETCH(QByteArray, qml); QFETCH(QTransform, transform); QQmlComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); + component.setData("import QtQuick 2.4\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); QCOMPARE(item->itemTransform(0,0), transform); diff --git a/src/imports/dialogs-private/dialogsprivateplugin.cpp b/tests/auto/quick/qquicklistview/data/displayMargin.qml index f920df30f3..fde48bc5b9 100644 --- a/src/imports/dialogs-private/dialogsprivateplugin.cpp +++ b/tests/auto/quick/qquicklistview/data/displayMargin.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Jolla Ltd. ** Contact: http://www.qt-project.org/legal ** -** This file is part of the plugins of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -39,28 +39,44 @@ ** ****************************************************************************/ -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include "qquickwritingsystemlistmodel_p.h" -#include "qquickfontlistmodel_p.h" +import QtQuick 2.3 -QT_BEGIN_NAMESPACE +Item { + width: 400; height: 400 -class QtQuick2DialogsPrivatePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + ListView { + id: view + anchors.top: header.bottom + anchors.bottom: footer.top + width: parent.width -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs.Private")); + cacheBuffer: 0 + displayMarginBeginning: 60 + displayMarginEnd: 60 - qmlRegisterType<QQuickWritingSystemListModel>(uri, 1, 1, "WritingSystemListModel"); - qmlRegisterType<QQuickFontListModel>(uri, 1, 1, "FontListModel"); + model: 100 + delegate: Rectangle { + objectName: "delegate" + width: parent.width + height: 25 + color: index % 2 ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + text: index + } + } } -}; -QT_END_NAMESPACE + Rectangle { + id: header + width: parent.width; height: 60 + color: "#80FF0000" + } -#include "dialogsprivateplugin.moc" + Rectangle { + id: footer + anchors.bottom: parent.bottom + width: parent.width; height: 60 + color: "#80FF0000" + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index a0045a244f..f741fec159 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -215,6 +215,7 @@ private slots: void testProxyModelChangedAfterMove(); void typedModel(); + void displayMargin(); void highlightItemGeometryChanges(); @@ -7039,6 +7040,43 @@ void tst_QQuickListView::typedModel() QCOMPARE(listview->count(), 0); } +void tst_QQuickListView::displayMargin() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("displayMargin.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>(); + QVERIFY(listview != 0); + + QQuickItem *content = listview->contentItem(); + QVERIFY(content != 0); + + QQuickItem *item0; + QQuickItem *item14; + + QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0)); + QCOMPARE(delegateVisible(item0), true); + + // the 14th item should be within the end margin + QVERIFY(item14 = findItem<QQuickItem>(content, "delegate", 13)); + QCOMPARE(delegateVisible(item14), true); + + // the 15th item should be outside the end margin + QVERIFY(findItem<QQuickItem>(content, "delegate", 14) == 0); + + // the first delegate should still be within the begin margin + listview->positionViewAtIndex(3, QQuickListView::Beginning); + QCOMPARE(delegateVisible(item0), true); + + // the first delegate should now be outside the begin margin + listview->positionViewAtIndex(4, QQuickListView::Beginning); + QCOMPARE(delegateVisible(item0), false); + + delete window; +} + void tst_QQuickListView::highlightItemGeometryChanges() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp index 204a3ff019..1fed2ecda8 100644 --- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/QSignalSpy> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> @@ -54,6 +55,7 @@ public: private slots: void gradient(); + void antialiasing(); private: QQmlEngine engine; @@ -87,6 +89,61 @@ void tst_qquickrectangle::gradient() delete rect; } +void tst_qquickrectangle::antialiasing() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Rectangle {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(object.data()); + QVERIFY(rect); + + QSignalSpy spy(rect, SIGNAL(antialiasingChanged(bool))); + + QCOMPARE(rect->antialiasing(), false); + + rect->setAntialiasing(true); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 1); + + rect->setAntialiasing(true); + QCOMPARE(spy.count(), 1); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 2); + + rect->setRadius(5); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 3); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 3); + + rect->setRadius(0); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 4); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 4); + + rect->setRadius(5); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 5); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 5); + + rect->setAntialiasing(false); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 6); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 7); +} QTEST_MAIN(tst_qquickrectangle) diff --git a/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml b/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml new file mode 100644 index 0000000000..6349f7a644 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: main + width: 200; height: 200 + + Text { + id: myText + objectName: "myText" + width: parent.width + font.family: "__Qt__Box__Engine__" + font.pixelSize: 14 + horizontalAlignment: Text.AlignHCenter + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + onLineLaidOut: { + // do nothing + } + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 78e03be9c2..d241ac2d70 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -101,6 +101,7 @@ private slots: void color(); void smooth(); void renderType(); + void antialiasing(); // QQuickFontValueType void weight(); @@ -126,6 +127,7 @@ private slots: void clipRect(); void lineLaidOut(); void lineLaidOutRelayout(); + void lineLaidOutHAlign(); void imgTagsBaseUrl_data(); void imgTagsBaseUrl(); @@ -901,6 +903,8 @@ void tst_qquicktext::hAlignImplicitWidth() { // HCenter Align text->setHAlign(QQuickText::AlignHCenter); + text->setText("Reset"); // set dummy string to force relayout once original text is set again + text->setText("AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"); QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); @@ -911,6 +915,8 @@ void tst_qquicktext::hAlignImplicitWidth() { // Right Align text->setHAlign(QQuickText::AlignRight); + text->setText("Reset"); // set dummy string to force relayout once original text is set again + text->setText("AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"); QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); @@ -1306,6 +1312,30 @@ void tst_qquicktext::renderType() QCOMPARE(spy.count(), 2); } +void tst_qquicktext::antialiasing() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Text {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickText *text = qobject_cast<QQuickText *>(object.data()); + QVERIFY(text); + + QSignalSpy spy(text, SIGNAL(antialiasingChanged(bool))); + + QCOMPARE(text->antialiasing(), true); + + text->setAntialiasing(false); + QCOMPARE(text->antialiasing(), false); + QCOMPARE(spy.count(), 1); + + text->setAntialiasing(false); + QCOMPARE(spy.count(), 1); + + text->resetAntialiasing(); + QCOMPARE(text->antialiasing(), true); + QCOMPARE(spy.count(), 2); +} + void tst_qquicktext::weight() { { @@ -2630,6 +2660,23 @@ void tst_qquicktext::lineLaidOutRelayout() delete window; } +void tst_qquicktext::lineLaidOutHAlign() +{ + QQuickView *window = createView(testFile("lineLayoutHAlign.qml")); + + QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText"); + QVERIFY(myText != 0); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); + QVERIFY(textPrivate != 0); + + QCOMPARE(textPrivate->layout.lineCount(), 1); + + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().x() < 0.0); + + delete window; +} + void tst_qquicktext::imgTagsBaseUrl_data() { QTest::addColumn<QUrl>("src"); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ff9554718b..8bf9d14a56 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2663,8 +2663,8 @@ void tst_qquicktextedit::delegateLoading_data() // import installed QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; - QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection "; - QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; + QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection"; + QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type"; } void tst_qquicktextedit::delegateLoading() diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index a4ed1267ac..77aeba9028 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -229,7 +229,7 @@ void tst_QQuickView::engine() QCOMPARE(view3->engine(), view4->engine()); delete view3; QVERIFY(!view4->engine()); - QTest::ignoreMessage(QtWarningMsg, "QQuickView: invalid qml engine. "); + QTest::ignoreMessage(QtWarningMsg, "QQuickView: invalid qml engine."); view4->setSource(QUrl()); QCOMPARE(view4->status(), QQuickView::Error); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 107d1d71f7..bdd70f6a6e 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -250,6 +250,18 @@ int TestTouchItem::mousePressNum = 0; int TestTouchItem::mouseMoveNum = 0; int TestTouchItem::mouseReleaseNum = 0; +class EventFilter : public QObject +{ +public: + bool eventFilter(QObject *watched, QEvent *event) { + Q_UNUSED(watched); + events.append(event->type()); + return false; + } + + QList<int> events; +}; + class ConstantUpdateItem : public QQuickItem { Q_OBJECT @@ -331,6 +343,10 @@ private slots: void crashWhenHoverItemDeleted(); + void qobjectEventFilter_touch(); + void qobjectEventFilter_key(); + void qobjectEventFilter_mouse(); + #ifndef QT_NO_CURSOR void cursor(); #endif @@ -923,6 +939,9 @@ void tst_qquickwindow::mouseFiltering() QTRY_COMPARE(middleItem->mousePressId, 1); QTRY_COMPARE(bottomItem->mousePressId, 2); QTRY_COMPARE(topItem->mousePressId, 3); + + // clean up mouse press state for the next tests + QTest::mouseRelease(window, Qt::LeftButton, 0, pos); } void tst_qquickwindow::qmlCreation() @@ -1560,6 +1579,84 @@ void tst_qquickwindow::crashWhenHoverItemDeleted() } } +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_touch() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QPointF pos(10, 10); + + // press single point + QTest::touchEvent(&window, touchDevice).press(0, item->mapToScene(pos).toPoint(), &window); + + QCOMPARE(eventFilter.events.count(), 1); + QCOMPARE(eventFilter.events.first(), (int)QEvent::TouchBegin); +} + +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_key() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + item->setFocus(true); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QTest::keyPress(&window, Qt::Key_A); + + // NB: It may also receive some QKeyEvent(ShortcutOverride) which we're not interested in + QVERIFY(eventFilter.events.contains((int)QEvent::KeyPress)); + eventFilter.events.clear(); + + QTest::keyRelease(&window, Qt::Key_A); + + QVERIFY(eventFilter.events.contains((int)QEvent::KeyRelease)); +} + +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_mouse() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QPoint point = item->mapToScene(QPointF(10, 10)).toPoint(); + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, point); + + QVERIFY(eventFilter.events.contains((int)QEvent::MouseButtonPress)); + + // clean up mouse press state for the next tests + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, point); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" |