aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/basictypes.qdoc15
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc229
-rw-r--r--src/declarative/items/qsgpainteditem.cpp43
-rw-r--r--src/declarative/items/qsgpainteditem.h3
-rw-r--r--src/declarative/items/qsgpainteditem_p.h1
-rw-r--r--src/declarative/items/qsgshadereffectsource.cpp38
-rw-r--r--src/declarative/items/qsgshadereffectsource_p.h8
-rw-r--r--src/declarative/items/qsgtextnode.cpp14
-rw-r--r--src/declarative/items/qsgtextnode_p.h2
-rw-r--r--src/declarative/qml/qdeclarativescarceresourcescriptclass.cpp36
-rw-r--r--src/declarative/scenegraph/qsgadaptationlayer_p.h4
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode.cpp4
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode_p.h4
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp2
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp6
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h4
-rw-r--r--tests/benchmarks/declarative/binding/data/creation.txt9
-rw-r--r--tests/benchmarks/declarative/binding/data/objectproperty.txt1
-rw-r--r--tests/benchmarks/declarative/binding/tst_binding.cpp28
-rw-r--r--tools/qmlviewer/loggerwidget.cpp14
-rw-r--r--tools/qmlviewer/main.cpp93
-rw-r--r--tools/qmlviewer/proxysettings.cpp36
-rw-r--r--tools/qmlviewer/proxysettings_maemo5.ui6
-rw-r--r--tools/qmlviewer/qdeclarativetester.cpp10
-rw-r--r--tools/qmlviewer/qmlruntime.cpp109
-rw-r--r--tools/qmlviewer/qmlviewer.pro2
26 files changed, 550 insertions, 171 deletions
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 4792bba6ef..876ab0038a 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -439,7 +439,20 @@
}
\endqml
- The \c variant type can also hold:
+ A \c variant type property can also hold an image or pixmap.
+ A \c variant which contains a QPixmap or QImage is known as a
+ "scarce resource" and the declarative engine will attempt to
+ automatically release such resources after evaluation of any JavaScript
+ expression which requires one to be copied has completed.
+
+ Clients may explicitly release such a scarce resource by calling the
+ "destroy" method on the \c variant property from within JavaScript. They
+ may also explicitly preserve the scarce resource by calling the
+ "preserve" method on the \c variant property from within JavaScript.
+ For more information regarding the usage of a scarce resource, please
+ see \l{Scarce Resources in JavaScript}.
+
+ Finally, the \c variant type can also hold:
\list
\o An array of \l {QML Basic Types}{basic type} values
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index f78f3c264d..984c81a870 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -168,6 +168,44 @@ Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions f
\c factorial.js into the \c MyScript namespace, which means the QML component can also
access \c factorial() directly as \c MyScript.factorial().
+In QtQuick 2.0, support has been added to allow JavaScript files to import other
+JavaScript files and also QML modules using a variation of the standard QML import
+syntax (where all of the previously described rules and qualifications apply).
+
+A JavaScript file may import another in the following fashion:
+\code
+.import "filename.js" as UniqueQualifier
+\endcode
+For example:
+\code
+.import "factorial.js" as MathFunctions
+\endcode
+
+A JavaScript file may import a QML module in the following fashion:
+\code
+.import Module.Name MajorVersion.MinorVersion as UniqueQualifier
+\endcode
+For example:
+\code
+.import Qt.test 1.0 as JsQtTest
+\endcode
+In particular, this may be useful in order to access functionality provided
+via a module API; see qmlRegisterModuleApi() for more information.
+
+Due to the ability of a JavaScript file to import another script or QML module in
+this fashion in QtQuick 2.0, some extra semantics are defined:
+\list
+\o a script with imports will not inherit imports from the QML file which imported it (so accessing Component.error will fail, for example)
+\o a script without imports will inherit imports from the QML file which imported it (so accessing Component.error will succeed, for example)
+\o a shared script (i.e., defined as .pragma library) does not inherit imports from any QML file even if it imports no other scripts
+\endlist
+
+The first semantic is conceptually correct, given that a particular script
+might be imported by any number of QML files. The second semantic is retained
+for the purposes of backwards-compatibility. The third semantic remains
+unchanged from the current semantics for shared scripts, but is clarified here
+in respect to the newly possible case (where the script imports other scripts
+or modules).
\section1 Running JavaScript at Startup
@@ -321,4 +359,195 @@ Item {
\endlist
+\section1 Scarce Resources in JavaScript
+
+As described in the documentation for \l{QML Basic Types}, a \c variant type
+property may hold a "scarce resource" (image or pixmap). There are several
+important semantics of scarce resources which should be noted:
+
+\list
+\o By default, a scarce resource is automatically released by the declarative engine as soon as evaluation of the expression in which the scarce resource is allocated is complete if there are no other references to the resource
+\o A client may explicitly preserve a scarce resource, which will ensure that the resource will not be released until all references to the resource are released and the JavaScript engine runs its garbage collector
+\o A client may explicitly destroy a scarce resource, which will immediately release the resource
+\endlist
+
+In most cases, allowing the engine to automatically release the resource is
+the correct choice. In some cases, however, this may result in an invalid
+variant being returned from a function in JavaScript, and in those cases it
+may be necessary for clients to manually preserve or destroy resources for
+themselves.
+
+For the following examples, imagine that we have defined the following class:
+\code
+class AvatarExample : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
+public:
+ AvatarExample(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
+ ~AvatarExample() {}
+
+ QPixmap avatar() const { return m_value; }
+ void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); }
+
+signals:
+ void avatarChanged();
+
+private:
+ QPixmap m_value;
+};
+\endcode
+
+and that we have registered it with the QML type-system as follows:
+\code
+qmlRegisterType<AvatarExample>("Qt.example", 1, 0, "AvatarExample");
+\endcode
+
+The AvatarExample class has a property which is a pixmap. When the property
+is accessed in JavaScript scope, a copy of the resource will be created and
+stored in a JavaScript object which can then be used within JavaScript. This
+copy will take up valuable system resources, and so by default the scarce
+resource copy in the JavaScript object will be released automatically by the
+declarative engine once evaluation of the JavaScript expression is complete,
+unless the client explicitly preserves it.
+
+\section2 Example One: Automatic Release
+
+In this example, the resource will be automatically
+released after the binding expression evaluation is
+complete.
+
+\qml
+// exampleOne.qml
+import QtQuick 1.0
+import Qt.example 1.0
+
+QtObject {
+ property AvatarExample a;
+ a: AvatarExample { id: example }
+ property variant avatar: example.avatar
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleOne.qml");
+QObject *object = component.create();
+// The scarce resource will have been released automatically
+// after the binding expression was evaluated.
+// Since the scarce resource was not released explicitly prior
+// to the binding expression being evaluated, we get the
+// expected result:
+//object->property("scarceResourceCopy").isValid() == true
+delete object;
+\endcode
+
+\section2 Example Two: Explicit Preservation
+
+In this example, the resource must be explicitly preserved in order
+to prevent the declarative engine from automatically releasing the
+resource after evaluation of the imported script.
+
+\code
+// exampleTwo.js
+.import Qt.example 1.0 as QtExample
+
+var component = Qt.createComponent("exampleOne.qml");
+var exampleOneElement = component.createObject(null);
+var avatarExample = exampleOneElement.a;
+var retn = avatarExample.avatar;
+
+// without the following call, the scarce resource held
+// by retn would be automatically released by the engine
+// after the import statement in exampleTwo.qml, prior
+// to the variable assignment.
+retn.preserve();
+
+function importAvatar() {
+ return retn;
+}
+\endcode
+
+\qml
+// exampleTwo.qml
+import QtQuick 1.0
+import Qt.example 1.0
+import "exampleTwo.js" as ExampleTwoJs
+
+QtObject {
+ property variant avatar: ExampleTwoJs.importAvatar()
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleTwo.qml");
+QObject *object = component.create();
+// The resource was preserved explicitly during evaluation of the
+// JavaScript expression. Thus, during property assignment, the
+// scarce resource was still valid, and so we get the expected result:
+//object->property("avatar").isValid() == true
+// The scarce resource may not have been cleaned up by the JS GC yet;
+// it will continue to consume system resources until the JS GC runs.
+delete object;
+\endcode
+
+\section2 Example Three: Explicit Destruction
+
+In the following example, we release (via destroy()) an explicitly preserved
+scarce resource variant. This example shows how a client may free system
+resources by releasing the scarce resource held in a JavaScript object, if
+required, during evaluation of a JavaScript expression.
+
+\code
+// exampleThree.js
+.import Qt.example 1.0 as QtExample
+
+var component = Qt.createComponent("exampleOne.qml");
+var exampleOneElement = component.createObject(null);
+var avatarExample = exampleOneElement.a;
+var retn = avatarExample.avatar;
+retn.preserve();
+
+function importAvatar() {
+ return retn;
+}
+
+function releaseAvatar() {
+ retn.destroy();
+}
+\endcode
+
+\qml
+// exampleThree.qml
+import QtQuick 1.0
+import Qt.example 1.0
+import "exampleThree.js" as ExampleThreeJs
+
+QtObject {
+ property variant avatarOne
+ property variant avatarTwo
+
+ Component.onCompleted: {
+ avatarOne = ExampleThreeJs.importAvatar(); // valid at this stage
+ ExampleThreeJs.releaseAvatar(); // explicit release
+ avatarTwo = ExampleThreeJs.importAvatar(); // invalid at this stage
+ }
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleThree.qml");
+QObject *object = component.create();
+// The scarce resource was explicitly preserved by the client during
+// the evaluation of the imported script, and so the scarce resource
+// remains valid until the explicit call to releaseAvatar(). As such,
+// we get the expected results:
+//object->property("avatarOne").isValid() == true
+//object->property("avatarTwo").isValid() == false
+// Because the scarce resource was released explicitly, it will no longer
+// be consuming any system resources (beyond what a normal JS Object would;
+// that small overhead will exist until the JS GC runs, as per any other
+// JavaScript object).
+delete object;
+\endcode
+
*/
diff --git a/src/declarative/items/qsgpainteditem.cpp b/src/declarative/items/qsgpainteditem.cpp
index 89cbc5e980..800e37b324 100644
--- a/src/declarative/items/qsgpainteditem.cpp
+++ b/src/declarative/items/qsgpainteditem.cpp
@@ -103,6 +103,8 @@ QSGPaintedItemPrivate::QSGPaintedItemPrivate()
, geometryDirty(false)
, contentsDirty(false)
, opaquePainting(false)
+ , antialiasing(false)
+ , mipmap(false)
{
}
@@ -226,6 +228,40 @@ void QSGPaintedItem::setAntialiasing(bool enable)
}
/*!
+ Returns true if mipmaps are enabled; otherwise, false is returned.
+
+ By default, mipmapping is not enabled.
+
+ \sa setMipmap()
+*/
+bool QSGPaintedItem::mipmap() const
+{
+ Q_D(const QSGPaintedItem);
+ return d->mipmap;
+}
+
+/*!
+ If \a enable is true, mipmapping is enabled on the associated texture.
+
+ Mipmapping increases rendering speed and reduces aliasing artifacts when the item is
+ scaled down.
+
+ By default, mipmapping is not enabled.
+
+ \sa mipmap()
+*/
+void QSGPaintedItem::setMipmap(bool enable)
+{
+ Q_D(QSGPaintedItem);
+
+ if (d->mipmap == enable)
+ return;
+
+ d->mipmap = enable;
+ update();
+}
+
+/*!
This function returns the outer bounds of the item as a rectangle; all painting must be
restricted to inside an item's bounding rect.
@@ -379,6 +415,11 @@ void QSGPaintedItem::setRenderTarget(RenderTarget target)
Reimplement this function in a QSGPaintedItem subclass to provide the
item's painting implementation, using \a painter.
+
+ \note The QML Scene Graph uses two separate threads, the main thread does things such as
+ processing events or updating animations while a second thread does the actual OpenGL rendering.
+ As a consequence, paint() is not called from the main GUI thread but from the GL enabled
+ renderer thread.
*/
/*!
@@ -416,7 +457,7 @@ QSGNode *QSGPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
node->setSize(QSize(qRound(br.width()), qRound(br.height())));
node->setSmoothPainting(d->antialiasing);
node->setLinearFiltering(d->smooth);
- node->setMipmapping(d->smooth);
+ node->setMipmapping(d->mipmap);
node->setOpaquePainting(d->opaquePainting);
node->setFillColor(d->fillColor);
node->setContentsScale(d->contentsScale);
diff --git a/src/declarative/items/qsgpainteditem.h b/src/declarative/items/qsgpainteditem.h
index 2c0884d146..a2d3a09e76 100644
--- a/src/declarative/items/qsgpainteditem.h
+++ b/src/declarative/items/qsgpainteditem.h
@@ -75,6 +75,9 @@ public:
bool antialiasing() const;
void setAntialiasing(bool enable);
+ bool mipmap() const;
+ void setMipmap(bool enable);
+
QRectF contentsBoundingRect() const;
QSize contentsSize() const;
diff --git a/src/declarative/items/qsgpainteditem_p.h b/src/declarative/items/qsgpainteditem_p.h
index ac3e09e73b..9a170d0167 100644
--- a/src/declarative/items/qsgpainteditem_p.h
+++ b/src/declarative/items/qsgpainteditem_p.h
@@ -63,6 +63,7 @@ public:
bool contentsDirty : 1;
bool opaquePainting: 1;
bool antialiasing: 1;
+ bool mipmap: 1;
};
QT_END_NAMESPACE
diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp
index 11d7f6f97e..26be39d45e 100644
--- a/src/declarative/items/qsgshadereffectsource.cpp
+++ b/src/declarative/items/qsgshadereffectsource.cpp
@@ -82,6 +82,7 @@ QSGShaderEffectTexture::QSGShaderEffectTexture(QSGItem *shaderSource)
, m_dirtyTexture(true)
, m_multisamplingSupportChecked(false)
, m_multisampling(false)
+ , m_grab(false)
{
}
@@ -124,8 +125,9 @@ void QSGShaderEffectTexture::bind()
bool QSGShaderEffectTexture::updateTexture()
{
- if (m_dirtyTexture) {
+ if ((m_live || m_grab) && m_dirtyTexture) {
grab();
+ m_grab = false;
return true;
}
return false;
@@ -181,6 +183,15 @@ void QSGShaderEffectTexture::setLive(bool live)
markDirtyTexture();
}
+void QSGShaderEffectTexture::scheduleUpdate()
+{
+ if (m_grab)
+ return;
+ m_grab = true;
+ if (m_dirtyTexture)
+ emit textureChanged();
+}
+
void QSGShaderEffectTexture::setRecursive(bool recursive)
{
m_recursive = recursive;
@@ -188,10 +199,9 @@ void QSGShaderEffectTexture::setRecursive(bool recursive)
void QSGShaderEffectTexture::markDirtyTexture()
{
- if (m_live) {
- m_dirtyTexture = true;
+ m_dirtyTexture = true;
+ if (m_live || m_grab)
emit textureChanged();
- }
}
void QSGShaderEffectTexture::grab()
@@ -360,6 +370,7 @@ QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent)
, m_hideSource(false)
, m_mipmap(false)
, m_recursive(false)
+ , m_grab(true)
{
setFlag(ItemHasContents);
m_texture = new QSGShaderEffectTexture(this);
@@ -516,17 +527,12 @@ void QSGShaderEffectSource::setRecursive(bool enabled)
emit recursiveChanged();
}
-void QSGShaderEffectSource::grab()
+void QSGShaderEffectSource::scheduleUpdate()
{
- if (!m_sourceItem)
+ if (m_grab)
return;
- QSGCanvas *canvas = m_sourceItem->canvas();
- if (!canvas)
- return;
- QSGCanvasPrivate::get(canvas)->updateDirtyNodes();
- QGLContext *glctx = const_cast<QGLContext *>(canvas->context());
- glctx->makeCurrent();
- qobject_cast<QSGShaderEffectTexture *>(m_texture)->grab();
+ m_grab = true;
+ update();
}
static void get_wrap_mode(QSGShaderEffectSource::WrapMode mode, QSGTexture::WrapMode *hWrap, QSGTexture::WrapMode *vWrap)
@@ -582,6 +588,7 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture);
+ tex->setLive(m_live);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());
QRectF sourceRect = m_sourceRect.isNull()
? QRectF(0, 0, m_sourceItem->width(), m_sourceItem->height())
@@ -591,11 +598,14 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
? QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())))
: m_textureSize;
tex->setSize(textureSize);
- tex->setLive(m_live);
tex->setRecursive(m_recursive);
tex->setFormat(GLenum(m_format));
tex->setHasMipmaps(m_mipmap);
+ if (m_grab)
+ tex->scheduleUpdate();
+ m_grab = false;
+
QSGTexture::Filtering filtering = QSGItemPrivate::get(this)->smooth
? QSGTexture::Linear
: QSGTexture::Nearest;
diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h
index 891cc1ebba..5842ec7295 100644
--- a/src/declarative/items/qsgshadereffectsource_p.h
+++ b/src/declarative/items/qsgshadereffectsource_p.h
@@ -112,7 +112,7 @@ public:
bool recursive() const { return bool(m_recursive); }
void setRecursive(bool recursive);
- void grab();
+ void scheduleUpdate();
Q_SIGNALS:
void textureChanged();
@@ -121,6 +121,8 @@ public Q_SLOTS:
void markDirtyTexture();
private:
+ void grab();
+
QSGNode *m_item;
QRectF m_rect;
QSize m_size;
@@ -141,6 +143,7 @@ private:
uint m_dirtyTexture : 1;
uint m_multisamplingSupportChecked : 1;
uint m_multisampling : 1;
+ uint m_grab : 1;
};
class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider
@@ -204,7 +207,7 @@ public:
QSGTexture *texture() const;
const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
- Q_INVOKABLE void grab();
+ Q_INVOKABLE void scheduleUpdate();
Q_SIGNALS:
void wrapModeChanged();
@@ -233,6 +236,7 @@ private:
uint m_hideSource : 1;
uint m_mipmap : 1;
uint m_recursive : 1;
+ uint m_grab : 1;
};
QT_END_NAMESPACE
diff --git a/src/declarative/items/qsgtextnode.cpp b/src/declarative/items/qsgtextnode.cpp
index a887c2360a..33325a14ab 100644
--- a/src/declarative/items/qsgtextnode.cpp
+++ b/src/declarative/items/qsgtextnode.cpp
@@ -153,7 +153,7 @@ void QSGTextNode::addTextDecorations(const QPointF &position, const QRawFont &fo
}
}
-QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphs &glyphs, const QColor &color,
+QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
QSGText::TextStyle style, const QColor &styleColor)
{
QSGGlyphNode *node = m_context->createGlyphNode();
@@ -187,10 +187,10 @@ void QSGTextNode::addTextDocument(const QPointF &position, QTextDocument *textDo
void QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color,
QSGText::TextStyle style, const QColor &styleColor)
{
- QList<QGlyphs> glyphsList(textLayout->glyphs());
+ QList<QGlyphRun> glyphsList(textLayout->glyphRuns());
for (int i=0; i<glyphsList.size(); ++i) {
- QGlyphs glyphs = glyphsList.at(i);
- QRawFont font = glyphs.font();
+ QGlyphRun glyphs = glyphsList.at(i);
+ QRawFont font = glyphs.rawFont();
addGlyphs(position + QPointF(0, font.ascent()), glyphs, color, style, styleColor);
}
@@ -356,10 +356,10 @@ void QSGTextNode::addTextBlock(const QPointF &position, QTextDocument *textDocum
? overrideColor
: charFormat.foreground().color();
- QList<QGlyphs> glyphsList = fragment.glyphs();
+ QList<QGlyphRun> glyphsList = fragment.glyphRuns();
for (int i=0; i<glyphsList.size(); ++i) {
- QGlyphs glyphs = glyphsList.at(i);
- QRawFont font = glyphs.font();
+ QGlyphRun glyphs = glyphsList.at(i);
+ QRawFont font = glyphs.rawFont();
QSGGlyphNode *glyphNode = addGlyphs(position + blockPosition + QPointF(0, font.ascent()),
glyphs, color, style, styleColor);
diff --git a/src/declarative/items/qsgtextnode_p.h b/src/declarative/items/qsgtextnode_p.h
index e7bd95faee..7a49f51dbe 100644
--- a/src/declarative/items/qsgtextnode_p.h
+++ b/src/declarative/items/qsgtextnode_p.h
@@ -72,7 +72,7 @@ public:
private:
void addTextBlock(const QPointF &position, QTextDocument *textDocument, const QTextBlock &block,
const QColor &overrideColor, QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor());
- QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphs &glyphs, const QColor &color,
+ QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor());
void addTextDecorations(const QPointF &position, const QRawFont &font, const QColor &color,
qreal width, bool hasOverline, bool hasStrikeOut, bool hasUnderline);
diff --git a/src/declarative/qml/qdeclarativescarceresourcescriptclass.cpp b/src/declarative/qml/qdeclarativescarceresourcescriptclass.cpp
index 121d0a1a35..d94e2d9332 100644
--- a/src/declarative/qml/qdeclarativescarceresourcescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativescarceresourcescriptclass.cpp
@@ -144,9 +144,22 @@ QDeclarativeScarceResourceScriptClass::property(Object *object, const Identifier
}
/*
- The user explicitly wants to preserve the resource.
- We remove the scarce resource from the engine's linked list
- of resources to release after evaluation completes.
+ This method is called when the user explicitly calls the "preserve" method of a scarce resource in JavaScript
+ within the specified evaluation context \a context of the script engine \a engine.
+ Calling this function signifies that the user explicitly wants to preserve the resource rather than let it
+ be automatically released once evaluation of the expression is complete.
+ This function removes the internal scarce resource from the declarative engine's linked list of scarce resources
+ to release after evaluation of the expression completes. This means that the resource will only be truly
+ released when the JavaScript engine's garbage collector is run.
+
+ Example:
+ \qml
+ function getIcon(model) {
+ var icon = model.avatar; // a pixmap property
+ icon.preserve(); // explicitly preserves the resource
+ return icon; // a valid variant will be returned
+ }
+ \endqml
*/
QScriptValue QDeclarativeScarceResourceScriptClass::preserve(QScriptContext *context, QScriptEngine *engine)
{
@@ -168,8 +181,21 @@ QScriptValue QDeclarativeScarceResourceScriptClass::preserve(QScriptContext *con
}
/*
- The user explicitly wants to release the resource.
- We set the internal scarce resource variant to the invalid variant.
+ This method is called when the user explicitly calls the "destroy" method of a scarce resource in JavaScript
+ within the specified evaluation context \a context of the script engine \a engine.
+ Calling this function signifies that the user explicitly wants to release the resource.
+ This function sets the internal scarce resource variant to the invalid variant, in order to release the original resource,
+ and then removes the resource from the declarative engine's linked-list of scarce resources to
+ to release after evaluation of the expression completes, as it has already been released.
+
+ Example:
+ \qml
+ function getIcon(model) {
+ var icon = model.avatar; // a pixmap property
+ icon.destroy(); // explicitly releases the resource
+ return icon; // an invalid variant will be returned
+ }
+ \endqml
*/
QScriptValue QDeclarativeScarceResourceScriptClass::destroy(QScriptContext *context, QScriptEngine *engine)
{
diff --git a/src/declarative/scenegraph/qsgadaptationlayer_p.h b/src/declarative/scenegraph/qsgadaptationlayer_p.h
index 22d202d404..e0748de837 100644
--- a/src/declarative/scenegraph/qsgadaptationlayer_p.h
+++ b/src/declarative/scenegraph/qsgadaptationlayer_p.h
@@ -49,7 +49,7 @@
#include <QtCore/qrect.h>
#include <QtGui/qcolor.h>
#include <QtCore/qsharedpointer.h>
-#include <QtGui/qglyphs.h>
+#include <QtGui/qglyphrun.h>
#include <QtCore/qurl.h>
QT_BEGIN_HEADER
@@ -103,7 +103,7 @@ public:
SubPixelAntialiasing
};
- virtual void setGlyphs(const QPointF &position, const QGlyphs &glyphs) = 0;
+ virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) = 0;
virtual void setColor(const QColor &color) = 0;
virtual QPointF baseLine() const = 0;
diff --git a/src/declarative/scenegraph/qsgdefaultglyphnode.cpp b/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
index 57482a9cf4..a5a28a334e 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
@@ -69,12 +69,12 @@ void QSGDefaultGlyphNode::setColor(const QColor &color)
}
}
-void QSGDefaultGlyphNode::setGlyphs(const QPointF &position, const QGlyphs &glyphs)
+void QSGDefaultGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
{
if (m_material != 0)
delete m_material;
- QRawFont font = glyphs.font();
+ QRawFont font = glyphs.rawFont();
m_material = new QSGTextMaskMaterial(font);
m_material->setColor(m_color);
diff --git a/src/declarative/scenegraph/qsgdefaultglyphnode_p.h b/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
index 9e93bc4368..1f1319781c 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
@@ -60,13 +60,13 @@ public:
~QSGDefaultGlyphNode();
virtual QPointF baseLine() const { return m_baseLine; }
- virtual void setGlyphs(const QPointF &position, const QGlyphs &glyphs);
+ virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs);
virtual void setColor(const QColor &color);
virtual void setPreferredAntialiasingMode(AntialiasingMode) { }
private:
- QGlyphs m_glyphs;
+ QGlyphRun m_glyphs;
QPointF m_position;
QColor m_color;
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
index 318fc4a009..a21fccefcf 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
@@ -49,7 +49,7 @@
#include <private/qsgcontext_p.h>
#include <private/qrawfont_p.h>
#include <qglfunctions.h>
-#include <qglyphs.h>
+#include <qglyphrun.h>
#include <qrawfont.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
index ed2dba1ea3..d826f7f1e7 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -87,9 +87,9 @@ void QSGDistanceFieldGlyphNode::setPreferredAntialiasingMode(AntialiasingMode mo
updateMaterial();
}
-void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphs &glyphs)
+void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
{
- QRawFont font = glyphs.font();
+ QRawFont font = glyphs.rawFont();
m_position = QPointF(position.x(), position.y() - font.ascent());
m_glyphs = glyphs;
@@ -187,7 +187,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
void QSGDistanceFieldGlyphNode::updateFont()
{
- m_glyph_cache = QSGDistanceFieldGlyphCache::get(QGLContext::currentContext(), m_glyphs.font());
+ m_glyph_cache = QSGDistanceFieldGlyphCache::get(QGLContext::currentContext(), m_glyphs.rawFont());
}
void QSGDistanceFieldGlyphNode::updateMaterial()
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
index d42f187af3..e97972579c 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
@@ -61,7 +61,7 @@ public:
~QSGDistanceFieldGlyphNode();
virtual QPointF baseLine() const { return m_baseLine; }
- virtual void setGlyphs(const QPointF &position, const QGlyphs &glyphs);
+ virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs);
virtual void setColor(const QColor &color);
virtual void setPreferredAntialiasingMode(AntialiasingMode mode);
@@ -78,7 +78,7 @@ private:
QPointF m_baseLine;
QSGDistanceFieldTextMaterial *m_material;
QPointF m_position;
- QGlyphs m_glyphs;
+ QGlyphRun m_glyphs;
QSGDistanceFieldGlyphCache *m_glyph_cache;
QSGGeometry m_geometry;
QSGText::TextStyle m_style;
diff --git a/tests/benchmarks/declarative/binding/data/creation.txt b/tests/benchmarks/declarative/binding/data/creation.txt
new file mode 100644
index 0000000000..05704fa341
--- /dev/null
+++ b/tests/benchmarks/declarative/binding/data/creation.txt
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyQmlObject {
+ id: myObject
+ property int myValue: 1
+ object: myObject
+
+ result: ###
+}
diff --git a/tests/benchmarks/declarative/binding/data/objectproperty.txt b/tests/benchmarks/declarative/binding/data/objectproperty.txt
index 6133dd648b..06409f2dd1 100644
--- a/tests/benchmarks/declarative/binding/data/objectproperty.txt
+++ b/tests/benchmarks/declarative/binding/data/objectproperty.txt
@@ -2,6 +2,7 @@ import Test 1.0
MyQmlObject {
id: myObject
+ object: myObject
result: ###
}
diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp
index b1306527aa..d9ab06a537 100644
--- a/tests/benchmarks/declarative/binding/tst_binding.cpp
+++ b/tests/benchmarks/declarative/binding/tst_binding.cpp
@@ -41,6 +41,7 @@
#include <qtest.h>
#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
#include <QDeclarativeComponent>
#include <QFile>
#include <QDebug>
@@ -70,9 +71,12 @@ private slots:
void objectproperty();
void basicproperty_data();
void basicproperty();
+ void creation_data();
+ void creation();
private:
QDeclarativeEngine engine;
+ MyQmlObject tstObject;
};
tst_binding::tst_binding()
@@ -86,6 +90,7 @@ tst_binding::~tst_binding()
void tst_binding::initTestCase()
{
registerTypes();
+ engine.rootContext()->setContextProperty("tstObject", &tstObject);
}
void tst_binding::cleanupTestCase()
@@ -162,5 +167,28 @@ void tst_binding::basicproperty()
}
}
+void tst_binding::creation_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("binding");
+
+ QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10";
+ QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value";
+ QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue";
+ QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value";
+}
+
+void tst_binding::creation()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, binding);
+
+ COMPONENT(file, binding);
+
+ QBENCHMARK {
+ c.create();
+ }
+}
+
QTEST_MAIN(tst_binding)
#include "tst_binding.moc"
diff --git a/tools/qmlviewer/loggerwidget.cpp b/tools/qmlviewer/loggerwidget.cpp
index 3f2337a622..9a07402eb0 100644
--- a/tools/qmlviewer/loggerwidget.cpp
+++ b/tools/qmlviewer/loggerwidget.cpp
@@ -139,10 +139,10 @@ QAction *LoggerWidget::showAction()
void LoggerWidget::readSettings()
{
QSettings settings;
- QString warningsPreferences = settings.value("warnings", "hide").toString();
- if (warningsPreferences == "show") {
+ QString warningsPreferences = settings.value(QLatin1String("warnings"), QLatin1String("hide")).toString();
+ if (warningsPreferences == QLatin1String("show")) {
m_visibility = ShowWarnings;
- } else if (warningsPreferences == "hide") {
+ } else if (warningsPreferences == QLatin1String("hide")) {
m_visibility = HideWarnings;
} else {
m_visibility = AutoShowWarnings;
@@ -154,15 +154,15 @@ void LoggerWidget::saveSettings()
if (m_visibilityOrigin != SettingsOrigin)
return;
- QString value = "autoShow";
+ QString value = QLatin1String("autoShow");
if (defaultVisibility() == ShowWarnings) {
- value = "show";
+ value = QLatin1String("show");
} else if (defaultVisibility() == HideWarnings) {
- value = "hide";
+ value = QLatin1String("hide");
}
QSettings settings;
- settings.setValue("warnings", value);
+ settings.setValue(QLatin1String("warnings"), value);
}
void LoggerWidget::warningsPreferenceChanged(QAction *action)
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index b1a10ff6c4..24a4940915 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -50,6 +50,7 @@
#include <QDebug>
#include <QMessageBox>
#include <QAtomicInt>
+#include <QLibraryInfo>
#include "qdeclarativetester.h"
#include <private/qdeclarativedebughelper_p.h>
@@ -67,7 +68,7 @@ void exitApp(int i)
// Debugging output is not visible by default on Windows -
// therefore show modal dialog with errors instead.
if (!warnings.isEmpty()) {
- QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings);
+ QMessageBox::warning(0, QApplication::translate("QDeclarativeViewer", "Qt QML Viewer"), warnings);
}
#endif
exit(i);
@@ -123,7 +124,7 @@ void myMessageOutput(QtMsgType type, const char *msg)
static QDeclarativeViewer* globalViewer = 0;
// The qml file that is shown if the user didn't specify a QML file
-QString initialFile = "qrc:/startup/startup.qml";
+QString initialFile = QLatin1String("qrc:/startup/startup.qml");
void usage()
{
@@ -199,7 +200,7 @@ struct ViewerOptions
fps(0.0),
autorecord_from(0),
autorecord_to(0),
- dither("none"),
+ dither(QLatin1String("none")),
runScript(false),
devkeys(false),
cache(0),
@@ -336,54 +337,54 @@ static void parseCommandLineOptions(const QStringList &arguments)
for (int i = 1; i < arguments.count(); ++i) {
bool lastArg = (i == arguments.count() - 1);
QString arg = arguments.at(i);
- if (arg == "-frameless") {
+ if (arg == QLatin1String("-frameless")) {
opts.frameless = true;
- } else if (arg == "-maximized") {
+ } else if (arg == QLatin1String("-maximized")) {
opts.maximized = true;
- } else if (arg == "-fullscreen") {
+ } else if (arg == QLatin1String("-fullscreen")) {
opts.fullScreen = true;
- } else if (arg == "-stayontop") {
+ } else if (arg == QLatin1String("-stayontop")) {
opts.stayOnTop = true;
- } else if (arg == "-netcache") {
+ } else if (arg == QLatin1String("-netcache")) {
if (lastArg) usage();
opts.cache = arguments.at(++i).toInt();
- } else if (arg == "-recordrate") {
+ } else if (arg == QLatin1String("-recordrate")) {
if (lastArg) usage();
opts.fps = arguments.at(++i).toDouble();
- } else if (arg == "-recordfile") {
+ } else if (arg == QLatin1String("-recordfile")) {
if (lastArg) usage();
opts.recordfile = arguments.at(++i);
- } else if (arg == "-record") {
+ } else if (arg == QLatin1String("-record")) {
if (lastArg) usage();
opts.recordargs << arguments.at(++i);
- } else if (arg == "-recorddither") {
+ } else if (arg == QLatin1String("-recorddither")) {
if (lastArg) usage();
opts.dither = arguments.at(++i);
- } else if (arg == "-autorecord") {
+ } else if (arg == QLatin1String("-autorecord")) {
if (lastArg) usage();
QString range = arguments.at(++i);
- int dash = range.indexOf('-');
+ int dash = range.indexOf(QLatin1Char('-'));
if (dash > 0)
opts.autorecord_from = range.left(dash).toInt();
opts.autorecord_to = range.mid(dash+1).toInt();
- } else if (arg == "-devicekeys") {
+ } else if (arg == QLatin1String("-devicekeys")) {
opts.devkeys = true;
- } else if (arg == "-dragthreshold") {
+ } else if (arg == QLatin1String("-dragthreshold")) {
if (lastArg) usage();
qApp->setStartDragDistance(arguments.at(++i).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
qWarning("Qt QML Viewer version %s", QT_VERSION_STR);
exitApp(0);
- } else if (arg == "-translation") {
+ } else if (arg == QLatin1String("-translation")) {
if (lastArg) usage();
opts.translationFile = arguments.at(++i);
- } else if (arg == "-no-opengl") {
+ } else if (arg == QLatin1String("-no-opengl")) {
opts.useGL = false;
- } else if (arg == "-opengl") {
+ } else if (arg == QLatin1String("-opengl")) {
opts.useGL = true;
- } else if (arg == "-qmlbrowser") {
+ } else if (arg == QLatin1String("-qmlbrowser")) {
opts.useNativeFileBrowser = false;
- } else if (arg == "-warnings") {
+ } else if (arg == QLatin1String("-warnings")) {
if (lastArg) usage();
QString warningsStr = arguments.at(++i);
if (warningsStr == QLatin1String("show")) {
@@ -393,8 +394,8 @@ static void parseCommandLineOptions(const QStringList &arguments)
} else {
usage();
}
- } else if (arg == "-I" || arg == "-L") {
- if (arg == "-L")
+ } else if (arg == QLatin1String("-I") || arg == QLatin1String("-L")) {
+ if (arg == QLatin1String("-L"))
qWarning("-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
@@ -403,32 +404,32 @@ static void parseCommandLineOptions(const QStringList &arguments)
exitApp(0);
}
opts.imports << arguments.at(++i);
- } else if (arg == "-P") {
+ } else if (arg == QLatin1String("-P")) {
if (lastArg) usage();
opts.plugins << arguments.at(++i);
- } else if (arg == "-script") {
+ } else if (arg == QLatin1String("-script")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
- } else if (arg == "-scriptopts") {
+ } else if (arg == QLatin1String("-scriptopts")) {
if (lastArg) usage();
opts.scriptopts = arguments.at(++i);
- } else if (arg == "-savescript") {
+ } else if (arg == QLatin1String("-savescript")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = false;
- } else if (arg == "-playscript") {
+ } else if (arg == QLatin1String("-playscript")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = true;
- } else if (arg == "-sizeviewtorootobject") {
+ } else if (arg == QLatin1String("-sizeviewtorootobject")) {
opts.sizeToView = false;
- } else if (arg == "-sizerootobjecttoview") {
+ } else if (arg == QLatin1String("-sizerootobjecttoview")) {
opts.sizeToView = true;
- } else if (arg == "-experimentalgestures") {
+ } else if (arg == QLatin1String("-experimentalgestures")) {
opts.experimentalGestures = true;
- } else if (!arg.startsWith('-')) {
+ } else if (!arg.startsWith(QLatin1Char('-'))) {
fileNames.append(arg);
- } else if (true || arg == "-help") {
+ } else if (true || arg == QLatin1String("-help")) {
usage();
}
}
@@ -521,37 +522,47 @@ QDeclarativeViewer *openFile(const QString &fileName)
int main(int argc, char ** argv)
{
- QDeclarativeDebugHelper::enableDebugging();
-
systemMsgOutput = qInstallMsgHandler(myMessageOutput);
#if defined (Q_WS_X11) || defined (Q_WS_MAC)
//### default to using raster graphics backend for now
bool gsSpecified = false;
for (int i = 0; i < argc; ++i) {
- QString arg = argv[i];
- if (arg == "-graphicssystem") {
+ QString arg = QString::fromAscii(argv[i]);
+ if (arg == QLatin1String("-graphicssystem")) {
gsSpecified = true;
break;
}
}
if (!gsSpecified)
- QApplication::setGraphicsSystem("raster");
+ QApplication::setGraphicsSystem(QLatin1String("raster"));
#endif
QDeclarativeDebugHelper::enableDebugging();
Application app(argc, argv);
- app.setApplicationName("QtQmlViewer");
- app.setOrganizationName("Nokia");
- app.setOrganizationDomain("nokia.com");
+ app.setApplicationName(QLatin1String("QtQmlViewer"));
+ app.setOrganizationName(QLatin1String("Nokia"));
+ app.setOrganizationDomain(QLatin1String("nokia.com"));
QDeclarativeViewer::registerTypes();
QDeclarativeTester::registerTypes();
parseCommandLineOptions(app.arguments());
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ if (translator.load(QLatin1String("qmlviewer_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ app.installTranslator(&translator);
+ if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ app.installTranslator(&qtTranslator);
+ } else {
+ app.removeTranslator(&translator);
+ }
+ }
+
QTranslator qmlTranslator;
if (!opts.translationFile.isEmpty()) {
if (qmlTranslator.load(opts.translationFile)) {
diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp
index c4dc087263..78963da9a6 100644
--- a/tools/qmlviewer/proxysettings.cpp
+++ b/tools/qmlviewer/proxysettings.cpp
@@ -54,17 +54,17 @@ ProxySettings::ProxySettings (QWidget * parent)
#if !defined Q_WS_MAEMO_5
// the onscreen keyboard can't cope with masks
- proxyServerEdit->setInputMask ("000.000.000.000;_");
+ proxyServerEdit->setInputMask(QLatin1String("000.000.000.000;_"));
#endif
QIntValidator *validator = new QIntValidator (0, 9999, this);
- proxyPortEdit->setValidator (validator);
+ proxyPortEdit->setValidator(validator);
QSettings settings;
- proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ());
- proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ());
- proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ());
- usernameEdit->insert (settings.value ("http_proxy/username", "").toString ());
- passwordEdit->insert (settings.value ("http_proxy/password", "").toString ());
+ proxyCheckBox->setChecked(settings.value(QLatin1String("http_proxy/use"), 0).toBool());
+ proxyServerEdit->insert(settings.value(QLatin1String("http_proxy/hostname")).toString());
+ proxyPortEdit->insert(settings.value(QLatin1String("http_proxy/port"), QLatin1String("80")).toString ());
+ usernameEdit->insert(settings.value(QLatin1String("http_proxy/username")).toString ());
+ passwordEdit->insert(settings.value(QLatin1String("http_proxy/password")).toString ());
}
ProxySettings::~ProxySettings()
@@ -75,11 +75,11 @@ void ProxySettings::accept ()
{
QSettings settings;
- settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ());
- settings.setValue ("http_proxy/hostname", proxyServerEdit->text ());
- settings.setValue ("http_proxy/port", proxyPortEdit->text ());
- settings.setValue ("http_proxy/username", usernameEdit->text ());
- settings.setValue ("http_proxy/password", passwordEdit->text ());
+ settings.setValue(QLatin1String("http_proxy/use"), proxyCheckBox->isChecked());
+ settings.setValue(QLatin1String("http_proxy/hostname"), proxyServerEdit->text());
+ settings.setValue(QLatin1String("http_proxy/port"), proxyPortEdit->text());
+ settings.setValue(QLatin1String("http_proxy/username"), usernameEdit->text());
+ settings.setValue(QLatin1String("http_proxy/password"), passwordEdit->text());
QDialog::accept ();
}
@@ -89,13 +89,13 @@ QNetworkProxy ProxySettings::httpProxy ()
QSettings settings;
QNetworkProxy proxy;
- bool proxyInUse = settings.value ("http_proxy/use", 0).toBool ();
+ bool proxyInUse = settings.value(QLatin1String("http_proxy/use"), 0).toBool();
if (proxyInUse) {
proxy.setType (QNetworkProxy::HttpProxy);
- proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5"
- proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080
- proxy.setUser (settings.value ("http_proxy/username", "").toString ());
- proxy.setPassword (settings.value ("http_proxy/password", "").toString ());
+ proxy.setHostName (settings.value(QLatin1String("http_proxy/hostname")).toString());// "192.168.220.5"
+ proxy.setPort (settings.value(QLatin1String("http_proxy/port"), 80).toInt()); // 8080
+ proxy.setUser (settings.value(QLatin1String("http_proxy/username")).toString());
+ proxy.setPassword (settings.value(QLatin1String("http_proxy/password")).toString());
//QNetworkProxy::setApplicationProxy (proxy);
}
else {
@@ -107,7 +107,7 @@ QNetworkProxy ProxySettings::httpProxy ()
bool ProxySettings::httpProxyInUse()
{
QSettings settings;
- return settings.value ("http_proxy/use", 0).toBool ();
+ return settings.value(QLatin1String("http_proxy/use"), 0).toBool();
}
QT_END_NAMESPACE
diff --git a/tools/qmlviewer/proxysettings_maemo5.ui b/tools/qmlviewer/proxysettings_maemo5.ui
index 83f0c2a9de..75875d835b 100644
--- a/tools/qmlviewer/proxysettings_maemo5.ui
+++ b/tools/qmlviewer/proxysettings_maemo5.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>449</width>
- <height>164</height>
+ <width>447</width>
+ <height>162</height>
</rect>
</property>
<property name="windowTitle">
@@ -88,7 +88,7 @@
<item row="1" column="1">
<widget class="QLineEdit" name="proxyPortEdit">
<property name="text">
- <string>8080</string>
+ <string notr="true">8080</string>
</property>
</widget>
</item>
diff --git a/tools/qmlviewer/qdeclarativetester.cpp b/tools/qmlviewer/qdeclarativetester.cpp
index 11f81fc169..fa8af8f314 100644
--- a/tools/qmlviewer/qdeclarativetester.cpp
+++ b/tools/qmlviewer/qdeclarativetester.cpp
@@ -205,7 +205,7 @@ void QDeclarativeTester::save()
QString filename = m_script + QLatin1String(".qml");
QFileInfo filenameInfo(filename);
QDir saveDir = filenameInfo.absoluteDir();
- saveDir.mkpath(".");
+ saveDir.mkpath(QLatin1String("."));
QFile file(filename);
file.open(QIODevice::WriteOnly);
@@ -224,8 +224,8 @@ void QDeclarativeTester::save()
if (!fe.hash.isEmpty()) {
ts << " hash: \"" << fe.hash.toHex() << "\"\n";
} else if (!fe.image.isNull()) {
- QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png";
- fe.image.save(m_script + "." + QString::number(imgCount) + ".png");
+ QString filename = filenameInfo.baseName() + QLatin1String(".") + QString::number(imgCount) + QLatin1String(".png");
+ fe.image.save(m_script + QLatin1String(".") + QString::number(imgCount) + QLatin1String(".png"));
imgCount++;
ts << " image: \"" << filename << "\"\n";
}
@@ -375,7 +375,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
imagefailure();
}
if (goodImage != img) {
- QString reject(frame->image().toLocalFile() + ".reject.png");
+ QString reject(frame->image().toLocalFile() + QLatin1String(".reject.png"));
qWarning() << "QDeclarativeTester(" << m_script << "): Image mismatch. Reject saved to:"
<< reject;
img.save(reject);
@@ -393,7 +393,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
}
}
}
- QString diff(frame->image().toLocalFile() + ".diff.png");
+ QString diff(frame->image().toLocalFile() + QLatin1String(".diff.png"));
diffimg.save(diff);
qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff;
}
diff --git a/tools/qmlviewer/qmlruntime.cpp b/tools/qmlviewer/qmlruntime.cpp
index 4bae7f3ec0..e49c7f3d42 100644
--- a/tools/qmlviewer/qmlruntime.cpp
+++ b/tools/qmlviewer/qmlruntime.cpp
@@ -265,7 +265,7 @@ public:
hz->setValidator(new QDoubleValidator(hz));
#endif
for (int i=0; ffmpegprofiles[i].name; ++i) {
- profile->addItem(ffmpegprofiles[i].name);
+ profile->addItem(QString::fromAscii(ffmpegprofiles[i].name));
}
}
@@ -273,9 +273,9 @@ public:
{
int i;
for (i=0; ffmpegprofiles[i].args[0]; ++i) {
- if (ffmpegprofiles[i].args == a) {
+ if (QString::fromAscii(ffmpegprofiles[i].args) == a) {
profile->setCurrentIndex(i);
- args->setText(QLatin1String(ffmpegprofiles[i].args));
+ args->setText(QString::fromAscii(ffmpegprofiles[i].args));
return;
}
}
@@ -465,14 +465,14 @@ private:
}
}
QSettings settings;
- settings.setValue("Cookies",data);
+ settings.setValue(QLatin1String("Cookies"), data);
}
void load()
{
QMutexLocker lock(&mutex);
QSettings settings;
- QByteArray data = settings.value("Cookies").toByteArray();
+ QByteArray data = settings.value(QLatin1String("Cookies")).toByteArray();
setAllCookies(QNetworkCookie::parseCookies(data));
}
@@ -490,7 +490,7 @@ public:
if (proxyDirty)
setupProxy();
QString protocolTag = query.protocolTag();
- if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
+ if (httpProxyInUse && (protocolTag == QLatin1String("http") || protocolTag == QLatin1String("https"))) {
QList<QNetworkProxy> ret;
ret << httpProxy;
return ret;
@@ -597,7 +597,7 @@ QString QDeclarativeViewer::getVideoFileName()
if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)");
types += tr("Individual PNG frames")+QLatin1String(" (*.png)");
if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)");
- return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
+ return QFileDialog::getSaveFileName(this, title, QString(), types.join(QLatin1String(";; ")));
}
QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
@@ -725,18 +725,18 @@ void QDeclarativeViewer::createMenu()
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this);
- snapshotAction->setShortcut(QKeySequence("F3"));
+ snapshotAction->setShortcut(QKeySequence(tr("F3")));
connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
recordAction = new QAction(tr("Start Recording &Video"), this);
- recordAction->setShortcut(QKeySequence("F9"));
+ recordAction->setShortcut(QKeySequence(tr("F9")));
connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
QAction *recordOptions = new QAction(tr("Video &Options..."), this);
connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
QAction *slowAction = new QAction(tr("&Slow Down Animations"), this);
- slowAction->setShortcut(QKeySequence("Ctrl+."));
+ slowAction->setShortcut(QKeySequence(tr("Ctrl+.")));
slowAction->setCheckable(true);
connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
@@ -755,7 +755,7 @@ void QDeclarativeViewer::createMenu()
connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
rotateAction = new QAction(tr("Rotate orientation"), this);
- rotateAction->setShortcut(QKeySequence("Ctrl+T"));
+ rotateAction->setShortcut(QKeySequence(tr("Ctrl+T")));
connect(rotateAction, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
orientation = new QActionGroup(this);
@@ -963,7 +963,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
// Profile
- recdlg->setArguments(record_args.join(" "));
+ recdlg->setArguments(record_args.join(QLatin1String(" ")));
if (recdlg->exec()) {
// File
record_file = recdlg->file->text();
@@ -972,7 +972,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
// Rate
record_rate = recdlg->videoRate();
// Profile
- record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
+ record_args = recdlg->arguments().split(QLatin1Char(' '),QString::SkipEmptyParts);
}
}
@@ -983,8 +983,8 @@ void QDeclarativeViewer::toggleRecordingWithSelection()
QString fileName = getVideoFileName();
if (fileName.isEmpty())
return;
- if (!fileName.contains(QRegExp(".[^\\/]*$")))
- fileName += ".avi";
+ if (!fileName.contains(QRegExp(QLatin1String(".[^\\/]*$"))))
+ fileName += QLatin1String(".avi");
setRecordFile(fileName);
}
}
@@ -1026,7 +1026,7 @@ void QDeclarativeViewer::openFile()
{
QString cur = canvas->source().toLocalFile();
if (useQmlFileBrowser) {
- open("qrc:/browser/Browser.qml");
+ open(QLatin1String("qrc:/browser/Browser.qml"));
} else {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
if (!fileName.isEmpty()) {
@@ -1072,7 +1072,7 @@ void QDeclarativeViewer::loadTranslationFile(const QString& directory)
void QDeclarativeViewer::loadDummyDataFiles(const QString& directory)
{
- QDir dir(directory+"/dummydata", "*.qml");
+ QDir dir(directory + QLatin1String("/dummydata"), QLatin1String("*.qml"));
QStringList list = dir.entryList();
for (int i = 0; i < list.size(); ++i) {
QString qml = list.at(i);
@@ -1114,14 +1114,14 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
delete canvas->rootObject();
canvas->engine()->clearComponentCache();
QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("qmlViewer", this);
+ ctxt->setContextProperty(QLatin1String("qmlViewer"), this);
#ifdef Q_OS_SYMBIAN
- ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
+ ctxt->setContextProperty(QLatin1String("qmlViewerFolder"), QLatin1String("E:\\")); // Documents on your S60 phone
#else
- ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
+ ctxt->setContextProperty(QLatin1String("qmlViewerFolder"), QDir::currentPath());
#endif
- ctxt->setContextProperty("runtime", Runtime::instance());
+ ctxt->setContextProperty(QLatin1String("runtime"), Runtime::instance());
QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
@@ -1224,26 +1224,26 @@ bool QDeclarativeViewer::event(QEvent *event)
void QDeclarativeViewer::senseImageMagick()
{
QProcess proc;
- proc.start("convert", QStringList() << "-h");
+ proc.start(QLatin1String("convert"), QStringList() << QLatin1String("-h"));
proc.waitForFinished(2000);
- QString help = proc.readAllStandardOutput();
- convertAvailable = help.contains("ImageMagick");
+ QString help = QString::fromAscii(proc.readAllStandardOutput());
+ convertAvailable = help.contains(QLatin1String("ImageMagick"));
}
void QDeclarativeViewer::senseFfmpeg()
{
QProcess proc;
- proc.start("ffmpeg", QStringList() << "-h");
+ proc.start(QLatin1String("ffmpeg"), QStringList() << QLatin1String("-h"));
proc.waitForFinished(2000);
- QString ffmpegHelp = proc.readAllStandardOutput();
- ffmpegAvailable = ffmpegHelp.contains("-s ");
- ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp;
+ QString ffmpegHelp = QString::fromAscii(proc.readAllStandardOutput());
+ ffmpegAvailable = ffmpegHelp.contains(QLatin1String("-s "));
+ ffmpegHelp = tr("Video recording uses ffmpeg:") + QLatin1String("\n\n") + ffmpegHelp;
QDialog *d = new QDialog(recdlg);
QVBoxLayout *l = new QVBoxLayout(d);
QTextBrowser *b = new QTextBrowser(d);
QFont f = b->font();
- f.setFamily("courier");
+ f.setFamily(QLatin1String("courier"));
b->setFont(f);
b->setText(ffmpegHelp);
l->addWidget(b);
@@ -1266,7 +1266,7 @@ void QDeclarativeViewer::setRecording(bool on)
recordTimer.start();
frame_fmt = record_file.right(4).toLower();
frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32);
- if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) {
+ if (frame_fmt != QLatin1String(".png") && (!convertAvailable || frame_fmt != QLatin1String(".gif"))) {
// Stream video to ffmpeg
QProcess *proc = new QProcess(this);
@@ -1274,19 +1274,19 @@ void QDeclarativeViewer::setRecording(bool on)
frame_stream = proc;
QStringList args;
- args << "-y";
- args << "-r" << QString::number(record_rate);
- args << "-f" << "rawvideo";
- args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32");
- args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height());
- args << "-i" << "-";
+ args << QLatin1String("-y");
+ args << QLatin1String("-r") << QString::number(record_rate);
+ args << QLatin1String("-f") << QLatin1String("rawvideo");
+ args << QLatin1String("-pix_fmt") << (frame_fmt == QLatin1String(".gif") ? QLatin1String("rgb24") : QLatin1String("rgb32"));
+ args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(canvas->width()).arg(canvas->height());
+ args << QLatin1String("-i") << QLatin1String("-");
if (record_outsize.isValid()) {
- args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
- args << "-aspect" << QString::number(double(canvas->width())/canvas->height());
+ args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
+ args << QLatin1String("-aspect") << QString::number(double(canvas->width())/canvas->height());
}
args += record_args;
args << record_file;
- proc->start("ffmpeg",args);
+ proc->start(QLatin1String("ffmpeg"), args);
} else {
// Store frames, save to GIF/PNG
@@ -1309,14 +1309,14 @@ void QDeclarativeViewer::setRecording(bool on)
QString framename;
bool png_output = false;
- if (record_file.right(4).toLower()==".png") {
- if (record_file.contains('%'))
+ if (record_file.right(4).toLower() == QLatin1String(".png")) {
+ if (record_file.contains(QLatin1Char('%')))
framename = record_file;
else
- framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4);
+ framename = record_file.left(record_file.length()-4) + QLatin1String("%04d") + record_file.right(4);
png_output = true;
} else {
- framename = "tmp-frame%04d.png";
+ framename = QLatin1String("tmp-frame%04d.png");
png_output = false;
}
foreach (QImage* img, frames) {
@@ -1327,11 +1327,11 @@ void QDeclarativeViewer::setRecording(bool on)
name.sprintf(framename.toLocal8Bit(),frame++);
if (record_outsize.isValid())
*img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
- if (record_dither=="ordered")
+ if (record_dither==QLatin1String("ordered"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name);
- else if (record_dither=="threshold")
+ else if (record_dither==QLatin1String("threshold"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name);
- else if (record_dither=="floyd")
+ else if (record_dither==QLatin1String("floyd"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name);
else
img->save(name);
@@ -1341,25 +1341,26 @@ void QDeclarativeViewer::setRecording(bool on)
if (!progress.wasCanceled()) {
if (png_output) {
- framename.replace(QRegExp("%\\d*."),"*");
+ framename.replace(QRegExp(QLatin1String("%\\d*.")), QLatin1String("*"));
qDebug() << "Wrote frames" << framename;
inputs.clear(); // don't remove them
} else {
// ImageMagick and gifsicle for GIF encoding
progress.setLabelText(tr("Converting frames to GIF file..."));
QStringList args;
- args << "-delay" << QString::number(period/10);
+ args << QLatin1String("-delay") << QString::number(period/10);
args << inputs;
args << record_file;
qDebug() << "Converting..." << record_file << "(this may take a while)";
- if (0!=QProcess::execute("convert", args)) {
+ if (0!=QProcess::execute(QLatin1String("convert"), args)) {
qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
inputs.clear(); // don't remove them
qDebug() << "Wrote frames tmp-frame*.png";
} else {
- if (record_file.right(4).toLower() == ".gif") {
+ if (record_file.right(4).toLower() == QLatin1String(".gif")) {
qDebug() << "Compressing..." << record_file;
- if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file))
+ if (0!=QProcess::execute(QLatin1String("gifsicle"), QStringList() << QLatin1String("-O2")
+ << QLatin1String("-o") << record_file << record_file))
qWarning() << "Cannot run 'gifsicle' - not compressed";
}
qDebug() << "Wrote" << record_file;
@@ -1410,7 +1411,7 @@ void QDeclarativeViewer::recordFrame()
{
canvas->QWidget::render(&frame);
if (frame_stream) {
- if (frame_fmt == ".gif") {
+ if (frame_fmt == QLatin1String(".gif")) {
// ffmpeg can't do 32bpp with gif
QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888);
frame_stream->write((char*)rgb24.bits(),rgb24.numBytes());
@@ -1542,8 +1543,8 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
- qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation","");
- qmlRegisterUncreatableType<DeviceOrientation>("QtQuick",1,0,"Orientation","");
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt", 4, 7, "Orientation", QString());
+ qmlRegisterUncreatableType<DeviceOrientation>("QtQuick", 1, 0, "Orientation", QString());
registered = true;
}
}
diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro
index a185bdc9b4..87b5899fcc 100644
--- a/tools/qmlviewer/qmlviewer.pro
+++ b/tools/qmlviewer/qmlviewer.pro
@@ -10,6 +10,8 @@ INCLUDEPATH += ../../include/QtDeclarative
INCLUDEPATH += ../../src/declarative/util
INCLUDEPATH += ../../src/declarative/graphicsitems
+DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
+
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target