Add CutterPlugin::terminate() (#1372)

This commit is contained in:
Florian Märkl 2019-03-23 12:23:31 +01:00 committed by GitHub
parent 2ab676be71
commit 894a79b0cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -10,10 +10,32 @@ class MainWindow;
class CutterPlugin
{
public:
virtual ~CutterPlugin() {}
virtual ~CutterPlugin() = default;
/**
* @brief Initialize the Plugin
*
* called right when the plugin is loaded initially
*/
virtual void setupPlugin() = 0;
/**
* @brief Setup any UI components for the Plugin
* @param main the MainWindow to add any UI to
*
* called after Cutter's core UI has been initialized
*/
virtual void setupInterface(MainWindow *main) = 0;
/**
* @brief Shutdown the Plugin
*
* called just before the Plugin is deleted.
* This method is usually only relevant for Python Plugins where there is no
* direct equivalent of the destructor.
*/
virtual void terminate() {};
virtual QString getName() const = 0;
virtual QString getAuthor() const = 0;
virtual QString getDescription() const = 0;

View File

@ -78,6 +78,7 @@ void PluginManager::loadPlugins()
void PluginManager::destroyPlugins()
{
for (CutterPlugin *plugin : plugins) {
plugin->terminate();
delete plugin;
}
}

View File

@ -59,6 +59,9 @@ class CutterSamplePlugin(cutter.CutterPlugin):
widget = FortuneWidget(main, action)
main.addPluginDockWidget(widget, action)
def terminate(self): # optional
print("CutterSamplePlugin shutting down")
# This function will be called by Cutter and should return an instance of the plugin.
def create_cutter_plugin():