2023-11-14 09:09:12 +01:00
|
|
|
%{Cpp:LicenseTemplate}\
|
2020-01-02 16:31:23 +01:00
|
|
|
#include "%{HdrFileName}"
|
|
|
|
|
#include "%{ConstantsHdrFileName}"
|
2023-11-13 16:15:33 +01:00
|
|
|
#include "%{TrHdrFileName}"
|
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
|
|
|
|
2023-07-04 08:29:37 +02:00
|
|
|
namespace %{PluginName}::Internal {
|
2010-05-05 18:40:30 +02:00
|
|
|
|
2020-01-02 16:31:23 +01:00
|
|
|
%{CN}::%{CN}()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Create your members
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 16:31:23 +01:00
|
|
|
%{CN}::~%{CN}()
|
2010-05-05 18:40:30 +02:00
|
|
|
{
|
|
|
|
|
// Unregister objects from the plugin manager's object pool
|
|
|
|
|
// Delete members
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 16:08:36 +02:00
|
|
|
void %{CN}::initialize()
|
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
|
|
|
|
2023-07-28 16:08:36 +02:00
|
|
|
// If you need access to command line arguments or to report errors, use the
|
|
|
|
|
// bool IPlugin::initialize(const QStringList &arguments, QString *errorString)
|
|
|
|
|
// overload.
|
2010-05-06 11:55:53 +02:00
|
|
|
|
2023-11-13 16:15:33 +01:00
|
|
|
auto action = new QAction(Tr::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));
|
2023-11-13 16:15:33 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+Meta+A")));
|
2020-01-02 16:31:23 +01:00
|
|
|
connect(action, &QAction::triggered, this, &%{CN}::triggerAction);
|
2010-05-06 11:55:53 +02:00
|
|
|
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
|
2023-11-13 16:15:33 +01:00
|
|
|
menu->menu()->setTitle(Tr::tr("%{PluginName}"));
|
2010-05-06 11:55:53 +02:00
|
|
|
menu->addAction(cmd);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
|
2010-05-05 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-02 16:31:23 +01:00
|
|
|
void %{CN}::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
|
|
|
}
|
|
|
|
|
|
2020-01-02 16:31:23 +01:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag %{CN}::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
|
|
|
}
|
|
|
|
|
|
2020-01-02 16:31:23 +01:00
|
|
|
void %{CN}::triggerAction()
|
2010-05-06 11:55:53 +02:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QMessageBox::information(Core::ICore::mainWindow(),
|
2023-11-13 16:15:33 +01:00
|
|
|
Tr::tr("Action Triggered"),
|
|
|
|
|
Tr::tr("This is an action from %{PluginName}."));
|
2010-05-06 11:55:53 +02:00
|
|
|
}
|
2016-04-28 09:57:25 +03:00
|
|
|
|
2023-07-04 08:29:37 +02:00
|
|
|
} // namespace %{PluginName}::Internal
|