summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-26 08:26:29 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-26 08:26:29 (GMT)
commit39b861b75566c4db0db3b5aba2aa191a59f10bdb (patch)
tree4acede8c724bb5a20ef523ff9c2efe2917e08bfd
parent7120119af835c139b8808e7dcdeec3eb11b0b36d (diff)
parent124efaa694316a4e02684fde151395d8e1d28b7a (diff)
downloadQt-39b861b75566c4db0db3b5aba2aa191a59f10bdb.zip
Qt-39b861b75566c4db0db3b5aba2aa191a59f10bdb.tar.gz
Qt-39b861b75566c4db0db3b5aba2aa191a59f10bdb.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Doc fixes, improvements Allow js files with '.pragma library' to be used from WorkerScript Add more examples of XPath expressions to XmlRole. Open input panel on press if TextInput or TextEdit are already focused but panel has been closed Fix horizontal/verticalCenter anchors bug. Fix TextEdit clipping when not wrapped. Rename most-useful-wrap-mode to "Wrap". Fix for qml reloaded in qml viewer not being maximized properly on a device Unify naming of import plugin targets Add a way to control when software input panels are shown in TextInput and TextEdit elements Replace QTime with QElapsedTimer Fix Gradient doc snippet.
-rw-r--r--demos/declarative/minehunt/MinehuntCore/qmldir2
-rw-r--r--demos/declarative/minehunt/minehunt.pro6
-rw-r--r--demos/declarative/twitter/TwitterCore/HomeTitleBar.qml2
-rw-r--r--doc/src/declarative/advtutorial.qdoc4
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc14
-rw-r--r--doc/src/declarative/examples.qdoc23
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc4
-rw-r--r--doc/src/snippets/declarative/gradient.qml2
-rw-r--r--doc/src/snippets/declarative/texteditor.qml8
-rw-r--r--doc/src/snippets/declarative/xmlrole.qml81
-rw-r--r--doc/src/snippets/declarative/xmlrole.xml14
-rw-r--r--examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir2
-rw-r--r--examples/declarative/cppextensions/imageprovider/imageprovider.pro9
-rw-r--r--examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir2
-rw-r--r--examples/declarative/cppextensions/plugins/plugin.cpp2
-rw-r--r--examples/declarative/cppextensions/plugins/plugins.pro2
-rw-r--r--examples/declarative/cppextensions/qwidgets/QWidgets/qmldir2
-rw-r--r--examples/declarative/cppextensions/qwidgets/qwidgets.cpp2
-rw-r--r--examples/declarative/cppextensions/qwidgets/qwidgets.pro10
-rw-r--r--examples/declarative/ui-components/dialcontrol/dialcontrol.qmlproject (renamed from examples/declarative/ui-components/dialcontrol/dial.qmlproject)0
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp34
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp17
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp37
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h9
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp181
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h19
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp136
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp102
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp1
-rw-r--r--src/declarative/util/qdeclarativeview.cpp4
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp33
-rw-r--r--src/imports/gestures/gestures.pro4
-rw-r--r--src/imports/gestures/plugin.cpp2
-rw-r--r--src/imports/gestures/qmldir2
-rw-r--r--src/imports/particles/particles.cpp2
-rw-r--r--src/imports/particles/particles.pro4
-rw-r--r--src/imports/particles/qmldir2
-rw-r--r--src/imports/webkit/plugin.cpp2
-rw-r--r--src/imports/webkit/qmldir2
-rw-r--r--src/imports/webkit/webkit.pro4
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp14
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp94
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp95
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml24
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script.js1
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js4
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml21
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp43
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml2
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml2
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml2
-rw-r--r--tools/qml/qmlruntime.cpp4
62 files changed, 900 insertions, 250 deletions
diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir
index 95bccc8..2beccf9 100644
--- a/demos/declarative/minehunt/MinehuntCore/qmldir
+++ b/demos/declarative/minehunt/MinehuntCore/qmldir
@@ -1,3 +1,3 @@
-plugin minehunt
+plugin qmlminehuntplugin
Explosion 1.0 Explosion.qml
Tile 1.0 Tile.qml
diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro
index 41640f5..91d02cf 100644
--- a/demos/declarative/minehunt/minehunt.pro
+++ b/demos/declarative/minehunt/minehunt.pro
@@ -1,5 +1,5 @@
TEMPLATE = lib
-TARGET = minehunt
+TARGET = qmlminehuntplugin
QT += declarative
CONFIG += qt plugin
@@ -28,11 +28,11 @@ symbian:{
TARGET.EPOCALLOWDLLDATA = 1
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
TARGET.CAPABILITY = NetworkServices ReadUserData
- importFiles.sources = minehunt.dll \
+ importFiles.sources = qmlminehuntplugin.dll \
MinehuntCore/Explosion.qml \
MinehuntCore/pics \
MinehuntCore/qmldir
- importFiles.path = $$QT_IMPORTS_BASE_DIR/MinehuntCore
+ importFiles.path = MinehuntCore
DEPLOYMENT = importFiles
}
diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
index 2eaa40c..3828a40 100644
--- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
@@ -129,7 +129,7 @@ Item {
width: parent.width - 12
height: parent.height - 8
font.pointSize: 10
- wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
+ wrapMode: TextEdit.Wrap
color: "#151515"; selectionColor: "green"
}
Keys.forwardTo: [(returnKey), (editor)]
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 47504ae..abfeadb 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -178,7 +178,7 @@ The \c createBlock() function creates a block from the \c Block.qml file
and moves the new block to its position on the game canvas. This involves several steps:
\list
-\o \l {Qt.createComponent(url file)}{Qt.createComponent()} is called to generate an element from \c Block.qml.
+\o \l {Qt::createComponent()}{Qt.createComponent()} is called to generate an element from \c Block.qml.
If the component is ready, we can call \c createObject() to create an instance of the \c Block item.
\o If \c createObject() returned null (i.e. if there was an error while
loading the object), print the error information.
@@ -468,6 +468,6 @@ By following this tutorial you've seen how you can write a fully functional appl
\endlist
There is so much more to learn about QML that we haven't been able to cover in this tutorial. Check out all the
-demos and examples and the \l {Declarative UI Using QML}{documentation} to find out all the things you can do with QML!
+demos and examples and the \l {Qt Quick}{documentation} to find out all the things you can do with QML!
*/
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index 633489b..5e606f4 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -56,15 +56,15 @@ application, and there are no C++ components involved.
\section1 Creating Objects Dynamically
There are two ways to create objects dynamically from JavaScript. You can either call
-\l {Qt.createComponent(url file)}{Qt.createComponent()} to create
-a component which instantiates items, or use \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()}
+\l {Qt::createComponent()}{Qt.createComponent()} to create
+a component which instantiates items, or use \l{Qt::createQmlObject()}{Qt.createQmlObject()}
to create an item from a string of QML.
Creating a component is better if you have a predefined
item, and you want to create dynamic instances of that item; creating an item from
a string of QML is useful when the item QML itself is generated at runtime.
If you have a component specified in a QML file, you can dynamically load it with
-the \l {Qt.createComponent(url file)}{Qt.createComponent()} function on the \l{QML Global Object}.
+the \l {Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}.
This function takes the URL of the QML file as its only argument and returns
a component object which can be used to create and load that QML file.
@@ -98,10 +98,10 @@ in \c main.qml). After creating an item, you must set its parent to an item with
Otherwise your dynamically created item will not appear in the scene.
When using files with relative paths, the path should
-be relative to the file where \l {Qt.createComponent(url file)}{Qt.createComponent()} is executed.
+be relative to the file where \l {Qt::createComponent()}{Qt.createComponent()} is executed.
If the QML component does not exist until runtime, you can create a QML item from
-a string of QML using the \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} function, as in the following example:
+a string of QML using the \l{Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example:
\snippet doc/src/snippets/declarative/createQmlObject.qml 0
@@ -121,9 +121,9 @@ the bindings in the dynamic item will no longer work.
The actual creation context depends on how an item is created:
\list
-\o If \l {Qt.createComponent(url file)}{Qt.createComponent()} is used, the creation context
+\o If \l {Qt::createComponent()}{Qt.createComponent()} is used, the creation context
is the QDeclarativeContext in which this method is called
-\o If \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()}
+\o If \l{Qt::createQmlObject()}{Qt.createQmlObject()}
if called, it is the context of the item used as the second argument to this method
\o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()}
is called on that item, it is the context in which the \c Component is defined
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 6e0426c..5cb83fa 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -84,7 +84,10 @@ For example, from your build directory, run:
\o \l{declarative/imageelements/borderimage}{BorderImage}
\endlist
-\section2 \l{declarative/positioners}{Positioners}
+\section2 Positioners
+\list
+\o \l{declarative/positioners}{Example}
+\endlist
\section2 Key Interaction
\list
@@ -99,6 +102,7 @@ For example, from your build directory, run:
\section2 UI Components
\list
+\o \l{declarative/ui-components/dialcontrol}{Dial control}
\o \l{declarative/ui-components/flipable}{Flipable}
\o \l{declarative/ui-components/progressbar}{Progress bar}
\o \l{declarative/ui-components/scrollbar}{Scroll bar}
@@ -112,10 +116,10 @@ For example, from your build directory, run:
\list
\o \l{declarative/modelviews/gridview}{GridView}
\o \l{declarative/modelviews/listview}{ListView}
-\o \l{declarative/modelviews/objectlistmodel}{Object list model}
+\o \l{declarative/modelviews/objectlistmodel}{Object ListModel}
\o \l{declarative/modelviews/package}{Package}
\o \l{declarative/modelviews/parallax}{Parallax}
-\o \l{declarative/modelviews/stringlistmodel}{String list model}
+\o \l{declarative/modelviews/stringlistmodel}{String ListModel}
\o \l{declarative/modelviews/webview}{WebView}
\endlist
@@ -124,7 +128,10 @@ For example, from your build directory, run:
\o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest}
\endlist
-\section2 \l{declarative/i18n}{Internationalization (i18n)}
+\section2 Internationalization (i18n)
+\list
+\o \l{declarative/i18n}{Example}
+\endlist
\section2 Threading
\list
@@ -132,11 +139,14 @@ For example, from your build directory, run:
\o \l{declarative/threading/workerscript}{WorkerScript}
\endlist
-\section2 \l{declarative/sqllocalstorage}{SQL Local Storage}
+\section2 SQL Local Storage
+\list
+\o \l{declarative/sqllocalstorage}{Example}
+\endlist
\section2 C++ Extensions
\list
-\o \l{declarative-cppextensions-reference.html}{Reference examples} (discussed in \l {Extending QML in C++})
+\o \l{declarative-cppextensions-reference.html}{Reference examples}
\o \l{declarative/cppextensions/plugins}{Plugins}
\o \l{declarative-cppextensions-qgraphicslayouts.html}{QGraphicsLayouts}
\o \l{declarative/cppextensions/qwidgets}{QWidgets}
@@ -148,7 +158,6 @@ For example, from your build directory, run:
\list
\o \l{declarative/toys/clocks}{Clocks}
\o \l{declarative/toys/corkboards}{Corkboards}
-\o \l{declarative/toys/dial}{Dial}
\o \l{declarative/toys/dynamicscene}{Dynamic Scene}
\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe}
\o \l{declarative/toys/tvtennis}{TV Tennis}
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 2885dd5..3a2ad81 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -49,7 +49,7 @@ Contains all the properties of the JavaScript global object, plus:
\section1 Qt Object
-The \l{qt-qml.html}{Qt object} provides useful enums and functions from Qt, for use in all QML
+The \l{qml-qt.html}{Qt object} provides useful enums and functions from Qt, for use in all QML
files.
\section1 XMLHttpRequest
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index c47ab23..f7cb722 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -112,7 +112,7 @@
Returns the QML type id.
- \sa qmlRegisterTypeNotAvailable
+ \sa qmlRegisterTypeNotAvailable()
*/
/*!
@@ -147,7 +147,7 @@ fun.qml: Get back to work, slacker!
Without this, a generic "Game is not a type" message would be given.
- \sa qmlRegisterUncreatableType
+ \sa qmlRegisterUncreatableType()
*/
/*!
diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/declarative/gradient.qml
index d25352b..7a68233 100644
--- a/doc/src/snippets/declarative/gradient.qml
+++ b/doc/src/snippets/declarative/gradient.qml
@@ -41,6 +41,7 @@
import Qt 4.7
+//![code]
Rectangle {
width: 100; height: 100
gradient: Gradient {
@@ -49,3 +50,4 @@ Rectangle {
GradientStop { position: 1.0; color: "green" }
}
}
+//![code]
diff --git a/doc/src/snippets/declarative/texteditor.qml b/doc/src/snippets/declarative/texteditor.qml
index 0bd79b5..6735c6c 100644
--- a/doc/src/snippets/declarative/texteditor.qml
+++ b/doc/src/snippets/declarative/texteditor.qml
@@ -45,7 +45,8 @@ Flickable {
id: flick
width: 300; height: 200;
- contentHeight: edit.height
+ contentWidth: edit.paintedWidth
+ contentHeight: edit.paintedHeight
clip: true
function ensureVisible(r)
@@ -62,9 +63,10 @@ Flickable {
TextEdit {
id: edit
- width: parent.width
+ width: flick.width
+ height: flick.height
focus: true
- wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
+ wrapMode: TextEdit.Wrap
onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
}
}
diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/declarative/xmlrole.qml
new file mode 100644
index 0000000..6d04daf
--- /dev/null
+++ b/doc/src/snippets/declarative/xmlrole.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+Rectangle {
+ width: 300; height: 200
+
+//![0]
+XmlListModel {
+ id: model
+//![0]
+ source: "xmlrole.xml"
+
+//![1]
+ // XmlRole queries will be made on <book> elements
+ query: "/catalogue/book"
+
+ // query the book title
+ XmlRole { name: "title"; query: "title/string()" }
+
+ // query the book's year
+ XmlRole { name: "year"; query: "year/number()" }
+
+ // query the book's type (the '@' indicates 'type' is an attribute, not an element)
+ XmlRole { name: "type"; query: "@type/string()" }
+
+ // query the book's first listed author (note in XPath the first index is 1, not 0)
+ XmlRole { name: "first_author"; query: "author[1]/string()" }
+}
+//![1]
+
+ListView {
+ width: 300; height: 200
+ model: model
+ delegate: Column {
+ Text { text: title + " (" + type + ")"; font.bold: true }
+ Text { text: first_author }
+ Text { text: year }
+ }
+}
+
+}
diff --git a/doc/src/snippets/declarative/xmlrole.xml b/doc/src/snippets/declarative/xmlrole.xml
new file mode 100644
index 0000000..c9f999e
--- /dev/null
+++ b/doc/src/snippets/declarative/xmlrole.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<catalogue>
+ <book type="Hardcover">
+ <title>C++ GUI Programming with Qt 4</title>
+ <year>2006</year>
+ <author>Jasmin Blanchette</author>
+ <author>Mark Summerfield</author>
+ </book>
+ <book type="Paperback">
+ <title>Programming with Qt</title>
+ <year>2002</year>
+ <author>Matthias Kalle Dalheimer</author>
+ </book>
+ </catalogue>
diff --git a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir
index 1028590..6be88bc 100644
--- a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir
+++ b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir
@@ -1,2 +1,2 @@
-plugin imageprovider
+plugin qmlimageproviderplugin
diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro
index 462f7d9d..f218c30 100644
--- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro
+++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro
@@ -3,7 +3,7 @@ CONFIG += qt plugin
QT += declarative
DESTDIR = ImageProviderCore
-TARGET = imageprovider
+TARGET = qmlimageproviderplugin
SOURCES += imageprovider.cpp
@@ -18,7 +18,12 @@ ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovid
INSTALLS = sources ImageProviderCore_sources target
-symbian {
+symbian:{
+ load(data_caging_paths)
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
TARGET.EPOCALLOWDLLDATA = 1
+
+ importFiles.sources = qmlimageproviderplugin.dll ImageProviderCore/qmldir
+ importFiles.path = ImageProviderCore
+ DEPLOYMENT = importFiles
}
diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir
index e9ef115..e1288cf 100644
--- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir
+++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir
@@ -1,2 +1,2 @@
Clock 1.0 Clock.qml
-plugin qtimeexampleqmlplugin
+plugin qmlqtimeexampleplugin
diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp
index 2b1b320..355ca3f 100644
--- a/examples/declarative/cppextensions/plugins/plugin.cpp
+++ b/examples/declarative/cppextensions/plugins/plugin.cpp
@@ -148,4 +148,4 @@ public:
#include "plugin.moc"
-Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin);
+Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin);
diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro
index d37ff40..b7610a8 100644
--- a/examples/declarative/cppextensions/plugins/plugins.pro
+++ b/examples/declarative/cppextensions/plugins/plugins.pro
@@ -3,7 +3,7 @@ CONFIG += qt plugin
QT += declarative
DESTDIR = com/nokia/TimeExample
-TARGET = qtimeexampleqmlplugin
+TARGET = qmlqtimeexampleplugin
SOURCES += plugin.cpp
diff --git a/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir
index e55267c..a7c1d95 100644
--- a/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir
+++ b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir
@@ -1 +1 @@
-plugin proxywidgetsplugin
+plugin qmlqwidgetsplugin
diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.cpp b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp
index 228f9f1..47d3932 100644
--- a/examples/declarative/cppextensions/qwidgets/qwidgets.cpp
+++ b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp
@@ -94,4 +94,4 @@ public:
#include "qwidgets.moc"
-Q_EXPORT_PLUGIN2(qwidgetsplugin, QWidgetsPlugin);
+Q_EXPORT_PLUGIN2(qmlqwidgetsplugin, QWidgetsPlugin);
diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.pro b/examples/declarative/cppextensions/qwidgets/qwidgets.pro
index c5f8bcf..8d87804 100644
--- a/examples/declarative/cppextensions/qwidgets/qwidgets.pro
+++ b/examples/declarative/cppextensions/qwidgets/qwidgets.pro
@@ -3,7 +3,7 @@ CONFIG += qt plugin
QT += declarative
DESTDIR = QWidgets
-TARGET = qwidgetsplugin
+TARGET = qmlqwidgetsplugin
SOURCES += qwidgets.cpp
@@ -13,7 +13,13 @@ target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
INSTALLS += sources target
-symbian {
+symbian:{
+ load(data_caging_paths)
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
TARGET.EPOCALLOWDLLDATA = 1
+
+ importFiles.sources = qmlqwidgetsplugin.dll QWidgets/qmldir
+ importFiles.path = QWidgets
+
+ DEPLOYMENT = importFiles
}
diff --git a/examples/declarative/ui-components/dialcontrol/dial.qmlproject b/examples/declarative/ui-components/dialcontrol/dialcontrol.qmlproject
index d4909f8..d4909f8 100644
--- a/examples/declarative/ui-components/dialcontrol/dial.qmlproject
+++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qmlproject
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index ef07cbb..aa53aba 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -92,17 +92,17 @@ static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine
//position when origin is 0,0
static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
{
- int ret = 0;
+ qreal ret = 0.0;
QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item);
switch(anchorLine) {
case QDeclarativeAnchorLine::Left:
- ret = 0;
+ ret = 0.0;
break;
case QDeclarativeAnchorLine::Right:
ret = d->width();
break;
case QDeclarativeAnchorLine::Top:
- ret = 0;
+ ret = 0.0;
break;
case QDeclarativeAnchorLine::Bottom:
ret = d->height();
@@ -459,10 +459,10 @@ void QDeclarativeAnchors::resetCenterIn()
bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1,
const QDeclarativeAnchorLine &edge2,
- int offset1,
- int offset2,
+ qreal offset1,
+ qreal offset2,
QDeclarativeAnchorLine::AnchorLine line,
- int &stretch)
+ qreal &stretch)
{
bool edge1IsParent = (edge1.item == item->parentItem());
bool edge2IsParent = (edge2.item == item->parentItem());
@@ -471,15 +471,15 @@ bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1
bool invalid = false;
if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) {
- stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(edge1.item, edge1.anchorLine) + offset1);
+ stretch = (position(edge2.item, edge2.anchorLine) + offset2)
+ - (position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsParent && edge1IsSibling) {
- stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(item->parentObject(), line)
- + (int)position(edge1.item, edge1.anchorLine) + offset1);
+ stretch = (position(edge2.item, edge2.anchorLine) + offset2)
+ - (position(item->parentObject(), line)
+ + position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsSibling && edge1IsParent) {
- stretch = ((int)position(item->parentObject(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(edge1.item, edge1.anchorLine) + offset1);
+ stretch = (position(item->parentObject(), line) + position(edge2.item, edge2.anchorLine) + offset2)
+ - (position(edge1.item, edge1.anchorLine) + offset1);
} else
invalid = true;
@@ -497,7 +497,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
if (usedAnchors & QDeclarativeAnchors::TopAnchor) {
//Handle stretching
bool invalid = true;
- int height = 0;
+ qreal height = 0.0;
if (usedAnchors & QDeclarativeAnchors::BottomAnchor) {
invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarativeAnchorLine::Top, height);
} else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
@@ -516,7 +516,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
} else if (usedAnchors & QDeclarativeAnchors::BottomAnchor) {
//Handle stretching (top + bottom case is handled above)
if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
- int height = 0;
+ qreal height = 0.0;
bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin,
QDeclarativeAnchorLine::Top, height);
if (!invalid)
@@ -569,7 +569,7 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
if (usedAnchors & QDeclarativeAnchors::LeftAnchor) {
//Handle stretching
bool invalid = true;
- int width = 0;
+ qreal width = 0.0;
if (usedAnchors & QDeclarativeAnchors::RightAnchor) {
invalid = calcStretch(left, right, leftMargin, -rightMargin, QDeclarativeAnchorLine::Left, width);
} else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
@@ -588,7 +588,7 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
} else if (usedAnchors & QDeclarativeAnchors::RightAnchor) {
//Handle stretching (left + right case is handled in updateLeftAnchor)
if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
- int width = 0;
+ qreal width = 0.0;
bool invalid = calcStretch(hCenter, right, hCenterOffset, -rightMargin,
QDeclarativeAnchorLine::Left, width);
if (!invalid)
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index 05be6c5..1bbea36 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -131,7 +131,7 @@ public:
bool checkVValid() const;
bool checkHAnchorValid(QDeclarativeAnchorLine anchor) const;
bool checkVAnchorValid(QDeclarativeAnchorLine anchor) const;
- bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, int offset1, int offset2, QDeclarativeAnchorLine::AnchorLine line, int &stretch);
+ bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, qreal offset1, qreal offset2, QDeclarativeAnchorLine::AnchorLine line, qreal &stretch);
void updateHorizontalAnchors();
void updateVerticalAnchors();
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index c4f0b86..13d1b61 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -152,8 +152,6 @@ void QDeclarativePaintedItem::setContentsSize(const QSize &size)
Q_D(QDeclarativePaintedItem);
if (d->contentsSize == size) return;
d->contentsSize = size;
- setImplicitWidth(size.width()*d->contentsScale);
- setImplicitHeight(size.height()*d->contentsScale);
clearCache();
update();
emit contentsSizeChanged();
@@ -170,8 +168,6 @@ void QDeclarativePaintedItem::setContentsScale(qreal scale)
Q_D(QDeclarativePaintedItem);
if (d->contentsScale == scale) return;
d->contentsScale = scale;
- setImplicitWidth(d->contentsSize.width()*scale);
- setImplicitHeight(d->contentsSize.height()*scale);
clearCache();
update();
emit contentsScaleChanged();
@@ -232,6 +228,19 @@ void QDeclarativePaintedItem::setCacheFrozen(bool frozen)
// XXX clear cache?
}
+QRectF QDeclarativePaintedItem::boundingRect() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ qreal w = d->mWidth;
+ QSizeF sz = d->contentsSize * d->contentsScale;
+ if (w < sz.width())
+ w = sz.width();
+ qreal h = d->mHeight;
+ if (h < sz.height())
+ h = sz.height();
+ return QRectF(0.0,0.0,w,h);
+}
+
/*!
\internal
*/
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
index 8d08ba2..86f065a 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
@@ -93,6 +93,7 @@ protected:
const QVariant &value);
void setCacheFrozen(bool);
+ QRectF boundingRect() const;
Q_SIGNALS:
void fillColorChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index d098aa0..4f7a722 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -114,11 +114,7 @@ void QDeclarativeGradientStop::updateGradient()
rectangle with a gradient starting with red, blending to yellow at 1/3 of the
size of the rectangle, and ending with Green:
- \table
- \row
- \o \image gradient.png
- \o \quotefile doc/src/snippets/declarative/gradient.qml
- \endtable
+ \snippet doc/src/snippets/declarative/gradient.qml code
\sa GradientStop
*/
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 4e7e0fd..2c1eb67 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -499,13 +499,10 @@ void QDeclarativeText::setVAlign(VAlignment align)
wrap if an explicit width has been set. wrapMode can be one of:
\list
- \o Text.NoWrap - no wrapping will be performed.
- \o Text.WordWrap - wrapping is done on word boundaries. If the text cannot be
- word-wrapped to the specified width it will be partially drawn outside of the item's bounds.
- If this is undesirable then enable clipping on the item (Item::clip).
- \o Text.WrapAnywhere - Text can be wrapped at any point on a line, even if it occurs in the middle of a word.
- \o Text.WrapAtWordBoundaryOrAnywhere - If possible, wrapping occurs at a word boundary; otherwise it
- will occur at the appropriate point on the line, even in the middle of a word.
+ \o Text.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width.
+ \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width.
+ \o Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
+ \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
\endlist
The default is Text.NoWrap.
@@ -715,6 +712,7 @@ void QDeclarativeTextPrivate::updateSize()
QFontMetrics fm(font);
if (text.isEmpty()) {
q->setImplicitHeight(fm.height());
+ emit q->paintedSizeChanged();
return;
}
@@ -753,11 +751,36 @@ void QDeclarativeTextPrivate::updateSize()
//### need to comfirm cost of always setting these for richText
q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
+ emit q->paintedSizeChanged();
} else {
dirty = true;
}
}
+/*!
+ \qmlproperty real Text::paintedWidth
+
+ Returns the width of the text, including width past the width
+ which is covered due to insufficient wrapping if WrapMode is set.
+*/
+qreal QDeclarativeText::paintedWidth() const
+{
+ return implicitWidth();
+}
+
+/*!
+ \qmlproperty real Text::paintedHeight
+
+ Returns the height of the text, including height past the height
+ which is covered due to there being more text than fits in the set height.
+*/
+qreal QDeclarativeText::paintedHeight() const
+{
+ return implicitHeight();
+}
+
+
+
// ### text layout handling should be profiled and optimized as needed
// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index 00ce126..db21140 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -71,6 +71,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
+ Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
+ Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
public:
QDeclarativeText(QDeclarativeItem *parent=0);
@@ -98,7 +100,8 @@ public:
enum WrapMode { NoWrap = QTextOption::NoWrap,
WordWrap = QTextOption::WordWrap,
WrapAnywhere = QTextOption::WrapAnywhere,
- WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
+ WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
+ Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
QString text() const;
@@ -137,6 +140,9 @@ public:
int resourcesLoading() const; // mainly for testing
+ qreal paintedWidth() const;
+ qreal paintedHeight() const;
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
@@ -149,6 +155,7 @@ Q_SIGNALS:
void wrapModeChanged();
void textFormatChanged(TextFormat textFormat);
void elideModeChanged(TextElideMode mode);
+ void paintedSizeChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index a154d53..167db77 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -484,14 +484,13 @@ void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment)
The text will only wrap if an explicit width has been set.
\list
- \o TextEdit.NoWrap - no wrapping will be performed.
- \o TextEdit.WordWrap - wrapping is done on word boundaries.
- \o TextEdit.WrapAnywhere - Text can be wrapped at any point on a line, even if it occurs in the middle of a word.
- \o TextEdit.WrapAtWordBoundaryOrAnywhere - If possible, wrapping occurs at a word boundary; otherwise it
- will occur at the appropriate point on the line, even in the middle of a word.
+ \o TextEdit.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width.
+ \o TextEdit.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width.
+ \o TextEdit.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
+ \o TextEdit.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
\endlist
- The default is TextEdit.NoWrap.
+ The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap.
*/
QDeclarativeTextEdit::WrapMode QDeclarativeTextEdit::wrapMode() const
{
@@ -511,6 +510,29 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode)
}
/*!
+ \qmlproperty real TextEdit::paintedWidth
+
+ Returns the width of the text, including width past the width
+ which is covered due to insufficient wrapping if WrapMode is set.
+*/
+qreal QDeclarativeTextEdit::paintedWidth() const
+{
+ return implicitWidth();
+}
+
+/*!
+ \qmlproperty real TextEdit::paintedHeight
+
+ Returns the height of the text, including height past the height
+ which is covered due to there being more text than fits in the set height.
+*/
+qreal QDeclarativeTextEdit::paintedHeight() const
+{
+ return implicitHeight();
+}
+
+
+/*!
\qmlproperty bool TextEdit::cursorVisible
If true the text edit shows a cursor.
@@ -940,8 +962,8 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- bool hadFocus = hasFocus();
if (d->focusOnPress){
+ bool hadFocus = hasFocus();
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope)
@@ -949,9 +971,11 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
p = p->parentItem();
}
setFocus(true);
+ if (hasFocus() == hadFocus && d->showInputPanelOnFocus && !isReadOnly()) {
+ // re-open input panel on press if already focused
+ openSoftwareInputPanel();
+ }
}
- if (!hadFocus && hasFocus())
- d->clickCausedFocus = true;
if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse)
d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
@@ -965,11 +989,6 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- QWidget *widget = event->widget();
- if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
- d->clickCausedFocus = false;
-
d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mouseReleaseEvent(event);
@@ -1156,7 +1175,7 @@ void QDeclarativeTextEdit::updateSize()
int dy = height();
// ### assumes that if the width is set, the text will fill to edges
// ### (unless wrap is false, then clipping will occur)
- if (widthValid())
+ if (widthValid() && d->document->textWidth() != width())
d->document->setTextWidth(width());
dy -= (int)d->document->size().height();
@@ -1172,7 +1191,7 @@ void QDeclarativeTextEdit::updateSize()
//### need to comfirm cost of always setting these
int newWidth = qCeil(d->document->idealWidth());
- if (!widthValid())
+ if (!widthValid() && d->document->textWidth() != newWidth)
d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug)
int cursorWidth = 1;
if(d->cursor)
@@ -1182,9 +1201,12 @@ void QDeclarativeTextEdit::updateSize()
newWidth += 3;// ### Need a better way of accounting for space between char and cursor
// ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
setImplicitWidth(newWidth);
- setImplicitHeight(d->document->isEmpty() ? fm.height() : (int)d->document->size().height());
+ qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height();
+ setImplicitHeight(newHeight);
- setContentsSize(QSize(width(), height()));
+ setContentsSize(QSize(newWidth, newHeight));
+
+ emit paintedSizeChanged();
} else {
d->dirty = true;
}
@@ -1205,4 +1227,127 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
document->setDefaultTextOption(opt);
}
+
+/*!
+ \qmlmethod void TextEdit::openSoftwareInputPanel()
+
+ Opens software input panels like virtual keyboards for typing, useful for
+ customizing when you want the input keyboard to be shown and hidden in
+ your application.
+
+ By default input panels are shown when TextEdit element gains focus and hidden
+ when the focus is lost. You can disable the automatic behavior by setting the
+ property showInputPanelOnFocus to false and use functions openSoftwareInputPanel()
+ and closeSoftwareInputPanel() to implement the behavior you want.
+
+ Only relevant on platforms, which provide virtual keyboards.
+
+ \code
+ import Qt 4.7
+ TextEdit {
+ id: textEdit
+ text: "Hello world!"
+ showInputPanelOnFocus: false
+ MouseArea {
+ anchors.fill: parent
+ onClicked: textEdit.openSoftwareInputPanel()
+ }
+ onFocusChanged: if (!focus) closeSoftwareInputpanel()
+ }
+ \endcode
+*/
+void QDeclarativeTextEdit::openSoftwareInputPanel()
+{
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ if (qApp) {
+ if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
+ if (view->scene() && view->scene() == scene()) {
+ QApplication::sendEvent(view, &event);
+ }
+ }
+ }
+}
+
+/*!
+ \qmlmethod void TextEdit::closeSoftwareInputPanel()
+
+ Closes a software input panel like a virtual keyboard shown on the screen, useful
+ for customizing when you want the input keyboard to be shown and hidden in
+ your application.
+
+ By default input panels are shown when TextEdit element gains focus and hidden
+ when the focus is lost. You can disable the automatic behavior by setting the
+ property showInputPanelOnFocus to false and use functions openSoftwareInputPanel()
+ and closeSoftwareInputPanel() to implement the behavior you want.
+
+ Only relevant on platforms, which provide virtual keyboards.
+
+ \code
+ import Qt 4.7
+ TextEdit {
+ id: textEdit
+ text: "Hello world!"
+ showInputPanelOnFocus: false
+ MouseArea {
+ anchors.fill: parent
+ onClicked: textEdit.openSoftwareInputPanel()
+ }
+ onFocusChanged: if (!focus) closeSoftwareInputpanel()
+ }
+ \endcode
+*/
+void QDeclarativeTextEdit::closeSoftwareInputPanel()
+{
+ QEvent event(QEvent::CloseSoftwareInputPanel);
+ if (qApp) {
+ if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
+ if (view->scene() && view->scene() == scene()) {
+ QApplication::sendEvent(view, &event);
+ }
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool TextEdit::showInputPanelOnFocus
+ Whether input panels are automatically shown when TextEdit element gains
+ focus and hidden when focus is lost. By default this is set to true.
+
+ Only relevant on platforms, which provide virtual keyboards.
+*/
+bool QDeclarativeTextEdit::showInputPanelOnFocus() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->showInputPanelOnFocus;
+}
+
+void QDeclarativeTextEdit::setShowInputPanelOnFocus(bool showOnFocus)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->showInputPanelOnFocus == showOnFocus)
+ return;
+
+ d->showInputPanelOnFocus = showOnFocus;
+
+ emit showInputPanelOnFocusChanged(d->showInputPanelOnFocus);
+}
+
+void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event)
+{
+ Q_D(const QDeclarativeTextEdit);
+ if (d->showInputPanelOnFocus && !isReadOnly()) {
+ openSoftwareInputPanel();
+ }
+ QDeclarativePaintedItem::focusInEvent(event);
+}
+
+void QDeclarativeTextEdit::focusOutEvent(QFocusEvent *event)
+{
+ Q_D(const QDeclarativeTextEdit);
+ if (d->showInputPanelOnFocus && !isReadOnly()) {
+ closeSoftwareInputPanel();
+ }
+ QDeclarativePaintedItem::focusOutEvent(event);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 891b868..47174f4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -74,6 +74,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
+ Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
+ Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
@@ -84,6 +86,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+ Q_PROPERTY(bool showInputPanelOnFocus READ showInputPanelOnFocus WRITE setShowInputPanelOnFocus NOTIFY showInputPanelOnFocusChanged)
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
@@ -113,9 +116,13 @@ public:
enum WrapMode { NoWrap = QTextOption::NoWrap,
WordWrap = QTextOption::WordWrap,
WrapAnywhere = QTextOption::WrapAnywhere,
- WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
+ WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
+ Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
+ Q_INVOKABLE void openSoftwareInputPanel();
+ Q_INVOKABLE void closeSoftwareInputPanel();
+
QString text() const;
void setText(const QString &);
@@ -163,6 +170,9 @@ public:
bool focusOnPress() const;
void setFocusOnPress(bool on);
+ bool showInputPanelOnFocus() const;
+ void setShowInputPanelOnFocus(bool showOnFocus);
+
bool persistentSelection() const;
void setPersistentSelection(bool on);
@@ -185,8 +195,12 @@ public:
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+ qreal paintedWidth() const;
+ qreal paintedHeight() const;
+
Q_SIGNALS:
void textChanged(const QString &);
+ void paintedSizeChanged();
void cursorPositionChanged();
void cursorRectangleChanged();
void selectionStartChanged();
@@ -207,6 +221,7 @@ Q_SIGNALS:
void persistentSelectionChanged(bool isPersistentSelection);
void textMarginChanged(qreal textMargin);
void selectByMouseChanged(bool selectByMouse);
+ void showInputPanelOnFocusChanged(bool showOnFocus);
public Q_SLOTS:
void selectAll();
@@ -228,6 +243,8 @@ protected:
bool event(QEvent *);
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
// mouse filter?
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index d96796c..8e1d630 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -70,9 +70,9 @@ public:
QDeclarativeTextEditPrivate()
: color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
- persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
- cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
- wrapMode(QDeclarativeTextEdit::NoWrap),
+ showInputPanelOnFocus(true), persistentSelection(true), textMargin(0.0), lastSelectionStart(0),
+ lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText),
+ document(0), wrapMode(QDeclarativeTextEdit::NoWrap),
selectByMouse(false),
yoff(0)
{
@@ -101,8 +101,8 @@ public:
bool richText : 1;
bool cursorVisible : 1;
bool focusOnPress : 1;
+ bool showInputPanelOnFocus : 1;
bool persistentSelection : 1;
- bool clickCausedFocus : 1;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 1ac1b4e..18e3595 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -886,8 +886,8 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
- bool hadFocus = hasFocus();
if(d->focusOnPress){
+ bool hadFocus = hasFocus();
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope)
@@ -895,9 +895,11 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
p = p->parentItem();
}
setFocus(true);
+ if (hasFocus() == hadFocus && d->showInputPanelOnFocus && !isReadOnly()) {
+ // re-open input panel on press w already focused
+ openSoftwareInputPanel();
+ }
}
- if (!hadFocus && hasFocus())
- d->clickCausedFocus = true;
bool mark = event->modifiers() & Qt::ShiftModifier;
int cursor = d->xToPos(event->pos().x());
@@ -923,10 +925,7 @@ Handles the given mouse \a event.
void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
- QWidget *widget = event->widget();
- if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
- d->clickCausedFocus = false;
+ d->control->processEvent(event);
if (!event->isAccepted())
QDeclarativePaintedItem::mouseReleaseEvent(event);
}
@@ -1175,6 +1174,129 @@ void QDeclarativeTextInput::moveCursorSelection(int position)
d->control->moveCursor(position, true);
}
+/*!
+ \qmlmethod void TextInput::openSoftwareInputPanel()
+
+ Opens software input panels like virtual keyboards for typing, useful for
+ customizing when you want the input keyboard to be shown and hidden in
+ your application.
+
+ By default input panels are shown when TextInput element gains focus and hidden
+ when the focus is lost. You can disable the automatic behavior by setting the
+ property showInputPanelOnFocus to false and use functions openSoftwareInputPanel()
+ and closeSoftwareInputPanel() to implement the behavior you want.
+
+ Only relevant on platforms, which provide virtual keyboards.
+
+ \code
+ import Qt 4.7
+ TextInput {
+ id: textInput
+ text: "Hello world!"
+ showInputPanelOnFocus: false
+ MouseArea {
+ anchors.fill: parent
+ onClicked: textInput.openSoftwareInputPanel()
+ }
+ onFocusChanged: if (!focus) closeSoftwareInputPanel()
+ }
+ \endcode
+*/
+void QDeclarativeTextInput::openSoftwareInputPanel()
+{
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ if (qApp) {
+ if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
+ if (view->scene() && view->scene() == scene()) {
+ QApplication::sendEvent(view, &event);
+ }
+ }
+ }
+}
+
+/*!
+ \qmlmethod void TextInput::closeSoftwareInputPanel()
+
+ Closes a software input panel like a virtual keyboard shown on the screen, useful
+ for customizing when you want the input keyboard to be shown and hidden in
+ your application.
+
+ By default input panels are shown when TextInput element gains focus and hidden
+ when the focus is lost. You can disable the automatic behavior by setting the
+ property showInputPanelOnFocus to false and use functions openSoftwareInputPanel()
+ and closeSoftwareInputPanel() to implement the behavior you want.
+
+ Only relevant on platforms, which provide virtual keyboards.
+
+ \code
+ import Qt 4.7
+ TextInput {
+ id: textInput
+ text: "Hello world!"
+ showInputPanelOnFocus: false
+ MouseArea {
+ anchors.fill: parent
+ onClicked: textInput.openSoftwareInputPanel()
+ }
+ onFocusChanged: if (!focus) closeSoftwareInputPanel()
+ }
+ \endcode
+*/
+void QDeclarativeTextInput::closeSoftwareInputPanel()
+{
+ QEvent event(QEvent::CloseSoftwareInputPanel);
+ if (qApp) {
+ QEvent event(QEvent::CloseSoftwareInputPanel);
+ if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
+ if (view->scene() && view->scene() == scene()) {
+ QApplication::sendEvent(view, &event);
+ }
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool TextInput::showInputPanelOnFocus
+ Whether input panels are automatically shown when TextInput element gains
+ focus and hidden when focus is lost. By default this is set to true.
+
+ Only relevant on platforms, which provide virtual keyboards.
+*/
+bool QDeclarativeTextInput::showInputPanelOnFocus() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->showInputPanelOnFocus;
+}
+
+void QDeclarativeTextInput::setShowInputPanelOnFocus(bool showOnFocus)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->showInputPanelOnFocus == showOnFocus)
+ return;
+
+ d->showInputPanelOnFocus = showOnFocus;
+
+ emit showInputPanelOnFocusChanged(d->showInputPanelOnFocus);
+}
+
+void QDeclarativeTextInput::focusInEvent(QFocusEvent *event)
+{
+ Q_D(const QDeclarativeTextInput);
+ if (d->showInputPanelOnFocus && !isReadOnly()) {
+ openSoftwareInputPanel();
+ }
+ QDeclarativePaintedItem::focusInEvent(event);
+}
+
+void QDeclarativeTextInput::focusOutEvent(QFocusEvent *event)
+{
+ Q_D(const QDeclarativeTextInput);
+ if (d->showInputPanelOnFocus && !isReadOnly()) {
+ closeSoftwareInputPanel();
+ }
+ QDeclarativePaintedItem::focusOutEvent(event);
+}
+
void QDeclarativeTextInputPrivate::init()
{
Q_Q(QDeclarativeTextInput);
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index b2fd057..438293a 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -86,6 +86,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedIte
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+ Q_PROPERTY(bool showInputPanelOnFocus READ showInputPanelOnFocus WRITE setShowInputPanelOnFocus NOTIFY showInputPanelOnFocusChanged)
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
@@ -112,6 +113,9 @@ public:
Q_INVOKABLE int xToPosition(int x);
Q_INVOKABLE void moveCursorSelection(int pos);
+ Q_INVOKABLE void openSoftwareInputPanel();
+ Q_INVOKABLE void closeSoftwareInputPanel();
+
QString text() const;
void setText(const QString &);
@@ -172,6 +176,9 @@ public:
bool focusOnPress() const;
void setFocusOnPress(bool);
+ bool showInputPanelOnFocus() const;
+ void setShowInputPanelOnFocus(bool showOnFocus);
+
bool autoScroll() const;
void setAutoScroll(bool);
@@ -208,6 +215,7 @@ Q_SIGNALS:
void focusOnPressChanged(bool focusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
+ void showInputPanelOnFocusChanged(bool showOnFocus);
protected:
virtual void geometryChanged(const QRectF &newGeometry,
@@ -218,6 +226,8 @@ protected:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void keyPressEvent(QKeyEvent* ev);
bool event(QEvent *e);
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
public Q_SLOTS:
void selectAll();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 1d8e0f7..f44d014 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -72,7 +72,7 @@ public:
color((QRgb)0), style(QDeclarativeText::Normal),
styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
- cursorVisible(false), autoScroll(true), clickCausedFocus(false),
+ showInputPanelOnFocus(true), cursorVisible(false), autoScroll(true),
selectByMouse(false)
{
}
@@ -115,9 +115,9 @@ public:
int oldScroll;
bool focused;
bool focusOnPress;
+ bool showInputPanelOnFocus;
bool cursorVisible;
bool autoScroll;
- bool clickCausedFocus;
bool selectByMouse;
};
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index a7384a9..8679e76 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -153,11 +153,11 @@ void QDeclarativeEnginePrivate::defineModule()
/*!
\qmlclass Qt QDeclarativeEnginePrivate
-\brief The QML Global Qt Object
+\brief The QML global Qt object provides useful enums and functions from Qt.
-The Qt object provides useful enums and functions from Qt, for use in all QML
-files. Note that you do note create instances of this type, but instead use
-the members of the global "Qt" object.
+The Qt object provides useful enums and functions from Qt, for use in all QML files.
+
+You do not create instances of this type, but instead use the members of the global "Qt" object.
\section1 Enums
@@ -172,23 +172,23 @@ data types. This is primarily useful when setting the properties of an item
when the property has one of the following types:
\list
-\o Color
-\o Rect
-\o Point
-\o Size
-\o Vector3D
+\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()}
+\o \c rect - use \l{Qt::rect()}{Qt.rect()}
+\o \c point - use \l{Qt::point()}{Qt.point()}
+\o \c size - use \l{Qt::size()}{Qt.size()}
+\o \c vector3d - use \l{Qt::vector3d()}{Qt.vector3d()}
\endlist
-There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{Qml Types}.
+There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{QML Basic Types}.
\section1 Date/Time Formatters
The Qt object contains several functions for formatting dates and times.
\list
- \o \l{Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)
- \o \l{Qt::formatDate}{string Qt.formatDate(datetime date, variant format)
- \o \l{Qt::formatTime}{string Qt.formatTime(datetime date, variant format)
+ \o \l{Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
+ \o \l{Qt::formatDate}{string Qt.formatDate(datetime date, variant format)}
+ \o \l{Qt::formatTime}{string Qt.formatTime(datetime date, variant format)}
\endlist
The format specification is described at \l{Qt::formatDateTime}{Qt.formatDateTime}.
@@ -226,8 +226,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
/*!
\qmlmethod url Qt::resolvedUrl(url)
-This function returns \c url resolved relative to the URL of the
-caller.
+Returns \c url resolved relative to the URL of the caller.
*/
QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
{
@@ -1035,8 +1034,11 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
/*!
\qmlmethod object Qt::createComponent(url)
-This function takes the URL of a QML file as its only argument. It returns
-a component object which can be used to create and load that QML file.
+Returns a \l Component object created from the QML file at the specified \a url,
+or \c null if there was an error in creating the component.
+
+Call \l {Component::createObject()}{Component.createObject()} on the returned
+component to create an object instance of the component.
Here is an example. Remember that QML files that might be loaded
over the network cannot be expected to be ready immediately.
@@ -1049,17 +1051,8 @@ If you are certain the files will be local, you could simplify to:
\snippet doc/src/snippets/declarative/componentCreation.js 2
-The methods and properties of the \l {Component} element are defined in its own
-page, but when using it dynamically only two methods are usually used.
- \l {Component::createObject()}{Component.createObject()} returns the created object or \c null if there is an error.
-If there is an error, \l {Component::errorString()}{Component.errorString()} describes
-the error that occurred. Note that createObject() takes exactly one argument, which is set
-to the parent of the created object. Graphical objects without a parent will not appear
-on the scene, but if you do not wish to parent the item at this point you can safely pass
-in null.
-
-If you want to just create an arbitrary string of QML, instead of
-loading a QML file, consider the \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} function.
+To create a QML object from an arbitrary string of QML (instead of a file),
+use \l{Qt::createQmlObject()}{Qt.createQmlObject()}.
*/
QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1088,29 +1081,22 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
/*!
\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
-Creates a new object from the specified string of QML. It requires a
-second argument, which is the id of an existing QML object to use as
-the new object's parent. If a third argument is provided, this is used
-for error reporting as the filepath that the QML came from.
+Returns a new object created from the given \a string of QML with the specified \a parent,
+or \c null if there was an error in creating the object.
+
+If \a filepath is specified, it will be used for error reporting for the created object.
Example (where \c targetItem is the id of an existing QML item):
\snippet doc/src/snippets/declarative/createQmlObject.qml 0
-This function is intended for use inside QML only. It is intended to behave
-similarly to eval, but for creating QML elements.
-
-Returns the created object, \c or null if there is an error. In the case of an
-error, a QtScript Error object is thrown. This object has the additional property,
-qmlErrors, which is an array of all the errors encountered when trying to execute the
-QML. Each object in the array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
+In the case of an error, a QtScript Error object is thrown. This object has an additional property,
+\c qmlErrors, which is an array of the errors encountered.
+Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
Note that this function returns immediately, and therefore may not work if
-the QML loads new components. If you are trying to load a new component,
-for example from a QML file, consider the \l{Qt.createComponent(url file)}{Qt.createComponent()} function
-instead. 'New components' refers to external QML files that have not yet
-been loaded, and so it is safe to use \c Qt.createQmlObject() to load built-in
-components.
+the \a qml string loads new components (that is, external QML files that have not yet been loaded).
+If this is the case, consider using \l{Qt::createComponent()}{Qt.createComponent()} instead.
*/
QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1217,7 +1203,7 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript
/*!
\qmlmethod Qt::vector3d(real x, real y, real z)
-This function returns a Vector3D with the specified \c x, \c y and \c z.
+Returns a Vector3D with the specified \c x, \c y and \c z.
*/
QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEngine *engine)
{
@@ -1231,7 +1217,7 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn
/*!
\qmlmethod string Qt::formatDate(datetime date, variant format)
-This function returns the string representation of \c date, formatted according to \c format.
+Returns the string representation of \c date, formatted according to \c format.
*/
QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
{
@@ -1256,7 +1242,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
/*!
\qmlmethod string Qt::formatTime(datetime time, variant format)
-This function returns the string representation of \c time, formatted according to \c format.
+Returns the string representation of \c time, formatted according to \c format.
See Qt::formatDateTime for how to define \c format.
*/
@@ -1283,7 +1269,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
/*!
\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
-This function returns the string representation of \c dateTime, formatted according to \c format.
+Returns the string representation of \c dateTime, formatted according to \c format.
\c format for the date/time formatting functions is be specified as follows.
@@ -1374,7 +1360,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
/*!
\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
-This function returns a Color with the specified \c red, \c green, \c blue and \c alpha components.
+Returns a Color with the specified \c red, \c green, \c blue and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1402,7 +1388,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
-This function returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
+Returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1430,7 +1416,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod rect Qt::rect(int x, int y, int width, int height)
-This function returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
+Returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
*/
QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
{
@@ -1450,7 +1436,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod point Qt::point(int x, int y)
-This function returns a Point with the specified \c x and \c y coordinates.
+Returns a Point with the specified \c x and \c y coordinates.
*/
QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
{
@@ -1463,7 +1449,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin
/*!
\qmlmethod Qt::size(int width, int height)
-This function returns as Size with the specified \c width and \c height.
+Returns a Size with the specified \c width and \c height.
*/
QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
{
@@ -1476,7 +1462,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod color Qt::lighter(color baseColor, real factor)
-This function returns a color lighter than \c baseColor by the \c factor provided.
+Returns a color lighter than \c baseColor by the \c factor provided.
If the factor is greater than 1.0, this functions returns a lighter color.
Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0,
@@ -1512,7 +1498,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng
/*!
\qmlmethod color Qt::darker(color baseColor, real factor)
-This function returns a color darker than \c baseColor by the \c factor provided.
+Returns a color darker than \c baseColor by the \c factor provided.
If the factor is greater than 1.0, this function returns a darker color.
Setting factor to 3.0 returns a color that has one-third the brightness.
@@ -1549,7 +1535,7 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
/*!
\qmlmethod bool Qt::openUrlExternally(url target)
-This function attempts to open the specified \c target url in an external application, based on the user's desktop preferences. It will return true if it succeeds, and false otherwise.
+Attempts to open the specified \c target url in an external application, based on the user's desktop preferences. Returns true if it succeeds, and false otherwise.
*/
QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
{
@@ -1564,7 +1550,7 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc
/*!
\qmlmethod list<string> Qt::fontFamilies()
-This function returns a list of the font families available to the application.
+Returns a list of the font families available to the application.
*/
QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScriptEngine *e)
@@ -1579,7 +1565,7 @@ QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScri
/*!
\qmlmethod string Qt::md5(data)
-This function returns a hex string of the md5 hash of \c data.
+Returns a hex string of the md5 hash of \c data.
*/
QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
{
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 1550351..2ca030e 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -295,6 +295,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
ctxt->pushScope(urlContext);
ctxt->pushScope(activation);
ctxt->setActivationObject(activation);
+ QDeclarativeScriptParser::extractPragmas(script);
workerEngine->baseUrl = url;
workerEngine->evaluate(script);
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index e68ef94..b7ce9c9 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -116,7 +116,7 @@ public:
void frameBreak() { ++breaks; }
private:
- QTime timer;
+ QElapsedTimer timer;
int breaks;
};
@@ -152,7 +152,7 @@ public:
QBasicTimer resizetimer;
QDeclarativeView::ResizeMode resizeMode;
- QTime frameTimer;
+ QElapsedTimer frameTimer;
void init();
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index d08e37b..4f9355b 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -80,7 +80,11 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
/*!
\qmlproperty string XmlRole::name
- The name for the role. This name is used to access the model data for this role from Qml.
+
+ The name for the role. This name is used to access the model data for this role.
+
+ For example, the following model has a role named "title", which can be accessed
+ from the view's delegate:
\qml
XmlListModel {
@@ -91,19 +95,27 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
ListView {
model: xmlModel
- Text { text: title }
+ delegate: Text { text: title }
}
\endqml
*/
/*!
\qmlproperty string XmlRole::query
- The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
- relative).
+ The relative XPath expression query for this role. The query must be relative; it cannot start
+ with a '/'.
- \qml
- XmlRole { name: "title"; query: "title/string()" }
- \endqml
+ For example, if there is an XML document like this:
+
+ \quotefile doc/src/snippets/declarative/xmlrole.xml
+
+ Here are some valid XPath expressions for XmlRole queries on this document:
+
+ \snippet doc/src/snippets/declarative/xmlrole.qml 0
+ \dots 4
+ \snippet doc/src/snippets/declarative/xmlrole.qml 1
+
+ See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information.
*/
/*!
@@ -521,9 +533,12 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
\endqml
The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
- a model item for each \c <item> in the XML document. The XmlRole objects define the
+ a model item for each \c <item> in the XML document.
+
+ The XmlRole objects define the
model item attributes; here, each model item will have \c title and \c pubDate
attributes that match the \c title and \c pubDate values of its corresponding \c <item>.
+ (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.)
The model could be used in a ListView, like this:
@@ -559,8 +574,6 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
If multiple key roles are specified, the model only adds and reload items
with a combined value of all key roles that is not already present in
the model.
-
- \sa {declarative/xml/xmldata}{XML data example}
*/
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro
index f55c00e..4ef7931 100644
--- a/src/imports/gestures/gestures.pro
+++ b/src/imports/gestures/gestures.pro
@@ -1,4 +1,4 @@
-TARGET = gesturesqmlplugin
+TARGET = qmlgesturesplugin
TARGETPATH = Qt/labs/gestures
include(../qimportbase.pri)
@@ -17,7 +17,7 @@ symbian:{
load(data_caging_paths)
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
- importFiles.sources = gesturesqmlplugin.dll qmldir
+ importFiles.sources = qmlgesturesplugin.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/src/imports/gestures/plugin.cpp b/src/imports/gestures/plugin.cpp
index b8a9751..11f2392 100644
--- a/src/imports/gestures/plugin.cpp
+++ b/src/imports/gestures/plugin.cpp
@@ -61,5 +61,5 @@ QT_END_NAMESPACE
#include "plugin.moc"
-Q_EXPORT_PLUGIN2(gesturesqmlplugin, QT_PREPEND_NAMESPACE(GestureAreaQmlPlugin));
+Q_EXPORT_PLUGIN2(qmlgesturesplugin, QT_PREPEND_NAMESPACE(GestureAreaQmlPlugin));
diff --git a/src/imports/gestures/qmldir b/src/imports/gestures/qmldir
index 9d9d587..2a31920 100644
--- a/src/imports/gestures/qmldir
+++ b/src/imports/gestures/qmldir
@@ -1 +1 @@
-plugin gesturesqmlplugin
+plugin qmlgesturesplugin
diff --git a/src/imports/particles/particles.cpp b/src/imports/particles/particles.cpp
index ae3f318..ca2b060 100644
--- a/src/imports/particles/particles.cpp
+++ b/src/imports/particles/particles.cpp
@@ -65,5 +65,5 @@ QT_END_NAMESPACE
#include "particles.moc"
-Q_EXPORT_PLUGIN2(particlesqmlmodule, QT_PREPEND_NAMESPACE(QParticlesQmlModule));
+Q_EXPORT_PLUGIN2(qmlparticlesplugin, QT_PREPEND_NAMESPACE(QParticlesQmlModule));
diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro
index 79ac543..9fd4db5 100644
--- a/src/imports/particles/particles.pro
+++ b/src/imports/particles/particles.pro
@@ -1,4 +1,4 @@
-TARGET = particles
+TARGET = qmlparticlesplugin
TARGETPATH = Qt/labs/particles
include(../qimportbase.pri)
@@ -21,7 +21,7 @@ symbian:{
load(data_caging_paths)
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
- importFiles.sources = particles.dll qmldir
+ importFiles.sources = qmlparticlesplugin.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/src/imports/particles/qmldir b/src/imports/particles/qmldir
index 15456bb..aeebd2c 100644
--- a/src/imports/particles/qmldir
+++ b/src/imports/particles/qmldir
@@ -1 +1 @@
-plugin particles
+plugin qmlparticlesplugin
diff --git a/src/imports/webkit/plugin.cpp b/src/imports/webkit/plugin.cpp
index e3d73ec..c8e56ba 100644
--- a/src/imports/webkit/plugin.cpp
+++ b/src/imports/webkit/plugin.cpp
@@ -63,5 +63,5 @@ QT_END_NAMESPACE
#include "plugin.moc"
-Q_EXPORT_PLUGIN2(webkitqmlplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin));
+Q_EXPORT_PLUGIN2(qmlwebkitplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin));
diff --git a/src/imports/webkit/qmldir b/src/imports/webkit/qmldir
index 258aa2c..dcfdd06 100644
--- a/src/imports/webkit/qmldir
+++ b/src/imports/webkit/qmldir
@@ -1 +1 @@
-plugin webkitqmlplugin
+plugin qmlwebkitplugin
diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro
index 77cbc4d..7b2ac66 100644
--- a/src/imports/webkit/webkit.pro
+++ b/src/imports/webkit/webkit.pro
@@ -1,4 +1,4 @@
-TARGET = webkitqmlplugin
+TARGET = qmlwebkitplugin
TARGETPATH = org/webkit
include(../qimportbase.pri)
@@ -18,7 +18,7 @@ symbian:{
load(data_caging_paths)
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
- importFiles.sources = webkitqmlplugin.dll qmldir
+ importFiles.sources = qmlwebkitplugin.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml b/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml
new file mode 100644
index 0000000..7cd4f26
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+Rectangle {
+ width: 77; height: 95
+ Rectangle {
+ objectName: "centered"
+ width: 57; height: 57; color: "blue"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
index e169fa2..22f7966 100644
--- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -77,6 +77,7 @@ private slots:
void nullItem_data();
void crash1();
void centerIn();
+ void hvCenter();
void fill();
void margins();
};
@@ -526,6 +527,19 @@ void tst_qdeclarativeanchors::centerIn()
delete view;
}
+void tst_qdeclarativeanchors::hvCenter()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered"));
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+ delete view;
+}
+
void tst_qdeclarativeanchors::margins()
{
QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index b07849d..0df28d0 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
#include <math.h>
@@ -811,7 +812,7 @@ QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename)
class MyInputContext : public QInputContext
{
public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
+ MyInputContext() : openInputPanelReceived(false), closeInputPanelReceived(false) {}
~MyInputContext() {}
QString identifierName() { return QString(); }
@@ -824,10 +825,13 @@ public:
bool filterEvent( const QEvent *event )
{
if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
+ openInputPanelReceived = true;
+ if (event->type() == QEvent::CloseSoftwareInputPanel)
+ closeInputPanelReceived = true;
return QInputContext::filterEvent(event);
}
- bool softwareInputPanelEventReceived;
+ bool openInputPanelReceived;
+ bool closeInputPanelReceived;
};
void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
@@ -835,10 +839,9 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ view.setInputContext(&ic);
QDeclarativeTextEdit edit;
+ QSignalSpy inputPanelonFocusSpy(&edit, SIGNAL(showInputPanelOnFocusChanged(bool)));
edit.setText("Hello world");
edit.setPos(0, 0);
scene.addItem(&edit);
@@ -847,16 +850,77 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+
+ QVERIFY(edit.showInputPanelOnFocus());
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ // focus on press, input panel on focus
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.softwareInputPanelEventReceived, false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- }
+ QVERIFY(edit.hasFocus());
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // no events on release
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // Even with focus already gained, user needs
+ // to be able to open panel by pressing on the editor
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // input panel closed on focus lost
+ edit.setFocus(false);
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.closeInputPanelReceived = false;
+
+ // no input panel events if showInputPanelOnFocus is false
+ edit.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ edit.setFocus(false);
+ edit.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ edit.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+
+ // one show input panel event when openSoftwareInputPanel is called
+ edit.openSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // one close input panel event when closeSoftwareInputPanel is called
+ edit.closeSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.openInputPanelReceived = false;
+
+ // set showInputPanelOnFocus back to true
+ edit.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
+ edit.setFocus(false);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ edit.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+
+ edit.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
}
void tst_qdeclarativetextedit::geometrySignals()
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index ac80edb..155223d 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include "../../../shared/util.h"
#include <QtDeclarative/qdeclarativeengine.h>
#include <QFile>
@@ -712,11 +713,10 @@ QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
return canvas;
}
-
class MyInputContext : public QInputContext
{
public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
+ MyInputContext() : openInputPanelReceived(false), closeInputPanelReceived(false) {}
~MyInputContext() {}
QString identifierName() { return QString(); }
@@ -729,10 +729,13 @@ public:
bool filterEvent( const QEvent *event )
{
if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
+ openInputPanelReceived = true;
+ if (event->type() == QEvent::CloseSoftwareInputPanel)
+ closeInputPanelReceived = true;
return QInputContext::filterEvent(event);
}
- bool softwareInputPanelEventReceived;
+ bool openInputPanelReceived;
+ bool closeInputPanelReceived;
};
void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
@@ -740,10 +743,9 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ view.setInputContext(&ic);
QDeclarativeTextInput input;
+ QSignalSpy inputPanelonFocusSpy(&input, SIGNAL(showInputPanelOnFocusChanged(bool)));
input.setText("Hello world");
input.setPos(0, 0);
scene.addItem(&input);
@@ -752,16 +754,77 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+
+ QVERIFY(input.showInputPanelOnFocus());
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ // focus on press, input panel on focus
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.softwareInputPanelEventReceived, false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- }
+ QVERIFY(input.hasFocus());
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // no events on release
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // Even with focus already gained, user needs
+ // to be able to open panel by pressing on the editor
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // input panel closed on focus lost
+ input.setFocus(false);
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.closeInputPanelReceived = false;
+
+ // no input panel events if showInputPanelOnFocus is false
+ input.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ input.setFocus(false);
+ input.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ input.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+
+ // one show input panel event when openSoftwareInputPanel is called
+ input.openSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // one close input panel event when closeSoftwareInputPanel is called
+ input.closeSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.openInputPanelReceived = false;
+
+ // set showInputPanelOnFocus back to true
+ input.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
+ input.setFocus(false);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ input.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+
+ input.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
}
class MyTextInput : public QDeclarativeTextInput
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
new file mode 100644
index 0000000..d275ca8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
@@ -0,0 +1,24 @@
+import Qt 4.7
+
+WorkerScript {
+ id: worker
+
+ property variant response
+
+ signal done()
+
+ function testSend(value) {
+ worker.sendMessage(value)
+ }
+
+ function compareLiteralResponse(expected) {
+ var e = eval('(' + expected + ')')
+ return worker.response == e
+ }
+
+ onMessage: {
+ worker.response = messageObject
+ worker.done()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
index 09199de..90aae26 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
@@ -2,4 +2,3 @@ WorkerScript.onMessage = function(msg) {
WorkerScript.sendMessage(msg)
}
-
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
new file mode 100644
index 0000000..14f6f17
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
@@ -0,0 +1,4 @@
+WorkerScript.onMessage = function(msg) {
+ WorkerScript.sendMessage('Hello_World')
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
new file mode 100644
index 0000000..cb3b6d3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
@@ -0,0 +1,6 @@
+.pragma library
+
+WorkerScript.onMessage = function(msg) {
+ WorkerScript.sendMessage(msg)
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
index 5c7a5ff..1a20098 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
@@ -1,24 +1,5 @@
import Qt 4.7
-WorkerScript {
- id: worker
+BaseWorker {
source: "script.js"
-
- property variant response
-
- signal done()
-
- function testSend(value) {
- worker.sendMessage(value)
- }
-
- function compareLiteralResponse(expected) {
- var e = eval('(' + expected + ')')
- return worker.response == e
- }
-
- onMessage: {
- worker.response = messageObject
- worker.done()
- }
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
new file mode 100644
index 0000000..3b720ef
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+BaseWorker {
+ source: "script_pragma.js"
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index a1dae24..7a4315a 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -64,6 +64,7 @@ private slots:
void messaging_data();
void messaging_sendQObjectList();
void messaging_sendJsObject();
+ void script_with_pragma();
private:
void waitForEchoMessage(QDeclarativeWorkerScript *worker) {
@@ -82,18 +83,25 @@ private:
void tst_QDeclarativeWorkerScript::source()
{
- QUrl source = QUrl::fromLocalFile(SRCDIR "/data/worker.qml");
-
- QDeclarativeComponent component(&m_engine);
- component.setData("import Qt 4.7\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl());
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+ const QMetaObject *mo = worker->metaObject();
- QDeclarativeWorkerScript *item = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(item != 0);
+ QVariant value(100);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
- QCOMPARE(item->source(), source);
+ QUrl source = QUrl::fromLocalFile(SRCDIR "/data/script_fixed_return.js");
+ worker->setSource(source);
+ QCOMPARE(worker->source(), source);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
qApp->processEvents();
- delete item;
+ delete worker;
}
void tst_QDeclarativeWorkerScript::messaging()
@@ -177,6 +185,25 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
delete worker;
}
+void tst_QDeclarativeWorkerScript::script_with_pragma()
+{
+ QVariant value(100);
+
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_pragma.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+
QTEST_MAIN(tst_QDeclarativeWorkerScript)
#include "tst_qdeclarativeworkerscript.moc"
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
index d948e4a..73dd4d7 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
@@ -85,7 +85,7 @@ Rectangle {
text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere
}
Text {
- text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.Wrap
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
index d10cfd3..b41b93a 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
@@ -85,7 +85,7 @@ Rectangle {
text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere
}
Text {
- text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.Wrap
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
index abb4464..a1dc5bf 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
@@ -27,7 +27,7 @@ Item {
TextEdit {
width: 150
height: 100
- wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
+ wrapMode: TextEdit.Wrap
text: "This is a test that text edit wraps correctly. thisisaverylongstringwithnospaces"
y:300
}
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 5308e98..fe323c1 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -808,7 +808,9 @@ void QDeclarativeViewer::statusChanged()
initialSize = canvas->sizeHint();
if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
updateSizeHints();
- resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight()));
+ if (!isFullScreen() && !isMaximized()) {
+ resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight()));
+ }
}
}
}