From b5c05a6fc70ecbfb87071bc73b128b5b0e1dded0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pertti=20Kellom=C3=A4ki?= Date: Fri, 28 Jan 2011 15:16:49 +0200 Subject: [PATCH] Changes: Add examples of using qdeclarativebooster with qmake and cmake. RevBy: TrustMe --- .../boosted-qml/with-cmake/CMakeLists.txt | 9 +++++ examples/boosted-qml/with-cmake/README | 5 +++ examples/boosted-qml/with-cmake/main.cpp | 37 ++++++++++++++++++ examples/boosted-qml/with-cmake/main.qml | 12 ++++++ examples/boosted-qml/with-qmake/README | 5 +++ examples/boosted-qml/with-qmake/main.cpp | 38 +++++++++++++++++++ examples/boosted-qml/with-qmake/main.qml | 12 ++++++ .../boosted-qml/with-qmake/with-qmake.pro | 9 +++++ 8 files changed, 127 insertions(+) create mode 100644 examples/boosted-qml/with-cmake/CMakeLists.txt create mode 100644 examples/boosted-qml/with-cmake/README create mode 100644 examples/boosted-qml/with-cmake/main.cpp create mode 100644 examples/boosted-qml/with-cmake/main.qml create mode 100644 examples/boosted-qml/with-qmake/README create mode 100644 examples/boosted-qml/with-qmake/main.cpp create mode 100644 examples/boosted-qml/with-qmake/main.qml create mode 100644 examples/boosted-qml/with-qmake/with-qmake.pro diff --git a/examples/boosted-qml/with-cmake/CMakeLists.txt b/examples/boosted-qml/with-cmake/CMakeLists.txt new file mode 100644 index 0000000..3fd4512 --- /dev/null +++ b/examples/boosted-qml/with-cmake/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8) +find_package(Qt4 4.7.0 REQUIRED) +include(${QT_USE_FILE}) +include(FindPkgConfig) +pkg_check_modules(QDECLARATIVE_BOOSTABLE REQUIRED qdeclarative-boostable) +add_definitions(${QDECLARATIVE_BOOSTABLE_CFLAGS}) +link_libraries(${QDECLARATIVE_BOOSTABLE_LDFLAGS} ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY}) +add_executable(qml-helloworld main.cpp) + diff --git a/examples/boosted-qml/with-cmake/README b/examples/boosted-qml/with-cmake/README new file mode 100644 index 0000000..95e29e5 --- /dev/null +++ b/examples/boosted-qml/with-cmake/README @@ -0,0 +1,5 @@ +This example shows how to build a booster-enabled QML Helloworld with cmake. + +Build the example: cmake . && make +Run the example without booster: ./qml-helloworld +Run the example with booster: invoker --type=d ./qml-helloworld diff --git a/examples/boosted-qml/with-cmake/main.cpp b/examples/boosted-qml/with-cmake/main.cpp new file mode 100644 index 0000000..de95bdf --- /dev/null +++ b/examples/boosted-qml/with-cmake/main.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include + +Q_DECL_EXPORT int main(int argc, char **argv) +{ + QApplication *app = MDeclarativeCache::qApplication(argc, argv); + QDeclarativeView *window = MDeclarativeCache::qDeclarativeView(); + + // Use MDeclarativeCache::applicationDirPath() + // instead of QCoreApplication::applicationDirPath() + // because the latter does not work with the booster. + QDir::setCurrent(MDeclarativeCache::applicationDirPath()); + + window->setSource(QUrl::fromLocalFile("main.qml")); + window->showFullScreen(); + return app->exec(); +} + diff --git a/examples/boosted-qml/with-cmake/main.qml b/examples/boosted-qml/with-cmake/main.qml new file mode 100644 index 0000000..923a67c --- /dev/null +++ b/examples/boosted-qml/with-cmake/main.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Rectangle { + width: 854 + height: 480 + Text { + id: text1 + anchors.centerIn: parent + text: "Hello Boosted QML World!" + font.pixelSize: 60 + } +} diff --git a/examples/boosted-qml/with-qmake/README b/examples/boosted-qml/with-qmake/README new file mode 100644 index 0000000..e691db8 --- /dev/null +++ b/examples/boosted-qml/with-qmake/README @@ -0,0 +1,5 @@ +This example shows how to build a booster-enabled QML Helloworld with qmake. + +Build the example: qmake && make +Run the example without booster: ./qml-helloworld +Run the example with booster: invoker --type=d ./qml-helloworld diff --git a/examples/boosted-qml/with-qmake/main.cpp b/examples/boosted-qml/with-qmake/main.cpp new file mode 100644 index 0000000..585da76 --- /dev/null +++ b/examples/boosted-qml/with-qmake/main.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include + +Q_DECL_EXPORT int main(int argc, char **argv) +{ + QApplication *app = MDeclarativeCache::qApplication(argc, argv); + QDeclarativeView *window = MDeclarativeCache::qDeclarativeView(); + + // Use MDeclarativeCache::applicationDirPath() + // instead of QCoreApplication::applicationDirPath() + // because the latter does not work with the booster. + QDir::setCurrent(MDeclarativeCache::applicationDirPath()); + + window->setSource(QUrl::fromLocalFile("main.qml")); + + window->showFullScreen(); + return app->exec(); +} + diff --git a/examples/boosted-qml/with-qmake/main.qml b/examples/boosted-qml/with-qmake/main.qml new file mode 100644 index 0000000..923a67c --- /dev/null +++ b/examples/boosted-qml/with-qmake/main.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Rectangle { + width: 854 + height: 480 + Text { + id: text1 + anchors.centerIn: parent + text: "Hello Boosted QML World!" + font.pixelSize: 60 + } +} diff --git a/examples/boosted-qml/with-qmake/with-qmake.pro b/examples/boosted-qml/with-qmake/with-qmake.pro new file mode 100644 index 0000000..d810ecd --- /dev/null +++ b/examples/boosted-qml/with-qmake/with-qmake.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +QT += declarative + +CONFIG += qdeclarative-boostable + +TARGET = qml-helloworld +SOURCES += main.cpp + +OTHER_FILES += main.qml