Commit 5df5949d authored by Jan Möbius's avatar Jan Möbius

If qt scripttools are available, integrate them into the scripting plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13414 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e833a1bd
include (plugin)
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE )
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE
INSTALLDATA Icons )
......@@ -57,6 +57,9 @@
#include <QTextStream>
#include <QSyntaxHighlighter>
ScriptingPlugin::ScriptingPlugin() :
lastProblemLine_(0),
lastError_(""),
......@@ -67,7 +70,12 @@ ScriptingPlugin::ScriptingPlugin() :
highlighterCurrent_(0),
highlighterLive_(0),
highlighterList_(0),
lastFile_("")
lastFile_(""),
debuggerButton_(0),
#ifdef QT_SCRIPTTOOLS_LIB
debugger_(0)
#endif
{
}
......@@ -116,7 +124,6 @@ void ScriptingPlugin::pluginsInitialized() {
QToolBar* toolBar = new QToolBar(tr("Scripting Toolbar"));
QAction* openButton = new QAction(QIcon(iconPath + "document-open.png"), "Open", toolBar);
toolBar->addAction(openButton);
connect (openButton, SIGNAL( triggered() ), this, SLOT( slotLoadScript() ) );
......@@ -131,6 +138,23 @@ void ScriptingPlugin::pluginsInitialized() {
toolBar->addSeparator();
debuggerButton_ = new QAction(QIcon(iconPath + "script-debugger.png"), "Enable Debugger", toolBar);
debuggerButton_->setCheckable(true);
toolBar->addAction(debuggerButton_);
#ifdef QT_SCRIPTTOOLS_LIB
if ( OpenFlipperSettings().value("Scripting/QtScriptDebugger",true).toBool() )
debuggerButton_->setChecked(true);
else
debuggerButton_->setChecked(false);
connect (debuggerButton_, SIGNAL( triggered() ), this, SLOT( slotDebuggerButton() ) );
#else
debuggerButton_->setEnabled(false);
#endif
toolBar->addSeparator();
QAction* executeButton = new QAction(QIcon(iconPath + "arrow-right.png"), "Execute", toolBar);
toolBar->addAction(executeButton);
connect (executeButton, SIGNAL( triggered() ), this, SLOT( slotExecuteScriptButton() ) );
......@@ -189,6 +213,19 @@ void ScriptingPlugin::pluginsInitialized() {
errorTimer_ = new QTimer();
errorTimer_->setSingleShot(true);
connect(errorTimer_,SIGNAL(timeout()),this,SLOT(slotHighlightError()));
// ==================================================================
// Setup scripting debugger if available
// ==================================================================
#ifdef QT_SCRIPTTOOLS_LIB
QScriptEngine* engine;
emit getScriptingEngine( engine );
debugger_ = new QScriptEngineDebugger;
if ( OpenFlipperSettings().value("Scripting/QtScriptDebugger",true).toBool() )
debugger_->attachTo(engine);
#endif
}
void ScriptingPlugin::slotApplyFilter(){
......@@ -378,6 +415,26 @@ void ScriptingPlugin::slotExecuteScriptButton() {
slotExecuteScript( scriptWidget_->currentScript->toPlainText() );
}
void ScriptingPlugin::slotDebuggerButton() {
std::cerr << "Debuggerbutton" << std::endl;
#ifdef QT_SCRIPTTOOLS_LIB
QScriptEngine* engine;
emit getScriptingEngine( engine );
if ( debuggerButton_->isChecked() ) {
debugger_->attachTo(engine);
} else {
debugger_->detach();
}
OpenFlipperSettings().setValue("Scripting/QtScriptDebugger",debuggerButton_->isChecked());
#endif
}
QString ScriptingPlugin::mangleScript(QString _input ) {
// Update list of available functions
......
......@@ -53,6 +53,11 @@
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
// Include the scripttools for qt script debugging if available
#ifdef QT_SCRIPTTOOLS_LIB
#include <QtScriptTools/QScriptEngineDebugger>
#endif
#include "highLighter.hh"
#include "scriptingWidget.hh"
......@@ -119,6 +124,9 @@ private slots :
/// Called when an error is detected when checking the syntax
void slotHighlightError();
/// Triggered by the debugger button
void slotDebuggerButton();
private:
/// Store the last line that contained an error
......@@ -210,6 +218,13 @@ private :
QString lastFile_;
QAction* debuggerButton_;
#ifdef QT_SCRIPTTOOLS_LIB
QScriptEngineDebugger* debugger_;
#endif
public slots:
QString version() { return QString("1.0"); };
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment