diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-22 22:39:29 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-22 22:39:29 (GMT) |
commit | c042ad25ef1cf65c163bcdd3504e8482446cbf7b (patch) | |
tree | f493da0591281db183c23c86ecc3dc078009cafa | |
parent | 5d3b132dd94f6c985fa3f9584dedb46823acddfe (diff) | |
parent | 27d59016d35ae84d89e8d09bdadb1c3a89ac3f22 (diff) | |
download | Qt-c042ad25ef1cf65c163bcdd3504e8482446cbf7b.zip Qt-c042ad25ef1cf65c163bcdd3504e8482446cbf7b.tar.gz Qt-c042ad25ef1cf65c163bcdd3504e8482446cbf7b.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:
Handle TextInput inputMethodEvent() properly
Remove transparent.qml example for now, until QTBUG-11591 is fixed
qmldir no longer necessary
Add demo thumbnails to Examples/Demos index to make it more interesting
Doc
Allow QT_TR_NOOP (as a no-op) in ListModel values.
17 files changed, 132 insertions, 104 deletions
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index e06d100..7b02d33 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -31,29 +31,82 @@ \brief Building UI's with QML \ingroup all-examples -\section1 Running the examples -You can find many simple examples in the \c examples/declarative -sub-directory that show how to use various aspects of QML. In addition, the -\c demos/declarative sub-directory contains more sophisticated demos of large -applications. These demos are intended to show integrated functionality -rather than being instructive on specific elements. +Qt includes a set of examples and demos that show how to use various aspects +of QML. The examples are small demonstrations of particular QML components, +while the demos contain more complete and functional applications. To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qmlviewer} -command-line application. It has some useful options, revealed by: +command-line application. For example, from your build directory, run: \code - bin/qmlviewer -help + bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml \endcode -For example, from your build directory, run: -\code - bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml -\endcode +\section1 Demos + +The QML demos integrate a variety of features to demonstrate how QML +can be used to produce sophisticated interfaces and applications: + + +\table +\row + +\o +\l{demos/declarative/calculator}{Calculator} +\image qml-calculator-example-small.png + +\o +\l{demos/declarative/flickr}{Flickr Mobile} +\image qml-flickr-demo-small.png + +\o +\l{demos/declarative/minehunt}{Minehunt} +\image qml-minehunt-demo-small.png + +\row + +\o +\l{demos/declarative/photoviewer}{Photo Viewer} +\image qml-photoviewer-demo-small.png + +\o +\l{demos/declarative/rssnews}{RSS News Reader} +\image qml-rssnews-demo-small.png + +\o +\l{demos/declarative/samegame}{Same Game} +\image qml-samegame-demo-small.png + +\row + +\o +\l{demos/declarative/snake}{Snake} +\image qml-snake-demo-small.png + +\o +\l{demos/declarative/twitter}{Twitter} +\image qml-twitter-demo-small.png + +\o +\l{demos/declarative/webbrowser}{Web Browser} +\image qml-webbrowser-demo-small.png + +\endtable + +The demos can be found in Qt's \c demos/declarative directory. + \section1 Examples +The QML examples are small, simple applications that show how to use a particular +QML component or feature. If you are new +to QML, you may also find the \l{QML Tutorial}{Hello World} and +\l {QML Advanced Tutorial}{Same Game} tutorials useful. + +The examples can be found in Qt's \c examples/declarative directory. + \section2 Animation \list \o \l{declarative/animation/basics}{Basics} @@ -102,6 +155,15 @@ For example, from your build directory, run: \o \l{declarative/ui-components/tabwidget}{Tab widget} \endlist +\section2 Toys +\list +\o \l{declarative/toys/clocks}{Clocks} +\o \l{declarative/toys/corkboards}{Corkboards} +\o \l{declarative/toys/dynamicscene}{Dynamic Scene} +\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} +\o \l{declarative/toys/tvtennis}{TV Tennis} +\endlist + \section2 Models and Views \list \o \l{declarative/modelviews/gridview}{GridView} @@ -114,15 +176,6 @@ For example, from your build directory, run: \o \l{declarative/modelviews/webview}{WebView} \endlist -\section2 Toys -\list -\o \l{declarative/toys/clocks}{Clocks} -\o \l{declarative/toys/corkboards}{Corkboards} -\o \l{declarative/toys/dynamicscene}{Dynamic Scene} -\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} -\o \l{declarative/toys/tvtennis}{TV Tennis} -\endlist - \section2 XML \list \o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} @@ -155,20 +208,6 @@ For example, from your build directory, run: \endlist -\section1 Demos - -\list -\o \l{demos/declarative/calculator}{Calculator} -\o \l{demos/declarative/flickr}{Flickr Mobile} -\o \l{demos/declarative/minehunt}{Minehunt} -\o \l{demos/declarative/photoviewer}{Photo Viewer} -\o \l{demos/declarative/rssnews}{RSS News Reader} -\o \l{demos/declarative/samegame}{Same Game} -\o \l{demos/declarative/snake}{Snake} -\o \l{demos/declarative/twitter}{Twitter} -\o \l{demos/declarative/webbrowser}{Web Browser} -\endlist - \section1 Labs \list diff --git a/doc/src/images/qml-calculator-example-small.png b/doc/src/images/qml-calculator-example-small.png Binary files differnew file mode 100644 index 0000000..9e0370f --- /dev/null +++ b/doc/src/images/qml-calculator-example-small.png diff --git a/doc/src/images/qml-flickr-demo-small.png b/doc/src/images/qml-flickr-demo-small.png Binary files differnew file mode 100644 index 0000000..370ffcf --- /dev/null +++ b/doc/src/images/qml-flickr-demo-small.png diff --git a/doc/src/images/qml-minehunt-demo-small.png b/doc/src/images/qml-minehunt-demo-small.png Binary files differnew file mode 100644 index 0000000..e5badac --- /dev/null +++ b/doc/src/images/qml-minehunt-demo-small.png diff --git a/doc/src/images/qml-photoviewer-demo-small.png b/doc/src/images/qml-photoviewer-demo-small.png Binary files differnew file mode 100644 index 0000000..b16fb4e --- /dev/null +++ b/doc/src/images/qml-photoviewer-demo-small.png diff --git a/doc/src/images/qml-rssnews-demo-small.png b/doc/src/images/qml-rssnews-demo-small.png Binary files differnew file mode 100644 index 0000000..451a420 --- /dev/null +++ b/doc/src/images/qml-rssnews-demo-small.png diff --git a/doc/src/images/qml-samegame-demo-small.png b/doc/src/images/qml-samegame-demo-small.png Binary files differnew file mode 100644 index 0000000..ec9ad76 --- /dev/null +++ b/doc/src/images/qml-samegame-demo-small.png diff --git a/doc/src/images/qml-snake-demo-small.png b/doc/src/images/qml-snake-demo-small.png Binary files differnew file mode 100644 index 0000000..23a7b3b --- /dev/null +++ b/doc/src/images/qml-snake-demo-small.png diff --git a/doc/src/images/qml-twitter-demo-small.png b/doc/src/images/qml-twitter-demo-small.png Binary files differnew file mode 100644 index 0000000..b55ceba --- /dev/null +++ b/doc/src/images/qml-twitter-demo-small.png diff --git a/doc/src/images/qml-webbrowser-demo-small.png b/doc/src/images/qml-webbrowser-demo-small.png Binary files differnew file mode 100644 index 0000000..6c5d57d --- /dev/null +++ b/doc/src/images/qml-webbrowser-demo-small.png diff --git a/examples/declarative/keyinteraction/focus/Core/qmldir b/examples/declarative/keyinteraction/focus/Core/qmldir deleted file mode 100644 index e25d63c..0000000 --- a/examples/declarative/keyinteraction/focus/Core/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -ContextMenu ContextMenu.qml -GridMenu GridMenu.qml -ListViews ListViews.qml -ListViewDelegate ListViewDelegate.qml diff --git a/examples/declarative/modelviews/webview/transparent.qml b/examples/declarative/modelviews/webview/transparent.qml deleted file mode 100644 index d21a88e..0000000 --- a/examples/declarative/modelviews/webview/transparent.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** 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:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import QtWebKit 1.0 - -// The WebView background is transparent -// if the HTML does not specify a background -Rectangle { - color: "green" - width: web.width - height: web.height - - WebView { - id: web - html: "Hello <b>World!</b>" - } -} diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 9e5dfb5..ec14c78 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -913,6 +913,22 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) QDeclarativePaintedItem::keyPressEvent(ev); } +void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) +{ + Q_D(QDeclarativeTextInput); + inputMethodPreHandler(ev); + if (ev->isAccepted()) + return; + if (d->control->isReadOnly()) { + ev->ignore(); + } else { + d->control->processInputMethodEvent(ev); + updateSize(); + } + if (!ev->isAccepted()) + QDeclarativePaintedItem::inputMethodEvent(ev); +} + /*! \overload Handles the given mouse \a event. @@ -993,6 +1009,7 @@ bool QDeclarativeTextInput::event(QEvent* ev) switch(ev->type()){ case QEvent::KeyPress: case QEvent::KeyRelease://###Should the control be doing anything with release? + case QEvent::InputMethod: case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMouseRelease: @@ -1000,8 +1017,6 @@ bool QDeclarativeTextInput::event(QEvent* ev) break; default: handled = d->control->processEvent(ev); - if (ev->type() == QEvent::InputMethod) - updateSize(); } if(!handled) handled = QDeclarativePaintedItem::event(ev); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index 03f55ae..6934da4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -222,6 +222,7 @@ protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void keyPressEvent(QKeyEvent* ev); + void inputMethodEvent(QInputMethodEvent *); bool event(QEvent *e); void focusInEvent(QFocusEvent *event); diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 388f252..c29005a 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -172,6 +172,29 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback } } +/*! +\qmlmethod object Qt::include(url, callback) + +Include another JavaScript file. This method can only be used from within JavaScript files, +and not regular QML files. + +Qt.include() returns an object that describes the status of the operation. The object has +a single property, \c {status} that is set to one of the following values: + +\table +\header \o Symbol \o Value \o Description +\row \o result.OK \o 0 \o The include completed successfully. +\row \o result.LOADING \o 1 \o Data is being loaded from the network. +\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url. +\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code. +An additional \c exception property will be set in this case. +\endtable + +The return object's properties will be updated as the operation progresses. + +If provided, \a callback is invoked when the operation completes. The callback is passed +the same object as is returned from the Qt.include() call. +*/ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine) { if (ctxt->argumentCount() == 0) @@ -184,7 +207,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e return ctxt->throwError(QLatin1String("Qt.include(): Can only be called from JavaScript files")); QString urlString = ctxt->argument(0).toString(); - QUrl url(ctxt->argument(0).toString()); + QUrl url(urlString); if (url.isRelative()) { url = QUrl(contextUrl).resolved(url); urlString = url.toString(); diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index ff83227..9ed21a6 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -81,8 +81,8 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM Roles (properties) must begin with a lower-case letter. The above example defines a ListModel containing three elements, with the roles "name" and "cost". - Values must be simple constants - either strings (quoted), bools (true, false), numbers, - or enum values (like Text.AlignHCenter). + Values must be simple constants - either strings (quoted and optionally within a call to QT_TR_NOOP), + bools (true, false), numbers, or enum values (like Text.AlignHCenter). The defined model can be used in views such as ListView: @@ -620,8 +620,13 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser QByteArray script = variant.asScript().toUtf8(); int v = evaluateEnum(script); if (v<0) { - error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); - return false; + if (script.startsWith("QT_TR_NOOP(\"") && script.endsWith("\")")) { + d[0] = char(QDeclarativeParser::Variant::String); + d += script.mid(12,script.length()-14); + } else { + error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); + return false; + } } else { d[0] = char(QDeclarativeParser::Variant::Number); d += QByteArray::number(v); diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index b3b6c20..3d66733 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -48,6 +48,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qdebug.h> +#include <QtCore/qtranslator.h> #include "../../../shared/util.h" @@ -124,14 +125,17 @@ void tst_qdeclarativelistmodel::waitForWorker(QDeclarativeItem *item) void tst_qdeclarativelistmodel::static_i18n() { QString expect = QString::fromUtf8("na\303\257ve"); - QString componentStr = "import Qt 4.7\nListModel { ListElement { prop1: \""+expect+"\" } }"; + + QString componentStr = "import Qt 4.7\nListModel { ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } }"; QDeclarativeEngine engine; QDeclarativeComponent component(&engine); component.setData(componentStr.toUtf8(), QUrl::fromLocalFile("")); QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create()); QVERIFY(obj != 0); - QString prop = obj->get(0).property(QLatin1String("prop1")).toString(); - QCOMPARE(prop,expect); + QString prop1 = obj->get(0).property(QLatin1String("prop1")).toString(); + QCOMPARE(prop1,expect); + QString prop2 = obj->get(0).property(QLatin1String("prop2")).toString(); + QCOMPARE(prop2,expect); // (no, not translated, QT_TR_NOOP is a no-op) delete obj; } |