Newer
Older
Gigg, Martyn Anthony
committed
#ifndef SCRIPTINGWINDOW_H_
#define SCRIPTINGWINDOW_H_
//----------------------------------
// Includes
//----------------------------------
#include <QMainWindow>
#include "Script.h"
Gigg, Martyn Anthony
committed
//----------------------------------------------------------
// Forward declarations
//---------------------------------------------------------
class MultiTabScriptInterpreter;
Gigg, Martyn Anthony
committed
class ScriptingEnv;
class QTextEdit;
class QPoint;
class QMenu;
class QAction;
class QActionGroup;
Gigg, Martyn Anthony
committed
class QCloseEvent;
Gigg, Martyn Anthony
committed
class QShowEvent;
class QHideEvent;
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
This class displays a seperate window for editing and executing scripts
*/
class ScriptingWindow : public QMainWindow {
/// Qt macro
Gigg, Martyn Anthony
committed
Q_OBJECT
public:
/// Constructor
ScriptingWindow(ScriptingEnv *env, bool capturePrint = true,
QWidget *parent = 0, Qt::WindowFlags flags = 0);
/// Destructor
Gigg, Martyn Anthony
committed
~ScriptingWindow();
Gigg, Martyn Anthony
committed
/// Override the closeEvent
Gigg, Martyn Anthony
committed
void closeEvent(QCloseEvent *event);
Gigg, Martyn Anthony
committed
/// Override the showEvent
void showEvent(QShowEvent *event);
Gigg, Martyn Anthony
committed
/// Is a script running?
bool isExecuting() const;
/// Save the current state of the script window for next time
Gigg, Martyn Anthony
committed
void saveSettings();
/// Read settings from store
void readSettings();
/// Open a script in a new tab. Primarily useful for automatically
/// opening a script
void open(const QString &filename, bool newtab = true);
/// Executes whatever is in the current tab. Primarily useful for
/// automatically
/// running a script loaded with open
void executeCurrentTab(const Script::ExecutionMode mode);
/// saves scripts file names to a string
Sofia Antony
committed
QString saveToString();
/// Set whether to accept/reject close events
Gigg, Martyn Anthony
committed
void acceptCloseEvent(const bool value);
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
signals:
/// Show the scripting language dialog
void chooseScriptingLanguage();
Gigg, Martyn Anthony
committed
/// Tell others we are closing
void closeMe();
/// Tell others we are hiding
void hideMe();
Gigg, Martyn Anthony
committed
/// Accept a custom defined event
void customEvent(QEvent *event);
void dragMoveEvent(QDragMoveEvent *de);
void dropEvent(QDropEvent *de);
Gigg, Martyn Anthony
committed
private slots:
/// Populate file menu
void populateFileMenu();
/// Ensure the list is up to date
void populateRecentScriptsMenu();
/// Populate edit menu
void populateEditMenu();
/// Populate execute menu
void populateExecMenu();
/// Populate window menu
void populateWindowMenu();
/// Populate help menu
void populateHelpMenu();
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
/// Update window flags
void updateWindowFlags();
/// Update menus based on current tab counts
void setMenuStates(int nTabs);
/// Sets the execution actions based on the flag
void setEditActionsDisabled(bool state);
/// Sets the execution actions based on the flag
void setExecutionActionsDisabled(bool state);
Gigg, Martyn Anthony
committed
/// Finds the script corresponding to the action and
/// asks the manager to open it
void openRecentScript(QAction *);
/// Execute all using the current mode option
void executeAll();
/// Execute selection using the current mode option
void executeSelection();
/// Abort the current script
void abortCurrent();
/// Clear out any previous variable definitions in the current script
void clearScriptVariables();
/// Opens help page for scripting window
void showHelp();
/// Opens help page for Python API
void showPythonHelp();
private:
/// Create menu bar
void initMenus();
/// Create all actions
void initActions();
/// Create the file actions
void initFileMenuActions();
/// Create the edit menu actions
void initEditMenuActions();
/// Create the execute menu actions
void initExecMenuActions();
/// Create the window menu actions
void initWindowMenuActions();
/// Create the help menu actions
void initHelpMenuActions();
/// Opens tabs based on QStringList
void openPreviousTabs(const QStringList &tabsToOpen);
/// Returns the current execution mode
Script::ExecutionMode getExecutionMode() const;
QStringList extractPyFiles(const QList<QUrl> &urlList) const;
Gigg, Martyn Anthony
committed
private:
Gigg, Martyn Anthony
committed
/// The script editors' manager
MultiTabScriptInterpreter *m_manager;
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
/// File menu
QMenu *m_fileMenu;
/// File menu actions
QAction *m_newTab, *m_openInCurTab, *m_openInNewTab, *m_save, *m_saveAs,
*m_print, *m_closeTab;
QMenu *m_recentScripts;
Gigg, Martyn Anthony
committed
/// Edit menu
QMenu *m_editMenu;
/// Edit menu actions
QAction *m_undo, *m_redo, *m_cut, *m_copy, *m_paste, *m_comment, *m_uncomment,
*m_tabsToSpaces, *m_spacesToTabs, *m_find;
Gigg, Martyn Anthony
committed
/// Run menu
QMenu *m_runMenu;
/// Execute menu actions
QAction *m_execSelect, *m_execAll, *m_abortCurrent, *m_clearScriptVars;
/// Execution mode menu
QMenu *m_execModeMenu;
/// Execute mode actions
QAction *m_execParallel, *m_execSerial;
/// Action group for execution mode
QActionGroup *m_execModeGroup;
Gigg, Martyn Anthony
committed
/// Window menu
QMenu *m_windowMenu;
Gigg, Martyn Anthony
committed
/// Window actions
QAction *m_alwaysOnTop, *m_hide, *m_zoomIn, *m_zoomOut, *m_resetZoom,
*m_toggleProgress, *m_toggleFolding, *m_toggleWhitespace,
*m_openConfigTabs, *m_selectFont;
/// Help menu
QMenu *m_helpMenu;
/// Help actions
QAction *m_showHelp, *m_showPythonHelp;
Gigg, Martyn Anthony
committed
/// Change scripting language
QAction *m_scripting_lang;
Gigg, Martyn Anthony
committed
/// Flag to define whether we should accept a close event
bool m_acceptClose;
Gigg, Martyn Anthony
committed
};