summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-03-21 16:38:25 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-03-21 16:38:25 (GMT)
commit123a3aacd6a40fb07a225ef4db34ff7f986363ce (patch)
tree69744fb08a3b0dd4e246b90d2e90d4f533ca768b
parentf92501a82f5bca1ccac07ed17850c84b281a1fb1 (diff)
parent12689cc05936d675c8a7065cf39b8334b83f95bb (diff)
downloadQt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.zip
Qt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.tar.gz
Qt-123a3aacd6a40fb07a225ef4db34ff7f986363ce.tar.bz2
Merge remote-tracking branch 'mainline/4.7' into 4.7
Conflicts: dist/changes-4.7.4
-rw-r--r--dist/changes-4.7.415
-rw-r--r--doc/src/declarative/declarativeui.qdoc1
-rw-r--r--doc/src/declarative/examples.qdoc12
-rw-r--r--doc/src/declarative/pics/layoutmirroring.pngbin0 -> 2542 bytes
-rw-r--r--doc/src/declarative/qdeclarativeperformance.qdoc11
-rw-r--r--doc/src/declarative/righttoleft.qdoc195
-rw-r--r--doc/src/declarative/whatsnew.qdoc4
-rw-r--r--doc/src/examples/qml-examples.qdoc52
-rw-r--r--doc/src/images/qml-righttoleft-layoutdirection-example.pngbin0 -> 23327 bytes
-rw-r--r--doc/src/images/qml-righttoleft-layoutmirroring-example.pngbin0 -> 38982 bytes
-rw-r--r--doc/src/snippets/declarative/arrow.pngbin0 -> 454 bytes
-rw-r--r--doc/src/snippets/declarative/layoutmirroring.qml13
-rw-r--r--doc/src/snippets/declarative/righttoleft.qml149
-rw-r--r--doc/src/snippets/declarative/righttoleft/Child.qml51
-rw-r--r--examples/declarative/positioners/Button.qml (renamed from examples/declarative/positioners/addandremove/Button.qml)0
-rw-r--r--examples/declarative/positioners/add.png (renamed from examples/declarative/positioners/addandremove/add.png)bin810 -> 810 bytes
-rw-r--r--examples/declarative/positioners/del.png (renamed from examples/declarative/positioners/addandremove/del.png)bin488 -> 488 bytes
-rw-r--r--examples/declarative/positioners/layoutdirection/layoutdirection.qml171
-rw-r--r--examples/declarative/positioners/positioners.qml (renamed from examples/declarative/positioners/addandremove/addandremove.qml)0
-rw-r--r--examples/declarative/positioners/positioners.qmlproject (renamed from examples/declarative/positioners/layoutdirection/layoutdirection.qmlproject)0
-rw-r--r--examples/declarative/righttoleft/layoutdirection/layoutdirection.qml246
-rw-r--r--examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject (renamed from examples/declarative/positioners/addandremove/addandremove.qmlproject)0
-rw-r--r--examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml313
-rw-r--r--examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject18
-rw-r--r--examples/declarative/righttoleft/textalignment/textalignment.qml426
-rw-r--r--examples/declarative/righttoleft/textalignment/textalignment.qmlproject18
-rw-r--r--mkspecs/common/symbian/symbian.conf2
-rw-r--r--src/declarative/declarative.pro2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp17
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp67
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp22
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp2
-rw-r--r--src/declarative/util/qdeclarativeview.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h6
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp17
-rw-r--r--src/gui/image/qpixmap_s60.cpp29
-rw-r--r--src/gui/kernel/qapplication_s60.cpp3
-rw-r--r--src/gui/kernel/qclipboard_win.cpp15
-rw-r--r--src/gui/kernel/qwidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_s60.cpp10
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp5
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp28
-rw-r--r--src/gui/styles/qs60style_s60.cpp11
-rw-r--r--src/opengl/qgl_egl.cpp27
-rw-r--r--src/opengl/qgl_symbian.cpp140
-rw-r--r--src/opengl/qpixmapdata_gl_p.h9
-rw-r--r--src/opengl/qpixmapdata_poolgl.cpp118
-rw-r--r--src/openvg/qvg_symbian.cpp8
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp216
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h22
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp2
-rw-r--r--src/s60installs/bwins/QtOpenGLu.def1
-rw-r--r--src/s60installs/eabi/QtOpenGLu.def1
-rw-r--r--src/s60installs/s60installs.pro2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp24
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/dragpath.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp40
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/Global.js1
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp19
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp69
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp49
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h36
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.cpp60
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.h7
78 files changed, 2392 insertions, 513 deletions
diff --git a/dist/changes-4.7.4 b/dist/changes-4.7.4
index bc9eb2b..a37e66a 100644
--- a/dist/changes-4.7.4
+++ b/dist/changes-4.7.4
@@ -14,3 +14,18 @@ of the public source repository.
Qt Bug Tracker: http://bugreports.qt.nokia.com
Merge Request: http://qt.gitorious.org
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+
+
+****************************************************************************
+* Tools *
+****************************************************************************
+
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index aa9ed18..3962514 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -140,6 +140,7 @@ Module.
\o \l{QML Basic Types}
\o \l{QML Global Object}
\o \l{QML Internationalization}
+\o \l{QML Right-to-left User Interfaces}
\o \l{QML Security}
\o \l{Qt Declarative Module}
\o \l{Debugging QML}
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index be2d0c7..b359877 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -136,8 +136,7 @@ The examples can be found in Qt's \c examples/declarative directory.
\section2 Positioners
\list
-\o \l{declarative/positioners/addandremove}{Adding and Removing Items}
-\o \l{declarative/positioners/layoutdirection}{Layout Direction}
+\o \l{declarative/positioners}{Example}
\endlist
\section2 Key Interaction
@@ -198,13 +197,20 @@ The examples can be found in Qt's \c examples/declarative directory.
\o \l{declarative/i18n}{Example}
\endlist
+\section2 Right-to-left User Interfaces
+\list
+\o \l{declarative/righttoleft/layoutmirroring}{Layout mirroring}
+\o \l{declarative/righttoleft/layoutdirection}{Layout direction}
+\o \l{declarative/righttoleft/textalignment}{Text alignment}
+\endlist
+
\section2 Threading
\list
\o \l{declarative/threading/threadedlistmodel}{Threaded ListModel}
\o \l{declarative/threading/workerscript}{WorkerScript}
\endlist
-\section2 Screen orientation
+\section2 Screen Orientation
\list
\o \l{declarative/screenorientation}{Example}
\endlist
diff --git a/doc/src/declarative/pics/layoutmirroring.png b/doc/src/declarative/pics/layoutmirroring.png
new file mode 100644
index 0000000..df90ac4
--- /dev/null
+++ b/doc/src/declarative/pics/layoutmirroring.png
Binary files differ
diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc
index 36b4878..6760869 100644
--- a/doc/src/declarative/qdeclarativeperformance.qdoc
+++ b/doc/src/declarative/qdeclarativeperformance.qdoc
@@ -136,4 +136,15 @@ The QML Viewer uses the raster graphics system by default for X11 and OS X. It a
includes a \c -opengl command line option which sets a QGLWidget as the viewport of the
view. On OS X, a QGLWidget is always used.
+You can also prevent QDeclarativeView from painting its window background if
+you will provide the background of your application using QML, e.g.
+
+\code
+QDeclarativeView window;
+window.setAttribute(Qt::WA_OpaquePaintEvent);
+window.setAttribute(Qt::WA_NoSystemBackground);
+window.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
+window.viewport()->setAttribute(Qt::WA_NoSystemBackground);
+\endcode
+
*/
diff --git a/doc/src/declarative/righttoleft.qdoc b/doc/src/declarative/righttoleft.qdoc
new file mode 100644
index 0000000..7db6136
--- /dev/null
+++ b/doc/src/declarative/righttoleft.qdoc
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qml-righttoleft.html
+\title QML Right-to-left User Interfaces
+
+\section1 Overview
+
+This chapter discusses different approaches and options available for implementing right-to-left
+language support for Qt Quick applications. Some common right-to-left languages include Arabic, Hebrew,
+Persian and Urdu. Most changes include making sure that text translated to right-to-left languages
+is properly aligned to the right, and horizontally ordered content in views, lists and grids flows
+correctly from the right to left.
+
+In right-to-left language speaking cultures, people naturally scan and read graphic elements and text
+from the right to left. The general rule of thumb is that content (like photos, videos and maps) is not
+mirrored, but positioning of the content (like application layouts and the flow of visual elements) is
+mirrored. For example, photos shown in chronological order should flow from right to left, the
+low end range of the horizontal sliders should be located at the right side of the slider, and
+text lines should should be aligned to the right side of the available text area. The location of visual
+elements should not be mirrored when the position is related to a content; for example, when a
+position marker is shown to indicate a location on a map. Also, there are some special cases you may
+need to take into account where right-to-left language speakers are used to left-to-right
+positioning, for example when using number dialers in phones and media play, pause, rewind and
+forward buttons in music players.
+
+\section1 Text Alignment
+
+(This applies to the \l Text, \l TextInput and \l TextEdit elements.)
+
+When the horizontal alignment of a text item is not explicitly set, the text element is
+automatically aligned to the natural reading direction of the text. By default left-to-right text
+like English is aligned to the left side of the text area, and right-to-left text like Arabic is
+aligned to the right side of the text area. The alignment of a text element with empty text takes
+its alignment cue from \l QApplication::keyboardInputDirection(), which is based on the active
+system locale.
+
+This default locale-based alignment can be overriden by setting the \c horizontalAlignment
+property for the text element, or by enabling layout mirroring using the \l LayoutMirroring attached
+property, which causes any explicit left and right horizontal alignments to be mirrored.
+Note that when \l LayoutMirroring is set, the \c horizontalAlignment property value remains unchanged;
+the effective alignment of the text element that takes the mirroring into account can be read from the
+\c effectiveHorizontalAlignment property.
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 0
+
+\section1 Layout direction of positioners and views
+
+(This applies to the \l Row, \l Grid, \l Flow, \l ListView and \l GridView elements.)
+
+From Qt Quick 1.1 onwards, elements used for horizontal positioning and model views have gained a \c layoutDirection
+property for controlling the horizontal direction of the layouts. Setting \c layoutDirection to
+\c Qt.RightToLeft causes items to be laid out from the right to left. By default Qt Quick follows
+the left-to-right layout direction.
+
+The horizontal layout direction can also be reversed through the \l LayoutMirroring attached property.
+This causes the effective \c layoutDirection of positioners and views to be mirrored. Note the actual value
+of the \c layoutDirection property will remain unchanged; the effective layout direction of positioners and
+views that takes the mirroring into account can be read from the \c effectiveLayoutDirection property.
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 1
+
+\section1 Layout mirroring
+
+The attached property \l LayoutMirroring is provided as a convenience for easily implementing right-to-left
+support for existing left-to-right Qt Quick applications. It mirrors the behavior of \l {anchor-layout}
+{Item anchors}, the layout direction of \l{Using QML Positioner and Repeater Items}{positioners} and
+model views, and the explicit text alignment of QML text elements.
+
+You can enable layout mirroring for a particular \l Item:
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 2
+
+Or set all child elements to also inherit the layout direction:
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 3
+
+Applying mirroring in this manner does not change the actual value of the relevant anchor,
+\c layoutDirection or \c horizontalAlignment properties. The separate read-only property
+\c effectiveLayoutDirection can be used to query the effective layout
+direction of positioners and model views that takes the mirroring into account. Similarly the \l Text,
+\l TextInput and \l TextEdit elements have gained the read-only property \c effectiveHorizontalAlignment
+for querying the effective visual alignment of text. For anchors, the read only
+\l {Item::anchors}{anchors.mirrored} property reflects whether anchors have been mirrored.
+
+Note that application layouts and animations that are defined using \l {Item::}{x} property values (as
+opposed to anchors or positioner elements) are not affected by the \l LayoutMirroring attached property.
+Therefore, adding right-to-left support to these types of layouts may require some code changes to your application,
+especially in views that rely on both the anchors and x coordinate-based positioning. Here is one way to use
+the \l LayoutMirroring attached property to apply mirroring to an item that is positioned using \l {Item::}{x}
+coordinates:
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 4
+
+Not all layouts should necessarily be mirrored. There are cases where a visual element is positioned to
+the right side of the screen for improved one-handed use, because most people are right-handed, and not
+because of the reading direction. In the case that a child element should not be affected by mirroring,
+set the \l {LayoutMirroring::enabled}{LayoutMirroring.enabled} property for that element to false.
+
+Qt Quick is designed for developing animated, fluid user interfaces. When mirroring your application, remember to test that
+the animations and transitions continue to work as expected. If you do not have the resources to add
+right-to-left support for your application, it may be better to just keep the application layouts left
+aligned and just make sure that text is translated and aligned properly.
+
+\section1 Mirroring icons
+
+(This applies to \l Image, \l BorderImage and \l AnimatedImage elements.)
+
+Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored.
+The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1:
+
+\snippet doc/src/snippets/declarative/righttoleft.qml 5
+
+\section1 Default layout direction
+
+The \l {QML:Qt::application}{Qt.application.layoutDirection} property can be used to query the active layout direction of the
+application. It is based on QApplication::layoutDirection(), which most commonly determines the layout
+direction from the active language translation file.
+
+To define the layout direction for a particular locale, declare the dedicated string literal
+\c QT_LAYOUT_DIRECTION in context \c QApplication as either "LTR" or "RTL".
+
+You can do this by first introducing this line
+
+\code
+QT_TRANSLATE_NOOP("QApplication", "QT_LAYOUT_DIRECTION");
+\endcode
+
+somewhere in your QML source code and calling \c lupdate to generate the translation source file.
+
+\code
+lupdate myapp.qml -ts myapp.ts
+\endcode
+
+This will append the following declaration to the translation file, where you can fill in either "LTR" or
+"RTL" as the translation for the locale.
+
+\code
+<context>
+ <name>QApplication</name>
+ <message>
+ <location filename="myapp.qml" line="33"/>
+ <source>QT_LAYOUT_DIRECTION</source>
+ <translation type="unfinished">RTL</translation>
+ </message>
+</context>
+\endcode
+
+You can test that the layout direction works as expected by running your Qt Quick application with
+the compiled translation file:
+
+\code
+qmlviewer myapp.qml -translation myapp.qm
+\endcode
+
+You can test your application in right-to-left layout direction simply by executing qmlviewer with a
+command-line parameter "-reverse":
+
+\code
+qmlviewer myapp.qml -reverse
+\endcode
+
+The layout direction can also be set from C++ by calling the static function \l QApplication::setLayoutDirection():
+
+\code
+QApplication app(argc, argv);
+app.setLayoutDirection(Qt::RightToLeft);
+\endcode
+
+*/
diff --git a/doc/src/declarative/whatsnew.qdoc b/doc/src/declarative/whatsnew.qdoc
index 1a8ebd7..6eb1548 100644
--- a/doc/src/declarative/whatsnew.qdoc
+++ b/doc/src/declarative/whatsnew.qdoc
@@ -29,7 +29,7 @@
\title What's new in Qt Quick
\page qtquick-whatsnew.html
-\section1 Qt 4.7.3 includes QtQuick 1.1
+\section1 Qt 4.7.4 includes QtQuick 1.1
QtQuick 1.1 is a minor feature update. \e {import QtQuick 1.1} to use the new features.
@@ -37,7 +37,7 @@ QtQuick 1.1 is a minor feature update. \e {import QtQuick 1.1} to use the new f
PinchArea provides support for the common two finger pinch gesture.
-\section2 LayoutMirroring
+\section2 LayoutMirroring attached property
\l {LayoutMirroring}{Layout mirroring} is useful when you need to support both left-to-right and right-to-left layout versions of your application that target different language areas.
diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc
index bbea19b..3439b09 100644
--- a/doc/src/examples/qml-examples.qdoc
+++ b/doc/src/examples/qml-examples.qdoc
@@ -270,23 +270,55 @@
*/
/*!
- \title Positioners: Adding and Removing Items Example
- \example declarative/positioners/addandremove
+ \title Right-to-left User Interfaces: Text Alignment Example
+ \example declarative/righttoleft/textalignment
- This example shows how to use the positioner elements such as \l Row, \l Column,
- \l Grid and \l Flow, in particular how to add and remove items with appropriate transitions.
+ This example shows how the horizontal alignment of \l Text,
+ \l TextInput and \l TextEdit is affected by the reading direction
+ of the text and by the layout mirrroring. Click on the gray buttons
+ shown at the bottom of the example to toggle between different
+ horizontal alignment options.
- \image qml-positioners-example.png
+ \sa {QML Right-to-left User Interfaces}
*/
/*!
- \title Positioners: Layout Direction Example
- \example declarative/positioners/layoutdirection
+ \title Right-to-left User Interfaces: Layout Direction Example
+ \example declarative/righttoleft/layoutdirection
This example shows how to control the horizontal layout direction of
- \l Row, \l Grid and \l Flow positioners.
+ \l Row, \l Grid and \l Flow positioners, and \l ListView and \l GridView
+ model views. Click on the gray buttons shown at the bottom of the example
+ to toggle the layout direction of the shown elements.
+
+ \image qml-righttoleft-layoutdirection-example.png
+
+ \sa {QML Right-to-left User Interfaces}
+*/
+
+
+/*!
+ \title Right-to-left User Interfaces: Layout Mirroring Example
+ \example declarative/righttoleft/layoutmirroring
+
+ This example shows how to mirror the application layouts
+ using \l LayoutMirroring attached property. Click on the grey button
+ shown at the bottom of the example to enable or disable the
+ layout mirroring.
- \image qml-positioners-layoutdirection-example.png
+ \image qml-righttoleft-layoutmirroring-example.png
+
+ \sa {QML Right-to-left User Interfaces}
+*/
+
+/*!
+ \title Positioners Example
+ \example declarative/positioners
+
+ This example shows how to use the positioner elements such as \l Row, \l Column,
+ \l Grid and \l Flow.
+
+ \image qml-positioners-example.png
*/
/*!
@@ -456,7 +488,7 @@
/*!
- \title Screen orientation
+ \title Screen Orientation
\example declarative/screenorientation
This example shows how to implement screen orientation support for your application.
diff --git a/doc/src/images/qml-righttoleft-layoutdirection-example.png b/doc/src/images/qml-righttoleft-layoutdirection-example.png
new file mode 100644
index 0000000..381ecd7
--- /dev/null
+++ b/doc/src/images/qml-righttoleft-layoutdirection-example.png
Binary files differ
diff --git a/doc/src/images/qml-righttoleft-layoutmirroring-example.png b/doc/src/images/qml-righttoleft-layoutmirroring-example.png
new file mode 100644
index 0000000..992c876
--- /dev/null
+++ b/doc/src/images/qml-righttoleft-layoutmirroring-example.png
Binary files differ
diff --git a/doc/src/snippets/declarative/arrow.png b/doc/src/snippets/declarative/arrow.png
new file mode 100644
index 0000000..f0cae21
--- /dev/null
+++ b/doc/src/snippets/declarative/arrow.png
Binary files differ
diff --git a/doc/src/snippets/declarative/layoutmirroring.qml b/doc/src/snippets/declarative/layoutmirroring.qml
index 23eecd6..617f39d 100644
--- a/doc/src/snippets/declarative/layoutmirroring.qml
+++ b/doc/src/snippets/declarative/layoutmirroring.qml
@@ -43,18 +43,25 @@ import QtQuick 1.1
Rectangle {
LayoutMirroring.enabled: true
LayoutMirroring.childrenInherit: true
- width: 240; height: 50
+
+ width: 300; height: 50
+ color: "yellow"
+ border.width: 1
+
Row {
anchors { left: parent.left; margins: 5 }
y: 5; spacing: 5
+
Repeater {
model: 5
+
Rectangle {
color: "red"
- opacity: (5-index) / 5
+ opacity: (5 - index) / 5
width: 40; height: 40
+
Text {
- text: index+1
+ text: index + 1
anchors.centerIn: parent
}
}
diff --git a/doc/src/snippets/declarative/righttoleft.qml b/doc/src/snippets/declarative/righttoleft.qml
new file mode 100644
index 0000000..c2e504a
--- /dev/null
+++ b/doc/src/snippets/declarative/righttoleft.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 QtQuick 1.1
+import "righttoleft"
+
+Column {
+ width: 200
+//![0]
+// automatically aligned to the left
+Text {
+ text: "Phone"
+ width: 200
+}
+
+// automatically aligned to the right
+Text {
+ text: "خامل"
+ width: 200
+}
+
+// aligned to the left
+Text {
+ text: "خامل"
+ horizontalAlignment: Text.AlignLeft
+ width: 200
+}
+
+// aligned to the right
+Text {
+ text: "خامل"
+ horizontalAlignment: Text.AlignLeft
+ LayoutMirroring.enabled: true
+ width: 200
+}
+//![0]
+
+//![1]
+// by default child items are positioned from left to right
+Row {
+ Child {}
+ Child {}
+}
+
+// position child items from right to left
+Row {
+ layoutDirection: Qt.RightToLeft
+ Child {}
+ Child {}
+}
+
+// position child items from left to right
+Row {
+ LayoutMirroring.enabled: true
+ layoutDirection: Qt.RightToLeft
+ Child {}
+ Child {}
+}
+//![1]
+
+//![2]
+Item {
+ height: 50; width: 150
+
+ LayoutMirroring.enabled: true
+ anchors.left: parent.left // anchor left becomes right
+
+ Row {
+ // items flow from left to right (as per default)
+ Child {}
+ Child {}
+ Child {}
+ }
+}
+//![2]
+
+//![3]
+Item {
+ height: 50; width: 150
+
+ LayoutMirroring.enabled: true
+ LayoutMirroring.childrenInherit: true
+ anchors.left: parent.left // anchor left becomes right
+
+ Row {
+ // setting childrenInherit in the parent causes these
+ // items to flow from right to left instead
+ Child {}
+ Child {}
+ Child {}
+ }
+}
+//![3]
+
+//![4]
+Rectangle {
+ color: "black"
+ height: 50; width: 50
+ x: mirror(10)
+ function mirror(value) {
+ return LayoutMirroring.enabled ? (parent.width - width - value) : value;
+ }
+}
+//![4]
+
+//![5]
+Image {
+ source: "arrow.png"
+ mirror: true
+}
+//![5]
+}
diff --git a/doc/src/snippets/declarative/righttoleft/Child.qml b/doc/src/snippets/declarative/righttoleft/Child.qml
new file mode 100644
index 0000000..48cb295
--- /dev/null
+++ b/doc/src/snippets/declarative/righttoleft/Child.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 QtQuick 1.0
+
+Rectangle {
+ width: 50; height: 50
+ color: "black"
+ Text {
+ color: "white"
+ text: String.fromCharCode(65 + Math.floor(26*Math.random()))
+ anchors.centerIn: parent
+ }
+}
diff --git a/examples/declarative/positioners/addandremove/Button.qml b/examples/declarative/positioners/Button.qml
index 25907c0..25907c0 100644
--- a/examples/declarative/positioners/addandremove/Button.qml
+++ b/examples/declarative/positioners/Button.qml
diff --git a/examples/declarative/positioners/addandremove/add.png b/examples/declarative/positioners/add.png
index 1ee4542..1ee4542 100644
--- a/examples/declarative/positioners/addandremove/add.png
+++ b/examples/declarative/positioners/add.png
Binary files differ
diff --git a/examples/declarative/positioners/addandremove/del.png b/examples/declarative/positioners/del.png
index 8d2eaed..8d2eaed 100644
--- a/examples/declarative/positioners/addandremove/del.png
+++ b/examples/declarative/positioners/del.png
Binary files differ
diff --git a/examples/declarative/positioners/layoutdirection/layoutdirection.qml b/examples/declarative/positioners/layoutdirection/layoutdirection.qml
deleted file mode 100644
index 080010e..0000000
--- a/examples/declarative/positioners/layoutdirection/layoutdirection.qml
+++ /dev/null
@@ -1,171 +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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of 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 QtQuick 1.1
-
-Rectangle {
- property bool mirror
- property int direction: Qt.application.layoutDirection
- LayoutMirroring.enabled: mirror
- LayoutMirroring.childrenInherit: true
-
- width: column.width + 100
- height: column.height + 100
-
- Column {
- id: column
- spacing: 10
- anchors.centerIn: parent
- width: 230
-
- Text {
- text: "Row"
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Row {
- layoutDirection: direction
- spacing: 10
- move: Transition {
- NumberAnimation {
- properties: "x"
- }
- }
- Repeater {
- model: 4
- Loader {
- property int value: index
- sourceComponent: delegate
- }
- }
- }
- Text {
- text: "Grid"
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Grid {
- layoutDirection: direction
- spacing: 10; columns: 4
- move: Transition {
- NumberAnimation {
- properties: "x"
- }
- }
- Repeater {
- model: 11
- Loader {
- property int value: index
- sourceComponent: delegate
- }
- }
- }
- Text {
- text: "Flow"
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Flow {
- layoutDirection: direction
- spacing: 10; width: parent.width
- move: Transition {
- NumberAnimation {
- properties: "x"
- }
- }
- Repeater {
- model: 10
- Loader {
- property int value: index
- sourceComponent: delegate
- }
- }
- }
- Rectangle {
- height: 50; width: parent.width
- color: mouseArea.pressed ? "black" : "gray"
- Text {
- text: direction ? "Right to left" : "Left to right"
- color: "white"
- font.pixelSize: 16
- anchors.centerIn: parent
- }
- MouseArea {
- id: mouseArea
- onClicked: {
- if (direction == Qt.LeftToRight) {
- direction = Qt.RightToLeft;
- } else {
- direction = Qt.LeftToRight;
- }
- }
- anchors.fill: parent
- }
- }
- Rectangle {
- height: 50; width: parent.width
- color: mouseArea2.pressed ? "black" : "gray"
- Text {
- text: mirror ? "Mirrored" : "Normal"
- color: "white"
- font.pixelSize: 16
- anchors.centerIn: parent
- }
- MouseArea {
- id: mouseArea2
- onClicked: {
- mirror = !mirror;
- }
- anchors.fill: parent
- }
- }
- }
-
- Component {
- id: delegate
- Rectangle {
- width: 50; height: 50
- color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
- Text {
- text: parent.parent.value+1
- color: "white"
- font.pixelSize: 20
- anchors.centerIn: parent
- }
- }
- }
-}
diff --git a/examples/declarative/positioners/addandremove/addandremove.qml b/examples/declarative/positioners/positioners.qml
index 7d6d8fe..7d6d8fe 100644
--- a/examples/declarative/positioners/addandremove/addandremove.qml
+++ b/examples/declarative/positioners/positioners.qml
diff --git a/examples/declarative/positioners/layoutdirection/layoutdirection.qmlproject b/examples/declarative/positioners/positioners.qmlproject
index e526217..e526217 100644
--- a/examples/declarative/positioners/layoutdirection/layoutdirection.qmlproject
+++ b/examples/declarative/positioners/positioners.qmlproject
diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml
new file mode 100644
index 0000000..b4efebe
--- /dev/null
+++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of 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 QtQuick 1.1
+
+Rectangle {
+ id: root
+ property bool mirror
+ property int direction: Qt.application.layoutDirection
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: column.width + 80
+ height: column.height + 40
+ Column {
+ id: column
+ width: 190
+ spacing: 10
+ anchors.centerIn: parent
+
+ Text {
+ text: "Row"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Row {
+ layoutDirection: root.direction
+ spacing: 10
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 4
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Grid"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Grid {
+ layoutDirection: root.direction
+ spacing: 10; columns: 4
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 11
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Flow"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Flow {
+ layoutDirection: root.direction
+ spacing: 10; width: parent.width
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 10
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "ListView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ListView {
+ id: listView
+ clip: true
+ width: parent.width; height: 40
+ layoutDirection: root.direction
+ orientation: Qt.Horizontal
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Text {
+ text: "GridView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ GridView {
+ clip: true
+ width: 200; height: 160
+ cellWidth: 50; cellHeight: 50
+ layoutDirection: root.direction
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.direction ? "Right to left" : "Left to right"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (root.direction == Qt.LeftToRight) {
+ root.direction = Qt.RightToLeft;
+ } else {
+ root.direction = Qt.LeftToRight;
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+
+ Component {
+ id: positionerDelegate
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
+ Text {
+ text: parent.parent.value+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Component {
+ id: viewDelegate
+ Item {
+ width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.5+(48 - index)*Math.random()/48,
+ 0.3+index*Math.random()/48,
+ 0.3*Math.random(),
+ 1.0)
+ Text {
+ text: index+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/declarative/positioners/addandremove/addandremove.qmlproject b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject
index e526217..e526217 100644
--- a/examples/declarative/positioners/addandremove/addandremove.qmlproject
+++ b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject
diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml
new file mode 100644
index 0000000..0d1b871
--- /dev/null
+++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of 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 QtQuick 1.1
+
+Rectangle {
+ id: root
+ property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: 400
+ height: 875
+ color: "lightsteelblue"
+
+ Column {
+ spacing: 10
+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }
+
+ Text {
+ text: "Positioners"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: positioners
+ spacing: 5
+ anchors.left: parent.left
+ Row {
+ id: row
+ spacing: 4
+ property string text: "THISISROW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Flow {
+ id: flow
+ spacing: 4
+ width: 90
+ property string text: "THISISFLOW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Grid {
+ id: grid
+ spacing: 4
+ columns: 6
+ property string text: "THISISGRID"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Component {
+ id: positionerDelegate
+ Text {
+ color: "white"
+ font.pixelSize: 20
+ text: parent.text[index]
+ Rectangle {
+ z: -1
+ opacity: 0.7
+ color: "black"
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Text alignment"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: textStrings
+ width: 148
+ height: 85
+ color: "white"
+ anchors.left: parent.left
+ Column {
+ spacing: 5
+ width: parent.width
+ anchors { fill: parent; margins: 5 }
+ Text {
+ id: englishText
+ width: parent.width
+ text: "English text"
+ }
+ Text {
+ id: arabicText
+ width: parent.width
+ text: "النص العربي"
+ }
+ Text {
+ id: leftAlignedText
+ width: parent.width
+ text: "Text aligned to left"
+ horizontalAlignment: Text.AlignLeft
+ }
+ Text {
+ id: rightAlignedText
+ width: parent.width
+ text: "Text aligned to right"
+ horizontalAlignment: Text.AlignRight
+ }
+ }
+ }
+
+ Text {
+ text: "Model views"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: views
+ spacing: 10
+ anchors.left: parent.left
+ ListView {
+ id: listView
+ z: -1
+ clip: true
+ model: text.length
+ width: 360; height: 45
+ orientation: Qt.Horizontal
+ property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW"
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ text: listView.text[index]
+ font.pixelSize: 30
+ anchors.centerIn: parent
+ }
+ }
+ }
+ GridView {
+ id: gridView
+ z: -1
+ clip: true
+ model: text.length
+ width: 180; height: 90
+ cellWidth: 45; cellHeight: 45
+ property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW"
+ anchors.left: parent.left
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 30
+ text: gridView.text[index]
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Item x"
+ anchors.left: parent.left
+ }
+ Rectangle {
+ id: items
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 275; height: 95
+ anchors.left: parent.left
+ Rectangle {
+ y: 5; x: 5
+ width: 130; height: 40
+ Text {
+ text: "Item with x: 5\n(not mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ y: 50; x: mirror(5)
+ width: 130; height: 40
+ function mirror(value) {
+ return LayoutMirroring.enabled ? (parent.width - width - value) : value;
+ }
+ Text {
+ text: "Item with x: " + parent.x + "\n(manually mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Text {
+ text: "Item anchors"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: anchoredItems
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 270; height: 170
+ anchors.left: parent.left
+ Rectangle {
+ id: blackRectangle
+ color: "black"
+ width: 180; height: 90
+ anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 }
+ Text {
+ text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent."
+ color: "white"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: whiteRectangle
+ color: "white"
+ width: 120; height: 70
+ anchors { left: parent.left; bottom: parent.bottom }
+ Text {
+ text: "Left side anchored\nto the left side\nof the parent."
+ color: "black"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: grayRectangle
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ width: 140; height: 90
+ anchors { right: parent.right; bottom: parent.bottom }
+ Text {
+ text: "Right side anchored\nto the right side\nof the parent."
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Rectangle {
+ id: mirrorButton
+ color: mouseArea2.pressed ? "black" : "gray"
+ height: 50; width: parent.width
+ anchors.left: parent.left
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject
new file mode 100644
index 0000000..e526217
--- /dev/null
+++ b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject
@@ -0,0 +1,18 @@
+/* File generated by QtCreator */
+
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qml b/examples/declarative/righttoleft/textalignment/textalignment.qml
new file mode 100644
index 0000000..4c40c3c
--- /dev/null
+++ b/examples/declarative/righttoleft/textalignment/textalignment.qml
@@ -0,0 +1,426 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of 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 QtQuick 1.1
+
+Rectangle {
+ id: root
+ color: "white"
+ width: containerColumn.width
+ height: containerColumn.height + containerColumn.anchors.topMargin
+
+ property bool mirror: false
+ property variant horizontalAlignment: undefined
+
+ property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"]
+ property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"]
+ property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"]
+ property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput]
+
+ function shortText(horizontalAlignment) {
+
+ // all the different QML editors have
+ // the same alignment values
+ switch (horizontalAlignment) {
+ case Text.AlignLeft:
+ return "L";
+ case Text.AlignRight:
+ return "R";
+ case Text.AlignHCenter:
+ return "C";
+ case Text.AlignJustify:
+ return "J";
+ default:
+ return "Error";
+ }
+ }
+ Column {
+ id: containerColumn
+ spacing: 10
+ width: editorTypeRow.width
+ anchors { top: parent.top; topMargin: 5 }
+ Row {
+ id: editorTypeRow
+ Repeater {
+ model: editorType.length
+ Item {
+ width: editorColumn.width
+ height: editorColumn.height
+ Column {
+ id: editorColumn
+ spacing: 5
+ width: textColumn.width+10
+ Text {
+ text: root.editorType[index]
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Column {
+ id: textColumn
+ spacing: 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ Repeater {
+ model: textComponents.length
+ delegate: textComponents[index]
+ }
+ }
+ }
+ }
+ }
+ }
+ Column {
+ spacing: 2
+ width: parent.width
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "lightgray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ property int index: 0
+ anchors.fill: parent
+ onClicked: root.mirror = !root.mirror
+ }
+ }
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: {
+ if (root.horizontalAlignment == undefined)
+ return "Implict alignment";
+ switch (root.horizontalAlignment) {
+ case Text.AlignLeft:
+ return "Left alignment";
+ case Text.AlignRight:
+ return "Right alignment";
+ case Text.AlignHCenter:
+ return "Center alignment";
+ case Text.AlignJustify:
+ return "Justify alignment";
+ }
+ }
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ property int index: 0
+ anchors.fill: parent
+ onClicked: {
+ if (index < 0) {
+ root.horizontalAlignment = undefined;
+ } else {
+ root.horizontalAlignment = Math.pow(2, index);
+ }
+ index = (index + 2) % 5 - 1;
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: styledTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ style: Text.Sunken
+ styleColor: "white"
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: richTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicRichTextComponent
+ Text {
+ width: 180
+ text: "<i>" + root.text[index] + "</i>"
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ Rectangle {
+ z: -1
+ color: parent.backgroundColor
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextEdit
+ TextEdit {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicTextEdit
+ TextEdit {
+ width: 180
+ text: "<i>" + root.text[index] + "<i>"
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: textInput
+ Item {
+ width: 180
+ height: textInput.text.length > 20 ? 3*textInput.height : textInput.height
+ TextInput {
+ id: textInput
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.6, 0.4, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject
new file mode 100644
index 0000000..e526217
--- /dev/null
+++ b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject
@@ -0,0 +1,18 @@
+/* File generated by QtCreator */
+
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf
index c16e4f1..eab9644 100644
--- a/mkspecs/common/symbian/symbian.conf
+++ b/mkspecs/common/symbian/symbian.conf
@@ -93,7 +93,7 @@ contains(QMAKE_HOST.os,Windows) {
QMAKE_COPY = copy /y
QMAKE_COPY_DIR = xcopy /s /q /y /i
QMAKE_MOVE = move
- QMAKE_DEL_FILE = del 2> NUL
+ QMAKE_DEL_FILE = del /q 2> NUL
QMAKE_MKDIR = mkdir
QMAKE_DEL_DIR = rmdir
QMAKE_DEL_TREE = rmdir /s /q
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 1ad888b..f3a7db9 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -29,6 +29,8 @@ symbian: {
LIBS += -lefsrv
}
+linux-g++-maemo:DEFINES += QDECLARATIVEVIEW_NOBACKGROUND
+
DEFINES += QT_NO_OPENTYPE
INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 2c9bde5..ed5d5fc 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -147,8 +147,8 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
/*!
\qmlproperty enumeration Image::fillMode
- Set this property to define what happens when the image set for the item is smaller
- than the size of the item.
+ Set this property to define what happens when the source image has a different size
+ than the item.
\list
\o Image.Stretch - the image is scaled to fit
@@ -234,6 +234,9 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
\endtable
+ Note that \c clip is \c false by default which means that the element might
+ paint outside its bounding rectangle even if the fillMode is set to \c PreserveAspectCrop.
+
\sa {declarative/imageelements/image}{Image example}
*/
QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
@@ -386,14 +389,16 @@ void QDeclarativeImage::updatePaintedGeometry()
if (d->fillMode == PreserveAspectFit) {
if (!d->pix.width() || !d->pix.height())
return;
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
+ qreal w = widthValid() ? width() : d->pix.width();
+ qreal widthScale = w / qreal(d->pix.width());
+ qreal h = heightValid() ? height() : d->pix.height();
+ qreal heightScale = h / qreal(d->pix.height());
if (widthScale <= heightScale) {
- d->paintedWidth = width();
+ d->paintedWidth = w;
d->paintedHeight = widthScale * qreal(d->pix.height());
} else if(heightScale < widthScale) {
d->paintedWidth = heightScale * qreal(d->pix.width());
- d->paintedHeight = height();
+ d->paintedHeight = h;
}
if (widthValid() && !heightValid()) {
setImplicitHeight(d->paintedHeight);
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 471c87f..2de3ba0 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -130,7 +130,7 @@ QSize QDeclarativeImageBase::sourceSize() const
int width = d->sourcesize.width();
int height = d->sourcesize.height();
- return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight());
+ return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height());
}
bool QDeclarativeImageBase::cache() const
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 9cf1e78..4af91ce 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -746,44 +746,63 @@ void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *cur
\qmlclass LayoutMirroring QDeclarativeLayoutMirroringAttached
\since QtQuick 1.1
\ingroup qml-utility-elements
- \brief The LayoutMirroring is used for mirroring the Qt Quick application layouts.
+ \brief The LayoutMirroring attached property is used to mirror layout behavior.
- LayoutMirroring \l enabled property can be used to horizontally mirror \l {anchor-layout}{Item anchors},
- \l{Using QML Positioner and Repeater Items}{Positioner} elements and QML views like \l {GridView}{GridView}
- and horizontal \l {ListView}{ListView}. Mirroring is a visual change, left anchors will become
- right anchors and left-to-right positioner will instead position child items from right to left.
- By default setting the \l enabled property to true only affects the item in question. You can set property
- LayoutDirection \l childrenInherit to true if you want the item children also inherit the mirror setting.
- If no attached property has been defined, mirroring is disabled.
+ The LayoutMirroring attached property is used to horizontally mirror \l {anchor-layout}{Item anchors},
+ \l{Using QML Positioner and Repeater Items}{positioner} elements (such as \l Row and \l Grid)
+ and views (such as \l GridView and horizontal \l ListView). Mirroring is a visual change: left
+ anchors become right anchors, and positioner elements like \l Grid and \l Row reverse the
+ horizontal layout of child items.
- The following example shows mirroring in action. When \l enabled is set to true, left anchor
- becomes right, and \l {Row}{Row} starts positioning items in a reverse order:
+ Mirroring is enabled for an item by setting the \l enabled property to true. By default, this
+ only affects the item itself; setting the \l childrenInherit property to true propagates the mirroring
+ behavior to all child elements as well. If the \c LayoutMirroring attached property has not been defined
+ for an item, mirroring is not enabled.
+
+ The following example shows mirroring in action. The \l Row below is specified as being anchored
+ to the left of its parent. However, since mirroring has been enabled, the anchor is horizontally
+ reversed and it is now anchored to the right. Also, since items in a \l Row are positioned
+ from left to right by default, they are now positioned from right to left instead, as demonstrated
+ by the numbering and opacity of the items:
\snippet doc/src/snippets/declarative/layoutmirroring.qml 0
- Layout mirroring is useful when you need to support both left-to-right and right-to-left
- layout versions of your application that target different language areas. Inheritance saves
- you from having to mirror the layouts manually for each layout item in your application. Keep
- in mind however that the mirroring does not affect the positioning done by modifying Item's x
- co-ordinate directly, so even with the mirroring enabled you will often need to do some layout
- fixes to support the other reading direction. Also, there are cases where you need to disable
- mirroring of individual child items, either because mirroring is not the wanted behavior or
- because the item already implements mirroring in some custom way.
+ \image layoutmirroring.png
+
+ Layout mirroring is useful when it is necessary to support both left-to-right and right-to-left
+ layout versions of an application to target different language areas. The \l childrenInherit
+ property allows layout mirroring to be applied without manually setting layout configurations
+ for every item in an application. Keep in mind, however, that mirroring does not affect any
+ positioning that is defined by the \l Item \l {Item::}{x} coordinate value, so even with
+ mirroring enabled, it will often be necessary to apply some layout fixes to support the
+ desired layout direction. Also, it may be necessary to disable the mirroring of individual
+ child items (by setting \l {enabled}{LayoutMirroring.enabled} to false for such items) if
+ mirroring is not the desired behavior, or if the child item already implements mirroring in
+ some custom way.
+
+ See \l {QML Right-to-left User Interfaces} for further details on using \c LayoutMirroring and
+ other related features to implement right-to-left support for an application.
*/
/*!
\qmlproperty bool LayoutMirroring::enabled
- Setting this property to true mirrors item's layout horizontally, whether the layout is done
- using \l {anchor-layout}{anchors}, \l{Using QML Positioner and Repeater Items}{Positioners}
- or as a QML view \l {GridView}{GridView} or \l {ListView}{ListView}.
+ This property holds whether the item's layout is mirrored horizontally. Setting this to true
+ horizontally reverses \l {anchor-layout}{anchor} settings such that left anchors become right,
+ and right anchors become left. For \l{Using QML Positioner and Repeater Items}{positioner} elements
+ (such as \l Row and \l Grid) and view elements (such as \l {GridView}{GridView} and \l {ListView}{ListView})
+ this also mirrors the horizontal layout direction of the item.
+
+ The default value is false.
*/
/*!
\qmlproperty bool LayoutMirroring::childrenInherit
- This property can be set to true if you want the item children
- to inherit the item's mirror setting.
+ This property holds whether the \l {enabled}{LayoutMirroring.enabled} value for this item
+ is inherited by its children.
+
+ The default value is false.
*/
QDeclarativeLayoutMirroringAttached::QDeclarativeLayoutMirroringAttached(QObject *parent) : QObject(parent), itemPrivate(0)
@@ -1558,7 +1577,7 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
\section1 Layout Mirroring
- Item layouts can be mirrored using \l {LayoutMirroring}{LayoutMirroring} attached property.
+ Item layouts can be mirrored using the \l {LayoutMirroring}{LayoutMirroring} attached property.
*/
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 4e401e9..778b8b9 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -796,6 +796,7 @@ void QDeclarativePathView::setPreferredHighlightBegin(qreal start)
return;
d->highlightRangeStart = start;
d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ refill();
emit preferredHighlightBeginChanged();
}
@@ -812,6 +813,7 @@ void QDeclarativePathView::setPreferredHighlightEnd(qreal end)
return;
d->highlightRangeEnd = end;
d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ refill();
emit preferredHighlightEndChanged();
}
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 84dcec6..8a9bdb3 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -385,7 +385,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
Items with a width or height of 0 will not be positioned.
- \sa Row, Grid, Flow, {declarative/positioners/addandremove}{Positioners example}
+ \sa Row, Grid, Flow, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition Column::add
@@ -425,7 +425,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
}
\endqml
- \sa add, {declarative/positioners/addandremove}{Positioners example}
+ \sa add, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty int Column::spacing
@@ -528,7 +528,7 @@ void QDeclarativeColumn::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Column, Grid, Flow, {declarative/positioners/addandremove}{Positioners example}
+ \sa Column, Grid, Flow, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition Row::add
@@ -567,7 +567,7 @@ void QDeclarativeColumn::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners/addandremove}{Positioners example}
+ \sa add, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty int Row::spacing
@@ -597,7 +597,7 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent)
the right anchor remains to the right of the row.
\endlist
- \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QDeclarativeRow::layoutDirection() const
{
@@ -753,7 +753,7 @@ void QDeclarativeRow::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Flow, Row, Column, {declarative/positioners/addandremove}{Positioners example}
+ \sa Flow, Row, Column, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition Grid::add
@@ -791,7 +791,7 @@ void QDeclarativeRow::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners/addandremove}{Positioners example}
+ \sa add, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty int Grid::spacing
@@ -895,7 +895,7 @@ void QDeclarativeGrid::setFlow(Flow flow)
\l Grid::flow property.
\endlist
- \sa Flow::layoutDirection, Row::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+ \sa Flow::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QDeclarativeGrid::layoutDirection() const
{
@@ -1137,7 +1137,7 @@ void QDeclarativeGrid::reportConflictingAnchors()
Items with a width or height of 0 will not be positioned.
- \sa Column, Row, Grid, {declarative/positioners/addandremove}{Positioners example}
+ \sa Column, Row, Grid, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition Flow::add
@@ -1176,7 +1176,7 @@ void QDeclarativeGrid::reportConflictingAnchors()
}
\endqml
- \sa add, {declarative/positioners/addandremove}{Positioners example}
+ \sa add, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty int Flow::spacing
@@ -1255,7 +1255,7 @@ void QDeclarativeFlow::setFlow(Flow flow)
\l Flow::flow property.
\endlist
- \sa Grid::layoutDirection, Row::layoutDirection, {declarative/positioners/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QDeclarativeFlow::layoutDirection() const
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index c6de7a0..af18c90 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -399,10 +399,10 @@ bool QDeclarativeTextInputPrivate::setHAlign(QDeclarativeTextInput::HAlignment a
if ((hAlign != alignment || forceAlign) && alignment <= QDeclarativeTextInput::AlignHCenter) { // justify not supported
QDeclarativeTextInput::HAlignment oldEffectiveHAlign = q->effectiveHAlign();
hAlign = alignment;
- return true;
emit q->horizontalAlignmentChanged(alignment);
if (oldEffectiveHAlign != q->effectiveHAlign())
emit q->effectiveHorizontalAlignmentChanged();
+ return true;
}
return false;
}
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index b604706..d9e3ebf 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -940,7 +940,7 @@ QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extra
if (l.currentLineNo() == startLine)
return rv;
- if (pragmaValue == QLatin1String("library")) {
+ if (pragmaValue == library) {
rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
index d3e2025..0314a7a 100644
--- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -158,7 +158,7 @@ void QDeclarativeTypeNameScriptClass::setProperty(Object *o, const Identifier &n
Q_ASSERT(!type);
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- ep->objectClass->setProperty(((TypeNameData *)o)->object, n, v, context());
+ ep->objectClass->setProperty(object, n, v, context());
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index f8d52b5..1ff0caa 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -313,7 +313,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QScriptContext *ctxt = QScriptDeclarativeClass::pushCleanContext(workerEngine);
QScriptValue urlContext = workerEngine->newObject();
- urlContext.setData(QScriptValue(workerEngine, fileName));
+ urlContext.setData(QScriptValue(workerEngine, url.toString()));
ctxt->pushScope(urlContext);
ctxt->pushScope(activation);
ctxt->setActivationObject(activation);
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index c2e5efe..13880c2 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -293,6 +293,13 @@ void QDeclarativeViewPrivate::init()
q->setFocusPolicy(Qt::StrongFocus);
q->scene()->setStickyFocus(true); //### needed for correct focus handling
+
+#ifdef QDECLARATIVEVIEW_NOBACKGROUND
+ q->setAttribute(Qt::WA_OpaquePaintEvent);
+ q->setAttribute(Qt::WA_NoSystemBackground);
+ q->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
+ q->viewport()->setAttribute(Qt::WA_NoSystemBackground);
+#endif
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 1caa325..b4d8d56 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -417,6 +417,11 @@
click focus to items underneath when being clicked on. This flag
allows you create a non-focusable item that can be clicked on without
changing the focus. \endomit
+
+ \omitvalue ItemStopsFocusHandling \omit Same as
+ ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag
+ allows you to completely take over focus handling.
+ This flag was introduced in Qt 4.7.
*/
/*!
@@ -11551,6 +11556,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
case QGraphicsItem::ItemStopsClickFocusPropagation:
str = "ItemStopsClickFocusPropagation";
break;
+ case QGraphicsItem::ItemStopsFocusHandling:
+ str = "ItemStopsFocusHandling";
+ break;
}
debug << str;
return debug;
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index e59a7c9..67c9cd3 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -107,7 +107,8 @@ public:
ItemIsPanel = 0x4000,
ItemIsFocusScope = 0x8000, // internal
ItemSendsScenePositionChanges = 0x10000,
- ItemStopsClickFocusPropagation = 0x20000
+ ItemStopsClickFocusPropagation = 0x20000,
+ ItemStopsFocusHandling = 0x40000
// NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
};
Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 5c82116..90ff43f 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -559,7 +559,7 @@ public:
quint32 dirtyChildrenBoundingRect : 1;
// Packed 32 bits
- quint32 flags : 18;
+ quint32 flags : 19;
quint32 paintedViewBoundingRectsNeedRepaint : 1;
quint32 dirtySceneTransform : 1;
quint32 geometryChanged : 1;
@@ -573,9 +573,9 @@ public:
quint32 sceneTransformTranslateOnly : 1;
quint32 notifyBoundingRectChanged : 1;
quint32 notifyInvalidated : 1;
- quint32 mouseSetsFocus : 1;
// New 32 bits
+ quint32 mouseSetsFocus : 1;
quint32 explicitActivate : 1;
quint32 wantsActive : 1;
quint32 holesInSiblingIndex : 1;
@@ -586,7 +586,7 @@ public:
quint32 mayHaveChildWithGraphicsEffect : 1;
quint32 isDeclarativeItem : 1;
quint32 sendParentChangeNotification : 1;
- quint32 padding : 22;
+ quint32 padding : 21;
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index df68b1d..85a4e16 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1320,8 +1320,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Set focus on the topmost enabled item that can take focus.
bool setFocus = false;
+
foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- if (item->isBlockedByModalPanel()) {
+ if (item->isBlockedByModalPanel()
+ || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
// Make sure we don't clear focus.
setFocus = true;
break;
@@ -1334,10 +1336,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
break;
}
}
- if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
- break;
if (item->isPanel())
break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
}
// Check for scene modality.
@@ -5930,6 +5932,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
// Set focus on the topmost enabled item that can take focus.
bool setFocus = false;
+
foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
@@ -5943,6 +5946,11 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
break;
if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
+ // Make sure we don't clear focus.
+ setFocus = true;
+ break;
+ }
}
// If nobody could take focus, clear it.
@@ -5975,7 +5983,8 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
}
if (item && item->isPanel())
break;
- if (item && (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation))
+ if (item && (item->d_ptr->flags
+ & (QGraphicsItem::ItemStopsClickFocusPropagation | QGraphicsItem::ItemStopsFocusHandling)))
break;
}
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index fbdebf3..32d8dd7 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -601,6 +601,9 @@ bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect)
return res;
}
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
+
int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
if (!cfbsBitmap)
@@ -611,28 +614,18 @@ int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
return cfbsBitmap->SizeInPixels().iWidth;
case QPaintDevice::PdmHeight:
return cfbsBitmap->SizeInPixels().iHeight;
- case QPaintDevice::PdmWidthMM: {
- TInt twips = cfbsBitmap->SizeInTwips().iWidth;
- return (int)(twips * (25.4/KTwipsPerInch));
- }
- case QPaintDevice::PdmHeightMM: {
- TInt twips = cfbsBitmap->SizeInTwips().iHeight;
- return (int)(twips * (25.4/KTwipsPerInch));
- }
+ case QPaintDevice::PdmWidthMM:
+ return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX());
+ case QPaintDevice::PdmHeightMM:
+ return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY());
case QPaintDevice::PdmNumColors:
return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode());
case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX: {
- TReal inches = cfbsBitmap->SizeInTwips().iWidth / (TReal)KTwipsPerInch;
- TInt pixels = cfbsBitmap->SizeInPixels().iWidth;
- return pixels / inches;
- }
+ case QPaintDevice::PdmPhysicalDpiX:
+ return qt_defaultDpiX();
case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY: {
- TReal inches = cfbsBitmap->SizeInTwips().iHeight / (TReal)KTwipsPerInch;
- TInt pixels = cfbsBitmap->SizeInPixels().iHeight;
- return pixels / inches;
- }
+ case QPaintDevice::PdmPhysicalDpiY:
+ return qt_defaultDpiY();
case QPaintDevice::PdmDepth:
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode());
default:
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 43b9b01..2b10d63 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1132,7 +1132,8 @@ void QSymbianControl::Draw(const TRect& controlRect) const
// Do nothing
break;
case QWExtra::Blit:
- if (qwidget->d_func()->isOpaque)
+ case QWExtra::BlitWriteAlpha:
+ if (qwidget->d_func()->isOpaque || nativePaintMode == QWExtra::BlitWriteAlpha)
gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect);
break;
diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp
index 52b9663..ea41165 100644
--- a/src/gui/kernel/qclipboard_win.cpp
+++ b/src/gui/kernel/qclipboard_win.cpp
@@ -52,6 +52,7 @@
#include "qt_windows.h"
#include "qdnd_p.h"
#include <private/qwidget_p.h>
+#include <private/qsystemlibrary_p.h>
QT_BEGIN_NAMESPACE
@@ -70,6 +71,9 @@ void QtCeFlushClipboard();
#endif
+typedef BOOL (WINAPI *PtrIsHungAppWindow)(HWND);
+
+static PtrIsHungAppWindow ptrIsHungAppWindow = 0;
class QClipboardWatcher : public QInternalMimeData {
public:
@@ -327,9 +331,16 @@ bool QClipboard::event(QEvent *e)
d->releaseIData();
propagate = true;
}
-
if (propagate && d->nextClipboardViewer) {
- SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
+ if (ptrIsHungAppWindow == 0) {
+ QSystemLibrary library(QLatin1String("User32"));
+ ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow");
+ }
+ if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) {
+ qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO);
+ } else {
+ SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
+ }
}
return true;
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 5235dc4..13e2349 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -315,6 +315,11 @@ struct QWExtra {
*/
ZeroFill,
+ /**
+ * Blit backing store, propagating alpha channel into the framebuffer.
+ */
+ BlitWriteAlpha,
+
Default = Blit
};
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 62d09fe..b65ae4d 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -805,9 +805,14 @@ void QWidgetPrivate::s60UpdateIsOpaque()
{
Q_Q(QWidget);
- if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground))
+ if (!q->testAttribute(Qt::WA_WState_Created))
return;
+ const bool writeAlpha = extraData()->nativePaintMode == QWExtra::BlitWriteAlpha;
+ if (!q->testAttribute(Qt::WA_TranslucentBackground) && !writeAlpha)
+ return;
+ const bool requireAlphaChannel = !isOpaque || writeAlpha;
+
createTLExtra();
RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow());
@@ -819,12 +824,11 @@ void QWidgetPrivate::s60UpdateIsOpaque()
return;
}
#endif
- if (!isOpaque) {
+ if (requireAlphaChannel) {
const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA));
if (window->SetTransparencyAlphaChannel() == KErrNone) {
window->SetBackgroundColor(TRgb(255, 255, 255, 0));
extra->topextra->nativeWindowTransparencyEnabled = 1;
-
if (extra->topextra->backingStore.data() && (
QApplicationPrivate::graphics_system_name == QLatin1String("openvg")
|| QApplicationPrivate::graphics_system_name == QLatin1String("opengl"))) {
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index 5841d40..33652ee 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -394,7 +394,10 @@ void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
- proxy->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
+ QWindowSurface *newWindowSurface = m_graphicsSystem->createWindowSurface(widget);
+ newWindowSurface->setGeometry(proxy->geometry());
+
+ proxy->m_windowSurface.reset(newWindowSurface);
qt_widget_private(widget)->invalidateBuffer(widget->rect());
}
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 9f371a8..cb53ea0 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -63,7 +63,6 @@ struct QS60WindowSurfacePrivate
TDisplayMode displayMode(bool opaque)
{
-
TDisplayMode mode = S60->screenDevice()->DisplayMode();
if (opaque) {
mode = EColor16MU;
@@ -76,10 +75,18 @@ TDisplayMode displayMode(bool opaque)
return mode;
}
+bool blitWriteAlpha(QWidgetPrivate *widgetPrivate)
+{
+ QWExtra *extra = widgetPrivate->extraData();
+ return extra ? extra->nativePaintMode == QWExtra::BlitWriteAlpha : false;
+}
+
QS60WindowSurface::QS60WindowSurface(QWidget* widget)
: QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
{
- TDisplayMode mode = displayMode(qt_widget_private(widget)->isOpaque);
+ QWidgetPrivate *widgetPrivate = qt_widget_private(widget);
+ const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate);
+ TDisplayMode mode = displayMode(opaque);
// We create empty CFbsBitmap here -> it will be resized in setGeometry
CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new
qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
@@ -123,7 +130,8 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn)
S60->wsSession().Finish();
#endif
- if (!qt_widget_private(window())->isOpaque) {
+ QWidgetPrivate *windowPrivate = qt_widget_private(window());
+ if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) {
QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
TDisplayMode mode = displayMode(false);
@@ -132,12 +140,14 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn)
pixmapData->beginDataAccess();
- QPainter p(&pixmapData->image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
+ if (!windowPrivate->isOpaque) {
+ QPainter p(&pixmapData->image);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = rgn.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
}
pixmapData->endDataAccess();
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 1ff195d..e46c826 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -639,13 +639,14 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask
QPixmap pixmap;
QScopedPointer<QPixmapData> pd(QPixmapData::create(0, 0, QPixmapData::PixmapType));
- bool nativeMaskSupported = (pd->toNativeType(QPixmapData::VolatileImage) != 0);
- if (mask && nativeMaskSupported) {
- // Efficient path, less copying and conversion.
+ if (mask) {
+ // Try the efficient path with less copying and conversion.
QVolatileImage img(icon, mask);
pd->fromNativeType(&img, QPixmapData::VolatileImage);
- pixmap = QPixmap(pd.take());
- } else {
+ if (!pd->isNull())
+ pixmap = QPixmap(pd.take());
+ }
+ if (pixmap.isNull()) {
// Potentially more expensive path.
pd->fromNativeType(icon, QPixmapData::FbsBitmap);
pixmap = QPixmap(pd.take());
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 674d80d..d6b2d3b 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <QtCore/qdebug.h>
#include <QtOpenGL/qgl.h>
#include <QtOpenGL/qglpixelbuffer.h>
#include "qgl_p.h"
@@ -195,6 +196,7 @@ void QGLContext::makeCurrent()
// PowerVR MBX/SGX chips needs to clear all buffers when starting to render
// a new frame, otherwise there will be a performance penalty to pay for
// each frame.
+ qDebug() << "Found SGX/MBX driver, enabling FullClearOnEveryFrame";
d->workaround_needsFullClearOnEveryFrame = true;
// Older PowerVR SGX drivers (like the one in the N900) have a
@@ -202,10 +204,31 @@ void QGLContext::makeCurrent()
// or GL_ALPHA texture bound to an FBO. The only way to
// identify that driver is to check the EGL version number for it.
const char *egl_version = eglQueryString(d->eglContext->display(), EGL_VERSION);
- if (egl_version && strstr(egl_version, "1.3"))
+
+ if (egl_version && strstr(egl_version, "1.3")) {
+ qDebug() << "Found v1.3 driver, enabling brokenFBOReadBack";
d->workaround_brokenFBOReadBack = true;
- else if (egl_version && strstr(egl_version, "1.4"))
+ } else if (egl_version && strstr(egl_version, "1.4")) {
+ qDebug() << "Found v1.4 driver, enabling brokenTexSubImage";
d->workaround_brokenTexSubImage = true;
+
+ // this is a bit complicated; 1.4 version SGX drivers from
+ // Nokia have fixed the brokenFBOReadBack problem, but
+ // official drivers from TI haven't, meaning that things
+ // like the beagleboard are broken unless we hack around it
+ // - but at the same time, we want to not reduce performance
+ // by not enabling this elsewhere.
+ //
+ // so, let's check for a Nokia-specific addon, and only
+ // enable if it isn't present.
+ // (see MeeGo bug #5616)
+ if (!QEgl::hasExtension("EGL_NOK_image_shared")) {
+ // no Nokia extension, this is probably a standard SGX
+ // driver, so enable the workaround
+ qDebug() << "Found non-Nokia v1.4 driver, enabling brokenFBOReadBack";
+ d->workaround_brokenFBOReadBack = true;
+ }
+ }
}
}
}
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp
index 2978514..78624a2 100644
--- a/src/opengl/qgl_symbian.cpp
+++ b/src/opengl/qgl_symbian.cpp
@@ -41,9 +41,7 @@
#include "qgl.h"
-#include <coemain.h>
-#include <coecntrl.h>
-#include <w32std.h>
+#include <fbs.h>
#include <private/qt_s60_p.h>
#include <private/qpixmap_s60_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>
@@ -72,6 +70,8 @@ QT_BEGIN_NAMESPACE
#endif
#endif
+extern int qt_gl_pixmap_serial;
+
/*
QGLTemporaryContext implementation
*/
@@ -361,117 +361,61 @@ void QGLWidgetPrivate::recreateEglSurface()
eglSurfaceWindowId = currentId;
}
-/*
- * Symbian specific QGLPixmapData functions
- */
-
-static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
+static inline bool knownGoodFormat(QImage::Format format)
{
- CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
- if (!copy)
- return 0;
-
- if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
- delete copy;
- copy = 0;
-
- return 0;
+ switch (format) {
+ case QImage::Format_RGB16: // EColor64K
+ case QImage::Format_RGB32: // EColor16MU
+ case QImage::Format_ARGB32_Premultiplied: // EColor16MAP
+ return true;
+ default:
+ return false;
}
-
- CFbsBitmapDevice* bitmapDevice = 0;
- CFbsBitGc *bitmapGc = 0;
- QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy));
- QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
- bitmapGc->Activate(bitmapDevice);
-
- bitmapGc->BitBlt(TPoint(), bitmap);
-
- delete bitmapGc;
- delete bitmapDevice;
-
- return copy;
}
void QGLPixmapData::fromNativeType(void* pixmap, NativeType type)
{
if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
-
- bool deleteSourceBitmap = false;
-#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
-
- // Rasterize extended bitmaps
-
- TUid extendedBitmapType = bitmap->ExtendedBitmapType();
- if (extendedBitmapType != KNullUid) {
- bitmap = createBlitCopy(bitmap);
- deleteSourceBitmap = true;
- }
-#endif
-
- if (bitmap->IsCompressedInRAM()) {
- bitmap = createBlitCopy(bitmap);
- deleteSourceBitmap = true;
+ CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap);
+ QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
+ if (size.width() == w && size.height() == h)
+ setSerialNumber(++qt_gl_pixmap_serial);
+ resize(size.width(), size.height());
+ m_source = QVolatileImage(bitmap);
+ if (pixelType() == BitmapType) {
+ m_source.ensureFormat(QImage::Format_MonoLSB);
+ } else if (!knownGoodFormat(m_source.format())) {
+ m_source.beginDataAccess();
+ QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor);
+ m_source.endDataAccess(true);
+ m_source.ensureFormat(format);
}
-
- TDisplayMode displayMode = bitmap->DisplayMode();
- QImage::Format format = qt_TDisplayMode2Format(displayMode);
-
- TSize size = bitmap->SizeInPixels();
- int bytesPerLine = bitmap->ScanLineLength(size.iWidth, displayMode);
-
- bitmap->BeginDataAccess();
- uchar *bytes = (uchar*)bitmap->DataAddress();
- QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format);
- img = img.copy();
- bitmap->EndDataAccess();
-
- if (displayMode == EGray2) {
- //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
- //So invert mono bitmaps so that masks work correctly.
- img.invertPixels();
- } else if (displayMode == EColor16M) {
- img = img.rgbSwapped(); // EColor16M is BGR
- }
-
- fromImage(img, Qt::AutoColor);
-
- if (deleteSourceBitmap)
- delete bitmap;
+ m_hasAlpha = m_source.hasAlphaChannel();
+ m_hasFillColor = false;
+ m_dirty = true;
+
+ } else if (type == QPixmapData::VolatileImage && pixmap) {
+ // Support QS60Style in more efficient skin graphics retrieval.
+ QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
+ if (img->width() == w && img->height() == h)
+ setSerialNumber(++qt_gl_pixmap_serial);
+ resize(img->width(), img->height());
+ m_source = *img;
+ m_hasAlpha = m_source.hasAlphaChannel();
+ m_hasFillColor = false;
+ m_dirty = true;
}
}
void* QGLPixmapData::toNativeType(NativeType type)
{
if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
-
- if (bitmap) {
- QImage image = toImage();
-
- TDisplayMode displayMode(EColor16MU);
- if (image.format()==QImage::Format_ARGB32_Premultiplied)
- displayMode = EColor16MAP;
-
- if (bitmap->Create(TSize(image.width(), image.height()),
- displayMode) == KErrNone) {
- const uchar *sptr = const_cast<const QImage&>(image).bits();
- bitmap->BeginDataAccess();
-
- uchar *dptr = (uchar*)bitmap->DataAddress();
- Mem::Copy(dptr, sptr, image.byteCount());
-
- bitmap->EndDataAccess();
- } else {
- delete bitmap;
- bitmap = 0;
- }
- }
-
- return reinterpret_cast<void*>(bitmap);
+ if (m_source.isNull())
+ m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied);
+ return m_source.duplicateNativeImage();
}
+
return 0;
}
QT_END_NAMESPACE
-
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index 55cc29d..41740dd 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -59,6 +59,10 @@
#include "private/qpixmapdata_p.h"
#include "private/qglpaintdevice_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qvolatileimage_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
class QPaintEngine;
@@ -153,6 +157,7 @@ public:
#endif
#ifdef Q_OS_SYMBIAN
+ QImage::Format idealFormat(QImage &image, Qt::ImageConversionFlags flags);
void* toNativeType(NativeType type);
void fromNativeType(void* pixmap, NativeType type);
#endif
@@ -184,7 +189,11 @@ private:
mutable QGLFramebufferObject *m_renderFbo;
mutable QPaintEngine *m_engine;
mutable QGLContext *m_ctx;
+#ifdef Q_OS_SYMBIAN
+ mutable QVolatileImage m_source;
+#else
mutable QImage m_source;
+#endif
mutable QGLTexture m_texture;
// the texture is not in sync with the source image
diff --git a/src/opengl/qpixmapdata_poolgl.cpp b/src/opengl/qpixmapdata_poolgl.cpp
index f1220b1..64de29e 100644
--- a/src/opengl/qpixmapdata_poolgl.cpp
+++ b/src/opengl/qpixmapdata_poolgl.cpp
@@ -247,7 +247,7 @@ void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
data = d;
}
-static int qt_gl_pixmap_serial = 0;
+int qt_gl_pixmap_serial = 0;
QGLPixmapData::QGLPixmapData(PixelType type)
: QPixmapData(type, OpenGLClass)
@@ -330,7 +330,7 @@ void QGLPixmapData::resize(int width, int height)
destroyTexture();
- m_source = QImage();
+ m_source = QVolatileImage();
m_dirty = isValid();
setSerialNumber(++qt_gl_pixmap_serial);
}
@@ -353,6 +353,11 @@ void QGLPixmapData::ensureCreated() const
#endif
const GLenum target = GL_TEXTURE_2D;
+ GLenum type = GL_UNSIGNED_BYTE;
+ // Avoid conversion when pixmap is created from CFbsBitmap of EColor64K.
+ if (!m_source.isNull() && m_source.format() == QImage::Format_RGB16)
+ type = GL_UNSIGNED_SHORT_5_6_5;
+
m_texture.options &= ~QGLContext::MemoryManagedBindOption;
if (!m_texture.id) {
@@ -361,7 +366,7 @@ void QGLPixmapData::ensureCreated() const
0, internal_format,
w, h,
external_format,
- GL_UNSIGNED_BYTE,
+ type,
const_cast<QGLPixmapData*>(this));
if (!m_texture.id) {
failedToAlloc = true;
@@ -378,21 +383,35 @@ void QGLPixmapData::ensureCreated() const
if (!m_source.isNull() && m_texture.id) {
if (external_format == GL_RGB) {
- const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true);
+ m_source.beginDataAccess();
+ QImage tx;
+ if (type == GL_UNSIGNED_BYTE)
+ tx = m_source.imageRef().convertToFormat(QImage::Format_RGB888).mirrored(false, true);
+ else if (type == GL_UNSIGNED_SHORT_5_6_5)
+ tx = m_source.imageRef().mirrored(false, true);
+ m_source.endDataAccess(true);
glBindTexture(target, m_texture.id);
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- GL_UNSIGNED_BYTE, tx.bits());
+ if (!tx.isNull())
+ glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
+ type, tx.constBits());
+ else
+ qWarning("QGLPixmapData: Failed to create GL_RGB image of size %dx%d", w, h);
} else {
// do byte swizzling ARGB -> RGBA
- const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
+ m_source.beginDataAccess();
+ const QImage tx = ctx->d_func()->convertToGLFormat(m_source.imageRef(), true, external_format);
+ m_source.endDataAccess(true);
glBindTexture(target, m_texture.id);
- glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- GL_UNSIGNED_BYTE, tx.bits());
+ if (!tx.isNull())
+ glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
+ type, tx.constBits());
+ else
+ qWarning("QGLPixmapData: Failed to create GL_RGBA image of size %dx%d", w, h);
}
if (useFramebufferObjects())
- m_source = QImage();
+ m_source = QVolatileImage();
}
}
@@ -437,7 +456,7 @@ bool QGLPixmapData::fromFile(const QString &filename, const char *format,
is_null = false;
d = 32;
m_hasAlpha = alpha;
- m_source = QImage();
+ m_source = QVolatileImage();
m_dirty = isValid();
return true;
}
@@ -469,7 +488,7 @@ bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
is_null = false;
d = 32;
m_hasAlpha = alpha;
- m_source = QImage();
+ m_source = QVolatileImage();
m_dirty = isValid();
return true;
}
@@ -487,9 +506,20 @@ bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
return !isNull();
}
-/*!
- out-of-place conversion (inPlace == false) will always detach()
- */
+QImage::Format QGLPixmapData::idealFormat(QImage &image, Qt::ImageConversionFlags flags)
+{
+ QImage::Format format = QImage::Format_RGB32;
+ if (qApp->desktop()->depth() == 16)
+ format = QImage::Format_RGB16;
+
+ if (image.hasAlphaChannel()
+ && ((flags & Qt::NoOpaqueDetection)
+ || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
+ format = QImage::Format_ARGB32_Premultiplied;
+
+ return format;
+}
+
void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
{
if (image.size() == QSize(w, h))
@@ -498,26 +528,25 @@ void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags
resize(image.width(), image.height());
if (pixelType() == BitmapType) {
- m_source = image.convertToFormat(QImage::Format_MonoLSB);
+ QImage convertedImage = image.convertToFormat(QImage::Format_MonoLSB);
+ if (image.format() == QImage::Format_MonoLSB)
+ convertedImage.detach();
- } else {
- QImage::Format format = QImage::Format_RGB32;
- if (qApp->desktop()->depth() == 16)
- format = QImage::Format_RGB16;
+ m_source = QVolatileImage(convertedImage);
- if (image.hasAlphaChannel()
- && ((flags & Qt::NoOpaqueDetection)
- || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
- format = QImage::Format_ARGB32_Premultiplied;
+ } else {
+ QImage::Format format = idealFormat(image, flags);
if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
- m_source = image;
+ m_source = QVolatileImage(image);
} else {
- m_source = image.convertToFormat(format);
+ QImage convertedImage = image.convertToFormat(format);
// convertToFormat won't detach the image if format stays the same.
if (image.format() == format)
- m_source.detach();
+ convertedImage.detach();
+
+ m_source = QVolatileImage(convertedImage);
}
}
@@ -596,16 +625,13 @@ void QGLPixmapData::fill(const QColor &color)
}
if (useFramebufferObjects()) {
- m_source = QImage();
+ m_source = QVolatileImage();
m_hasFillColor = true;
m_fillColor = color;
} else {
+ forceToImage();
- if (m_source.isNull()) {
- m_fillColor = color;
- m_hasFillColor = true;
-
- } else if (m_source.depth() == 32) {
+ if (m_source.depth() == 32) {
m_source.fill(PREMUL(color.rgba()));
} else if (m_source.depth() == 1) {
@@ -656,13 +682,15 @@ QImage QGLPixmapData::toImage() const
if (m_renderFbo) {
copyBackFromRenderFbo(true);
} else if (!m_source.isNull()) {
- QImageData *data = const_cast<QImage &>(m_source).data_ptr();
- if (data->paintEngine && data->paintEngine->isActive()
- && data->paintEngine->paintDevice() == &m_source)
- {
- return m_source.copy();
+ // QVolatileImage::toImage() will make a copy always so no check
+ // for active painting is needed.
+ QImage img = m_source.toImage();
+ if (img.format() == QImage::Format_MonoLSB) {
+ img.setColorCount(2);
+ img.setColor(0, QColor(Qt::color0).rgba());
+ img.setColor(1, QColor(Qt::color1).rgba());
}
- return m_source;
+ return img;
} else if (m_dirty || m_hasFillColor) {
return fillImage(m_fillColor);
} else {
@@ -802,7 +830,7 @@ GLuint QGLPixmapData::bind(bool copyBack) const
if (m_hasFillColor) {
if (!useFramebufferObjects()) {
- m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
+ m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied);
m_source.fill(PREMUL(m_fillColor.rgba()));
}
@@ -811,7 +839,7 @@ GLuint QGLPixmapData::bind(bool copyBack) const
GLenum format = qt_gl_preferredTextureFormat();
QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.bits());
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.constBits());
}
return id;
@@ -888,8 +916,12 @@ void QGLPixmapData::forceToImage()
if (!isValid())
return;
- if (m_source.isNull())
- m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
+ if (m_source.isNull()) {
+ QImage::Format format = QImage::Format_ARGB32_Premultiplied;
+ if (pixelType() == BitmapType)
+ format = QImage::Format_MonoLSB;
+ m_source = QVolatileImage(w, h, format);
+ }
m_dirty = true;
}
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index 2924d41..0d2ed9e 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -195,14 +195,16 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
if (!conversionLessFormat(source.format())) {
// Here we may need to copy if the formats do not match.
// (e.g. for display modes other than EColor16MAP and EColor16MU)
- source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor));
+ source.beginDataAccess();
+ QImage::Format format = idealFormat(&source.imageRef(), Qt::AutoColor);
+ source.endDataAccess(true);
+ source.ensureFormat(format);
}
recreate = true;
} else if (type == QPixmapData::VolatileImage && pixmap) {
QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
resize(img->width(), img->height());
source = *img;
- source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor));
recreate = true;
} else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
destroyImages();
@@ -282,8 +284,6 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
// Just duplicate the bitmap handle, no data copying happens.
return source.duplicateNativeImage();
- } else if (type == QPixmapData::VolatileImage) {
- return &source;
}
return 0;
}
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
index 13eab7f..c904c3c 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -59,10 +59,16 @@
#include "qmeegographicssystem.h"
#include "qmeegoextensions.h"
+#include <QTimer>
+
bool QMeeGoGraphicsSystem::surfaceWasCreated = false;
QHash <Qt::HANDLE, QPixmap*> QMeeGoGraphicsSystem::liveTexturePixmaps;
+QList<QMeeGoSwitchCallback> QMeeGoGraphicsSystem::switchCallbacks;
+
+QMeeGoGraphicsSystem::SwitchPolicy QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::AutomaticSwitch;
+
QMeeGoGraphicsSystem::QMeeGoGraphicsSystem()
{
qDebug("Using the meego graphics system");
@@ -74,6 +80,115 @@ QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
qt_destroy_gl_share_widget();
}
+class QMeeGoGraphicsSystemSwitchHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QMeeGoGraphicsSystemSwitchHandler();
+
+ void addWidget(QWidget *widget);
+ bool eventFilter(QObject *, QEvent *);
+
+ void handleMapNotify();
+
+private slots:
+ void removeWidget(QObject *object);
+ void switchToRaster();
+ void switchToMeeGo();
+
+private:
+ int visibleWidgets() const;
+
+private:
+ QList<QWidget *> m_widgets;
+};
+
+typedef bool(*QX11FilterFunction)(XEvent *event);
+Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func);
+
+static bool x11EventFilter(XEvent *event);
+
+QMeeGoGraphicsSystemSwitchHandler::QMeeGoGraphicsSystemSwitchHandler()
+{
+ qt_installX11EventFilter(x11EventFilter);
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::addWidget(QWidget *widget)
+{
+ if (widget != qt_gl_share_widget() && !m_widgets.contains(widget)) {
+ widget->installEventFilter(this);
+ connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(removeWidget(QObject *)));
+ m_widgets << widget;
+ }
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::handleMapNotify()
+{
+ if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
+ QTimer::singleShot(0, this, SLOT(switchToMeeGo()));
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::removeWidget(QObject *object)
+{
+ m_widgets.removeOne(static_cast<QWidget *>(object));
+ if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
+ QTimer::singleShot(0, this, SLOT(switchToRaster()));
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::switchToRaster()
+{
+ QMeeGoGraphicsSystem::switchToRaster();
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::switchToMeeGo()
+{
+ QMeeGoGraphicsSystem::switchToMeeGo();
+}
+
+int QMeeGoGraphicsSystemSwitchHandler::visibleWidgets() const
+{
+ int count = 0;
+ for (int i = 0; i < m_widgets.size(); ++i)
+ count += m_widgets.at(i)->isVisible() && !(m_widgets.at(i)->windowState() & Qt::WindowMinimized);
+ return count;
+}
+
+bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *event)
+{
+ if (event->type() == QEvent::WindowStateChange
+ && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
+ {
+ QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);
+ QWidget *widget = static_cast<QWidget *>(object);
+
+ Qt::WindowStates current = widget->windowState();
+ Qt::WindowStates old = change->oldState();
+
+ // did minimized flag change?
+ if ((current ^ old) & Qt::WindowMinimized) {
+ if (current & Qt::WindowMinimized) {
+ if (visibleWidgets() == 0)
+ QMeeGoGraphicsSystem::switchToRaster();
+ } else {
+ if (visibleWidgets() == 1)
+ QMeeGoGraphicsSystem::switchToMeeGo();
+ }
+ }
+ }
+
+ // resume processing of event
+ return false;
+}
+
+Q_GLOBAL_STATIC(QMeeGoGraphicsSystemSwitchHandler, switch_handler)
+
+bool x11EventFilter(XEvent *event)
+{
+ if (event->type == MapNotify)
+ switch_handler()->handleMapNotify();
+ return false;
+}
+
QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
{
QGLWidget *shareWidget = qt_gl_share_widget();
@@ -83,6 +198,9 @@ QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
QGLShareContextScope ctx(shareWidget->context());
+ if (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime"))
+ switch_handler()->addWidget(widget);
+
QMeeGoGraphicsSystem::surfaceWasCreated = true;
QWindowSurface *surface = new QGLWindowSurface(widget);
return surface;
@@ -203,18 +321,7 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
bool QMeeGoGraphicsSystem::meeGoRunning()
{
- if (! QApplicationPrivate::instance()) {
- qWarning("Application not running just yet... hard to know what system running!");
- return false;
- }
-
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == "runtime") {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- name = rsystem->graphicsSystemName();
- }
-
- return (name == "meego");
+ return runningGraphicsSystemName() == "meego";
}
QPixmapData* QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
@@ -259,6 +366,69 @@ void QMeeGoGraphicsSystem::destroyFenceSync(void *fenceSync)
QMeeGoExtensions::eglDestroySyncKHR(QEgl::display(), fenceSync);
}
+QString QMeeGoGraphicsSystem::runningGraphicsSystemName()
+{
+ if (!QApplicationPrivate::instance()) {
+ qWarning("Querying graphics system but application not running yet!");
+ return QString();
+ }
+
+ QString name = QApplicationPrivate::instance()->graphics_system_name;
+ if (name == QLatin1String("runtime")) {
+ QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
+ name = rsystem->graphicsSystemName();
+ }
+
+ return name;
+}
+
+void QMeeGoGraphicsSystem::switchToMeeGo()
+{
+ if (switchPolicy == NoSwitch || meeGoRunning())
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
+ else {
+ triggerSwitchCallbacks(0, "meego");
+
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("meego"));
+
+ triggerSwitchCallbacks(1, "meego");
+ }
+}
+
+void QMeeGoGraphicsSystem::switchToRaster()
+{
+ if (switchPolicy == NoSwitch || runningGraphicsSystemName() == QLatin1String("raster"))
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
+ else {
+ triggerSwitchCallbacks(0, "raster");
+
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("raster"));
+
+ QMeeGoLivePixmapData::invalidateSurfaces();
+
+ triggerSwitchCallbacks(1, "raster");
+ }
+}
+
+void QMeeGoGraphicsSystem::registerSwitchCallback(QMeeGoSwitchCallback callback)
+{
+ switchCallbacks << callback;
+}
+
+void QMeeGoGraphicsSystem::triggerSwitchCallbacks(int type, const char *name)
+{
+ for (int i = 0; i < switchCallbacks.size(); ++i)
+ switchCallbacks.at(i)(type, name);
+}
+
/* C API */
int qt_meego_image_to_egl_shared_image(const QImage &image)
@@ -340,3 +510,25 @@ void qt_meego_invalidate_live_surfaces(void)
{
return QMeeGoLivePixmapData::invalidateSurfaces();
}
+
+void qt_meego_switch_to_raster(void)
+{
+ QMeeGoGraphicsSystem::switchToRaster();
+}
+
+void qt_meego_switch_to_meego(void)
+{
+ QMeeGoGraphicsSystem::switchToMeeGo();
+}
+
+void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback)
+{
+ QMeeGoGraphicsSystem::registerSwitchCallback(callback);
+}
+
+void qt_meego_set_switch_policy(int policy)
+{
+ QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::SwitchPolicy(policy);
+}
+
+#include "qmeegographicssystem.moc"
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
index 27a4e7a..3528425 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
@@ -47,9 +47,13 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+extern "C" typedef void (*QMeeGoSwitchCallback)(int type, const char *name);
+
class QMeeGoGraphicsSystem : public QGraphicsSystem
{
public:
+ enum SwitchPolicy { AutomaticSwitch, ManualSwitch, NoSwitch };
+
QMeeGoGraphicsSystem();
~QMeeGoGraphicsSystem();
@@ -76,13 +80,23 @@ public:
static void* createFenceSync();
static void destroyFenceSync(void* fenceSync);
+ static void switchToRaster();
+ static void switchToMeeGo();
+ static QString runningGraphicsSystemName();
+
+ static void registerSwitchCallback(QMeeGoSwitchCallback callback);
+
+ static SwitchPolicy switchPolicy;
+
private:
static bool meeGoRunning();
static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap);
static void destroySurfaceForLiveTexturePixmap(QPixmapData* pmd);
+ static void triggerSwitchCallbacks(int type, const char *name);
static bool surfaceWasCreated;
- static QHash <Qt::HANDLE, QPixmap*> liveTexturePixmaps;
+ static QHash<Qt::HANDLE, QPixmap*> liveTexturePixmaps;
+ static QList<QMeeGoSwitchCallback> switchCallbacks;
};
/* C api */
@@ -95,7 +109,7 @@ extern "C" {
Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle);
Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height);
Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height);
- Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
+ Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle);
Q_DECL_EXPORT QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync);
@@ -104,6 +118,10 @@ extern "C" {
Q_DECL_EXPORT void* qt_meego_create_fence_sync(void);
Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs);
Q_DECL_EXPORT void qt_meego_invalidate_live_surfaces(void);
+ Q_DECL_EXPORT void qt_meego_switch_to_raster(void);
+ Q_DECL_EXPORT void qt_meego_switch_to_meego(void);
+ Q_DECL_EXPORT void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback);
+ Q_DECL_EXPORT void qt_meego_set_switch_policy(int policy);
}
#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
index 2a2a098..0970b89 100644
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
@@ -219,7 +219,7 @@ QImage* QMeeGoLivePixmapData::lock(EGLSyncKHR fenceSync)
return &lockedImage;
}
- lockedImage = QImage((uchar *) data, width(), height(), format);
+ lockedImage = QImage((uchar *) data, width(), height(), pitch, format);
return &lockedImage;
}
diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def
index 87d1b56..f52932c 100644
--- a/src/s60installs/bwins/QtOpenGLu.def
+++ b/src/s60installs/bwins/QtOpenGLu.def
@@ -718,4 +718,5 @@ EXPORTS
?releaseCachedResources@QGLGraphicsSystem@@UAEXXZ @ 717 NONAME ; void QGLGraphicsSystem::releaseCachedResources(void)
?serialNumber@QGLTextureGlyphCache@@QBEHXZ @ 718 NONAME ; int QGLTextureGlyphCache::serialNumber(void) const
?forceToImage@QGLPixmapData@@QAEXXZ @ 719 NONAME ; void QGLPixmapData::forceToImage(void)
+ ?idealFormat@QGLPixmapData@@QAE?AW4Format@QImage@@AAV3@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 720 NONAME ; enum QImage::Format QGLPixmapData::idealFormat(class QImage &, class QFlags<enum Qt::ImageConversionFlag>)
diff --git a/src/s60installs/eabi/QtOpenGLu.def b/src/s60installs/eabi/QtOpenGLu.def
index 4c5dca9..f7a7f71 100644
--- a/src/s60installs/eabi/QtOpenGLu.def
+++ b/src/s60installs/eabi/QtOpenGLu.def
@@ -720,4 +720,5 @@ EXPORTS
_ZN13QGLPixmapData21detachTextureFromPoolEv @ 719 NONAME
_ZN13QGLPixmapData9hibernateEv @ 720 NONAME
_ZN17QGLGraphicsSystem22releaseCachedResourcesEv @ 721 NONAME
+ _ZN13QGLPixmapData11idealFormatER6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 722 NONAME
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index 1e5ce0f..76f1dda 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -58,7 +58,7 @@ symbian: {
" \"$$pluginLocations/qts60plugin_5_0$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0$${QT_LIBINFIX}.dll\"" \
" \"$$bearerPluginLocation/qsymbianbearer$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qsymbianbearer$${QT_LIBINFIX}.dll\"" \
"ENDIF" \
- " \"$$bearerStubZ\" - \"c:$$replace(QT_PLUGINS_BASE_DIR,/,\\)\\bearer\\qsymbianbearer$${QT_LIBINFIX}.qtplugin\"
+ " \"$$bearerStubZ\" - \"c:$$replace(QT_PLUGINS_BASE_DIR,/,\\)\\bearer\\qsymbianbearer$${QT_LIBINFIX}.qtplugin\""
} else {
# No need to deploy plugins for older platform versions when building on Symbian3 or later
qts60plugindeployment = \
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml
new file mode 100644
index 0000000..31bf69d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml
@@ -0,0 +1,6 @@
+import QtQuick 1.0
+import Qt.test 1.0
+
+QtObject {
+ function writeValue2() { MyQmlObject.value2 = 9 }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 40b0e1b..48466d5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -639,15 +639,29 @@ void tst_qdeclarativeecmascript::overrideExtensionProperties()
void tst_qdeclarativeecmascript::attachedProperties()
{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 19);
- QCOMPARE(object->property("b").toInt(), 19);
- QCOMPARE(object->property("c").toInt(), 19);
- QCOMPARE(object->property("d").toInt(), 19);
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 19);
+ QCOMPARE(object->property("b").toInt(), 19);
+ QCOMPARE(object->property("c").toInt(), 19);
+ QCOMPARE(object->property("d").toInt(), 19);
+ }
- // ### Need to test attached property assignment
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("writeAttachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "writeValue2");
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(attached->value2(), 9);
+ }
}
void tst_qdeclarativeecmascript::enums()
diff --git a/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml
new file mode 100644
index 0000000..29fba40
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml
@@ -0,0 +1,30 @@
+import QtQuick 1.0
+Rectangle {
+ width: 400
+ height: 400
+
+ Item {
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.bottom: blueHandle.top
+ anchors.right: blueHandle.left
+
+ Image {
+ id: iconImage
+ objectName: "iconImage"
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ source: "heart200.png"
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ }
+ }
+
+ Rectangle {
+ id: blueHandle
+ objectName: "blueHandle"
+ color: "blue"
+ width: 25
+ height: 25
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index f1fe2bd..9e090d2 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -89,6 +89,7 @@ private slots:
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
+ void sourceSize_QTBUG_16389();
void nullPixmapPaint();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -640,6 +641,29 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(sourceSizeSpy.count(), 2);
}
+void tst_qdeclarativeimage::sourceSize_QTBUG_16389()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QDeclarativeImage *image = findItem<QDeclarativeImage>(canvas->rootObject(), "iconImage");
+ QDeclarativeItem *handle = findItem<QDeclarativeItem>(canvas->rootObject(), "blueHandle");
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 0.0);
+ QCOMPARE(image->paintedHeight(), 0.0);
+
+ handle->setY(20);
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 20.0);
+ QCOMPARE(image->paintedHeight(), 20.0);
+}
+
static int numberOfWarnings = 0;
static void checkWarnings(QtMsgType, const char *)
{
diff --git a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
index a361bdc..0f94840 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
@@ -9,7 +9,7 @@ PathView {
startX: 0; startY: 100
PathLine { x: 400; y: 100 }
}
- delegate: Rectangle { height: 100; width: 1; color: PathView.isCurrentItem?"red" : "black" }
+ delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" }
dragMargin: 100
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index ebb5f98..8000137 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -111,6 +111,7 @@ private slots:
void undefinedPath();
void mouseDrag();
void treeModel();
+ void changePreferredHighlight();
private:
QDeclarativeView *createView();
@@ -948,6 +949,45 @@ void tst_QDeclarativePathView::treeModel()
delete canvas;
}
+void tst_QDeclarativePathView::changePreferredHighlight()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setFixedSize(400,200);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml"));
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+ QCOMPARE(current, 0);
+
+ QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.5);
+ start.setX(qRound(start.x()));
+ start.setY(qRound(start.y()));
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ pathview->setPreferredHighlightBegin(0.8);
+ pathview->setPreferredHighlightEnd(0.8);
+ start = path->pointAt(0.8);
+ start.setX(qRound(start.x()));
+ start.setY(qRound(start.y()));
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentIndex(), 0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 2d52642..581b58c 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -1206,13 +1206,13 @@ void tst_qdeclarativetext::lineHeight()
myText->setLineHeightMode(QDeclarativeText::ProportionalHeight);
myText->setLineHeight(1.0);
- //qreal h2 = myText->height();
+ qreal h2 = myText->height();
myText->setLineHeight(2.0);
- //QVERIFY(myText->height() == h2 * 2.0);
+ QVERIFY(myText->height() == h2 * 2.0);
myText->setLineHeightMode(QDeclarativeText::FixedHeight);
myText->setLineHeight(10);
- //QCOMPARE(myText->height(), myText->lineCount() * 10.0);
+ QCOMPARE(myText->height(), myText->lineCount() * 10.0);
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
new file mode 100644
index 0000000..6bdb4a5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
@@ -0,0 +1 @@
+var data = "World"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
new file mode 100644
index 0000000..0385d91
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
@@ -0,0 +1,5 @@
+WorkerScript.onMessage = function(msg) {
+ var res = Qt.include("Global.js");
+ WorkerScript.sendMessage(msg + " " + data)
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
new file mode 100644
index 0000000..595cb2b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+BaseWorker {
+ source: "script_include.js"
+}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 4b922fb..b64e10c 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -79,6 +79,7 @@ private slots:
void messaging_sendQObjectList();
void messaging_sendJsObject();
void script_with_pragma();
+ void script_included();
void scriptError_onLoad();
void scriptError_onCall();
@@ -226,6 +227,24 @@ void tst_QDeclarativeWorkerScript::script_with_pragma()
delete worker;
}
+void tst_QDeclarativeWorkerScript::script_included()
+{
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_include.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QString value("Hello");
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
+
+ qApp->processEvents();
+ delete worker;
+}
+
static QString qdeclarativeworkerscript_lastWarning;
static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg)
{
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index dacb61e..168f75e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -447,7 +447,8 @@ private slots:
void updateMicroFocus();
void textItem_shortcuts();
void scroll();
- void stopClickFocusPropagation();
+ void focusHandling_data();
+ void focusHandling();
void deviceCoordinateCache_simpleRotations();
// task specific tests below me
@@ -10537,8 +10538,39 @@ void tst_QGraphicsItem::scroll()
QCOMPARE(item2->lastExposedRect, expectedItem2Expose);
}
-void tst_QGraphicsItem::stopClickFocusPropagation()
+Q_DECLARE_METATYPE(QGraphicsItem::GraphicsItemFlag);
+
+void tst_QGraphicsItem::focusHandling_data()
{
+ QTest::addColumn<QGraphicsItem::GraphicsItemFlag>("focusFlag");
+ QTest::addColumn<bool>("useStickyFocus");
+ QTest::addColumn<int>("expectedFocusItem"); // 0: none, 1: focusableUnder, 2: itemWithFocus
+
+ QTest::newRow("Focus goes through.")
+ << static_cast<QGraphicsItem::GraphicsItemFlag>(0x0) << false << 1;
+
+ QTest::newRow("Focus goes through, even with sticky scene.")
+ << static_cast<QGraphicsItem::GraphicsItemFlag>(0x0) << true << 1;
+
+ QTest::newRow("With ItemStopsClickFocusPropagation, we cannot focus the item beneath the flagged one (but can still focus-out).")
+ << QGraphicsItem::ItemStopsClickFocusPropagation << false << 0;
+
+ QTest::newRow("With ItemStopsClickFocusPropagation, we cannot focus the item beneath the flagged one (and cannot focus-out if scene is sticky).")
+ << QGraphicsItem::ItemStopsClickFocusPropagation << true << 2;
+
+ QTest::newRow("With ItemStopsFocusHandling, focus cannot be changed by presses.")
+ << QGraphicsItem::ItemStopsFocusHandling << false << 2;
+
+ QTest::newRow("With ItemStopsFocusHandling, focus cannot be changed by presses (even if scene is sticky).")
+ << QGraphicsItem::ItemStopsFocusHandling << true << 2;
+}
+
+void tst_QGraphicsItem::focusHandling()
+{
+ QFETCH(QGraphicsItem::GraphicsItemFlag, focusFlag);
+ QFETCH(bool, useStickyFocus);
+ QFETCH(int, expectedFocusItem);
+
class MyItem : public QGraphicsRectItem
{
public:
@@ -10549,12 +10581,9 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
}
};
- QGraphicsScene scene(-50, -50, 400, 400);
- scene.setStickyFocus(true);
-
QGraphicsRectItem *noFocusOnTop = new MyItem;
+ noFocusOnTop->setFlag(QGraphicsItem::ItemIsFocusable, false);
noFocusOnTop->setBrush(Qt::yellow);
- noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
QGraphicsRectItem *focusableUnder = new MyItem;
focusableUnder->setBrush(Qt::blue);
@@ -10566,9 +10595,13 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable);
itemWithFocus->setPos(250, 10);
+ QGraphicsScene scene(-50, -50, 400, 400);
scene.addItem(noFocusOnTop);
scene.addItem(focusableUnder);
scene.addItem(itemWithFocus);
+ scene.setStickyFocus(useStickyFocus);
+
+ noFocusOnTop->setFlag(focusFlag);
focusableUnder->stackBefore(noFocusOnTop);
itemWithFocus->setFocus();
@@ -10580,14 +10613,28 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
QVERIFY(itemWithFocus->hasFocus());
- QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF());
- mousePressPoint.rx() += 60;
- mousePressPoint.ry() += 60;
+ const QPointF mousePressPoint = noFocusOnTop->mapToScene(noFocusOnTop->boundingRect().center());
const QList<QGraphicsItem *> itemsAtMousePressPosition = scene.items(mousePressPoint);
- QVERIFY(itemsAtMousePressPosition.contains(focusableUnder));
+ QVERIFY(itemsAtMousePressPosition.contains(noFocusOnTop));
sendMousePress(&scene, mousePressPoint);
- QVERIFY(itemWithFocus->hasFocus());
+
+ switch (expectedFocusItem) {
+ case 0:
+ QCOMPARE(scene.focusItem(), static_cast<QGraphicsRectItem *>(0));
+ break;
+ case 1:
+ QCOMPARE(scene.focusItem(), focusableUnder);
+ break;
+ case 2:
+ QCOMPARE(scene.focusItem(), itemWithFocus);
+ break;
+ }
+
+ // Sanity check - manually setting the focus must work regardless of our
+ // focus handling flags:
+ focusableUnder->setFocus();
+ QCOMPARE(scene.focusItem(), focusableUnder);
}
void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index bd9c26f..464cd3b 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -52,6 +52,7 @@
#include <qsplashscreen.h>
#include <private/qpixmapdata_p.h>
+#include <private/qdrawhelper_p.h>
#include <QSet>
@@ -1264,7 +1265,10 @@ void tst_QPixmap::fromSymbianCFbsBitmap()
QCOMPARE(actualColor, color);
QImage shouldBe(pixmap.width(), pixmap.height(), image.format());
- shouldBe.fill(color.rgba());
+ if (image.format() == QImage::Format_RGB16)
+ shouldBe.fill(qrgb565(color.rgba()).rawValue());
+ else
+ shouldBe.fill(color.rgba());
QCOMPARE(image, shouldBe);
}
__UHEAP_MARKEND;
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
index ac32995..6778bd5 100644
--- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
@@ -47,7 +47,6 @@
#include <private/qpixmap_raster_p.h>
#include <private/qwindowsurface_gl_p.h>
#include "qmeegoruntime.h"
-#include "qmeegoswitchevent.h"
QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName()
{
@@ -77,46 +76,12 @@ bool QMeeGoGraphicsSystemHelper::isRunningRuntime()
void QMeeGoGraphicsSystemHelper::switchToMeeGo()
{
- if (isRunningMeeGo())
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
- else {
- QMeeGoSwitchEvent willSwitchEvent(QLatin1String("meego"), QMeeGoSwitchEvent::WillSwitch);
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- QCoreApplication::sendEvent(widget, &willSwitchEvent);
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("meego"));
-
- QMeeGoSwitchEvent didSwitchEvent(QLatin1String("meego"), QMeeGoSwitchEvent::DidSwitch);
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- QCoreApplication::sendEvent(widget, &didSwitchEvent);
- }
+ QMeeGoRuntime::switchToMeeGo();
}
void QMeeGoGraphicsSystemHelper::switchToRaster()
{
- if (runningGraphicsSystemName() == QLatin1String("raster"))
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
- else {
- QMeeGoSwitchEvent willSwitchEvent(QLatin1String("raster"), QMeeGoSwitchEvent::WillSwitch);
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- QCoreApplication::sendEvent(widget, &willSwitchEvent);
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("raster"));
-
- QMeeGoRuntime::invalidateLiveSurfaces();
-
- QMeeGoSwitchEvent didSwitchEvent(QLatin1String("raster"), QMeeGoSwitchEvent::DidSwitch);
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- QCoreApplication::sendEvent(widget, &didSwitchEvent);
- }
+ QMeeGoRuntime::switchToRaster();
}
Qt::HANDLE QMeeGoGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image)
@@ -170,3 +135,13 @@ void QMeeGoGraphicsSystemHelper::setSwapBehavior(SwapMode mode)
else if (mode == KillSwap)
QGLWindowSurface::swapBehavior = QGLWindowSurface::KillSwap;
}
+
+void QMeeGoGraphicsSystemHelper::setSwitchPolicy(SwitchPolicy policy)
+{
+ QMeeGoRuntime::setSwitchPolicy(policy);
+}
+
+void QMeeGoGraphicsSystemHelper::enableSwitchEvents()
+{
+ QMeeGoRuntime::enableSwitchEvents();
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
index 5a3b57e..4612190 100644
--- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
@@ -97,14 +97,22 @@ public:
*/
static bool isRunningRuntime();
+ //! Enables the sending of QMeeGoSwitchEvent's when the graphicssystem switches.
+ /*!
+ An application that wishes to start receive QMeegoSwitchEvents must call this function.
+ */
+ static void enableSwitchEvents();
+
//! Switches to meego graphics system.
/*!
When running with the 'runtime' graphics system, sets the currently active
system to 'meego'. The window surface and all the resources are automatically
migrated to OpenGL. Will fail if the active graphics system is not 'runtime'.
Calling this function will emit QMeeGoSwitchEvent to the top level widgets.
- Two events will be emitted for each switch -- one before the switch (QMeeGoSwitchEvent::WillSwitch)
- and one after the switch (QMeeGoSwitchEvent::DidSwitch).
+ If switch events are enabled, two events will be emitted for each switch --
+ one before the switch (QMeeGoSwitchEvent::WillSwitch) and one after the
+ switch (QMeeGoSwitchEvent::DidSwitch).
+ If the switch policy is set to NoSwitch, this function has no effect.
*/
static void switchToMeeGo();
@@ -114,12 +122,30 @@ public:
system to 'raster'. The window surface and the graphics resources (including the
EGL shared image resources) are automatically migrated back to the CPU. All OpenGL
resources (surface, context, cache, font cache) are automaticall anihilated.
- Calling this function will emit QMeeGoSwitchEvent to the top level widgets.
- Two events will be emitted for each switch -- one before the switch (QMeeGoSwitchEvent::WillSwitch)
- and one after the switch (QMeeGoSwitchEvent::DidSwitch).
+ Calling this function will emit QMeeGoSwitchEvent to the top level widgets. If switch
+ events are enabled, two events will be emitted for each switch -- one before the
+ switch (QMeeGoSwitchEvent::WillSwitch) and one after the switch (QMeeGoSwitchEvent::DidSwitch).
+ If the switch policy is set to NoSwitch, this function has no effect.
*/
static void switchToRaster();
+ //! Used to specify the policy for graphics system switching.
+ enum SwitchPolicy {
+ AutomaticSwitch, /**< Automatic switching */
+ ManualSwitch, /**< Switching is controleld by the application */
+ NoSwitch /**< Switching is disabled completely */
+ };
+
+ //! Sets the policy of graphicssystem switching
+ /*!
+ By default, the switch to raster happens automatically when all windows are either
+ minimized or when the last window is destroyed. This function lets the application
+ change the graphicssystem switching policy to prevent the switching from happening
+ automatically (that is if the application doesn't want switching at all or wishes
+ to control the switching manually).
+ */
+ static void setSwitchPolicy(SwitchPolicy policy);
+
//! Returns the name of the active graphics system
/*!
Returns the name of the currently active system. If running with 'runtime' graphics
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
index 7c81d51..928d01a 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
@@ -41,6 +41,11 @@
#include "qmeegoruntime.h"
+#include "qmeegoswitchevent.h"
+
+#include <QtGui/QApplication>
+#include <QtGui/QWidget>
+
#include <private/qlibrary_p.h>
#include <private/qfactoryloader_p.h>
#include <private/qgraphicssystemplugin_p.h>
@@ -49,6 +54,7 @@
#define ENSURE_INITIALIZED {if (!initialized) initialize();}
bool QMeeGoRuntime::initialized = false;
+bool QMeeGoRuntime::switchEventsEnabled = false;
typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&);
typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&);
@@ -66,6 +72,10 @@ typedef Qt::HANDLE (*QMeeGoLiveTextureGetHandleFunc) (QPixmap*);
typedef void* (*QMeeGoCreateFenceSyncFunc) (void);
typedef void (*QMeeGoDestroyFenceSyncFunc) (void *fs);
typedef void (*QMeeGoInvalidateLiveSurfacesFunc) (void);
+typedef void (*QMeeGoSwitchToRasterFunc) (void);
+typedef void (*QMeeGoSwitchToMeeGoFunc) (void);
+typedef void (*QMeeGoRegisterSwitchCallbackFunc) (void (*callback)(int type, const char *name));
+typedef void (*QMeeGoSetSwitchPolicyFunc) (int policy);
static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL;
@@ -83,6 +93,17 @@ static QMeeGoLiveTextureGetHandleFunc qt_meego_live_texture_get_handle = NULL;
static QMeeGoCreateFenceSyncFunc qt_meego_create_fence_sync = NULL;
static QMeeGoDestroyFenceSyncFunc qt_meego_destroy_fence_sync = NULL;
static QMeeGoInvalidateLiveSurfacesFunc qt_meego_invalidate_live_surfaces = NULL;
+static QMeeGoSwitchToRasterFunc qt_meego_switch_to_raster = NULL;
+static QMeeGoSwitchToMeeGoFunc qt_meego_switch_to_meego = NULL;
+static QMeeGoRegisterSwitchCallbackFunc qt_meego_register_switch_callback = NULL;
+static QMeeGoSetSwitchPolicyFunc qt_meego_set_switch_policy = NULL;
+
+extern "C" void handleSwitch(int type, const char *name)
+{
+ QMeeGoSwitchEvent switchEvent((QLatin1String(name)), QMeeGoSwitchEvent::State(type));
+ foreach (QWidget *widget, QApplication::topLevelWidgets())
+ QCoreApplication::sendEvent(widget, &switchEvent);
+}
void QMeeGoRuntime::initialize()
{
@@ -112,13 +133,19 @@ void QMeeGoRuntime::initialize()
qt_meego_create_fence_sync = (QMeeGoCreateFenceSyncFunc) library.resolve("qt_meego_create_fence_sync");
qt_meego_destroy_fence_sync = (QMeeGoDestroyFenceSyncFunc) library.resolve("qt_meego_destroy_fence_sync");
qt_meego_invalidate_live_surfaces = (QMeeGoInvalidateLiveSurfacesFunc) library.resolve("qt_meego_invalidate_live_surfaces");
+ qt_meego_switch_to_raster = (QMeeGoSwitchToRasterFunc) library.resolve("qt_meego_switch_to_raster");
+ qt_meego_switch_to_meego = (QMeeGoSwitchToMeeGoFunc) library.resolve("qt_meego_switch_to_meego");
+ qt_meego_register_switch_callback = (QMeeGoRegisterSwitchCallbackFunc) library.resolve("qt_meego_register_switch_callback");
+ qt_meego_set_switch_policy = (QMeeGoSetSwitchPolicyFunc) library.resolve("qt_meego_set_switch_policy");
if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image &&
qt_meego_pixmapdata_with_gl_texture && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap &&
qt_meego_set_surface_fixed_size && qt_meego_set_surface_scaling && qt_meego_set_translucent &&
qt_meego_pixmapdata_with_new_live_texture && qt_meego_pixmapdata_from_live_texture_handle &&
qt_meego_live_texture_lock && qt_meego_live_texture_release && qt_meego_live_texture_get_handle &&
- qt_meego_create_fence_sync && qt_meego_destroy_fence_sync && qt_meego_invalidate_live_surfaces)
+ qt_meego_create_fence_sync && qt_meego_destroy_fence_sync && qt_meego_invalidate_live_surfaces &&
+ qt_meego_switch_to_raster && qt_meego_switch_to_meego && qt_meego_register_switch_callback &&
+ qt_meego_set_switch_policy)
{
qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion));
} else {
@@ -242,3 +269,34 @@ void QMeeGoRuntime::invalidateLiveSurfaces()
Q_ASSERT(qt_meego_invalidate_live_surfaces);
qt_meego_invalidate_live_surfaces();
}
+
+void QMeeGoRuntime::switchToRaster()
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_switch_to_raster);
+ qt_meego_switch_to_raster();
+}
+
+void QMeeGoRuntime::switchToMeeGo()
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_switch_to_meego);
+ qt_meego_switch_to_meego();
+}
+
+void QMeeGoRuntime::enableSwitchEvents()
+{
+ ENSURE_INITIALIZED;
+ if (!switchEventsEnabled) {
+ Q_ASSERT(qt_meego_register_switch_callback);
+ qt_meego_register_switch_callback(handleSwitch);
+ switchEventsEnabled = true;
+ }
+}
+
+void QMeeGoRuntime::setSwitchPolicy(QMeeGoGraphicsSystemHelper::SwitchPolicy policy)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_set_switch_policy);
+ qt_meego_set_switch_policy(int(policy));
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h
index b91efae..b898699 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.h
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h
@@ -42,6 +42,8 @@
#include <QPixmap>
#include <QImage>
+#include "qmeegographicssystemhelper.h"
+
class QMeeGoRuntime
{
public:
@@ -63,7 +65,12 @@ public:
static void* createFenceSync();
static void destroyFenceSync(void *fs);
static void invalidateLiveSurfaces();
+ static void switchToRaster();
+ static void switchToMeeGo();
+ static void enableSwitchEvents();
+ static void setSwitchPolicy(QMeeGoGraphicsSystemHelper::SwitchPolicy policy);
private:
static bool initialized;
+ static bool switchEventsEnabled;
};