Scribus
Open source desktop publishing at your fingertips
scriptercore.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 SCRIPTERCORE_H
8 #define SCRIPTERCORE_H
9 
10 #include "cmdvar.h"
11 
12 #include "qmap.h"
13 #include "qpointer.h"
14 
15 class ScrAction;
16 class ScribusMainWindow;
17 class MenuManager;
18 class PythonConsole;
19 
20 class ScripterCore : public QObject
21 {
22  Q_OBJECT
23 
24 public:
25  ScripterCore(QWidget* parent);
26  ~ScripterCore();
27 
28  void addToMainWindowMenu(ScribusMainWindow *);
29  void enableMainWindowMenu();
30  void disableMainWindowMenu();
31 
33  QString returnString;
35  QString inValue;
36 
37 public slots:
38  void runScriptDialog();
39  void StdScript(QString filebasename);
40  void RecentScript(QString fn);
41  void slotRunScriptFile(QString fileName, bool inMainInterpreter = false);
42  void slotRunScriptFile(QString fileName, QStringList arguments, bool inMainInterpreter = false);
43  void slotRunPythonScript(); // needed for running python script from CLI
44  void slotRunScript(const QString script);
45  void slotInteractiveScript(bool);
46  void slotExecute();
51  void aboutScript();
53  bool setupMainInterpreter();
55  void initExtensionScripts();
57  void runStartupScript();
58  void languageChange();
59 
60  const QString & startupScript() const;
61  bool extensionsEnabled() const;
62  void setStartupScript(const QString& newScript);
63  void setExtensionsEnabled(bool enable);
64  void updateSyntaxHighlighter();
65 
66 protected:
67  // Private helper functions
68  void FinishScriptRun();
69  void ReadPlugPrefs();
70  void SavePlugPrefs();
71  void rebuildRecentScriptsMenu();
72  void buildScribusScriptsMenu();
73  //void buildRecentScriptsMenu();
74  void rebuildScribusScriptsMenu();
75 
76  //Internal members
78  PythonConsole *pcon;
79  QStringList SavedRecentScripts;
80  QStringList RecentScripts;
81  MenuManager *menuMgr;
82  QMap<QString, QPointer<ScrAction> > scrScripterActions;
83  QMap<QString, QPointer<ScrAction> > scrRecentScriptActions;
84 
85  // Preferences
91  QString m_startupScript;
92 };
93 
94 #endif
bool m_enableExtPython
pref: Enable access to main interpreter and 'extension scripts'
Definition: scriptercore.h:87
QString returnString
String representation of result returned by last python console command.
Definition: scriptercore.h:33
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
Definition: menumanager.h:43
QString m_startupScript
pref: Load this script on startup
Definition: scriptercore.h:91
bool m_importAllNames
pref: Run 'from scribus import *' at scripter startup
Definition: scriptercore.h:89
PythonConsole * pcon
Reference to the "IDE" widget.
Definition: scriptercore.h:78
Definition: scraction.h:33
void runStartupScript()
Runs the startup script, if enabled.
Definition: scriptercore.cpp:571
void aboutScript()
Show docstring of the script to the user. I don't know how to get docstring via e.g. pydoc because of it needs to run script => error cannot find scribus module.
Definition: scriptercore.cpp:536
bool setupMainInterpreter()
Does setup for the main interpreter, particularly the interactive console. True for success...
Definition: scriptercore.cpp:597
void initExtensionScripts()
Sets up the plugin for extension scripts, if enabled.
Definition: scriptercore.cpp:566
QString inValue
String representation of line of code to be passed to the Python interactive interpreter.
Definition: scriptercore.h:35
Definition: scriptercore.h:20