myplugin.cpp
Go to the documentation of this file.00001 /* 00002 For general Scribus (>=1.3.2) copyright and licensing information please refer 00003 to the COPYING file provided with the program. Following this notice may exist 00004 a copyright and/or license notice that predates the release of Scribus 1.3.2 00005 for which a new license (GPL+exception) is in place. 00006 */ 00007 #include "myplugin.h" 00008 #include "mypluginimpl.h" 00009 00010 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods 00011 // do. That documentatation is not duplicated here. 00012 // Please don't implement the functionality of your plugin here; do that 00013 // in mypluginimpl.h and mypluginimpl.cpp . 00014 00015 MyPlugin::MyPlugin() : ScActionPlugin() 00016 { 00017 // Set action info in languageChange, so we only have to do 00018 // it in one place. 00019 languageChange(); 00020 } 00021 00022 MyPlugin::~MyPlugin() {}; 00023 00024 void MyPlugin::languageChange() 00025 { 00026 // Note that we leave the unused members unset. They'll be initialised 00027 // with their default ctors during construction. 00028 // Action name 00029 m_actionInfo.name = "MyPlugin"; 00030 // Action text for menu, including &accel 00031 m_actionInfo.text = tr("My &Plugin"); 00032 // Menu 00033 m_actionInfo.menu = "Extras"; 00034 // If needed, what item to add the menu item after 00035 //m_actionInfo.menuAfterName = "ColorWheel" 00036 // If needed, the keyboard shortcut for the plugin 00037 //m_actionInfo.keySequence = "CTRL+ALT+F3" 00038 // Should the menu item be enabled when the app starts 00039 // (even without a document open) ? 00040 m_actionInfo.enabledOnStartup = true; 00041 } 00042 00043 const QString MyPlugin::fullTrName() const 00044 { 00045 return QObject::tr("My Plugin"); 00046 } 00047 00048 const ScActionPlugin::AboutData* MyPlugin::getAboutData() const 00049 { 00050 AboutData* about = new AboutData; 00051 Q_CHECK_PTR(about); 00052 return about; 00053 } 00054 00055 void MyPlugin::deleteAboutData(const AboutData* about) const 00056 { 00057 Q_ASSERT(about); 00058 delete about; 00059 } 00060 00061 bool MyPlugin::run(ScribusDoc* doc, QString target) 00062 { 00063 MyPluginImpl *myPluginImpl = new MyPluginImpl(); 00064 Q_CHECK_PTR(myPluginImpl); 00065 bool result = myPluginImpl->run(target, doc); 00066 delete myPluginImpl; 00067 return result; 00068 } 00069 00070 // Low level plugin API 00071 int myplugin_getPluginAPIVersion() 00072 { 00073 return PLUGIN_API_VERSION; 00074 } 00075 00076 ScPlugin* myplugin_getPlugin() 00077 { 00078 MyPlugin* plug = new MyPlugin(); 00079 Q_CHECK_PTR(plug); 00080 return plug; 00081 } 00082 00083 void myplugin_freePlugin(ScPlugin* plugin) 00084 { 00085 MyPlugin* plug = dynamic_cast<MyPlugin*>(plugin); 00086 Q_ASSERT(plug); 00087 delete plug; 00088 }
