2010-12-07 12:24:30 +01:00
|
|
|
#include "%PluginName:l%plugin.%CppHeaderSuffix%"
|
|
|
|
|
#include "%PluginName:l%constants.%CppHeaderSuffix%"
|
2010-05-05 18:40:30 +02:00
|
|
|
|
2010-05-06 11:55:53 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2010-07-13 14:35:37 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2010-05-06 11:55:53 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QMenu>
|
2011-01-24 15:32:06 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
2010-05-06 11:55:53 +02:00
|
|
|
|
2010-05-05 18:40:30 +02:00
|
|
|
using namespace %PluginName%::Internal;
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
%PluginName%Plugin::%PluginName%Plugin()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Create your members
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
%PluginName%Plugin::~%PluginName%Plugin()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Unregister objects from the plugin manager's object pool
|
|
|
|
|
// Delete members
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
bool %PluginName%Plugin::initialize(const QStringList &arguments, QString *errorString)
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Register objects in the plugin manager's object pool
|
|
|
|
|
// Load settings
|
|
|
|
|
// Add actions to menus
|
2011-10-10 08:32:07 +02:00
|
|
|
// Connect to other plugins' signals
|
2013-10-07 13:34:40 +02:00
|
|
|
// In the initialize function, a plugin can be sure that the plugins it
|
2011-10-10 08:32:07 +02:00
|
|
|
// depends on have initialized their members.
|
2010-05-06 11:55:53 +02:00
|
|
|
|
|
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(errorString)
|
|
|
|
|
|
2016-02-16 10:13:40 +01:00
|
|
|
QAction *action = new QAction(tr("%PluginName% Action"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
|
2010-07-13 14:35:37 +02:00
|
|
|
Core::Context(Core::Constants::C_GLOBAL));
|
2010-05-06 11:55:53 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
|
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(triggerAction()));
|
|
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
|
2010-05-06 11:55:53 +02:00
|
|
|
menu->menu()->setTitle(tr("%PluginName%"));
|
|
|
|
|
menu->addAction(cmd);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
|
2010-05-06 11:55:53 +02:00
|
|
|
|
2010-05-05 18:40:30 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
void %PluginName%Plugin::extensionsInitialized()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Retrieve objects from the plugin manager's object pool
|
2013-10-07 13:34:40 +02:00
|
|
|
// In the extensionsInitialized function, a plugin can be sure that all
|
2011-10-10 08:32:07 +02:00
|
|
|
// plugins that depend on it are completely initialized.
|
2010-05-05 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag %PluginName%Plugin::aboutToShutdown()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Save settings
|
|
|
|
|
// Disconnect from signals that are not needed during shutdown
|
2010-07-13 14:35:37 +02:00
|
|
|
// Hide UI (if you add UI that is not in the main window directly)
|
|
|
|
|
return SynchronousShutdown;
|
2010-05-05 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-07 12:24:30 +01:00
|
|
|
void %PluginName%Plugin::triggerAction()
|
2010-05-06 11:55:53 +02:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QMessageBox::information(Core::ICore::mainWindow(),
|
2016-02-16 10:13:40 +01:00
|
|
|
tr("Action Triggered"),
|
2010-05-06 11:55:53 +02:00
|
|
|
tr("This is an action from %PluginName%."));
|
|
|
|
|
}
|