aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shared
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/shared')
-rw-r--r--examples/quick/shared/FlickrRssModel.qml8
-rw-r--r--examples/quick/shared/LauncherList.qml4
-rw-r--r--examples/quick/shared/SimpleLauncherDelegate.qml11
-rw-r--r--examples/quick/shared/TabSet.qml9
4 files changed, 23 insertions, 9 deletions
diff --git a/examples/quick/shared/FlickrRssModel.qml b/examples/quick/shared/FlickrRssModel.qml
index cee4022bf0..2fb4412ba1 100644
--- a/examples/quick/shared/FlickrRssModel.qml
+++ b/examples/quick/shared/FlickrRssModel.qml
@@ -63,10 +63,16 @@ ListModel {
var xhr = new XMLHttpRequest;
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
+
+ if (xhr.status !== 200) {
+ console.log("Failed to get images from flickr. status code: " + xhr.status);
+ return;
+ }
+
var jsonText = xhr.responseText;
var objArray = JSON.parse(jsonText.replace(/\'/g,"'"))
if (objArray.errors !== undefined)
- console.log(lCategory, "Error fetching tweets: " + imageItems.errors[0].message)
+ console.log("Error fetching tweets: " + objArray.errors[0].message)
else {
for (var key in objArray.items) {
var rssItem = objArray.items[key];
diff --git a/examples/quick/shared/LauncherList.qml b/examples/quick/shared/LauncherList.qml
index 9859b5b635..cb13ec4372 100644
--- a/examples/quick/shared/LauncherList.qml
+++ b/examples/quick/shared/LauncherList.qml
@@ -48,6 +48,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
+import QtQml 2.12
+import QtQml.Models 2.12
import QtQuick 2.12
Rectangle {
@@ -75,6 +78,7 @@ Rectangle {
id: launcherList
clip: true
delegate: SimpleLauncherDelegate{
+ required property url url
onClicked: root.showExample(url)
}
model: ListModel {id:myModel}
diff --git a/examples/quick/shared/SimpleLauncherDelegate.qml b/examples/quick/shared/SimpleLauncherDelegate.qml
index 75aecf262c..dd29b8b821 100644
--- a/examples/quick/shared/SimpleLauncherDelegate.qml
+++ b/examples/quick/shared/SimpleLauncherDelegate.qml
@@ -55,18 +55,21 @@ Rectangle {
width: ListView.view.width
height: button.implicitHeight + 22
+ required property string name
+ required property string description
+
signal clicked()
gradient: Gradient {
GradientStop {
position: 0
Behavior on color {ColorAnimation { duration: 100 }}
- color: button.pressed ? "#e0e0e0" : "#fff"
+ color: tapHandler.pressed ? "#e0e0e0" : "#fff"
}
GradientStop {
position: 1
Behavior on color {ColorAnimation { duration: 100 }}
- color: button.pressed ? "#e0e0e0" : button.containsMouse ? "#f5f5f5" : "#eee"
+ color: tapHandler.pressed ? "#e0e0e0" : button.containsMouse ? "#f5f5f5" : "#eee"
}
}
@@ -110,7 +113,7 @@ Rectangle {
anchors.leftMargin: 10
anchors.right: parent.right
anchors.rightMargin: 10
- text: name
+ text: container.name
color: "black"
font.pixelSize: 22
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
@@ -122,7 +125,7 @@ Rectangle {
id: buttonLabel2
anchors.left: parent.left
anchors.leftMargin: 10
- text: description
+ text: container.description
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: "#666"
font.pixelSize: 12
diff --git a/examples/quick/shared/TabSet.qml b/examples/quick/shared/TabSet.qml
index 9e2759c3ec..ab8476ad44 100644
--- a/examples/quick/shared/TabSet.qml
+++ b/examples/quick/shared/TabSet.qml
@@ -78,6 +78,7 @@ Item {
Repeater {
model: stack.children.length
delegate: Rectangle {
+ required property int index
width: tabWidget.width / stack.children.length
height: Math.max(Screen.pixelDensity * 7, label.implicitHeight * 1.2)
@@ -90,18 +91,18 @@ Item {
anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
border { left: 7; right: 7 }
source: "images/tab.png"
- visible: tabWidget.current == index
+ visible: tabWidget.current == parent.index
}
Text {
id: label
horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
anchors.fill: parent
- text: stack.children[index].title
+ text: stack.children[parent.index].title
elide: Text.ElideRight
- font.bold: tabWidget.current == index
+ font.bold: tabWidget.current == parent.index
}
TapHandler {
- onTapped: tabWidget.current = index
+ onTapped: tabWidget.current = parent.index
}
}
}