Commit 5bab50a9 authored by Nicolas Arnaud-Cormos's avatar Nicolas Arnaud-Cormos Committed by con
Browse files

Update the template for Qt Creator plugin.



Make it more consistant with the current plugins:
 * plugin class use the Plugin template instead of Impl
 * add a pluginconstants.h file
 * use the new pluginspec.in file

Merge-request: 216
Reviewed-by: default avatarcon <qtc-committer@nokia.com>
parent c18dc4d4
<plugin name="%PluginName%" version="0.0.1" compatVersion="0.0.1">
<plugin name=\"%PluginName%\" version=\"0.0.1\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>%VendorName%</vendor>
<copyright>%Copyright%</copyright>
<license>%License%</license>
<description>%Description%</description>
<url>%URL%</url>
<dependencyList>
<dependency name="Core" version="2.1.81"/>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
#include "%PluginName:l%.%CppHeaderSuffix%"
#include "%PluginName:l%plugin.%CppHeaderSuffix%"
#include "%PluginName:l%constants.%CppHeaderSuffix%"
#include <QtPlugin>
......@@ -15,25 +16,20 @@
#include <QMainWindow>
#include <QMenu>
namespace {
const char * const ACTION_ID = "%PluginName%.Action";
const char * const MENU_ID = "%PluginName%.Menu";
}
using namespace %PluginName%::Internal;
%PluginName%Impl::%PluginName%Impl()
%PluginName%Plugin::%PluginName%Plugin()
{
// Create your members
}
%PluginName%Impl::~%PluginName%Impl()
%PluginName%Plugin::~%PluginName%Plugin()
{
// Unregister objects from the plugin manager's object pool
// Delete members
}
bool %PluginName%Impl::initialize(const QStringList &arguments, QString *errorString)
bool %PluginName%Plugin::initialize(const QStringList &arguments, QString *errorString)
{
// Register objects in the plugin manager's object pool
// Load settings
......@@ -47,12 +43,12 @@ bool %PluginName%Impl::initialize(const QStringList &arguments, QString *errorSt
Core::ActionManager *am = Core::ICore::instance()->actionManager();
QAction *action = new QAction(tr("%PluginName% action"), this);
Core::Command *cmd = am->registerAction(action, ACTION_ID,
Core::Command *cmd = am->registerAction(action, Constants::ACTION_ID,
Core::Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
connect(action, SIGNAL(triggered()), this, SLOT(triggerAction()));
Core::ActionContainer *menu = am->createMenu(MENU_ID);
Core::ActionContainer *menu = am->createMenu(Constants::MENU_ID);
menu->menu()->setTitle(tr("%PluginName%"));
menu->addAction(cmd);
am->actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
......@@ -60,14 +56,14 @@ bool %PluginName%Impl::initialize(const QStringList &arguments, QString *errorSt
return true;
}
void %PluginName%Impl::extensionsInitialized()
void %PluginName%Plugin::extensionsInitialized()
{
// Retrieve objects from the plugin manager's object pool
// "In the extensionsInitialized method, a plugin can be sure that all
// plugins that depend on it are completely initialized."
}
ExtensionSystem::IPlugin::ShutdownFlag %PluginName%Impl::aboutToShutdown()
ExtensionSystem::IPlugin::ShutdownFlag %PluginName%Plugin::aboutToShutdown()
{
// Save settings
// Disconnect from signals that are not needed during shutdown
......@@ -75,11 +71,11 @@ ExtensionSystem::IPlugin::ShutdownFlag %PluginName%Impl::aboutToShutdown()
return SynchronousShutdown;
}
void %PluginName%Impl::triggerAction()
void %PluginName%Plugin::triggerAction()
{
QMessageBox::information(Core::ICore::instance()->mainWindow(),
tr("Action triggered"),
tr("This is an action from %PluginName%."));
}
Q_EXPORT_PLUGIN2(%PluginName%, %PluginName%Impl)
Q_EXPORT_PLUGIN2(%PluginName%, %PluginName%Plugin)
......@@ -8,13 +8,13 @@
namespace %PluginName% {
namespace Internal {
class %PluginName%Impl : public ExtensionSystem::IPlugin
class %PluginName%Plugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
public:
%PluginName%Impl();
~%PluginName%Impl();
%PluginName%Plugin();
~%PluginName%Plugin();
bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized();
......
......@@ -5,10 +5,11 @@ DEFINES += %PluginName:u%_LIBRARY
# %PluginName% files
SOURCES += %PluginName:l%.cpp
SOURCES += %PluginName:l%plugin.cpp
HEADERS += %PluginName:l%.h\
%PluginName:l%_global.h
HEADERS += %PluginName:l%plugin.h\
%PluginName:l%_global.h\
%PluginName:l%constants.h
OTHER_FILES = %PluginName%.pluginspec
......
#ifndef %PluginName:u%CONSTANTS_%CppHeaderSuffix:u%
#define %PluginName:u%CONSTANTS_%CppHeaderSuffix:u%
namespace %PluginName% {
namespace Constants {
const char * const ACTION_ID = "%PluginName%.Action";
const char * const MENU_ID = "%PluginName%.Menu";
} // namespace %PluginName%
} // namespace Constants
#endif // %PluginName:u%CONSTANTS_%CppHeaderSuffix:u%
......@@ -43,10 +43,11 @@ leave room for the Qt 4 target page.
<displaycategory>Other Project</displaycategory>
<files>
<file source="myplugin.pro" target="%PluginName:l%.pro" openproject="true"/>
<file source="MyPlugin.pluginspec" target="%PluginName%.pluginspec" openeditor="true"/>
<file source="myplugin.h" target="%PluginName:l%.%CppHeaderSuffix%" openeditor="true"/>
<file source="myplugin.cpp" target="%PluginName:l%.%CppSourceSuffix%" openeditor="true"/>
<file source="MyPlugin.pluginspec.in" target="%PluginName%.pluginspec.in" openeditor="true"/>
<file source="myplugin_global.h" target="%PluginName:l%_global.%CppHeaderSuffix%" openeditor="true"/>
<file source="mypluginconstants.h" target="%PluginName:l%constants.%CppHeaderSuffix%" openeditor="true"/>
<file source="myplugin.h" target="%PluginName:l%plugin.%CppHeaderSuffix%" openeditor="true"/>
<file source="myplugin.cpp" target="%PluginName:l%plugin.%CppSourceSuffix%" openeditor="true"/>
</files>
<!-- Create a 2nd wizard page with parameters -->
<fieldpagetitle>Plugin Information</fieldpagetitle>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment