Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scplugin.h
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 #ifndef _SCPLUGIN_H
00008 #define _SCPLUGIN_H
00009 
00010 #include "qobject.h"
00011 #include "qwidget.h"
00012 #include "qstring.h"
00013 #include "qpixmap.h"
00014 #include "qdatetime.h"
00015 #include "qiconset.h"
00016 #include "scribusapi.h"
00017 
00018 class QWidget;
00019 class ScribusDoc;
00020 class ScribusMainWindow;
00021 class DeferredTask;
00022 class PrefsPanel;
00023 
00090 class SCRIBUS_API ScPlugin : public QObject
00091 {
00092        Q_OBJECT
00093 
00099        public:
00100 
00103               struct AboutData
00104               {
00106                      QString authors;
00108                      QString shortDescription;
00110                      QString description;
00112                      QString version;
00114                      QDateTime releaseDate;
00116                      QString copyright;
00121                      QString license;
00122               };
00123 
00130               ScPlugin();
00131 
00139               virtual ~ScPlugin() = 0;
00140 
00147               virtual const QString fullTrName() const = 0;
00148 
00174               virtual bool newPrefsPanelWidget(QWidget* parent, PrefsPanel*& panel,
00175                                                                        QString& caption, QPixmap& icon);
00176 
00188               virtual const AboutData* getAboutData() const = 0;
00189               virtual void deleteAboutData(const AboutData* about) const = 0;
00190 
00198               const QString & lastError() const;
00199 
00211               virtual void languageChange() = 0;
00212 
00214               const QString pluginTypeName() const;
00215 
00217               virtual void addToMainWindowMenu(ScribusMainWindow *) = 0;
00218        protected:
00220               QString m_lastError;
00221 };
00222 
00223 
00235 class SCRIBUS_API ScActionPlugin : public ScPlugin
00236 {
00237        Q_OBJECT
00238 
00239        public:
00240 
00245               ScActionPlugin();
00246 
00248               virtual ~ScActionPlugin() = 0;
00249 
00250               // Information about actions, to be returned by actionInfo()
00251               struct ActionInfo {
00252                      QString name;  // name of action
00253                      QString text;  // text to display to user
00254                      QString keySequence;
00255                      QString menu;
00256                      QString menuAfterName;
00257                      QIconSet iconSet;
00258                      bool enabledOnStartup;
00259               };
00260 
00261               // Return an ActionInfo instance to the caller
00262               const ActionInfo & actionInfo() const;
00263 
00264        public slots:
00291               virtual bool run(ScribusDoc* doc, QString target = QString::null) = 0;
00292 
00300               virtual bool run(QWidget* parent, ScribusDoc* doc, QString target = QString::null);
00301 
00317               virtual bool run(ScribusDoc* doc, QIODevice* target);
00318 
00359               virtual DeferredTask* runAsync(QString target = QString::null);
00360 
00368               virtual DeferredTask* runAsync(QIODevice* target);
00369 
00370               // Compat kludge ... we store a QString result from any successful
00371               // run(...) call in m_runResult and let callers retrive it here.
00372               // DO NOT USE THIS INTERFACE FOR NEW PLUG-INS; you should
00373               // dynamic_cast<> to the plugin type then call a plug-in specific
00374               // method instead.
00376               const QString & runResult() const;
00377 
00378        protected:
00379               // Action info. To be set up by ctor.
00380               ActionInfo m_actionInfo;
00381               // Obsolete - see runResult()
00382               QString m_runResult;
00383               ScribusDoc* m_Doc;
00384 };
00385 
00399 class SCRIBUS_API ScPersistentPlugin : public ScPlugin
00400 {
00401        Q_OBJECT
00402 
00403        public:
00404 
00409               ScPersistentPlugin();
00410 
00412               virtual ~ScPersistentPlugin() = 0;
00413 
00438               virtual bool initPlugin() = 0;
00439 
00451               virtual bool cleanupPlugin() = 0;
00452 };
00453 
00454 // Plug-in API version used to check if we can load the plug-in. This
00455 // does *NOT* ensure that the plug-in will be compatible with the internal
00456 // Scribus APIs, only that the ScPlugin class and its standard subclasses
00457 // will be compatible with what we expect, and that "extern C" functions
00458 // we need will be present and work as expected. It's a preprocessor directive
00459 // to make sure that it's compiled into each plugin rather than referenced
00460 // from the main code.
00461 //
00462 // The API version is currently simply incremented with each incompatible
00463 // change. Future versions may introduce a minor/major scheme if necessary.
00464 #define PLUGIN_API_VERSION 0x00000008
00465 
00466 
00467 #endif