1 /*
2 # Projeto: Modelador de Banco de Dados PostgreSQL (pgsqlDBM)
3 #
4 # Copyright 2006-2020 - Raphael Araújo e Silva <raphael@pgmodeler.io>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation version 3.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # The complete text of GPLv3 is at LICENSE file on source code root directory.
16 # Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17 */
18 
19 /**
20 \ingroup libpgmodeler_ui
21 \class PgModelerPlugin
22 \brief Implements the basic operations to create third party plugins based upon shared libraries.
23 */
24 
25 #ifndef PGMODELER_PLUGIN_H
26 #define PGMODELER_PLUGIN_H
27 
28 #include "modelwidget.h"
29 #include "baseform.h"
30 
31 /*	The plugins in pgModeler must be within the "plugins" folder in its own
32 		directory and must have the following basic structure:
33 
34 
35 		 [PGMODELER_PLUGINS_DIR]/
36 					|
37 					+ - pluginA/
38 							 |
39 							 + ---- (lib)*(pluginA.)(so|dylib|dll) (library)
40 							 |
41 							 + ---- pluginA.png (icon)
42 
43 		> Library: it is the shared object that represents the plugin. The prefix (lib) and suffix (so|dylib|dll) are plataform dependent.
44 		> Icon: it is a PNG image that represents the plugin on the plugins toolbar.
45 	> Plugins can have a optional lang subdir in which are stored the translation for them. The translation files must be named
46 	  as [plugin name].[lang code].qm, for instance, Brazilian Portuguese translation for "dummy" would be: "dummy.pt_BR.qm".
47 
48 	Note: Plugins can have another additional subdirectories but any reference to them must be made programatically by the plugin author. */
49 
50 // Making the MainWindow class of pgModeler be known by the plugin interface
51 class MainWindow;
52 
53 class PgModelerPlugin {
54 	protected:
55 		BaseForm *plugin_info_frm;
56 
57 		MainWindow *main_window;
58 
59 	private:
60 		QLabel	*icon_lbl,
61 		*title_lbl,
62 		*author_lbl,
63 		*version_lbl,
64 		*description_lbl;
65 
66 	public:
67 		PgModelerPlugin();
68 
69 		virtual ~PgModelerPlugin();
70 
71 		/*! \brief This method is executed right before the main window is created and can be used to perform
72 		 * plugin's initializations like UI modications and other miscellaneous initialization that can't be done
73 		 * in the constructor. Additionally, a main window instance can be passed to the plugin in order to facilitate
74 		 * customization on the UI. The default implementation is to do nothing else then only expose main window to the plugin. */
75 		virtual void initPlugin(MainWindow *main_window);
76 
77 		//! \brief Executes the plugins having a ModelWidget as input parameter.
78 		virtual void executePlugin(ModelWidget *modelo)=0;
79 
80 		//! \brief Returns the plugin's title, this same text is used as action's text on plugins toolbar.
81 		virtual QString getPluginTitle(void)=0;
82 
83 		//! \brief Returns the plugin's author
84 		virtual QString getPluginAuthor(void)=0;
85 
86 		//! \brief Returns the plugin's version
87 		virtual QString getPluginVersion(void)=0;
88 
89 		//! \brief Returns the plugin's complete description
90 		virtual QString getPluginDescription(void)=0;
91 
92 		//! \brief Shows the plugin's information dialog
93 		virtual void showPluginInfo(void) = 0;
94 
95 		/*! \brief Returns the plugin's action shortcut
96 		 * The default implementation is to return an empty shortcut */
97 		virtual QKeySequence getPluginShortcut();
98 
99 		/*! \brief Indicates if the plugin's has an action to be installed in a Qmenu instance
100 		 * The default implementation is to indicate the presence of an action */
101 		virtual bool hasMenuAction();
102 
103 		//! \brief Sets the plugin's all attributes at once.
104 		void configurePluginInfo(const QString &title, const QString &version, const QString &author,
105 														 const QString &description, const QString &ico_filename);
106 };
107 
108 /* Declares the class PgModelerPlugin as interface, this means that the class is a base
109 	 for plugin implementation. All plugin must inherit this class and use the Q_INTERFACE
110 	 directive in its declaration  */
111 Q_DECLARE_INTERFACE(PgModelerPlugin,"br.com.pgmodeler.PgModelerPlugin")
112 
113 #endif
114