diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-29 03:11:10 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-29 03:11:10 (GMT) |
commit | b1af9212cb0f7fe85458677aee8de3ad94a8883a (patch) | |
tree | 6d8789c1b8d96545a93cf1470778391b0adcf7b9 /examples | |
parent | c0c89664feec6fa6d70b4ffb44a8cfdac9de532f (diff) | |
parent | 3a1a7cf24f54b3ef23accc777f10c6ebba12f37b (diff) | |
download | Qt-b1af9212cb0f7fe85458677aee8de3ad94a8883a.zip Qt-b1af9212cb0f7fe85458677aee8de3ad94a8883a.tar.gz Qt-b1af9212cb0f7fe85458677aee8de3ad94a8883a.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/follow/follow.qml | 12 | ||||
-rw-r--r-- | examples/declarative/loader/loader.qrc | 1 | ||||
-rw-r--r-- | examples/declarative/loader/main.cpp | 118 |
3 files changed, 128 insertions, 3 deletions
diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml index b906c12..59561b3 100644 --- a/examples/declarative/follow/follow.qml +++ b/examples/declarative/follow/follow.qml @@ -25,6 +25,7 @@ Rect { Rect { color: "#ff0000" x: Rect.width; width: Rect.width; height: 20 + y: 200 y: Follow { source: Rect.y; velocity: 200 } } Text { x: Rect.width; y: 220; text: "Velocity" } @@ -32,8 +33,15 @@ Rect { // Spring Rect { color: "#ff0000" - x: Rect.width * 2; width: Rect.width; height: 20 - y: Follow { source: Rect.y; spring: 1.2; damping: 0.1 } + x: Rect.width * 2; width: Rect.width/2; height: 20 + y: 200 + y: Follow { source: Rect.y; spring: 1.0; damping: 0.2 } + } + Rect { + color: "#880000" + x: Rect.width * 2.5; width: Rect.width/2; height: 20 + y: 200 + y: Follow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object } Text { x: Rect.width * 2; y: 220; text: "Spring" } diff --git a/examples/declarative/loader/loader.qrc b/examples/declarative/loader/loader.qrc index bdbcd5c..73ee253 100644 --- a/examples/declarative/loader/loader.qrc +++ b/examples/declarative/loader/loader.qrc @@ -4,5 +4,6 @@ <file>Browser.qml</file> <file>images/fileopen.png</file> <file>images/up.png</file> + <file>Button.qml</file> </qresource> </RCC> diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp index 762212b..070ba75 100644 --- a/examples/declarative/loader/main.cpp +++ b/examples/declarative/loader/main.cpp @@ -2,6 +2,12 @@ #include <QUrl> #include <QFileInfo> #include <QDir> +#include <QPlainTextEdit> +#include <QAction> +#include <QVBoxLayout> +#include <QMainWindow> +#include <QMenuBar> +#include <QDebug> #include <QmlContext> #include <QmlComponent> #include <qfxview.h> @@ -9,6 +15,61 @@ QFxView *canvas = 0; +class Logger : public QWidget +{ + Q_OBJECT +public: + Logger() : QWidget() { + logText = new QPlainTextEdit; + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(logText); + layout->setMargin(0); + setLayout(layout); +#ifdef Q_OS_SYMBIAN + QAction *closeAction = new QAction("Close", this); + closeAction->setSoftKeyRole(QAction::BackSoftKey); + connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); + + QList<QAction*> softKeys; + softKeys.append(closeAction); + setSoftKeys(softKeys); +#endif + } + + void append(const QString &text) { + logText->appendPlainText(text); + } + + static Logger *instance() { + static Logger *logger = 0; + if (!logger) + logger = new Logger(); + return logger; + } + +private: + QPlainTextEdit *logText; +}; + +void myMessageOutput(QtMsgType type, const char *msg) +{ + switch (type) { + case QtDebugMsg: + Logger::instance()->append(QString(msg)); + break; + case QtWarningMsg: + Logger::instance()->append(QString(msg)); + break; + case QtCriticalMsg: + Logger::instance()->append(QString(msg)); + break; + case QtFatalMsg: + Logger::instance()->append(QString(msg)); + abort(); + } +} + + class QmlLauncher : public QObject { Q_OBJECT @@ -51,20 +112,75 @@ public: canvas->setUrl(fileName); canvas->execute(); } + +signals: + void logUpdated(); }; +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + MainWindow() : QMainWindow() {} + + +public slots: + void toggleFullScreen() + { + if (isFullScreen()) { +#ifdef Q_OS_SYMBIAN + showMaximized(); +#else + showNormal(); +#endif + } else { + showFullScreen(); + } + } + + void showLog() + { +#ifdef Q_OS_SYMBIAN + Logger::instance()->showMaximized(); +#else + Logger::instance()->show(); +#endif + } +}; + + int main(int argc, char *argv[]) { + qInstallMsgHandler(myMessageOutput); QApplication app(argc, argv); + MainWindow *mw = new MainWindow; + QmlLauncher *launcher = new QmlLauncher; + QObject::connect(Logger::instance(), SIGNAL(textChanged()), launcher, SIGNAL(logUpdated())); + canvas = new QFxView; + mw->setCentralWidget(canvas); + + QMenuBar *mb = mw->menuBar(); + QAction *showLogAction = new QAction("View Log...", mw); + mb->addAction(showLogAction); + QObject::connect(showLogAction, SIGNAL(triggered()), mw, SLOT(showLog())); + QAction *toggleFSAction = new QAction("Fullscreen", mw); + mb->addAction(toggleFSAction); + QObject::connect(toggleFSAction, SIGNAL(triggered()), mw, SLOT(toggleFullScreen())); + QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("qmlLauncher", launcher); canvas->setUrl(QUrl("qrc:/loader.qml")); +#ifdef Q_OS_SYMBIAN + canvas->setContentResizable(true); + mw->showMaximized(); +#else + mw->show(); +#endif canvas->execute(); - canvas->show(); return app.exec(); } |