summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-07 06:57:21 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-07 06:57:21 (GMT)
commita3a6e1622149654bc9e244e685e8e7dcbdf966b2 (patch)
tree1c4fe9feab63839213a0d97e9b24414c9585a227 /demos
parent99573a8e81fcea38c5f68b340068fff266315c03 (diff)
parent8b0cac9179de4d1cb34b9f17932d34cef3cd4f5b (diff)
downloadQt-a3a6e1622149654bc9e244e685e8e7dcbdf966b2.zip
Qt-a3a6e1622149654bc9e244e685e8e7dcbdf966b2.tar.gz
Qt-a3a6e1622149654bc9e244e685e8e7dcbdf966b2.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into test
Conflicts: demos/declarative/samegame/content/samegame.js tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
Diffstat (limited to 'demos')
-rw-r--r--demos/browser/browser.pro10
-rw-r--r--demos/declarative/calculator/CalcButton.qml32
-rw-r--r--demos/declarative/calculator/calculator.js58
-rw-r--r--demos/declarative/calculator/calculator.qml59
-rw-r--r--demos/declarative/contacts/Contact.qml4
-rw-r--r--demos/declarative/flickr/common/ImageDetails.qml120
-rw-r--r--demos/declarative/flickr/common/LikeOMeter.qml22
-rw-r--r--demos/declarative/flickr/common/Loading.qml4
-rw-r--r--demos/declarative/flickr/common/MediaButton.qml22
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml62
-rw-r--r--demos/declarative/flickr/common/Progress.qml5
-rw-r--r--demos/declarative/flickr/common/ScrollBar.qml10
-rw-r--r--demos/declarative/flickr/common/Slider.qml16
-rw-r--r--demos/declarative/flickr/common/Star.qml13
-rw-r--r--demos/declarative/flickr/common/pics/button-pressed.sci10
-rw-r--r--demos/declarative/flickr/common/pics/button.sci10
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml138
-rw-r--r--demos/declarative/flickr/flickr-mobile.qml56
-rw-r--r--demos/declarative/flickr/mobile/Button.qml27
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml52
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml74
-rw-r--r--demos/declarative/flickr/mobile/ListDelegate.qml13
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml38
-rw-r--r--demos/declarative/flickr/mobile/ToolBar.qml14
-rw-r--r--demos/declarative/flickr/mobile/images/lineedit.sci10
-rw-r--r--demos/declarative/flickr/mobile/images/titlebar.sci10
-rw-r--r--demos/declarative/flickr/mobile/images/toolbutton.sci10
-rw-r--r--demos/declarative/minehunt/Description.qml10
-rw-r--r--demos/declarative/samegame/content/Button.qml6
-rw-r--r--demos/declarative/samegame/content/Dialog.qml8
-rwxr-xr-xdemos/declarative/samegame/content/samegame.js26
-rw-r--r--demos/declarative/samegame/samegame.qml29
-rw-r--r--demos/declarative/twitter/content/AuthView.qml12
-rw-r--r--demos/declarative/twitter/content/FatDelegate.qml20
-rw-r--r--demos/declarative/twitter/content/HomeTitleBar.qml64
-rw-r--r--demos/declarative/twitter/content/MultiTitleBar.qml14
-rw-r--r--demos/declarative/twitter/twitter.qml73
-rw-r--r--demos/declarative/webbrowser/content/RectSoftShadow.qml2
-rw-r--r--demos/declarative/webbrowser/content/pics/addressbar-filled.sci10
-rw-r--r--demos/declarative/webbrowser/content/pics/addressbar.sci10
-rw-r--r--demos/declarative/webbrowser/content/pics/footer.sci10
-rw-r--r--demos/declarative/webbrowser/content/pics/softshadow-left.sci10
-rw-r--r--demos/declarative/webbrowser/content/pics/softshadow-right.sci10
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml170
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.pro29
-rw-r--r--demos/sub-attaq/animationmanager.cpp6
-rw-r--r--demos/sub-attaq/boat.cpp92
-rw-r--r--demos/sub-attaq/boat.h12
-rw-r--r--demos/sub-attaq/boat_p.h50
-rw-r--r--demos/sub-attaq/bomb.cpp16
-rw-r--r--demos/sub-attaq/bomb.h16
-rw-r--r--demos/sub-attaq/custompropertyanimation.cpp108
-rw-r--r--demos/sub-attaq/custompropertyanimation.h114
-rw-r--r--demos/sub-attaq/graphicsscene.cpp196
-rw-r--r--demos/sub-attaq/graphicsscene.h13
-rw-r--r--demos/sub-attaq/mainwindow.cpp31
-rw-r--r--demos/sub-attaq/mainwindow.h1
-rw-r--r--demos/sub-attaq/pixmapitem.cpp33
-rw-r--r--demos/sub-attaq/pixmapitem.h14
-rw-r--r--demos/sub-attaq/states.cpp39
-rw-r--r--demos/sub-attaq/states.h2
-rw-r--r--demos/sub-attaq/sub-attaq.pro2
-rw-r--r--demos/sub-attaq/submarine.cpp62
-rw-r--r--demos/sub-attaq/submarine.h11
-rw-r--r--demos/sub-attaq/submarine_p.h1
-rw-r--r--demos/sub-attaq/torpedo.cpp20
-rw-r--r--demos/sub-attaq/torpedo.h16
-rw-r--r--demos/symbianpkgrules.pri2
68 files changed, 876 insertions, 1393 deletions
diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro
index dab9387..6c5f005 100644
--- a/demos/browser/browser.pro
+++ b/demos/browser/browser.pro
@@ -80,6 +80,16 @@ mac {
ICON = browser.icns
QMAKE_INFO_PLIST = Info_mac.plist
TARGET = Browser
+
+ # No 64-bit Flash on Mac, so build the browser 32-bit
+ contains(QT_CONFIG, x86) {
+ CONFIG -= x86_64
+ CONFIG += x86
+ }
+ contains(QT_CONFIG, ppc) {
+ CONFIG -= ppc64
+ CONFIG += ppc
+ }
}
wince*: {
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml
index 55b5f0c..c2e3a81 100644
--- a/demos/declarative/calculator/CalcButton.qml
+++ b/demos/declarative/calculator/CalcButton.qml
@@ -1,41 +1,41 @@
import Qt 4.6
Rectangle {
- property alias operation: Label.text
+ property alias operation: label.text
property bool toggable: false
property bool toggled: false
signal clicked
- id: Button; width: 50; height: 30
- border.color: Palette.mid; radius: 6
+ id: button; width: 50; height: 30
+ border.color: palette.mid; radius: 6
gradient: Gradient {
- GradientStop { id: G1; position: 0.0; color: Palette.lighter(Palette.button) }
- GradientStop { id: G2; position: 1.0; color: Palette.button }
+ GradientStop { id: G1; position: 0.0; color: palette.lighter(palette.button) }
+ GradientStop { id: G2; position: 1.0; color: palette.button }
}
- Text { id: Label; anchors.centerIn: parent; color: Palette.buttonText }
+ Text { id: label; anchors.centerIn: parent; color: palette.buttonText }
MouseRegion {
- id: ClickRegion
+ id: clickRegion
anchors.fill: parent
onClicked: {
doOp(operation);
- Button.clicked();
- if (!Button.toggable) return;
- Button.toggled ? Button.toggled = false : Button.toggled = true
+ button.clicked();
+ if (!button.toggable) return;
+ button.toggled ? button.toggled = false : button.toggled = true
}
}
states: [
State {
- name: "Pressed"; when: ClickRegion.pressed == true
- PropertyChanges { target: G1; color: Palette.dark }
- PropertyChanges { target: G2; color: Palette.button }
+ name: "Pressed"; when: clickRegion.pressed == true
+ PropertyChanges { target: G1; color: palette.dark }
+ PropertyChanges { target: G2; color: palette.button }
},
State {
- name: "Toggled"; when: Button.toggled == true
- PropertyChanges { target: G1; color: Palette.dark }
- PropertyChanges { target: G2; color: Palette.button }
+ name: "Toggled"; when: button.toggled == true
+ PropertyChanges { target: G1; color: palette.dark }
+ PropertyChanges { target: G2; color: palette.button }
}
]
}
diff --git a/demos/declarative/calculator/calculator.js b/demos/declarative/calculator/calculator.js
index 774b232..cd6490a 100644
--- a/demos/declarative/calculator/calculator.js
+++ b/demos/declarative/calculator/calculator.js
@@ -5,9 +5,9 @@ var lastOp = "";
var timer = 0;
function disabled(op) {
- if (op == "." && CurNum.text.toString().search(/\./) != -1) {
+ if (op == "." && curNum.text.toString().search(/\./) != -1) {
return true;
- } else if (op == "Sqrt" && CurNum.text.toString().search(/-/) != -1) {
+ } else if (op == "Sqrt" && curNum.text.toString().search(/-/) != -1) {
return true;
} else {
return false;
@@ -20,12 +20,12 @@ function doOp(op) {
}
if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) {
- if (CurNum.text.toString().length >= 14)
+ if (curNum.text.toString().length >= 14)
return; // No arbitrary length numbers
if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp==".") ) {
- CurNum.text = CurNum.text + op.toString();
+ curNum.text = curNum.text + op.toString();
} else {
- CurNum.text = op;
+ curNum.text = op;
}
lastOp = op;
return;
@@ -33,55 +33,55 @@ function doOp(op) {
lastOp = op;
// Pending operations
- if (CurrentOperation.text == "+") {
- CurNum.text = Number(CurNum.text.valueOf()) + Number(curVal.valueOf());
- } else if (CurrentOperation.text == "-") {
- CurNum.text = Number(curVal) - Number(CurNum.text.valueOf());
- } else if (CurrentOperation.text == "x") {
- CurNum.text = Number(curVal) * Number(CurNum.text.valueOf());
- } else if (CurrentOperation.text == "/") {
- CurNum.text = Number(Number(curVal) / Number(CurNum.text.valueOf())).toString();
- } else if (CurrentOperation.text == "=") {
+ if (currentOperation.text == "+") {
+ curNum.text = Number(curNum.text.valueOf()) + Number(curVal.valueOf());
+ } else if (currentOperation.text == "-") {
+ curNum.text = Number(curVal) - Number(curNum.text.valueOf());
+ } else if (currentOperation.text == "x") {
+ curNum.text = Number(curVal) * Number(curNum.text.valueOf());
+ } else if (currentOperation.text == "/") {
+ curNum.text = Number(Number(curVal) / Number(curNum.text.valueOf())).toString();
+ } else if (currentOperation.text == "=") {
}
if (op == "+" || op == "-" || op == "x" || op == "/") {
- CurrentOperation.text = op;
- curVal = CurNum.text.valueOf();
+ currentOperation.text = op;
+ curVal = curNum.text.valueOf();
return;
}
curVal = 0;
- CurrentOperation.text = "";
+ currentOperation.text = "";
// Immediate operations
if (op == "1/x") { // reciprocal
- CurNum.text = (1 / CurNum.text.valueOf()).toString();
+ curNum.text = (1 / curNum.text.valueOf()).toString();
} else if (op == "^2") { // squared
- CurNum.text = (CurNum.text.valueOf() * CurNum.text.valueOf()).toString();
+ curNum.text = (curNum.text.valueOf() * curNum.text.valueOf()).toString();
} else if (op == "Abs") {
- CurNum.text = (Math.abs(CurNum.text.valueOf())).toString();
+ curNum.text = (Math.abs(curNum.text.valueOf())).toString();
} else if (op == "Int") {
- CurNum.text = (Math.floor(CurNum.text.valueOf())).toString();
+ curNum.text = (Math.floor(curNum.text.valueOf())).toString();
} else if (op == "+/-") { // plus/minus
- CurNum.text = (CurNum.text.valueOf() * -1).toString();
+ curNum.text = (curNum.text.valueOf() * -1).toString();
} else if (op == "Sqrt") { // square root
- CurNum.text = (Math.sqrt(CurNum.text.valueOf())).toString();
+ curNum.text = (Math.sqrt(curNum.text.valueOf())).toString();
} else if (op == "MC") { // memory clear
memory = 0;
} else if (op == "M+") { // memory increment
- memory += CurNum.text.valueOf();
+ memory += curNum.text.valueOf();
} else if (op == "MR") { // memory recall
- CurNum.text = memory.toString();
+ curNum.text = memory.toString();
} else if (op == "MS") { // memory set
- memory = CurNum.text.valueOf();
+ memory = curNum.text.valueOf();
} else if (op == "Bksp") {
- CurNum.text = CurNum.text.toString().slice(0, -1);
+ curNum.text = curNum.text.toString().slice(0, -1);
} else if (op == "C") {
- CurNum.text = "0";
+ curNum.text = "0";
} else if (op == "AC") {
curVal = 0;
memory = 0;
lastOp = "";
- CurNum.text ="0";
+ curNum.text ="0";
}
}
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index d93f04a..8041025 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -1,36 +1,35 @@
import Qt 4.6
Rectangle {
- id: MainWindow;
- width: 320; height: 270; color: Palette.window
+ width: 320; height: 270; color: palette.window
- SystemPalette { id: Palette; colorGroup: Qt.Active }
+ SystemPalette { id: palette; colorGroup: Qt.Active }
Script { source: "calculator.js" }
Column {
x: 2; spacing: 10;
Rectangle {
- id: Container
+ id: container
width: 316; height: 50
- border.color: Palette.dark; color: Palette.base
+ border.color: palette.dark; color: palette.base
Text {
- id: CurNum
+ id: curNum
font.bold: true; font.pointSize: 16
- color: Palette.text
- anchors.right: Container.right
+ color: palette.text
+ anchors.right: container.right
anchors.rightMargin: 5
- anchors.verticalCenter: Container.verticalCenter
+ anchors.verticalCenter: container.verticalCenter
}
Text {
- id: CurrentOperation
- color: Palette.text
+ id: currentOperation
+ color: palette.text
font.bold: true; font.pointSize: 16
- anchors.left: Container.left
+ anchors.left: container.left
anchors.leftMargin: 5
- anchors.verticalCenter: Container.verticalCenter
+ anchors.verticalCenter: container.verticalCenter
}
}
@@ -38,7 +37,7 @@ Rectangle {
width: 320; height: 30
CalcButton {
- id: AdvancedCheckBox
+ id: advancedCheckBox
x: 55; width: 206
operation: "Advanced Mode"
toggable: true
@@ -49,15 +48,15 @@ Rectangle {
width: 320
Item {
- id: BasicButtons
+ id: basicButtons
x: 55; width: 160; height: 160
- CalcButton { operation: "Bksp"; id: Bksp; width: 67; opacity: 0 }
- CalcButton { operation: "C"; id: C; width: 76 }
- CalcButton { operation: "AC"; id: AC; x: 78; width: 76 }
+ CalcButton { operation: "Bksp"; id: bksp; width: 67; opacity: 0 }
+ CalcButton { operation: "C"; id: c; width: 76 }
+ CalcButton { operation: "AC"; id: ac; x: 78; width: 76 }
Grid {
- id: NumKeypad; y: 32; spacing: 2; columns: 3
+ id: numKeypad; y: 32; spacing: 2; columns: 3
CalcButton { operation: "7" }
CalcButton { operation: "8" }
@@ -75,11 +74,11 @@ Rectangle {
CalcButton { operation: "0"; width: 50 }
CalcButton { operation: "."; x: 77; width: 50 }
- CalcButton { operation: "="; id: Equals; x: 77; width: 102 }
+ CalcButton { operation: "="; id: equals; x: 77; width: 102 }
}
Column {
- id: SimpleOperations
+ id: simpleOperations
x: 156; y: 0; spacing: 2
CalcButton { operation: "x" }
@@ -90,7 +89,7 @@ Rectangle {
}
Grid {
- id: AdvancedButtons
+ id: advancedButtons
x: 350; spacing: 2; columns: 2; opacity: 0
CalcButton { operation: "Abs" }
@@ -109,14 +108,14 @@ Rectangle {
states: [
State {
- name: "Advanced"; when: AdvancedCheckBox.toggled == true
- PropertyChanges { target: BasicButtons; x: 0 }
- PropertyChanges { target: SimpleOperations; y: 32 }
- PropertyChanges { target: Bksp; opacity: 1 }
- PropertyChanges { target: C; x: 69; width: 67 }
- PropertyChanges { target: AC; x: 138; width: 67 }
- PropertyChanges { target: Equals; width: 50 }
- PropertyChanges { target: AdvancedButtons; x: 210; opacity: 1 }
+ name: "Advanced"; when: advancedCheckBox.toggled == true
+ PropertyChanges { target: basicButtons; x: 0 }
+ PropertyChanges { target: simpleOperations; y: 32 }
+ PropertyChanges { target: bksp; opacity: 1 }
+ PropertyChanges { target: c; x: 69; width: 67 }
+ PropertyChanges { target: ac; x: 138; width: 67 }
+ PropertyChanges { target: equals; width: 50 }
+ PropertyChanges { target: advancedButtons; x: 210; opacity: 1 }
}
]
diff --git a/demos/declarative/contacts/Contact.qml b/demos/declarative/contacts/Contact.qml
index 91510c7..e12cd3b 100644
--- a/demos/declarative/contacts/Contact.qml
+++ b/demos/declarative/contacts/Contact.qml
@@ -82,8 +82,8 @@ Item {
}
Column {
id: layout
- width: contents.width
- height:contents.height
+ width: childrenRect.width
+ height: childrenRect.height
anchors.centerIn: parent
spacing: 5
ContactField {
diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml
index 6b42910..b8b7d29 100644
--- a/demos/declarative/flickr/common/ImageDetails.qml
+++ b/demos/declarative/flickr/common/ImageDetails.qml
@@ -1,9 +1,9 @@
import Qt 4.6
Flipable {
- id: Container
+ id: container
- property var frontContainer: ContainerFront
+ property var frontContainer: containerFront
property string photoTitle: ""
property string photoDescription: ""
property string photoTags: ""
@@ -19,13 +19,13 @@ Flipable {
signal closed
transform: Rotation {
- id: DetailsRotation
- origin.x: Container.width / 2;
+ id: detailsRotation
+ origin.x: container.width / 2;
axis.y: 1; axis.z: 0
}
front: Item {
- id: ContainerFront; anchors.fill: Container
+ id: containerFront; anchors.fill: container
Rectangle {
anchors.fill: parent
@@ -34,74 +34,74 @@ Flipable {
}
MediaButton {
- id: BackButton; x: 630; y: 370; text: "Back"
- onClicked: { Container.closed() }
+ id: backButton; x: 630; y: 370; text: "Back"
+ onClicked: { container.closed() }
}
MediaButton {
- id: MoreButton; x: 530; y: 370; text: "View..."
- onClicked: { Container.state='Back' }
+ id: moreButton; x: 530; y: 370; text: "View..."
+ onClicked: { container.state='Back' }
}
- Text { id: TitleText; style: "Raised"; styleColor: "black"; color: "white"; elide: "ElideRight"
- x: 220; y: 30; width: parent.width - 240; text: Container.photoTitle; font.pointSize: 22 }
+ Text { id: titleText; style: "Raised"; styleColor: "black"; color: "white"; elide: "ElideRight"
+ x: 220; y: 30; width: parent.width - 240; text: container.photoTitle; font.pointSize: 22 }
- LikeOMeter { x: 40; y: 250; rating: Container.rating }
+ LikeOMeter { x: 40; y: 250; rating: container.rating }
- Flickable { id: FlickSurface; x: 220; width: 480; height: 210; y: 130; clip: true
- viewportWidth: 480; viewportHeight: DescriptionText.height
+ Flickable { id: flickable; x: 220; width: 480; height: 210; y: 130; clip: true
+ viewportWidth: 480; viewportHeight: descriptionText.height
- WebView { id: DescriptionText; width: parent.width
- html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + Container.photoDescription }
+ WebView { id: descriptionText; width: parent.width
+ html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + container.photoDescription }
}
- Text { id: Size; color: "white"; width: 300; x: 40; y: 300
- text: "<b>Size:</b> " + Container.photoWidth + 'x' + Container.photoHeight }
- Text { id: Type; color: "white"; width: 300; x: 40; anchors.top: Size.bottom
- text: "<b>Type:</b> " + Container.photoType }
-
- Text { id: Author; color: "white"; width: 300; x: 220; y: 80
- text: "<b>Author:</b> " + Container.photoAuthor }
- Text { id: Date; color: "white"; width: 300; x: 220; anchors.top: Author.bottom
- text: "<b>Published:</b> " + Container.photoDate }
- Text { id: TagsLabel; color: "white"; x: 220; anchors.top: Date.bottom;
- text: Container.photoTags == "" ? "" : "<b>Tags:</b> " }
- Text { id: Tags; color: "white"; width: parent.width-x-20;
- anchors.left: TagsLabel.right; anchors.top: Date.bottom;
- elide: "ElideRight"; text: Container.photoTags }
-
- ScrollBar { id: ScrollBar; x: 720; y: FlickSurface.y; width: 7; height: FlickSurface.height; opacity: 0;
- flickableArea: FlickSurface; clip: true }
+ Text { id: size; color: "white"; width: 300; x: 40; y: 300
+ text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight }
+ Text { id: type; color: "white"; width: 300; x: 40; anchors.top: size.bottom
+ text: "<b>Type:</b> " + container.photoType }
+
+ Text { id: author; color: "white"; width: 300; x: 220; y: 80
+ text: "<b>Author:</b> " + container.photoAuthor }
+ Text { id: date; color: "white"; width: 300; x: 220; anchors.top: author.bottom
+ text: "<b>Published:</b> " + container.photoDate }
+ Text { id: tagsLabel; color: "white"; x: 220; anchors.top: date.bottom;
+ text: container.photoTags == "" ? "" : "<b>Tags:</b> " }
+ Text { id: tags; color: "white"; width: parent.width-x-20;
+ anchors.left: tagsLabel.right; anchors.top: date.bottom;
+ elide: "ElideRight"; text: container.photoTags }
+
+ ScrollBar { id: scrollBar; x: 720; y: flickable.y; width: 7; height: flickable.height; opacity: 0;
+ flickableArea: flickable; clip: true }
}
back: Item {
- anchors.fill: Container
+ anchors.fill: container
Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4; border.color: "white"; border.width: 2 }
- Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status!=1 }
+ Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 }
Flickable {
- id: Flick; width: Container.width - 10; height: Container.height - 10
+ id: flick; width: container.width - 10; height: container.height - 10
x: 5; y: 5; clip: true;
- viewportWidth: ImageContainer.width; viewportHeight: ImageContainer.height
+ viewportWidth: imageContainer.width; viewportHeight: imageContainer.height
Item {
- id: ImageContainer
- width: Math.max(BigImage.width * BigImage.scale, Flick.width);
- height: Math.max(BigImage.height * BigImage.scale, Flick.height);
+ id: imageContainer
+ width: Math.max(bigImage.width * bigImage.scale, flick.width);
+ height: Math.max(bigImage.height * bigImage.scale, flick.height);
Image {
- id: BigImage; source: Container.photoUrl; scale: Slider.value
+ id: bigImage; source: container.photoUrl; scale: slider.value
// Center image if it is smaller than the flickable area.
- x: ImageContainer.width > width*scale ? (ImageContainer.width - width*scale) / 2 : 0
- y: ImageContainer.height > height*scale ? (ImageContainer.height - height*scale) / 2 : 0
- smooth: !Flick.moving
+ x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0
+ y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0
+ smooth: !flick.moving
onStatusChanged : {
// Default scale shows the entire image.
if (status == 1 && width != 0) {
- Slider.minimum = Math.min(Flick.width / width, Flick.height / height);
- prevScale = Math.min(Slider.minimum, 1);
- Slider.value = prevScale;
+ slider.minimum = Math.min(flick.width / width, flick.height / height);
+ prevScale = Math.min(slider.minimum, 1);
+ slider.value = prevScale;
}
}
}
@@ -109,24 +109,24 @@ Flipable {
}
MediaButton {
- id: BackButton2; x: 630; y: 370; text: "Back"; onClicked: { Container.state = '' }
+ id: backButton2; x: 630; y: 370; text: "Back"; onClicked: { container.state = '' }
}
Text {
text: "Image Unavailable"
- visible: BigImage.status == 'Error'
+ visible: bigImage.status == 'Error'
anchors.centerIn: parent; color: "white"; font.bold: true
}
Slider {
- id: Slider; x: 25; y: 374; visible: { BigImage.status == 1 && maximum > minimum }
+ id: slider; x: 25; y: 374; visible: { bigImage.status == 1 && maximum > minimum }
onValueChanged: {
- if (BigImage.width * value > Flick.width) {
- var xoff = (Flick.width/2 + Flick.viewportX) * value / prevScale;
- Flick.viewportX = xoff - Flick.width/2;
+ if (bigImage.width * value > flick.width) {
+ var xoff = (flick.width/2 + flick.viewportX) * value / prevScale;
+ flick.viewportX = xoff - flick.width/2;
}
- if (BigImage.height * value > Flick.height) {
- var yoff = (Flick.height/2 + Flick.viewportY) * value / prevScale;
- Flick.viewportY = yoff - Flick.height/2;
+ if (bigImage.height * value > flick.height) {
+ var yoff = (flick.height/2 + flick.viewportY) * value / prevScale;
+ flick.viewportY = yoff - flick.height/2;
}
prevScale = value;
}
@@ -136,7 +136,7 @@ Flipable {
states: [
State {
name: "Back"
- PropertyChanges { target: DetailsRotation; angle: 180 }
+ PropertyChanges { target: detailsRotation; angle: 180 }
}
]
@@ -144,15 +144,15 @@ Flipable {
Transition {
SequentialAnimation {
PropertyAction {
- target: BigImage
+ target: bigImage
property: "smooth"
value: false
}
NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
PropertyAction {
- target: BigImage
+ target: bigImage
property: "smooth"
- value: !Flick.moving
+ value: !flick.moving
}
}
}
diff --git a/demos/declarative/flickr/common/LikeOMeter.qml b/demos/declarative/flickr/common/LikeOMeter.qml
index 754dbb1..5ee048b 100644
--- a/demos/declarative/flickr/common/LikeOMeter.qml
+++ b/demos/declarative/flickr/common/LikeOMeter.qml
@@ -1,35 +1,35 @@
import Qt 4.6
Item {
- id: Container
+ id: container
property int rating: 2
Row {
Star {
rating: 0
- onClicked: { Container.rating = rating }
- on: Container.rating >= 0
+ onClicked: { container.rating = rating }
+ on: container.rating >= 0
}
Star {
rating: 1
- onClicked: { Container.rating = rating }
- on: Container.rating >= 1
+ onClicked: { container.rating = rating }
+ on: container.rating >= 1
}
Star {
rating: 2
- onClicked: { Container.rating = rating }
- on: Container.rating >= 2
+ onClicked: { container.rating = rating }
+ on: container.rating >= 2
}
Star {
rating: 3
- onClicked: { Container.rating = rating }
- on: Container.rating >= 3
+ onClicked: { container.rating = rating }
+ on: container.rating >= 3
}
Star {
rating: 4
- onClicked: { Container.rating = rating }
- on: Container.rating >= 4
+ onClicked: { container.rating = rating }
+ on: container.rating >= 4
}
}
}
diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml
index ff2c829..64a04c4 100644
--- a/demos/declarative/flickr/common/Loading.qml
+++ b/demos/declarative/flickr/common/Loading.qml
@@ -1,8 +1,8 @@
import Qt 4.6
Image {
- id: Loading; source: "pics/loading.png"; transformOrigin: "Center"
+ id: loading; source: "pics/loading.png"; transformOrigin: "Center"
rotation: NumberAnimation {
- id: "RotationAnimation"; from: 0; to: 360; running: Loading.visible == true; repeat: true; duration: 900
+ id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900
}
}
diff --git a/demos/declarative/flickr/common/MediaButton.qml b/demos/declarative/flickr/common/MediaButton.qml
index e1e09e8..c12b642 100644
--- a/demos/declarative/flickr/common/MediaButton.qml
+++ b/demos/declarative/flickr/common/MediaButton.qml
@@ -1,39 +1,39 @@
import Qt 4.6
Item {
- id: Container
+ id: container
signal clicked
property string text
Image {
- id: ButtonImage
+ id: buttonImage
source: "pics/button.png"
}
Image {
- id: Pressed
+ id: pressed
source: "pics/button-pressed.png"
opacity: 0
}
MouseRegion {
- id: MyMouseRegion
- anchors.fill: ButtonImage
- onClicked: { Container.clicked(); }
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
}
Text {
font.bold: true
color: "white"
- anchors.centerIn: ButtonImage
- text: Container.text
+ anchors.centerIn: buttonImage
+ text: container.text
}
- width: ButtonImage.width
+ width: buttonImage.width
states: [
State {
name: "Pressed"
- when: MyMouseRegion.pressed == true
+ when: mouseRegion.pressed == true
PropertyChanges {
- target: Pressed
+ target: pressed
opacity: 1
}
}
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index 7599ce6a05..4b21f66 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -1,42 +1,42 @@
import Qt 4.6
Item {
- id: Container
+ id: container
property string label
property string text
- width: Math.max(94,Label.width + Editor.width + 20)
- height: ButtonImage.height
+ width: Math.max(94,label.width + editor.width + 20)
+ height: buttonImage.height
states: [
State {
name: "Edit"
PropertyChanges {
- target: Label
- text: Container.label + ": "
+ target: label
+ text: container.label + ": "
}
PropertyChanges {
- target: Label
+ target: label
x: 10
}
PropertyChanges {
- target: Editor
+ target: editor
cursorVisible: true
width: 100
}
PropertyChanges {
- target: Container
+ target: container
focus: true
}
StateChangeScript {
- script:"Editor.selectAll()"
+ script:"editor.selectAll()"
}
},
State {
// When returning to default state, typed text is propagated
StateChangeScript {
- script: "Container.text = Editor.text"
+ script: "container.text = editor.text"
}
}
]
@@ -48,29 +48,29 @@ Item {
BorderImage {
- id: ButtonImage
+ id: buttonImage
source: "pics/button.sci"
- anchors.left: Container.left
- anchors.right: Container.right
+ anchors.left: container.left
+ anchors.right: container.right
}
BorderImage {
- id: Pressed
+ id: pressed
source: "pics/button-pressed.sci"
opacity: 0
- anchors.left: Container.left
- anchors.right: Container.right
+ anchors.left: container.left
+ anchors.right: container.right
}
MouseRegion {
- id: MyMouseRegion
- anchors.fill: ButtonImage
- onClicked: { Container.state = Container.state=="Edit" ? "" : "Edit" }
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.state = container.state=="Edit" ? "" : "Edit" }
states: [
State {
- when: MyMouseRegion.pressed == true
+ when: mouseRegion.pressed == true
PropertyChanges {
- target: Pressed
+ target: pressed
opacity: 1
}
}
@@ -78,27 +78,27 @@ Item {
}
Text {
- id: Label
+ id: label
font.bold: true
color: "white"
- anchors.verticalCenter: Container.verticalCenter
- x: (Container.width - width)/2
- text: Container.label + "..."
+ anchors.verticalCenter: container.verticalCenter
+ x: (container.width - width)/2
+ text: container.label + "..."
}
TextInput {
- id: Editor
+ id: editor
font.bold: true
color: "white"
selectionColor: "green"
width: 0
clip: true
- anchors.left: Label.right
- anchors.verticalCenter: Container.verticalCenter
+ anchors.left: label.right
+ anchors.verticalCenter: container.verticalCenter
}
- Keys.forwardTo: [(ReturnKey), (Editor)]
+ Keys.forwardTo: [(returnKey), (editor)]
Item {
- id: ReturnKey
- Keys.onReturnPressed: "Container.state = ''"
+ id: returnKey
+ Keys.onReturnPressed: "container.state = ''"
}
}
diff --git a/demos/declarative/flickr/common/Progress.qml b/demos/declarative/flickr/common/Progress.qml
index 00ef901..fd9be10 100644
--- a/demos/declarative/flickr/common/Progress.qml
+++ b/demos/declarative/flickr/common/Progress.qml
@@ -1,12 +1,10 @@
import Qt 4.6
Item {
- id: Progress;
-
property var progress: 0
Rectangle {
- id: Container; anchors.fill: parent; smooth: true
+ anchors.fill: parent; smooth: true
border.color: "white"; border.width: 0; radius: height/2 - 2
gradient: Gradient {
GradientStop { position: 0; color: "#66343434" }
@@ -15,7 +13,6 @@ Item {
}
Rectangle {
- id: Fill
y: 2; height: parent.height-4;
x: 2; width: Math.max(parent.width * progress - 4, 0);
opacity: width < 1 ? 0 : 1; smooth: true
diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml
index d31c57c..feebcb0 100644
--- a/demos/declarative/flickr/common/ScrollBar.qml
+++ b/demos/declarative/flickr/common/ScrollBar.qml
@@ -1,7 +1,7 @@
import Qt 4.6
Item {
- id: Container
+ id: container
property var flickableArea
@@ -12,16 +12,16 @@ Item {
border.color: "white"
border.width: 2
x: 0
- y: flickableArea.visibleArea.yPosition * Container.height
+ y: flickableArea.visibleArea.yPosition * container.height
width: parent.width
- height: flickableArea.visibleArea.heightRatio * Container.height
+ height: flickableArea.visibleArea.heightRatio * container.height
}
states: [
State {
name: "show"
when: flickableArea.moving
PropertyChanges {
- target: Container
+ target: container
opacity: 1
}
}
@@ -31,7 +31,7 @@ Item {
from: "*"
to: "*"
NumberAnimation {
- target: Container
+ target: container
properties: "opacity"
duration: 400
}
diff --git a/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/common/Slider.qml
index b88636d..fa1645c 100644
--- a/demos/declarative/flickr/common/Slider.qml
+++ b/demos/declarative/flickr/common/Slider.qml
@@ -1,17 +1,17 @@
import Qt 4.6
Item {
- id: Slider; width: 400; height: 16
+ id: slider; width: 400; height: 16
// value is read/write.
property real value
- onValueChanged: { Handle.x = 2 + (value - minimum) * Slider.xMax / (maximum - minimum); }
+ onValueChanged: { handle.x = 2 + (value - minimum) * slider.xMax / (maximum - minimum); }
property real maximum: 1
property real minimum: 1
- property int xMax: Slider.width - Handle.width - 4
+ property int xMax: slider.width - handle.width - 4
Rectangle {
- id: Container; anchors.fill: parent
+ anchors.fill: parent
border.color: "white"; border.width: 0; radius: 8
gradient: Gradient {
GradientStop { position: 0.0; color: "#66343434" }
@@ -20,8 +20,8 @@ Item {
}
Rectangle {
- id: Handle; smooth: true
- x: Slider.width / 2 - Handle.width / 2; y: 2; width: 30; height: Slider.height-4; radius: 6
+ id: handle; smooth: true
+ x: slider.width / 2 - handle.width / 2; y: 2; width: 30; height: slider.height-4; radius: 6
gradient: Gradient {
GradientStop { position: 0.0; color: "lightgray" }
GradientStop { position: 1.0; color: "gray" }
@@ -29,8 +29,8 @@ Item {
MouseRegion {
anchors.fill: parent; drag.target: parent
- drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2
- onPositionChanged: { value = (maximum - minimum) * (Handle.x-2) / Slider.xMax + minimum; }
+ drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: slider.xMax+2
+ onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
}
}
}
diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml
index c4d1bec..173021b 100644
--- a/demos/declarative/flickr/common/Star.qml
+++ b/demos/declarative/flickr/common/Star.qml
@@ -1,17 +1,16 @@
import Qt 4.6
Item {
- id: Container
+ id: container
width: 24
height: 24
property int rating
property bool on
-
signal clicked
Image {
- id: StarImage
+ id: starImage
source: "pics/ghns_star.png"
x: 6
y: 7
@@ -19,15 +18,15 @@ Item {
scale: 0.5
}
MouseRegion {
- anchors.fill: Container
- onClicked: { Container.clicked() }
+ anchors.fill: container
+ onClicked: { container.clicked() }
}
states: [
State {
name: "on"
- when: Container.on == true
+ when: container.on == true
PropertyChanges {
- target: StarImage
+ target: starImage
opacity: 1
scale: 1
x: 1
diff --git a/demos/declarative/flickr/common/pics/button-pressed.sci b/demos/declarative/flickr/common/pics/button-pressed.sci
index d3b16e2..b8db272 100644
--- a/demos/declarative/flickr/common/pics/button-pressed.sci
+++ b/demos/declarative/flickr/common/pics/button-pressed.sci
@@ -1,5 +1,5 @@
-gridLeft: 8
-gridTop: 4
-gridBottom: 4
-gridRight: 8
-imageFile: button.png
+border.left: 8
+border.top: 4
+border.bottom: 4
+border.right: 8
+source: button.png
diff --git a/demos/declarative/flickr/common/pics/button.sci b/demos/declarative/flickr/common/pics/button.sci
index d3b16e2..b8db272 100644
--- a/demos/declarative/flickr/common/pics/button.sci
+++ b/demos/declarative/flickr/common/pics/button.sci
@@ -1,5 +1,5 @@
-gridLeft: 8
-gridTop: 4
-gridBottom: 4
-gridRight: 8
-imageFile: button.png
+border.left: 8
+border.top: 4
+border.bottom: 4
+border.right: 8
+source: button.png
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 6a4efd9..d1ad6e1 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -3,94 +3,96 @@ import Qt 4.6
import "common"
Item {
- id: MainWindow; width: 800; height: 450
+ id: mainWindow; width: 800; height: 450
property bool showPathView : false
resources: [
Component {
- id: PhotoDelegate
+ id: photoDelegate
Item {
- id: Wrapper; width: 85; height: 85
- scale: Wrapper.PathView.scale; z: Wrapper.PathView.z
+ id: wrapper; width: 85; height: 85
+ scale: wrapper.PathView.scale; z: wrapper.PathView.z
transform: Rotation {
- id: ItemRotation; origin.x: Wrapper.width/2; origin.y: Wrapper.height/2
- axis.y: 1; axis.z: 0; angle: Wrapper.PathView.angle
+ id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
+ axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle
}
Connection {
- sender: ImageDetails; signal: "closed()"
+ sender: imageDetails; signal: "closed()"
script: {
- if (Wrapper.state == 'Details') {
- Wrapper.state = '';
- ImageDetails.photoUrl = "";
+ if (wrapper.state == 'Details') {
+ wrapper.state = '';
+ imageDetails.photoUrl = "";
}
}
}
Script {
function photoClicked() {
- ImageDetails.photoTitle = title;
- ImageDetails.photoDescription = description;
- ImageDetails.photoTags = tags;
- ImageDetails.photoWidth = photoWidth;
- ImageDetails.photoHeight = photoHeight;
- ImageDetails.photoType = photoType;
- ImageDetails.photoAuthor = photoAuthor;
- ImageDetails.photoDate = photoDate;
- ImageDetails.photoUrl = url;
- ImageDetails.rating = 0;
- Wrapper.state = "Details";
+ imageDetails.photoTitle = title;
+ imageDetails.photoDescription = description;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ wrapper.state = "Details";
}
}
Rectangle {
- id: WhiteRect; anchors.fill: parent; color: "white"; radius: 5
+ id: whiteRect; anchors.fill: parent; color: "white"; radius: 5
- Loading { x: 26; y: 26; visible: Thumb.status!=1 }
- Image { id: Thumb; source: imagePath; x: 5; y: 5 }
+ Loading { x: 26; y: 26; visible: thumb.status!=1 }
+ Image { id: thumb; source: imagePath; x: 5; y: 5 }
Item {
- id: Shadows
- Image { source: "common/pics/shadow-right.png"; x: WhiteRect.width; height: WhiteRect.height }
- Image { source: "common/pics/shadow-bottom.png"; y: WhiteRect.height; width: WhiteRect.width }
- Image { id: Corner; source: "common/pics/shadow-corner.png"; x: WhiteRect.width; y: WhiteRect.height }
+ id: shadows
+ Image { source: "common/pics/shadow-right.png"; x: whiteRect.width; height: whiteRect.height }
+ Image { source: "common/pics/shadow-bottom.png"; y: whiteRect.height; width: whiteRect.width }
+ Image { id: Corner; source: "common/pics/shadow-corner.png"; x: whiteRect.width; y: whiteRect.height }
}
}
- MouseRegion { anchors.fill: Wrapper; onClicked: { photoClicked() } }
+ MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
states: [
State {
name: "Details"
- PropertyChanges { target: ImageDetails; z: 2 }
- ParentChange { target: Wrapper; parent: ImageDetails.frontContainer }
- PropertyChanges { target: Wrapper; x: 45; y: 35; scale: 1; z: 1000 }
- PropertyChanges { target: ItemRotation; angle: 0 }
- PropertyChanges { target: Shadows; opacity: 0 }
- PropertyChanges { target: ImageDetails; y: 20 }
- PropertyChanges { target: PhotoGridView; y: "-480" }
- PropertyChanges { target: PhotoPathView; y: "-480" }
- PropertyChanges { target: ViewModeButton; opacity: 0 }
- PropertyChanges { target: TagsEdit; opacity: 0 }
- PropertyChanges { target: FetchButton; opacity: 0 }
- PropertyChanges { target: CategoryText; y: "-50" }
+ PropertyChanges { target: imageDetails; z: 2 }
+ ParentChange { target: wrapper; parent: imageDetails.frontContainer }
+ PropertyChanges { target: wrapper; x: 45; y: 35; scale: 1; z: 1000 }
+ PropertyChanges { target: itemRotation; angle: 0 }
+ PropertyChanges { target: shadows; opacity: 0 }
+ PropertyChanges { target: imageDetails; y: 20 }
+ PropertyChanges { target: photoGridView; y: -480 }
+ PropertyChanges { target: photoPathView; y: -480 }
+ PropertyChanges { target: viewModeButton; opacity: 0 }
+ PropertyChanges { target: tagsEdit; opacity: 0 }
+ PropertyChanges { target: fetchButton; opacity: 0 }
+ PropertyChanges { target: categoryText; y: "-50" }
}
]
transitions: [
Transition {
from: "*"; to: "Details"
- ParentAction { }
- NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ SequentialAnimation {
+ ParentAction { }
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ }
},
Transition {
from: "Details"; to: "*"
SequentialAnimation {
ParentAction { }
NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
- PropertyAction { target: Wrapper; properties: "z" }
+ PropertyAction { target: wrapper; properties: "z" }
}
}
]
@@ -100,21 +102,21 @@ Item {
]
Item {
- id: Background
+ id: background
anchors.fill: parent
Image { source: "common/pics/background.png"; anchors.fill: parent }
- RssModel { id: RssModel; tags : TagsEdit.text }
- Loading { anchors.centerIn: parent; visible: RssModel.status == 2 }
+ RssModel { id: rssModel; tags : tagsEdit.text }
+ Loading { anchors.centerIn: parent; visible: rssModel.status == 2 }
GridView {
- id: PhotoGridView; model: RssModel; delegate: PhotoDelegate; cacheBuffer: 100
+ id: photoGridView; model: rssModel; delegate: photoDelegate; cacheBuffer: 100
cellWidth: 105; cellHeight: 105; x:32; y: 80; width: 800; height: 330; z: 1
}
PathView {
- id: PhotoPathView; model: RssModel; delegate: PhotoDelegate
+ id: photoPathView; model: rssModel; delegate: photoDelegate
y: -380; width: 800; height: 330; pathItemCount: 10; z: 1
path: Path {
startX: -50; startY: 40;
@@ -144,36 +146,34 @@ Item {
}
- ImageDetails { id: ImageDetails; width: 750; x: 25; y: 500; height: 410 }
+ ImageDetails { id: imageDetails; width: 750; x: 25; y: 500; height: 410 }
MediaButton {
- id: ViewModeButton; x: 680; y: 410; text: "View Mode"
- onClicked: { if (MainWindow.showPathView == true) MainWindow.showPathView = false; else MainWindow.showPathView = true }
+ id: viewModeButton; x: 680; y: 410; text: "View Mode"
+ onClicked: { if (mainWindow.showPathView == true) mainWindow.showPathView = false; else mainWindow.showPathView = true }
}
MediaButton {
- id: FetchButton
+ id: fetchButton
text: "Update"
- anchors.right: ViewModeButton.left; anchors.rightMargin: 5
- anchors.top: ViewModeButton.top
- onClicked: { RssModel.reload(); }
+ anchors.right: viewModeButton.left; anchors.rightMargin: 5
+ anchors.top: viewModeButton.top
+ onClicked: { rssModel.reload(); }
}
MediaLineEdit {
- id: TagsEdit;
+ id: tagsEdit;
label: "Tags"
- anchors.right: FetchButton.left; anchors.rightMargin: 5
- anchors.top: ViewModeButton.top
+ anchors.right: fetchButton.left; anchors.rightMargin: 5
+ anchors.top: viewModeButton.top
}
- states: [
- State {
- name: "PathView"
- when: MainWindow.showPathView == true
- PropertyChanges { target: PhotoPathView; y: 80 }
- PropertyChanges { target: PhotoGridView; y: -380 }
- }
- ]
+ states: State {
+ name: "PathView"
+ when: mainWindow.showPathView == true
+ PropertyChanges { target: photoPathView; y: 80 }
+ PropertyChanges { target: photoGridView; y: -380 }
+ }
transitions: [
Transition {
@@ -184,9 +184,9 @@ Item {
}
Text {
- id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15;
+ id: categoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15;
text: "Flickr - " +
- (RssModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + RssModel.tags)
+ (rssModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + rssModel.tags)
font.pointSize: 20; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
}
}
diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml
index 32f3e37..48fe7df 100644
--- a/demos/declarative/flickr/flickr-mobile.qml
+++ b/demos/declarative/flickr/flickr-mobile.qml
@@ -3,38 +3,38 @@ import "common" as Common
import "mobile" as Mobile
Item {
- id: Screen; width: 320; height: 480
+ id: screen; width: 320; height: 480
property bool inListView : false
Rectangle {
- id: Background
+ id: background
anchors.fill: parent; color: "#343434";
Image { source: "mobile/images/stripes.png"; fillMode: "Tile"; anchors.fill: parent; opacity: 0.3 }
- Common.RssModel { id: RssModel }
- Common.Loading { anchors.centerIn: parent; visible: RssModel.status == 2 }
+ Common.RssModel { id: rssModel }
+ Common.Loading { anchors.centerIn: parent; visible: rssModel.status == 2 }
Item {
- id: Views
+ id: views
x: 2; width: parent.width - 4
- anchors.top: TitleBar.bottom; anchors.bottom: ToolBar.top
+ anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
- Mobile.GridDelegate { id: GridDelegate }
+ Mobile.GridDelegate { id: gridDelegate }
GridView {
- id: PhotoGridView; model: RssModel; delegate: GridDelegate; cacheBuffer: 100
+ id: photoGridView; model: rssModel; delegate: gridDelegate; cacheBuffer: 100
cellWidth: 79; cellHeight: 79; width: parent.width; height: parent.height - 1; z: 6
}
- Mobile.ListDelegate { id: ListDelegate }
+ Mobile.ListDelegate { id: listDelegate }
ListView {
- id: PhotoListView; model: RssModel; delegate: ListDelegate; z: 6
+ id: photoListView; model: rssModel; delegate: listDelegate; z: 6
width: parent.width; height: parent.height; x: -(parent.width * 1.5); cacheBuffer: 100;
}
states: State {
- name: "ListView"; when: Screen.inListView == true
- PropertyChanges { target: PhotoListView; x: 0 }
- PropertyChanges { target: PhotoGridView; x: -(parent.width * 1.5) }
+ name: "ListView"; when: screen.inListView == true
+ PropertyChanges { target: photoListView; x: 0 }
+ PropertyChanges { target: photoGridView; x: -(parent.width * 1.5) }
}
transitions: Transition {
@@ -42,37 +42,37 @@ Item {
}
}
- Mobile.ImageDetails { id: ImageDetails; width: parent.width; anchors.left: Views.right; height: parent.height; z:1 }
- Mobile.TitleBar { id: TitleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 }
+ Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height; z:1 }
+ Mobile.TitleBar { id: titleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 }
Mobile.ToolBar {
- id: ToolBar; z: 5
+ id: toolBar; z: 5
height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
button1Label: "Update"; button2Label: "View mode"
- onButton1Clicked: RssModel.reload()
- onButton2Clicked: if (Screen.inListView == true) Screen.inListView = false; else Screen.inListView = true
+ onButton1Clicked: rssModel.reload()
+ onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = true
}
Connection {
- sender: ImageDetails; signal: "closed()"
+ sender: imageDetails; signal: "closed()"
script: {
- if (Background.state == "DetailedView") {
- Background.state = '';
- ImageDetails.photoUrl = "";
+ if (background.state == "DetailedView") {
+ background.state = '';
+ imageDetails.photoUrl = "";
}
}
}
states: State {
name: "DetailedView"
- PropertyChanges { target: Views; x: -parent.width }
- PropertyChanges { target: ToolBar; button1Label: "More..." }
+ PropertyChanges { target: views; x: -parent.width }
+ PropertyChanges { target: toolBar; button1Label: "More..." }
PropertyChanges {
- target: ToolBar
- onButton1Clicked: if (ImageDetails.state=='') ImageDetails.state='Back'; else ImageDetails.state=''
+ target: toolBar
+ onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
}
- PropertyChanges { target: ToolBar; button2Label: "Back" }
- PropertyChanges { target: ToolBar; onButton2Clicked: ImageDetails.closed() }
+ PropertyChanges { target: toolBar; button2Label: "Back" }
+ PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
}
transitions: Transition {
diff --git a/demos/declarative/flickr/mobile/Button.qml b/demos/declarative/flickr/mobile/Button.qml
index 6887240..a4a96d4 100644
--- a/demos/declarative/flickr/mobile/Button.qml
+++ b/demos/declarative/flickr/mobile/Button.qml
@@ -1,41 +1,38 @@
import Qt 4.6
Item {
- id: Container
+ id: container
signal clicked
property string text
BorderImage {
- id: ButtonImage
+ id: buttonImage
source: "images/toolbutton.sci"
- width: Container.width; height: Container.height
+ width: container.width; height: container.height
}
BorderImage {
- id: Pressed
+ id: pressed
opacity: 0
source: "images/toolbutton.sci"
- width: Container.width; height: Container.height
+ width: container.width; height: container.height
}
MouseRegion {
- id: MyMouseRegion
- anchors.fill: ButtonImage
- onClicked: { Container.clicked(); }
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
}
Text {
color: "white"
- anchors.centerIn: ButtonImage; font.bold: true
- text: Container.text; style: "Raised"; styleColor: "black"
+ anchors.centerIn: buttonImage; font.bold: true
+ text: container.text; style: "Raised"; styleColor: "black"
}
states: [
State {
name: "Pressed"
- when: MyMouseRegion.pressed == true
- PropertyChanges {
- target: Pressed
- opacity: 1
- }
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
}
]
}
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index 19369b2..9b9fb24 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -1,22 +1,22 @@
import Qt 4.6
Component {
- id: PhotoDelegate
+ id: photoDelegate
Item {
- id: Wrapper; width: 79; height: 79
+ id: wrapper; width: 79; height: 79
Script {
function photoClicked() {
- ImageDetails.photoTitle = title;
- ImageDetails.photoTags = tags;
- ImageDetails.photoWidth = photoWidth;
- ImageDetails.photoHeight = photoHeight;
- ImageDetails.photoType = photoType;
- ImageDetails.photoAuthor = photoAuthor;
- ImageDetails.photoDate = photoDate;
- ImageDetails.photoUrl = url;
- ImageDetails.rating = 0;
- ScaleMe.state = "Details";
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
}
}
@@ -24,31 +24,31 @@
anchors.centerIn: parent
scale: 0.0
scale: Behavior { NumberAnimation { easing: "easeInOutQuad"} }
- id: ScaleMe
+ id: scaleMe
- Rectangle { height: 79; width: 79; id: BlackRect; anchors.centerIn: parent; color: "black"; smooth: true }
+ Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true }
Rectangle {
- id: WhiteRect; width: 77; height: 77; anchors.centerIn: parent; color: "#dddddd"; smooth: true
- Image { id: Thumb; source: imagePath; x: 1; y: 1; smooth: true}
+ id: whiteRect; width: 77; height: 77; anchors.centerIn: parent; color: "#dddddd"; smooth: true
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true}
Image { source: "images/gloss.png" }
}
Connection {
- sender: ToolBar; signal: "button2Clicked()"
- script: if (ScaleMe.state == 'Details' ) ScaleMe.state = 'Show';
+ sender: toolBar; signal: "button2Clicked()"
+ script: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show';
}
states: [
State {
- name: "Show"; when: Thumb.status == 1
- PropertyChanges { target: ScaleMe; scale: 1 }
+ name: "Show"; when: thumb.status == 1
+ PropertyChanges { target: scaleMe; scale: 1 }
},
State {
name: "Details"
- PropertyChanges { target: ScaleMe; scale: 1 }
- ParentChange { target: Wrapper; parent: ImageDetails.frontContainer }
- PropertyChanges { target: Wrapper; x: 20; y: 60; z: 1000 }
- PropertyChanges { target: Background; state: "DetailedView" }
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: wrapper; parent: imageDetails.frontContainer }
+ PropertyChanges { target: wrapper; x: 20; y: 60; z: 1000 }
+ PropertyChanges { target: background; state: "DetailedView" }
}
]
transitions: [
@@ -62,11 +62,11 @@
SequentialAnimation {
ParentAction { }
NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" }
- PropertyAction { target: Wrapper; properties: "z" }
+ PropertyAction { target: wrapper; properties: "z" }
}
}
]
}
- MouseRegion { anchors.fill: Wrapper; onClicked: { photoClicked() } }
+ MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
}
}
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index c55ab50..26052b9 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -2,9 +2,9 @@ import Qt 4.6
import "../common" as Common
Flipable {
- id: Container
+ id: container
- property var frontContainer: ContainerFront
+ property var frontContainer: containerFront
property string photoTitle: ""
property string photoTags: ""
property int photoWidth
@@ -19,13 +19,13 @@ Flipable {
signal closed
transform: Rotation {
- id: ItemRotation
- origin.x: Container.width / 2;
+ id: itemRotation
+ origin.x: container.width / 2;
axis.y: 1; axis.z: 0
}
front: Item {
- id: ContainerFront; anchors.fill: Container
+ id: containerFront; anchors.fill: container
Rectangle {
anchors.fill: parent
@@ -39,43 +39,43 @@ Flipable {
right: parent.right; rightMargin: 20
top: parent.top; topMargin: 180
}
- Text { id: TitleText; font.bold: true; color: "white"; elide: "ElideRight"; text: Container.photoTitle }
- Text { id: Size; color: "white"; elide: "ElideRight"; text: "<b>Size:</b> " + Container.photoWidth + 'x' + Container.photoHeight }
- Text { id: Type; color: "white"; elide: "ElideRight"; text: "<b>Type:</b> " + Container.photoType }
- Text { id: Author; color: "white"; elide: "ElideRight"; text: "<b>Author:</b> " + Container.photoAuthor }
- Text { id: Date; color: "white"; elide: "ElideRight"; text: "<b>Published:</b> " + Container.photoDate }
- Text { id: TagsLabel; color: "white"; elide: "ElideRight"; text: Container.photoTags == "" ? "" : "<b>Tags:</b> " }
- Text { id: Tags; color: "white"; elide: "ElideRight"; elide: "ElideRight"; text: Container.photoTags }
+ Text { font.bold: true; color: "white"; elide: "ElideRight"; text: container.photoTitle }
+ Text { color: "white"; elide: "ElideRight"; text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight }
+ Text { color: "white"; elide: "ElideRight"; text: "<b>Type:</b> " + container.photoType }
+ Text { color: "white"; elide: "ElideRight"; text: "<b>Author:</b> " + container.photoAuthor }
+ Text { color: "white"; elide: "ElideRight"; text: "<b>Published:</b> " + container.photoDate }
+ Text { color: "white"; elide: "ElideRight"; text: container.photoTags == "" ? "" : "<b>Tags:</b> " }
+ Text { color: "white"; elide: "ElideRight"; elide: "ElideRight"; text: container.photoTags }
}
}
back: Item {
- anchors.fill: Container
+ anchors.fill: container
Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 }
- Common.Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status!=1 }
+ Common.Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 }
Flickable {
- id: Flick; anchors.fill: parent; clip: true
- viewportWidth: ImageContainer.width; viewportHeight: ImageContainer.height
+ id: flickable; anchors.fill: parent; clip: true
+ viewportWidth: imageContainer.width; viewportHeight: imageContainer.height
Item {
- id: ImageContainer
- width: Math.max(BigImage.width * BigImage.scale, Flick.width);
- height: Math.max(BigImage.height * BigImage.scale, Flick.height);
+ id: imageContainer
+ width: Math.max(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.max(bigImage.height * bigImage.scale, flickable.height);
Image {
- id: BigImage; source: Container.photoUrl; scale: Slider.value
+ id: bigImage; source: container.photoUrl; scale: slider.value
// Center image if it is smaller than the flickable area.
- x: ImageContainer.width > width*scale ? (ImageContainer.width - width*scale) / 2 : 0
- y: ImageContainer.height > height*scale ? (ImageContainer.height - height*scale) / 2 : 0
- smooth: !Flick.moving
+ x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0
+ y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0
+ smooth: !flickable.moving
onStatusChanged : {
// Default scale shows the entire image.
if (status == 1 && width != 0) {
- Slider.minimum = Math.min(Flick.width / width, Flick.height / height);
- prevScale = Math.min(Slider.minimum, 1);
- Slider.value = prevScale;
+ slider.minimum = Math.min(flickable.width / width, flickable.height / height);
+ prevScale = Math.min(slider.minimum, 1);
+ slider.value = prevScale;
}
}
}
@@ -84,25 +84,25 @@ Flipable {
Text {
text: "Image Unavailable"
- visible: BigImage.status == 'Error'
+ visible: bigImage.status == 'Error'
anchors.centerIn: parent; color: "white"; font.bold: true
}
Common.Slider {
- id: Slider; visible: { BigImage.status == 1 && maximum > minimum }
+ id: slider; visible: { bigImage.status == 1 && maximum > minimum }
anchors {
bottom: parent.bottom; bottomMargin: 65
left: parent.left; leftMargin: 25
right: parent.right; rightMargin: 25
}
onValueChanged: {
- if (BigImage.width * value > Flick.width) {
- var xoff = (Flick.width/2 + Flick.viewportX) * value / prevScale;
- Flick.viewportX = xoff - Flick.width/2;
+ if (bigImage.width * value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.viewportX) * value / prevScale;
+ flickable.viewportX = xoff - flickable.width/2;
}
- if (BigImage.height * value > Flick.height) {
- var yoff = (Flick.height/2 + Flick.viewportY) * value / prevScale;
- Flick.viewportY = yoff - Flick.height/2;
+ if (bigImage.height * value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.viewportY) * value / prevScale;
+ flickable.viewportY = yoff - flickable.height/2;
}
prevScale = value;
}
@@ -111,14 +111,14 @@ Flipable {
states: State {
name: "Back"
- PropertyChanges { target: ItemRotation; angle: 180 }
+ PropertyChanges { target: itemRotation; angle: 180 }
}
transitions: Transition {
SequentialAnimation {
- PropertyAction { target: BigImage; property: "smooth"; value: false }
+ PropertyAction { target: bigImage; property: "smooth"; value: false }
NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
- PropertyAction { target: BigImage; property: "smooth"; value: !Flick.moving }
+ PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving }
}
}
}
diff --git a/demos/declarative/flickr/mobile/ListDelegate.qml b/demos/declarative/flickr/mobile/ListDelegate.qml
index fa6f8ea..090e91a 100644
--- a/demos/declarative/flickr/mobile/ListDelegate.qml
+++ b/demos/declarative/flickr/mobile/ListDelegate.qml
@@ -1,20 +1,19 @@
import Qt 4.6
Component {
- id: ListDelegate
Item {
- id: Wrapper; width: Wrapper.ListView.view.width; height: 86
+ id: wrapper; width: wrapper.ListView.view.width; height: 86
Item {
- id: MoveMe
- Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: Wrapper.width; y: 1 }
+ id: moveMe
+ Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
Rectangle {
- id: WhiteRect; x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
+ x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
- Image { id: Thumb; source: imagePath; x: 1; y: 1 }
+ Image { source: imagePath; x: 1; y: 1 }
Image { source: "images/gloss.png" }
}
Column {
- x: 92; width: Wrapper.ListView.view.width - 95; y: 15; spacing: 2
+ x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: "ElideRight"; style: "Raised"; styleColor: "black" }
Text { text: photoAuthor; color: "white"; width: parent.width; elide: "ElideLeft"; color: "#cccccc"; style: "Raised"; styleColor: "black" }
Text { text: photoDate; color: "white"; width: parent.width; elide: "ElideRight"; color: "#cccccc"; style: "Raised"; styleColor: "black" }
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index 13484a2..108faf7 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -1,50 +1,50 @@
import Qt 4.6
Item {
- id: TitleBar
+ id: titleBar
property string untaggedString: "Uploads from everyone"
property string taggedString: "Recent uploads tagged "
BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
Item {
- id: Container
+ id: container
width: (parent.width * 2) - 55 ; height: parent.height
Script {
function accept() {
- TitleBar.state = ""
- Background.state = ""
- RssModel.tags = Editor.text
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
}
}
Text {
- id: CategoryText
+ id: categoryText
anchors {
- left: parent.left; right: TagButton.left; leftMargin: 10; rightMargin: 10
+ left: parent.left; right: tagButton.left; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
}
elide: "ElideLeft"
- text: (RssModel.tags=="" ? untaggedString : taggedString + RssModel.tags)
+ text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
font.bold: true; color: "White"; style: "Raised"; styleColor: "Black"
}
Button {
- id: TagButton; x: TitleBar.width - 50; width: 45; height: 32; text: "..."
- onClicked: if (TitleBar.state == "Tags") accept(); else TitleBar.state = "Tags"
+ id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
+ onClicked: if (titleBar.state == "Tags") accept(); else titleBar.state = "Tags"
anchors.verticalCenter: parent.verticalCenter
}
Item {
- id: LineEdit
+ id: lineEdit
y: 4; height: parent.height - 9
- anchors { left: TagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
+ anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
TextInput {
- id: Editor
+ id: editor
anchors {
left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
@@ -53,21 +53,21 @@ Item {
color: "#151515"; selectionColor: "Green"
}
- Keys.forwardTo: [ (ReturnKey), (Editor)]
+ Keys.forwardTo: [ (returnKey), (editor)]
Item {
- id: ReturnKey
+ id: returnKey
Keys.onReturnPressed: accept()
- Keys.onEscapePressed: TitleBar.state = ""
+ Keys.onEscapePressed: titleBar.state = ""
}
}
}
states: State {
name: "Tags"
- PropertyChanges { target: Container; x: -TagButton.x + 5 }
- PropertyChanges { target: TagButton; text: "OK" }
- PropertyChanges { target: LineEdit; focus: true }
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: tagButton; text: "OK" }
+ PropertyChanges { target: lineEdit; focus: true }
}
transitions: Transition {
diff --git a/demos/declarative/flickr/mobile/ToolBar.qml b/demos/declarative/flickr/mobile/ToolBar.qml
index cfdc8fe..f96c767 100644
--- a/demos/declarative/flickr/mobile/ToolBar.qml
+++ b/demos/declarative/flickr/mobile/ToolBar.qml
@@ -1,24 +1,24 @@
import Qt 4.6
Item {
- id: Toolbar
+ id: toolbar
- property alias button1Label: Button1.text
- property alias button2Label: Button2.text
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
signal button1Clicked
signal button2Clicked
BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
Button {
- id: Button1
+ id: button1
anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
- onClicked: Toolbar.button1Clicked()
+ onClicked: toolbar.button1Clicked()
}
Button {
- id: Button2
+ id: button2
anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
- onClicked: Toolbar.button2Clicked()
+ onClicked: toolbar.button2Clicked()
}
}
diff --git a/demos/declarative/flickr/mobile/images/lineedit.sci b/demos/declarative/flickr/mobile/images/lineedit.sci
index 7c5ec6c..054bff7 100644
--- a/demos/declarative/flickr/mobile/images/lineedit.sci
+++ b/demos/declarative/flickr/mobile/images/lineedit.sci
@@ -1,5 +1,5 @@
-gridLeft: 10
-gridTop: 10
-gridBottom: 10
-gridRight: 10
-imageFile: lineedit.png
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/demos/declarative/flickr/mobile/images/titlebar.sci b/demos/declarative/flickr/mobile/images/titlebar.sci
index 50444e1..0418d94 100644
--- a/demos/declarative/flickr/mobile/images/titlebar.sci
+++ b/demos/declarative/flickr/mobile/images/titlebar.sci
@@ -1,5 +1,5 @@
-gridLeft: 10
-gridTop: 12
-gridBottom: 12
-gridRight: 10
-imageFile: titlebar.png
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/demos/declarative/flickr/mobile/images/toolbutton.sci b/demos/declarative/flickr/mobile/images/toolbutton.sci
index a0a885f..9e4f965 100644
--- a/demos/declarative/flickr/mobile/images/toolbutton.sci
+++ b/demos/declarative/flickr/mobile/images/toolbutton.sci
@@ -1,5 +1,5 @@
-gridLeft: 15
-gridTop: 4
-gridBottom: 4
-gridRight: 15
-imageFile: toolbutton.png
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/demos/declarative/minehunt/Description.qml b/demos/declarative/minehunt/Description.qml
index df4881c..440dd2e 100644
--- a/demos/declarative/minehunt/Description.qml
+++ b/demos/declarative/minehunt/Description.qml
@@ -1,12 +1,12 @@
import Qt 4.6
Item {
- id: Page
- height: MyText.height + 20
+ id: page
+ height: myText.height + 20
property var text
MouseRegion {
anchors.fill: parent
- drag.target: Page
+ drag.target: page
drag.axis: "XandYAxis"
drag.minimumX: 0
drag.maximumX: 1000
@@ -24,8 +24,8 @@ Item {
width: parent.width - 20
height: parent.height - 20
Text {
- id: MyText
- text: Page.text
+ id: myText
+ text: page.text
width: parent.width
clip: true
wrap: true
diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml
index 2354218..301124e 100644
--- a/demos/declarative/samegame/content/Button.qml
+++ b/demos/declarative/samegame/content/Button.qml
@@ -1,7 +1,7 @@
import Qt 4.6
Rectangle {
- id: Container
+ id: container
signal clicked
property string text: "Button"
@@ -17,9 +17,9 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() }
+ MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index 401d211..661257b 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -7,15 +7,15 @@ Rectangle {
page.opacity = 0;
}
function show(txt) {
- MyText.text = txt;
+ myText.text = txt;
page.opacity = 1;
}
signal closed();
- color: "white"; border.width: 1; width: MyText.width + 20; height: 60;
+ color: "white"; border.width: 1; width: myText.width + 20; height: 60;
opacity: 0
- opacity: Behavior {
+ opacity: Behavior {
NumberAnimation { duration: 1000 }
}
- Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" }
+ Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 7deafde..15bafc4 100755
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -1,8 +1,7 @@
/* This script file handles the game logic */
//Note that X/Y referred to here are in game coordinates
-var maxX = 10;//Nums are for tileSize 40
+var maxX = 10;//Nums are for gameCanvas.tileSize 40
var maxY = 15;
-var tileSize = 40;
var maxIndex = maxX*maxY;
var board = new Array(maxIndex);
var tileSrc = "content/BoomBlock.qml";
@@ -35,8 +34,9 @@ function initBoard()
board[i].destroy();
}
- maxX = Math.floor(gameCanvas.width/tileSize);
- maxY = Math.floor(gameCanvas.height/tileSize);
+ //Calculate board size
+ maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
+ maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
maxIndex = maxY*maxX;
//Close dialogs
@@ -63,8 +63,8 @@ var floodBoard;//Set to 1 if the floodFill reaches off that node
//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
function handleClick(x,y)
{
- var xIdx = Math.floor(x/tileSize);
- var yIdx = Math.floor(y/tileSize);
+ var xIdx = Math.floor(x/gameCanvas.tileSize);
+ var yIdx = Math.floor(y/gameCanvas.tileSize);
if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
return;
if(board[index(xIdx, yIdx)] == null)
@@ -118,7 +118,7 @@ function shuffleDown()
}else{
if(fallDist > 0){
var obj = board[index(xIdx,yIdx)];
- obj.targetY += fallDist * tileSize;
+ obj.targetY += fallDist * gameCanvas.tileSize;
board[index(xIdx,yIdx+fallDist)] = obj;
board[index(xIdx,yIdx)] = null;
}
@@ -136,7 +136,7 @@ function shuffleDown()
obj = board[index(xIdx,yIdx)];
if(obj == null)
continue;
- obj.targetX -= fallDist * tileSize;
+ obj.targetX -= fallDist * gameCanvas.tileSize;
board[index(xIdx-fallDist,yIdx)] = obj;
board[index(xIdx,yIdx)] = null;
}
@@ -195,11 +195,11 @@ function createBlock(xIdx,yIdx){
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.parent = gameCanvas;
- dynamicObject.x = xIdx*tileSize;
- dynamicObject.targetX = xIdx*tileSize;
- dynamicObject.targetY = yIdx*tileSize;
- dynamicObject.width = tileSize;
- dynamicObject.height = tileSize;
+ dynamicObject.x = xIdx*gameCanvas.tileSize;
+ dynamicObject.targetX = xIdx*gameCanvas.tileSize;
+ dynamicObject.targetY = yIdx*gameCanvas.tileSize;
+ dynamicObject.width = gameCanvas.tileSize;
+ dynamicObject.height = gameCanvas.tileSize;
dynamicObject.spawned = true;
board[index(xIdx,yIdx)] = dynamicObject;
}else{//isError or isLoading
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 2d00208..ea7c14c 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -2,15 +2,13 @@ import Qt 4.6
import "content"
Rectangle {
- id: Screen
+ id: screen
width: 490; height: 720
- Script { source: "content/samegame.js" }
-
SystemPalette { id: activePalette; colorGroup: Qt.Active }
Item {
- width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top
+ width: parent.width; anchors.top: parent.top; anchors.bottom: toolBar.top
Image {
id: background
@@ -21,6 +19,9 @@ Rectangle {
Item {
id: gameCanvas
property int score: 0
+ property int tileSize: 40
+
+ Script { source: "content/samegame.js" }
z: 20; anchors.centerIn: parent
width: parent.width - (parent.width % getTileSize());
@@ -34,14 +35,14 @@ Rectangle {
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
- Dialog {
- id: scoreName; anchors.centerIn: parent; z: 22;
+ Dialog {
+ id: scoreName; anchors.centerIn: parent; z: 22;
TextInput {
- id: Editor
- onAccepted: {
- if(scoreName.opacity==1&&Editor.text!="")
- sendHighScore(Editor.text);
- scoreName.forceClose();
+ id: editor
+ onAccepted: {
+ if(scoreName.opacity==1&&editor.text!="")
+ sendHighScore(editor.text);
+ scoreName.forceClose();
}
anchors.verticalCenter: parent.verticalCenter
width: 72; focus: true
@@ -50,10 +51,10 @@ Rectangle {
}
Rectangle {
- id: ToolBar
+ id: toolBar
color: activePalette.window
height: 32; width: parent.width
- anchors.bottom: Screen.bottom
+ anchors.bottom: screen.bottom
Button {
id: btnA; text: "New Game"; onClicked: {initBoard();}
@@ -62,7 +63,7 @@ Rectangle {
}
Text {
- id: Score
+ id: score
text: "Score: " + gameCanvas.score; font.bold: true
anchors.right: parent.right; anchors.rightMargin: 3
anchors.verticalCenter: parent.verticalCenter
diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml
index 3fe7e7e..73ce308 100644
--- a/demos/declarative/twitter/content/AuthView.qml
+++ b/demos/declarative/twitter/content/AuthView.qml
@@ -1,6 +1,6 @@
import Qt 4.6
import "../../flickr/common"
-import "../../flickr/mobile"
+import "../../flickr/mobile"
Item {
id: wrapper
@@ -9,7 +9,7 @@ Item {
spacing: 20
Row{
spacing: 4
- Text {
+ Text {
width: 100
text: "Screen name:"
font.pointSize: 10; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
@@ -29,7 +29,7 @@ Item {
font.bold: true
color: "#151515"; selectionColor: "green"
Keys.forwardTo: [(tabber), (nameIn)]
- Item {
+ Item {
id: tabber
//Note: it's not working yet
Keys.onPressed: {if(event.key == Qt.Key_Tab){print('Tab works!'); passIn.focus = true; accept(); }}
@@ -39,7 +39,7 @@ Item {
}
Row{
spacing: 4
- Text {
+ Text {
width: 100
text: "Password:"
font.pointSize: 10; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
@@ -71,7 +71,7 @@ Item {
height: 32
id: login
text: "Log in"
- onClicked: {RssModel.authName=nameIn.text; RssModel.authPass=passIn.text; RssModel.tags='my timeline';}
+ onClicked: {rssModel.authName=nameIn.text; rssModel.authPass=passIn.text; rssModel.tags='my timeline';}
}
Button {
x: 120
@@ -79,7 +79,7 @@ Item {
height: 32
id: guest
text: "Guest"
- onClicked: {RssModel.authName='-'; Screen.setMode(true);}
+ onClicked: {rssModel.authName='-'; screen.setMode(true);}
}
}
}
diff --git a/demos/declarative/twitter/content/FatDelegate.qml b/demos/declarative/twitter/content/FatDelegate.qml
index a2e9c39..32a921e 100644
--- a/demos/declarative/twitter/content/FatDelegate.qml
+++ b/demos/declarative/twitter/content/FatDelegate.qml
@@ -4,12 +4,12 @@ import "../../flickr/common"
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 > 58){txt.height+8}else{58}//50+4+4
Script {
function handleLink(link){
if(link.slice(0,3) == 'app'){
setUser(link.slice(7));
- Screen.setMode(true);
+ screen.setMode(true);
}else if(link.slice(0,4) == 'http'){
Qt.DesktopServices.openUrl(link);
}
@@ -21,17 +21,17 @@ Component {
}
}
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
+ 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
+ id: whiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true
anchors.verticalCenter: parent.verticalCenter
- Loading { x: 1; y: 1; width: 48; height: 48; visible: RealImage.status != 1 }
- Image { id: RealImage; source: userImage; x: 1; y: 1; width:48; height:48 }
+ Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != 1 }
+ Image { id: realImage; source: userImage; x: 1; y: 1; width:48; height:48 }
}
Text { id:txt; y:4; x: 56
text: '<html><style type="text/css">a:link {color:"#aaccaa"}; a:visited {color:"#336633"}</style>'
@@ -39,7 +39,7 @@ Component {
+ "<br /><b>" + addTags(statusText) + "</b></html>";
textFormat: Qt.RichText
color: "white"; color: "#cccccc"; style: "Raised"; styleColor: "black"; wrap: true
- anchors.left: WhiteRect.right; anchors.right: BlackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
onLinkActivated: handleLink(link)
}
}
diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml
index bd3bc2c..3108a9b 100644
--- a/demos/declarative/twitter/content/HomeTitleBar.qml
+++ b/demos/declarative/twitter/content/HomeTitleBar.qml
@@ -10,80 +10,80 @@ Item {
BorderImage { source: "../../flickr/mobile/images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
Item {
- id: Container
+ id: container
width: (parent.width * 2) - 55 ; height: parent.height
Script {
function accept() {
- if(RssModel.authName == '' || RssModel.authPass == '')
+ if(rssModel.authName == '' || rssModel.authPass == '')
return false;//Can't login like that
- var postData = "status=" + Editor.text;
+ 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() {
+ 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.send(postData);
- Editor.text = ""
+ editor.text = ""
titleBar.state = ""
}
}
Rectangle {
- id: WhiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true
+ x: 6; width: 50; height: 50; color: "white"; smooth: true
anchors.verticalCenter: parent.verticalCenter
- UserModel { user: RssModel.authName; id: userModel }
- Component { id: imgDelegate;
- Item { id: Wrapper
- Loading { width:48; height:48; visible: realImage.status != 1 }
- Image { source: image; width:48; height:48; id: realImage }
+ UserModel { user: rssModel.authName; id: userModel }
+ Component { id: imgDelegate;
+ Item {
+ Loading { width:48; height:48; visible: realImage.status != 1 }
+ 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
+ id: categoryText
+ anchors.left: parent.left; anchors.right: tagButton.left
anchors.leftMargin: 58; anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
elide: "ElideLeft"
- text: "Timeline for " + RssModel.authName
+ text: "Timeline for " + rssModel.authName
font.pointSize: 10; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
}
Button {
- id: TagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..."
+ id: tagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..."
anchors.verticalCenter: parent.verticalCenter;
onClicked: if (titleBar.state == "Posting") 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"
+ 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: "Raised"; styleColor: "black"
}
Item {
id: txtEdit;
- anchors.left: TagButton.right; anchors.leftMargin: 5; y: 4
+ anchors.left: tagButton.right; anchors.leftMargin: 5; y: 4
anchors.right: parent.right; anchors.rightMargin: 40; height: parent.height - 9
BorderImage { source: "../../flickr/mobile/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
+ when: editor.text.length > 140
+ target: editor
property: "text"
- value: Editor.text.slice(0,140)
+ value: editor.text.slice(0,140)
}
TextEdit {
- id: Editor
- anchors.left: parent.left;
+ id: editor
+ anchors.left: parent.left;
anchors.leftMargin: 8;
anchors.bottom: parent.bottom
anchors.bottomMargin: 4;
@@ -94,9 +94,9 @@ Item {
wrap:true
color: "#151515"; selectionColor: "green"
}
- Keys.forwardTo: [(ReturnKey), (Editor)]
+ Keys.forwardTo: [(returnKey), (editor)]
Item {
- id: ReturnKey
+ id: returnKey
Keys.onReturnPressed: accept()
Keys.onEscapePressed: titleBar.state = ""
}
@@ -105,11 +105,11 @@ Item {
states: [
State {
name: "Posting"
- PropertyChanges { target: Container; x: -TagButton.x + 5 }
+ 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: tagButton; text: "OK" }
+ PropertyChanges { target: tagButton; width: 28 }
+ PropertyChanges { target: tagButton; height: 24 }
PropertyChanges { target: txtEdit; focus: true }
}
]
diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml
index 6a6a28f..da0794d 100644
--- a/demos/declarative/twitter/content/MultiTitleBar.qml
+++ b/demos/declarative/twitter/content/MultiTitleBar.qml
@@ -2,20 +2,20 @@ import Qt 4.6
import "../../flickr/mobile"
Item {
- height: HomeBar.height
- HomeTitleBar { id: HomeBar; width: parent.width; height: 60;
- onUpdate: RssModel.reload()
+ height: homeBar.height
+ HomeTitleBar { id: homeBar; width: parent.width; height: 60;
+ onUpdate: rssModel.reload()
}
- TitleBar { id: TitleBar; width: parent.width; height: 60;
+ TitleBar { id: titleBar; width: parent.width; height: 60;
y: -80
untaggedString: "Latest tweets from everyone"
taggedString: "Latest tweets from "
}
states: [
State {
- name: "search"; when: Screen.userView
- PropertyChanges { target: TitleBar; y: 0 }
- PropertyChanges { target: HomeBar; y: -80 }
+ name: "search"; when: screen.userView
+ PropertyChanges { target: titleBar; y: 0 }
+ PropertyChanges { target: homeBar; y: -80 }
}
]
transitions: [
diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml
index eb9f5d6..e9752ff 100644
--- a/demos/declarative/twitter/twitter.qml
+++ b/demos/declarative/twitter/twitter.qml
@@ -4,43 +4,44 @@ import "../flickr/common" as Common
import "../flickr/mobile" as Mobile
Item {
- id: Screen; width: 320; height: 480
- property bool userView : false
+ id: screen; width: 320; height: 480
+ property bool userView : false
+ property var tmpStr
function setMode(m){
- Screen.userView = m;
- if(m == false){
- RssModel.tags='my timeline';
- RssModel.reload();
- ToolBar.button2Label = "View others";
+ screen.userView = m;
+ if(m == false){
+ rssModel.tags='my timeline';
+ rssModel.reload();
+ toolBar.button2Label = "View others";
} else {
- ToolBar.button2Label = "Return home";
+ toolBar.button2Label = "Return home";
}
}
//Workaround for bug 260266
Timer{ interval: 1; running: false; repeat: false; onTriggered: reallySetUser(); id:hack }
- Script{
- var tmpStr;
+ Script {
+// var tmpStr;
function setUser(str){hack.running = true; tmpStr = str}
- function reallySetUser(){RssModel.tags = tmpStr;}
+ function reallySetUser(){rssModel.tags = tmpStr;}
}
Rectangle {
- id: Background
+ id: background
anchors.fill: parent; color: "#343434";
Image { source: "mobile/images/stripes.png"; fillMode: "Tile"; anchors.fill: parent; opacity: 0.3 }
- Twitter.RssModel { id: RssModel }
- Common.Loading { anchors.centerIn: parent; visible: RssModel.status==XmlListModel.Loading && state!='unauthed'}
- Text {
+ Twitter.RssModel { id: rssModel }
+ Common.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
+ Text {
width: 180
- text: "Could not access twitter using this screen name and password pair.";
+ text: "Could not access twitter using this screen name and password pair.";
color: "white"; color: "#cccccc"; style: "Raised"; styleColor: "black"; wrap: true
- visible: RssModel.status==XmlListModel.Error; anchors.centerIn: parent
+ visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
}
Item {
- id: Views
+ id: views
x: 2; width: parent.width - 4
y:60 //Below the title bars
height: 380
@@ -48,44 +49,44 @@ Item {
Twitter.AuthView{
id: authView
anchors.verticalCenter: parent.verticalCenter
- width: parent.width; height: parent.height-60;
- x: -(Screen.width * 1.5)
+ width: parent.width; height: parent.height-60;
+ x: -(screen.width * 1.5)
}
- Twitter.FatDelegate { id: FatDelegate }
+ Twitter.FatDelegate { id: fatDelegate }
ListView {
- id: MainView; model: RssModel.model; delegate: FatDelegate;
+ id: mainView; model: rssModel.model; delegate: fatDelegate;
width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
}
}
- Twitter.MultiTitleBar { id: TitleBar; width: parent.width }
- Mobile.ToolBar { id: ToolBar; height: 40;
- //anchors.bottom: parent.bottom;
+ Twitter.MultiTitleBar { id: titleBar; width: parent.width }
+ Mobile.ToolBar { id: toolBar; height: 40;
+ //anchors.bottom: parent.bottom;
//TODO: Use anchor changes instead of hard coding
y: 440
- width: parent.width; opacity: 0.9
+ width: parent.width; opacity: 0.9
button1Label: "Update"
button2Label: "View others"
- onButton1Clicked: RssModel.reload();
- onButton2Clicked:
+ onButton1Clicked: rssModel.reload();
+ onButton2Clicked:
{
- if(Screen.userView == true){
- Screen.setMode(false);
+ if(screen.userView == true){
+ screen.setMode(false);
}else{
- RssModel.tags='';
- Screen.setMode(true);
+ rssModel.tags='';
+ screen.setMode(true);
}
}
}
states: [
State {
- name: "unauthed"; when: RssModel.authName==""
+ 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 + 80 }
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height + 80 }
}
]
transitions: [
diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml
index 5b278ac..6bba98e 100644
--- a/demos/declarative/webbrowser/content/RectSoftShadow.qml
+++ b/demos/declarative/webbrowser/content/RectSoftShadow.qml
@@ -26,7 +26,7 @@ Item {
source: "pics/softshadow-bottom.png"
x: 0
y: parent.height
- width: WebView.width*WebView.scale
+ width: webView.width*webView.scale
height: 16
}
}
diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci
index 464dbf5..96c5efb 100644
--- a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci
+++ b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci
@@ -1,6 +1,6 @@
-gridLeft: 7
-gridTop: 7
-gridBottom: 7
-gridRight: 7
-imageFile: addressbar-filled.png
+border.left: 7
+border.top: 7
+border.bottom: 7
+border.right: 7
+source: addressbar-filled.png
diff --git a/demos/declarative/webbrowser/content/pics/addressbar.sci b/demos/declarative/webbrowser/content/pics/addressbar.sci
index 23a2a19..8f1cd18 100644
--- a/demos/declarative/webbrowser/content/pics/addressbar.sci
+++ b/demos/declarative/webbrowser/content/pics/addressbar.sci
@@ -1,6 +1,6 @@
-gridLeft: 7
-gridTop: 7
-gridBottom: 7
-gridRight: 7
-imageFile: addressbar.png
+border.left: 7
+border.top: 7
+border.bottom: 7
+border.right: 7
+source: addressbar.png
diff --git a/demos/declarative/webbrowser/content/pics/footer.sci b/demos/declarative/webbrowser/content/pics/footer.sci
index be1d086..7be58f1 100644
--- a/demos/declarative/webbrowser/content/pics/footer.sci
+++ b/demos/declarative/webbrowser/content/pics/footer.sci
@@ -1,6 +1,6 @@
-gridLeft: 5
-gridTop: 0
-gridBottom: 0
-gridRight: 5
-imageFile: footer.png
+border.left: 5
+border.top: 0
+border.bottom: 0
+border.right: 5
+source: footer.png
diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.sci b/demos/declarative/webbrowser/content/pics/softshadow-left.sci
index 82e38f8..45c88d5 100644
--- a/demos/declarative/webbrowser/content/pics/softshadow-left.sci
+++ b/demos/declarative/webbrowser/content/pics/softshadow-left.sci
@@ -1,5 +1,5 @@
-gridLeft: 0
-gridTop: 16
-gridBottom: 16
-gridRight: 0
-imageFile: softshadow-left.png
+border.left: 0
+border.top: 16
+border.bottom: 16
+border.right: 0
+source: softshadow-left.png
diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.sci b/demos/declarative/webbrowser/content/pics/softshadow-right.sci
index e9494ed..4d459c0 100644
--- a/demos/declarative/webbrowser/content/pics/softshadow-right.sci
+++ b/demos/declarative/webbrowser/content/pics/softshadow-right.sci
@@ -1,5 +1,5 @@
-gridLeft: 0
-gridTop: 16
-gridBottom: 16
-gridRight: 0
-imageFile: softshadow-right.png
+border.left: 0
+border.top: 16
+border.bottom: 16
+border.right: 0
+source: softshadow-right.png
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 3f23d83..53ac214 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -4,7 +4,7 @@ import "content"
import "fieldtext"
Item {
- id: WebBrowser
+ id: webBrowser
property string urlString : "http://qt.nokia.com/"
@@ -14,7 +14,7 @@ Item {
height: 480
Item {
- id: WebPanel
+ id: webPanel
anchors.fill: parent
clip: true
Rectangle {
@@ -23,48 +23,48 @@ Item {
}
Image {
source: "content/pics/softshadow-bottom.png"
- width: WebPanel.width
+ width: webPanel.width
height: 16
}
Image {
source: "content/pics/softshadow-top.png"
- width: WebPanel.width
+ width: webPanel.width
height: 16
- anchors.bottom: Footer.top
+ anchors.bottom: footer.top
}
RectSoftShadow {
- x: -Flick.viewportX
- y: -Flick.viewportY
- width: MyWebView.width*MyWebView.scale
- height: Flick.y+MyWebView.height*MyWebView.scale
+ x: -flickable.viewportX
+ y: -flickable.viewportY
+ width: webView.width*webView.scale
+ height: flickable.y+webView.height*webView.scale
}
Item {
- id: HeaderSpace
+ id: headerSpace
width: parent.width
height: 60
z: 1
Rectangle {
- id: HeaderSpaceTint
+ id: headerSpaceTint
color: "black"
opacity: 0
anchors.fill: parent
}
Image {
- id: Header
+ id: header
source: "content/pics/header.png"
width: parent.width
height: 60
state: "Normal"
- x: Flick.viewportX < 0 ? -Flick.viewportX : Flick.viewportX > Flick.viewportWidth-Flick.width
- ? -Flick.viewportX+Flick.viewportWidth-Flick.width : 0
- y: Flick.viewportY < 0 ? -Flick.viewportY : progressOff*
- (Flick.viewportY>height?-height:-Flick.viewportY)
+ x: flickable.viewportX < 0 ? -flickable.viewportX : flickable.viewportX > flickable.viewportWidth-flickable.width
+ ? -flickable.viewportX+flickable.viewportWidth-flickable.width : 0
+ y: flickable.viewportY < 0 ? -flickable.viewportY : progressOff*
+ (flickable.viewportY>height?-height:-flickable.viewportY)
Text {
- id: HeaderText
+ id: headerText
- text: MyWebView.title!='' || MyWebView.progress == 1.0 ? MyWebView.title : 'Loading...'
+ text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...'
elide: "ElideRight"
color: "white"
@@ -75,22 +75,22 @@ Item {
font.pointSize: 10
font.bold: true
- anchors.left: Header.left
- anchors.right: Header.right
+ anchors.left: header.left
+ anchors.right: header.right
anchors.leftMargin: 4
anchors.rightMargin: 4
- anchors.top: Header.top
+ anchors.top: header.top
anchors.topMargin: 4
horizontalAlignment: "AlignHCenter"
}
Item {
width: parent.width
- anchors.top: HeaderText.bottom
+ anchors.top: headerText.bottom
anchors.topMargin: 2
anchors.bottom: parent.bottom
Item {
- id: UrlBox
+ id: urlBox
height: 31
anchors.left: parent.left
anchors.leftMargin: 12
@@ -102,32 +102,32 @@ Item {
BorderImage {
source: "content/pics/addressbar.sci"
- anchors.fill: UrlBox
+ anchors.fill: urlBox
}
-
+
BorderImage {
- id: UrlBoxhl
+ id: urlBoxhl
source: "content/pics/addressbar-filled.sci"
- width: parent.width*MyWebView.progress
+ width: parent.width*webView.progress
height: parent.height
- opacity: 1-Header.progressOff
+ opacity: 1-header.progressOff
clip: true
}
FieldText {
- id: EditUrl
+ id: editUrl
mouseGrabbed: parent.mouseGrabbed
- text: WebBrowser.urlString
+ text: webBrowser.urlString
label: "url:"
- onConfirmed: { WebBrowser.urlString = EditUrl.text; MyWebView.focus=true }
- onCancelled: { MyWebView.focus=true }
- onStartEdit: { MyWebView.focus=false }
+ onConfirmed: { webBrowser.urlString = editUrl.text; webView.focus=true }
+ onCancelled: { webView.focus=true }
+ onStartEdit: { webView.focus=false }
- anchors.left: UrlBox.left
- anchors.right: UrlBox.right
+ anchors.left: urlBox.left
+ anchors.right: urlBox.right
anchors.leftMargin: 6
- anchors.verticalCenter: UrlBox.verticalCenter
+ anchors.verticalCenter: urlBox.verticalCenter
anchors.verticalCenterOffset: 1
}
}
@@ -137,19 +137,19 @@ Item {
states: [
State {
name: "Normal"
- when: MyWebView.progress == 1.0
- PropertyChanges { target: Header; progressOff: 1 }
+ when: webView.progress == 1.0
+ PropertyChanges { target: header; progressOff: 1 }
},
State {
name: "ProgressShown"
- when: MyWebView.progress < 1.0
- PropertyChanges { target: Header; progressOff: 0; }
+ when: webView.progress < 1.0
+ PropertyChanges { target: header; progressOff: 0; }
}
]
transitions: [
Transition {
NumberAnimation {
- target: Header
+ target: header
properties: "progressOff"
easing: "easeInOutQuad"
duration: 300
@@ -159,18 +159,18 @@ Item {
}
}
Flickable {
- id: Flick
+ id: flickable
width: parent.width
- viewportWidth: Math.max(parent.width,MyWebView.width*MyWebView.scale)
- viewportHeight: Math.max(parent.height,MyWebView.height*MyWebView.scale)
- anchors.top: HeaderSpace.bottom
- anchors.bottom: Footer.top
+ viewportWidth: Math.max(parent.width,webView.width*webView.scale)
+ viewportHeight: Math.max(parent.height,webView.height*webView.scale)
+ anchors.top: headerSpace.bottom
+ anchors.bottom: footer.top
anchors.left: parent.left
anchors.right: parent.right
pressDelay: 200
WebView {
- id: MyWebView
+ id: webView
pixelCacheSize: 4000000
Script {
@@ -190,29 +190,29 @@ Item {
}
}
- url: fixUrl(WebBrowser.urlString)
+ url: fixUrl(webBrowser.urlString)
smooth: true
fillColor: "white"
focus: true
- preferredWidth: Flick.width
+ preferredWidth: flickable.width
webPageWidth: 980
- onUrlChanged: { if (url != null) { WebBrowser.urlString = url.toString(); } }
+ onUrlChanged: { if (url != null) { webBrowser.urlString = url.toString(); } }
onDoubleClick: { heuristicZoom(clickX,clickY) }
SequentialAnimation {
- id: QuickZoom
+ id: quickZoom
PropertyAction {
- target: MyWebView
+ target: webView
property: "renderingEnabled"
value: false
}
ParallelAnimation {
NumberAnimation {
- id: ScaleAnim
- target: MyWebView
+ id: scaleAnim
+ target: webView
property: "scale"
from: 1
to: 0 // set before calling
@@ -220,8 +220,8 @@ Item {
duration: 200
}
NumberAnimation {
- id: FlickVX
- target: Flick
+ id: flickVX
+ target: flickable
property: "viewportX"
easing: "easeLinear"
duration: 200
@@ -229,8 +229,8 @@ Item {
to: 0 // set before calling
}
NumberAnimation {
- id: FlickVY
- target: Flick
+ id: flickVY
+ target: flickable
property: "viewportY"
easing: "easeLinear"
duration: 200
@@ -239,12 +239,12 @@ Item {
}
}
PropertyAction {
- id: FinalZoom
- target: MyWebView
+ id: finalZoom
+ target: webView
property: "zoomFactor"
}
PropertyAction {
- target: MyWebView
+ target: webView
property: "scale"
value: 1.0
}
@@ -252,19 +252,19 @@ Item {
// size changes may have started a correction if
// zoomFactor < 1.0.
PropertyAction {
- id: FinalX
- target: Flick
+ id: finalX
+ target: flickable
property: "viewportX"
value: 0 // set before calling
}
PropertyAction {
- id: FinalY
- target: Flick
+ id: finalY
+ target: flickable
property: "viewportY"
value: 0 // set before calling
}
PropertyAction {
- target: MyWebView
+ target: webView
property: "renderingEnabled"
value: true
}
@@ -272,23 +272,23 @@ Item {
onZooming: {
if (centerX) {
sc = zoom/zoomFactor;
- ScaleAnim.to = sc;
- FlickVX.from = Flick.viewportX
- FlickVX.to = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width)
- FinalX.value = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width)
- FlickVY.from = Flick.viewportY
- FlickVY.to = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height)
- FinalY.value = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height)
- FinalZoom.value = zoom
- QuickZoom.start()
+ scaleAnim.to = sc;
+ flickVX.from = flickable.viewportX
+ flickVX.to = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
+ finalX.value = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
+ flickVY.from = flickable.viewportY
+ flickVY.to = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
+ finalY.value = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
+ finalZoom.value = zoom
+ quickZoom.start()
}
}
}
Rectangle {
- id: WebViewTint
+ id: webViewTint
color: "black"
opacity: 0
- anchors.fill: MyWebView
+ anchors.fill: webView
/*MouseRegion {
anchors.fill: WebViewTint
onClicked: { proxy.focus=false }
@@ -296,7 +296,7 @@ Item {
}
}
BorderImage {
- id: Footer
+ id: footer
source: "content/pics/footer.sci"
width: parent.width
height: 43
@@ -327,13 +327,13 @@ Item {
states: [
State {
name: "Enabled"
- when: MyWebView.back.enabled==true
+ when: webView.back.enabled==true
PropertyChanges { target: back_e; opacity: 1 }
PropertyChanges { target: back_d; opacity: 0 }
},
State {
name: "Disabled"
- when: MyWebView.back.enabled==false
+ when: webView.back.enabled==false
PropertyChanges { target: back_e; opacity: 0 }
PropertyChanges { target: back_d; opacity: 1 }
}
@@ -349,7 +349,7 @@ Item {
]
MouseRegion {
anchors.fill: back_e
- onClicked: { if (MyWebView.back.enabled) MyWebView.back.trigger() }
+ onClicked: { if (webView.back.enabled) webView.back.trigger() }
}
}
Image {
@@ -360,7 +360,7 @@ Item {
}
MouseRegion {
anchors.fill: reload
- onClicked: { MyWebView.reload.trigger() }
+ onClicked: { webView.reload.trigger() }
}
Item {
id: forwardbutton
@@ -383,13 +383,13 @@ Item {
states: [
State {
name: "Enabled"
- when: MyWebView.forward.enabled==true
+ when: webView.forward.enabled==true
PropertyChanges { target: forward_e; opacity: 1 }
PropertyChanges { target: forward_d; opacity: 0 }
},
State {
name: "Disabled"
- when: MyWebView.forward.enabled==false
+ when: webView.forward.enabled==false
PropertyChanges { target: forward_e; opacity: 0 }
PropertyChanges { target: forward_d; opacity: 1 }
}
@@ -405,7 +405,7 @@ Item {
]
MouseRegion {
anchors.fill: parent
- onClicked: { if (MyWebView.forward.enabled) MyWebView.forward.trigger() }
+ onClicked: { if (webView.forward.enabled) webView.forward.trigger() }
}
}
}
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro
index d677e9d..f2abde6 100644
--- a/demos/embedded/fluidlauncher/fluidlauncher.pro
+++ b/demos/embedded/fluidlauncher/fluidlauncher.pro
@@ -59,7 +59,7 @@ symbian {
load(data_caging_paths)
TARGET.UID3 = 0xA000A641
- ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg
+ ICON = ../../../src/s60installs/qt.svg
executables.sources = \
styledemo.exe \
@@ -126,21 +126,7 @@ symbian {
mifs.sources = \
$${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A641.mif \ #fluidlauncher
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63F.mif \ #styledemo
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63D.mif \ #deform
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63E.mif \ #pathstroke
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C607.mif \ #wiggly
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A648.mif \ #ftp
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C60A.mif \ #saxbookmarks
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif \ #desktopservices
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C610.mif \ #fridgemagnets
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C612.mif \ #drilldown
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF6B.mif \ #softkeys
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF76.mif \ #raycasting
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF73.mif \ #flickable
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF72.mif \ #digiflip
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF75.mif \ #lightmaps
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF74.mif #flightinfo
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif #desktopservices
mifs.path = $$APP_RESOURCE_DIR
contains(QT_CONFIG, svg) {
@@ -155,33 +141,22 @@ symbian {
resource.sources += \
$${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \
$${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/weatherinfo.rsc
-
- mifs.sources += \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A640.mif \ #embeddedsvgviewer
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF77.mif #weatherinfo
-
}
contains(QT_CONFIG, webkit) {
executables.sources += anomaly.exe
reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc
resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc
- mifs.sources += \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF71.mif #anomaly
}
contains(QT_CONFIG, phonon) {
executables.sources += qmediaplayer.exe
resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.rsc
- mifs.sources += \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C613.mif #qmediaplayer
}
contains(QT_CONFIG, script) {
executables.sources += context2d.exe
reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc
resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.rsc
- mifs.sources += \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C608.mif #context2d
}
files.sources = $$PWD/screenshots $$PWD/slides
diff --git a/demos/sub-attaq/animationmanager.cpp b/demos/sub-attaq/animationmanager.cpp
index 916dd21..eb5a125 100644
--- a/demos/sub-attaq/animationmanager.cpp
+++ b/demos/sub-attaq/animationmanager.cpp
@@ -77,16 +77,14 @@ void AnimationManager::unregisterAllAnimations()
void AnimationManager::pauseAll()
{
- foreach (QAbstractAnimation* animation, animations)
- {
+ foreach (QAbstractAnimation* animation, animations) {
if (animation->state() == QAbstractAnimation::Running)
animation->pause();
}
}
void AnimationManager::resumeAll()
{
- foreach (QAbstractAnimation* animation, animations)
- {
+ foreach (QAbstractAnimation* animation, animations) {
if (animation->state() == QAbstractAnimation::Paused)
animation->resume();
}
diff --git a/demos/sub-attaq/boat.cpp b/demos/sub-attaq/boat.cpp
index 864a099..3b1bac7 100644
--- a/demos/sub-attaq/boat.cpp
+++ b/demos/sub-attaq/boat.cpp
@@ -46,7 +46,6 @@
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
-#include "custompropertyanimation.h"
#include "qanimationstate.h"
//Qt
@@ -60,79 +59,35 @@
static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat);
-#if QT_VERSION >=0x040500
- PixmapItem *step1 = new PixmapItem(QString("explosion/boat/step1"),GraphicsScene::Big, boat);
- step1->setZValue(6);
- PixmapItem *step2 = new PixmapItem(QString("explosion/boat/step2"),GraphicsScene::Big, boat);
- step2->setZValue(6);
- PixmapItem *step3 = new PixmapItem(QString("explosion/boat/step3"),GraphicsScene::Big, boat);
- step3->setZValue(6);
- PixmapItem *step4 = new PixmapItem(QString("explosion/boat/step4"),GraphicsScene::Big, boat);
- step4->setZValue(6);
- step1->setOpacity(0);
- step2->setOpacity(0);
- step3->setOpacity(0);
- step4->setOpacity(0);
- CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(boat);
- anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim1->setDuration(100);
- anim1->setEndValue(1);
- CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(boat);
- anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim2->setDuration(100);
- anim2->setEndValue(1);
- CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(boat);
- anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim3->setDuration(100);
- anim3->setEndValue(1);
- CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(boat);
- anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim4->setDuration(100);
- anim4->setEndValue(1);
- CustomPropertyAnimation *anim5 = new CustomPropertyAnimation(boat);
- anim5->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim5->setDuration(100);
- anim5->setEndValue(0);
- CustomPropertyAnimation *anim6 = new CustomPropertyAnimation(boat);
- anim6->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim6->setDuration(100);
- anim6->setEndValue(0);
- CustomPropertyAnimation *anim7 = new CustomPropertyAnimation(boat);
- anim7->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim7->setDuration(100);
- anim7->setEndValue(0);
- CustomPropertyAnimation *anim8 = new CustomPropertyAnimation(boat);
- anim8->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim8->setDuration(100);
- anim8->setEndValue(0);
- group->addAnimation(anim1);
- group->addAnimation(anim2);
- group->addAnimation(anim3);
- group->addAnimation(anim4);
- group->addAnimation(anim5);
- group->addAnimation(anim6);
- group->addAnimation(anim7);
- group->addAnimation(anim8);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
- group->addAnimation(anim);
-#endif
+ for (int i = 1; i <= 4; i++) {
+ PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat);
+ step->setZValue(6);
+ step->setOpacity(0);
+
+ //fade-in
+ QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity");
+ anim->setEndValue(1);
+ anim->setDuration(100);
+ group->insertAnimationAt(i-1, anim);
+
+ //and then fade-out
+ QPropertyAnimation *anim2 = new QPropertyAnimation(step, "opacity");
+ anim2->setEndValue(0);
+ anim2->setDuration(100);
+ group->addAnimation(anim2);
+ }
+
AnimationManager::self()->registerAnimation(group);
return group;
}
-Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0)
+Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big),
+ speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0)
{
- pixmapItem = new PixmapItem(QString("boat"),GraphicsScene::Big, this);
setZValue(4);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable);
- resize(pixmapItem->boundingRect().size());
+ setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable);
//The movement animation used to animate the boat
movementAnimation = new QPropertyAnimation(this, "pos");
@@ -223,13 +178,13 @@ Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags)
destroyedState->setAnimation(destroyAnimation);
//Play a nice animation when the boat is destroyed
- moving->addTransition(this, SIGNAL(boatDestroyed()),destroyedState);
+ moving->addTransition(this, SIGNAL(boatDestroyed()), destroyedState);
//Transition to final state when the destroyed animation is finished
destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the boat is dead
- connect(machine,SIGNAL(finished()),this, SIGNAL(boatExecutionFinished()));
+ connect(machine,SIGNAL(finished()), this, SIGNAL(boatExecutionFinished()));
}
@@ -255,7 +210,6 @@ void Boat::updateBoatMovement()
}
movementAnimation->stop();
- movementAnimation->setStartValue(pos());
if (direction == Boat::Left) {
movementAnimation->setEndValue(QPointF(0,y()));
diff --git a/demos/sub-attaq/boat.h b/demos/sub-attaq/boat.h
index 0fe8ce4..0b4de1e 100644
--- a/demos/sub-attaq/boat.h
+++ b/demos/sub-attaq/boat.h
@@ -42,13 +42,8 @@
#ifndef __BOAT__H__
#define __BOAT__H__
-//Qt
-#include <QtCore/QObject>
-#include <QtGui/QKeyEvent>
+#include "pixmapitem.h"
-#include <QtGui/QGraphicsWidget>
-
-class PixmapItem;
class Bomb;
QT_BEGIN_NAMESPACE
class QVariantAnimation;
@@ -56,7 +51,7 @@ class QAbstractAnimation;
class QStateMachine;
QT_END_NAMESPACE
-class Boat : public QGraphicsWidget
+class Boat : public PixmapItem
{
Q_OBJECT
public:
@@ -66,7 +61,7 @@ public:
Right
};
enum { Type = UserType + 2 };
- Boat(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ Boat();
void destroy();
void run();
void stop();
@@ -95,7 +90,6 @@ private:
QVariantAnimation *movementAnimation;
QAbstractAnimation *destroyAnimation;
QStateMachine *machine;
- PixmapItem *pixmapItem;
};
#endif //__BOAT__H__
diff --git a/demos/sub-attaq/boat_p.h b/demos/sub-attaq/boat_p.h
index 692702b..6eb52b6 100644
--- a/demos/sub-attaq/boat_p.h
+++ b/demos/sub-attaq/boat_p.h
@@ -67,22 +67,16 @@ static const int MAX_BOMB = 5;
class KeyStopTransition : public QKeyEventTransition
{
public:
- KeyStopTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ KeyStopTransition(Boat *b, QEvent::Type t, int k)
+ : QKeyEventTransition(b, t, k), boat(b), key(k)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (boat->currentSpeed() == 1)
- return true;
- else
- return false;
+ return (boat->currentSpeed() == 1);
}
private:
Boat * boat;
@@ -93,23 +87,16 @@ private:
class KeyMoveTransition : public QKeyEventTransition
{
public:
- KeyMoveTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ KeyMoveTransition(Boat *b, QEvent::Type t, int k)
+ : QKeyEventTransition(b, t, k), boat(b), key(k)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (boat->currentSpeed() >= 0)
- return true;
- else
- return false;
-
+ return (boat->currentSpeed() >= 0);
}
void onTransition(QEvent *)
{
@@ -132,22 +119,16 @@ private:
{
public:
KeyLaunchTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ : QKeyEventTransition(boat, type, key), boat(boat), key(key)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
//We have enough bomb?
- if (boat->bombsLaunched() < MAX_BOMB)
- return true;
- else
- return false;
+ return (boat->bombsLaunched() < MAX_BOMB);
}
private:
Boat * boat;
@@ -158,9 +139,8 @@ private:
class MoveStateRight : public QState
{
public:
- MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent)
+ MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -176,9 +156,8 @@ private:
class MoveStateLeft : public QState
{
public:
- MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent)
+ MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -194,9 +173,8 @@ private:
class StopState : public QState
{
public:
- StopState(Boat *boat,QState *parent = 0) : QState(parent)
+ StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -213,9 +191,8 @@ private:
class LaunchStateRight : public QState
{
public:
- LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent)
+ LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -235,9 +212,8 @@ private:
class LaunchStateLeft : public QState
{
public:
- LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent)
+ LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
diff --git a/demos/sub-attaq/bomb.cpp b/demos/sub-attaq/bomb.cpp
index d17024f..acc3475 100644
--- a/demos/sub-attaq/bomb.cpp
+++ b/demos/sub-attaq/bomb.cpp
@@ -52,19 +52,14 @@
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
-Bomb::Bomb(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), launchAnimation(0)
+Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big)
{
- pixmapItem = new PixmapItem(QString("bomb"),GraphicsScene::Big, this);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable);
setZValue(2);
- resize(pixmapItem->boundingRect().size());
}
void Bomb::launch(Bomb::Direction direction)
{
- launchAnimation = new QSequentialAnimationGroup();
+ QSequentialAnimationGroup *launchAnimation = new QSequentialAnimationGroup;
AnimationManager::self()->registerAnimation(launchAnimation);
qreal delta = direction == Right ? 20 : - 20;
QPropertyAnimation *anim = new QPropertyAnimation(this, "pos");
@@ -80,7 +75,7 @@ void Bomb::launch(Bomb::Direction direction)
anim->setDuration(y()/2*60);
launchAnimation->addAnimation(anim);
connect(anim,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &)));
-
+ connect(this, SIGNAL(bombExploded()), launchAnimation, SLOT(stop()));
//We setup the state machine of the bomb
QStateMachine *machine = new QStateMachine(this);
@@ -94,7 +89,7 @@ void Bomb::launch(Bomb::Direction direction)
machine->setInitialState(launched);
//### Add a nice animation when the bomb is destroyed
- launched->addTransition(this, SIGNAL(bombExplosed()),final);
+ launched->addTransition(this, SIGNAL(bombExploded()),final);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, SIGNAL(animationFinished()), final);
@@ -119,6 +114,5 @@ void Bomb::onAnimationLaunchValueChanged(const QVariant &)
void Bomb::destroy()
{
- launchAnimation->stop();
- emit bombExplosed();
+ emit bombExploded();
}
diff --git a/demos/sub-attaq/bomb.h b/demos/sub-attaq/bomb.h
index f5b221c..ec059b5 100644
--- a/demos/sub-attaq/bomb.h
+++ b/demos/sub-attaq/bomb.h
@@ -42,13 +42,9 @@
#ifndef __BOMB__H__
#define __BOMB__H__
-//Qt
-#include <QtGui/QGraphicsWidget>
-#include <QtCore/QAnimationGroup>
+#include "pixmapitem.h"
-class PixmapItem;
-
-class Bomb : public QGraphicsWidget
+class Bomb : public PixmapItem
{
Q_OBJECT
public:
@@ -56,20 +52,16 @@ public:
Left = 0,
Right
};
- Bomb(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ Bomb();
void launch(Direction direction);
void destroy();
signals:
- void bombExplosed();
+ void bombExploded();
void bombExecutionFinished();
private slots:
void onAnimationLaunchValueChanged(const QVariant &);
-
-private:
- QAnimationGroup *launchAnimation;
- PixmapItem *pixmapItem;
};
#endif //__BOMB__H__
diff --git a/demos/sub-attaq/custompropertyanimation.cpp b/demos/sub-attaq/custompropertyanimation.cpp
deleted file mode 100644
index 9b435f0..0000000
--- a/demos/sub-attaq/custompropertyanimation.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore 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$
-**
-****************************************************************************/
-
-#include "custompropertyanimation.h"
-
-// Qt
-#include <QtCore/qdebug.h>
-
-CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) :
- QVariantAnimation(parent), animProp(0)
-{
-}
-
-CustomPropertyAnimation::~CustomPropertyAnimation()
-{
-}
-
-void CustomPropertyAnimation::setProperty(AbstractProperty *_animProp)
-{
- if (animProp == _animProp)
- return;
- delete animProp;
- animProp = _animProp;
-}
-
-/*!
- \reimp
- */
-void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
-{
- if (!animProp || state() == QAbstractAnimation::Stopped)
- return;
-
- animProp->write(value);
-}
-
-
-/*!
- \reimp
-*/
-void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
-{
- // Initialize start value
- if (oldState == QAbstractAnimation::Stopped) {
- if (!animProp)
- return;
- QVariant def = animProp->read();
- if (def.isValid()) {
- const int t = def.userType();
- KeyValues values = keyValues();
- //this ensures that all the keyValues are of type t
- for (int i = 0; i < values.count(); ++i) {
- QVariantAnimation::KeyValue &pair = values[i];
- if (pair.second.userType() != t)
- pair.second.convert(static_cast<QVariant::Type>(t));
- }
- //let's now update the key values
- setKeyValues(values);
- }
-
- if ((animProp && !startValue().isValid() && currentTime() == 0)
- || (currentTime() == duration() && currentLoop() == (loopCount() - 1))) {
- setStartValue(def);
- }
- }
-
- QVariantAnimation::updateState(oldState, newState);
-}
-
-#include "moc_custompropertyanimation.cpp"
diff --git a/demos/sub-attaq/custompropertyanimation.h b/demos/sub-attaq/custompropertyanimation.h
deleted file mode 100644
index 0c97bf0..0000000
--- a/demos/sub-attaq/custompropertyanimation.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore 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$
-**
-****************************************************************************/
-
-#ifndef CUSTOMPROPERTYANIMATION_H
-#define CUSTOMPROPERTYANIMATION_H
-
-#include <QtCore/qvariantanimation.h>
-
-QT_BEGIN_NAMESPACE
-class QGraphicsItem;
-QT_END_NAMESPACE
-
-struct AbstractProperty
-{
- virtual QVariant read() const = 0;
- virtual void write(const QVariant &value) = 0;
-};
-
-
-class CustomPropertyAnimation : public QVariantAnimation
-{
- Q_OBJECT
-
- template <typename Target, typename T, typename T2 = T>
- class MemberFunctionProperty : public AbstractProperty
- {
- public:
- typedef T (Target::*Getter)(void) const;
- typedef void (Target::*Setter)(T2);
-
- MemberFunctionProperty(Target* target, Getter getter, Setter setter)
- : m_target(target), m_getter(getter), m_setter(setter) {}
-
- virtual void write(const QVariant &value)
- {
- if (m_setter) (m_target->*m_setter)(qVariantValue<T>(value));
- }
-
- virtual QVariant read() const
- {
- if (m_getter) return qVariantFromValue<T>((m_target->*m_getter)());
- return QVariant();
- }
-
- private:
- Target *m_target;
- Getter m_getter;
- Setter m_setter;
- };
-
-public:
- CustomPropertyAnimation(QObject *parent = 0);
- ~CustomPropertyAnimation();
-
- template<class Target, typename T>
- void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(const T& ))
- {
- setProperty(new MemberFunctionProperty<Target, T, const T&>(target, getter, setter));
- }
-
- template<class Target, typename T>
- void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(T))
- {
- setProperty(new MemberFunctionProperty<Target, T>(target, getter, setter));
- }
-
- void updateCurrentValue(const QVariant &value);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
- void setProperty(AbstractProperty *animProp);
-
-private:
- Q_DISABLE_COPY(CustomPropertyAnimation);
- AbstractProperty *animProp;
-};
-
-#endif // CUSTOMPROPERTYANIMATION_H
diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp
index e5d7aad..812eadf 100644
--- a/demos/sub-attaq/graphicsscene.cpp
+++ b/demos/sub-attaq/graphicsscene.cpp
@@ -47,7 +47,6 @@
#include "torpedo.h"
#include "bomb.h"
#include "pixmapitem.h"
-#include "custompropertyanimation.h"
#include "animationmanager.h"
#include "qanimationstate.h"
#include "progressitem.h"
@@ -68,39 +67,10 @@
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtCore/QXmlStreamReader>
-//helper function that creates an animation for position and inserts it into group
-static CustomPropertyAnimation *addGraphicsItemPosAnimation(QSequentialAnimationGroup *group,
- QGraphicsItem *item, const QPointF &endPos)
-{
- CustomPropertyAnimation *ret = new CustomPropertyAnimation(group);
- ret->setMemberFunctions(item, &QGraphicsItem::pos, &QGraphicsItem::setPos);
- ret->setEndValue(endPos);
- ret->setDuration(200);
- ret->setEasingCurve(QEasingCurve::OutElastic);
- group->addPause(50);
- return ret;
-}
-
-//helper function that creates an animation for opacity and inserts it into group
-static void addGraphicsItemFadeoutAnimation(QAnimationGroup *group, QGraphicsItem *item)
-{
-#if QT_VERSION >=0x040500
- CustomPropertyAnimation *anim = new CustomPropertyAnimation(group);
- anim->setMemberFunctions(item, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim->setDuration(800);
- anim->setEndValue(0);
- anim->setEasingCurve(QEasingCurve::OutQuad);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
-#endif
-}
-
GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
- : QGraphicsScene(x,y,width,height), mode(mode), newAction(0), quitAction(0), boat(0)
+ : QGraphicsScene(x , y, width, height), mode(mode), boat(new Boat)
{
- backgroundItem = new PixmapItem(QString("background"),mode);
+ PixmapItem *backgroundItem = new PixmapItem(QString("background"),mode);
backgroundItem->setZValue(1);
backgroundItem->setPos(0,0);
addItem(backgroundItem);
@@ -116,7 +86,6 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
textInformationItem = new TextInformationItem(backgroundItem);
textInformationItem->hide();
//We create the boat
- boat = new Boat();
addItem(boat);
boat->setPos(this->width()/2, sealLevel() - boat->size().height());
boat->hide();
@@ -130,28 +99,21 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
while (!reader.atEnd()) {
reader.readNext();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "submarine")
- {
+ if (reader.name() == "submarine") {
SubmarineDescription desc;
desc.name = reader.attributes().value("name").toString();
desc.points = reader.attributes().value("points").toString().toInt();
desc.type = reader.attributes().value("type").toString().toInt();
submarinesData.append(desc);
- }
- if (reader.name() == "level")
- {
+ } else if (reader.name() == "level") {
currentLevel.id = reader.attributes().value("id").toString().toInt();
currentLevel.name = reader.attributes().value("name").toString();
+ } else if (reader.name() == "subinstance") {
+ currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(), reader.attributes().value("nb").toString().toInt()));
}
- if (reader.name() == "subinstance")
- {
- currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(),reader.attributes().value("nb").toString().toInt()));
- }
- }
- if (reader.tokenType() == QXmlStreamReader::EndElement) {
- if (reader.name() == "level")
- {
- levelsData.insert(currentLevel.id,currentLevel);
+ } else if (reader.tokenType() == QXmlStreamReader::EndElement) {
+ if (reader.name() == "level") {
+ levelsData.insert(currentLevel.id, currentLevel);
currentLevel.submarines.clear();
}
}
@@ -160,80 +122,52 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
qreal GraphicsScene::sealLevel() const
{
- if (mode == Big)
- return 220;
- else
- return 160;
+ return (mode == Big) ? 220 : 160;
}
-void GraphicsScene::setupScene(const QList<QAction *> &actions)
+void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
{
- newAction = actions.at(0);
- quitAction = actions.at(1);
-
- QGraphicsItem *logo_s = addWelcomeItem(QPixmap(":/logo-s"));
- QGraphicsItem *logo_u = addWelcomeItem(QPixmap(":/logo-u"));
- QGraphicsItem *logo_b = addWelcomeItem(QPixmap(":/logo-b"));
- QGraphicsItem *logo_dash = addWelcomeItem(QPixmap(":/logo-dash"));
- QGraphicsItem *logo_a = addWelcomeItem(QPixmap(":/logo-a"));
- QGraphicsItem *logo_t = addWelcomeItem(QPixmap(":/logo-t"));
- QGraphicsItem *logo_t2 = addWelcomeItem(QPixmap(":/logo-t2"));
- QGraphicsItem *logo_a2 = addWelcomeItem(QPixmap(":/logo-a2"));
- QGraphicsItem *logo_q = addWelcomeItem(QPixmap(":/logo-q"));
- QGraphicsItem *logo_excl = addWelcomeItem(QPixmap(":/logo-excl"));
- logo_s->setZValue(3);
- logo_u->setZValue(4);
- logo_b->setZValue(5);
- logo_dash->setZValue(6);
- logo_a->setZValue(7);
- logo_t->setZValue(8);
- logo_t2->setZValue(9);
- logo_a2->setZValue(10);
- logo_q->setZValue(11);
- logo_excl->setZValue(12);
- logo_s->setPos(QPointF(-1000, -1000));
- logo_u->setPos(QPointF(-800, -1000));
- logo_b->setPos(QPointF(-600, -1000));
- logo_dash->setPos(QPointF(-400, -1000));
- logo_a->setPos(QPointF(1000, 2000));
- logo_t->setPos(QPointF(800, 2000));
- logo_t2->setPos(QPointF(600, 2000));
- logo_a2->setPos(QPointF(400, 2000));
- logo_q->setPos(QPointF(200, 2000));
- logo_excl->setPos(QPointF(0, 2000));
+ static const int nLetters = 10;
+ static struct {
+ char *pix;
+ qreal initX, initY;
+ qreal destX, destY;
+ } logoData[nLetters] = {
+ {"s", -1000, -1000, 300, 150 },
+ {"u", -800, -1000, 350, 150 },
+ {"b", -600, -1000, 400, 120 },
+ {"dash", -400, -1000, 460, 150 },
+ {"a", 1000, 2000, 350, 250 },
+ {"t", 800, 2000, 400, 250 },
+ {"t2", 600, 2000, 430, 250 },
+ {"a2", 400, 2000, 465, 250 },
+ {"q", 200, 2000, 510, 250 },
+ {"excl", 0, 2000, 570, 220 } };
QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this);
QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this);
- //creation of the animations for moving letters
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_s, QPointF(300, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_u, QPointF(350, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_b, QPointF(400, 120));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_dash, QPointF(460, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_a, QPointF(350, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_t, QPointF(400, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_t2, QPointF(430, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_a2, QPointF(465, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_q, QPointF(510, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_excl, QPointF(570, 220));
-
- //creation of the animations for fading out the letters
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_s);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_u);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_b);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_dash);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t2);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a2);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_q);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_excl);
- connect(lettersGroupFading, SIGNAL(finished()), this, SLOT(onIntroAnimationFinished()));
+ for (int i = 0; i < nLetters; ++i) {
+ PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this);
+ logo->setPos(logoData[i].initX, logoData[i].initY);
+ logo->setZValue(i + 3);
+ //creation of the animations for moving letters
+ QPropertyAnimation *moveAnim = new QPropertyAnimation(logo, "pos", lettersGroupMoving);
+ moveAnim->setEndValue(QPointF(logoData[i].destX, logoData[i].destY));
+ moveAnim->setDuration(200);
+ moveAnim->setEasingCurve(QEasingCurve::OutElastic);
+ lettersGroupMoving->addPause(50);
+ //creation of the animations for fading out the letters
+ QPropertyAnimation *fadeAnim = new QPropertyAnimation(logo, "opacity", lettersGroupFading);
+ fadeAnim->setDuration(800);
+ fadeAnim->setEndValue(0);
+ fadeAnim->setEasingCurve(QEasingCurve::OutQuad);
+ }
QStateMachine *machine = new QStateMachine(this);
//This state is when the player is playing
- PlayState *gameState = new PlayState(this,machine);
+ PlayState *gameState = new PlayState(this, machine);
//Final state
QFinalState *final = new QFinalState(machine);
@@ -263,7 +197,7 @@ void GraphicsScene::setupScene(const QList<QAction *> &actions)
machine->start();
//We reach the final state, then we quit
- connect(machine,SIGNAL(finished()),this, SLOT(onQuitGameTriggered()));
+ connect(machine, SIGNAL(finished()), qApp, SLOT(quit()));
}
void GraphicsScene::addItem(Bomb *bomb)
@@ -292,16 +226,6 @@ void GraphicsScene::addItem(QGraphicsItem *item)
QGraphicsScene::addItem(item);
}
-void GraphicsScene::mousePressEvent (QGraphicsSceneMouseEvent * event)
-{
- event->ignore();
-}
-
-void GraphicsScene::onQuitGameTriggered()
-{
- qApp->closeAllWindows();
-}
-
void GraphicsScene::onBombExecutionFinished()
{
Bomb *bomb = qobject_cast<Bomb *>(sender());
@@ -322,32 +246,26 @@ void GraphicsScene::onSubMarineExecutionFinished()
{
SubMarine *submarine = qobject_cast<SubMarine *>(sender());
submarines.remove(submarine);
- if (submarines.count() == 0) {
+ if (submarines.count() == 0)
emit allSubMarineDestroyed(submarine->points());
- } else {
+ else
emit subMarineDestroyed(submarine->points());
- }
submarine->deleteLater();
}
-int GraphicsScene::remainingSubMarines() const
-{
- return submarines.count();
-}
-
void GraphicsScene::clearScene()
{
- foreach (SubMarine *sub,submarines) {
+ foreach (SubMarine *sub, submarines) {
sub->destroy();
sub->deleteLater();
}
- foreach (Torpedo *torpedo,torpedos) {
+ foreach (Torpedo *torpedo, torpedos) {
torpedo->destroy();
torpedo->deleteLater();
}
- foreach (Bomb *bomb,bombs) {
+ foreach (Bomb *bomb, bombs) {
bomb->destroy();
bomb->deleteLater();
}
@@ -361,17 +279,3 @@ void GraphicsScene::clearScene()
boat->stop();
boat->hide();
}
-
-QGraphicsPixmapItem *GraphicsScene::addWelcomeItem(const QPixmap &pm)
-{
- QGraphicsPixmapItem *item = addPixmap(pm);
- welcomeItems << item;
- return item;
-}
-
-void GraphicsScene::onIntroAnimationFinished()
-{
- qDeleteAll(welcomeItems);
- welcomeItems.clear();
-}
-
diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h
index 7d7252d..ce2c91f 100644
--- a/demos/sub-attaq/graphicsscene.h
+++ b/demos/sub-attaq/graphicsscene.h
@@ -82,41 +82,30 @@ public:
GraphicsScene(int x, int y, int width, int height, Mode mode = Big);
qreal sealLevel() const;
- void setupScene(const QList<QAction *> &actions);
+ void setupScene(QAction *newAction, QAction *quitAction);
void addItem(Bomb *bomb);
void addItem(Torpedo *torpedo);
void addItem(SubMarine *submarine);
void addItem(QGraphicsItem *item);
- int remainingSubMarines() const;
void clearScene();
- QGraphicsPixmapItem *addWelcomeItem(const QPixmap &pm);
signals:
void subMarineDestroyed(int);
void allSubMarineDestroyed(int);
-protected:
- void mousePressEvent (QGraphicsSceneMouseEvent * event);
-
private slots:
- void onQuitGameTriggered();
void onBombExecutionFinished();
void onTorpedoExecutionFinished();
void onSubMarineExecutionFinished();
- void onIntroAnimationFinished();
private:
Mode mode;
- PixmapItem *backgroundItem;
ProgressItem *progressItem;
TextInformationItem *textInformationItem;
- QAction * newAction;
- QAction * quitAction;
Boat *boat;
QSet<SubMarine *> submarines;
QSet<Bomb *> bombs;
QSet<Torpedo *> torpedos;
- QVector<QGraphicsPixmapItem *> welcomeItems;
QVector<SubmarineDescription> submarinesData;
QHash<int, LevelDescription> levelsData;
diff --git a/demos/sub-attaq/mainwindow.cpp b/demos/sub-attaq/mainwindow.cpp
index 37129f8..45e5554 100644
--- a/demos/sub-attaq/mainwindow.cpp
+++ b/demos/sub-attaq/mainwindow.cpp
@@ -56,42 +56,27 @@
MainWindow::MainWindow() : QMainWindow(0)
{
- QMenuBar *menuBar = new QMenuBar;
- QMenu *file = new QMenu(tr("&File"),menuBar);
+ QMenu *file = menuBar()->addMenu(tr("&File"));
- QAction *newAction = new QAction(tr("New Game"),file);
+ QAction *newAction = file->addAction(tr("New Game"));
newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
- file->addAction(newAction);
- QAction *quitAction = new QAction(tr("Quit"),file);
+ QAction *quitAction = file->addAction(tr("Quit"));
quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
- file->addAction(quitAction);
- menuBar->addMenu(file);
- setMenuBar(menuBar);
-
- QStringList list = QApplication::arguments();
- if (list.contains("-fullscreen")) {
- scene = new GraphicsScene(0, 0, 750, 400,GraphicsScene::Small);
+ if (QApplication::arguments().contains("-fullscreen")) {
+ scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small);
setWindowState(Qt::WindowFullScreen);
} else {
scene = new GraphicsScene(0, 0, 880, 630);
layout()->setSizeConstraint(QLayout::SetFixedSize);
}
- view = new QGraphicsView(scene,this);
+ view = new QGraphicsView(scene, this);
view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- QList<QAction *> actions;
- actions << newAction << quitAction;
- scene->setupScene(actions);
+ scene->setupScene(newAction, quitAction);
#ifndef QT_NO_OPENGL
- view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
+ view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
setCentralWidget(view);
-
-}
-
-MainWindow::~MainWindow()
-{
}
-
diff --git a/demos/sub-attaq/mainwindow.h b/demos/sub-attaq/mainwindow.h
index d626ad7..12a7364 100644
--- a/demos/sub-attaq/mainwindow.h
+++ b/demos/sub-attaq/mainwindow.h
@@ -54,7 +54,6 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
MainWindow();
- ~MainWindow();
private:
GraphicsScene *scene;
diff --git a/demos/sub-attaq/pixmapitem.cpp b/demos/sub-attaq/pixmapitem.cpp
index 9abf745..fcc7ce9 100644
--- a/demos/sub-attaq/pixmapitem.cpp
+++ b/demos/sub-attaq/pixmapitem.cpp
@@ -43,17 +43,34 @@
#include "pixmapitem.h"
//Qt
-#include <QtCore/QDir>
+#include <QPainter>
-PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsPixmapItem(parent),name(fileName)
+PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent)
{
- loadPixmap(mode);
+ if (mode == GraphicsScene::Big)
+ pix = ":/big/" + fileName;
+ else
+ pix = ":/small/" + fileName;
}
-void PixmapItem::loadPixmap(GraphicsScene::Mode mode)
+PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName)
{
- if (mode == GraphicsScene::Big)
- setPixmap(":/big/" + name);
- else
- setPixmap(":/small/" + name);
+ scene->addItem(this);
}
+
+QSizeF PixmapItem::size() const
+{
+ return pix.size();
+}
+
+QRectF PixmapItem::boundingRect() const
+{
+ return QRectF(QPointF(0, 0), pix.size());
+}
+
+void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ painter->drawPixmap(0, 0, pix);
+}
+
+
diff --git a/demos/sub-attaq/pixmapitem.h b/demos/sub-attaq/pixmapitem.h
index b176215..57f831a 100644
--- a/demos/sub-attaq/pixmapitem.h
+++ b/demos/sub-attaq/pixmapitem.h
@@ -46,18 +46,18 @@
#include "graphicsscene.h"
//Qt
-#include <QtGui/QGraphicsPixmapItem>
+#include <QtGui/QGraphicsObject>
-class PixmapItem : public QGraphicsPixmapItem
+class PixmapItem : public QGraphicsObject
{
public:
PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0);
-
+ PixmapItem(const QString &fileName, QGraphicsScene *scene);
+ QSizeF size() const;
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
private:
- void loadPixmap(GraphicsScene::Mode mode);
-
- QString name;
- QPixmap pixmap;
+ QPixmap pix;
};
#endif //__PIXMAPITEM__H__
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index 7443ae7..742095e 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -67,8 +67,7 @@ PlayState::PlayState(GraphicsScene *scene, QState *parent)
PlayState::~PlayState()
{
- if (machine)
- delete machine;
+ delete machine;
}
void PlayState::onEntry(QEvent *)
@@ -169,7 +168,7 @@ void LevelState::initializeLevel()
scene->boat->setCurrentDirection(Boat::None);
scene->boat->setBombsLaunched(0);
scene->boat->show();
- scene->setFocusItem(scene->boat,Qt::OtherFocusReason);
+ scene->setFocusItem(scene->boat, Qt::OtherFocusReason);
scene->boat->run();
scene->progressItem->setScore(game->score);
@@ -276,13 +275,8 @@ void WinState::onExit(QEvent *)
}
/** UpdateScore State */
-UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QState(parent)
-{
- this->game = game;
-}
-void UpdateScoreState::onEntry(QEvent *e)
+UpdateScoreState::UpdateScoreState(PlayState *g, QState *parent) : QState(parent), game(g)
{
- QState::onEntry(e);
}
/** Win transition */
@@ -297,12 +291,10 @@ bool UpdateScoreTransition::eventTest(QEvent *event)
{
if (!QSignalTransition::eventTest(event))
return false;
- else {
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
- game->score += se->arguments().at(0).toInt();
- scene->progressItem->setScore(game->score);
- return true;
- }
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
+ game->score += se->arguments().at(0).toInt();
+ scene->progressItem->setScore(game->score);
+ return true;
}
/** Win transition */
@@ -317,12 +309,10 @@ bool WinTransition::eventTest(QEvent *event)
{
if (!QSignalTransition::eventTest(event))
return false;
- else {
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
- game->score += se->arguments().at(0).toInt();
- scene->progressItem->setScore(game->score);
- return true;
- }
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
+ game->score += se->arguments().at(0).toInt();
+ scene->progressItem->setScore(game->score);
+ return true;
}
/** Space transition */
@@ -334,12 +324,7 @@ CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, Q
bool CustomSpaceTransition::eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (game->currentLevel != 0)
- return true;
- else
- return false;
-
+ return (game->currentLevel != 0);
}
diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h
index 9e78ae4..f588e5d 100644
--- a/demos/sub-attaq/states.h
+++ b/demos/sub-attaq/states.h
@@ -136,8 +136,6 @@ class UpdateScoreState : public QState
{
public:
UpdateScoreState(PlayState *game, QState *parent);
-protected:
- void onEntry(QEvent *);
private:
QPropertyAnimation *scoreAnimation;
PlayState *game;
diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro
index 8677ff5..b5aa465 100644
--- a/demos/sub-attaq/sub-attaq.pro
+++ b/demos/sub-attaq/sub-attaq.pro
@@ -10,7 +10,6 @@ HEADERS += boat.h \
states.h \
boat_p.h \
submarine_p.h \
- custompropertyanimation.h \
qanimationstate.h \
progressitem.h \
textinformationitem.h
@@ -24,7 +23,6 @@ SOURCES += boat.cpp \
graphicsscene.cpp \
animationmanager.cpp \
states.cpp \
- custompropertyanimation.cpp \
qanimationstate.cpp \
progressitem.cpp \
textinformationitem.cpp
diff --git a/demos/sub-attaq/submarine.cpp b/demos/sub-attaq/submarine.cpp
index 3d8490f..f71b81c 100644
--- a/demos/sub-attaq/submarine.cpp
+++ b/demos/sub-attaq/submarine.cpp
@@ -46,7 +46,6 @@
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
-#include "custompropertyanimation.h"
#include "qanimationstate.h"
#include <QtCore/QPropertyAnimation>
@@ -57,62 +56,27 @@
static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub)
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub);
-#if QT_VERSION >=0x040500
- PixmapItem *step1 = new PixmapItem(QString("explosion/submarine/step1"),GraphicsScene::Big, sub);
- step1->setZValue(6);
- PixmapItem *step2 = new PixmapItem(QString("explosion/submarine/step2"),GraphicsScene::Big, sub);
- step2->setZValue(6);
- PixmapItem *step3 = new PixmapItem(QString("explosion/submarine/step3"),GraphicsScene::Big, sub);
- step3->setZValue(6);
- PixmapItem *step4 = new PixmapItem(QString("explosion/submarine/step4"),GraphicsScene::Big, sub);
- step4->setZValue(6);
- step1->setOpacity(0);
- step2->setOpacity(0);
- step3->setOpacity(0);
- step4->setOpacity(0);
- CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(sub);
- anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim1->setDuration(100);
- anim1->setEndValue(1);
- CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(sub);
- anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim2->setDuration(100);
- anim2->setEndValue(1);
- CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(sub);
- anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim3->setDuration(100);
- anim3->setEndValue(1);
- CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(sub);
- anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim4->setDuration(100);
- anim4->setEndValue(1);
- group->addAnimation(anim1);
- group->addAnimation(anim2);
- group->addAnimation(anim3);
- group->addAnimation(anim4);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
- group->addAnimation(anim);
-#endif
+ for (int i = 1; i <= 4; ++i) {
+ PixmapItem *step = new PixmapItem(QString::fromLatin1("explosion/submarine/step%1").arg(i), GraphicsScene::Big, sub);
+ step->setZValue(6);
+ step->setOpacity(0);
+ QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity", group);
+ anim->setDuration(100);
+ anim->setEndValue(1);
+ }
AnimationManager::self()->registerAnimation(group);
return group;
}
-SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None)
+SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QString("submarine"), GraphicsScene::Big),
+ subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None)
{
- pixmapItem = new PixmapItem(QString("submarine"),GraphicsScene::Big, this);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setZValue(5);
- setFlags(QGraphicsItem::ItemIsMovable);
- resize(pixmapItem->boundingRect().width(),pixmapItem->boundingRect().height());
setTransformOriginPoint(boundingRect().center());
graphicsRotation = new QGraphicsRotation(this);
- graphicsRotation->setAxis(QVector3D(0, 1, 0));
+ graphicsRotation->setAxis(Qt::YAxis);
graphicsRotation->setOrigin(QVector3D(size().width()/2, size().height()/2, 0));
QList<QGraphicsTransform *> r;
r.append(graphicsRotation);
@@ -163,7 +127,7 @@ SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem *
machine->start();
}
-int SubMarine::points()
+int SubMarine::points() const
{
return subPoints;
}
@@ -202,7 +166,7 @@ void SubMarine::launchTorpedo(int speed)
Torpedo * torp = new Torpedo();
GraphicsScene *scene = static_cast<GraphicsScene *>(this->scene());
scene->addItem(torp);
- torp->setPos(x(), y());
+ torp->setPos(pos());
torp->setCurrentSpeed(speed);
torp->launch();
}
diff --git a/demos/sub-attaq/submarine.h b/demos/sub-attaq/submarine.h
index 1a3d2e5..326a1c8 100644
--- a/demos/sub-attaq/submarine.h
+++ b/demos/sub-attaq/submarine.h
@@ -43,15 +43,13 @@
#define __SUBMARINE__H__
//Qt
-#include <QtCore/QVariantAnimation>
-#include <QtGui/QGraphicsWidget>
#include <QtGui/QGraphicsTransform>
-class PixmapItem;
+#include "pixmapitem.h"
class Torpedo;
-class SubMarine : public QGraphicsWidget
+class SubMarine : public PixmapItem
{
Q_OBJECT
public:
@@ -61,9 +59,9 @@ public:
Right
};
enum { Type = UserType + 1 };
- SubMarine(int type, const QString &name, int points, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ SubMarine(int type, const QString &name, int points);
- int points();
+ int points() const;
void setCurrentDirection(Movement direction);
enum Movement currentDirection() const;
@@ -89,7 +87,6 @@ private:
int subPoints;
int speed;
Movement direction;
- PixmapItem *pixmapItem;
QGraphicsRotation *graphicsRotation;
};
diff --git a/demos/sub-attaq/submarine_p.h b/demos/sub-attaq/submarine_p.h
index fa7430b..64a0cf7 100644
--- a/demos/sub-attaq/submarine_p.h
+++ b/demos/sub-attaq/submarine_p.h
@@ -94,7 +94,6 @@ protected:
movementAnimation->setEndValue(QPointF(submarine->scene()->width()-submarine->size().width(),submarine->y()));
movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12);
}
- movementAnimation->setStartValue(submarine->pos());
QAnimationState::onEntry(e);
}
diff --git a/demos/sub-attaq/torpedo.cpp b/demos/sub-attaq/torpedo.cpp
index cce430d..95f88e6 100644
--- a/demos/sub-attaq/torpedo.cpp
+++ b/demos/sub-attaq/torpedo.cpp
@@ -51,24 +51,21 @@
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
-Torpedo::Torpedo(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), currentSpeed(0), launchAnimation(0)
+Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big),
+ currentSpeed(0)
{
- pixmapItem = new PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big, this);
setZValue(2);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable);
- resize(pixmapItem->boundingRect().size());
}
void Torpedo::launch()
{
- launchAnimation = new QPropertyAnimation(this, "pos");
+ QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos");
AnimationManager::self()->registerAnimation(launchAnimation);
launchAnimation->setEndValue(QPointF(x(),qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15));
launchAnimation->setEasingCurve(QEasingCurve::InQuad);
launchAnimation->setDuration(y()/currentSpeed*10);
connect(launchAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &)));
+ connect(this,SIGNAL(torpedoExploded()), launchAnimation, SLOT(stop()));
//We setup the state machine of the torpedo
QStateMachine *machine = new QStateMachine(this);
@@ -83,7 +80,7 @@ void Torpedo::launch()
machine->setInitialState(launched);
//### Add a nice animation when the torpedo is destroyed
- launched->addTransition(this, SIGNAL(torpedoExplosed()),final);
+ launched->addTransition(this, SIGNAL(torpedoExploded()),final);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, SIGNAL(animationFinished()), final);
@@ -106,15 +103,12 @@ void Torpedo::setCurrentSpeed(int speed)
void Torpedo::onAnimationLaunchValueChanged(const QVariant &)
{
foreach (QGraphicsItem *item , collidingItems(Qt::IntersectsItemBoundingRect)) {
- if (item->type() == Boat::Type) {
- Boat *b = static_cast<Boat *>(item);
+ if (Boat *b = qgraphicsitem_cast<Boat*>(item))
b->destroy();
- }
}
}
void Torpedo::destroy()
{
- launchAnimation->stop();
- emit torpedoExplosed();
+ emit torpedoExploded();
}
diff --git a/demos/sub-attaq/torpedo.h b/demos/sub-attaq/torpedo.h
index 2e654f4..03f277d 100644
--- a/demos/sub-attaq/torpedo.h
+++ b/demos/sub-attaq/torpedo.h
@@ -42,25 +42,19 @@
#ifndef __TORPEDO__H__
#define __TORPEDO__H__
-//Qt
-#include <QtCore/QObject>
+#include "pixmapitem.h"
-#include <QtCore/QVariantAnimation>
-#include <QtGui/QGraphicsWidget>
-
-class PixmapItem;
-
-class Torpedo : public QGraphicsWidget
+class Torpedo : public PixmapItem
{
Q_OBJECT
public:
- Torpedo(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ Torpedo();
void launch();
void setCurrentSpeed(int speed);
void destroy();
signals:
- void torpedoExplosed();
+ void torpedoExploded();
void torpedoExecutionFinished();
private slots:
@@ -68,8 +62,6 @@ private slots:
private:
int currentSpeed;
- PixmapItem *pixmapItem;
- QVariantAnimation *launchAnimation;
};
#endif //__TORPEDO__H__
diff --git a/demos/symbianpkgrules.pri b/demos/symbianpkgrules.pri
index cf52cb3..7e6852b 100644
--- a/demos/symbianpkgrules.pri
+++ b/demos/symbianpkgrules.pri
@@ -11,5 +11,3 @@ vendorinfo = \
" "
default_deployment.pkg_prerules += vendorinfo
-
-!isEmpty(TARGET.UID3):ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg