summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:00:07 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:00:07 (GMT)
commit8d00a0a21f245d15962191e0690d3619735d118b (patch)
tree7aaa66528f0ee40d0d2d885f94835d0f09ea4a68 /examples
parent97cec103793a4b9aae8337ffc2ce9a2bd98fb5fc (diff)
parent508b447075fb852e61ddf88c92c9099dad292747 (diff)
downloadQt-8d00a0a21f245d15962191e0690d3619735d118b.zip
Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.gz
Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.bz2
Merge commit 'qt/master' into kinetic-graphicseffect
Conflicts: src/gui/graphicsview/graphicsview.pri
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/graphicsview/anchorlayout/anchorlayout.pro14
-rw-r--r--examples/graphicsview/anchorlayout/main.cpp108
-rw-r--r--examples/graphicsview/graphicsview.pro3
-rw-r--r--examples/painting/svgviewer/files/bubbles.svg26
-rw-r--r--examples/script/calculator/main.cpp4
-rw-r--r--examples/script/context2d/window.cpp27
-rw-r--r--examples/script/qstetrix/main.cpp4
8 files changed, 158 insertions, 30 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index 197e80f..8367670 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -23,10 +23,10 @@ SUBDIRS = \
widgets \
uitools \
xml \
- script \
multitouch \
gestures
+contains(QT_CONFIG, script): SUBDIRS += script
contains(QT_CONFIG, multimedia):!static: SUBDIRS += multimedia
contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon
contains(QT_CONFIG, webkit): SUBDIRS += webkit
diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro
new file mode 100644
index 0000000..c969c8b
--- /dev/null
+++ b/examples/graphicsview/anchorlayout/anchorlayout.pro
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Tue May 12 15:22:25 2009
+######################################################################
+
+# Input
+SOURCES += main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout
+sources.files = $$SOURCES $$HEADERS $$RESOURCES anchorlayout.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout
+INSTALLS += target sources
+
+TARGET = anchorlayout_example
diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp
new file mode 100644
index 0000000..5427bbf
--- /dev/null
+++ b/examples/graphicsview/anchorlayout/main.cpp
@@ -0,0 +1,108 @@
+#include <QGraphicsWidget>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsAnchorLayout>
+#include <QtGui>
+
+static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
+ const QSizeF &preferred = QSize(150.0, 100.0),
+ const QSizeF &maximum = QSizeF(200.0, 100.0),
+ const QString &name = "0")
+{
+ QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
+ w->setWidget(new QPushButton(name));
+ w->setData(0, name);
+ w->setMinimumSize(minimum);
+ w->setPreferredSize(preferred);
+ w->setMaximumSize(maximum);
+
+ return w;
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QGraphicsScene scene;
+ scene.setSceneRect(0, 0, 800, 480);
+
+ QSizeF min(30, 100);
+ QSizeF pref(210, 100);
+ QSizeF max(300, 100);
+
+ QGraphicsProxyWidget *a = createItem(min, pref, max, "A");
+ QGraphicsProxyWidget *b = createItem(min, pref, max, "B");
+ QGraphicsProxyWidget *c = createItem(min, pref, max, "C");
+ QGraphicsProxyWidget *d = createItem(min, pref, max, "D");
+ QGraphicsProxyWidget *e = createItem(min, pref, max, "E");
+ QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), max, "F");
+ QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), max, "G");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+
+ QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
+ w->setPos(20, 20);
+ w->setLayout(l);
+
+ // vertical
+ l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
+ l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0);
+ l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
+ l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0);
+
+ l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
+ l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0);
+ l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
+ l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0);
+ l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
+ l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
+ l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
+ l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
+
+ l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
+ l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
+
+ l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
+ l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0);
+ l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
+ l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0);
+ l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
+ l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0);
+ l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
+ l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0);
+
+ // horizontal
+ l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+ l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
+ l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
+ l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0);
+ l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
+
+ l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
+ l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+ l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
+ l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
+
+ l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
+ l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+ l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
+ l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+ l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
+ l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
+
+ l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
+ l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0);
+ l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
+ l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0);
+ l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
+ l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0);
+
+ scene.addItem(w);
+ scene.setBackgroundBrush(Qt::darkGreen);
+ QGraphicsView *view = new QGraphicsView(&scene);
+ view->show();
+
+ return app.exec();
+}
diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro
index 7c8e787..627f9d4 100644
--- a/examples/graphicsview/graphicsview.pro
+++ b/examples/graphicsview/graphicsview.pro
@@ -6,7 +6,8 @@ SUBDIRS = \
diagramscene \
dragdroprobot \
padnavigator \
- basicgraphicslayouts
+ basicgraphicslayouts \
+ anchorlayout
contains(QT_CONFIG, qt3support):SUBDIRS += portedcanvas portedasteroids
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= dragdroprobot
diff --git a/examples/painting/svgviewer/files/bubbles.svg b/examples/painting/svgviewer/files/bubbles.svg
index 65867da..9fae8cc 100644
--- a/examples/painting/svgviewer/files/bubbles.svg
+++ b/examples/painting/svgviewer/files/bubbles.svg
@@ -91,56 +91,56 @@
<g transform="translate(200,700)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(315,700)">
<g transform="scale(0.5,0.5)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(80,700)">
<g transform="scale(0.65,0.65)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(255,700)">
<g transform="scale(0.3,0.3)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(565,700)">
<g transform="scale(0.4,0.4)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(715,700)">
<g transform="scale(0.6,0.6)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(645,700)">
<g transform="scale(0.375,0.375)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(555,700)">
<g transform="scale(0.9,0.9)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" />
</g>
@@ -148,28 +148,28 @@
<g transform="scale(0.5,0.5)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(215,700)">
<g transform="scale(0.45,0.45)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(420,700)">
<g transform="scale(0.75,0.75)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(815,700)">
<g transform="scale(0.6,0.6)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
- <animateTransform attributeName="transform" type="translate"
+ <animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" />
</g>
@@ -186,7 +186,7 @@
<circle fill="#a6ce39" cx="0" cy="0" r="33" />
<path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
L -11,22 L -1,12 Z" />
- <animateTransform attributeName="transform" type="rotate" values="0; 360"
+ <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360"
begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(200,375)">
diff --git a/examples/script/calculator/main.cpp b/examples/script/calculator/main.cpp
index d85d0ae..2930a97 100644
--- a/examples/script/calculator/main.cpp
+++ b/examples/script/calculator/main.cpp
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
QScriptEngine engine;
//! [0a]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
//! [2]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QLineEdit *display = qFindChild<QLineEdit*>(ui, "display");
QObject::connect(display, SIGNAL(returnPressed()),
debugWindow, SLOT(show()));
diff --git a/examples/script/context2d/window.cpp b/examples/script/context2d/window.cpp
index 5d3f4df..d70a4f1 100644
--- a/examples/script/context2d/window.cpp
+++ b/examples/script/context2d/window.cpp
@@ -66,7 +66,8 @@ static QString scriptsDir()
//! [0]
Window::Window(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent),
+ m_debugger(0), m_debugWindow(0)
{
m_env = new Environment(this);
QObject::connect(m_env, SIGNAL(scriptError(QScriptValue)),
@@ -107,14 +108,6 @@ Window::Window(QWidget *parent)
this, SLOT(selectScript(QListWidgetItem*)));
//! [1]
-#ifndef QT_NO_SCRIPTTOOLS
- m_debugger = new QScriptEngineDebugger(this);
- m_debugger->attachTo(m_env->engine());
- m_debugWindow = m_debugger->standardWindow();
- m_debugWindow->setWindowModality(Qt::ApplicationModal);
- m_debugWindow->resize(1280, 704);
-#endif
-
setWindowTitle(tr("Context 2D"));
}
@@ -156,8 +149,19 @@ void Window::runScript(const QString &fileName, bool debug)
m_env->reset();
#ifndef QT_NO_SCRIPTTOOLS
- if (debug)
+ if (debug) {
+ if (!m_debugger) {
+ m_debugger = new QScriptEngineDebugger(this);
+ m_debugWindow = m_debugger->standardWindow();
+ m_debugWindow->setWindowModality(Qt::ApplicationModal);
+ m_debugWindow->resize(1280, 704);
+ }
+ m_debugger->attachTo(m_env->engine());
m_debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
+ } else {
+ if (m_debugger)
+ m_debugger->detach();
+ }
#else
Q_UNUSED(debug);
#endif
@@ -165,7 +169,8 @@ void Window::runScript(const QString &fileName, bool debug)
QScriptValue ret = m_env->evaluate(contents, fileName);
#ifndef QT_NO_SCRIPTTOOLS
- m_debugWindow->hide();
+ if (m_debugWindow)
+ m_debugWindow->hide();
#endif
if (ret.isError())
diff --git a/examples/script/qstetrix/main.cpp b/examples/script/qstetrix/main.cpp
index 52cf76f..8e83c7a 100644
--- a/examples/script/qstetrix/main.cpp
+++ b/examples/script/qstetrix/main.cpp
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
engine.globalObject().setProperty("Qt", Qt);
//! [1]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
//! [3]
QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton");
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QObject::connect(debugButton, SIGNAL(clicked()),
debugger.action(QScriptEngineDebugger::InterruptAction),
SIGNAL(triggered()));