From 7262d30e9e689aaacd7926c90d953ab86cd9cfa7 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 2 Jul 2019 18:07:37 +0200 Subject: Implement load of sources in emscripten build and minor fixes. Signed-off-by: Pavel Pisa --- qtmips_gui/srceditor.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'qtmips_gui/srceditor.cpp') diff --git a/qtmips_gui/srceditor.cpp b/qtmips_gui/srceditor.cpp index 2f4d3a6..e8bdb85 100644 --- a/qtmips_gui/srceditor.cpp +++ b/qtmips_gui/srceditor.cpp @@ -41,12 +41,21 @@ #include "srceditor.h" -SrcEditor::SrcEditor(QWidget *parent) : Super(parent) { +void SrcEditor::setup_common() { + QFont font; + font.setFamily("Courier"); + font.setFixedPitch(true); + font.setPointSize(10); + setFont(font); tname = "Unknown"; } +SrcEditor::SrcEditor(QWidget *parent) : Super(parent) { + setup_common(); +} + SrcEditor::SrcEditor(const QString &text, QWidget *parent) : Super(text, parent) { - tname = "Unknown"; + setup_common(); } SrcEditor::~SrcEditor() { @@ -74,6 +83,16 @@ bool SrcEditor::loadFile(QString filename) { } } +bool SrcEditor::loadByteArray(const QByteArray &content, QString filename) { + setPlainText(QString::fromUtf8(content.data(), content.size())); + if (!filename.isEmpty()) { + QFileInfo fi(filename); + fname = filename; + tname = fi.fileName(); + } + return true; +} + bool SrcEditor::saveFile(QString filename) { if (filename.isEmpty()) filename = this->filename(); -- cgit v1.2.3