aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-07-22 13:43:43 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-07-22 13:43:43 +0200
commit3a6f5735ee723ff998114314c5ccdf6609667f6f (patch)
tree9c877dd1e35972fa336cea8a61986594f168b49c
parent000b6330d4ca7165ff241b21ee728ed28d82fba1 (diff)
parent17ded06804576dfde1b19f82f168f7ceb09ec92c (diff)
Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into wip/v4
Conflicts: src/quick/items/context2d/qquickcontext2d.cpp tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro Change-Id: I36a4fd28b3156839aecd70039a3ba566bf19a0bc
-rw-r--r--dist/changes-5.1.064
-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.qml21
-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/dialogs.pro19
-rw-r--r--examples/quick/dialogs/systemdialogs/ColorDialogs.qml (renamed from examples/quick/dialogs/ColorDialogs.qml)0
-rw-r--r--examples/quick/dialogs/systemdialogs/FileDialogs.qml (renamed from examples/quick/dialogs/FileDialogs.qml)2
-rw-r--r--examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg (renamed from examples/quick/dialogs/doc/images/dialogs-example.jpg)bin47413 -> 47413 bytes
-rw-r--r--examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc (renamed from examples/quick/dialogs/doc/src/dialogs.qdoc)16
-rw-r--r--examples/quick/dialogs/systemdialogs/main.cpp (renamed from examples/quick/dialogs/main.cpp)4
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.pro17
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.qml (renamed from examples/quick/dialogs/dialogs.qml)0
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.qrc (renamed from examples/quick/dialogs/dialogs.qrc)2
-rw-r--r--examples/quick/models/objectlistmodel/objectlistmodel.qmlproject14
-rw-r--r--examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc2
-rw-r--r--examples/quick/particles/system/doc/src/system.qdoc2
-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--examples/quick/window/Splash.qml6
-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/doc/qtquickdialogs.qdocconf3
-rw-r--r--src/imports/dialogs/images/window_border.pngbin0 -> 588 bytes
-rw-r--r--src/imports/dialogs/plugin.cpp44
-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.cpp22
-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/folderlistmodel/fileinfothread.cpp13
-rw-r--r--src/imports/folderlistmodel/fileinfothread_p.h2
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp28
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h3
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/widgets/plugins.qmltypes5
-rw-r--r--src/imports/widgets/qquickqcolordialog.cpp7
-rw-r--r--src/imports/widgets/qquickqfiledialog.cpp17
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp3
-rw-r--r--src/qml/debugger/qqmldebug.h6
-rw-r--r--src/qml/doc/qtqml.qdocconf4
-rw-r--r--src/qml/doc/src/whatsnew.qdoc7
-rw-r--r--src/qml/qml/ftw/qqmltrace.cpp1
-rw-r--r--src/qml/qml/qqml.h3
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlengine.cpp17
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp9
-rw-r--r--src/qml/qml/qqmlextensionplugin.h1
-rw-r--r--src/qml/qml/qqmlglobal.cpp38
-rw-r--r--src/qml/qml/qqmlglobal_p.h8
-rw-r--r--src/qml/qml/qqmlplatform.cpp2
-rw-r--r--src/qml/types/qqmllistmodel.cpp18
-rw-r--r--src/quick/doc/images/qml-item-canvas-clip-complex.pngbin0 -> 70000 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-scaley.pngbin0 -> 1080 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-skewx.pngbin0 -> 1857 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-skewy.pngbin0 -> 2654 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-translate.pngbin0 -> 1269 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-translatey.pngbin0 -> 1666 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas.arc.png (renamed from src/quick/doc/images/qml-item-canvas-arcTo2.png)bin6532 -> 6532 bytes
-rw-r--r--src/quick/doc/qtquick.qdocconf4
-rw-r--r--src/quick/doc/src/concepts/effects/topic.qdoc2
-rw-r--r--src/quick/doc/src/whatsnew.qdoc3
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp5
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp329
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp7
-rw-r--r--src/quick/items/qquickevents.cpp20
-rw-r--r--src/quick/items/qquickevents_p_p.h3
-rw-r--r--src/quick/items/qquickflickable.cpp4
-rw-r--r--src/quick/items/qquickgridview.cpp27
-rw-r--r--src/quick/items/qquickitem.cpp10
-rw-r--r--src/quick/items/qquickitem.h2
-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.cpp29
-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/coreapi/qsgmaterial.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h1
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp9
-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.cpp3
-rw-r--r--src/quick/util/qquickapplication.cpp10
-rw-r--r--src/quick/util/qquickutilmodule.cpp6
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/installed_cmake/installed_cmake.pro4
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml9
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp29
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp19
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp1
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/runningChange.qml59
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp24
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_context.qml79
-rw-r--r--tests/auto/quick/qquickitem2/data/standardkeys.qml57
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp60
-rw-r--r--tests/auto/quick/qquickloader/qquickloader.pro1
-rw-r--r--tests/auto/quick/qquickpositioners/qquickpositioners.pro1
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro4
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/groups.qml10
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/groups.xml18
-rw-r--r--tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro3
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp13
-rw-r--r--tests/auto/quick/quick.pro3
-rw-r--r--tests/auto/quick/touchmouse/touchmouse.pro2
-rw-r--r--tools/qmlscene/main.cpp23
133 files changed, 1920 insertions, 431 deletions
diff --git a/dist/changes-5.1.0 b/dist/changes-5.1.0
index eaf6d05094..141c9a90e1 100644
--- a/dist/changes-5.1.0
+++ b/dist/changes-5.1.0
@@ -21,7 +21,12 @@ information about a particular change.
General Improvements
--------------------
-
+- The Qt.application object in QML has gained the following new members
+ * arguments property, containing any command line arguments of the application
+ * name property, containing the string of the application name
+ * version property, containing the string of the application version
+ * aboutToQuit() signal, allowing last-minute cleanup
+- New Qt.platform.os property exposes the current platform.
Third party components
----------------------
@@ -42,9 +47,10 @@ Third party components
- As part of a fix for QTBUG-30555, ListView and GridView properties, such
as count, which are based off of the data model will no longer update
immediately if queried. Updates are batched to happen once per frame (or
- when properties are being set).
+ when properties are being set). You may manually update using the
+ forceLayout() method, new in QtQuick 2.1.
- - tryCompare now correctly fails when it only gets two parameters
+ - For QML tests, tryCompare now correctly fails when it only gets two parameters
- If a QObject has a property and a slot (or invokable method) with the same
name, in QML the previous behavior was to let the property obscure the
@@ -53,11 +59,43 @@ Third party components
for objects having dynamic properties, such as QQmlPropertyMap. This change
was a consequence of the fix for QTBUG-29836.
+ - The 'with' statement has been deprecated in the QML language. Using this
+ statement now produces a deprecation warning, and future versions of the
+ QML engine may not recognize it.
+
+ - The implicit import is now only loaded for QML files if there are
+ unresolved types after loading all explicit imports. Applications where
+ the implicit import triggered code other than the registration of types
+ will now need to add import "." to their QML files.
+
****************************************************************************
* Library *
****************************************************************************
+QtQml
+------
+ - New QML import version QtQml.Models 2.1 contains generic versions of the VisualModel
+ types. These new generic versions work with any QObject based delegate,
+ not just QQuickItem based delegates.
+ - New module version QtQml 2.1 provides the new Instantiator type, which
+ is a generic version of Repeater which works with any QObject based
+ delegate, not just QQuickItem based delegates.
+ - New convenience class QQmlApplicationEngine automatically provides
+ functionality common in the C++ shell of a primarily QML application.
+ - New qmlClearTypeRegistrations() function in qqml.h. This function drops all
+ 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
+------
+ - New QML import version QtQuick 2.1 contains no new types, but adds new
+ properties, methods and signals to existing types. See the release notes
+ in the QtQuick documentation for details.
- QTBUG-30837: The Flickable type no longer fixes up the content area on
startup to move it inside the viewport.
+ - QTBUG-28086: Remote image URLs now work as a source for AnimatedSprite
****************************************************************************
@@ -68,7 +106,11 @@ Third party components
****************************************************************************
* Platform Specific Changes *
****************************************************************************
-
+ - New threaded render loop for Mac and Linux should lead to improved
+ graphical performance of QtQuick 2 on those platforms.
+ - New render loop on Windows should lead to smoother animations.
+ - assets: scheme supported on Android for urls inside QML
+ - Mac: "@2x" images are now loaded on "retina" systems.
****************************************************************************
* Compiler Specific Changes *
@@ -79,9 +121,23 @@ Third party components
* Tools *
****************************************************************************
+- qmlplugindump gains a -relocatable flag.
****************************************************************************
* Plugins *
****************************************************************************
+- New QML import QtQuick.Dialogs 1.0 contains types for more easily adding
+ dialogs to an application. Initially comes with FileDialog and ColorDialog
+
+- New QML import version QtQuick.Window 2.1 adds many new properties to both
+ the Screen and Window types. See the release notes in the QtQuick
+ documentation for further details.
+
+- QTBUG-30915: Animating emitRate on Emitter no longer fails for specific
+ animation timings. As a side effect, when emitting infinite particles
+ changing the particle count will no longer have an effect after initial
+ emission (previously it no longer had an effect after a certain point
+ into the animation).
+
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 53e0edffbe..9d081de1e3 100644
--- a/examples/quick/demos/photosurface/photosurface.qml
+++ b/examples/quick/demos/photosurface/photosurface.qml
@@ -39,13 +39,14 @@
****************************************************************************/
import QtQuick 2.0
import QtQuick.Dialogs 1.0
+import QtQuick.Window 2.1
import Qt.labs.folderlistmodel 1.0
-Rectangle {
+Window {
id: root
+ visible: true
width: 1024; height: 600
color: "black"
- visible: true
property int highestZ: 0
property real defaultSize: 200
@@ -117,11 +118,27 @@ Rectangle {
}
}
}
+
+ 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/dialogs.pro b/examples/quick/dialogs/dialogs.pro
index b76f396e9d..538e75686c 100644
--- a/examples/quick/dialogs/dialogs.pro
+++ b/examples/quick/dialogs/dialogs.pro
@@ -1,17 +1,4 @@
-TEMPLATE = app
+TEMPLATE = subdirs
-QT += quick qml
-SOURCES += main.cpp
-RESOURCES += dialogs.qrc ../shared/shared.qrc
-
-OTHER_FILES += \
- dialogs.qml \
- FileDialogs.qml \
- ColorDialogs.qml
-
-EXAMPLE_FILES = \
- FileDialogs.qml \
- ColorDialogs.qml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs
-INSTALLS += target
+SUBDIRS = \
+ systemdialogs
diff --git a/examples/quick/dialogs/ColorDialogs.qml b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml
index 6a0af7f730..6a0af7f730 100644
--- a/examples/quick/dialogs/ColorDialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml
diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml
index d1278609f9..4a218853ef 100644
--- a/examples/quick/dialogs/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/dialogs/doc/images/dialogs-example.jpg b/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg
index 4517a39308..4517a39308 100644
--- a/examples/quick/dialogs/doc/images/dialogs-example.jpg
+++ b/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg
Binary files differ
diff --git a/examples/quick/dialogs/doc/src/dialogs.qdoc b/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc
index daac914c60..9788be7343 100644
--- a/examples/quick/dialogs/doc/src/dialogs.qdoc
+++ b/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc
@@ -25,10 +25,10 @@
**
****************************************************************************/
/*!
- \title Qt Quick Dialog Examples
- \example dialogs
- \brief This example demonstrates the dialog types in QML
- \image dialogs-example.jpg
+ \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}
@@ -36,9 +36,13 @@
A \l FileDialog is used to choose a single file, multiple files or a
single directory, depending on how it is configured.
- \snippet dialogs/FileDialogs.qml filedialog
+ \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 dialogs/ColorDialogs.qml colordialog
+ \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/main.cpp b/examples/quick/dialogs/systemdialogs/main.cpp
index bbf0c48104..2119227c1f 100644
--- a/examples/quick/dialogs/main.cpp
+++ b/examples/quick/dialogs/systemdialogs/main.cpp
@@ -37,5 +37,5 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs)
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(dialogs/systemdialogs)
diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.pro b/examples/quick/dialogs/systemdialogs/systemdialogs.pro
new file mode 100644
index 0000000000..e8c3e9857b
--- /dev/null
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+RESOURCES += systemdialogs.qrc ../../shared/shared.qrc
+
+OTHER_FILES += \
+ systemdialogs.qml \
+ FileDialogs.qml \
+ ColorDialogs.qml
+
+EXAMPLE_FILES = \
+ FileDialogs.qml \
+ ColorDialogs.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs
+INSTALLS += target
diff --git a/examples/quick/dialogs/dialogs.qml b/examples/quick/dialogs/systemdialogs/systemdialogs.qml
index b5f9841a3f..b5f9841a3f 100644
--- a/examples/quick/dialogs/dialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qml
diff --git a/examples/quick/dialogs/dialogs.qrc b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc
index efebfe4845..b90b99f7f5 100644
--- a/examples/quick/dialogs/dialogs.qrc
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/dialogs">
- <file>dialogs.qml</file>
+ <file>systemdialogs.qml</file>
<file>FileDialogs.qml</file>
<file>ColorDialogs.qml</file>
</qresource>
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/particles/imageparticle/doc/src/imageparticle.qdoc b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
index 4fda13746a..ea94a4bc39 100644
--- a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
+++ b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \title Qt Quick Particles Examples - Affectors
+ \title Qt Quick Particles Examples - Image Particles
\example particles/imageparticle
\brief This is a collection of examples using Affectors in the QML particle system.
\image qml-imageparticle-example.png
diff --git a/examples/quick/particles/system/doc/src/system.qdoc b/examples/quick/particles/system/doc/src/system.qdoc
index 99be23d9d1..385cd927da 100644
--- a/examples/quick/particles/system/doc/src/system.qdoc
+++ b/examples/quick/particles/system/doc/src/system.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \title Qt Quick Particles Examples - Affectors
+ \title Qt Quick Particles Examples - System
\example particles/system
\brief This is a collection of examples using Affectors in the QML particle system.
\image qml-system-example.png
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/examples/quick/window/Splash.qml b/examples/quick/window/Splash.qml
index c981bd2585..995e264f8b 100644
--- a/examples/quick/window/Splash.qml
+++ b/examples/quick/window/Splash.qml
@@ -44,9 +44,6 @@ import QtQuick.Window 2.1
//! [splash-properties]
Window {
id: splash
- visible: true
- width: splashImage.width
- height: splashImage.height
color: "transparent"
title: "Splash Window"
modality: Qt.ApplicationModal
@@ -58,6 +55,8 @@ Window {
x: (Screen.width - splashImage.width) / 2
y: (Screen.height - splashImage.height) / 2
//! [screen-properties]
+ width: splashImage.width
+ height: splashImage.height
Image {
id: splashImage
@@ -76,4 +75,5 @@ Window {
}
}
//! [timer]
+ Component.onCompleted: visible = true
}
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/doc/qtquickdialogs.qdocconf b/src/imports/dialogs/doc/qtquickdialogs.qdocconf
index 34f19b5ff3..be4fd5e9ec 100644
--- a/src/imports/dialogs/doc/qtquickdialogs.qdocconf
+++ b/src/imports/dialogs/doc/qtquickdialogs.qdocconf
@@ -34,3 +34,6 @@ headerdirs += ..
sourcedirs += ..
imagedirs += images
+
+navigation.landingpage = "Qt Quick Dialogs"
+navigation.qmltypespage = "Qt Quick Dialogs QML Types"
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..eab273ed1c 100644
--- a/src/imports/dialogs/plugin.cpp
+++ b/src/imports/dialogs/plugin.cpp
@@ -48,11 +48,10 @@
#include "qquickabstractcolordialog_p.h"
#include "qquickplatformcolordialog_p.h"
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
//#define PURE_QML_ONLY
-#define DIALOGS_MAJOR_MINOR 1, 0
-
QT_BEGIN_NAMESPACE
/*!
@@ -78,9 +77,19 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin
public:
QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { }
+ virtual void initializeEngine(QQmlEngine *engine, const char *uri) {
+ //qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl;
+ Q_UNUSED(uri);
+ 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");
@@ -93,47 +102,48 @@ public:
// FileDialog
#ifndef PURE_QML_ONLY
if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
- qmlRegisterType<QQuickPlatformFileDialog>(uri, DIALOGS_MAJOR_MINOR, "FileDialog");
+ qmlRegisterType<QQuickPlatformFileDialog>(uri, 1, 0, "FileDialog");
else
#endif
- registerWidgetOrQmlImplementation<QQuickFileDialog>(widgetsDir, "WidgetFileDialog.qml",
- qmlDir, "DefaultFileDialog.qml", "FileDialog", uri);
+ registerWidgetOrQmlImplementation<QQuickFileDialog>(widgetsDir, qmlDir, "FileDialog", uri, hasTopLevelWindows, 1, 0);
// ColorDialog
#ifndef PURE_QML_ONLY
if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::ColorDialog))
- qmlRegisterType<QQuickPlatformColorDialog>(uri, DIALOGS_MAJOR_MINOR, "ColorDialog");
+ qmlRegisterType<QQuickPlatformColorDialog>(uri, 1, 0, "ColorDialog");
else
#endif
- registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, "WidgetColorDialog.qml",
- qmlDir, "DefaultColorDialog.qml", "ColorDialog", uri);
+ registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, qmlDir, "ColorDialog", uri, hasTopLevelWindows, 1, 0);
}
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, int versionMajor, int versionMinor) {
+ //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);
- if (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, DIALOGS_MAJOR_MINOR, qmlName) >= 0)
+ QString dialogQmlPath = qmlDir.filePath(QString("Widget%1.qml").arg(qmlName));
+ if (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, versionMajor, versionMinor, 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
+ qmlRegisterType<WrapperType>(uri, versionMajor, versionMinor, 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);
+ qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, versionMajor, versionMinor, 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..ec5a7f6926 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,22 @@ void QQuickAbstractFileDialog::setSelectFolder(bool selectFolder)
updateModes();
}
-QString QQuickAbstractFileDialog::folder()
+QUrl QQuickAbstractFileDialog::folder()
{
+ return QUrl();
+ /* TODO after dialog helper switches to URLs
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 +145,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);
@@ -159,9 +163,11 @@ QUrl QQuickAbstractFileDialog::fileUrl()
QList<QUrl> QQuickAbstractFileDialog::fileUrls()
{
QList<QUrl> ret;
+ /* TODO after dialog helper switches to URLs
if (m_dlgHelper)
foreach (QString path, m_dlgHelper->selectedFiles())
ret << QUrl::fromLocalFile(path);
+ */
return ret;
}
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/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp
index ad09f54381..4aa43b2d3f 100644
--- a/src/imports/folderlistmodel/fileinfothread.cpp
+++ b/src/imports/folderlistmodel/fileinfothread.cpp
@@ -55,6 +55,7 @@ FileInfoThread::FileInfoThread(QObject *parent)
needUpdate(true),
folderUpdate(false),
sortUpdate(false),
+ showFiles(true),
showDirs(true),
showDirsFirst(false),
showDotAndDotDot(false),
@@ -142,6 +143,14 @@ void FileInfoThread::setNameFilters(const QStringList & filters)
condition.wakeAll();
}
+void FileInfoThread::setShowFiles(bool show)
+{
+ QMutexLocker locker(&mutex);
+ showFiles = show;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
void FileInfoThread::setShowDirs(bool showFolders)
{
QMutexLocker locker(&mutex);
@@ -213,7 +222,9 @@ void FileInfoThread::run()
void FileInfoThread::getFileInfos(const QString &path)
{
QDir::Filters filter;
- filter = QDir::Files | QDir::CaseSensitive;
+ filter = QDir::CaseSensitive;
+ if (showFiles)
+ filter = filter | QDir::Files;
if (showDirs)
filter = filter | QDir::AllDirs | QDir::Drives;
if (!showDotAndDotDot)
diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h
index cf6572a279..d50361de3a 100644
--- a/src/imports/folderlistmodel/fileinfothread_p.h
+++ b/src/imports/folderlistmodel/fileinfothread_p.h
@@ -70,6 +70,7 @@ public:
void setRootPath(const QString &path);
void setSortFlags(QDir::SortFlags flags);
void setNameFilters(const QStringList & nameFilters);
+ void setShowFiles(bool show);
void setShowDirs(bool showFolders);
void setShowDirsFirst(bool show);
void setShowDotAndDotDot(bool on);
@@ -102,6 +103,7 @@ private:
bool needUpdate;
bool folderUpdate;
bool sortUpdate;
+ bool showFiles;
bool showDirs;
bool showDirsFirst;
bool showDotAndDotDot;
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 85b59e9c73..4dbbcf359d 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -55,7 +55,8 @@ class QQuickFolderListModelPrivate
public:
QQuickFolderListModelPrivate(QQuickFolderListModel *q)
: q_ptr(q),
- sortField(QQuickFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDotAndDotDot(false), showOnlyReadable(false)
+ sortField(QQuickFolderListModel::Name), sortReversed(false), showFiles(true),
+ showDirs(true), showDirsFirst(false), showDotAndDotDot(false), showOnlyReadable(false)
{
nameFilters << QLatin1String("*");
}
@@ -70,6 +71,7 @@ public:
QQuickFolderListModel::SortField sortField;
QStringList nameFilters;
bool sortReversed;
+ bool showFiles;
bool showDirs;
bool showDirsFirst;
bool showDotAndDotDot;
@@ -619,6 +621,30 @@ bool QQuickFolderListModel::isFolder(int index) const
}
/*!
+ \qmlproperty bool FolderListModel::showFiles
+
+ If true, files are included in the model; otherwise only directories
+ are included.
+
+ By default, this property is true.
+
+ \sa showDirs
+*/
+bool QQuickFolderListModel::showFiles() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->showFiles;
+}
+
+void QQuickFolderListModel::setShowFiles(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ d->fileInfoThread.setShowFiles(on);
+ d->showFiles = on;
+}
+
+/*!
\qmlproperty bool FolderListModel::showDirs
If true, directories are included in the model; otherwise only files
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index 03cb24d368..43af77adf5 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -69,6 +69,7 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
+ Q_PROPERTY(bool showFiles READ showFiles WRITE setShowFiles)
Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst)
Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
@@ -121,6 +122,8 @@ public:
bool sortReversed() const;
void setSortReversed(bool rev);
+ bool showFiles() const;
+ void setShowFiles(bool showFiles);
bool showDirs() const;
void setShowDirs(bool showDirs);
bool showDirsFirst() const;
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 7a922a832e..6fbe8a51b8 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -10,7 +10,8 @@ qtHaveModule(quick) {
qtquick2 \
particles \
window \
- dialogs \
+# disabled to allow file dialog changes to use urls internally (qtbase)
+# dialogs \
testlib
}
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/qquickqcolordialog.cpp b/src/imports/widgets/qquickqcolordialog.cpp
index abe6ffd004..d10eacee60 100644
--- a/src/imports/widgets/qquickqcolordialog.cpp
+++ b/src/imports/widgets/qquickqcolordialog.cpp
@@ -68,8 +68,11 @@ public:
virtual void exec() { m_dialog.exec(); }
virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
- m_dialog.windowHandle()->setTransientParent(parent);
- m_dialog.windowHandle()->setFlags(f);
+ 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())));
diff --git a/src/imports/widgets/qquickqfiledialog.cpp b/src/imports/widgets/qquickqfiledialog.cpp
index 672c6d1bf4..6aab2adbb9 100644
--- a/src/imports/widgets/qquickqfiledialog.cpp
+++ b/src/imports/widgets/qquickqfiledialog.cpp
@@ -67,9 +67,11 @@ public:
virtual bool defaultNameFilterDisables() const { return true; }
virtual void setDirectory(const QString &dir) { m_dialog.setDirectory(dir); }
- virtual QString directory() const { return m_dialog.directory().absolutePath(); }
virtual void selectFile(const QString &f) { m_dialog.selectFile(f); }
+ /* TODO after dialog helper switches to URLs
+ virtual QString directory() const { return m_dialog.directory().absolutePath(); }
virtual QStringList selectedFiles() const { return m_dialog.selectedFiles(); }
+ */
virtual void setFilter() {
m_dialog.setWindowTitle(QPlatformFileDialogHelper::options()->windowTitle());
@@ -96,8 +98,11 @@ public:
virtual void exec() { m_dialog.exec(); }
virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
- m_dialog.windowHandle()->setTransientParent(parent);
- m_dialog.windowHandle()->setFlags(f);
+ 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();
@@ -132,14 +137,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
*/
@@ -185,6 +190,7 @@ QPlatformFileDialogHelper *QQuickQFileDialog::helper()
if (parentItem)
m_parentWindow = parentItem->window();
+ /* TODO after dialog helper switches to URLs
if (!m_dlgHelper) {
m_dlgHelper = new QFileDialogHelper();
connect(m_dlgHelper, SIGNAL(directoryEntered(QString)), this, SIGNAL(folderChanged()));
@@ -192,6 +198,7 @@ QPlatformFileDialogHelper *QQuickQFileDialog::helper()
connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
}
+ */
return m_dlgHelper;
}
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
index f3f78c8eae..c12bfee924 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
@@ -393,8 +393,7 @@ void QQuickXmlQueryEngine::doQueryJob(XmlQueryJob *currentJob, QQuickXmlQueryRes
b.open(QIODevice::ReadOnly);
QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
- QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
+ QString prefix = QLatin1String("doc($inputDocument)/dummy:items/*");
//figure out how many items we are dealing with
int count = -1;
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/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf
index 2198428a38..da596a1d97 100644
--- a/src/qml/doc/qtqml.qdocconf
+++ b/src/qml/doc/qtqml.qdocconf
@@ -47,3 +47,7 @@ exampledirs += ../../../examples/qml \
snippets
imagedirs += images
+
+navigation.landingpage = "Qt QML"
+navigation.cppclassespage = "Qt QML C++ Classes"
+navigation.qmltypespage = "Qt QML QML Types"
diff --git a/src/qml/doc/src/whatsnew.qdoc b/src/qml/doc/src/whatsnew.qdoc
index eece3bcaab..9ad8c23a42 100644
--- a/src/qml/doc/src/whatsnew.qdoc
+++ b/src/qml/doc/src/whatsnew.qdoc
@@ -37,6 +37,11 @@ a summary of the new changes:
\li New QQmlApplicationEngine convenience class for QML applications.
\li New Instantiatior type for generic, dynamic object creation.
\li New properties for \l Qt.application: arguments, name, and version.
+\li The 'with' statement has been deprecated and is slated for removal in a
+ future version of the language.
+\li New \l Qt.platform object with an os property
+\li New \l qmlClearTypeRegistations() function drops all data from qmlRegisterType calls
+\li New \l qmlRegisterType function for registering composite types.
\endlist
\section2 New Submodule
@@ -110,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/ftw/qqmltrace.cpp b/src/qml/qml/ftw/qqmltrace.cpp
index 98f86dad32..9bf58c245c 100644
--- a/src/qml/qml/ftw/qqmltrace.cpp
+++ b/src/qml/qml/ftw/qqmltrace.cpp
@@ -43,6 +43,7 @@
#ifdef QML_ENABLE_TRACE
#include <stdio.h>
+#include <unistd.h>
#endif
QT_BEGIN_NAMESPACE
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 cd5d1e96b7..e59116a7c1 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -785,8 +785,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
*/
@@ -827,8 +826,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 2b186dbb75..dbf098e701 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -391,9 +391,9 @@ The following functions are also on the Qt object.
\list
\li \c "android" - Android
\li \c "blackberry" - BlackBerry OS
- \li \c "ios" - Apple iOS
+ \li \c "ios" - iOS
\li \c "linux" - Linux
- \li \c "mac" - Mac OS X
+ \li \c "osx" - OS X
\li \c "unix" - Other Unix-based OS
\li \c "windows" - Windows
\li \c "wince" - Windows CE
@@ -451,7 +451,15 @@ The following functions are also on the Qt object.
\row
\li \c application.version
\li This is the application version set on the QCoreApplication instance. This property can be written
- to in order to set the application name.
+ to in order to set the application version.
+ \row
+ \li \c application.organization
+ \li This is the organization name set on the QCoreApplication instance. This property can be written
+ to in order to set the organization name.
+ \row
+ \li \c application.domain
+ \li This is the organization domain set on the QCoreApplication instance. This property can be written
+ to in order to set the organization domain.
\endtable
The object also has one signal, aboutToQuit(), which is the same as \l QCoreApplication::aboutToQuit().
@@ -855,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/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp
index 8418217ab9..939b7e465a 100644
--- a/src/qml/qml/qqmlglobal.cpp
+++ b/src/qml/qml/qqmlglobal.cpp
@@ -403,6 +403,14 @@ QQmlApplication::QQmlApplication(QObject *parent)
{
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
this, SIGNAL(aboutToQuit()));
+ connect(QCoreApplication::instance(), SIGNAL(applicationNameChanged()),
+ this, SIGNAL(nameChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(applicationVersionChanged()),
+ this, SIGNAL(versionChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(organizationNameChanged()),
+ this, SIGNAL(organizationChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(organizationDomainChanged()),
+ this, SIGNAL(domainChanged()));
}
QQmlApplication::QQmlApplication(QQmlApplicationPrivate &dd, QObject *parent)
@@ -410,6 +418,14 @@ QQmlApplication::QQmlApplication(QQmlApplicationPrivate &dd, QObject *parent)
{
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
this, SIGNAL(aboutToQuit()));
+ connect(QCoreApplication::instance(), SIGNAL(applicationNameChanged()),
+ this, SIGNAL(nameChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(applicationVersionChanged()),
+ this, SIGNAL(versionChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(organizationNameChanged()),
+ this, SIGNAL(organizationChanged()));
+ connect(QCoreApplication::instance(), SIGNAL(organizationDomainChanged()),
+ this, SIGNAL(domainChanged()));
}
QStringList QQmlApplication::args()
@@ -432,16 +448,34 @@ QString QQmlApplication::version() const
return QCoreApplication::instance()->applicationVersion();
}
+QString QQmlApplication::organization() const
+{
+ return QCoreApplication::instance()->organizationName();
+}
+
+QString QQmlApplication::domain() const
+{
+ return QCoreApplication::instance()->organizationDomain();
+}
+
void QQmlApplication::setName(const QString &arg)
{
QCoreApplication::instance()->setApplicationName(arg);
- emit nameChanged(); //Note that we don't get notified if it's changed from C++
}
void QQmlApplication::setVersion(const QString &arg)
{
QCoreApplication::instance()->setApplicationVersion(arg);
- emit versionChanged(); //Note that we don't get notified if it's changed from C++
+}
+
+void QQmlApplication::setOrganization(const QString &arg)
+{
+ QCoreApplication::instance()->setOrganizationName(arg);
+}
+
+void QQmlApplication::setDomain(const QString &arg)
+{
+ QCoreApplication::instance()->setOrganizationDomain(arg);
}
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 0c9e685a07..7b968a7e46 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -322,6 +322,8 @@ class Q_QML_PRIVATE_EXPORT QQmlApplication : public QObject
Q_PROPERTY(QStringList arguments READ args CONSTANT)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString version READ version WRITE setVersion NOTIFY versionChanged)
+ Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged)
+ Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged)
public:
QQmlApplication(QObject* parent=0);
@@ -329,16 +331,22 @@ public:
QString name() const;
QString version() const;
+ QString organization() const;
+ QString domain() const;
public Q_SLOTS:
void setName(const QString &arg);
void setVersion(const QString &arg);
+ void setOrganization(const QString &arg);
+ void setDomain(const QString &arg);
Q_SIGNALS:
void aboutToQuit();
void nameChanged();
void versionChanged();
+ void organizationChanged();
+ void domainChanged();
protected:
QQmlApplication(QQmlApplicationPrivate &dd, QObject* parent=0);
diff --git a/src/qml/qml/qqmlplatform.cpp b/src/qml/qml/qqmlplatform.cpp
index de48f60f56..04862379be 100644
--- a/src/qml/qml/qqmlplatform.cpp
+++ b/src/qml/qml/qqmlplatform.cpp
@@ -66,7 +66,7 @@ QString QQmlPlatform::os()
#elif defined(Q_OS_IOS)
return QLatin1String("ios");
#elif defined(Q_OS_MAC)
- return QLatin1String("mac");
+ return QLatin1String("osx");
#elif defined(Q_OS_WINCE)
return QLatin1String("wince");
#elif defined(Q_OS_WIN)
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 4c0b382439..067d91ea7f 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -1838,7 +1838,7 @@ int QQmlListModel::count() const
}
/*!
- \qmlmethod QtQml2::ListModel::clear()
+ \qmlmethod ListModel::clear()
Deletes all content from the model.
@@ -1860,7 +1860,7 @@ void QQmlListModel::clear()
}
/*!
- \qmlmethod QtQml2::ListModel::remove(int index, int count = 1)
+ \qmlmethod ListModel::remove(int index, int count = 1)
Deletes the content at \a index from the model.
@@ -1894,7 +1894,7 @@ void QQmlListModel::remove(QQmlV4Function *args)
}
/*!
- \qmlmethod QtQml2::ListModel::insert(int index, jsobject dict)
+ \qmlmethod ListModel::insert(int index, jsobject dict)
Adds a new item to the list model at position \a index, with the
values in \a dict.
@@ -1952,7 +1952,7 @@ void QQmlListModel::insert(QQmlV4Function *args)
}
/*!
- \qmlmethod QtQml2::ListModel::move(int from, int to, int n)
+ \qmlmethod ListModel::move(int from, int to, int n)
Moves \a n items \a from one position \a to another.
@@ -2005,7 +2005,7 @@ void QQmlListModel::move(int from, int to, int n)
}
/*!
- \qmlmethod QtQml2::ListModel::append(jsobject dict)
+ \qmlmethod ListModel::append(jsobject dict)
Adds a new item to the end of the list model, with the
values in \a dict.
@@ -2056,7 +2056,7 @@ void QQmlListModel::append(QQmlV4Function *args)
}
/*!
- \qmlmethod object QtQml2::ListModel::get(int index)
+ \qmlmethod object ListModel::get(int index)
Returns the item at \a index in the list model. This allows the item
data to be accessed or modified from JavaScript:
@@ -2106,7 +2106,7 @@ QQmlV4Handle QQmlListModel::get(int index) const
}
/*!
- \qmlmethod QtQml2::ListModel::set(int index, jsobject dict)
+ \qmlmethod ListModel::set(int index, jsobject dict)
Changes the item at \a index in the list model with the
values in \a dict. Properties not appearing in \a dict
@@ -2160,7 +2160,7 @@ void QQmlListModel::set(int index, const QQmlV4Handle &handle)
}
/*!
- \qmlmethod QtQml2::ListModel::setProperty(int index, string property, variant value)
+ \qmlmethod ListModel::setProperty(int index, string property, variant value)
Changes the \a property of the item at \a index in the list model to \a value.
@@ -2203,7 +2203,7 @@ void QQmlListModel::setProperty(int index, const QString& property, const QVaria
}
/*!
- \qmlmethod QtQml2::ListModel::sync()
+ \qmlmethod ListModel::sync()
Writes any unsaved changes to the list model after it has been modified
from a worker script.
diff --git a/src/quick/doc/images/qml-item-canvas-clip-complex.png b/src/quick/doc/images/qml-item-canvas-clip-complex.png
new file mode 100644
index 0000000000..cb582bad41
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-clip-complex.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-scaley.png b/src/quick/doc/images/qml-item-canvas-scaley.png
new file mode 100644
index 0000000000..61462b9adc
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-scaley.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-skewx.png b/src/quick/doc/images/qml-item-canvas-skewx.png
new file mode 100644
index 0000000000..c9bcb6715c
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-skewx.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-skewy.png b/src/quick/doc/images/qml-item-canvas-skewy.png
new file mode 100644
index 0000000000..594ac842a4
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-skewy.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-translate.png b/src/quick/doc/images/qml-item-canvas-translate.png
new file mode 100644
index 0000000000..7bb3ae7560
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-translate.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-translatey.png b/src/quick/doc/images/qml-item-canvas-translatey.png
new file mode 100644
index 0000000000..9196bf5919
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-translatey.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-arcTo2.png b/src/quick/doc/images/qml-item-canvas.arc.png
index 5f9d32d8d3..5f9d32d8d3 100644
--- a/src/quick/doc/images/qml-item-canvas-arcTo2.png
+++ b/src/quick/doc/images/qml-item-canvas.arc.png
Binary files differ
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index 30861d9b2e..8f769871a5 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -63,3 +63,7 @@ sourcedirs += ../../plugins
excludedirs += ../../imports/dialogs \
../../imports/models \
../../../examples/quick/dialogs
+
+navigation.landingpage = "Qt Quick"
+navigation.cppclassespage = "Qt Quick C++ Classes"
+navigation.qmltypespage = "Qt Quick QML Types"
diff --git a/src/quick/doc/src/concepts/effects/topic.qdoc b/src/quick/doc/src/concepts/effects/topic.qdoc
index 42b0291e44..bf713c2259 100644
--- a/src/quick/doc/src/concepts/effects/topic.qdoc
+++ b/src/quick/doc/src/concepts/effects/topic.qdoc
@@ -35,7 +35,7 @@
Visually appealing user-interfaces are more engaging than lacklustre ones.
That said, the designer must bear in mind that visual effects simply provide
-a useful way to subtlely communicate to the user (for example, which visual
+a useful way to subtly communicate to the user (for example, which visual
item is active, or how focus is being transferred). Over-use of visual
effects can actually detract from the user-experience.
diff --git a/src/quick/doc/src/whatsnew.qdoc b/src/quick/doc/src/whatsnew.qdoc
index 973d41dca2..26d88699bc 100644
--- a/src/quick/doc/src/whatsnew.qdoc
+++ b/src/quick/doc/src/whatsnew.qdoc
@@ -38,7 +38,8 @@ features introduced by the new import and new classes in Qt 5.1:
\li New render loop for windows for smoother animations.
\li New \l Window properties: activeFocusItem, minimumWidth, minimumHeight,
maximumWidth, maximumHeight, visibility, contentOrientation, and opacity.
-\li New \l Item property: activeFocusOnTab.
+\li New \l Screen attached properties: name, desktopAvailableWidth,
+ desktopAvailableHeight, logicalPixelDensity
\li New \l Grid properties: horizontalAlignment, verticalAlignment, and
effectiveHorizontalAlignment.
\li New \l TextEdit properties: selectByKeyboard and textDocument
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 9c4cef1fe1..55fb8b7fc5 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -630,8 +630,11 @@ void QQuickCanvasItem::itemChange(QQuickItem::ItemChange change, const QQuickIte
return;
Q_D(QQuickCanvasItem);
- if (d->available)
+ if (d->available) {
+ if (d->dirtyAttributes & QQuickItemPrivate::ContentUpdateMask)
+ requestPaint();
return;
+ }
if (value.window== 0)
return;
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index ca8b947756..d59e65dfd4 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -198,31 +198,153 @@ QColor qt_color_from_string(const QV4::Value &name)
return QColor();
}
-QFont qt_font_from_string(const QString& fontString) {
- QFont font;
- // ### this is simplified and incomplete
- // ### TODO:get code from Qt webkit
- const QStringList tokens = fontString.split(QLatin1Char(' '));
- foreach (const QString &token, tokens) {
- if (token == QStringLiteral("italic"))
- font.setItalic(true);
- else if (token == QStringLiteral("bold"))
- font.setBold(true);
- else if (token.endsWith(QStringLiteral("px"))) {
- QString number = token;
- number.remove(QLatin1String("px"));
- bool ok = false;
- float pixelSize = number.trimmed().toFloat(&ok);
- if (ok)
- font.setPixelSize(int(pixelSize));
- } else
- font.setFamily(token);
- }
-
- return font;
+static bool qSetFontSizeFromToken(QFont &font, const QString &fontSizeToken)
+{
+ const QString trimmedToken = fontSizeToken.trimmed();
+ QString unit = trimmedToken.right(2);
+ QString value = trimmedToken.left(fontSizeToken.size() - 2);
+ bool ok = false;
+ float size = value.trimmed().toFloat(&ok);
+ if (ok) {
+ int intSize = int(size);
+ if (unit.compare(QLatin1String("px")) == 0) {
+ font.setPixelSize(intSize);
+ return true;
+ } else if (unit.compare(QLatin1String("pt")) == 0) {
+ font.setPointSize(intSize);
+ return true;
+ }
+ }
+ qWarning().nospace() << "Context2D: A font size of " << fontSizeToken << " is invalid.";
+ return false;
+}
+
+static bool qSetFontFamilyFromToken(QFont &font, const QString &fontFamilyToken)
+{
+ const QString trimmedToken = fontFamilyToken.trimmed();
+ QFontDatabase fontDatabase;
+ if (fontDatabase.hasFamily(trimmedToken)) {
+ font.setFamily(trimmedToken);
+ return true;
+ } else {
+ // Can't find a family matching this name; if it's a generic family,
+ // try searching for the default family for it by using style hints.
+ QFont tmp;
+ int styleHint = -1;
+ if (fontFamilyToken.compare(QLatin1String("serif")) == 0) {
+ styleHint = QFont::Serif;
+ } else if (fontFamilyToken.compare(QLatin1String("sans-serif")) == 0) {
+ styleHint = QFont::SansSerif;
+ } else if (fontFamilyToken.compare(QLatin1String("cursive")) == 0) {
+ styleHint = QFont::Cursive;
+ } else if (fontFamilyToken.compare(QLatin1String("monospace")) == 0) {
+ styleHint = QFont::Monospace;
+ } else if (fontFamilyToken.compare(QLatin1String("fantasy")) == 0) {
+ styleHint = QFont::Fantasy;
+ }
+ if (styleHint != -1) {
+ tmp.setStyleHint(static_cast<QFont::StyleHint>(styleHint));
+ font.setFamily(tmp.defaultFamily());
+ return true;
+ }
+ }
+ qWarning().nospace() << "Context2D: The font family " << fontFamilyToken << " is invalid.";
+ return false;
}
+enum FontToken
+{
+ NoTokens = 0x00,
+ FontStyle = 0x01,
+ FontVariant = 0x02,
+ FontWeight = 0x04
+};
+#define Q_TRY_SET_TOKEN(token, value, setStatement) \
+if (!(usedTokens & token)) { \
+ usedTokens |= token; \
+ setStatement; \
+} else { \
+ qWarning().nospace() << "Context2D: Duplicate token " << QLatin1String(value) << " found in font string."; \
+ return currentFont; \
+}
+
+/*!
+ Parses a font string based on the CSS shorthand font property.
+
+ See: http://www.w3.org/TR/css3-fonts/#font-prop
+*/
+static QFont qt_font_from_string(const QString& fontString, const QFont &currentFont) {
+ const QStringList tokens = fontString.split(QLatin1Char(' '));
+ if (tokens.size() < 2) {
+ qWarning().nospace() << "Context2D: Insufficent amount of tokens in font string.";
+ return currentFont;
+ }
+
+ QFont newFont;
+ QStringList remainingTokens = tokens;
+ int usedTokens = NoTokens;
+ // Optional properties can be in any order, but font-size and font-family must be last.
+ while (remainingTokens.size() > 2) {
+ const QString token = remainingTokens.takeFirst();
+ if (token.compare(QLatin1String("normal")) == 0) {
+ if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
+ // Could be font-style, font-variant or font-weight.
+ if (!(usedTokens & FontStyle)) {
+ // QFont::StyleNormal is the default for QFont::style.
+ usedTokens = usedTokens | FontStyle;
+ } else if (!(usedTokens & FontVariant)) {
+ // QFont::MixedCase is the default for QFont::capitalization.
+ usedTokens |= FontVariant;
+ } else if (!(usedTokens & FontWeight)) {
+ // QFont::Normal is the default for QFont::weight.
+ usedTokens |= FontWeight;
+ }
+ } else {
+ qWarning().nospace() << "Context2D: Duplicate token \"normal\" found in font string.";
+ return currentFont;
+ }
+ } else if (token.compare(QLatin1String("bold")) == 0) {
+ Q_TRY_SET_TOKEN(FontWeight, "bold", newFont.setBold(true))
+ } else if (token.compare(QLatin1String("italic")) == 0) {
+ Q_TRY_SET_TOKEN(FontStyle, "italic", newFont.setStyle(QFont::StyleItalic))
+ } else if (token.compare(QLatin1String("oblique")) == 0) {
+ Q_TRY_SET_TOKEN(FontStyle, "oblique", newFont.setStyle(QFont::StyleOblique))
+ } else if (token.compare(QLatin1String("small-caps")) == 0) {
+ Q_TRY_SET_TOKEN(FontVariant, "small-caps", newFont.setCapitalization(QFont::SmallCaps))
+ } else {
+ bool conversionOk = false;
+ int weight = token.toInt(&conversionOk);
+ if (conversionOk) {
+ if (weight >= 0 && weight <= 99) {
+ Q_TRY_SET_TOKEN(FontWeight, "<font-weight>", newFont.setWeight(weight))
+ continue;
+ } else {
+ qWarning().nospace() << "Context2D: Invalid font weight " << weight << " found in font string; "
+ << "must be between 0 and 99, inclusive.";
+ return currentFont;
+ }
+ }
+ // The token is invalid or in the wrong place/order in the font string.
+ qWarning().nospace() << "Context2D: Invalid or misplaced token " << token << " found in font string.";
+ return currentFont;
+ }
+ }
+ if (remainingTokens.size() == 2) {
+ // Order must be: font-size font-family.
+ if (!qSetFontSizeFromToken(newFont, remainingTokens.first())) {
+ return currentFont;
+ }
+ if (!qSetFontFamilyFromToken(newFont, remainingTokens.last())) {
+ return currentFont;
+ }
+ return newFont;
+ } else {
+ qWarning().nospace() << "Context2D: Missing font-size and/or font-family tokens in font string.";
+ return currentFont;
+ }
+ return newFont;
+}
class QQuickContext2DEngineData : public QV8Engine::Deletable
{
@@ -781,17 +903,19 @@ QV4::Value QQuickJSContext2DPrototype::method_save(QV4::SimpleCallContext *ctx)
// transformations
/*!
\qmlmethod object QtQuick2::Context2D::rotate(real angle)
- Rotate the canvas around the current origin by \c angle in radians and clockwise direction.
+ Rotate the canvas around the current origin by \a angle in radians and clockwise direction.
+
\code
ctx.rotate(Math.PI/2);
\endcode
+
\image qml-item-canvas-rotate.png
The rotation transformation matrix is as follows:
\image qml-item-canvas-math-rotate.png
- where the \c angle of rotation is in radians.
+ where the \a angle of rotation is in radians.
*/
QV4::Value QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallContext *ctx)
@@ -806,17 +930,20 @@ QV4::Value QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallContext *ctx
/*!
\qmlmethod object QtQuick2::Context2D::scale(real x, real y)
+
Increases or decreases the size of each unit in the canvas grid by multiplying the scale factors
to the current tranform matrix.
- Where \c x is the scale factor in the horizontal direction and \c y is the scale factor in the
+ \a x is the scale factor in the horizontal direction and \a y is the scale factor in the
vertical direction.
- The following code doubles the horizontal size of an object drawn on the canvas and half its
+
+ The following code doubles the horizontal size of an object drawn on the canvas and halves its
vertical size:
+
\code
ctx.scale(2.0, 0.5);
\endcode
- \image qml-item-canvas-scale.png
+ \image qml-item-canvas-scale.png
*/
QV4::Value QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallContext *ctx)
{
@@ -845,15 +972,15 @@ QV4::Value QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallContext *ctx)
\li \c{a} is the scale factor in the horizontal (x) direction
\image qml-item-canvas-scalex.png
\li \c{c} is the skew factor in the x direction
- \image qml-item-canvas-canvas-skewx.png
+ \image qml-item-canvas-skewx.png
\li \c{e} is the translation in the x direction
- \image qml-item-canvas-canvas-translate.png
+ \image qml-item-canvas-translate.png
\li \c{b} is the skew factor in the y (vertical) direction
- \image qml-item-canvas-canvas-skewy.png
+ \image qml-item-canvas-skewy.png
\li \c{d} is the scale factor in the y direction
- \image qml-item-canvas-canvas-scaley.png
+ \image qml-item-canvas-scaley.png
\li \c{f} is the translation in the y direction
- \image qml-item-canvas-canvas-translatey.png
+ \image qml-item-canvas-translatey.png
\li the last row remains constant
\endlist
The scale factors and skew factors are multiples; \c{e} and \c{f} are
@@ -881,8 +1008,9 @@ QV4::Value QQuickJSContext2DPrototype::method_setTransform(QV4::SimpleCallContex
/*!
\qmlmethod object QtQuick2::Context2D::transform(real a, real b, real c, real d, real e, real f)
+
This method is very similar to setTransform(), but instead of replacing the old
- tranform matrix, this method applies the given tranform matrix to the current matrix by mulitplying to it.
+ transform matrix, this method applies the given tranform matrix to the current matrix by multiplying to it.
The setTransform(a, b, c, d, e, f) method actually resets the current transform to the identity matrix,
and then invokes the transform(a, b, c, d, e, f) method with the same arguments.
@@ -908,10 +1036,10 @@ QV4::Value QQuickJSContext2DPrototype::method_transform(QV4::SimpleCallContext *
/*!
\qmlmethod object QtQuick2::Context2D::translate(real x, real y)
- Translates the origin of the canvas to point (\c x, \c y).
- \c x is the horizontal distance that the origin is translated, in coordinate space units,
- \c y is the vertical distance that the origin is translated, in coordinate space units.
+ Translates the origin of the canvas by a horizontal distance of \a x,
+ and a vertical distance of \a y, in coordinate space units.
+
Translating the origin enables you to draw patterns of different objects on the canvas
without having to measure the coordinates manually for each shape.
*/
@@ -929,7 +1057,9 @@ QV4::Value QQuickJSContext2DPrototype::method_translate(QV4::SimpleCallContext *
/*!
\qmlmethod object QtQuick2::Context2D::resetTransform()
- Reset the transformation matrix to default value.
+
+ Reset the transformation matrix to the default value (equivalent to calling
+ setTransform(\c 1, \c 0, \c 0, \c 1, \c 0, \c 0)).
\sa transform(), setTransform(), reset()
*/
@@ -945,8 +1075,10 @@ QV4::Value QQuickJSContext2DPrototype::method_resetTransform(QV4::SimpleCallCont
/*!
- \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv )
- Shear the transformation matrix with \a sh in horizontal direction and \a sv in vertical direction.
+ \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv)
+
+ Shears the transformation matrix by \a sh in the horizontal direction and
+ \a sv in the vertical direction.
*/
QV4::Value QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallContext *ctx)
{
@@ -962,9 +1094,10 @@ QV4::Value QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallContext *ctx)
/*!
\qmlproperty real QtQuick2::Context2D::globalAlpha
+
Holds the current alpha value applied to rendering operations.
- The value must be in the range from 0.0 (fully transparent) to 1.0 (fully opque).
- The default value is 1.0.
+ The value must be in the range from \c 0.0 (fully transparent) to \c 1.0 (fully opaque).
+ The default value is \c 1.0.
*/
QV4::Value QQuickJSContext2D::method_get_globalAlpha(QV4::SimpleCallContext *ctx)
{
@@ -1826,12 +1959,25 @@ QV4::Value QQuickJSContext2DPrototype::method_strokeRect(QV4::SimpleCallContext
// Complex shapes (paths) API
/*!
- \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)
- Adds an arc to the current subpath that lies on the circumference of the circle whose center is at the point (\c x,\cy) and whose radius is \c radius.
- \image qml-item-canvas-arcTo2.png
- \sa arcTo,
- {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C 2d context standard for arc}
- */
+ \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius,
+ real startAngle, real endAngle, bool anticlockwise)
+
+ Adds an arc to the current subpath that lies on the circumference of the
+ circle whose center is at the point (\a x, \a y) and whose radius is
+ \a radius.
+
+ Both \c startAngle and \c endAngle are measured from the x-axis in radians.
+
+ \image qml-item-canvas-arc.png
+
+ \image qml-item-canvas-startAngle.png
+
+ The \a anticlockwise parameter is \c true for each arc in the figure above
+ because they are all drawn in the anticlockwise direction.
+
+ \sa arcTo, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C's 2D
+ Context Standard for arc()}
+*/
QV4::Value QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx)
{
QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
@@ -1860,25 +2006,28 @@ QV4::Value QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx)
}
/*!
- \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2, real y2, real radius)
+ \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2,
+ real y2, real radius)
+
+ Adds an arc with the given control points and radius to the current subpath,
+ connected to the previous point by a straight line. To draw an arc, you
+ begin with the same steps you followed to create a line:
- Adds an arc with the given control points and radius to the current subpath, connected to the previous point by a straight line.
- To draw an arc, you begin with the same steps your followed to create a line:
\list
- \li Call the context.beginPath() method to set a new path.
- \li Call the context.moveTo(\c x, \c y) method to set your starting position on the canvas at the point (\c x,\c y).
- \li To draw an arc or circle, call the context.arcTo(\c x1, \c y1, \c x2, \c y2,\c radius) method.
- This adds an arc with starting point (\c x1,\c y1), ending point (\c x2, \c y2), and radius \c radius to the current subpath and connects
- it to the previous subpath by a straight line.
+ \li Call the beginPath() method to set a new path.
+ \li Call the moveTo(\c x, \c y) method to set your starting position on the
+ canvas at the point (\c x, \c y).
+ \li To draw an arc or circle, call the arcTo(\a x1, \a y1, \a x2, \a y2,
+ \a radius) method. This adds an arc with starting point (\a x1, \a y1),
+ ending point (\a x2, \a y2), and \a radius to the current subpath and
+ connects it to the previous subpath by a straight line.
\endlist
+
\image qml-item-canvas-arcTo.png
- Both startAngle and endAngle are measured from the x axis in units of radians.
- \image qml-item-canvas-startAngle.png
- The anticlockwise has the value TRUE for each arc in the figure above because they are all drawn in the counterclockwise direction.
- \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C 2d
- context standard for arcTo}
- */
+ \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C's 2D
+ Context Standard for arcTo()}
+*/
QV4::Value QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallContext *ctx)
{
QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
@@ -1975,7 +2124,7 @@ QV4::Value QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::SimpleCallConte
The new shape displays. The following shows how a clipping path can
modify how an image displays:
- \image qml-canvas-clip-complex.png
+ \image qml-item-canvas-clip-complex.png
\sa beginPath()
\sa closePath()
\sa stroke()
@@ -2232,13 +2381,28 @@ QV4::Value QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::SimpleCallCont
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
}
-// text
+
/*!
- \qmlproperty string QtQuick2::Context2D::font
- Holds the current font settings.
+ \qmlproperty string QtQuick2::Context2D::font
+ Holds the current font settings.
+
+ A subset of the
+ \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+ is supported:
+
+ \list
+ \li font-style (optional):
+ normal | italic | oblique
+ \li font-variant (optional): normal | small-caps
+ \li font-weight (optional): normal | bold | 0 ... 99
+ \li font-size: Npx | Npt (where N is a positive number)
+ \li font-family: See \l {http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family}
+ \endlist
+
+ Note that font-size and font-family are mandatory and must be in the order
+ they are shown in above.
- The default font value is "10px sans-serif".
- See \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+ The default font value is "10px sans-serif".
*/
QV4::Value QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ctx)
{
@@ -2254,7 +2418,7 @@ QV4::Value QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ctx)
CHECK_CONTEXT_SETTER(r)
QString fs = ctx->argument(0).toQString();
- QFont font = qt_font_from_string(fs);
+ QFont font = qt_font_from_string(fs, r->context->state.font);
if (font != r->context->state.font) {
r->context->state.font = font;
}
@@ -2504,7 +2668,7 @@ QV4::Value QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCallContext
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}
*/
/*!
- \qmlmethod QtQuick2::Context2D::drawImage(variant image, real sx, real sy, real sw, sh, real dx, real dy, real dw, dh)
+ \qmlmethod QtQuick2::Context2D::drawImage(variant image, real sx, real sy, real sw, real sh, real dx, real dy, real dw, real dh)
This is an overloaded function.
Draws the given item as \a image from source point (\a sx, \a sy) and source width \a sw, source height \a sh
onto the canvas at point (\a dx, \a dy) and with width \a dw, height \a dh.
@@ -2784,20 +2948,25 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q
}
}
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
- Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
- */
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
+
+ Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
+*/
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
- Creates a CanvasImageData object with the same dimensions as the argument.
- */
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
+
+ Creates a CanvasImageData object with the same dimensions as the argument.
+*/
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
- Creates a CanvasImageData object with the given image loaded from \a imageUrl.
- Note:The \a imageUrl must be already loaded before this function call, if not, an empty
- CanvasImageData obect will be returned.
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
+
+ Creates a CanvasImageData object with the given image loaded from \a imageUrl.
+
+ \note The \a imageUrl must be already loaded before this function call,
+ otherwise an empty CanvasImageData obect will be returned.
- \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(), QtQuick2::Canvas::isImageLoaded
+ \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(),
+ QtQuick2::Canvas::isImageLoaded
*/
QV4::Value QQuickJSContext2DPrototype::method_createImageData(QV4::SimpleCallContext *ctx)
{
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index f09e9bb90e..c7c66d6fdd 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -377,8 +377,6 @@ QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
, m_pauseOffset(0)
{
setFlag(ItemHasContents);
- connect(this, SIGNAL(runningChanged(bool)),
- this, SLOT(update()));
connect(this, SIGNAL(widthChanged()),
this, SLOT(sizeVertices()));
connect(this, SIGNAL(heightChanged()),
@@ -660,7 +658,10 @@ void QQuickAnimatedSprite::prepareNextFrame()
}
if (m_loops > 0 && m_curLoop >= m_loops) {
frameAt = 0;
- m_running = false;
+ if (m_running) {
+ m_running = false;
+ emit runningChanged(false);
+ }
}
} else {
frameAt = m_curFrame;
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 50c5697487..6ee5e6d046 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -147,6 +147,26 @@ Item {
\endqml
*/
+/*!
+ \qmlmethod bool QtQuick2::KeyEvent::matches(StandardKey key)
+ \since QtQuick 2.2
+
+ Returns \c true if the key event matches the given standard \a key; otherwise returns \c false.
+
+ \qml
+ Item {
+ focus: true
+ Keys.onPressed: {
+ if (event.matches(StandardKey.Undo))
+ myModel.undo();
+ else if (event.matches(StandardKey.Redo))
+ myModel.redo();
+ }
+ }
+ \endqml
+
+ \sa QKeySequence::StandardKey
+*/
/*!
\qmltype MouseEvent
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 6f1b152ad3..f14e035857 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -59,6 +59,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qevent.h>
+#include <QtGui/qkeysequence.h>
QT_BEGIN_NAMESPACE
@@ -89,6 +90,8 @@ public:
bool isAccepted() { return event.isAccepted(); }
void setAccepted(bool accepted) { event.setAccepted(accepted); }
+ Q_REVISION(2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const { return event.matches(key); }
+
private:
QKeyEvent event;
};
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index e6b39d5380..75d509129b 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -2384,7 +2384,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;
@@ -2397,7 +2397,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/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index d0417c80f3..ce23b99e8c 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -3068,9 +3068,9 @@ void QQuickItemPrivate::_q_resourceObjectDeleted(QObject *object)
relationship with other items.
Margins apply to top, bottom, left, right, and fill anchors.
- The \c anchors.margins property can be used to set all of the various margins at once, to the same value.
+ The \l anchors.margins property can be used to set all of the various margins at once, to the same value.
It will not override a specific margin that has been previously set; to clear an explicit margin
- set it's value to \c undefined.
+ set its value to \c undefined.
Note that margins are anchor-specific and are not applied if an item does not
use anchors.
@@ -3117,14 +3117,14 @@ void QQuickItemPrivate::_q_resourceObjectDeleted(QObject *object)
\endqml
\endtable
- \c anchors.fill provides a convenient way for one item to have the
+ \l anchors.fill provides a convenient way for one item to have the
same geometry as another item, and is equivalent to connecting all
four directional anchors.
To clear an anchor value, set it to \c undefined.
- \c anchors.alignWhenCentered (default true) forces centered anchors to align to a
- whole pixel, i.e. if the item being centered has an odd width/height the item
+ \l anchors.alignWhenCentered (default \c true) forces centered anchors to align to a
+ whole pixel; if the item being centered has an odd \l width or \l height, the item
will be positioned on a whole pixel rather than being placed on a half-pixel.
This ensures the item is painted crisply. There are cases where this is not
desirable, for example when rotating the item jitters may be apparent as the
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 6ad121fffa..c11f65affd 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -324,7 +324,7 @@ public:
Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
- Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
+ Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
#ifndef QT_NO_IM
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 6b734eab92..7e3d064ca3 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..f0e39c5e5a 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;
}
@@ -2330,6 +2322,7 @@ void QQuickListView::setSnapMode(SnapMode mode)
if (d->snapMode != mode) {
d->snapMode = mode;
emit snapModeChanged();
+ d->fixupPosition();
}
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 37a0c8e407..e7284f870b 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 cf2526e5a7..c34bad5430 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/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 9346236db9..c0794d0d69 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -556,7 +556,6 @@ static void qt_print_material_count()
QSGMaterial::QSGMaterial()
: m_flags(0)
- , m_reserved(0)
{
#ifndef QT_NO_DEBUG
if (qsg_leak_check) {
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 20ab21ad28..ee8889deac 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -133,7 +133,6 @@ public:
void setFlag(Flags flags, bool on = true);
private:
- friend class QSGContext;
Flags m_flags;
void *m_reserved;
Q_DISABLE_COPY(QSGMaterial)
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 866d678412..a142a23c67 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -507,16 +507,10 @@ QSGDepthStencilBufferManager *QSGContext::depthStencilBufferManager()
QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
{
Q_D(QSGContext);
-
- if (material->m_reserved)
- return reinterpret_cast<QSGMaterialShader *>(material->m_reserved);
-
QSGMaterialType *type = material->type();
QSGMaterialShader *shader = d->materials.value(type);
- if (shader) {
- material->m_reserved = shader;
+ if (shader)
return shader;
- }
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing || QQmlProfilerService::enabled)
@@ -524,7 +518,6 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
#endif
shader = material->createShader();
- material->m_reserved = shader;
shader->compile();
shader->initialize();
d->materials[type] = shader;
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..f17aa59e3e 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -222,7 +222,7 @@ static void qt_debug_remove_texture(QSGTexture* texture)
\section1 Texture Atlasses
- Some scene graph backens use texture atlasses, grouping multiple
+ Some scene graph backends use texture atlasses, grouping multiple
small textures into one large texture. If this is the case, the
function isAtlasTexture() will return true. Atlasses are used to
aid the rendering algorithm to do better sorting which increases
@@ -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/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp
index bc8b724a00..2de28a9509 100644
--- a/src/quick/util/qquickapplication.cpp
+++ b/src/quick/util/qquickapplication.cpp
@@ -103,9 +103,15 @@ bool QQuickApplication::eventFilter(QObject *, QEvent *event)
{
Q_D(QQuickApplication);
if ((event->type() == QEvent::ApplicationActivate) ||
- (event->type() == QEvent::ApplicationDeactivate)) {
+ (event->type() == QEvent::ApplicationDeactivate) ||
+ (event->type() == QEvent::ApplicationStateChange)) {
bool wasActive = d->isActive;
- d->isActive = (event->type() == QEvent::ApplicationActivate);
+ if (event->type() == QEvent::ApplicationStateChange) {
+ QApplicationStateChangeEvent * e= static_cast<QApplicationStateChangeEvent*>(event);
+ d->isActive = e->applicationState() == Qt::ApplicationActive;
+ } else {
+ d->isActive = (event->type() == QEvent::ApplicationActivate);
+ }
if (d->isActive != wasActive) {
emit activeChanged();
}
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index a45ec4ef15..fdf8314145 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -58,6 +58,9 @@
#include <private/qquickanimationcontroller_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/QInputMethod>
+#include <QtGui/QKeySequence>
+
+Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void QQuickUtilModule::defineModule()
{
@@ -91,4 +94,7 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickStateOperation>();
qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser);
+
+ qRegisterMetaType<QKeySequence::StandardKey>();
+ qmlRegisterUncreatableType<QKeySequence, 2>("QtQuick", 2, 2, "StandardKey", QStringLiteral("Cannot create an instance of StandardKey."));
}
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 7f9281c70f..b64fc073ba 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -6,6 +6,9 @@ SUBDIRS=\
particles \
qmltest \
qmldevtools \
- cmake
+ cmake \
+ installed_cmake
+
+installed_cmake.depends = cmake
testcocoon: SUBDIRS -= headersclean
diff --git a/tests/auto/installed_cmake/installed_cmake.pro b/tests/auto/installed_cmake/installed_cmake.pro
new file mode 100644
index 0000000000..14d0b283d6
--- /dev/null
+++ b/tests/auto/installed_cmake/installed_cmake.pro
@@ -0,0 +1,4 @@
+include(../cmake/cmake.pro)
+
+CONFIG -= ctest_testcase
+CONFIG += ctest_testcase_installed
diff --git a/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml
index 2a1b4fbf57..53a93621bb 100644
--- a/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml
+++ b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml
@@ -3,12 +3,21 @@ import QtQml 2.0
QtObject {
property string originalName
property string originalVersion
+ property string originalOrganization
+ property string originalDomain
property string currentName: Qt.application.name
property string currentVersion: Qt.application.version
+ property string currentOrganization: Qt.application.organization
+ property string currentDomain: Qt.application.domain
+ property QtObject applicationInstance: Qt.application
Component.onCompleted: {
originalName = Qt.application.name
originalVersion = Qt.application.version
+ originalOrganization = Qt.application.organization
+ originalDomain = Qt.application.domain
Qt.application.name = "Test B"
Qt.application.version = "0.0B"
+ Qt.application.organization = "Org B"
+ Qt.application.domain = "b.org"
}
}
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index 4780ee0310..489972716d 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -132,26 +132,55 @@ void tst_qqmlapplicationengine::applicationProperties()
QCoreApplication* coreApp = QCoreApplication::instance();
QString originalName = coreApp->applicationName();
QString originalVersion = coreApp->applicationVersion();
+ QString originalOrganization = coreApp->organizationName();
+ QString originalDomain = coreApp->organizationDomain();
QString firstName = QLatin1String("Test A");
QString firstVersion = QLatin1String("0.0A");
+ QString firstOrganization = QLatin1String("Org A");
+ QString firstDomain = QLatin1String("a.org");
QString secondName = QLatin1String("Test B");
QString secondVersion = QLatin1String("0.0B");
+ QString secondOrganization = QLatin1String("Org B");
+ QString secondDomain = QLatin1String("b.org");
coreApp->setApplicationName(firstName);
coreApp->setApplicationVersion(firstVersion);
+ coreApp->setOrganizationName(firstOrganization);
+ coreApp->setOrganizationDomain(firstDomain);
QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("applicationTest.qml"));
QObject* root = test->rootObjects().at(0);
QVERIFY(root);
QCOMPARE(root->property("originalName").toString(), firstName);
QCOMPARE(root->property("originalVersion").toString(), firstVersion);
+ QCOMPARE(root->property("originalOrganization").toString(), firstOrganization);
+ QCOMPARE(root->property("originalDomain").toString(), firstDomain);
QCOMPARE(root->property("currentName").toString(), secondName);
QCOMPARE(root->property("currentVersion").toString(), secondVersion);
+ QCOMPARE(root->property("currentOrganization").toString(), secondOrganization);
+ QCOMPARE(root->property("currentDomain").toString(), secondDomain);
QCOMPARE(coreApp->applicationName(), secondName);
QCOMPARE(coreApp->applicationVersion(), secondVersion);
+ QCOMPARE(coreApp->organizationName(), secondOrganization);
+ QCOMPARE(coreApp->organizationDomain(), secondDomain);
+
+ QObject* application = root->property("applicationInstance").value<QObject*>();
+ QVERIFY(application);
+ QSignalSpy nameChanged(application, SIGNAL(nameChanged()));
+ QSignalSpy versionChanged(application, SIGNAL(versionChanged()));
+ QSignalSpy organizationChanged(application, SIGNAL(organizationChanged()));
+ QSignalSpy domainChanged(application, SIGNAL(domainChanged()));
coreApp->setApplicationName(originalName);
coreApp->setApplicationVersion(originalVersion);
+ coreApp->setOrganizationName(originalOrganization);
+ coreApp->setOrganizationDomain(originalDomain);
+
+ QCOMPARE(nameChanged.count(), 1);
+ QCOMPARE(versionChanged.count(), 1);
+ QCOMPARE(organizationChanged.count(), 1);
+ QCOMPARE(domainChanged.count(), 1);
+
delete test;
}
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index b845faca7d..9308bc6f40 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -71,6 +71,7 @@ public slots:
private slots:
void basicProperties();
+ void showFiles();
void resetFiltering();
void refresh();
#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE)
@@ -121,6 +122,7 @@ void tst_qquickfolderlistmodel::basicProperties()
QCOMPARE(flm->property("sortField").toInt(), int(Name));
QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
QCOMPARE(flm->property("sortReversed").toBool(), false);
+ QCOMPARE(flm->property("showFiles").toBool(), true);
QCOMPARE(flm->property("showDirs").toBool(), true);
QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
@@ -131,6 +133,23 @@ void tst_qquickfolderlistmodel::basicProperties()
QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
}
+void tst_qquickfolderlistmodel::showFiles()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ flm->setProperty("folder", dataDirectoryUrl());
+ QTRY_COMPARE(flm->property("count").toInt(), 5); // wait for refresh
+ QCOMPARE(flm->property("showFiles").toBool(), true);
+
+ flm->setProperty("showFiles", false);
+ QCOMPARE(flm->property("showFiles").toBool(), false);
+ QTRY_COMPARE(flm->property("count").toInt(), 1); // wait for refresh
+}
+
void tst_qquickfolderlistmodel::resetFiltering()
{
// see QTBUG-17837
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index 9c5fb88af2..7ef07e4896 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -89,6 +89,7 @@ tst_examples::tst_examples()
// Add files to exclude here
excludedFiles << "examples/quick/canvas/tiger/tiger.qml"; // QTBUG-26528
excludedFiles << "snippets/qml/listmodel/listmodel.qml"; //Just a ListModel, no root QQuickItem
+ excludedFiles << "examples/quick/demos/photosurface/photosurface.qml"; // root item is Window rather than Item
// Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/)
excludedDirs << "shared"; //Not an example
diff --git a/tests/auto/quick/qquickanimatedsprite/data/runningChange.qml b/tests/auto/quick/qquickanimatedsprite/data/runningChange.qml
new file mode 100644
index 0000000000..9994ff6d9b
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/data/runningChange.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Tasuku Suzuki <stasuku@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ AnimatedSprite {
+ objectName: "sprite"
+ source: "squarefacesprite.png"
+ frameCount: 6
+ loops: 3
+ frameSync: true
+ running: false
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index bf46b6eca8..6422e0b656 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -53,6 +53,7 @@ public:
private slots:
void initTestCase();
void test_properties();
+ void test_runningChangedSignal();
void test_frameChangedSignal();
};
@@ -87,6 +88,29 @@ void tst_qquickanimatedsprite::test_properties()
delete window;
}
+void tst_qquickanimatedsprite::test_runningChangedSignal()
+{
+ QQuickView *window = new QQuickView(0);
+
+ window->setSource(testFileUrl("runningChange.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QVERIFY(window->rootObject());
+ QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(!sprite->running());
+
+ QSignalSpy runningChangedSpy(sprite, SIGNAL(runningChanged(bool)));
+ sprite->setRunning(true);
+ QTRY_COMPARE(runningChangedSpy.count(), 1);
+ QTRY_VERIFY(!sprite->running());
+ QTRY_COMPARE(runningChangedSpy.count(), 2);
+
+ delete window;
+}
+
void tst_qquickanimatedsprite::test_frameChangedSignal()
{
QQuickView *window = new QQuickView(0);
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
index ad44f6d28e..ab351f0de8 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
@@ -71,6 +71,7 @@ Canvas {
}
}
+ // See: http://www.w3.org/TR/css3-fonts/#font-prop
TestCase {
name: "ContextFontValidation"
when: canvas.available
@@ -82,8 +83,82 @@ Canvas {
var ctx = canvas.getContext("2d");
compare(ctx.font, "sans-serif,-1,10,5,50,0,0,0,0,0");
- ctx.font = "80.1px sans-serif";
- compare(ctx.font, "sans-serif,-1,80,5,50,0,0,0,0,0");
+ ctx.font = "80.1px cursive";
+ // Can't verify the chosen font family since it's different for each platform.
+ compare(ctx.font.substr(ctx.font.indexOf(",") + 1), "-1,80,5,50,0,0,0,0,0");
+ }
+
+ function test_valid() {
+ wait(100);
+ compare(contextSpy.count, 1);
+
+ var ctx = canvas.getContext("2d");
+
+ var validFonts = [
+ { string: "12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" },
+ { string: "12px serif", expected: "serif,-1,12,5,50,0,0,0,0,0" },
+ { string: "12pt sans-serif", expected: "sans-serif,12,-1,5,50,0,0,0,0,0" },
+ { string: "12pt serif", expected: "serif,12,-1,5,50,0,0,0,0,0" },
+ { string: "normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" },
+ { string: "normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" },
+ { string: "normal normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" },
+ { string: "italic 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" },
+ { string: "italic normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" },
+ { string: "italic normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" },
+ { string: "oblique 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" },
+ { string: "oblique normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" },
+ { string: "oblique normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" },
+ { string: "bold 12px sans-serif", expected: "sans-serif,-1,12,5,75,0,0,0,0,0" },
+ { string: "0 12px sans-serif", expected: "sans-serif,-1,12,5,0,0,0,0,0,0" },
+ { string: "small-caps 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" },
+ ];
+ for (var i = 0; i < validFonts.length; ++i) {
+ ctx.font = validFonts[i].string;
+ compare(ctx.font.substr(ctx.font.indexOf(",") + 1),
+ validFonts[i].expected.substr(validFonts[i].expected.indexOf(",") + 1));
+ }
+ }
+
+ function test_invalid() {
+ wait(100);
+ compare(contextSpy.count, 1);
+
+ var ctx = canvas.getContext("2d");
+ var originalFont = ctx.font;
+ var i = 0;
+
+ var insufficientQtyTokens = ["", "12px", "sans-serif"];
+ for (i = 0; i < insufficientQtyTokens.length; ++i) {
+ ignoreWarning("Context2D: Insufficent amount of tokens in font string.");
+ ctx.font = insufficientQtyTokens[i];
+ compare(ctx.font, originalFont);
+ }
+
+ var invalidFontSizes = ["z12px sans-serif", "1z2px sans-serif", "12zpx sans-serif",
+ "12pzx sans-serif", "12pxz sans-serif", "sans-serif 12px"];
+ for (i = 0; i < invalidFontSizes.length; ++i) {
+ ignoreWarning("Context2D: A font size of \"" + invalidFontSizes[i].split(" ")[0] + "\" is invalid.");
+ ctx.font = invalidFontSizes[i];
+ compare(ctx.font, originalFont);
+ }
+
+ var invalidFontFamilies = ["12px !@weeeeeeee!@!@Don'tNameYourFontThis", "12px )(&*^^^%#$@*!!@#$JSPOR)"];
+ for (i = 0; i < invalidFontFamilies.length; ++i) {
+ ignoreWarning("Context2D: The font family \"" + invalidFontFamilies[i].split(" ")[1] + "\" is invalid.");
+ ctx.font = invalidFontFamilies[i];
+ compare(ctx.font, originalFont);
+ }
+
+ var duplicates = [
+ { duplicate: "normal", string: "normal normal normal normal 12px sans-serif" },
+ { duplicate: "bold", string: "normal normal bold bold 12px sans-serif" },
+ { duplicate: "bold", string: "bold bold 12px sans-serif" }
+ ];
+ for (i = 0; i < duplicates.length; ++i) {
+ ignoreWarning("Context2D: Duplicate token \"" + duplicates[i].duplicate + "\" found in font string.");
+ ctx.font = duplicates[i].string;
+ compare(ctx.font, originalFont);
+ }
}
}
}
diff --git a/tests/auto/quick/qquickitem2/data/standardkeys.qml b/tests/auto/quick/qquickitem2/data/standardkeys.qml
new file mode 100644
index 0000000000..c29a143c28
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/standardkeys.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Item {
+ focus: true
+
+ property bool pressed: false
+ property bool released: false
+
+ Keys.onPressed: {
+ pressed = event.matches(standardKey)
+ }
+
+ Keys.onReleased: {
+ released = event.matches(standardKey)
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 992e81aa64..d15a46feca 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -78,6 +78,8 @@ private slots:
void nextItemInFocusChain2();
void keys();
+ void standardKeys_data();
+ void standardKeys();
void keysProcessingOrder();
void keysim();
void keyNavigation();
@@ -1089,6 +1091,64 @@ void tst_QQuickItem::keys()
delete testObject;
}
+Q_DECLARE_METATYPE(QEvent::Type);
+Q_DECLARE_METATYPE(QKeySequence::StandardKey);
+
+void tst_QQuickItem::standardKeys_data()
+{
+ QTest::addColumn<QKeySequence::StandardKey>("standardKey");
+ QTest::addColumn<QKeySequence::StandardKey>("contextProperty");
+ QTest::addColumn<QEvent::Type>("eventType");
+ QTest::addColumn<bool>("pressed");
+ QTest::addColumn<bool>("released");
+
+ QTest::newRow("Press: Open") << QKeySequence::Open << QKeySequence::Open << QEvent::KeyPress << true << false;
+ QTest::newRow("Press: Close") << QKeySequence::Close << QKeySequence::Close << QEvent::KeyPress << true << false;
+ QTest::newRow("Press: Save") << QKeySequence::Save << QKeySequence::Save << QEvent::KeyPress << true << false;
+ QTest::newRow("Press: Quit") << QKeySequence::Quit << QKeySequence::Quit << QEvent::KeyPress << true << false;
+
+ QTest::newRow("Release: New") << QKeySequence::New << QKeySequence::New << QEvent::KeyRelease << false << true;
+ QTest::newRow("Release: Delete") << QKeySequence::Delete << QKeySequence::Delete << QEvent::KeyRelease << false << true;
+ QTest::newRow("Release: Undo") << QKeySequence::Undo << QKeySequence::Undo << QEvent::KeyRelease << false << true;
+ QTest::newRow("Release: Redo") << QKeySequence::Redo << QKeySequence::Redo << QEvent::KeyRelease << false << true;
+
+ QTest::newRow("Mismatch: Cut") << QKeySequence::Cut << QKeySequence::Copy << QEvent::KeyPress << false << false;
+ QTest::newRow("Mismatch: Copy") << QKeySequence::Copy << QKeySequence::Paste << QEvent::KeyPress << false << false;
+ QTest::newRow("Mismatch: Paste") << QKeySequence::Paste << QKeySequence::Cut << QEvent::KeyRelease << false << false;
+ QTest::newRow("Mismatch: Quit") << QKeySequence::Quit << QKeySequence::New << QEvent::KeyRelease << false << false;
+}
+
+void tst_QQuickItem::standardKeys()
+{
+ QFETCH(QKeySequence::StandardKey, standardKey);
+ QFETCH(QKeySequence::StandardKey, contextProperty);
+ QFETCH(QEvent::Type, eventType);
+ QFETCH(bool, pressed);
+ QFETCH(bool, released);
+
+ QKeySequence keySequence(standardKey);
+ if (keySequence.isEmpty())
+ QSKIP("Undefined key sequence.");
+
+ QQuickView view;
+ view.rootContext()->setContextProperty("standardKey", contextProperty);
+ view.setSource(testFileUrl("standardkeys.qml"));
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(item);
+
+ const int key = keySequence[0] & Qt::Key_unknown;
+ const int modifiers = keySequence[0] & Qt::KeyboardModifierMask;
+ QKeyEvent keyEvent(eventType, key, static_cast<Qt::KeyboardModifiers>(modifiers));
+ QGuiApplication::sendEvent(&view, &keyEvent);
+
+ QCOMPARE(item->property("pressed").toBool(), pressed);
+ QCOMPARE(item->property("released").toBool(), released);
+}
+
void tst_QQuickItem::keysProcessingOrder()
{
QQuickView *window = new QQuickView(0);
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
diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
index c625080d7c..f6a046e622 100644
--- a/tests/auto/quick/qquickpositioners/qquickpositioners.pro
+++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
@@ -9,6 +9,5 @@ macx:CONFIG -= app_bundle
TESTDATA = data/*
-CONFIG += parallel_test
QT += testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
index 7b0e0c2878..d9aff688ab 100644
--- a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
+++ b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
@@ -9,8 +9,6 @@ include (../shared/util.pri)
TESTDATA = data/*
-CONFIG += parallel_test
-
-QT += core-private gui-private qml-private quick-private testlib
+QT += core-private gui-private qml-private quick-private testlib
qtHaveModule(widgets): QT += widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.qml b/tests/auto/quick/qquickxmllistmodel/data/groups.qml
new file mode 100644
index 0000000000..c1b574a822
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/data/groups.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ source: "groups.xml"
+ query: "//animal[@name='Garfield']/parent::group"
+
+ XmlRole { name: "id"; query: "@id/string()" }
+ XmlRole { name: "name"; query: "@name/string()" }
+}
diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.xml b/tests/auto/quick/qquickxmllistmodel/data/groups.xml
new file mode 100644
index 0000000000..5de4d2ec71
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/data/groups.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<groups version="2.0">
+ <group id="1" name="Animals" type="root">
+ <group id="11" name="dogs">
+ <animal id="111" name="Lassie"/>
+ <animal id="112" name="Laika"/>
+ <animal id="113" name="Wile E. Coyote" type="fictional"/>
+ </group>
+ <group id="12" name="cats">
+ <animal id="121" name="Garfield" type="fictional"/>
+ <animal id="122" name="Sylvester" type="fictional"/>
+ </group>
+ <group id="13" name="birds">
+ <animal id="131" name="Donald Duck" type="fictional"/>
+ <animal id="132" name="Phoenix" type="fictional"/>
+ </group>
+ </group>
+</groups>
diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
index da899a12ec..574481c456 100644
--- a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
+++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
@@ -12,3 +12,6 @@ CONFIG += parallel_test
QT += core-private gui-private qml-private network testlib xmlpatterns
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+OTHER_FILES += \
+ data/groups.qml
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
index 847cc5078d..1f7a8029dc 100644
--- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -101,6 +101,7 @@ private slots:
void threading();
void threading_data();
void propertyChanges();
+ void selectAncestor();
void roleCrash();
@@ -964,6 +965,18 @@ void tst_qquickxmllistmodel::propertyChanges()
delete model;
}
+void tst_qquickxmllistmodel::selectAncestor()
+{
+ QQmlComponent component(&engine, testFileUrl("groups.qml"));
+ QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->rowCount(), 1);
+
+ QModelIndex index = model->index(0, 0);
+ QCOMPARE(model->data(index, Qt::UserRole).toInt(), 12);
+ QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("cats"));
+}
+
void tst_qquickxmllistmodel::roleCrash()
{
// don't crash
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 81d4fd3348..d0f8c401d6 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -69,7 +69,8 @@ QUICKTESTS = \
qquickcanvasitem \
qquickscreen \
touchmouse \
- dialogs \
+# disabled to allow file dialog changes to use urls internally (qtbase)
+# dialogs \
SUBDIRS += $$PUBLICTESTS
diff --git a/tests/auto/quick/touchmouse/touchmouse.pro b/tests/auto/quick/touchmouse/touchmouse.pro
index e21695904e..e7c50e6f54 100644
--- a/tests/auto/quick/touchmouse/touchmouse.pro
+++ b/tests/auto/quick/touchmouse/touchmouse.pro
@@ -13,8 +13,6 @@ TESTDATA = data/*
# OTHER_FILES += data/foo.qml
-CONFIG += parallel_test
-
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
mac:CONFIG+=insignificant_test # QTBUG-27890
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 8a48445d63..244e0af4ac 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -44,6 +44,8 @@
#include <QtCore/qdir.h>
#include <QtCore/qmath.h>
#include <QtCore/qdatetime.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/QGuiApplication>
@@ -461,7 +463,7 @@ int main(int argc, char ** argv)
// TODO: as soon as the engine construction completes, the debug service is
// listening for connections. But actually we aren't ready to debug anything.
QQmlEngine engine;
- QQmlComponent *component = new QQmlComponent(&engine);
+ QPointer<QQmlComponent> component = new QQmlComponent(&engine);
for (int i = 0; i < imports.size(); ++i)
engine.addImportPath(imports.at(i));
for (int i = 0; i < bundles.size(); ++i)
@@ -481,15 +483,14 @@ int main(int argc, char ** argv)
}
QObject *topLevel = component->create();
- QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
- QQuickView* qxView = 0;
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(topLevel));
if (window) {
engine.setIncubationController(window->incubationController());
} else {
QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel);
if (contentItem) {
- qxView = new QQuickView(&engine, NULL);
- window = qxView;
+ QQuickView* qxView = new QQuickView(&engine, NULL);
+ window.reset(qxView);
// Set window default properties; the qml can still override them
QString oname = contentItem->objectName();
window->setTitle(oname.isEmpty() ? QString::fromLatin1("qmlscene") : QString::fromLatin1("qmlscene: ") + oname);
@@ -534,14 +535,10 @@ int main(int argc, char ** argv)
#ifdef QML_RUNTIME_TESTING
RenderStatistics::printTotalStats();
#endif
- // Ready to exit. If we created qxView, it owns the component;
- // otherwise, the ownership is still right here. Nobody deletes the engine
- // (which is odd since the container constructor takes the engine pointer),
- // but it's stack-allocated anyway.
- if (qxView)
- delete qxView;
- else
- delete component;
+ // Ready to exit. Notice that the component might be owned by
+ // QQuickView if one was created. That case is tracked by
+ // QPointer, so it is safe to delete the component here.
+ delete component;
}
}