diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-07-02 18:07:37 +0200 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-07-02 18:07:37 +0200 |
commit | 7262d30e9e689aaacd7926c90d953ab86cd9cfa7 (patch) | |
tree | d2d7fb3515cb548a876f6214d143715a4a9142ff /qtmips_gui/srceditor.cpp | |
parent | 040c1998500d3b0b50b3ddef4fe93216563343a8 (diff) | |
download | qtmips-7262d30e9e689aaacd7926c90d953ab86cd9cfa7.tar.gz qtmips-7262d30e9e689aaacd7926c90d953ab86cd9cfa7.tar.bz2 qtmips-7262d30e9e689aaacd7926c90d953ab86cd9cfa7.zip |
Implement load of sources in emscripten build and minor fixes.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui/srceditor.cpp')
-rw-r--r-- | qtmips_gui/srceditor.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
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(); |