From 1cca48fb548a484ea98d7ff23ecda5c0b2d403f0 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 19 Mar 2010 13:52:16 +0100 Subject: [PATCH] Added a wizard for QML Runtime Plug-ins. --- .../templates/wizards/qml-runtime/object.cpp | 63 +++++++++++++++++++ .../templates/wizards/qml-runtime/object.h | 62 ++++++++++++++++++ .../templates/wizards/qml-runtime/plugin.cpp | 52 +++++++++++++++ .../templates/wizards/qml-runtime/plugin.h | 56 +++++++++++++++++ .../templates/wizards/qml-runtime/project.pro | 18 ++++++ .../templates/wizards/qml-runtime/qmldir | 1 + .../templates/wizards/qml-runtime/wizard.xml | 59 +++++++++++++++++ 7 files changed, 311 insertions(+) create mode 100644 share/qtcreator/templates/wizards/qml-runtime/object.cpp create mode 100644 share/qtcreator/templates/wizards/qml-runtime/object.h create mode 100644 share/qtcreator/templates/wizards/qml-runtime/plugin.cpp create mode 100644 share/qtcreator/templates/wizards/qml-runtime/plugin.h create mode 100644 share/qtcreator/templates/wizards/qml-runtime/project.pro create mode 100644 share/qtcreator/templates/wizards/qml-runtime/qmldir create mode 100644 share/qtcreator/templates/wizards/qml-runtime/wizard.xml diff --git a/share/qtcreator/templates/wizards/qml-runtime/object.cpp b/share/qtcreator/templates/wizards/qml-runtime/object.cpp new file mode 100644 index 00000000000..f2d9eb39d08 --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/object.cpp @@ -0,0 +1,63 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include +#include + +#include "%ObjectName%.h" + +%ObjectName%::%ObjectName%(QObject *parent): + QObject(parent) +{ + timer = new QTimer(this); + timer->setInterval(750); + connect(timer, SIGNAL(timeout()), this, SLOT(timerFired())); + timer->start(); +} + +QString %ObjectName%::text() const +{ + return theText; +} + +void %ObjectName%::setText(const QString &text) +{ + if (theText != text) { + theText = text; + emit textChanged(theText); + } +} + +void %ObjectName%::timerFired() +{ + QTime t = QTime::currentTime(); + setText(t.toString(QLatin1String("HH:mm:ss"))); +} + +QML_DECLARE_TYPE(%ObjectName%); diff --git a/share/qtcreator/templates/wizards/qml-runtime/object.h b/share/qtcreator/templates/wizards/qml-runtime/object.h new file mode 100644 index 00000000000..50898b454ce --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/object.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef EXAMPLEITEM_H +#define EXAMPLEITEM_H + +#include +#include +#include + +class %ObjectName% : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + +public: + %ObjectName%(QObject *parent = 0); + + QString text() const; + void setText(const QString &text); + +signals: + void textChanged(const QString &newText); + +private slots: + void timerFired(); + +private: + QString theText; + QTimer *timer; + + Q_DISABLE_COPY(%ObjectName%) +}; + +#endif // EXAMPLEITEM_H diff --git a/share/qtcreator/templates/wizards/qml-runtime/plugin.cpp b/share/qtcreator/templates/wizards/qml-runtime/plugin.cpp new file mode 100644 index 00000000000..ec2a0a1d50e --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/plugin.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 demonstration applications 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 "%ProjectName%.h" +#include "%ObjectName%.h" + +void %ProjectName%::registerTypes(const char *uri) +{ + Q_UNUSED(uri); + + QML_REGISTER_TYPE(%ProjectName%,1,0,%ObjectName%,%ObjectName%); +} + +Q_EXPORT_PLUGIN(%ProjectName%); diff --git a/share/qtcreator/templates/wizards/qml-runtime/plugin.h b/share/qtcreator/templates/wizards/qml-runtime/plugin.h new file mode 100644 index 00000000000..d42a3c51239 --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/plugin.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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 demonstration applications 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$ +** +****************************************************************************/ + +#ifndef EXAMPLECOREPLUGIN_H +#define EXAMPLECOREPLUGIN_H + +#include +#include + +class %ProjectName% : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + +public: + void registerTypes(const char *uri); +}; + +#endif // EXAMPLECOREPLUGIN_H diff --git a/share/qtcreator/templates/wizards/qml-runtime/project.pro b/share/qtcreator/templates/wizards/qml-runtime/project.pro new file mode 100644 index 00000000000..72bb0c1e0e3 --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/project.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +TARGET = %ProjectName% +QT += declarative +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +DESTDIR = %ProjectName% + +# Input +SOURCES += \ + %ProjectName%.cpp \ + %ObjectName%.cpp + +OTHER_FILES=%ProjectName%/qmldir + +HEADERS += \ + %ProjectName%.h \ + %ObjectName%.h diff --git a/share/qtcreator/templates/wizards/qml-runtime/qmldir b/share/qtcreator/templates/wizards/qml-runtime/qmldir new file mode 100644 index 00000000000..ee07ff6b101 --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/qmldir @@ -0,0 +1 @@ +plugin %ProjectName% diff --git a/share/qtcreator/templates/wizards/qml-runtime/wizard.xml b/share/qtcreator/templates/wizards/qml-runtime/wizard.xml new file mode 100644 index 00000000000..14db77f70e3 --- /dev/null +++ b/share/qtcreator/templates/wizards/qml-runtime/wizard.xml @@ -0,0 +1,59 @@ + + + + Creates a plug-in for the QML runtime. + QML Runtime Plug-in + QML Runtime Plug-in + + + + + + + + + + QML Runtime Plug-in Parameters + + + + Example Object Class-name: + + +