aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-07-04 15:32:50 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-07-04 15:32:51 +0200
commit81077291e3ae1fe8819cf58471ee09ad66c9cad1 (patch)
treec0e7a482affcdfa38ee9a2ec305d02b543ad25d8
parentea045d82a3a837f83fec82462feebf2bc262f9d9 (diff)
parent9422bb302882bfe9e3123d8f1542507c6b6577f4 (diff)
Merge remote-tracking branch 'origin/stable' into dev
-rw-r--r--dist/changes-5.1.02
-rw-r--r--examples/quick/demos/demos.pro2
-rw-r--r--examples/quick/demos/photosurface/main.cpp63
-rw-r--r--examples/quick/demos/photosurface/photosurface.pro13
-rw-r--r--examples/quick/demos/photosurface/photosurface.qml16
-rw-r--r--examples/quick/demos/photosurface/photosurface.qrc6
-rw-r--r--examples/quick/demos/photosurface/resources/folder.pngbin0 -> 5851 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/icon.pngbin0 -> 35894 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.icnsbin0 -> 47407 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.icobin0 -> 38623 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.rc32
-rw-r--r--examples/quick/dialogs/systemdialogs/FileDialogs.qml2
-rw-r--r--examples/quick/models/objectlistmodel/objectlistmodel.qmlproject14
-rw-r--r--examples/quick/scenegraph/scenegraph.pro1
-rw-r--r--examples/quick/scenegraph/threadedanimation/main.cpp58
-rw-r--r--examples/quick/scenegraph/threadedanimation/main.qml134
-rw-r--r--examples/quick/scenegraph/threadedanimation/spinner.cpp133
-rw-r--r--examples/quick/scenegraph/threadedanimation/spinner.h69
-rw-r--r--examples/quick/scenegraph/threadedanimation/spinner.pngbin0 -> 3198 bytes
-rw-r--r--examples/quick/scenegraph/threadedanimation/threadedanimation.pro8
-rw-r--r--examples/quick/scenegraph/threadedanimation/threadedanimation.qrc6
-rw-r--r--examples/quick/shared/Button.qml16
-rw-r--r--src/imports/dialogs/DefaultColorDialog.qml10
-rw-r--r--src/imports/dialogs/DefaultFileDialog.qml27
-rw-r--r--src/imports/dialogs/dialogs.pro2
-rw-r--r--src/imports/dialogs/images/window_border.pngbin0 -> 588 bytes
-rw-r--r--src/imports/dialogs/plugin.cpp31
-rw-r--r--src/imports/dialogs/plugins.qmltypes7
-rw-r--r--src/imports/dialogs/qml/Button.qml15
-rw-r--r--src/imports/dialogs/qml/DefaultWindowDecoration.qml68
-rw-r--r--src/imports/dialogs/qml/TextField.qml4
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog.cpp2
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog_p.h2
-rw-r--r--src/imports/dialogs/qquickabstractdialog.cpp77
-rw-r--r--src/imports/dialogs/qquickabstractdialog_p.h12
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog.cpp17
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog_p.h10
-rw-r--r--src/imports/dialogs/qquickcolordialog.cpp10
-rw-r--r--src/imports/dialogs/qquickfiledialog.cpp29
-rw-r--r--src/imports/dialogs/qquickfiledialog_p.h4
-rw-r--r--src/imports/dialogs/qquickplatformcolordialog.cpp6
-rw-r--r--src/imports/dialogs/qquickplatformfiledialog.cpp22
-rw-r--r--src/imports/widgets/plugins.qmltypes5
-rw-r--r--src/imports/widgets/qquickqfiledialog.cpp4
-rw-r--r--src/qml/debugger/qqmldebug.h6
-rw-r--r--src/qml/doc/src/whatsnew.qdoc2
-rw-r--r--src/qml/qml/qqml.h3
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlengine.cpp3
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp9
-rw-r--r--src/qml/qml/qqmlextensionplugin.h1
-rw-r--r--src/quick/items/qquickflickable.cpp4
-rw-r--r--src/quick/items/qquickgridview.cpp27
-rw-r--r--src/quick/items/qquickitemview.cpp27
-rw-r--r--src/quick/items/qquickitemview_p_p.h4
-rw-r--r--src/quick/items/qquicklistview.cpp28
-rw-r--r--src/quick/items/qquicktext.cpp4
-rw-r--r--src/quick/items/qquicktextdocument.cpp18
-rw-r--r--src/quick/items/qquicktextdocument.h18
-rw-r--r--src/quick/items/qquicktextedit.cpp53
-rw-r--r--src/quick/items/qquicktextedit_p_p.h5
-rw-r--r--src/quick/items/qquickwindow.cpp12
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp6
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.cpp18
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp1
-rw-r--r--tests/auto/quick/qquickloader/qquickloader.pro1
66 files changed, 960 insertions, 235 deletions
diff --git a/dist/changes-5.1.0 b/dist/changes-5.1.0
index 528260e760..141c9a90e1 100644
--- a/dist/changes-5.1.0
+++ b/dist/changes-5.1.0
@@ -85,6 +85,8 @@ QtQml
static data generated by previous qmlRegisterType calls.
- New qmlRegisteredType function in qqml.h, allowing the registration of
composite types from C++.
+ - New baseUrl() accessor in QQmlExtensionPlugin, in case a plugin
+ needs to load QML or other assets from the same directory.
QtQuick
------
diff --git a/examples/quick/demos/demos.pro b/examples/quick/demos/demos.pro
index 67128a905f..867dfa5a07 100644
--- a/examples/quick/demos/demos.pro
+++ b/examples/quick/demos/demos.pro
@@ -3,10 +3,10 @@ SUBDIRS = samegame \
calqlatr \
tweetsearch \
maroon \
+ photosurface \
stocqt
EXAMPLE_FILES = \
clocks \
photoviewer \
- photosurface \
rssnews
diff --git a/examples/quick/demos/photosurface/main.cpp b/examples/quick/demos/photosurface/main.cpp
new file mode 100644
index 0000000000..90d6454211
--- /dev/null
+++ b/examples/quick/demos/photosurface/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifdef QT_WIDGETS_LIB
+#include <QtWidgets/QApplication>
+#else
+#include <QtGui/QGuiApplication>
+#endif
+#include <QtQml/QQmlApplicationEngine>
+#include <QtQuick/QQuickWindow>
+#include <QtCore/QUrl>
+
+int main(int argc, char* argv[])
+{
+ // The reason to use QApplication is that QWidget-based dialogs
+ // are the native dialogs on Qt-based platforms like KDE,
+ // but they cannot be instantiated if this is a QGuiApplication.
+#ifdef QT_WIDGETS_LIB
+ QApplication app(argc, argv);
+#else
+ QGuiApplication app(argc, argv);
+#endif
+ QQuickWindow::setDefaultAlphaBuffer(true);
+ QQmlApplicationEngine engine(QUrl("qrc:///photosurface.qml"));
+ return app.exec();
+}
diff --git a/examples/quick/demos/photosurface/photosurface.pro b/examples/quick/demos/photosurface/photosurface.pro
new file mode 100644
index 0000000000..5e5b0f0815
--- /dev/null
+++ b/examples/quick/demos/photosurface/photosurface.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+
+QT += qml quick
+qtHaveModule(widgets): QT += widgets
+SOURCES += main.cpp
+RESOURCES += photosurface.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/photosurface
+INSTALLS += target
+ICON = resources/icon.png
+macx: ICON = resources/photosurface.icns
+win32: RC_FILE = resources/photosurface.rc
+
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml
index 4f7100358f..9d081de1e3 100644
--- a/examples/quick/demos/photosurface/photosurface.qml
+++ b/examples/quick/demos/photosurface/photosurface.qml
@@ -118,11 +118,27 @@ Window {
}
}
}
+
+ Image {
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.margins: 10
+ source: "resources/folder.png"
+ MouseArea {
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: fileDialog.open()
+ }
+ }
+
Text {
anchors.bottom: parent.bottom
anchors.left: parent.left
+ anchors.right: parent.right
anchors.margins: 10
color: "darkgrey"
+ wrapMode: Text.WordWrap
+ font.pointSize: 8
text: "On a touchscreen: use two fingers to zoom and rotate, one finger to drag\n" +
"With a mouse: drag normally, use the vertical wheel to zoom, horizontal wheel to rotate, or hold Ctrl while using the vertical wheel to rotate"
}
diff --git a/examples/quick/demos/photosurface/photosurface.qrc b/examples/quick/demos/photosurface/photosurface.qrc
new file mode 100644
index 0000000000..f8fafbb1ff
--- /dev/null
+++ b/examples/quick/demos/photosurface/photosurface.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>photosurface.qml</file>
+ <file>resources/folder.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/demos/photosurface/resources/folder.png b/examples/quick/demos/photosurface/resources/folder.png
new file mode 100644
index 0000000000..2aec3b6ebf
--- /dev/null
+++ b/examples/quick/demos/photosurface/resources/folder.png
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/icon.png b/examples/quick/demos/photosurface/resources/icon.png
new file mode 100644
index 0000000000..f8ff553fcb
--- /dev/null
+++ b/examples/quick/demos/photosurface/resources/icon.png
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.icns b/examples/quick/demos/photosurface/resources/photosurface.icns
new file mode 100644
index 0000000000..c69ec41c4e
--- /dev/null
+++ b/examples/quick/demos/photosurface/resources/photosurface.icns
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.ico b/examples/quick/demos/photosurface/resources/photosurface.ico
new file mode 100644
index 0000000000..03bb7ee367
--- /dev/null
+++ b/examples/quick/demos/photosurface/resources/photosurface.ico
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.rc b/examples/quick/demos/photosurface/resources/photosurface.rc
new file mode 100644
index 0000000000..ec18eb1cfc
--- /dev/null
+++ b/examples/quick/demos/photosurface/resources/photosurface.rc
@@ -0,0 +1,32 @@
+#include "winver.h"
+
+IDI_ICON1 ICON DISCARDABLE "photosurface.ico"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,0
+ PRODUCTVERSION 1,0,0,0
+ FILEFLAGS 0x0L
+ FILEFLAGSMASK 0x3fL
+ FILEOS 0x00040004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "CompanyName", "Digia Plc and/or its subsidiary(-ies)"
+ VALUE "FileDescription", "Photo Surface Demo"
+ VALUE "FileVersion", "1.0.0.0"
+ VALUE "LegalCopyright", "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies)."
+ VALUE "InternalName", "photosurface"
+ VALUE "OriginalFilename", "photosurface.exe"
+ VALUE "ProductName", "Photo Surface Demo"
+ VALUE "ProductVersion", "1.0.0.0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/examples/quick/dialogs/systemdialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml
index d1278609f9..4a218853ef 100644
--- a/examples/quick/dialogs/systemdialogs/FileDialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/FileDialogs.qml
@@ -162,7 +162,7 @@ Rectangle {
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 = "/tmp"
+ onClicked: fileDialog.folder = "/tmp" // file:///tmp would also be OK
}
}
}
diff --git a/examples/quick/models/objectlistmodel/objectlistmodel.qmlproject b/examples/quick/models/objectlistmodel/objectlistmodel.qmlproject
deleted file mode 100644
index 2bb4016996..0000000000
--- a/examples/quick/models/objectlistmodel/objectlistmodel.qmlproject
+++ /dev/null
@@ -1,14 +0,0 @@
-import QmlProject 1.0
-
-Project {
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro
index 3ddb216615..4354954445 100644
--- a/examples/quick/scenegraph/scenegraph.pro
+++ b/examples/quick/scenegraph/scenegraph.pro
@@ -5,3 +5,4 @@ SUBDIRS += \
simplematerial \
textureinsgnode \
textureinthread \
+ threadedanimation
diff --git a/examples/quick/scenegraph/threadedanimation/main.cpp b/examples/quick/scenegraph/threadedanimation/main.cpp
new file mode 100644
index 0000000000..28abf9da94
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the demonstration 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 <QGuiApplication>
+#include <QtQuick/QQuickView>
+
+#include "spinner.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<Spinner>("Spinner", 1, 0, "Spinner");
+
+ QQuickView view;
+ view.setSource(QUrl("qrc:///scenegraph/threadedanimation/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/quick/scenegraph/threadedanimation/main.qml b/examples/quick/scenegraph/threadedanimation/main.qml
new file mode 100644
index 0000000000..30ba9a2eb1
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/main.qml
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the demonstration 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$
+**
+****************************************************************************/
+
+//! [1]
+import QtQuick 2.0
+import Spinner 1.0
+
+Rectangle {
+
+ width: 320
+ height: 480
+
+ gradient: Gradient {
+ GradientStop { position: 0; color: "lightsteelblue" }
+ GradientStop { position: 1; color: "black" }
+ }
+
+ Rectangle {
+ color: Qt.rgba(1, 1, 1, 0.7);
+ radius: 10
+ border.width: 1
+ border.color: "white"
+ anchors.fill: blockingLabel;
+ anchors.margins: -10
+ }
+
+ Text {
+ id: blockingLabel
+ color: blocker.running ? "red" : "black"
+ text: blocker.running ? "Blocked!" : "Not blocked"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: parent.top
+ anchors.topMargin: 100
+ }
+
+ Timer {
+ id: blocker
+ interval: 357
+ running: false;
+ repeat: true
+ onTriggered: {
+ var d = new Date();
+ var x = 0;
+ var wait = 50 + Math.random() * 200;
+ while ((new Date().getTime() - d.getTime()) < 100) {
+ x += 1;
+ }
+ }
+ }
+
+ Timer {
+ id: blockerEnabler
+ interval: 4000
+ running: true
+ repeat: true
+ onTriggered: {
+ blocker.running = !blocker.running
+ }
+ }
+
+ Spinner {
+ anchors.centerIn: parent
+ anchors.horizontalCenterOffset: 80
+ spinning: true
+ }
+
+ Image {
+ anchors.centerIn: parent
+ anchors.horizontalCenterOffset: -80
+ source: "spinner.png"
+ NumberAnimation on rotation {
+ from: 0; to: 360; duration: 1000; loops: Animation.Infinite
+ }
+ }
+
+ Rectangle {
+ color: Qt.rgba(1, 1, 1, 0.7)
+ radius: 10
+ border.width: 1
+ border.color: "white"
+ anchors.fill: label
+ anchors.margins: -10
+ }
+
+ Text {
+ id: label
+ color: "black"
+ wrapMode: Text.WordWrap
+ text: "This application shows two spinners. The one to the right is animated on the scene graph thread (when applicable) and the left one is using the normal Qt Quick animation system."
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 20
+ }
+}
+//! [2]
diff --git a/examples/quick/scenegraph/threadedanimation/spinner.cpp b/examples/quick/scenegraph/threadedanimation/spinner.cpp
new file mode 100644
index 0000000000..7efcdb5da6
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/spinner.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the demonstration 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 "spinner.h"
+
+#include <QtQuick/QQuickWindow>
+#include <QtGui/QScreen>
+#include <QtQuick/QSGSimpleTextureNode>
+
+#include <QtGui/QConicalGradient>
+#include <QtGui/QPainter>
+
+class SpinnerNode : public QObject, public QSGTransformNode
+{
+ Q_OBJECT
+public:
+ SpinnerNode(QQuickWindow *window)
+ : m_rotation(0)
+ , m_spinning(false)
+ , m_window(window)
+ {
+ connect(window, SIGNAL(beforeRendering()), this, SLOT(maybeRotate()));
+ connect(window, SIGNAL(frameSwapped()), this, SLOT(maybeUpdate()));
+
+ QImage image(":/scenegraph/threadedanimation/spinner.png");
+ m_texture = window->createTextureFromImage(image);
+ QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode();
+ textureNode->setTexture(m_texture);
+ textureNode->setRect(0, 0, image.width(), image.height());
+ textureNode->setFiltering(QSGTexture::Linear);
+ appendChildNode(textureNode);
+ }
+
+ ~SpinnerNode() {
+ delete m_texture;
+ }
+
+ void setSpinning(bool spinning)
+ {
+ m_spinning = spinning;
+ }
+
+public slots:
+ void maybeRotate() {
+ if (m_spinning) {
+ m_rotation += (360 / m_window->screen()->refreshRate());
+ QMatrix4x4 matrix;
+ matrix.translate(32, 32);
+ matrix.rotate(m_rotation, 0, 0, 1);
+ matrix.translate(-32, -32);
+ setMatrix(matrix);
+ }
+ }
+
+ void maybeUpdate() {
+ if (m_spinning) {
+ m_window->update();
+ }
+ }
+
+private:
+ qreal m_rotation;
+ bool m_spinning;
+ QSGTexture *m_texture;
+ QQuickWindow *m_window;
+};
+
+Spinner::Spinner()
+ : m_spinning(false)
+{
+ setSize(QSize(64, 64));
+ setFlag(ItemHasContents);
+}
+
+void Spinner::setSpinning(bool spinning)
+{
+ if (spinning == m_spinning)
+ return;
+ m_spinning = spinning;
+ emit spinningChanged();
+ update();
+}
+
+QSGNode *Spinner::updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
+{
+ SpinnerNode *n = static_cast<SpinnerNode *>(old);
+ if (!n)
+ n = new SpinnerNode(window());
+
+ n->setSpinning(m_spinning);
+
+ return n;
+}
+
+#include "spinner.moc"
diff --git a/examples/quick/scenegraph/threadedanimation/spinner.h b/examples/quick/scenegraph/threadedanimation/spinner.h
new file mode 100644
index 0000000000..01b489021f
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/spinner.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the demonstration 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$
+**
+****************************************************************************/
+
+#ifndef SPINNER_H
+#define SPINNER_H
+
+#include <QtQuick/QQuickItem>
+
+class Spinner : public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool spinning READ spinning WRITE setSpinning NOTIFY spinningChanged)
+
+public:
+ Spinner();
+
+ bool spinning() const { return m_spinning; }
+ void setSpinning(bool spinning);
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+
+signals:
+ void spinningChanged();
+
+private:
+ bool m_spinning;
+};
+
+#endif // SQUIRCLE_H
diff --git a/examples/quick/scenegraph/threadedanimation/spinner.png b/examples/quick/scenegraph/threadedanimation/spinner.png
new file mode 100644
index 0000000000..bacb1698d7
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/spinner.png
Binary files differ
diff --git a/examples/quick/scenegraph/threadedanimation/threadedanimation.pro b/examples/quick/scenegraph/threadedanimation/threadedanimation.pro
new file mode 100644
index 0000000000..419ee97e2e
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/threadedanimation.pro
@@ -0,0 +1,8 @@
+QT += qml quick
+
+HEADERS += spinner.h
+SOURCES += spinner.cpp main.cpp
+RESOURCES += threadedanimation.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/threadedanimation
+INSTALLS += target
diff --git a/examples/quick/scenegraph/threadedanimation/threadedanimation.qrc b/examples/quick/scenegraph/threadedanimation/threadedanimation.qrc
new file mode 100644
index 0000000000..ecaf4f7a31
--- /dev/null
+++ b/examples/quick/scenegraph/threadedanimation/threadedanimation.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/scenegraph/threadedanimation">
+ <file>main.qml</file>
+ <file>spinner.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/shared/Button.qml b/examples/quick/shared/Button.qml
index 9942a17b5c..551f7d6e04 100644
--- a/examples/quick/shared/Button.qml
+++ b/examples/quick/shared/Button.qml
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
Item {
id: container
@@ -48,10 +48,10 @@ Item {
signal clicked
property alias containsMouse: mouseArea.containsMouse
property alias pressed: mouseArea.pressed
- implicitHeight: buttonLabel.implicitHeight
- implicitWidth: buttonLabel.implicitWidth
- height: buttonLabel.implicitHeight + 12
- width: Math.max(80, implicitWidth + 8)
+ implicitHeight: buttonLabel.implicitHeight * 1.2
+ implicitWidth: buttonLabel.implicitWidth * 1.2
+ height: implicitHeight
+ width: implicitWidth
SystemPalette { id: palette }
@@ -64,7 +64,7 @@ Item {
GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
}
antialiasing: true
- radius: 5
+ radius: height / 4
border.color: Qt.darker(palette.button, 1.5)
border.width: 1
}
@@ -78,10 +78,8 @@ Item {
Text {
id: buttonLabel
- width: parent.width
- horizontalAlignment: Text.Center
text: container.text
color: palette.buttonText
- anchors.verticalCenter: parent.verticalCenter
+ anchors.centerIn: parent
}
}
diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml
index 7322aa18e7..8636259957 100644
--- a/src/imports/dialogs/DefaultColorDialog.qml
+++ b/src/imports/dialogs/DefaultColorDialog.qml
@@ -39,6 +39,7 @@
*****************************************************************************/
import QtQuick 2.1
+import QtQuick.Window 2.1
import QtQuick.Dialogs 1.0
import "qml"
@@ -47,14 +48,17 @@ AbstractColorDialog {
Rectangle {
id: content
- width: 320
- height: (usePaletteMap ? width : 0) + bottomMinHeight
+ property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
+ implicitHeight: Math.max(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 10 : 5))
+ implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5
color: palette.window
property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3
property real spacing: 8
property real outerSpacing: 12
property bool usePaletteMap: true
- property bool inited: false
+
+ // set the preferred width based on height, to avoid "letterboxing" the paletteMap
+ onHeightChanged: implicitHeight = Math.max((usePaletteMap ? 480 : bottomMinHeight), height)
SystemPalette { id: palette }
diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml
index 5542e59cb5..2cdb34cc03 100644
--- a/src/imports/dialogs/DefaultFileDialog.qml
+++ b/src/imports/dialogs/DefaultFileDialog.qml
@@ -40,6 +40,7 @@
import QtQuick 2.1
import QtQuick.Dialogs 1.0
+import QtQuick.Window 2.1
import Qt.labs.folderlistmodel 2.0
import "qml"
@@ -52,13 +53,13 @@ AbstractFileDialog {
currentPathField.visible = false
}
}
+ onFolderChanged: view.model.folder = folder
property bool showFocusHighlight: false
- property real textX: 28
+ property real textX: titleBar.height
property SystemPalette palette
property var selectedIndices: []
property int lastClickedIdx: -1
- folder: urlToPath(view.model.folder)
function dirDown(path) {
view.model.folder = path
@@ -106,10 +107,11 @@ AbstractFileDialog {
selectedIndices.map(function(idx) {
if (view.model.isFolder(idx)) {
if (selectFolder)
- addSelection(view.model.get(idx, "filePath"))
+ // TODO after QTBUG-32039: should not need to convert pathToUrl here
+ addSelection(pathToUrl(view.model.get(idx, "filePath")))
} else {
if (!selectFolder)
- addSelection(view.model.get(idx, "filePath"))
+ addSelection(pathToUrl(view.model.get(idx, "filePath")))
}
})
}
@@ -117,11 +119,12 @@ AbstractFileDialog {
}
Rectangle {
- width: 480 // TODO: QTBUG-29817 geometry from AbstractFileDialog
- height: 320
+ property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
+ // TODO: QTBUG-29817 geometry from AbstractFileDialog
+ implicitWidth: Math.min(maxSize, Screen.logicalPixelDensity * 100)
+ implicitHeight: Math.min(maxSize, Screen.logicalPixelDensity * 80)
id: window
color: palette.window
- anchors.centerIn: Qt.application.supportsMultipleWindows ? null : parent
SystemPalette { id: palette }
@@ -209,7 +212,12 @@ AbstractFileDialog {
clip: true
x: 0
width: parent.width
- model: FolderListModel { }
+ model: FolderListModel {
+ onFolderChanged: {
+ root.folder = folder
+ currentPathField.text = root.urlToPath(view.model.folder)
+ }
+ }
delegate: folderDelegate
highlight: Rectangle {
color: "transparent"
@@ -303,10 +311,9 @@ AbstractFileDialog {
anchors.leftMargin: textX; anchors.rightMargin: 4
visible: false
focus: visible
- text: root.urlToPath(view.model.folder)
onAccepted: {
root.clearSelection()
- if (root.addSelection(text))
+ if (root.addSelection(root.pathToUrl(text)))
root.accept()
else
view.model.folder = root.pathFolder(text)
diff --git a/src/imports/dialogs/dialogs.pro b/src/imports/dialogs/dialogs.pro
index 53cad30cee..e745d52e2b 100644
--- a/src/imports/dialogs/dialogs.pro
+++ b/src/imports/dialogs/dialogs.pro
@@ -31,6 +31,7 @@ QML_FILES += \
WidgetColorDialog.qml \
qml/Button.qml \
qml/ColorSlider.qml \
+ qml/DefaultWindowDecoration.qml \
qml/TextField.qml \
qml/qmldir \
images/checkers.png \
@@ -38,6 +39,7 @@ QML_FILES += \
images/crosshairs.png \
images/slider_handle.png \
images/sunken_frame.png \
+ images/window_border.png \
images/folder.png \
images/up.png
diff --git a/src/imports/dialogs/images/window_border.png b/src/imports/dialogs/images/window_border.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/src/imports/dialogs/images/window_border.png
Binary files differ
diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp
index 5502a65310..8d1501cd03 100644
--- a/src/imports/dialogs/plugin.cpp
+++ b/src/imports/dialogs/plugin.cpp
@@ -48,6 +48,7 @@
#include "qquickabstractcolordialog_p.h"
#include "qquickplatformcolordialog_p.h"
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
//#define PURE_QML_ONLY
@@ -78,9 +79,18 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin
public:
QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { }
+ virtual void initializeEngine(QQmlEngine *engine, const char *uri) {
+ //qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl;
+ QQuickAbstractDialog::m_decorationComponent =
+ new QQmlComponent(engine, m_decorationComponentUrl, QQmlComponent::Asynchronous);
+ }
+
virtual void registerTypes(const char *uri) {
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs"));
+ bool hasTopLevelWindows = QGuiApplicationPrivate::platformIntegration()->
+ hasCapability(QPlatformIntegration::MultipleWindows);
QDir qmlDir(baseUrl().toLocalFile());
+ m_decorationComponentUrl = QUrl::fromLocalFile(qmlDir.filePath(QString("qml/DefaultWindowDecoration.qml")));
QDir widgetsDir(baseUrl().toLocalFile());
// TODO: find the directory by searching rather than assuming a relative path
widgetsDir.cd("../PrivateWidgets");
@@ -96,8 +106,7 @@ public:
qmlRegisterType<QQuickPlatformFileDialog>(uri, DIALOGS_MAJOR_MINOR, "FileDialog");
else
#endif
- registerWidgetOrQmlImplementation<QQuickFileDialog>(widgetsDir, "WidgetFileDialog.qml",
- qmlDir, "DefaultFileDialog.qml", "FileDialog", uri);
+ registerWidgetOrQmlImplementation<QQuickFileDialog>(widgetsDir, qmlDir, "FileDialog", uri, hasTopLevelWindows);
// ColorDialog
#ifndef PURE_QML_ONLY
@@ -105,35 +114,37 @@ public:
qmlRegisterType<QQuickPlatformColorDialog>(uri, DIALOGS_MAJOR_MINOR, "ColorDialog");
else
#endif
- registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, "WidgetColorDialog.qml",
- qmlDir, "DefaultColorDialog.qml", "ColorDialog", uri);
+ registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, qmlDir, "ColorDialog", uri, hasTopLevelWindows);
}
protected:
template <class WrapperType>
- void registerWidgetOrQmlImplementation(QDir widgetsDir, QString widgetQmlFile,
- QDir qmlDir, QString qmlFile, const char *qmlName, const char *uri) {
+ void registerWidgetOrQmlImplementation(QDir widgetsDir, QDir qmlDir,
+ const char *qmlName, const char *uri, bool hasTopLevelWindows) {
+ //qDebug() << Q_FUNC_INFO << qmlDir << qmlName << uri;
bool needQml = true;
+
#ifndef PURE_QML_ONLY
// If there is a qmldir and we have a QApplication instance (as opposed to a
// widget-free QGuiApplication), assume that the widget-based dialog will work.
- if (widgetsDir.exists("qmldir") && !widgetQmlFile.isEmpty() &&
+ if (hasTopLevelWindows && widgetsDir.exists("qmldir") &&
!qstrcmp(QCoreApplication::instance()->metaObject()->className(), "QApplication")) {
- QString dialogQmlPath = qmlDir.filePath(widgetQmlFile);
+ QString dialogQmlPath = qmlDir.filePath(QString("Widget%1.qml").arg(qmlName));
if (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, DIALOGS_MAJOR_MINOR, qmlName) >= 0)
needQml = false;
- // qDebug() << "registering" << qmlName << " as " << dialogQmlPath << "success?" << needQml;
+ // qDebug() << "registering" << qmlName << " as " << dialogQmlPath << "success?" << !needQml;
}
#endif
if (needQml) {
- QString dialogQmlPath = qmlDir.filePath(qmlFile);
QByteArray abstractTypeName = QByteArray("Abstract") + qmlName;
qmlRegisterType<WrapperType>(uri, DIALOGS_MAJOR_MINOR, abstractTypeName); // implementation wrapper
+ QString dialogQmlPath = qmlDir.filePath(QString("Default%1.qml").arg(qmlName));
// qDebug() << "registering" << qmlName << " as " << dialogQmlPath << "success?" <<
qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, DIALOGS_MAJOR_MINOR, qmlName);
}
}
+ QUrl m_decorationComponentUrl;
};
QT_END_NAMESPACE
diff --git a/src/imports/dialogs/plugins.qmltypes b/src/imports/dialogs/plugins.qmltypes
index 80eb8bd291..4e7090b960 100644
--- a/src/imports/dialogs/plugins.qmltypes
+++ b/src/imports/dialogs/plugins.qmltypes
@@ -39,6 +39,7 @@ Module {
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" }
@@ -56,7 +57,7 @@ Module {
Property { name: "selectExisting"; type: "bool" }
Property { name: "selectMultiple"; type: "bool" }
Property { name: "selectFolder"; type: "bool" }
- Property { name: "folder"; type: "string" }
+ Property { name: "folder"; type: "QUrl" }
Property { name: "nameFilters"; type: "QStringList" }
Property { name: "selectedNameFilter"; type: "string" }
Property { name: "fileUrl"; type: "QUrl"; isReadonly: true }
@@ -86,7 +87,7 @@ Module {
}
Method {
name: "setFolder"
- Parameter { name: "f"; type: "string" }
+ Parameter { name: "f"; type: "QUrl" }
}
Method {
name: "setNameFilters"
@@ -116,7 +117,7 @@ Module {
Method {
name: "addSelection"
type: "bool"
- Parameter { name: "path"; type: "string" }
+ Parameter { name: "path"; type: "QUrl" }
}
}
}
diff --git a/src/imports/dialogs/qml/Button.qml b/src/imports/dialogs/qml/Button.qml
index 491dc2e251..4a0ec12cd3 100644
--- a/src/imports/dialogs/qml/Button.qml
+++ b/src/imports/dialogs/qml/Button.qml
@@ -39,6 +39,7 @@
*****************************************************************************/
import QtQuick 2.1
+import QtQuick.Window 2.1
Item {
id: container
@@ -48,10 +49,10 @@ Item {
signal clicked
property alias containsMouse: mouseArea.containsMouse
property alias pressed: mouseArea.pressed
- implicitHeight: buttonLabel.implicitHeight
- implicitWidth: buttonLabel.implicitWidth
- height: buttonLabel.implicitHeight + 12
- width: Math.max(80, implicitWidth + 8)
+ implicitHeight: buttonLabel.implicitHeight * 1.2
+ implicitWidth: Math.max(Screen.logicalPixelDensity * 10, buttonLabel.implicitWidth * 1.2)
+ height: implicitHeight
+ width: implicitWidth
SystemPalette { id: palette }
@@ -64,7 +65,7 @@ Item {
GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
}
antialiasing: true
- radius: 5
+ radius: height / 4
border.color: Qt.darker(palette.button, 1.5)
border.width: 1
}
@@ -78,10 +79,8 @@ Item {
Text {
id: buttonLabel
- width: parent.width
- horizontalAlignment: Text.Center
text: container.text
color: palette.buttonText
- anchors.verticalCenter: parent.verticalCenter
+ anchors.centerIn: parent
}
}
diff --git a/src/imports/dialogs/qml/DefaultWindowDecoration.qml b/src/imports/dialogs/qml/DefaultWindowDecoration.qml
new file mode 100644
index 0000000000..69a8658aba
--- /dev/null
+++ b/src/imports/dialogs/qml/DefaultWindowDecoration.qml
@@ -0,0 +1,68 @@
+/*****************************************************************************
+**
+** 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
+
+ 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 }
+ source: "../images/window_border.png"
+ anchors.centerIn: parent
+ onContentChanged: if (content) content.parent = borderImage
+ }
+ }
+}
diff --git a/src/imports/dialogs/qml/TextField.qml b/src/imports/dialogs/qml/TextField.qml
index baa469caa9..9a6427a105 100644
--- a/src/imports/dialogs/qml/TextField.qml
+++ b/src/imports/dialogs/qml/TextField.qml
@@ -45,10 +45,10 @@ Item {
property alias textInput: textInput
property alias text: textInput.text
- property real implicitWidth: textInput.implicitWidth + rect.radius * 2
- property real implicitHeight: textInput.implicitHeight + rect.radius * 2
signal accepted
signal downPressed
+ implicitWidth: textInput.implicitWidth + rect.radius * 2
+ implicitHeight: textInput.implicitHeight
function copyAll() {
textInput.selectAll()
diff --git a/src/imports/dialogs/qquickabstractcolordialog.cpp b/src/imports/dialogs/qquickabstractcolordialog.cpp
index 9a9f3bc11b..7cfd7ea692 100644
--- a/src/imports/dialogs/qquickabstractcolordialog.cpp
+++ b/src/imports/dialogs/qquickabstractcolordialog.cpp
@@ -91,7 +91,7 @@ bool QQuickAbstractColorDialog::showAlphaChannel() const
return m_options->testOption(QColorDialogOptions::ShowAlphaChannel);
}
-void QQuickAbstractColorDialog::setTitle(QString t)
+void QQuickAbstractColorDialog::setTitle(const QString &t)
{
if (m_options->windowTitle() == t) return;
m_options->setWindowTitle(t);
diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h
index 3301605c86..46f0f84acb 100644
--- a/src/imports/dialogs/qquickabstractcolordialog_p.h
+++ b/src/imports/dialogs/qquickabstractcolordialog_p.h
@@ -78,7 +78,7 @@ public:
public Q_SLOTS:
void setVisible(bool v);
void setModality(Qt::WindowModality m);
- void setTitle(QString t);
+ void setTitle(const QString &t);
void setColor(QColor arg);
void setShowAlphaChannel(bool arg);
diff --git a/src/imports/dialogs/qquickabstractdialog.cpp b/src/imports/dialogs/qquickabstractdialog.cpp
index abdc9e067c..560cbaf3e0 100644
--- a/src/imports/dialogs/qquickabstractdialog.cpp
+++ b/src/imports/dialogs/qquickabstractdialog.cpp
@@ -44,11 +44,14 @@
#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)
@@ -56,6 +59,10 @@ QQuickAbstractDialog::QQuickAbstractDialog(QObject *parent)
, m_modality(Qt::WindowModal)
, m_qmlImplementation(0)
, m_dialogWindow(0)
+ , m_contentItem(0)
+ , m_windowDecoration(0)
+ , m_hasNativeWindows(QGuiApplicationPrivate::platformIntegration()->
+ hasCapability(QPlatformIntegration::MultipleWindows))
{
}
@@ -82,36 +89,47 @@ void QQuickAbstractDialog::setVisible(bool v)
if (!m_dialogWindow) {
m_dialogWindow = qobject_cast<QWindow *>(m_qmlImplementation);
if (!m_dialogWindow) {
- QQuickItem *dlgItem = qobject_cast<QQuickItem *>(m_qmlImplementation);
- if (dlgItem) {
- m_dialogWindow = dlgItem->window();
+ m_contentItem = qobject_cast<QQuickItem *>(m_qmlImplementation);
+ if (m_contentItem) {
+ 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 && QGuiApplicationPrivate::platformIntegration()->
- hasCapability(QPlatformIntegration::MultipleWindows)) {
+ if (!m_dialogWindow && m_hasNativeWindows) {
QQuickWindow *win = new QQuickWindow;
((QObject *)win)->setParent(this); // memory management only
m_dialogWindow = win;
- dlgItem->setParentItem(win->contentItem());
- m_dialogWindow->setMinimumSize(QSize(dlgItem->width(), dlgItem->height()));
+ 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());
- // qDebug() << "item implementation" << dlgItem << "has window" << m_dialogWindow << "and parent" << parentItem;
// If the platform does not support multiple windows, but the dialog is
- // implemented as an Item, then just reparent it and make it visible.
- // TODO QTBUG-29818: put it into a fake Item-based window, when we have a reusable self-decorated one.
- if (parentItem && !m_dialogWindow)
- dlgItem->setParentItem(parentItem);
+ // 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)
connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool)));
}
- if (m_dialogWindow) {
+ if (m_windowDecoration) {
+ m_windowDecoration->setVisible(v);
+ } else if (m_dialogWindow) {
if (v) {
m_dialogWindow->setTransientParent(parentWindow());
m_dialogWindow->setTitle(title());
@@ -124,6 +142,38 @@ void QQuickAbstractDialog::setVisible(bool v)
emit visibilityChanged();
}
+void QQuickAbstractDialog::decorationLoaded()
+{
+ bool ok = false;
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ 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;
@@ -152,7 +202,6 @@ void QQuickAbstractDialog::visibleChanged(bool v)
void QQuickAbstractDialog::windowGeometryChanged()
{
QQuickItem *content = qobject_cast<QQuickItem*>(m_qmlImplementation);
-qDebug() << Q_FUNC_INFO << m_dialogWindow << content;
if (m_dialogWindow && content) {
content->setWidth(m_dialogWindow->width());
content->setHeight(m_dialogWindow->height());
diff --git a/src/imports/dialogs/qquickabstractdialog_p.h b/src/imports/dialogs/qquickabstractdialog_p.h
index 2ad24f98e0..5e3d9b43f7 100644
--- a/src/imports/dialogs/qquickabstractdialog_p.h
+++ b/src/imports/dialogs/qquickabstractdialog_p.h
@@ -66,6 +66,7 @@ class QQuickAbstractDialog : public QObject
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)
@@ -87,8 +88,9 @@ public:
virtual void setVisible(bool v);
virtual void setModality(Qt::WindowModality m);
- virtual void setTitle(QString t) = 0;
+ virtual void setTitle(const QString &t) = 0;
void setQmlImplementation(QObject* obj);
+ bool isWindow() const { return m_hasNativeWindows; }
void setX(int arg);
void setY(int arg);
void setWidth(int arg);
@@ -107,6 +109,7 @@ Q_SIGNALS:
void rejected();
protected Q_SLOTS:
+ void decorationLoaded();
void accept();
void reject();
void visibleChanged(bool v);
@@ -124,6 +127,13 @@ protected:
protected: // variables for pure-QML implementations only
QObject *m_qmlImplementation;
QWindow *m_dialogWindow;
+ QQuickItem *m_contentItem;
+ QQuickItem *m_windowDecoration;
+ bool m_hasNativeWindows;
+
+ static QQmlComponent *m_decorationComponent;
+
+ friend class QtQuick2DialogsPlugin;
Q_DISABLE_COPY(QQuickAbstractDialog)
};
diff --git a/src/imports/dialogs/qquickabstractfiledialog.cpp b/src/imports/dialogs/qquickabstractfiledialog.cpp
index 32442de41f..d8a75feb53 100644
--- a/src/imports/dialogs/qquickabstractfiledialog.cpp
+++ b/src/imports/dialogs/qquickabstractfiledialog.cpp
@@ -78,7 +78,7 @@ QString QQuickAbstractFileDialog::title() const
return m_options->windowTitle();
}
-void QQuickAbstractFileDialog::setTitle(QString t)
+void QQuickAbstractFileDialog::setTitle(const QString &t)
{
if (m_options->windowTitle() == t) return;
m_options->setWindowTitle(t);
@@ -106,18 +106,19 @@ void QQuickAbstractFileDialog::setSelectFolder(bool selectFolder)
updateModes();
}
-QString QQuickAbstractFileDialog::folder()
+QUrl QQuickAbstractFileDialog::folder()
{
if (m_dlgHelper && !m_dlgHelper->directory().isEmpty())
- return m_dlgHelper->directory();
- return m_options->initialDirectory();
+ return QUrl::fromLocalFile(m_dlgHelper->directory());
+ return QUrl::fromLocalFile(m_options->initialDirectory());
}
-void QQuickAbstractFileDialog::setFolder(QString f)
+void QQuickAbstractFileDialog::setFolder(const QUrl &f)
{
+ QString dir = f.path();
if (m_dlgHelper)
- m_dlgHelper->setDirectory(f);
- m_options->setInitialDirectory(f);
+ m_dlgHelper->setDirectory(dir);
+ m_options->setInitialDirectory(dir);
emit folderChanged();
}
@@ -141,7 +142,7 @@ QString QQuickAbstractFileDialog::selectedNameFilter()
return ret;
}
-void QQuickAbstractFileDialog::selectNameFilter(QString f)
+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);
diff --git a/src/imports/dialogs/qquickabstractfiledialog_p.h b/src/imports/dialogs/qquickabstractfiledialog_p.h
index 965f1a7029..5ce48e8055 100644
--- a/src/imports/dialogs/qquickabstractfiledialog_p.h
+++ b/src/imports/dialogs/qquickabstractfiledialog_p.h
@@ -67,7 +67,7 @@ class QQuickAbstractFileDialog : public QQuickAbstractDialog
Q_PROPERTY(bool selectExisting READ selectExisting WRITE setSelectExisting NOTIFY fileModeChanged)
Q_PROPERTY(bool selectMultiple READ selectMultiple WRITE setSelectMultiple NOTIFY fileModeChanged)
Q_PROPERTY(bool selectFolder READ selectFolder WRITE setSelectFolder NOTIFY fileModeChanged)
- Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(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)
@@ -81,7 +81,7 @@ public:
bool selectExisting() const { return m_selectExisting; }
bool selectMultiple() const { return m_selectMultiple; }
bool selectFolder() const { return m_selectFolder; }
- QString folder();
+ QUrl folder();
QStringList nameFilters() const { return m_options->nameFilters(); }
QString selectedNameFilter();
QUrl fileUrl();
@@ -89,13 +89,13 @@ public:
public Q_SLOTS:
void setVisible(bool v);
- void setTitle(QString t);
+ void setTitle(const QString &t);
void setSelectExisting(bool s);
void setSelectMultiple(bool s);
void setSelectFolder(bool s);
- void setFolder(QString f);
+ void setFolder(const QUrl &f);
void setNameFilters(const QStringList &f);
- void selectNameFilter(QString f);
+ void selectNameFilter(const QString &f);
Q_SIGNALS:
void folderChanged();
diff --git a/src/imports/dialogs/qquickcolordialog.cpp b/src/imports/dialogs/qquickcolordialog.cpp
index 39af99770e..d0e0e11b07 100644
--- a/src/imports/dialogs/qquickcolordialog.cpp
+++ b/src/imports/dialogs/qquickcolordialog.cpp
@@ -64,13 +64,13 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::AbstractColorDialog::accepted
- The \a accepted signal is emitted by \l accept().
+ This signal is emitted by \l accept().
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractColorDialog::rejected
- The \a accepted signal is emitted by \l reject().
+ This signal is emitted by \l reject().
*/
/*!
@@ -110,12 +110,6 @@ QQuickColorDialog::~QQuickColorDialog()
*/
/*!
- \qmlproperty bool AbstractColorDialog::filePaths
-
- A list of files to be populated as the user chooses.
-*/
-
-/*!
\qmlproperty QObject AbstractColorDialog::implementation
The QML object which implements the actual file dialog. Should be either a
diff --git a/src/imports/dialogs/qquickfiledialog.cpp b/src/imports/dialogs/qquickfiledialog.cpp
index f78e8a6f8d..2ee4afc5d2 100644
--- a/src/imports/dialogs/qquickfiledialog.cpp
+++ b/src/imports/dialogs/qquickfiledialog.cpp
@@ -64,13 +64,13 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::AbstractFileDialog::accepted
- The \a accepted signal is emitted by \l accept().
+ This signal is emitted by \l accept().
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractFileDialog::rejected
- The \a accepted signal is emitted by \l reject().
+ This signal is emitted by \l reject().
*/
/*!
@@ -105,10 +105,7 @@ QQuickFileDialog::~QQuickFileDialog()
QList<QUrl> QQuickFileDialog::fileUrls()
{
- QList<QUrl> ret;
- foreach (QString path, m_selections)
- ret << QUrl::fromLocalFile(path);
- return ret;
+ return m_selections;
}
/*!
@@ -118,13 +115,13 @@ QList<QUrl> QQuickFileDialog::fileUrls()
*/
/*!
- \qmlproperty bool AbstractFileDialog::filePaths
+ \qmlproperty bool AbstractFileDialog::fileUrls
A list of files to be populated as the user chooses.
*/
/*!
- \brief Clears \l filePaths
+ \brief Clears \l fileUrls
*/
void QQuickFileDialog::clearSelection()
{
@@ -132,20 +129,18 @@ void QQuickFileDialog::clearSelection()
}
/*!
- \brief Adds one file to \l filePaths
+ \brief Adds one file to \l fileUrls
- \l path should be given as an absolute file system path. If it is given as a
- file:// URL, it will be converted to a path. Returns true on success,
- false if the given path is not valid given the current setting properties.
+ \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(QString path)
+bool QQuickFileDialog::addSelection(const QUrl &path)
{
- if (path.startsWith("file:"))
- path = QUrl(path).toLocalFile();
- QFileInfo info(path);
+ QFileInfo info(path.toLocalFile());
if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) {
if (m_selectFolder)
- m_selections.append(pathFolder(path).toLocalFile());
+ m_selections.append(pathFolder(path.toLocalFile()));
else
m_selections.append(path);
return true;
diff --git a/src/imports/dialogs/qquickfiledialog_p.h b/src/imports/dialogs/qquickfiledialog_p.h
index 93e11f9e3e..0176bc3fe4 100644
--- a/src/imports/dialogs/qquickfiledialog_p.h
+++ b/src/imports/dialogs/qquickfiledialog_p.h
@@ -72,7 +72,7 @@ signals:
public Q_SLOTS:
void clearSelection();
- bool addSelection(QString path);
+ bool addSelection(const QUrl &path);
protected:
virtual QPlatformFileDialogHelper *helper() { return 0; }
@@ -81,7 +81,7 @@ protected:
Q_INVOKABLE QUrl pathFolder(const QString &path);
private:
- QStringList m_selections;
+ QList<QUrl> m_selections;
Q_DISABLE_COPY(QQuickFileDialog)
};
diff --git a/src/imports/dialogs/qquickplatformcolordialog.cpp b/src/imports/dialogs/qquickplatformcolordialog.cpp
index ea3114c86e..8dc6d09f2c 100644
--- a/src/imports/dialogs/qquickplatformcolordialog.cpp
+++ b/src/imports/dialogs/qquickplatformcolordialog.cpp
@@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE
/*!
\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.
+ 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:
@@ -117,7 +117,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::ColorDialog::rejected
- The \a rejected signal is emitted when the user has dismissed the dialog,
+ This handler is called when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
*/
diff --git a/src/imports/dialogs/qquickplatformfiledialog.cpp b/src/imports/dialogs/qquickplatformfiledialog.cpp
index 5ae7fd0067..3da9f6c3b2 100644
--- a/src/imports/dialogs/qquickplatformfiledialog.cpp
+++ b/src/imports/dialogs/qquickplatformfiledialog.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
id: fileDialog
title: "Please choose a file"
onAccepted: {
- console.log("You chose: " + fileDialog.filePaths)
+ console.log("You chose: " + fileDialog.fileUrls)
Qt.quit()
}
onRejected: {
@@ -103,15 +103,15 @@ QT_BEGIN_NAMESPACE
/*!
\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 filePath or \a filePaths properties to
+ 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: " + filePath) }
+ onAccepted: { console.log("Selected file: " + fileUrl) }
}
\endqml
*/
@@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::FileDialog::rejected
- The \a rejected signal is emitted when the user has dismissed the dialog,
+ This handler is called when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
*/
@@ -191,7 +191,7 @@ QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
containing the dialog's parent Item, modal with respect to the whole
application, or non-modal.
- By default it is \l WindowModal.
+ 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
@@ -252,7 +252,7 @@ QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
*/
/*!
- \qmlproperty string FileDialog::folder
+ \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
@@ -295,18 +295,18 @@ QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
*/
/*!
- \qmlproperty string FileDialog::filePath
+ \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 return an empty string.
+ other cases, it will be empty.
- \sa filePaths
+ \sa fileUrls
*/
/*!
- \qmlproperty list<string> FileDialog::filePaths
+ \qmlproperty list<url> FileDialog::fileUrls
The list of file paths which were selected by the user.
*/
diff --git a/src/imports/widgets/plugins.qmltypes b/src/imports/widgets/plugins.qmltypes
index 583a36a357..9e73330c12 100644
--- a/src/imports/widgets/plugins.qmltypes
+++ b/src/imports/widgets/plugins.qmltypes
@@ -39,6 +39,7 @@ Module {
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" }
@@ -56,7 +57,7 @@ Module {
Property { name: "selectExisting"; type: "bool" }
Property { name: "selectMultiple"; type: "bool" }
Property { name: "selectFolder"; type: "bool" }
- Property { name: "folder"; type: "string" }
+ Property { name: "folder"; type: "QUrl" }
Property { name: "nameFilters"; type: "QStringList" }
Property { name: "selectedNameFilter"; type: "string" }
Property { name: "fileUrl"; type: "QUrl"; isReadonly: true }
@@ -86,7 +87,7 @@ Module {
}
Method {
name: "setFolder"
- Parameter { name: "f"; type: "string" }
+ Parameter { name: "f"; type: "QUrl" }
}
Method {
name: "setNameFilters"
diff --git a/src/imports/widgets/qquickqfiledialog.cpp b/src/imports/widgets/qquickqfiledialog.cpp
index afb150b509..498e34a24c 100644
--- a/src/imports/widgets/qquickqfiledialog.cpp
+++ b/src/imports/widgets/qquickqfiledialog.cpp
@@ -135,14 +135,14 @@ private:
\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 filePath or \a filePaths properties to
+ dialog. You can then inspect the \a fileUrl or \a fileUrls properties to
get the selection.
Example:
\qml
FileDialog {
- onAccepted: { console.log("Selected file: " + filePath) }
+ onAccepted: { console.log("Selected file: " + fileUrl) }
}
\endqml
*/
diff --git a/src/qml/debugger/qqmldebug.h b/src/qml/debugger/qqmldebug.h
index d2b0220bc6..d6b6bb0301 100644
--- a/src/qml/debugger/qqmldebug.h
+++ b/src/qml/debugger/qqmldebug.h
@@ -54,9 +54,9 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler
// Execute code in constructor before first QQmlEngine is instantiated
#if defined(QT_QML_DEBUG_NO_WARNING)
-static QQmlDebuggingEnabler qmlEnableDebuggingHelper(false);
-#elif defined(QT_QML_DEBUG) || defined(QT_DECLARATIVE_DEBUG)
-static QQmlDebuggingEnabler qmlEnableDebuggingHelper(true);
+static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(false);
+#elif defined(QT_QML_DEBUG)
+static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
#endif
QT_END_NAMESPACE
diff --git a/src/qml/doc/src/whatsnew.qdoc b/src/qml/doc/src/whatsnew.qdoc
index f1c69160b6..9ad8c23a42 100644
--- a/src/qml/doc/src/whatsnew.qdoc
+++ b/src/qml/doc/src/whatsnew.qdoc
@@ -115,6 +115,8 @@ has now been replaced by the new \l {Qt QML} and \l {Qt Quick} modules. See the
\list
\li Arbitrary functionality may be provided in a namespace through a singleton type. See qmlRegisterSingletonType() for more information.
\li JavaScript (.js) files may now import QML modules and other JavaScript files using the ".import" syntax.
+\li Plugins may now use QQmlExtensionPlugin::baseUrl to get the directory from which the plugin is loaded.
+ This will be useful if the plugin needs to load QML or other assets from the same directory.
\endlist
\section2 Other
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index fb0133f305..b48a776b4f 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -49,7 +49,6 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qmetaobject.h>
-#include <QtCore/qdebug.h>
#define QML_VERSION 0x020000
#define QML_VERSION_STR "2.0"
@@ -477,7 +476,7 @@ inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, i
{
if (url.isRelative()) {
// User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
- qWarning() << "qmlRegisterType requires absolute URLs.";
+ qWarning("qmlRegisterType requires absolute URLs.");
return 0;
}
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 1fa1c2382f..df1e7f420e 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -768,8 +768,7 @@ QQmlComponent::QQmlComponent(QQmlComponentPrivate &dd, QObject *parent)
If \a context is 0 (the default), it will create the instance in the
engine' s \l {QQmlEngine::rootContext()}{root context}.
- The ownership of the returned object instance is determined by the QQmlEngine.
- By default the caller has to take care that the object is eventually deleted.
+ The ownership of the returned object instance is transferred to the caller.
\sa QQmlEngine::ObjectOwnership
*/
@@ -810,8 +809,7 @@ QObject *QQmlComponent::create(QQmlContext *context)
communicate information to an instantiated component, as it allows their
initial values to be configured before property bindings take effect.
- The ownership of the returned object instance is determined by the QQmlEngine.
- By default the caller has to take care that the object is eventually deleted.
+ The ownership of the returned object instance is transferred to the caller.
\sa completeCreate(), QQmlEngine::ObjectOwnership
*/
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index a7fff20530..1c491ae492 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -863,9 +863,6 @@ QQmlEngine::~QQmlEngine()
QList<QQmlType*> singletonTypes = QQmlMetaType::qmlSingletonTypes();
foreach (QQmlType *currType, singletonTypes)
currType->singletonInstanceInfo()->destroy(this);
-
- if (d->incubationController)
- d->incubationController->d = 0;
}
/*! \fn void QQmlEngine::quit()
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index f77b176404..30eca7b112 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
/*!
- \since 5.0
+ \since Qt 5.0
\inmodule QtQml
\class QQmlExtensionPlugin
\brief The QQmlExtensionPlugin class provides an abstract base for custom QML extension plugins.
@@ -156,6 +156,13 @@ QQmlExtensionPlugin::~QQmlExtensionPlugin()
{
}
+/*!
+ \since Qt 5.1
+ \brief Returns the URL of the directory from which the extension is loaded.
+
+ This is useful when the plugin also needs to load QML files or other
+ assets from the same directory.
+*/
QUrl QQmlExtensionPlugin::baseUrl() const
{
Q_D(const QQmlExtensionPlugin);
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
index 170c7915a5..245651979b 100644
--- a/src/qml/qml/qqmlextensionplugin.h
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -68,6 +68,7 @@ public:
virtual void registerTypes(const char *uri) = 0;
virtual void initializeEngine(QQmlEngine *engine, const char *uri);
+private:
Q_DISABLE_COPY(QQmlExtensionPlugin)
};
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index f8b69eeedf..374d4397ff 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -2383,7 +2383,7 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
}
// emit moving signals
- bool wasMoving = d->hData.moving || d->vData.moving;
+ bool wasMoving = isMoving();
if (hMovementEnding && d->hData.moving
&& (!d->pressed && !d->stealMouse)) {
d->hData.moving = false;
@@ -2396,7 +2396,7 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
d->vMoved = false;
emit movingVerticallyChanged();
}
- if (wasMoving && (!d->hData.moving || !d->vData.moving)) {
+ if (wasMoving && !isMoving()) {
emit movingChanged();
emit movementEnded();
}
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index bc71a1c064..37276d5603 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -65,19 +65,8 @@ QT_BEGIN_NAMESPACE
class FxGridItemSG : public FxViewItem
{
public:
- FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickGridViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxGridItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
qreal position() const {
@@ -470,7 +459,7 @@ FxViewItem *QQuickGridViewPrivate::newViewItem(int modelIndex, QQuickItem *item)
{
Q_Q(QQuickGridView);
Q_UNUSED(modelIndex);
- return new FxGridItemSG(item, q, false, false);
+ return new FxGridItemSG(item, q, false);
}
void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item)
@@ -478,8 +467,7 @@ void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item)
QQuickItemViewPrivate::initializeViewItem(item);
// need to track current items that are animating
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(true);
}
bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer)
@@ -739,7 +727,8 @@ void QQuickGridViewPrivate::createHighlight()
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true, true);
+ FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight)
resetHighlightPosition();
highlightXAnimator = new QSmoothedAnimation;
@@ -817,7 +806,8 @@ void QQuickGridViewPrivate::updateFooter()
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxGridItemSG(item, q, true, true);
+ footer = new FxGridItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
@@ -861,7 +851,8 @@ void QQuickGridViewPrivate::updateHeader()
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxGridItemSG(item, q, true, true);
+ header = new FxGridItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index a6dabee7ba..f8f622a1b9 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -51,13 +51,14 @@ QT_BEGIN_NAMESPACE
#define QML_VIEW_DEFAULTCACHEBUFFER 320
#endif
-FxViewItem::FxViewItem(QQuickItem *i, bool own, bool trackGeometry)
+FxViewItem::FxViewItem(QQuickItem *i, QQuickItemView *v, bool own)
: item(i)
+ , view(v)
, transitionableItem(0)
, attached(0)
, ownItem(own)
, releaseAfterTransition(false)
- , trackGeom(trackGeometry)
+ , trackGeom(false)
{
}
@@ -96,6 +97,23 @@ void FxViewItem::setVisible(bool visible)
QQuickItemPrivate::get(item)->setCulled(!visible);
}
+void FxViewItem::trackGeometry(bool track)
+{
+ if (track) {
+ if (!trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = true;
+ }
+ } else {
+ if (trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = false;
+ }
+ }
+}
+
QQuickItemViewTransitioner::TransitionType FxViewItem::scheduledTransitionType() const
{
return transitionableItem ? transitionableItem->nextTransitionType : QQuickItemViewTransitioner::NoTransition;
@@ -2131,6 +2149,7 @@ void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QQmlChangeSet::MoveKe
bool isRemove = it.key().moveId < 0;
if (isRemove) {
FxViewItem *item = *it;
+ item->trackGeometry(false);
item->releaseAfterTransition = true;
releasePendingTransition.append(item);
item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true);
@@ -2272,8 +2291,8 @@ bool QQuickItemViewPrivate::releaseItem(FxViewItem *item)
return true;
if (trackedItem == item)
trackedItem = 0;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(false);
+
QQmlInstanceModel::ReleaseFlags flags = model->release(item->item);
if (flags == 0) {
// item was not destroyed, and we no longer reference it.
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 1fa933ebd1..32e94e0e4a 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
class FxViewItem
{
public:
- FxViewItem(QQuickItem *, bool own, bool trackGeometry);
+ FxViewItem(QQuickItem *, QQuickItemView *, bool own);
virtual ~FxViewItem();
qreal itemX() const;
@@ -64,6 +64,7 @@ public:
void moveTo(const QPointF &pos, bool immediate);
void setVisible(bool visible);
+ void trackGeometry(bool track);
QQuickItemViewTransitioner::TransitionType scheduledTransitionType() const;
bool transitionScheduledOrRunning() const;
@@ -83,6 +84,7 @@ public:
virtual bool contains(qreal x, qreal y) const = 0;
QQuickItem *item;
+ QQuickItemView *view;
QQuickItemViewTransitionableItem *transitionableItem;
QQuickItemViewAttached *attached;
int index;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 4d42c9ece1..dfdd27e118 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -244,19 +244,8 @@ void QQuickViewSection::setLabelPositioning(int l)
class FxListItemSG : public FxViewItem
{
public:
- FxListItemSG(QQuickItem *i, QQuickListView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickListViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxListItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
inline QQuickItem *section() const {
@@ -570,7 +559,7 @@ FxViewItem *QQuickListViewPrivate::newViewItem(int modelIndex, QQuickItem *item)
{
Q_Q(QQuickListView);
- FxListItemSG *listItem = new FxListItemSG(item, q, false, false);
+ FxListItemSG *listItem = new FxListItemSG(item, q, false);
listItem->index = modelIndex;
// initialise attached properties
@@ -598,8 +587,8 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item)
{
QQuickItemViewPrivate::initializeViewItem(item);
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ // need to track current items that are animating
+ item->trackGeometry(true);
if (sectionCriteria && sectionCriteria->delegate()) {
if (QString::compare(item->attached->m_prevSection, item->attached->m_section, Qt::CaseInsensitive))
@@ -876,7 +865,8 @@ void QQuickListViewPrivate::createHighlight()
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxListItemSG *newHighlight = new FxListItemSG(item, q, true, true);
+ FxListItemSG *newHighlight = new FxListItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight) {
newHighlight->setSize(static_cast<FxListItemSG*>(currentItem)->itemSize());
@@ -1299,7 +1289,8 @@ void QQuickListViewPrivate::updateFooter()
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxListItemSG(item, q, true, true);
+ footer = new FxListItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
@@ -1329,7 +1320,8 @@ void QQuickListViewPrivate::updateHeader()
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxListItemSG(item, q, true, true);
+ header = new FxListItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index cc2cbb3cb3..3e9e988f28 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1794,6 +1794,10 @@ void QQuickText::setVAlign(VAlignment align)
return;
d->vAlign = align;
+
+ if (isComponentComplete())
+ d->updateLayout();
+
emit verticalAlignmentChanged(align);
}
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index e29e48c5d0..4b4958e122 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -47,6 +47,24 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QQuickTextDocument
+ \since 5.1
+ \brief The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit
+ \inmodule QtQuick
+
+ This class provides access to the QTextDocument of QQuickTextEdit elements.
+ This is provided to allow usage of the \l{Rich Text Processing} functionalities of Qt.
+ You are not allowed to modify the document, but it can be used to output content, for example with \l{QTextDocumentWriter}),
+ or provide additional formatting, for example with \l{QSyntaxHighlighter}.
+
+ The class has to be used from C++ directly, using the property of the \l TextEdit.
+
+ Warning: The QTextDocument provided is used internally by \l {Qt Quick} elements to provide text manipulation primitives.
+ You are not allowed to perform any modification of the internal state of the QTextDocument. If you do, the element
+ in question may stop functioning or crash.
+*/
+
class QQuickTextDocumentPrivate : public QObjectPrivate
{
public:
diff --git a/src/quick/items/qquicktextdocument.h b/src/quick/items/qquicktextdocument.h
index 7c22c01d5a..7c87dfd1e7 100644
--- a/src/quick/items/qquicktextdocument.h
+++ b/src/quick/items/qquicktextdocument.h
@@ -47,24 +47,6 @@
QT_BEGIN_NAMESPACE
-/*!
- \class QQuickTextDocument
- \since 5.1
- \brief The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit
- \inmodule QtQuick
-
- This class provides access to the QTextDocument of QQuickTextEdit elements.
- This is provided to allow usage of the \l{Rich Text Processing} functionalities of Qt.
- You are not allowed to modify the document, but it can be used to output content, for example with \l{QTextDocumentWriter}),
- or provide additional formatting, for example with \l{QSyntaxHighlighter}.
-
- The class has to be used from C++ directly, using the property of the \l TextEdit.
-
- Warning: The QTextDocument provided is used internally by \l {Qt Quick} elements to provide text manipulation primitives.
- You are not allowed to perform any modification of the internal state of the QTextDocument. If you do, the element
- in question may stop functioning or crash.
-*/
-
class QQuickTextDocumentPrivate;
class Q_QUICK_EXPORT QQuickTextDocument : public QObject
{
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 6e2262831d..6ee05700ae 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -135,6 +135,37 @@ namespace {
return format(pos);
}
};
+
+ class RootNode : public QSGTransformNode
+ {
+ public:
+ RootNode() : cursorNode(0), frameDecorationsNode(0)
+ { }
+
+ void resetFrameDecorations(QQuickTextNode* newNode)
+ {
+ if (frameDecorationsNode) {
+ removeChildNode(frameDecorationsNode);
+ delete frameDecorationsNode;
+ }
+ frameDecorationsNode = newNode;
+ newNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ void resetCursorNode(QSGSimpleRectNode* newNode)
+ {
+ if (cursorNode)
+ removeChildNode(cursorNode);
+ delete cursorNode;
+ cursorNode = newNode;
+ appendChildNode(cursorNode);
+ cursorNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ QSGSimpleRectNode *cursorNode;
+ QQuickTextNode* frameDecorationsNode;
+
+ };
}
QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)
@@ -1737,7 +1768,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
d->updateType = QQuickTextEditPrivate::UpdateNone;
- QSGTransformNode *rootNode = static_cast<QSGTransformNode *>(oldNode);
+ RootNode *rootNode = static_cast<RootNode *>(oldNode);
TextNodeIterator nodeIterator = d->textNodeMap.begin();
while (nodeIterator != d->textNodeMap.end() && !(*nodeIterator)->dirty())
++nodeIterator;
@@ -1746,7 +1777,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if (!oldNode || nodeIterator < d->textNodeMap.end()) {
if (!oldNode)
- rootNode = new QSGTransformNode;
+ rootNode = new RootNode;
int firstDirtyPos = 0;
if (nodeIterator != d->textNodeMap.end()) {
@@ -1760,11 +1791,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
// FIXME: the text decorations could probably be handled separately (only updated for affected textFrames)
- if (d->frameDecorationsNode) {
- rootNode->removeChildNode(d->frameDecorationsNode);
- delete d->frameDecorationsNode;
- }
- d->frameDecorationsNode = d->createTextNode();
+ rootNode->resetFrameDecorations(d->createTextNode());
QQuickTextNode *node = 0;
@@ -1780,7 +1807,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
while (!frames.isEmpty()) {
QTextFrame *textFrame = frames.takeFirst();
frames.append(textFrame->childFrames());
- d->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
+ rootNode->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
if (textFrame->lastPosition() < firstDirtyPos || (firstCleanNode && textFrame->firstPosition() >= firstCleanNode->startPos()))
@@ -1843,9 +1870,9 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
d->addCurrentTextNodeToRoot(rootNode, node, nodeIterator, nodeStart);
}
- d->frameDecorationsNode->m_engine->addToSceneGraph(d->frameDecorationsNode, QQuickText::Normal, QColor());
+ rootNode->frameDecorationsNode->m_engine->addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor());
// Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front.
- rootNode->prependChildNode(d->frameDecorationsNode);
+ rootNode->prependChildNode(rootNode->frameDecorationsNode);
Q_ASSERT(nodeIterator == d->textNodeMap.end() || (*nodeIterator) == firstCleanNode);
// Update the position of the subsequent text blocks.
@@ -1871,11 +1898,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
QColor color = (!d->cursorVisible || !d->control->cursorOn())
? QColor(0, 0, 0, 0)
: d->color;
- if (d->cursorNode)
- rootNode->removeChildNode(d->cursorNode);
- delete d->cursorNode;
- d->cursorNode = new QSGSimpleRectNode(cursorRectangle(), color);
- rootNode->appendChildNode(d->cursorNode);
+ rootNode->resetCursorNode(new QSGSimpleRectNode(cursorRectangle(), color));
}
return rootNode;
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index ec3cf1cec5..331e5bb13f 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -93,8 +93,7 @@ public:
QQuickTextEditPrivate()
: color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
, textMargin(0.0), xoff(0), yoff(0), font(sourceFont), cursorComponent(0), cursorItem(0), document(0), control(0)
- , quickDocument(0), frameDecorationsNode(0), cursorNode(0)
- , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
+ , quickDocument(0), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
, hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
, format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
, renderType(QQuickTextEdit::QtRendering)
@@ -156,8 +155,6 @@ public:
QQuickTextControl *control;
QQuickTextDocument *quickDocument;
QList<Node*> textNodeMap;
- QQuickTextNode *frameDecorationsNode;
- QSGSimpleRectNode *cursorNode;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 619c72afb8..377228e6bf 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3196,6 +3196,18 @@ void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha)
Requests the window to be activated, i.e. receive keyboard focus.
*/
+/*!
+ \qmlmethod QtQuick2::Window::alert(int msec)
+ \since QtQuick 2.1
+
+ Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the
+ default), then the alert is shown indefinitely until the window becomes
+ active again.
+
+ In alert state, the window indicates that it demands attention, for example by
+ flashing or bouncing the taskbar entry.
+*/
+
#include "moc_qquickwindow.cpp"
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index bdbce6165b..3556a4ebe5 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -219,7 +219,7 @@ QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
bool QSGDistanceFieldTextMaterial::updateTextureSize()
{
if (!m_texture)
- m_texture = m_glyph_cache->glyphTexture(-1); // invalid texture
+ m_texture = m_glyph_cache->glyphTexture(0); // invalid texture
if (m_texture->size != m_size) {
m_size = m_texture->size;
@@ -240,8 +240,8 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
}
if (m_color != other->m_color)
return &m_color < &other->m_color ? -1 : 1;
- int t0 = m_texture ? m_texture->textureId : -1;
- int t1 = other->m_texture ? other->m_texture->textureId : -1;
+ int t0 = m_texture ? m_texture->textureId : 0;
+ int t1 = other->m_texture ? other->m_texture->textureId : 0;
return t0 - t1;
}
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.cpp b/src/quick/scenegraph/util/qsgsimplematerial.cpp
index ee7a272fbe..35ad56a44b 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.cpp
+++ b/src/quick/scenegraph/util/qsgsimplematerial.cpp
@@ -180,17 +180,29 @@
/*!
\fn void QSGSimpleMaterialShader::resolveUniforms()
- \internal
+
+ Reimplement this function to resolve the location of named uniforms
+ in the shader program.
+
+ This function is called when the material shader is initialized.
*/
/*!
\fn const char *QSGSimpleMaterialShader::uniformMatrixName() const
- \internal
+
+ Reimplement this function to give a different name to the uniform for
+ item transformation. The default value is \c qt_Matrix.
+
*/
/*!
\fn const char *QSGSimpleMaterialShader::uniformOpacityName() const
- \internal
+
+ Reimplement this function to give a different name to the uniform for
+ item opacity. The default value is \c qt_Opacity.
+
+ If the shader program does not implement the item opacity, the
+ implemented function should return a null pointer.
*/
/*!
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index a69f43f8d6..078c86b27f 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -528,6 +528,7 @@ QSGPlainTexture::QSGPlainTexture()
, m_texture_id(0)
, m_has_alpha(false)
, m_has_mipmaps(false)
+ , m_dirty_texture(false)
, m_dirty_bind_options(false)
, m_owns_texture(true)
, m_mipmaps_generated(false)
diff --git a/tests/auto/quick/qquickloader/qquickloader.pro b/tests/auto/quick/qquickloader/qquickloader.pro
index 567917877c..88de3c4c60 100644
--- a/tests/auto/quick/qquickloader/qquickloader.pro
+++ b/tests/auto/quick/qquickloader/qquickloader.pro
@@ -14,3 +14,4 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private network testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+CONFIG+=insignificant_test # QTBUG-30721