forked from qt-creator/qt-creator
Transform Qt Quick 2 Extension Plugin wizard to JSON
Change-Id: I0e59219adeb5b3aa08a99da7c0bb657d793ba2e1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#include "%ObjectName:l%.%CppHeaderSuffix%"
|
#include "%{ObjectHdr}"
|
||||||
|
|
||||||
%ObjectName%::%ObjectName%(QQuickItem *parent):
|
%{ObjectName}::%{ObjectName}(QQuickItem *parent)
|
||||||
QQuickItem(parent)
|
: QQuickItem(parent)
|
||||||
{
|
{
|
||||||
// By default, QQuickItem does not draw anything. If you subclass
|
// By default, QQuickItem does not draw anything. If you subclass
|
||||||
// QQuickItem to create a visual item, you will need to uncomment the
|
// QQuickItem to create a visual item, you will need to uncomment the
|
||||||
@@ -10,6 +10,6 @@
|
|||||||
// setFlag(ItemHasContents, true);
|
// setFlag(ItemHasContents, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
%ObjectName%::~%ObjectName%()
|
%{ObjectName}::~%{ObjectName}()
|
||||||
{
|
{
|
||||||
}
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
%{Cpp:LicenseTemplate}\
|
||||||
|
@if '%{Cpp:PragmaOnce}'
|
||||||
|
#pragma once
|
||||||
|
@else
|
||||||
|
#ifndef %{OBJECTGUARD}
|
||||||
|
#define %{OBJECTGUARD}
|
||||||
|
@endif
|
||||||
|
|
||||||
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
class %{ObjectName} : public QQuickItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(%{ObjectName})
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit %{ObjectName}(QQuickItem *parent = nullptr);
|
||||||
|
~%{ObjectName}() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
@if ! '%{Cpp:PragmaOnce}'
|
||||||
|
#endif // %{OBJECTGUARD}
|
||||||
|
@endif
|
@@ -0,0 +1,12 @@
|
|||||||
|
#include "%{PluginHdr}"
|
||||||
|
|
||||||
|
#include "%{ObjectHdr}"
|
||||||
|
|
||||||
|
#include <qqml.h>
|
||||||
|
|
||||||
|
void %{PluginName}::registerTypes(const char *uri)
|
||||||
|
{
|
||||||
|
// @uri %{Uri}
|
||||||
|
qmlRegisterType<%{ObjectName}>(uri, 1, 0, "%{ObjectName}");
|
||||||
|
}
|
||||||
|
|
@@ -1,13 +1,14 @@
|
|||||||
|
%{Cpp:LicenseTemplate}\
|
||||||
@if '%{Cpp:PragmaOnce}'
|
@if '%{Cpp:PragmaOnce}'
|
||||||
#pragma once
|
#pragma once
|
||||||
@else
|
@else
|
||||||
#ifndef %ProjectName:h%_PLUGIN_H
|
#ifndef %{PLUGINGUARD}
|
||||||
#define %ProjectName:h%_PLUGIN_H
|
#define %{PLUGINGUARD}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
#include <QQmlExtensionPlugin>
|
#include <QQmlExtensionPlugin>
|
||||||
|
|
||||||
class %ProjectName:s%Plugin : public QQmlExtensionPlugin
|
class %{PluginName} : public QQmlExtensionPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
||||||
@@ -17,5 +18,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
@if ! '%{Cpp:PragmaOnce}'
|
@if ! '%{Cpp:PragmaOnce}'
|
||||||
#endif // %ProjectName:h%_PLUGIN_H
|
#endif // %{PLUGINGUARD}
|
||||||
@endif
|
@endif
|
@@ -1,26 +1,26 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = %ProjectName%
|
TARGET = %{ProjectName}
|
||||||
QT += qml quick
|
QT += qml quick
|
||||||
CONFIG += plugin c++11
|
CONFIG += plugin c++11
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget($$TARGET)
|
TARGET = $$qtLibraryTarget($$TARGET)
|
||||||
uri = %Uri%
|
uri = %{Uri}
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
SOURCES += \
|
SOURCES += \\
|
||||||
%ProjectName:l%_plugin.%CppSourceSuffix% \
|
%{PluginSrc} \\
|
||||||
%ObjectName:l%.%CppSourceSuffix%
|
%{ObjectSrc}
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \\
|
||||||
%ProjectName:l%_plugin.%CppHeaderSuffix% \
|
%{PluginHdr} \\
|
||||||
%ObjectName:l%.%CppHeaderSuffix%
|
%{ObjectHdr}
|
||||||
|
|
||||||
DISTFILES = qmldir
|
DISTFILES = qmldir
|
||||||
|
|
||||||
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
|
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
|
||||||
copy_qmldir.target = $$OUT_PWD/qmldir
|
copy_qmldir.target = $$OUT_PWD/qmldir
|
||||||
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
|
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
|
||||||
copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
|
copy_qmldir.commands = $(COPY_FILE) "$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)" "$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)"
|
||||||
QMAKE_EXTRA_TARGETS += copy_qmldir
|
QMAKE_EXTRA_TARGETS += copy_qmldir
|
||||||
PRE_TARGETDEPS += $$copy_qmldir.target
|
PRE_TARGETDEPS += $$copy_qmldir.target
|
||||||
}
|
}
|
@@ -0,0 +1,2 @@
|
|||||||
|
module %{Uri}
|
||||||
|
plugin %{ProjectName}
|
@@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ],
|
||||||
|
"id": "M.QtQuick2ExtensionPlugin",
|
||||||
|
"category": "G.Library",
|
||||||
|
"trDescription": "Creates a C++ plugin to load Qt Quick extensions dynamically into applications using the QQmlEngine class.",
|
||||||
|
"trDisplayName": "Qt Quick 2 Extension Plugin",
|
||||||
|
"trDisplayCategory": "Library",
|
||||||
|
"icon": "lib.png",
|
||||||
|
"featuresRequired": [ "QtSupport.Wizards.FeatureQtQuick", "QtSupport.Wizards.FeatureQtQuick.2" ],
|
||||||
|
"enabled": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}",
|
||||||
|
|
||||||
|
"options":
|
||||||
|
[
|
||||||
|
{ "key": "ProjectFile", "value": "%{ProFile}" },
|
||||||
|
{ "key": "ProFile", "value": "%{JS: Util.fileName(value('ProjectDirectory') + '/' + value('ProjectName'), 'pro')}" },
|
||||||
|
{ "key": "PluginBaseFileName", "value": "%{JS: value('ProjectName') + '_plugin'}" },
|
||||||
|
{ "key": "PluginSrc", "value": "%{JS: Cpp.classToFileName(value('PluginBaseFileName'), Util.preferredSuffix('text/x-c++src'))}" },
|
||||||
|
{ "key": "PluginHdr", "value": "%{JS: Cpp.classToFileName(value('PluginBaseFileName'), Util.preferredSuffix('text/x-c++hdr'))}" },
|
||||||
|
{ "key": "ObjectSrc", "value": "%{JS: Cpp.classToFileName(value('ObjectName'), Util.preferredSuffix('text/x-c++src'))}" },
|
||||||
|
{ "key": "ObjectHdr", "value": "%{JS: Cpp.classToFileName(value('ObjectName'), Util.preferredSuffix('text/x-c++hdr'))}" },
|
||||||
|
{ "key": "PluginName", "value": "%{JS: value('ProjectName').charAt(0).toUpperCase() + value('ProjectName').slice(1) + 'Plugin' }" },
|
||||||
|
{ "key": "PLUGINGUARD", "value": "%{JS: Cpp.classToHeaderGuard(value('PluginBaseFileName'), Util.preferredSuffix('text/x-c++hdr'))}" },
|
||||||
|
{ "key": "OBJECTGUARD", "value": "%{JS: Cpp.classToHeaderGuard(value('ObjectName'), Util.preferredSuffix('text/x-c++hdr'))}" }
|
||||||
|
],
|
||||||
|
|
||||||
|
"pages":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"trDisplayName": "Project Location",
|
||||||
|
"trShortTitle": "Location",
|
||||||
|
"typeId": "Project"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Custom Parameters",
|
||||||
|
"trShortTitle": "Details",
|
||||||
|
"typeId": "Fields",
|
||||||
|
"data":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "ObjectName",
|
||||||
|
"trDisplayName": "Object class-name:",
|
||||||
|
"mandatory": true,
|
||||||
|
"type": "LineEdit",
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
"validator": "^[A-Za-z0-9_]+$",
|
||||||
|
"trText": "MyItem"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Uri",
|
||||||
|
"trDisplayName": "URI:",
|
||||||
|
"mandatory": true,
|
||||||
|
"type": "LineEdit",
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
"validator": "^[A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9]+)?(\.[A-Za-z0-9]+([-A-Za-z0-9]*[A-Za-z0-9]+)?)*$",
|
||||||
|
"trText": "com.mycompany.qmlcomponents"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Project Management",
|
||||||
|
"trShortTitle": "Summary",
|
||||||
|
"typeId": "Summary"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"generators":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"typeId": "File",
|
||||||
|
"data":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"source": "project.pro",
|
||||||
|
"target": "%{ProFile}",
|
||||||
|
"openAsProject": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "qmldir",
|
||||||
|
"target": "qmldir"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "plugin.cpp",
|
||||||
|
"target": "%{PluginSrc}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "plugin.h",
|
||||||
|
"target": "%{PluginHdr}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "object.cpp",
|
||||||
|
"target": "%{ObjectSrc}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "object.h",
|
||||||
|
"target": "%{ObjectHdr}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "../git.ignore",
|
||||||
|
"target": ".gitignore",
|
||||||
|
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -1,22 +0,0 @@
|
|||||||
@if '%{Cpp:PragmaOnce}'
|
|
||||||
#pragma once
|
|
||||||
@else
|
|
||||||
#ifndef %ObjectName:u%_H
|
|
||||||
#define %ObjectName:u%_H
|
|
||||||
@endif
|
|
||||||
|
|
||||||
#include <QQuickItem>
|
|
||||||
|
|
||||||
class %ObjectName% : public QQuickItem
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_DISABLE_COPY(%ObjectName%)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit %ObjectName%(QQuickItem *parent = nullptr);
|
|
||||||
~%ObjectName%() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
@if ! '%{Cpp:PragmaOnce}'
|
|
||||||
#endif // %ObjectName:u%_H
|
|
||||||
@endif
|
|
@@ -1,11 +0,0 @@
|
|||||||
#include "%ProjectName:l%_plugin.%CppHeaderSuffix%"
|
|
||||||
#include "%ObjectName:l%.%CppHeaderSuffix%"
|
|
||||||
|
|
||||||
#include <qqml.h>
|
|
||||||
|
|
||||||
void %ProjectName:s%Plugin::registerTypes(const char *uri)
|
|
||||||
{
|
|
||||||
// @uri %Uri%
|
|
||||||
qmlRegisterType<%ObjectName%>(uri, 1, 0, "%ObjectName:c%");
|
|
||||||
}
|
|
||||||
|
|
@@ -1,2 +0,0 @@
|
|||||||
module %Uri%
|
|
||||||
plugin %ProjectName%
|
|
@@ -1,66 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
Custom project wizard configuration example file. Note that by convention,
|
|
||||||
the project file goes last.
|
|
||||||
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|
||||||
leave room for the Qt 4 target page.
|
|
||||||
-->
|
|
||||||
<wizard version="1" kind="project"
|
|
||||||
class="qmakeproject" firstpage="10"
|
|
||||||
id="QtQuick2ExtensionPlugin" category="G.Library"
|
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.2">
|
|
||||||
<icon>lib.png</icon>
|
|
||||||
<description>Creates a C++ plugin to load extensions dynamically into applications using the QQmlEngine class. Requires Qt 5.0 or newer.</description>
|
|
||||||
<displayname>Qt Quick 2 Extension Plugin</displayname>
|
|
||||||
<displaycategory>Library</displaycategory>
|
|
||||||
<files>
|
|
||||||
<file source="qmldir" target="qmldir"/>
|
|
||||||
<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"/>
|
|
||||||
</files>
|
|
||||||
<!-- Create a 2nd wizard page with parameters -->
|
|
||||||
<fieldpagetitle>Custom QML Extension Plugin Parameters</fieldpagetitle>
|
|
||||||
<fields>
|
|
||||||
<field mandatory="true" name="ObjectName">
|
|
||||||
<fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9_]+$' defaulttext="MyItem"/>
|
|
||||||
<fielddescription>Object class-name:</fielddescription>
|
|
||||||
</field>
|
|
||||||
<field mandatory="true" name="Uri">
|
|
||||||
<fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9]+)?(\.[A-Za-z0-9]+([-A-Za-z0-9]*[A-Za-z0-9]+)?)*$' defaulttext="com.mycompany.qmlcomponents"/>
|
|
||||||
<fielddescription>URI:</fielddescription>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
<validationrules>
|
|
||||||
<validationrule condition='"%ObjectName%" != "%ProjectName%_plugin"'>
|
|
||||||
<message>The project name and the object class-name cannot be the same.</message>
|
|
||||||
</validationrule>
|
|
||||||
</validationrules>
|
|
||||||
</wizard>
|
|
Reference in New Issue
Block a user