summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-09-02 13:43:17 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-09-02 13:43:17 (GMT)
commit2bb571fe49d05b06b13aedc4f7fb71cbb1c949be (patch)
treeac37be379829c9aa5e9853763cb7f7d1a22464b8 /demos
parent0d54ade501443d8a3b0e756520f6c43e602f1283 (diff)
parent7aed1cf06ed7b50f060ebce7a5a041c752989307 (diff)
downloadQt-2bb571fe49d05b06b13aedc4f7fb71cbb1c949be.zip
Qt-2bb571fe49d05b06b13aedc4f7fb71cbb1c949be.tar.gz
Qt-2bb571fe49d05b06b13aedc4f7fb71cbb1c949be.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'demos')
-rw-r--r--demos/browser/downloadmanager.cpp2
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js3
-rw-r--r--demos/declarative/samegame/samegame.qml1
-rw-r--r--demos/declarative/twitter/TwitterCore/AuthView.qml146
-rw-r--r--demos/declarative/twitter/TwitterCore/Button.qml2
-rw-r--r--demos/declarative/twitter/TwitterCore/FatDelegate.qml36
-rw-r--r--demos/declarative/twitter/TwitterCore/HomeTitleBar.qml161
-rw-r--r--demos/declarative/twitter/TwitterCore/Input.qml65
-rw-r--r--demos/declarative/twitter/TwitterCore/MultiTitleBar.qml7
-rw-r--r--demos/declarative/twitter/TwitterCore/RssModel.qml59
-rw-r--r--demos/declarative/twitter/TwitterCore/SearchView.qml124
-rw-r--r--demos/declarative/twitter/TwitterCore/TitleBar.qml80
-rw-r--r--demos/declarative/twitter/TwitterCore/ToolBar.qml5
-rw-r--r--demos/declarative/twitter/TwitterCore/UserModel.qml26
-rw-r--r--demos/declarative/twitter/TwitterCore/qmldir4
-rw-r--r--demos/declarative/twitter/twitter.qml74
-rw-r--r--demos/qtdemo/menumanager.cpp4
17 files changed, 335 insertions, 464 deletions
diff --git a/demos/browser/downloadmanager.cpp b/demos/browser/downloadmanager.cpp
index 876ec1d..ab68209 100644
--- a/demos/browser/downloadmanager.cpp
+++ b/demos/browser/downloadmanager.cpp
@@ -282,7 +282,7 @@ void DownloadItem::updateInfoLabel()
remaining = tr("- %4 %5 remaining")
.arg(timeRemaining)
.arg(timeRemainingString);
- info = QString(tr("%1 of %2 (%3/sec) %4"))
+ info = tr("%1 of %2 (%3/sec) %4")
.arg(dataString(m_bytesReceived))
.arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal))
.arg(dataString((int)speed))
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index aa1b359..9266767 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -151,7 +151,8 @@ function victoryCheck()
gameDuration = new Date() - gameDuration;
nameInputDialog.show("You won! Please enter your name: ");
nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
- nameInputDialog.width = nameInputDialog.initialWidth;
+ if(nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
nameInputDialog.text.opacity = 0;//Just a spacer
}
}
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 9504fb6..3e9c505 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -82,6 +82,7 @@ Rectangle {
id: nameInputDialog
property int initialWidth: 0
+ property alias name: nameInputText.text
anchors.centerIn: parent
z: 22;
diff --git a/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml
deleted file mode 100644
index 0d05deb..0000000
--- a/demos/declarative/twitter/TwitterCore/AuthView.qml
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- id: wrapper
- Column {
- anchors.centerIn: parent
- spacing: 20
- Column{
- spacing: 4
- Text {
- text: "Screen name:"
- font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- horizontalAlignment: Qt.AlignRight
- }
- Item {
- width: 220
- height: 28
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
- TextInput{
- id: nameIn
- width: parent.width - 8
- anchors.centerIn: parent
- maximumLength:21
- font.pixelSize: 16;
- font.bold: true
- color: "#151515"; selectionColor: "green"
- KeyNavigation.tab: passIn
- KeyNavigation.backtab: guest
- focus: true
- }
- }
- }
- Column{
- spacing: 4
- Text {
- text: "Password:"
- font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- horizontalAlignment: Qt.AlignRight
- }
- Item {
- width: 220
- height: 28
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
- TextInput{
- id: passIn
- width: parent.width - 8
- anchors.centerIn: parent
- maximumLength:21
- echoMode: TextInput.Password
- font.pixelSize: 16;
- font.bold: true
- color: "#151515"; selectionColor: "green"
- KeyNavigation.tab: login
- KeyNavigation.backtab: nameIn
- onAccepted: login.doLogin();
- }
- }
- }
- Row{
- spacing: 10
- Button {
- width: 100
- height: 32
- id: login
- keyUsing: true;
- function doLogin(){
- rssModel.authName=nameIn.text;
- rssModel.authPass=passIn.text;
- rssModel.tags='my timeline';
- screen.focus = true;
- }
- text: "Log in"
- KeyNavigation.right: guest
- KeyNavigation.tab: guest
- KeyNavigation.backtab: passIn
- Keys.onReturnPressed: login.doLogin();
- Keys.onEnterPressed: login.doLogin();
- Keys.onSelectPressed: login.doLogin();
- Keys.onSpacePressed: login.doLogin();
- onClicked: login.doLogin();
- }
- Button {
- width: 100
- height: 32
- id: guest
- keyUsing: true;
- function doGuest()
- {
- rssModel.authName='-';
- screen.focus = true;
- screen.setMode(true);
- }
- text: "Guest"
- KeyNavigation.left: login
- KeyNavigation.tab: nameIn
- KeyNavigation.backtab: login
- Keys.onReturnPressed: guest.doGuest();
- Keys.onEnterPressed: guest.doGuest();
- Keys.onSelectPressed: guest.doGuest();
- Keys.onSpacePressed: guest.doGuest();
- onClicked: guest.doGuest();
- }
- }
- }
-}
diff --git a/demos/declarative/twitter/TwitterCore/Button.qml b/demos/declarative/twitter/TwitterCore/Button.qml
index d326c64..437b013 100644
--- a/demos/declarative/twitter/TwitterCore/Button.qml
+++ b/demos/declarative/twitter/TwitterCore/Button.qml
@@ -67,7 +67,7 @@ Item {
}
Text {
id: btnText
- color: if(container.keyUsing){"#DDDDDD";} else {"#FFFFFF";}
+ color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
anchors.centerIn: buttonImage; font.bold: true
text: container.text; style: Text.Raised; styleColor: "black"
font.pixelSize: 12
diff --git a/demos/declarative/twitter/TwitterCore/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml
index ff03b0b..27dd300 100644
--- a/demos/declarative/twitter/TwitterCore/FatDelegate.qml
+++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml
@@ -44,11 +44,10 @@ import Qt 4.7
Component {
id: listDelegate
Item {
- id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 58){txt.height+8}else{58}//50+4+4
+ id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5
function handleLink(link){
if(link.slice(0,3) == 'app'){
screen.setUser(link.slice(7));
- screen.setMode(true);
}else if(link.slice(0,4) == 'http'){
Qt.openUrlExternally(link);
}
@@ -58,26 +57,47 @@ Component {
var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
return ret2;
}
+
+ // Strip away paranthesis
+ function userName(str) {
+ var user = str.replace(/\([\S|\s]*\)/gi, "");
+ return user.trim();
+ }
+
Item {
id: moveMe; height: parent.height
Rectangle {
id: blackRect
color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
}
- Rectangle {
- id: whiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true
+ Item {
+ id: image; x: 6; width: 48; height: 48; smooth: true
anchors.verticalCenter: parent.verticalCenter
Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready }
- Image { id: realImage; source: userImage; x: 1; y: 1; width:48; height:48 }
+ Image {
+ id: realImage;
+ source: userImage; x: 1; y: 1;
+ width:48; height:48; opacity:0 ;
+ onStatusChanged: {
+ if(status==Image.Ready)
+ image.state="loaded"
+ }
+ }
+ states: State {
+ name: "loaded";
+ PropertyChanges { target: realImage ; opacity:1 }
+ }
+ transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } }
+
}
Text { id:txt; y:4; x: 56
text: '<html><style type="text/css">a:link {color:"#aaccaa"}; a:visited {color:"#336633"}</style>'
- + '<a href="app://@'+userScreenName+'"><b>'+userScreenName + "</b></a> from " +source
- + "<br /><b>" + wrapper.addTags(statusText) + "</b></html>";
+ + '<a href="app://@'+userName(name)+'"><b>'+userName(name) + "</b></a> from " +source
+ + "<br /><b>" + statusText + "</b></html>";
textFormat: Qt.RichText
color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
- anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
onLinkActivated: wrapper.handleLink(link)
}
}
diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
deleted file mode 100644
index 56f31b1..0000000
--- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- id: titleBar
-
- signal update()
- onYChanged: state="" //When switching titlebars
-
- BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
- Item {
- id: container
- width: (parent.width * 2) - 55 ; height: parent.height
-
- function accept() {
- if(rssModel.authName == '' || rssModel.authPass == '')
- return false;//Can't login like that
-
- var postData = "status=" + editor.text;
- var postman = new XMLHttpRequest();
- postman.open("POST", "http://twitter.com/statuses/update.xml", true, rssModel.authName, rssModel.authPass);
- postman.onreadystatechange = function() {
- if (postman.readyState == postman.DONE) {
- titleBar.update();
- }
- }
- postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- postman.send(postData);
-
- editor.text = ""
- titleBar.state = ""
- }
-
- Rectangle {
- x: 6; width: 50; height: 50; color: "white"; smooth: true
- anchors.verticalCenter: parent.verticalCenter
-
- UserModel { user: rssModel.authName; id: userModel }
- Component { id: imgDelegate;
- Item {
- Loading { width:48; height:48; visible: realImage.status != Image.Ready }
- Image { source: image; width:48; height:48; id: realImage }
- }
- }
- ListView { model: userModel.model; x:1; y:1; delegate: imgDelegate }
- }
-
- Text {
- id: categoryText
- anchors.left: parent.left; anchors.right: tagButton.left
- anchors.leftMargin: 58; anchors.rightMargin: 10
- anchors.verticalCenter: parent.verticalCenter
- elide: Text.ElideLeft
- text: "Timeline for " + rssModel.authName
- font.pixelSize: 12; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- }
-
- Button {
- id: tagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..."
- anchors.verticalCenter: parent.verticalCenter;
- onClicked: if (titleBar.state == "Posting") container.accept(); else titleBar.state = "Posting"
- }
-
- Text {
- id: charsLeftText; anchors.horizontalCenter: tagButton.horizontalCenter;
- anchors.top: tagButton.bottom; anchors.topMargin: 2
- text: {140 - editor.text.length;} visible: titleBar.state == "Posting"
- font.pointSize: 10; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- }
- Item {
- id: txtEdit;
- anchors.left: tagButton.right; anchors.leftMargin: 5; y: 4
- anchors.right: parent.right; anchors.rightMargin: 40; height: parent.height - 9
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
-
- Binding {//TODO: Can this be a function, which also resets the cursor? And flashes?
- when: editor.text.length > 140
- target: editor
- property: "text"
- value: editor.text.slice(0,140)
- }
- TextEdit {
- id: editor
- anchors.left: parent.left;
- anchors.leftMargin: 8;
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 4;
- cursorVisible: true; font.bold: true
- width: parent.width - 12
- height: parent.height - 8
- font.pixelSize: 12
- wrapMode: TextEdit.Wrap
- color: "#151515"; selectionColor: "green"
- }
- Keys.forwardTo: [(returnKey), (editor)]
- Item {
- id: returnKey
- Keys.onReturnPressed: container.accept()
- Keys.onEnterPressed: container.accept()
- Keys.onEscapePressed: titleBar.state = ""
- }
- }
- }
- states: [
- State {
- name: "Posting"
- PropertyChanges { target: container; x: -tagButton.x + 5 }
- PropertyChanges { target: titleBar; height: 80 }
- PropertyChanges { target: tagButton; text: "OK" }
- PropertyChanges { target: tagButton; width: 28 }
- PropertyChanges { target: tagButton; height: 24 }
- PropertyChanges { target: editor; focus: true }
- }
- ]
- transitions: [
- Transition {
- from: "*"; to: "*"
- NumberAnimation { properties: "x,y,width,height"; easing.type: Easing.InOutQuad }
- }
- ]
-}
diff --git a/demos/declarative/twitter/TwitterCore/Input.qml b/demos/declarative/twitter/TwitterCore/Input.qml
new file mode 100644
index 0000000..a33a995
--- /dev/null
+++ b/demos/declarative/twitter/TwitterCore/Input.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+FocusScope {
+ id:container
+ width: 220
+ height: 28
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+ signal accepted
+ property alias text: input.text
+ property alias item:input
+ TextInput{
+ id: input
+ width: parent.width - 12
+ anchors.centerIn: parent
+ maximumLength:21
+ font.pixelSize: 16;
+ font.bold: true
+ color: "#151515"; selectionColor: "mediumseagreen"
+ focus: true
+ onAccepted:{container.accepted()}
+ text: ""
+ selectByMouse: true
+ }
+}
diff --git a/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
index 38d6c9c..29b7713 100644
--- a/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
@@ -42,10 +42,6 @@
import Qt 4.7
Item {
- height: homeBar.height
- HomeTitleBar { id: homeBar; width: parent.width; height: 60;
- onUpdate: rssModel.reload()
- }
TitleBar { id: titleBar; width: parent.width; height: 60;
y: -80
untaggedString: "Latest tweets from everyone"
@@ -53,9 +49,8 @@ Item {
}
states: [
State {
- name: "search"; when: screen.userView
+ name: "search"; when: screen.state!="search"
PropertyChanges { target: titleBar; y: 0 }
- PropertyChanges { target: homeBar; y: -80 }
}
]
transitions: [
diff --git a/demos/declarative/twitter/TwitterCore/RssModel.qml b/demos/declarative/twitter/TwitterCore/RssModel.qml
index bd73200..d03cdb3 100644
--- a/demos/declarative/twitter/TwitterCore/RssModel.qml
+++ b/demos/declarative/twitter/TwitterCore/RssModel.qml
@@ -43,43 +43,34 @@ import Qt 4.7
Item { id: wrapper
property variant model: xmlModel
- property string tags : ""
- property string authName : ""
- property string authPass : ""
+ property string from : ""
+ property string to : ""
+ property string phrase : ""
+
property string mode : "everyone"
property int status: xmlModel.status
function reload() { xmlModel.reload(); }
-XmlListModel {
- id: xmlModel
+ XmlListModel {
+ id: xmlModel
- source:{
- if (wrapper.authName == ""){
- ""; //Avoid worthless calls to twitter servers
- }else if(wrapper.mode == 'user'){
- "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/user_timeline.xml?screen_name="+wrapper.tags;
- }else if(wrapper.mode == 'self'){
- "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/friends_timeline.xml";
- }else{//everyone/public
- "http://twitter.com/statuses/public_timeline.xml";
- }
- }
- query: "/statuses/status"
+ source: (from=="" && to=="" && phrase=="") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+phrase
- XmlRole { name: "statusText"; query: "text/string()" }
- XmlRole { name: "timestamp"; query: "created_at/string()" }
- XmlRole { name: "source"; query: "source/string()" }
- XmlRole { name: "userName"; query: "user/name/string()" }
- XmlRole { name: "userScreenName"; query: "user/screen_name/string()" }
- XmlRole { name: "userImage"; query: "user/profile_image_url/string()" }
- XmlRole { name: "userLocation"; query: "user/location/string()" }
- XmlRole { name: "userDescription"; query: "user/description/string()" }
- XmlRole { name: "userFollowers"; query: "user/followers_count/string()" }
- XmlRole { name: "userStatuses"; query: "user/statuses_count/string()" }
- //TODO: Could also get the user's color scheme, timezone and a few other things
-}
-Binding {
- property: "mode"
- target: wrapper
- value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
-}
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "statusText"; query: "content/string()" }
+ XmlRole { name: "timestamp"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+ Binding {
+ property: "mode"
+ target: wrapper
+ value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
+ }
}
diff --git a/demos/declarative/twitter/TwitterCore/SearchView.qml b/demos/declarative/twitter/TwitterCore/SearchView.qml
new file mode 100644
index 0000000..22df374
--- /dev/null
+++ b/demos/declarative/twitter/TwitterCore/SearchView.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+FocusScope {
+ id: wrapper
+ Column {
+ anchors.centerIn: parent
+ spacing: 20
+ Column{
+ spacing: 4
+ Text {
+ text: "Posted by:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: fromIn
+ KeyNavigation.backtab: searchbutton
+ KeyNavigation.tab:toIn
+ onAccepted:searchbutton.doSearch();
+ focus: true
+ }
+ Text {
+ text: "In reply to:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: toIn
+ KeyNavigation.backtab: fromIn
+ KeyNavigation.tab:phraseIn
+ onAccepted:searchbutton.doSearch();
+ }
+ Text {
+ text: "Search phrase:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: phraseIn
+ KeyNavigation.backtab: toIn
+ KeyNavigation.tab:searchbutton
+ onAccepted:searchbutton.doSearch();
+ text: "Qt Quick"
+ }
+ }
+ Button {
+ width: 100
+ height: 32
+ id: searchbutton
+ keyUsing: true;
+ opacity: 1
+ text: "Search"
+ KeyNavigation.tab: fromIn
+ Keys.onReturnPressed: searchbutton.doSearch();
+ Keys.onEnterPressed: searchbutton.doSearch();
+ Keys.onSelectPressed: searchbutton.doSearch();
+ Keys.onSpacePressed: searchbutton.doSearch();
+ onClicked: searchbutton.doSearch();
+
+ function doSearch() {
+ // Search ! allowed
+ if (wrapper.state=="invalidinput")
+ return;
+
+ rssModel.from=fromIn.text;
+ rssModel.to= toIn.text;
+ rssModel.phrase = phraseIn.text;
+ screen.focus = true;
+ screen.state = ""
+ }
+ }
+ }
+ states:
+ State {
+ name: "invalidinput"
+ when: fromIn.text=="" && toIn.text=="" && phraseIn.text==""
+ PropertyChanges { target: searchbutton ; opacity: 0.6 ; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 }
+ }
+}
diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml
index 479aa20..145c189 100644
--- a/demos/declarative/twitter/TwitterCore/TitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml
@@ -58,66 +58,58 @@ Item {
rssModel.tags = editor.text
}
- Image {
- id: quitButton
- x: 5
+ Item {
+ id:imageBox
+ x: 6; width: 0; height: 50; smooth: true
anchors.verticalCenter: parent.verticalCenter
- source: "images/quit.png"
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.quit()
+
+ UserModel { user: rssModel.from; id: userModel }
+ Component {
+ id: imgDelegate;
+ Item {
+ id:imageitem
+ visible:true
+ Loading { width:48; height:48; visible: realImage.status != Image.Ready }
+ Image { id: realImage; source: image; width:48; height:48; opacity:0; }
+ states:
+ State {
+ name: "loaded"
+ when: (realImage.status == Image.Ready)
+ PropertyChanges { target: realImage; opacity:1 }
+ }
+ transitions: Transition {
+ NumberAnimation { target: realImage; property: "opacity"; duration: 200 }
+ }
+ }
+ }
+ ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate }
+ states:
+ State {
+ when: !userModel.user==""
+ PropertyChanges { target: imageBox; width: 50; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: imageBox; property: "width"; duration: 200 }
}
- }
+ }
+
Text {
id: categoryText
anchors {
- left: quitButton.right; right: tagButton.left; leftMargin: 5; rightMargin: 10
+ left: imageBox.right; right: parent.right; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
}
elide: Text.ElideLeft
- text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
+ text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from)
font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
font.pixelSize: 12
}
-
- Button {
- id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
- onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
- anchors.verticalCenter: parent.verticalCenter
- }
-
- Item {
- id: lineEdit
- y: 4; height: parent.height - 9
- anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
-
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
-
- TextInput {
- id: editor
- anchors {
- left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
- verticalCenter: parent.verticalCenter
- }
- cursorVisible: true; font.bold: true
- color: "#151515"; selectionColor: "Green"
- }
-
- Keys.forwardTo: [ (returnKey), (editor)]
-
- Item {
- id: returnKey
- Keys.onReturnPressed: container.accept()
- Keys.onEnterPressed: container.accept()
- Keys.onEscapePressed: titleBar.state = ""
- }
- }
}
states: State {
name: "Tags"
PropertyChanges { target: container; x: -tagButton.x + 5 }
- PropertyChanges { target: tagButton; text: "OK" }
PropertyChanges { target: editor; focus: true }
}
diff --git a/demos/declarative/twitter/TwitterCore/ToolBar.qml b/demos/declarative/twitter/TwitterCore/ToolBar.qml
index b9cb915..e18f5c6 100644
--- a/demos/declarative/twitter/TwitterCore/ToolBar.qml
+++ b/demos/declarative/twitter/TwitterCore/ToolBar.qml
@@ -48,15 +48,14 @@ Item {
property alias button2Label: button2.text
signal button1Clicked
signal button2Clicked
-
+ focus:true
BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
-
Button {
id: button1
anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
onClicked: toolbar.button1Clicked()
+ focus:true
}
-
Button {
id: button2
anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
diff --git a/demos/declarative/twitter/TwitterCore/UserModel.qml b/demos/declarative/twitter/TwitterCore/UserModel.qml
index e653836..d8ca804 100644
--- a/demos/declarative/twitter/TwitterCore/UserModel.qml
+++ b/demos/declarative/twitter/TwitterCore/UserModel.qml
@@ -42,26 +42,24 @@
import Qt 4.7
//This "model" gets the user information about the searched user. Mainly for the icon.
-//Copied from RssModel
Item { id: wrapper
property variant model: xmlModel
property string user : ""
property int status: xmlModel.status
function reload() { xmlModel.reload(); }
-XmlListModel {
- id: xmlModel
+ XmlListModel {
+ id: xmlModel
- source: {if(user!="") {"http://twitter.com/users/show.xml?screen_name="+user;}else{"";}}
- query: "/user"
+ source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : ""
+ query: "/user"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "screenName"; query: "screen_name/string()" }
- XmlRole { name: "image"; query: "profile_image_url/string()" }
- XmlRole { name: "location"; query: "location/string()" }
- XmlRole { name: "description"; query: "description/string()" }
- XmlRole { name: "followers"; query: "followers_count/string()" }
- //XmlRole { name: "protected"; query: "protected/bool()" }
- //TODO: Could also get the user's color scheme, timezone and a few other things
-}
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "screenName"; query: "screen_name/string()" }
+ XmlRole { name: "image"; query: "profile_image_url/string()" }
+ XmlRole { name: "location"; query: "location/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "followers"; query: "followers_count/string()" }
+ //TODO: Could also get the user's color scheme, timezone and a few other things
+ }
}
diff --git a/demos/declarative/twitter/TwitterCore/qmldir b/demos/declarative/twitter/TwitterCore/qmldir
index 8b56c56..84d85c2 100644
--- a/demos/declarative/twitter/TwitterCore/qmldir
+++ b/demos/declarative/twitter/TwitterCore/qmldir
@@ -1,7 +1,7 @@
-AuthView 1.0 AuthView.qml
+SearchView 1.0 SearchView.qml
Button 1.0 Button.qml
+Input 1.0 Input.qml
FatDelegate 1.0 FatDelegate.qml
-HomeTitleBar 1.0 HomeTitleBar.qml
Loading 1.0 Loading.qml
MultiTitleBar 1.0 MultiTitleBar.qml
TitleBar 1.0 TitleBar.qml
diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml
index 08cecb0..6d224a2 100644
--- a/demos/declarative/twitter/twitter.qml
+++ b/demos/declarative/twitter/twitter.qml
@@ -46,28 +46,18 @@ Item {
id: screen; width: 320; height: 480
property bool userView : false
property variant tmpStr
- function setMode(m){
- screen.userView = m;
- if(m == false){
- rssModel.tags='my timeline';
- rssModel.reload();
- toolBar.button2Label = "View others";
- } else {
- toolBar.button2Label = "Return home";
- }
- }
function setUser(str){hack.running = true; tmpStr = str}
- function reallySetUser(){rssModel.tags = tmpStr;}
-
+ function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
+ state:"searchquery"
//Workaround for bug 260266
Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
-
- //TODO: better way to return to the auth screen
- Keys.onEscapePressed: rssModel.authName=''
+ Keys.onEscapePressed: screen.state="searchquery"
+ Keys.onBacktabPressed: screen.state="searchquery"
Rectangle {
id: background
anchors.fill: parent; color: "#343434";
+ state:"searchquery"
Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
MouseArea {
@@ -90,8 +80,16 @@ Item {
y:60 //Below the title bars
height: 380
- Twitter.AuthView{
- id: authView
+ Text {
+ id:title
+ text: "Search Twitter"
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
+ opacity:0
+ }
+
+ Twitter.SearchView{
+ id: searchView
anchors.verticalCenter: parent.verticalCenter
width: parent.width; height: parent.height-60;
x: -(screen.width * 1.5)
@@ -110,31 +108,27 @@ Item {
//TODO: Use anchor changes instead of hard coding
y: screen.height - 40
width: parent.width; opacity: 0.9
- button1Label: "Update"
- button2Label: "View others"
- onButton1Clicked: rssModel.reload();
- onButton2Clicked:
+ button1Label: "New Search"
+ button2Label: "Update"
+ onButton1Clicked:
{
- if(screen.userView == true){
- screen.setMode(false);
- }else{
- rssModel.tags='';
- screen.setMode(true);
- }
+ screen.state="searchquery"
}
+ onButton2Clicked: rssModel.reload();
}
-
- states: [
- State {
- name: "unauthed"; when: rssModel.authName==""
- PropertyChanges { target: authView; x: 0 }
- PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
- PropertyChanges { target: titleBar; y: -80 }
- PropertyChanges { target: toolBar; y: screen.height }
- }
- ]
- transitions: [
- Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
- ]
}
+ states: [
+ State {
+ name: "searchquery";
+ PropertyChanges { target: searchView; x: 0; focus:true}
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height }
+ PropertyChanges { target: toolBar }
+ PropertyChanges { target: title; opacity:1}
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
}
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
index 4ae9ca1..fe3c5aa 100644
--- a/demos/qtdemo/menumanager.cpp
+++ b/demos/qtdemo/menumanager.cpp
@@ -384,9 +384,7 @@ void MenuManager::launchQmlExample(const QString &name)
qmlRoot->setProperty("show", QVariant(true));
qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName()));
#else
- QMessageBox::critical(0, tr("Failed to launch the example"),
- tr("This application was built without the QtDeclarative module, and therefore declarative examples have been disabled."),
- QMessageBox::Cancel);
+ exampleError(QProcess::UnknownError);
#endif
}