diff --git a/share/qtcreator/templates/wizards/qml-extension/object.cpp b/share/qtcreator/templates/wizards/qml-extension/object.cpp index 78db2a4d3df933c65df421c67593b62b9db96102..0f9ed3e7bb019146e6eded4e5b9dc0dc2d45a383 100644 --- a/share/qtcreator/templates/wizards/qml-extension/object.cpp +++ b/share/qtcreator/templates/wizards/qml-extension/object.cpp @@ -1,11 +1,17 @@ #include "%ObjectName:l%.%CppHeaderSuffix%" -#include <QtCore/QTime> #include <QtDeclarative/qdeclarative.h> -%ObjectName%::%ObjectName%(QObject *parent): - QObject(parent) +%ObjectName%::%ObjectName%(QDeclarativeItem *parent): + QDeclarativeItem(parent) { + // By default, QDeclarativeItem does not draw anything. If you subclass + // QDeclarativeItem to create a visual item, you will need to uncomment the + // following line: + + // setFlag(ItemHasNoContents, false); } -QML_DECLARE_TYPE(%ObjectName%); +%ObjectName%::~%ObjectName%() +{ +} diff --git a/share/qtcreator/templates/wizards/qml-extension/object.h b/share/qtcreator/templates/wizards/qml-extension/object.h index e4190443e444f3b2aa5cb6595bf7a5ab12672a20..054174b20e406f5cf34bd26856c7e8baa3ac010d 100644 --- a/share/qtcreator/templates/wizards/qml-extension/object.h +++ b/share/qtcreator/templates/wizards/qml-extension/object.h @@ -1,17 +1,18 @@ #ifndef %ObjectName:u%_H #define %ObjectName:u%_H -#include <QtCore/QObject> -#include <QtCore/QString> -#include <QtCore/QTimer> +#include <QtDeclarative/QDeclarativeItem> -class %ObjectName% : public QObject +class %ObjectName% : public QDeclarativeItem { Q_OBJECT Q_DISABLE_COPY(%ObjectName%) public: - %ObjectName%(QObject *parent = 0); + %ObjectName%(QDeclarativeItem *parent = 0); + ~%ObjectName%(); }; +QML_DECLARE_TYPE(%ObjectName%) + #endif // %ObjectName:u%_H diff --git a/share/qtcreator/templates/wizards/qml-extension/plugin.cpp b/share/qtcreator/templates/wizards/qml-extension/plugin.cpp index 0d97d3d2080e21820f2bd6379d53525f705eefd3..5e86f2463a12f9db3138899c315e417f7931d1d2 100644 --- a/share/qtcreator/templates/wizards/qml-extension/plugin.cpp +++ b/share/qtcreator/templates/wizards/qml-extension/plugin.cpp @@ -1,11 +1,11 @@ -#include "%ProjectName:l%.%CppHeaderSuffix%" +#include "%ProjectName:l%_plugin.%CppHeaderSuffix%" #include "%ObjectName:l%.%CppHeaderSuffix%" #include <QtDeclarative/qdeclarative.h> -void %ProjectName%::registerTypes(const char *uri) +void %ProjectName%Plugin::registerTypes(const char *uri) { qmlRegisterType<%ObjectName%>(uri, 1, 0, "%ObjectName%"); } -Q_EXPORT_PLUGIN(%ProjectName%); +Q_EXPORT_PLUGIN2(%ProjectName%, %ProjectName%Plugin) diff --git a/share/qtcreator/templates/wizards/qml-extension/plugin.h b/share/qtcreator/templates/wizards/qml-extension/plugin.h index 1ae9c559ec9314da57bca8fcc671562f0933347e..8600532f3c29ac7d479ff689e04f2beac8a2df54 100644 --- a/share/qtcreator/templates/wizards/qml-extension/plugin.h +++ b/share/qtcreator/templates/wizards/qml-extension/plugin.h @@ -1,9 +1,9 @@ -#ifndef %ProjectName:u%_H -#define %ProjectName:u%_H +#ifndef %ProjectName:u%_PLUGIN_H +#define %ProjectName:u%_PLUGIN_H #include <QtDeclarative/QDeclarativeExtensionPlugin> -class %ProjectName% : public QDeclarativeExtensionPlugin +class %ProjectName%Plugin : public QDeclarativeExtensionPlugin { Q_OBJECT @@ -11,4 +11,4 @@ public: void registerTypes(const char *uri); }; -#endif // %ProjectName:u%_H +#endif // %ProjectName:u%_PLUGIN_H diff --git a/share/qtcreator/templates/wizards/qml-extension/project.pro b/share/qtcreator/templates/wizards/qml-extension/project.pro index 800dbffdf88806c7fef0ac1695789d53eafcd3a2..e7f123beee6cb78e5402e23114c74f2ecbc372db 100644 --- a/share/qtcreator/templates/wizards/qml-extension/project.pro +++ b/share/qtcreator/templates/wizards/qml-extension/project.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -TARGET = %ProjectName% +TARGET = %ProjectName% QT += declarative CONFIG += qt plugin @@ -7,11 +7,11 @@ TARGET = $$qtLibraryTarget($$TARGET) # Input SOURCES += \ - %ProjectName:l%.%CppSourceSuffix% \ + %ProjectName:l%_plugin.%CppSourceSuffix% \ %ObjectName:l%.%CppSourceSuffix% -OTHER_FILES=qmldir - HEADERS += \ - %ProjectName:l%.%CppHeaderSuffix% \ + %ProjectName:l%_plugin.%CppHeaderSuffix% \ %ObjectName:l%.%CppHeaderSuffix% + +OTHER_FILES = qmldir diff --git a/share/qtcreator/templates/wizards/qml-extension/wizard.xml b/share/qtcreator/templates/wizards/qml-extension/wizard.xml index d6d1fdcb285c95330cdb395b220ad5253b8ea24e..6f202f9574fb56b343d61b43faec8c9b8135e1d0 100644 --- a/share/qtcreator/templates/wizards/qml-extension/wizard.xml +++ b/share/qtcreator/templates/wizards/qml-extension/wizard.xml @@ -43,8 +43,8 @@ leave room for the Qt 4 target page. <displaycategory>QML Extension Plugin</displaycategory> <files> <file source="qmldir" target="qmldir"/> - <file source="plugin.h" target="%ProjectName:l%.%CppHeaderSuffix%"/> - <file source="plugin.cpp" target="%ProjectName:l%.%CppSourceSuffix%"/> + <file source="plugin.h" target="%ProjectName:l%_plugin.%CppHeaderSuffix%"/> + <file source="plugin.cpp" target="%ProjectName:l%_plugin.%CppSourceSuffix%"/> <file source="object.h" target="%ObjectName:l%.%CppHeaderSuffix%"/> <file source="object.cpp" target="%ObjectName:l%.%CppSourceSuffix%" openeditor="true"/> <file source="project.pro" target="%ProjectName:l%.pro" openproject="true"/> @@ -53,14 +53,13 @@ leave room for the Qt 4 target page. <fieldpagetitle>Custom QML Extension Plugin Parameters</fieldpagetitle> <fields> <field mandatory="false" name="ObjectName"> - <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9_]+$' defaulttext="ExampleObject"/> + <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9_]+$' defaulttext="MyItem"/> <fielddescription>Object Class-name:</fielddescription> </field> </fields> <validationrules> - <validationrule condition='"%ObjectName%" != "%ProjectName%"'> + <validationrule condition='"%ObjectName%" != "%ProjectName%_plugin"'> <message>The project name and the object class-name cannot be the same.</message> - <message xml:lang='nl'>De naam voor het project en de naam voor de klasse kunnen niet hetzelfde zijn.</message> </validationrule> </validationrules> </wizard>