Rev 5051 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
1718 | craig | 7 | #ifndef SCRIPTERCORE_H |
8 | #define SCRIPTERCORE_H |
||
1467 | cbradney | 9 | |
10 | #include "cmdvar.h" |
||
11 | |||
1718 | craig | 12 | #include "qmap.h" |
13 | #include "qguardedptr.h" |
||
1467 | cbradney | 14 | |
1718 | craig | 15 | class ScrAction; |
5243 | cbradney | 16 | class ScribusMainWindow; |
1718 | craig | 17 | class MenuManager; |
3254 | craig | 18 | class PythonConsole; |
1718 | craig | 19 | |
1467 | cbradney | 20 | class ScripterCore : public QObject |
21 | { |
||
1718 | craig | 22 | Q_OBJECT |
1467 | cbradney | 23 | |
24 | public: |
||
1718 | craig | 25 | ScripterCore(QWidget* parent); |
26 | ~ScripterCore(); |
||
5243 | cbradney | 27 | void addToMainWindowMenu(ScribusMainWindow *); |
1718 | craig | 28 | |
5051 | subik | 29 | /** @brief String representation of result returned by last python console command */ |
30 | QString returnString; |
||
31 | /** @brief String representation of line of code to be passed to the Python interactive interpreter */ |
||
32 | QString inValue; |
||
33 | |||
1467 | cbradney | 34 | public slots: |
2622 | craig | 35 | void runScriptDialog(); |
1718 | craig | 36 | void StdScript(QString filebasename); |
37 | void RecentScript(QString fn); |
||
1752 | craig | 38 | void slotRunScriptFile(QString fileName, bool inMainInterpreter = false); |
5051 | subik | 39 | void slotRunScript(const QString Script); |
1718 | craig | 40 | void slotInteractiveScript(bool); |
41 | void slotExecute(); |
||
4458 | subik | 42 | /*! \brief Show docstring of the script to the user. |
43 | * I don't know how to get docstring via e.g. pydoc because of |
||
44 | * it needs to run script => error cannot find scribus module |
||
45 | */ |
||
1718 | craig | 46 | void aboutScript(); |
4458 | subik | 47 | /** \brief Does setup for the main interpreter, particularly the interactive console. True for success. */ |
2706 | craig | 48 | bool setupMainInterpreter(); |
4458 | subik | 49 | /** \brief Sets up the plugin for extension scripts, if enabled */ |
1752 | craig | 50 | void initExtensionScripts(); |
4458 | subik | 51 | /** \brief Runs the startup script, if enabled */ |
1752 | craig | 52 | void runStartupScript(); |
2226 | cbradney | 53 | void languageChange(); |
1718 | craig | 54 | |
3216 | craig | 55 | const QString & startupScript() const; |
56 | bool extensionsEnabled() const; |
||
57 | void setStartupScript(const QString& newScript); |
||
58 | void setExtensionsEnabled(bool enable); |
||
59 | |||
1718 | craig | 60 | protected: |
61 | // Private helper functions |
||
62 | void FinishScriptRun(); |
||
63 | void ReadPlugPrefs(); |
||
64 | void SavePlugPrefs(); |
||
65 | void rebuildRecentScriptsMenu(); |
||
66 | void buildScribusScriptsMenu(); |
||
67 | void buildRecentScriptsMenu(); |
||
68 | void rebuildScribusScriptsMenu(); |
||
69 | |||
2503 | subik | 70 | //Internal members |
4458 | subik | 71 | //! \brief Reference to the "IDE" widget |
2503 | subik | 72 | PythonConsole *pcon; |
1718 | craig | 73 | QStringList SavedRecentScripts; |
74 | QStringList RecentScripts; |
||
75 | MenuManager *menuMgr; |
||
76 | QMap<QString, QGuardedPtr<ScrAction> > scrScripterActions; |
||
77 | QMap<QString, QGuardedPtr<ScrAction> > scrRecentScriptActions; |
||
1752 | craig | 78 | |
79 | // Preferences |
||
4458 | subik | 80 | /** \brief pref: Enable access to main interpreter and 'extension scripts' */ |
3216 | craig | 81 | bool m_enableExtPython; |
4458 | subik | 82 | /** \brief pref: Run 'from scribus import *' at scripter startup */ |
3216 | craig | 83 | bool m_importAllNames; |
4458 | subik | 84 | /** \brief pref: Load this script on startup */ |
3216 | craig | 85 | QString m_startupScript; |
1467 | cbradney | 86 | }; |
87 | |||
88 | #endif |