Scribus
Open source desktop publishing at your fingertips
scripterimpl.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef SCRIPTERIMPL_H
8 #define SCRIPTERIMPL_H
9 
10 #include <QObject>
11 #include <QtDebug>
12 
13 #include "scribus.h"
14 #include "scribusdoc.h"
15 #include "scribuscore.h"
16 #include "scpaths.h"
17 #include "pythonize.h"
18 #include "api_prefs.h"
19 #include "api_printer.h"
20 #include "api_imageexport.h"
21 #include "api_layer.h"
22 #include "api_page.h"
23 #include "api_dialogs.h"
24 #include "api_window.h"
25 #include "api_document.h"
26 #include "api_color.h"
27 
28 // XXX make this INTO method inside a new util.cpp
29 #define RAISE(msg) QApplication::instance()->setProperty("MIKRO_EXCEPTION", QVariant(msg))
30 #define COLLECTOR ScripterImpl::instance()->collector()
31 #define SCRIPTER ScripterImpl::instance()
32 
33 class QString;
34 class ScribusDoc;
35 
36 //Q_DECLARE_METATYPE(QList<QVariant*>)
37 
38 class ScripterImpl : public QObject
39 {
40  Q_OBJECT
41  Q_PROPERTY(QObject* collector READ collector);
42  Q_PROPERTY(QString language READ language);
43  Q_PROPERTY(QObject* activeDocument READ activeDocument);
44  Q_PROPERTY(QObject* activeWindow READ activeWindow);
45  Q_PROPERTY(QList<QVariant> colors READ colors);
46  Q_PROPERTY(QList<QVariant> fontInfo READ fontInfo);
47  Q_PROPERTY(QList<QVariant> extendedFontInfo READ xFontInfo);
48 
49 public:
50  ScripterImpl();
51  ~ScripterImpl();
52  static ScripterImpl *instance();
53  bool init();
54  bool cleanup();
55  void addToMainWindowMenu(ScribusMainWindow *mainwin);
56  QObject *collector()
57  {
58  return collected;
59  };
60 
61 public slots:
62  void aboutScripter();
63  QObject *openDocument(const QString & filename);
64  QObject *newDocument(
65  double topMargin, double bottomMargin,
66  double leftMargin, double rightMargin,
67  double pageWidth, double pageHeight,
68  int orientation, int firstPageNr, int unit, int pagesType,
69  int facingPages, int firstPageOrder, int numPages);
70  QObject *fromVariant(const QVariant& v);
71  bool test();
72 
73 signals:
74  void createMenu(QMainWindow *mainwin);
75 
76 private:
77  /*
78  collected is used for dumb garbage collection.
79  Use it as a parent to make sure that your object gets deleted
80  inside the scripting environment if it is not needed anymore.
81  */
82  QObject *collected;
83  Pythonize *python;
84  static ScripterImpl *_instance;
85  QString path;
86  bool runScript(const QString & filename);
87  QString language();
88  QObject *activeDocument();
89  QObject *activeWindow();
90  QList<QVariant> colors();
91  QList<QVariant> fontInfo();
92  QList<QVariant> xFontInfo();
93 };
94 
95 #endif
QObject * fromVariant(const QVariant &v)
Definition: scripterimpl.cpp:92
void aboutScripter()
Definition: scripterimpl.cpp:327
QObject * openDocument(const QString &filename)
Definition: scripterimpl.cpp:115
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
Definition: pythonize.h:39
the Document Class
Definition: scribusdoc.h:90
QObject * newDocument(double topMargin, double bottomMargin, double leftMargin, double rightMargin, double pageWidth, double pageHeight, int orientation, int firstPageNr, int unit, int pagesType, int facingPages, int firstPageOrder, int numPages)
Definition: scripterimpl.cpp:235
Definition: scripterimpl.h:38