diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-10-16 07:31:25 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-10-16 07:31:25 (GMT) |
commit | c48746b06e5e5e79eb6657f9acf043670306fa4e (patch) | |
tree | 683ef4d704b7401093439ff3247c0875e5911574 /examples/declarative | |
parent | fbd212abb05fee0ff9c9faf00c40136f0b901707 (diff) | |
parent | 9d22aa7aa14a200d8c1fc0f1b4b1ead540e45e67 (diff) | |
download | Qt-c48746b06e5e5e79eb6657f9acf043670306fa4e.zip Qt-c48746b06e5e5e79eb6657f9acf043670306fa4e.tar.gz Qt-c48746b06e5e5e79eb6657f9acf043670306fa4e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples/declarative')
-rw-r--r-- | examples/declarative/dynamic/dynamic.qml | 8 | ||||
-rw-r--r-- | examples/declarative/loader/Browser.diff | 60 | ||||
-rw-r--r-- | examples/declarative/loader/Browser.qml | 187 | ||||
-rw-r--r-- | examples/declarative/loader/images/fileopen.png | bin | 953 -> 0 bytes | |||
-rw-r--r-- | examples/declarative/loader/images/folder.png | bin | 0 -> 1841 bytes | |||
-rw-r--r-- | examples/declarative/loader/images/titlebar.png | bin | 0 -> 1436 bytes | |||
-rw-r--r-- | examples/declarative/loader/images/titlebar.sci | 5 | ||||
-rw-r--r-- | examples/declarative/loader/loader.pro | 9 | ||||
-rw-r--r-- | examples/declarative/loader/loader.qrc | 6 | ||||
-rw-r--r-- | examples/declarative/loader/main.cpp | 42 |
10 files changed, 268 insertions, 49 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 66fdf87..2c6a8e0 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -8,6 +8,7 @@ Rectangle { Script { source: "dynamic.js" } property bool extendStars: false + property var fourthBox: undefined Item { id: targetItem; x: 100; y: 100; } Item { id: targetItem2; x: 0; y: 300; } @@ -20,7 +21,7 @@ Rectangle { MouseRegion { anchors.fill: parent - onClicked: { a = createWithComponent(); } + onClicked: { var a = createWithComponent(); } } } @@ -47,8 +48,8 @@ Rectangle { MouseRegion { anchors.fill: parent onClicked: { - if (fourthBox == null) { - a = createQml(targetItem2); + if (fourthBox == null || fourthBox == undefined) { + var a = createQml(targetItem2); if (a != null) { a.parent = targetItem2;//BUG: this should happen automatically fourthBox = a; @@ -68,6 +69,7 @@ Rectangle { Particles { x: 0 y: 0 + z: 10 count: 20 lifeSpan: 500 width: 100 diff --git a/examples/declarative/loader/Browser.diff b/examples/declarative/loader/Browser.diff new file mode 100644 index 0000000..adc0f60 --- /dev/null +++ b/examples/declarative/loader/Browser.diff @@ -0,0 +1,60 @@ +diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml +index 96c2a76..00e1bb6 100644 +--- a/examples/declarative/loader/Browser.qml ++++ b/examples/declarative/loader/Browser.qml +@@ -17,9 +17,16 @@ Rect { + id: FolderDelegate + Rect { + id: Wrapper ++ function launch() { ++ if (folders.isFolder(index)) { ++ folders.folder = filePath; ++ } else { ++ qmlLauncher.launch(filePath); ++ } ++ } + width: Root.width + height: 32 +- color: activePalette.base ++ color: "transparent" + Rect { + id: Highlight; visible: false + anchors.fill: parent +@@ -42,13 +49,7 @@ Rect { + MouseRegion { + id: Mouse + anchors.fill: parent +- onClicked: { +- if (folders.isFolder(index)) { +- folders.folder = filePath; +- } else { +- qmlLauncher.launch(filePath); +- } +- } ++ onClicked: { launch() } + } + states: [ + State { +@@ -69,13 +70,22 @@ Rect { + } + + ListView { ++ id: View + anchors.top: TitleBar.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + model: folders + delegate: FolderDelegate ++ highlight: Rect { color: "#FFFBAF" } + clip: true ++ focus: true ++ onKeyPress: { ++ if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) { ++ View.current.launch(); ++ event.accepted = true; ++ } ++ } + } + + Rect { diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index 5f972f1..18dc206 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -2,30 +2,70 @@ import Qt 4.6 Rectangle { id: root + property bool keyPressed: false + property var folders: folders1 + property var view: view1 width: parent.width height: parent.height - color: palette.base + color: palette.window FolderListModel { - id: folders + id: folders1 nameFilters: [ "*.qml" ] -// folder: "E:" + folder: "file:///E:/" // Documents on your S60 phone (or Windows E: drive) + } + FolderListModel { + id: folders2 + nameFilters: [ "*.qml" ] + folder: "file:///E:/" // Documents on your S60 phone (or Windows E: drive) } SystemPalette { id: palette; colorGroup: Qt.Active } + Script { + function down(path) { + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitLeft"; + } else { + view = view1 + folders = folders1; + view2.state = "exitLeft"; + } + view.x = root.width; + view.state = "current"; + folders.folder = path; + } + function up() { + var path = folders.parentFolder; + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitRight"; + } else { + view = view1 + folders = folders1; + view2.state = "exitRight"; + } + view.x = -root.width; + view.state = "current"; + folders.folder = path; + } + } + Component { id: folderDelegate Rectangle { id: wrapper function launch() { if (folders.isFolder(index)) { - folders.folder = filePath; + down(filePath); } else { qmlLauncher.launch(filePath); } } width: root.width - height: 32 + height: 48 color: "transparent" Rectangle { id: highlight; visible: false @@ -36,15 +76,15 @@ Rectangle { } } Item { - width: 32; height: 32 - Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} + width: 46; height: 46 + Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} } Text { id: nameText anchors.fill: parent; verticalAlignment: "AlignVCenter" - text: fileName; anchors.leftMargin: 32 - font.pointSize: 10 - color: palette.windowText + text: fileName; anchors.leftMargin: 48 + font.pixelSize: 32 + color: wrapper.isCurrentItem ? palette.highlightedText : palette.text } MouseRegion { id: mouseRegion @@ -62,52 +102,131 @@ Rectangle { } } - Script { - function up(path) { - var pos = path.toString().lastIndexOf("/"); - return path.toString().substring(0, pos); - } + ListView { + id: view1 + anchors.top: titleBar.bottom + anchors.bottom: parent.bottom + x: parent.left + width: parent.width + model: folders1 + delegate: folderDelegate + highlight: Rectangle { color: palette.highlight; visible: root.keyPressed } + focus: true + pressDelay: 100 + state: current + states: [ + State { + name: "current" + PropertyChanges { target: view1; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view1; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view1; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } + NumberAnimation { properties: "x"; duration: 250 } + } + ] } ListView { - id: view + id: view2 anchors.top: titleBar.bottom - anchors.left: parent.left - anchors.right: parent.right anchors.bottom: parent.bottom - model: folders + x: parent.width + width: parent.width + model: folders2 delegate: folderDelegate - highlight: Rectangle { color: "#FFFBAF" } - clip: true + highlight: Rectangle { color: palette.highlight; visible: root.keyPressed } focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) { - view.currentItem.launch(); - event.accepted = true; + pressDelay: 100 + states: [ + State { + name: "current" + PropertyChanges { target: view2; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view2; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view2; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } } + ] + } + + Keys.onPressed: { + root.keyPressed = true; + if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { + view.currentItem.launch(); + event.accepted = true; } } + Keys.onLeftPressed: up() - Rectangle { + BorderImage { + source: "images/titlebar.sci"; + width: parent.width; + height: 48 + y: -7 id: titleBar - width: parent.width - height: 32 - color: palette.button; border.color: palette.mid Rectangle { id: upButton - width: 30 - height: titleBar.height - border.color: palette.mid; color: "transparent" - MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) } + width: 40 + height: titleBar.height - 7 + color: "transparent" + Image { anchors.centerIn: parent; source: "images/up.png" } + MouseRegion { id: upRegion; anchors.fill: parent + onClicked: if (folders.parentFolder != "") up() + } + states: [ + State { + name: "pressed" + when: upRegion.pressed + PropertyChanges { target: upButton; color: palette.highlightedText } + } + ] + } + Rectangle { + color: "gray" + x: 40 + width: 1 + height: 40 } Text { anchors.left: upButton.right; anchors.right: parent.right; height: parent.height anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder; color: palette.buttonText + text: folders.folder; color: "white" elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter" + font.pixelSize: 32 } } } diff --git a/examples/declarative/loader/images/fileopen.png b/examples/declarative/loader/images/fileopen.png Binary files differdeleted file mode 100644 index 4aaf149..0000000 --- a/examples/declarative/loader/images/fileopen.png +++ /dev/null diff --git a/examples/declarative/loader/images/folder.png b/examples/declarative/loader/images/folder.png Binary files differnew file mode 100644 index 0000000..e53e2ad --- /dev/null +++ b/examples/declarative/loader/images/folder.png diff --git a/examples/declarative/loader/images/titlebar.png b/examples/declarative/loader/images/titlebar.png Binary files differnew file mode 100644 index 0000000..51c9008 --- /dev/null +++ b/examples/declarative/loader/images/titlebar.png diff --git a/examples/declarative/loader/images/titlebar.sci b/examples/declarative/loader/images/titlebar.sci new file mode 100644 index 0000000..0418d94 --- /dev/null +++ b/examples/declarative/loader/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro index 089eaff..9b03b8f 100644 --- a/examples/declarative/loader/loader.pro +++ b/examples/declarative/loader/loader.pro @@ -7,3 +7,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader INSTALLS += target sources + +symbian { +# TARGET.UID3 = + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 100000 20000000 + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon -linsock + TARGET.CAPABILITY = NetworkServices +} diff --git a/examples/declarative/loader/loader.qrc b/examples/declarative/loader/loader.qrc index 73ee253..94d7b92 100644 --- a/examples/declarative/loader/loader.qrc +++ b/examples/declarative/loader/loader.qrc @@ -1,9 +1,11 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/" > <file>loader.qml</file> <file>Browser.qml</file> - <file>images/fileopen.png</file> <file>images/up.png</file> <file>Button.qml</file> + <file>images/folder.png</file> + <file>images/titlebar.sci</file> + <file>images/titlebar.png</file> </qresource> </RCC> diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp index fbae5f1..0993814 100644 --- a/examples/declarative/loader/main.cpp +++ b/examples/declarative/loader/main.cpp @@ -15,6 +15,15 @@ #include <QDebug> #include <QNetworkDiskCache> #include <QNetworkAccessManager> +#include <QtCore> + +#if defined (Q_OS_SYMBIAN) +#define SYMBIAN_NETWORK_INIT +#endif + +#if defined (SYMBIAN_NETWORK_INIT) +#include "sym_iap_util.h" +#endif QmlView *canvas = 0; @@ -30,13 +39,11 @@ public: setLayout(layout); #ifdef Q_OS_SYMBIAN QAction *closeAction = new QAction("Close", this); - closeAction->setSoftKeyRole(QAction::BackSoftKey); + closeAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); - - QList<QAction*> softKeys; - softKeys.append(closeAction); - setSoftKeys(softKeys); + addAction(closeAction); #endif + connect(logText, SIGNAL(textChanged()), this, SIGNAL(textChanged())); } void append(const QString &text) { @@ -50,6 +57,9 @@ public: return logger; } +signals: + void textChanged(); + private: QPlainTextEdit *logText; }; @@ -112,7 +122,7 @@ public: } } - canvas->setUrl(fileName); + canvas->setUrl(url); canvas->execute(); } @@ -124,8 +134,9 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow() : QMainWindow() {} - + MainWindow() : QMainWindow() + { + } public slots: void toggleFullScreen() @@ -149,6 +160,13 @@ public slots: Logger::instance()->show(); #endif } + + void enableNetwork() + { +#if defined(SYMBIAN_NETWORK_INIT) + qt_SetDefaultIap(); +#endif + } }; class ConfiguredNetworkAccessManager : public QNetworkAccessManager { @@ -185,8 +203,6 @@ int main(int argc, char *argv[]) canvas->setFocusPolicy(Qt::StrongFocus); canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager); - mw->setCentralWidget(canvas); - QMenuBar *mb = mw->menuBar(); QAction *showLogAction = new QAction("View Log...", mw); mb->addAction(showLogAction); @@ -194,6 +210,11 @@ int main(int argc, char *argv[]) QAction *toggleFSAction = new QAction("Fullscreen", mw); mb->addAction(toggleFSAction); QObject::connect(toggleFSAction, SIGNAL(triggered()), mw, SLOT(toggleFullScreen())); +#if defined(SYMBIAN_NETWORK_INIT) + QAction *enableNetworkAction = new QAction("Enable Network", mw); + mb->addAction(enableNetworkAction); + QObject::connect(enableNetworkAction, SIGNAL(triggered()), mw, SLOT(enableNetwork())); +#endif QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("qmlLauncher", launcher); @@ -205,6 +226,7 @@ int main(int argc, char *argv[]) mw->show(); #endif canvas->execute(); + mw->setCentralWidget(canvas); return app.exec(); } |