summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-05-08 03:41:47 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-05-08 03:41:47 (GMT)
commitad15641f118516f811d8370d65a4231ebe846891 (patch)
treea801c6734ce6430b7745703d6313efcaaec53442 /demos
parent299f9546f24b5ea288588ed4161a8e516e9391b1 (diff)
parent674f6502671e969264bb7450a507ca04ab149b6a (diff)
downloadQt-ad15641f118516f811d8370d65a4231ebe846891.zip
Qt-ad15641f118516f811d8370d65a4231ebe846891.tar.gz
Qt-ad15641f118516f811d8370d65a4231ebe846891.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos')
-rw-r--r--demos/declarative/contacts/Contact.qml69
-rw-r--r--demos/declarative/contacts/ContactField.qml2
-rw-r--r--demos/declarative/contacts/RemoveButton.qml6
-rw-r--r--demos/declarative/contacts/contacts.qml22
-rw-r--r--demos/declarative/flickr/content/MediaLineEdit.qml108
-rw-r--r--demos/declarative/flickr/content/pics/button-pressed.sci5
-rw-r--r--demos/declarative/flickr/content/pics/button.sci5
-rw-r--r--demos/declarative/flickr/flickr.qml18
8 files changed, 201 insertions, 34 deletions
diff --git a/demos/declarative/contacts/Contact.qml b/demos/declarative/contacts/Contact.qml
index 7297fa6..50c9d1c 100644
--- a/demos/declarative/contacts/Contact.qml
+++ b/demos/declarative/contacts/Contact.qml
@@ -16,41 +16,53 @@ Item {
id: updateContactQuery
connection: contactDatabase
query: "UPDATE contacts SET label = :l, email = :e, phone = :p WHERE recid = :r"
- bindings: SqlBind {
- name: ":r"
- value: contactId
- }
- bindings: SqlBind {
- name: ":l"
- value: labelField.value
- }
- bindings: SqlBind {
- name: ":e"
- value: emailField.value
- }
- bindings: SqlBind {
- name: ":p"
- value: phoneField.value
- }
+ bindings: [
+ SqlBind {
+ name: ":r"
+ value: contactId
+ },
+ SqlBind {
+ name: ":l"
+ value: labelField.value
+ },
+ SqlBind {
+ name: ":e"
+ value: emailField.value
+ },
+ SqlBind {
+ name: ":p"
+ value: phoneField.value
+ }
+ ]
},
SqlQuery {
id: insertContactQuery
connection: contactDatabase
query: "INSERT INTO contacts (label, email, phone) VALUES(:l, :e, :p)"
+ bindings: [
+ SqlBind {
+ name: ":l"
+ value: labelField.value
+ },
+ SqlBind {
+ name: ":e"
+ value: emailField.value
+ },
+ SqlBind {
+ name: ":p"
+ value: phoneField.value
+ }
+ ]
+ },
+ SqlQuery {
+ id: removeContactQuery
+ connection: contactDatabase
+ query: "DELETE FROM contacts WHERE recid = :r"
bindings: SqlBind {
- name: ":l"
- value: labelField.value
- }
- bindings: SqlBind {
- name: ":e"
- value: emailField.value
- }
- bindings: SqlBind {
- name: ":p"
- value: phoneField.value
+ name: ":r"
+ value: contactId
}
}
-
]
function refresh() {
labelField.value = label;
@@ -63,6 +75,9 @@ Item {
function insert() {
insertContactQuery.exec();
}
+ function remove() {
+ removeContactQuery.exec();
+ }
VerticalLayout {
id: layout
anchors.fill: parent
diff --git a/demos/declarative/contacts/ContactField.qml b/demos/declarative/contacts/ContactField.qml
index cb319ae..003e723 100644
--- a/demos/declarative/contacts/ContactField.qml
+++ b/demos/declarative/contacts/ContactField.qml
@@ -3,7 +3,7 @@ Item {
clip: true
height: 30
property var label: "Name"
- property var icon: "pics/phone.png"
+ property var icon: ""
property var value: ""
onValueChanged: { fieldText.text = contactField.value }
RemoveButton {
diff --git a/demos/declarative/contacts/RemoveButton.qml b/demos/declarative/contacts/RemoveButton.qml
index 114db2e..59e3fcb 100644
--- a/demos/declarative/contacts/RemoveButton.qml
+++ b/demos/declarative/contacts/RemoveButton.qml
@@ -76,6 +76,12 @@ Rect {
text: "Remove"
opacity: 0
}
+ opacity: Behaviour {
+ NumericAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
states: [
State {
name: "opened"
diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml
index 4582bd1..b38e02e 100644
--- a/demos/declarative/contacts/contacts.qml
+++ b/demos/declarative/contacts/contacts.qml
@@ -127,13 +127,26 @@ Rect {
sender: cancelEditButton
signal: "clicked()"
script: {
- if (wrapper.state == 'opened' && !contacts.mouseGrabbed) {
+ if (wrapper.state == 'opened' && !contacts.mouseGrabbed) {
wrapper.state = '';
contacts.mode = 'list';
}
}
}
+ Connection {
+ sender: removeContactButton
+ signal: "confirmed()"
+ script: {
+ if (wrapper.state == 'opened' && !contacts.mouseGrabbed) {
+ Details.qmlItem.remove();
+ wrapper.state = '';
+ contacts.mode = 'list';
+ contactList.exec();
+ }
+
+ }
+ }
}
}
]
@@ -165,6 +178,13 @@ Rect {
icon: "pics/cancel.png"
opacity: contacts.mode == 'list' || contacts.mouseGrabbed ? 0 : 1
}
+ RemoveButton {
+ id: removeContactButton
+ anchors.top: parent.top
+ anchors.topMargin: 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ opacity: (contacts.mode == 'edit' && (!contacts.mouseGrabbed || removeContactButton.state =='opened')) ? 1 : 0
+ }
ListView {
id: contactListView
anchors.left: parent.left
diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml
new file mode 100644
index 0000000..37caf24
--- /dev/null
+++ b/demos/declarative/flickr/content/MediaLineEdit.qml
@@ -0,0 +1,108 @@
+Item {
+ id: Container
+
+ property string label
+ property string text
+
+ width: Math.max(94,Label.width + Editor.width + 20)
+ height: Image.height
+
+ states: [
+ State {
+ name: "Edit"
+ SetProperties {
+ target: Label
+ text: Container.label + ": "
+ }
+ SetProperty {
+ target: Label
+ property: "x"
+ binding: 10
+ }
+ SetProperties {
+ target: Editor
+ cursorVisible: true
+ width: 100
+ }
+ SetProperties {
+ target: Proxy
+ focus: true
+ }
+ RunScript {
+ script:"Editor.selectAll()"
+ }
+ },
+ State {
+ // When returning to default state, typed text is propagated
+ RunScript {
+ script: "Container.text = Editor.text"
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumericAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" }
+ }
+ ]
+
+
+ Image {
+ id: Image
+ source: "pics/button.sci"
+ anchors.left: Container.left
+ anchors.right: Container.right
+ }
+
+ Image {
+ id: Pressed
+ source: "pics/button-pressed.sci"
+ opacity: 0
+ anchors.left: Container.left
+ anchors.right: Container.right
+ }
+
+ MouseRegion {
+ id: MouseRegion
+ anchors.fill: Image
+ onClicked: { Container.state = Container.state=="Edit" ? "" : "Edit" }
+ states: [
+ State {
+ when: MouseRegion.pressed == true
+ SetProperties {
+ target: Pressed
+ opacity: 1
+ }
+ }
+ ]
+ }
+
+ Text {
+ id: Label
+ font.bold: true
+ color: "white"
+ anchors.verticalCenter: Container.verticalCenter
+ x: (Container.width - width)/2
+ text: Container.label + "..."
+ }
+
+ TextEdit {
+ id: Editor
+ font.bold: true
+ color: "white"
+ width: 0
+ clip: true
+ anchors.left: Label.right
+ anchors.verticalCenter: Container.verticalCenter
+ }
+ KeyProxy {
+ id: Proxy
+ anchors.left: Container.left
+ anchors.fill: Container
+ focusable: true
+ targets: [(ReturnKey), (Editor)]
+ }
+ KeyActions {
+ id: ReturnKey
+ return: "Container.state = ''"
+ }
+}
diff --git a/demos/declarative/flickr/content/pics/button-pressed.sci b/demos/declarative/flickr/content/pics/button-pressed.sci
new file mode 100644
index 0000000..d3b16e2
--- /dev/null
+++ b/demos/declarative/flickr/content/pics/button-pressed.sci
@@ -0,0 +1,5 @@
+gridLeft: 8
+gridTop: 4
+gridBottom: 4
+gridRight: 8
+imageFile: button.png
diff --git a/demos/declarative/flickr/content/pics/button.sci b/demos/declarative/flickr/content/pics/button.sci
new file mode 100644
index 0000000..d3b16e2
--- /dev/null
+++ b/demos/declarative/flickr/content/pics/button.sci
@@ -0,0 +1,5 @@
+gridLeft: 8
+gridTop: 4
+gridBottom: 4
+gridRight: 8
+imageFile: button.png
diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml
index dc150cb..092aef6 100644
--- a/demos/declarative/flickr/flickr.qml
+++ b/demos/declarative/flickr/flickr.qml
@@ -8,7 +8,7 @@ Item {
resources: [
XmlListModel {
id: FeedModel
- property string tags : ""
+ property string tags : TagsEdit.text
source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2"
query: "doc($src)/rss/channel/item"
namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
@@ -90,7 +90,8 @@ Item {
SetProperties { target: ImageDetails; y: 20 }
SetProperties { target: PhotoGridView; y: "-480" }
SetProperties { target: PhotoPathView; y: "-480" }
- SetProperties { target: CloseButton; opacity: 0 }
+ SetProperties { target: ViewModeButton; opacity: 0 }
+ SetProperties { target: TagsEdit; opacity: 0 }
SetProperties { target: FetchButton; opacity: 0 }
SetProperties { target: CategoryText; y: "-50" }
}
@@ -160,18 +161,25 @@ Item {
ImageDetails { id: ImageDetails; width: 750; x: 25; y: 500; height: 410 }
MediaButton {
- id: CloseButton; x: 680; y: 410; text: "View Mode"
+ id: ViewModeButton; x: 680; y: 410; text: "View Mode"
onClicked: { if (MainWindow.showPathView == true) MainWindow.showPathView = false; else MainWindow.showPathView = true }
}
MediaButton {
id: FetchButton
text: "Update"
- anchors.right: CloseButton.left; anchors.rightMargin: 5
- anchors.top: CloseButton.top
+ anchors.right: ViewModeButton.left; anchors.rightMargin: 5
+ anchors.top: ViewModeButton.top
onClicked: { FeedModel.reload(); }
}
+ MediaLineEdit {
+ id: TagsEdit;
+ label: "Tags"
+ anchors.right: FetchButton.left; anchors.rightMargin: 5
+ anchors.top: ViewModeButton.top
+ }
+
states: [
State {
name: "PathView"