Switched script source code view to a QScintilla based view.

This commit is contained in:
Collin Kidder
2015-12-02 21:56:06 -05:00
parent 0d7490a423
commit cc0f1733b1
3 changed files with 20 additions and 7 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
CONFIG += c++11 CONFIG += c++11 qscintilla2
TARGET = SavvyCAN TARGET = SavvyCAN
TEMPLATE = app TEMPLATE = app
+5 -2
View File
@@ -3,6 +3,7 @@
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <Qsci/qscilexerjavascript.h>
#include "mainwindow.h" #include "mainwindow.h"
@@ -23,6 +24,8 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
connect(ui->btnRevertScript, &QAbstractButton::pressed, this, &ScriptingWindow::revertScript); connect(ui->btnRevertScript, &QAbstractButton::pressed, this, &ScriptingWindow::revertScript);
connect(ui->btnSaveScript, &QAbstractButton::pressed, this, &ScriptingWindow::saveScript); connect(ui->btnSaveScript, &QAbstractButton::pressed, this, &ScriptingWindow::saveScript);
connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &ScriptingWindow::updatedFrames); connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &ScriptingWindow::updatedFrames);
ui->txtScriptSource->setLexer(new QsciLexerJavaScript(ui->txtScriptSource));
} }
ScriptingWindow::~ScriptingWindow() ScriptingWindow::~ScriptingWindow()
@@ -181,7 +184,7 @@ void ScriptingWindow::saveScript()
delete outFile; delete outFile;
return; return;
} }
outFile->write(ui->txtScriptSource->toPlainText().toUtf8()); outFile->write(ui->txtScriptSource->text().toUtf8());
outFile->close(); outFile->close();
delete outFile; delete outFile;
} }
@@ -195,6 +198,6 @@ void ScriptingWindow::revertScript()
void ScriptingWindow::recompileScript() void ScriptingWindow::recompileScript()
{ {
currentScript->scriptText = ui->txtScriptSource->toPlainText(); currentScript->scriptText = ui->txtScriptSource->text();
currentScript->compileScript(); currentScript->compileScript();
} }
+14 -4
View File
@@ -53,7 +53,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,5,0,0,1"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,10,0,0,4">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@@ -65,9 +65,12 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextEdit" name="txtScriptSource"> <widget class="QsciScintilla" name="txtScriptSource">
<property name="enabled"> <property name="toolTip">
<bool>false</bool> <string/>
</property>
<property name="whatsThis">
<string/>
</property> </property>
</widget> </widget>
</item> </item>
@@ -113,6 +116,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QsciScintilla</class>
<extends>QFrame</extends>
<header>Qsci/qsciscintilla.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>