aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-07-26 21:50:00 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-07-26 21:50:00 +0200
commit134ab4bd5ad895fbc7c2ca0324348519d33e19ba (patch)
tree1f23eaede274fb0708ef940a22d09aa99e68b925
parent46e758e985798ca659c79d39683ab000cf870354 (diff)
parentd5b4e460bde0c152da5b872ac8ed6f675bf227a9 (diff)
Merge remote-tracking branch 'origin/release' into stable
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetDelegate.qml6
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetsModel.qml96
-rw-r--r--examples/quick/demos/tweetsearch/content/tweetsearch.js61
-rw-r--r--examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc45
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.pro5
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qml20
-rw-r--r--examples/quick/text/doc/src/text.qdoc2
-rw-r--r--src/imports/dialogs/DefaultColorDialog.qml27
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog_p.h8
-rw-r--r--src/qml/doc/src/external-resources.qdoc4
-rw-r--r--src/qml/doc/src/javascript/date.qdoc3
-rw-r--r--src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc2
-rw-r--r--src/qml/doc/src/qmltypereference.qdoc10
-rw-r--r--src/qml/doc/src/qtqml.qdoc5
-rw-r--r--src/qml/qml/qqmlengine.cpp5
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp6
-rw-r--r--tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml2
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp52
-rw-r--r--tests/auto/quick/qquicktextedit/data/hAlignVisual.qml2
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp68
20 files changed, 313 insertions, 116 deletions
diff --git a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
index 8cd22110d4..e8bfff437b 100644
--- a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
+++ b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
@@ -103,7 +103,7 @@ Item {
Text {
id: name
- text: Helper.realName(model.name)
+ text: model.name
anchors { left: avatar.right; leftMargin: 10; top: avatar.top; topMargin: -3 }
font.pixelSize: 12
font.bold: true
@@ -121,7 +121,7 @@ Item {
color: "#adebff"
linkColor: "white"
onLinkActivated: {
- var tag = link.split("http://search.twitter.com/search?q=%23")
+ var tag = link.split("https://twitter.com/search?q=%23")
var user = link.split("https://twitter.com/")
if (tag[1] != undefined) {
mainListView.positionViewAtBeginning()
@@ -166,7 +166,7 @@ Item {
Text {
id: username
- text: Helper.twitterName(model.name)
+ text: model.twitterName
x: 10; anchors { top: avatar2.top; topMargin: -3 }
font.pixelSize: 12
font.bold: true
diff --git a/examples/quick/demos/tweetsearch/content/TweetsModel.qml b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
index cd91a787b7..7d813d18c8 100644
--- a/examples/quick/demos/tweetsearch/content/TweetsModel.qml
+++ b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
@@ -39,53 +39,87 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.XmlListModel 2.0
+import "tweetsearch.js" as Helper
Item {
id: wrapper
- property variant model: xmlModel
+ // Insert valid consumer key and secret tokens below
+ // See https://dev.twitter.com/apps
+//! [auth tokens]
+ property string consumerKey : ""
+ property string consumerSecret : ""
+//! [auth tokens]
+ property string bearerToken : ""
+
+ property variant model: tweets
property string from : ""
property string phrase : ""
- property string mode : "everyone"
- property int status: xmlModel.status
-
- function reload() { xmlModel.reload(); }
-
- property bool isLoading: status == XmlListModel.Loading
+ property int status: XMLHttpRequest.UNSENT
+ property bool isLoading: status === XMLHttpRequest.LOADING
property bool wasLoading: false
signal isLoaded
- XmlListModel {
- id: xmlModel
+ ListModel { id: tweets }
- onStatusChanged: {
- if (status == XmlListModel.Ready && wasLoading == true)
- wrapper.isLoaded()
- if (status == XmlListModel.Loading)
- wasLoading = true;
- else
- wasLoading = false;
- }
+ function encodePhrase(x) { return encodeURIComponent(x); }
- function encodePhrase(x) { return encodeURIComponent(x); }
+ function reload() {
+ tweets.clear()
- source: (from == "" && phrase == "") ? "" :
- 'http://search.twitter.com/search.atom?from='+from+"&rpp=10&phrase="+encodePhrase(phrase)
+ if (from == "" && phrase == "")
+ return;
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
- "declare namespace twitter=\"http://api.twitter.com/\";";
+//! [requesting]
+ var req = new XMLHttpRequest;
+ req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from +
+ "&count=10&q=" + encodePhrase(phrase));
+ req.setRequestHeader("Authorization", "Bearer " + bearerToken);
+ req.onreadystatechange = function() {
+ status = req.readyState;
+ if (status === XMLHttpRequest.DONE) {
+ var objectArray = JSON.parse(req.responseText);
+ if (objectArray.errors !== undefined)
+ console.log("Error fetching tweets: " + objectArray.errors[0].message)
+ else {
+ for (var key in objectArray.statuses) {
+ var jsonObject = objectArray.statuses[key];
+ tweets.append(jsonObject);
+ }
+ }
+ if (wasLoading == true)
+ wrapper.isLoaded()
+ }
+ wasLoading = (status === XMLHttpRequest.LOADING);
+ }
+ req.send();
+//! [requesting]
+ }
- query: "/feed/entry"
+ onPhraseChanged: reload();
+ onFromChanged: reload();
- XmlRole { name: "id"; query: "id/string()" }
- XmlRole { name: "content"; query: "content/string()" }
- XmlRole { name: "published"; query: "published/string()" }
- XmlRole { name: "source"; query: "twitter:source/string()" }
- XmlRole { name: "name"; query: "author/name/string()" }
- XmlRole { name: "uri"; query: "author/uri/string()" }
- XmlRole { name: "image"; query: "link[@rel = 'image']/@href/string()" }
+ Component.onCompleted: {
+ if (consumerKey === "" || consumerSecret == "") {
+ bearerToken = encodeURIComponent(Helper.demoToken())
+ return;
+ }
+ var authReq = new XMLHttpRequest;
+ authReq.open("POST", "https://api.twitter.com/oauth2/token");
+ authReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+ authReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(consumerKey + ":" + consumerSecret));
+ authReq.onreadystatechange = function() {
+ if (authReq.readyState === XMLHttpRequest.DONE) {
+ var jsonResponse = JSON.parse(authReq.responseText);
+ if (jsonResponse.errors !== undefined)
+ console.log("Authentication error: " + jsonResponse.errors[0].message)
+ else
+ bearerToken = jsonResponse.access_token;
+ }
+ }
+ authReq.send("grant_type=client_credentials");
}
+
}
diff --git a/examples/quick/demos/tweetsearch/content/tweetsearch.js b/examples/quick/demos/tweetsearch/content/tweetsearch.js
index 9b8638f69e..42a76c99fc 100644
--- a/examples/quick/demos/tweetsearch/content/tweetsearch.js
+++ b/examples/quick/demos/tweetsearch/content/tweetsearch.js
@@ -1,19 +1,62 @@
.pragma library
-function twitterName(str)
+function formatDate(date)
{
- var s = str.split("(")
- return s[0]
+ var da = new Date(date)
+ return da.toDateString()
}
-function realName(str)
+function demoToken()
{
- var s = str.split("(")
- return s[1].substring(0, s[1].length-1)
+ var a = new Array(22).join('A')
+ return a + String.fromCharCode(0x44, 0x69, 0x4a, 0x52, 0x51, 0x41, 0x41, 0x41, 0x41,
+ 0x41, 0x41, 0x74, 0x2b, 0x72, 0x6a, 0x6c, 0x2b, 0x71,
+ 0x6d, 0x7a, 0x30, 0x72, 0x63, 0x79, 0x2b, 0x42, 0x62,
+ 0x75, 0x58, 0x42, 0x42, 0x73, 0x72, 0x55, 0x48, 0x47,
+ 0x45, 0x67, 0x3d, 0x71, 0x30, 0x45, 0x4b, 0x32, 0x61,
+ 0x57, 0x71, 0x51, 0x4d, 0x62, 0x31, 0x35, 0x67, 0x43,
+ 0x5a, 0x4e, 0x77, 0x5a, 0x6f, 0x39, 0x79, 0x71, 0x61,
+ 0x65, 0x30, 0x68, 0x70, 0x65, 0x32, 0x46, 0x44, 0x73,
+ 0x53, 0x39, 0x32, 0x57, 0x41, 0x75, 0x30, 0x67)
}
-function formatDate(date)
+function linkForEntity(entity)
{
- var da = new Date(date)
- return da.toDateString()
+ return (entity.url ? entity.url :
+ (entity.screen_name ? 'https://twitter.com/' + entity.screen_name :
+ 'https://twitter.com/search?q=%23' + entity.text))
+}
+
+function textForEntity(entity)
+{
+ return (entity.display_url ? entity.display_url :
+ (entity.screen_name ? entity.screen_name : entity.text))
+}
+
+function insertLinks(text, entities)
+{
+ if (typeof text !== 'string')
+ return "";
+
+ if (!entities)
+ return text;
+
+ // Add all links (urls, usernames and hashtags) to an array and sort them in
+ // descending order of appearance in text
+ var links = []
+ if (entities.urls)
+ links = entities.urls.concat(entities.hashtags, entities.user_mentions)
+ else if (entities.url)
+ links = entities.url.urls
+
+ links.sort(function(a, b) { return b.indices[0] - a.indices[0] })
+
+ for (var i = 0; i < links.length; i++) {
+ var offset = links[i].url ? 0 : 1
+ text = text.substring(0, links[i].indices[0] + offset) +
+ '<a href=\"' + linkForEntity(links[i]) + '\">' +
+ textForEntity(links[i]) + '</a>' +
+ text.substring(links[i].indices[1])
+ }
+ return text.replace(/\n/g, '<br>');
}
diff --git a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
index 9ba252fcb5..a56ed0d7e9 100644
--- a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
+++ b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
@@ -32,5 +32,48 @@
\brief A Twitter search client with 3D effects.
\image qtquick-demo-tweetsearch-med-1.png
\image qtquick-demo-tweetsearch-med-2.png
-*/
+ \section1 Demo Introduction
+
+ The Tweet Search demo searches items posted to Twitter service
+ using a number of query parameters. Search can be done for tweets
+ from a specified user, a hashtag or a search phrase.
+
+ The search result is a list of items showing the contents of the
+ tweet as well as the name and image of the user who posted it.
+ Hashtags, names and links in the content are clickable. Clicking
+ on the image will flip the item to reveal more information.
+
+ \section1 Running the Demo
+
+ Tweet Search uses Twitter API v1.1 for running seaches.
+
+ \section2 Authentication
+
+ Each request must be authenticated on behalf of the application.
+ For demonstration purposes, the application uses a hard-coded
+ token for identifying itself to the Twitter service. However, this
+ token is subject to rate limits for the number of requests as well
+ as possible expiration.
+
+ If you are having authentication or rate limit problems running the
+ demo, obtain a set of application-specific tokens (consumer
+ key and consumer secret) by registering a new application on
+ \l{https://dev.twitter.com/apps}.
+
+ Type in the two token values in \e {TweetsModel.qml}:
+
+ \snippet demos/tweetsearch/content/TweetsModel.qml auth tokens
+
+ Rebuild and run the demo.
+
+ \section2 JSON Parsing
+
+ Search results are returned in JSON (JavaScript Object Notation)
+ format. \c TweetsModel uses an \l XMLHTTPRequest object to send
+ an HTTP GET request, and calls JSON.parse() on the returned text
+ string to convert it to a JavaScript object. Each object
+ representing a tweet is then added to a \l ListModel:
+
+ \snippet demos/tweetsearch/content/TweetsModel.qml requesting
+*/
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.pro b/examples/quick/demos/tweetsearch/tweetsearch.pro
index b063cc4106..27c34bac5d 100644
--- a/examples/quick/demos/tweetsearch/tweetsearch.pro
+++ b/examples/quick/demos/tweetsearch/tweetsearch.pro
@@ -4,5 +4,10 @@ QT += quick qml
SOURCES += main.cpp
RESOURCES += tweetsearch.qrc
+OTHER_FILES = tweetsearch.qml \
+ content/*.qml \
+ content/*.js \
+ content/resources/*
+
target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch
INSTALLS += target
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qml b/examples/quick/demos/tweetsearch/tweetsearch.qml
index d7e77ceb4b..19d3b5e708 100644
--- a/examples/quick/demos/tweetsearch/tweetsearch.qml
+++ b/examples/quick/demos/tweetsearch/tweetsearch.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import "content"
+import "content/tweetsearch.js" as Helper
Rectangle {
id: main
@@ -47,7 +48,6 @@ Rectangle {
height: 480
color: "#d6d6d6"
- property string searchTerms: ""
property int inAnimDur: 250
property int counter: 0
property alias isLoading: tweetsModel.isLoading
@@ -85,13 +85,15 @@ Rectangle {
onTriggered: {
main.counter--;
var id = tweetsModel.model.get(idx[main.counter]).id
- mainListView.add( { "statusText": tweetsModel.model.get(main.counter).content,
- "name": tweetsModel.model.get(main.counter).name,
- "userImage": tweetsModel.model.get(main.counter).image,
- "source": tweetsModel.model.get(main.counter).source,
- "id": id,
- "uri": tweetsModel.model.get(main.counter).uri,
- "published": tweetsModel.model.get(main.counter).published } );
+ var item = tweetsModel.model.get(main.counter)
+ mainListView.add( { "statusText": Helper.insertLinks(item.text, item.entities),
+ "twitterName": item.user.screen_name,
+ "name" : item.user.name,
+ "userImage": item.user.profile_image_url,
+ "source": item.source,
+ "id": id,
+ "uri": Helper.insertLinks(item.user.url, item.user.entities),
+ "published": item.created_at } );
ids.push(id)
}
}
@@ -107,7 +109,7 @@ Rectangle {
PropertyAction { property: "appear"; value: 250 }
}
- onDragEnded: if (header.refresh) { tweetsModel.model.reload() }
+ onDragEnded: if (header.refresh) { tweetsModel.reload() }
ListHeader {
id: header
diff --git a/examples/quick/text/doc/src/text.qdoc b/examples/quick/text/doc/src/text.qdoc
index c93d2db8aa..3a300fbcf3 100644
--- a/examples/quick/text/doc/src/text.qdoc
+++ b/examples/quick/text/doc/src/text.qdoc
@@ -50,7 +50,7 @@
or finally using a FontLoader and specifying a remote font file:
\snippet text/fonts/fonts.qml fontloaderremote
- 'Available Fonts' shows how to use the QML global Qt object and a list view
+ 'Available Fonts' shows how to use the QML \l{QtQml::Qt}{Qt} global object and a list view
to display all the fonts available on the system.
The ListView type uses the list of fonts available as its model:
\snippet text/fonts/availableFonts.qml model
diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml
index 8636259957..44af99bf18 100644
--- a/src/imports/dialogs/DefaultColorDialog.qml
+++ b/src/imports/dialogs/DefaultColorDialog.qml
@@ -45,11 +45,23 @@ import "qml"
AbstractColorDialog {
id: root
+ property bool _valueSet: true // guard to prevent binding loops
+ function _setControlsFromColor() {
+ _valueSet = false
+ hueSlider.value = root.hue
+ saturationSlider.value = root.saturation
+ lightnessSlider.value = root.lightness
+ alphaSlider.value = root.alpha
+ crosshairs.x = root.lightness * paletteMap.width
+ crosshairs.y = (1.0 - root.saturation) * paletteMap.height
+ _valueSet = true
+ }
+ onColorChanged: _setControlsFromColor()
Rectangle {
id: content
property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
- implicitHeight: Math.max(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 10 : 5))
+ implicitHeight: Math.min(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 100 : 50))
implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5
color: palette.window
property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3
@@ -62,12 +74,6 @@ AbstractColorDialog {
SystemPalette { id: palette }
- Binding {
- target: root
- property: "color"
- value: Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
- }
-
Item {
id: paletteFrame
visible: content.usePaletteMap
@@ -83,6 +89,7 @@ AbstractColorDialog {
id: paletteMap
x: (parent.width - width) / 2
width: height
+ onWidthChanged: root._setControlsFromColor()
height: parent.height
source: "images/checkers.png"
fillMode: Image.Tile
@@ -197,6 +204,7 @@ AbstractColorDialog {
ColorSlider {
id: hueSlider
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Hue")
trackDelegate: Rectangle {
rotation: -90
@@ -217,6 +225,7 @@ AbstractColorDialog {
id: saturationSlider
visible: !content.usePaletteMap
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Saturation")
trackDelegate: Rectangle {
rotation: -90
@@ -232,6 +241,7 @@ AbstractColorDialog {
id: lightnessSlider
visible: !content.usePaletteMap
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Luminosity")
trackDelegate: Rectangle {
rotation: -90
@@ -249,6 +259,7 @@ AbstractColorDialog {
minimum: 0.0
maximum: 1.0
value: 1.0
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Alpha")
visible: root.showAlphaChannel
trackDelegate: Item {
@@ -273,7 +284,7 @@ AbstractColorDialog {
Item {
id: buttonRow
- height: buttonsOnly.height
+ height: Math.max(buttonsOnly.height, copyIcon.height)
width: parent.width
anchors {
left: parent.left
diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h
index 46f0f84acb..bd23e0d1a4 100644
--- a/src/imports/dialogs/qquickabstractcolordialog_p.h
+++ b/src/imports/dialogs/qquickabstractcolordialog_p.h
@@ -66,6 +66,10 @@ class QQuickAbstractColorDialog : public QQuickAbstractDialog
Q_OBJECT
Q_PROPERTY(bool showAlphaChannel READ showAlphaChannel WRITE setShowAlphaChannel NOTIFY showAlphaChannelChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged)
+ Q_PROPERTY(qreal saturation READ saturation NOTIFY colorChanged)
+ Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged)
+ Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged)
public:
QQuickAbstractColorDialog(QObject *parent = 0);
@@ -74,6 +78,10 @@ public:
virtual QString title() const;
bool showAlphaChannel() const;
QColor color() const { return m_color; }
+ qreal hue() const { return m_color.hslHueF(); }
+ qreal saturation() const { return m_color.hslSaturationF(); }
+ qreal lightness() const { return m_color.lightnessF(); }
+ qreal alpha() const { return m_color.alphaF(); }
public Q_SLOTS:
void setVisible(bool v);
diff --git a/src/qml/doc/src/external-resources.qdoc b/src/qml/doc/src/external-resources.qdoc
index 0832564660..671246d7ab 100644
--- a/src/qml/doc/src/external-resources.qdoc
+++ b/src/qml/doc/src/external-resources.qdoc
@@ -35,3 +35,7 @@
\title W3Schools JavaScript Reference
*/
+/*!
+ \externalpage https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
+ \title Mozilla Developer Network Date Reference
+*/ \ No newline at end of file
diff --git a/src/qml/doc/src/javascript/date.qdoc b/src/qml/doc/src/javascript/date.qdoc
index 7da24d4092..085d988377 100644
--- a/src/qml/doc/src/javascript/date.qdoc
+++ b/src/qml/doc/src/javascript/date.qdoc
@@ -30,7 +30,8 @@
\inqmlmodule QtQml 2
\brief Provides date functions
- The QML Date object extends the JS Date object with
+ The QML Date object extends the
+ \l{Mozilla Developer Network Date Reference}{JS Date object} with
locale aware functions.
Functions that accept a locale format may be either an enumeration
diff --git a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
index 7d2d662e4e..1d24acc31a 100644
--- a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
@@ -70,6 +70,8 @@ QML modules may extend the QML language with more basic types.
For example, the basic types provided by the \c QtQuick module are listed below:
\annotatedlist qtquickbasictypes
+The \l{QtQml::Qt}{Qt} global object provides useful functions for manipulating values of basic types.
+
Currently only QML modules which are provided by Qt may provide their
own basic types, however this may change in future releases of Qt QML.
In order to use types provided by a particular QML module, clients
diff --git a/src/qml/doc/src/qmltypereference.qdoc b/src/qml/doc/src/qmltypereference.qdoc
index 3def3209cc..0b363d424e 100644
--- a/src/qml/doc/src/qmltypereference.qdoc
+++ b/src/qml/doc/src/qmltypereference.qdoc
@@ -104,14 +104,10 @@ When integrating with C++, note that any QDate value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c date value, and vice-versa.
-Note that the date type has comparison semantics which match
-those of the JavaScript Date object. To compare the value
-of two date properties, you should compare their "toString()"
-values.
+This basic type is provided by the QML language. It can be implicitly converted
+to a \l{QtQml2::Date}{Date} object.
-This basic type is provided by the QML language.
-
-\sa {QML Basic Types}
+\sa {QtQml2::Date}{QML Date object}, {QML Basic Types}
*/
/*!
diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc
index 26e4867bbc..a260a3d785 100644
--- a/src/qml/doc/src/qtqml.qdoc
+++ b/src/qml/doc/src/qtqml.qdoc
@@ -75,7 +75,7 @@ The Qt QML module contains the QML framework and important QML types used in
applications. The constructs of QML are described in the \l{The QML Reference}.
In addition to the \l{QML Basic Types}, the module comes with
-various QML object types:
+the following QML object types:
\list
\li \l Component
\li \l QtObject
@@ -84,6 +84,9 @@ various QML object types:
\li \l Timer
\endlist
+The \l{QtQml::Qt}{Qt} global object provides useful enums and functions
+for various QML types.
+
\section2 Lists and Models
New in Qt 5.1, the model types are moved to a submodule, \c QtQml.Models. The
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 5a7a9f1928..fef3dd21fe 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -278,11 +278,8 @@ QQmlImageProviderBase::~QQmlImageProviderBase()
\inqmlmodule QtQml 2
\instantiates QQmlEnginePrivate
\ingroup qml-utility-elements
-\brief The QML global Qt object provides useful enums and functions from Qt.
-
\keyword QmlGlobalQtObject
-
-\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
+\brief Provides a global object with useful enums and functions from Qt.
The \c Qt object is a global object with utility functions, properties and enums.
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index afea96b35c..4652a2241e 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -172,7 +172,8 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
}
}
- glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits());
+ for (int i = 0; i < glyph.height(); ++i)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, glyph.width(), 1, GL_ALPHA, GL_UNSIGNED_BYTE, glyph.scanLine(i));
}
QHash<TextureInfo *, QVector<glyph_t> >::const_iterator i;
@@ -242,7 +243,8 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int
updateTexture(oldTexture, texInfo->texture, texInfo->size);
if (useWorkaround()) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits());
+ for (int i = 0; i < oldHeight; ++i)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i));
texInfo->image = texInfo->image.copy(0, 0, width, height);
glDeleteTextures(1, &oldTexture);
return;
diff --git a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
index 136e5d21a2..9c9318d3cc 100644
--- a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
+++ b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
@@ -6,7 +6,7 @@ Rectangle {
Text {
objectName: "textItem"
- text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC"
+ text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"
anchors.centerIn: parent
horizontalAlignment: Text.AlignLeft
}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 6637d36318..51a5b2547f 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -854,9 +854,20 @@ int tst_qquicktext::numberOfNonWhitePixels(int fromX, int toX, const QImage &ima
return pixels;
}
+static inline QByteArray msgNotGreaterThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2);
+}
+
+static inline QByteArray msgNotLessThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2);
+}
+
void tst_qquicktext::hAlignImplicitWidth()
{
QQuickView view(testFileUrl("hAlignImplicitWidth.qml"));
+ view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows.
view.show();
view.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -864,34 +875,45 @@ void tst_qquicktext::hAlignImplicitWidth()
QQuickText *text = view.rootObject()->findChild<QQuickText*>("textItem");
QVERIFY(text != 0);
+ // Try to check whether alignment works by checking the number of black
+ // pixels in the thirds of the grabbed image.
+ const int windowWidth = 200;
+ const int textWidth = qCeil(text->implicitWidth());
+ QVERIFY2(textWidth < windowWidth, "System font too large.");
+ const int sectionWidth = textWidth / 3;
+ const int centeredSection1 = (windowWidth - textWidth) / 2;
+ const int centeredSection2 = centeredSection1 + sectionWidth;
+ const int centeredSection3 = centeredSection2 + sectionWidth;
+ const int centeredSection3End = centeredSection3 + sectionWidth;
+
{
// Left Align
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left > mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// HCenter Align
text->setHAlign(QQuickText::AlignHCenter);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// Right Align
text->setHAlign(QQuickText::AlignRight);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid < right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid < right, msgNotLessThan(mid, right).constData());
}
}
diff --git a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
index 136e5d21a2..9c9318d3cc 100644
--- a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
+++ b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
@@ -6,7 +6,7 @@ Rectangle {
Text {
objectName: "textItem"
- text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC"
+ text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"
anchors.centerIn: parent
horizontalAlignment: Text.AlignLeft
}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 667d52ee7a..6e74d840aa 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -818,42 +818,66 @@ static int numberOfNonWhitePixels(int fromX, int toX, const QImage &image)
return pixels;
}
+static inline QByteArray msgNotGreaterThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2);
+}
+
+static inline QByteArray msgNotLessThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2);
+}
+
void tst_qquicktextedit::hAlignVisual()
{
QQuickView view(testFileUrl("hAlignVisual.qml"));
+ view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows.
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QQuickText *text = view.rootObject()->findChild<QQuickText*>("textItem");
QVERIFY(text != 0);
+
+ // Try to check whether alignment works by checking the number of black
+ // pixels in the thirds of the grabbed image.
+ const int windowWidth = 200;
+ const int textWidth = qCeil(text->implicitWidth());
+ QVERIFY2(textWidth < windowWidth, "System font too large.");
+ const int sectionWidth = textWidth / 3;
+ const int centeredSection1 = (windowWidth - textWidth) / 2;
+ const int centeredSection2 = centeredSection1 + sectionWidth;
+ const int centeredSection3 = centeredSection2 + sectionWidth;
+ const int centeredSection3End = centeredSection3 + sectionWidth;
+
{
// Left Align
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left > mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// HCenter Align
text->setHAlign(QQuickText::AlignHCenter);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// Right Align
text->setHAlign(QQuickText::AlignRight);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid < right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ image.save("test3.png");
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid < right, msgNotLessThan(mid, right).constData());
}
text->setWidth(200);
@@ -864,8 +888,8 @@ void tst_qquicktextedit::hAlignVisual()
int x = qCeil(text->implicitWidth());
int left = numberOfNonWhitePixels(0, x, image);
int right = numberOfNonWhitePixels(x, image.width() - x, image);
- QVERIFY(left > 0);
- QVERIFY(right == 0);
+ QVERIFY2(left > 0, msgNotGreaterThan(left, 0).constData());
+ QCOMPARE(right, 0);
}
{
// HCenter Align
@@ -876,9 +900,9 @@ void tst_qquicktextedit::hAlignVisual()
int left = numberOfNonWhitePixels(0, x1, image);
int mid = numberOfNonWhitePixels(x1, x2 - x1, image);
int right = numberOfNonWhitePixels(x2, image.width() - x2, image);
- QVERIFY(left == 0);
- QVERIFY(mid > 0);
- QVERIFY(right == 0);
+ QCOMPARE(left, 0);
+ QVERIFY2(mid > 0, msgNotGreaterThan(left, 0).constData());
+ QCOMPARE(right, 0);
}
{
// Right Align
@@ -887,8 +911,8 @@ void tst_qquicktextedit::hAlignVisual()
int x = image.width() - qCeil(text->implicitWidth());
int left = numberOfNonWhitePixels(0, x, image);
int right = numberOfNonWhitePixels(x, image.width() - x, image);
- QVERIFY(left == 0);
- QVERIFY(right > 0);
+ QCOMPARE(left, 0);
+ QVERIFY2(right > 0, msgNotGreaterThan(left, 0).constData());
}
}