2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef SCRIPTCONSOLE_H
|
|
|
|
#define SCRIPTCONSOLE_H
|
|
|
|
|
|
|
|
#include "tcommon.h"
|
|
|
|
#include <QTextEdit>
|
|
|
|
|
|
|
|
class ScriptEngine;
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TOONZQT_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class DVAPI ScriptConsole final : public QTextEdit {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
|
|
|
ScriptEngine *m_engine;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QList<QString> m_commands;
|
|
|
|
int m_commandIndex;
|
|
|
|
QString m_currentCommand;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString m_prompt;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ScriptConsole(QWidget *parent = 0);
|
|
|
|
~ScriptConsole();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void executeCommand(const QString &cmd);
|
|
|
|
ScriptEngine *getEngine() const { return m_engine; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2016-06-15 18:43:10 +12:00
|
|
|
void onReturnKeyPress();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool canInsertFromMimeData(const QMimeData *source) const override;
|
|
|
|
void insertFromMimeData(const QMimeData *source) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onEvaluationDone();
|
|
|
|
void output(int, const QString &msg);
|
|
|
|
void onCursorPositionChanged();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif // SCRIPTCONSOLE_H
|