src/terralib/ceditor/Plugin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20  */
21 
22 /*!
23  \file terralib/ceditor/Plugin.cpp
24 
25  \brief Plugin interface for dynamic loading of the Code Editor.
26 */
27 // TerraLib
28 #include "../core/plugin/CppPlugin.h"
29 #include "../qt/af/ApplicationController.h"
30 #include "CodeEditorDialog.h"
31 #include "Plugin.h"
32 
33 //qt
34 #include <QAction>
35 #include <QIcon>
36 #include <QMenu>
37 
39  : te::core::CppPlugin(pluginInfo),
40  m_codeEditorDialog(nullptr),
41  m_codeEditorAction(nullptr)
42 {
43 }
44 te::ce::Plugin::~Plugin() = default;
45 
47 {
48  // if initialized, return
49  if (m_initialized)
50  return;
51 
52  // creates a new QAction for the plugin
53  m_codeEditorAction = new QAction(this);
54  m_codeEditorAction->setText("Code Editor");
55  m_codeEditorAction->setIcon(QIcon::fromTheme("terminal"));
56  m_codeEditorAction->setObjectName("CEditor");
57 
58  // inserts the action into the Plugins menu
59  te::qt::af::AppCtrlSingleton::getInstance().getMenu("Plugins")->addAction(
61 
62  // connects the action to the slot
63  connect(m_codeEditorAction, SIGNAL(triggered(bool)), this,
64  SLOT(onCodeEditorActionClicked(bool)));
65 
66  // initialized is now true
67  m_initialized = true;
68 }
69 
71 {
72  if (!m_initialized)
73  return;
74 
75  delete m_codeEditorDialog;
76  delete m_codeEditorAction;
77 
78  m_initialized = false;
79 }
80 
82 {
83  // creates a new CodeEditorDialog when the actions is triggered
86 
87  // shows the CodeEditorDialog
88  m_codeEditorDialog->show();
89 }
90 
Basic information about a plugin.
te::ce::CodeEditorDialog * m_codeEditorDialog
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
#define TERRALIB_PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
Plugin(const te::core::PluginInfo &pluginInfo)
Plugin interface for dynamic loading of the Code Editor.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.