summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-03-29 03:39:26 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-03-29 03:39:26 (GMT)
commit593f551d6718343f80b5497de58eb80566ea7908 (patch)
tree22e4211e379e9d559d14aa09b94d1910f4794ff3 /examples
parentf183932778932a8c2fc5ac38c753893eaeb99575 (diff)
parent0f39158778ad3a7deb96303596f7b365802ffb5d (diff)
downloadQt-593f551d6718343f80b5497de58eb80566ea7908.zip
Qt-593f551d6718343f80b5497de58eb80566ea7908.tar.gz
Qt-593f551d6718343f80b5497de58eb80566ea7908.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/focus/Core/ContextMenu.qml15
-rw-r--r--examples/declarative/focus/Core/GridMenu.qml54
-rw-r--r--examples/declarative/focus/Core/ListViewDelegate.qml39
-rw-r--r--examples/declarative/focus/Core/ListViews.qml47
-rw-r--r--examples/declarative/focus/Core/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/declarative/focus/Core/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/declarative/focus/Core/qmldir4
-rw-r--r--examples/declarative/focus/focus.qml50
-rw-r--r--examples/declarative/widgets/MyWidgets/qmldir1
-rw-r--r--examples/declarative/widgets/mywidgets.cpp99
-rw-r--r--examples/declarative/widgets/mywidgets.pro19
-rw-r--r--examples/declarative/widgets/mywidgets.qml53
12 files changed, 381 insertions, 0 deletions
diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml
new file mode 100644
index 0000000..bd6d8a2
--- /dev/null
+++ b/examples/declarative/focus/Core/ContextMenu.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+
+FocusScope {
+ id: container
+ property bool open: false
+
+ Item {
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent; color: "#D1DBBD"; focus: true
+ Keys.onRightPressed: mainView.focus = true
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml
new file mode 100644
index 0000000..03d837a
--- /dev/null
+++ b/examples/declarative/focus/Core/GridMenu.qml
@@ -0,0 +1,54 @@
+import Qt 4.6
+
+FocusScope {
+ property alias interactive: gridView.interactive
+
+ onWantsFocusChanged: if (wantsFocus) mainView.state = ""
+
+ Rectangle {
+ clip: true; anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#193441" }
+ GradientStop { position: 1.0; color: Qt.darker("#193441") }
+ }
+
+ GridView {
+ id: gridView; cellWidth: 152; cellHeight: 152; focus: true
+ x: 20; width: parent.width - 40; height: parent.height
+ model: 12
+ KeyNavigation.down: listViews
+ KeyNavigation.left: contextMenu
+
+ delegate: Item {
+ id: container; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Rectangle {
+ id: content
+ color: "transparent"; smooth: true
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10
+ Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
+ }
+
+ MouseArea {
+ id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ onClicked: {
+ GridView.view.currentIndex = index
+ container.focus = true
+ gridMenu.focus = true
+ mainView.focus = true
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.focus == true
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml
new file mode 100644
index 0000000..b7e067a
--- /dev/null
+++ b/examples/declarative/focus/Core/ListViewDelegate.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Component {
+ Item {
+ id: container
+ x: 5; width: ListView.view.width - 10; height: 60
+
+ Rectangle {
+ id: content
+ color: "transparent"; smooth: true
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 10; radius: 10
+ Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Text {
+ text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent
+ font.pixelSize: 14
+ }
+ }
+
+ MouseArea {
+ id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ onClicked: {
+ ListView.view.currentIndex = index
+ container.focus = true
+ ListView.view.focus = true
+ listViews.focus = true
+ mainView.focus = true
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.focus == true
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml
new file mode 100644
index 0000000..3cc4836
--- /dev/null
+++ b/examples/declarative/focus/Core/ListViews.qml
@@ -0,0 +1,47 @@
+import Qt 4.6
+
+FocusScope {
+ clip: true
+
+ onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews"
+
+ ListView {
+ id: list1
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; focus: true; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ ListView {
+ id: list2
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ ListView {
+ id: list3
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list2
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ Rectangle { width: parent.width; height: 1; color: "#D1DBBD" }
+ Rectangle {
+ y: 1; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#3E606F" }
+ GradientStop { position: 1.0; color: "transparent" }
+ }
+ }
+ Rectangle {
+ y: parent.height - 10; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#3E606F" }
+ GradientStop { position: 0.0; color: "transparent" }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/images/arrow.png b/examples/declarative/focus/Core/images/arrow.png
new file mode 100644
index 0000000..14978c2
--- /dev/null
+++ b/examples/declarative/focus/Core/images/arrow.png
Binary files differ
diff --git a/examples/declarative/focus/Core/images/qt-logo.png b/examples/declarative/focus/Core/images/qt-logo.png
new file mode 100644
index 0000000..14ddf2a
--- /dev/null
+++ b/examples/declarative/focus/Core/images/qt-logo.png
Binary files differ
diff --git a/examples/declarative/focus/Core/qmldir b/examples/declarative/focus/Core/qmldir
new file mode 100644
index 0000000..0460d9c
--- /dev/null
+++ b/examples/declarative/focus/Core/qmldir
@@ -0,0 +1,4 @@
+ContextMenu ContextMenu.qml
+GridMenu GridMenu.qml
+ListViews Listviews.qml
+ListViewDelegate ListViewDelegate.qml
diff --git a/examples/declarative/focus/focus.qml b/examples/declarative/focus/focus.qml
new file mode 100644
index 0000000..a8dc3c8
--- /dev/null
+++ b/examples/declarative/focus/focus.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+import "Core" 1.0
+
+Rectangle {
+ id: window; width: 800; height: 480; color: "#3E606F"
+
+ FocusScope {
+ id: mainView; focus: true; width: parent.width; height: parent.height
+
+ GridMenu {
+ id: gridMenu; focus: true
+ width: parent.width; height: 320; interactive: parent.wantsFocus
+ }
+
+ ListViews { id: listViews; y: 320; width: parent.width; height: 320 }
+
+ Rectangle { id: shade; color: "black"; opacity: 0; anchors.fill: parent }
+
+ states: State {
+ name: "showListViews"
+ PropertyChanges { target: gridMenu; y: -160 }
+ PropertyChanges { target: listViews; y: 160 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "y"; duration: 600; easing.type: "OutQuint" }
+ }
+ }
+
+ Image {
+ source: "Core/images/arrow.png"; rotation: 90; anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 }
+ onClicked: window.state = "contextMenuOpen"
+ }
+ }
+
+ ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
+
+ states: State {
+ name: "contextMenuOpen"; when: !mainView.wantsFocus
+ PropertyChanges { target: contextMenu; x: 0; open: true }
+ PropertyChanges { target: mainView; x: 130 }
+ PropertyChanges { target: shade; opacity: 0.25 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: "OutQuint" }
+ }
+}
diff --git a/examples/declarative/widgets/MyWidgets/qmldir b/examples/declarative/widgets/MyWidgets/qmldir
new file mode 100644
index 0000000..dc1d10e
--- /dev/null
+++ b/examples/declarative/widgets/MyWidgets/qmldir
@@ -0,0 +1 @@
+plugin mywidgetsplugin
diff --git a/examples/declarative/widgets/mywidgets.cpp b/examples/declarative/widgets/mywidgets.cpp
new file mode 100644
index 0000000..e17240d
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtGui/QGraphicsProxyWidget>
+#include <QtGui/QPushButton>
+#include <QDebug>
+
+class MyPushButton : public QGraphicsProxyWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+
+public:
+ MyPushButton(QGraphicsItem* parent = 0)
+ : QGraphicsProxyWidget(parent)
+ {
+ widget = new QPushButton("MyPushButton");
+ widget->setAttribute(Qt::WA_NoSystemBackground);
+ setWidget(widget);
+
+ QObject::connect(widget, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool)));
+ }
+
+ QString text() const
+ {
+ return widget->text();
+ }
+
+ void setText(const QString& text)
+ {
+ if (text != widget->text()) {
+ widget->setText(text);
+ emit textChanged();
+ }
+ }
+
+Q_SIGNALS:
+ void clicked(bool);
+ void textChanged();
+
+private:
+ QPushButton *widget;
+};
+
+class MyWidgetsPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<MyPushButton>(uri, 1, 0, "MyPushButton");
+ }
+};
+
+#include "mywidgets.moc"
+
+QML_DECLARE_TYPE(MyPushButton)
+
+Q_EXPORT_PLUGIN2(mywidgetsplugin, MyWidgetsPlugin);
diff --git a/examples/declarative/widgets/mywidgets.pro b/examples/declarative/widgets/mywidgets.pro
new file mode 100644
index 0000000..258edb1
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.pro
@@ -0,0 +1,19 @@
+TEMPLATE = lib
+DESTDIR = MyWidgets
+TARGET = mywidgetsplugin
+CONFIG += qt plugin
+QT += declarative
+VERSION = 1.0.0
+
+SOURCES += mywidgets.cpp
+
+sources.files += mywidgets.pro mywidgets.cpp mywidgets.qml
+
+sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+
+target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+
+INSTALLS += sources target
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+
diff --git a/examples/declarative/widgets/mywidgets.qml b/examples/declarative/widgets/mywidgets.qml
new file mode 100644
index 0000000..b1efed4
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.qml
@@ -0,0 +1,53 @@
+import Qt 4.6
+import "MyWidgets" 1.0
+
+Rectangle {
+ id: window
+ width: 640; height: 480; color: palette.window
+
+ property int margin: 30
+
+ SystemPalette { id: palette }
+
+ MyPushButton {
+ id: button1; x: margin; y: margin; text: "Right"; onClicked: window.state = "right"
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ MyPushButton {
+ id: button2; x: margin; y: margin + 30; text: "Bottom"; onClicked: window.state = "bottom"
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ MyPushButton {
+ id: button3; x: margin; y: margin + 60; text: "Quit"; onClicked: Qt.quit()
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ states: [
+ State {
+ name: "right"
+ PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" }
+ PropertyChanges { target: button2; x: window.width - width - margin }
+ PropertyChanges { target: button3; x: window.width - width - margin }
+ PropertyChanges { target: window; color: Qt.darker(palette.window) }
+ },
+ State {
+ name: "bottom"
+ PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges {
+ target: button2; x: button1.x + button1.width + 10; y: window.height - height - margin; rotation: 180
+ text: "Top"; onClicked: window.state = ""
+ }
+ PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges { target: window; color: Qt.lighter(palette.window) }
+ }
+ ]
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "x,y,rotation"; duration: 600; easing.type: "OutQuad" }
+ ColorAnimation { target: window; duration: 600 }
+ }
+ }
+}