Refactor EditTab to use its toolbar for editor control
ADD
resources/icons/cancel.svg
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ viewBox="0 0 496.158 496.158" style="enable-background:new 0 0 496.158 496.158;" xml:space="preserve">
+<path style="fill:#E04F5F;" d="M496.158,248.085c0-137.021-111.07-248.082-248.076-248.082C111.07,0.003,0,111.063,0,248.085
+ c0,137.002,111.07,248.07,248.082,248.07C385.088,496.155,496.158,385.087,496.158,248.085z"/>
+<path style="fill:#FFFFFF;" d="M277.042,248.082l72.528-84.196c7.91-9.182,6.876-23.041-2.31-30.951
+ c-9.172-7.904-23.032-6.876-30.947,2.306l-68.236,79.212l-68.229-79.212c-7.91-9.188-21.771-10.216-30.954-2.306
+ c-9.186,7.91-10.214,21.77-2.304,30.951l72.522,84.196l-72.522,84.192c-7.91,9.182-6.882,23.041,2.304,30.951
+ c4.143,3.569,9.241,5.318,14.316,5.318c6.161,0,12.294-2.586,16.638-7.624l68.229-79.212l68.236,79.212
+ c4.338,5.041,10.47,7.624,16.637,7.624c5.069,0,10.168-1.749,14.311-5.318c9.186-7.91,10.22-21.77,2.31-30.951L277.042,248.082z"/>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+</svg>

MODIFY
resources/icons/icons.qrc
resources/icons/icons.qrc
<file>reset.svg</file>
<file>tag.svg</file>
<file>run.svg</file>
+ <file>cancel.svg</file>
+ <file>saveas.svg</file>
</qresource>
</RCC>

MODIFY
resources/icons/save.svg
resources/icons/save.svg
-<?xml version="1.0" encoding="iso-8859-1"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
- viewBox="0 0 47 47" style="enable-background:new 0 0 47 47;" xml:space="preserve">
-<polygon style="fill:#424A60;" points="46.5,8 46.5,47 0.5,47 0.5,0 38.5,0 "/>
-<rect x="7.5" y="26" style="fill:#E7ECED;" width="31" height="21"/>
-<rect x="7.5" y="26" style="fill:#EBBA16;" width="31" height="12.037"/>
-<rect x="9.5" style="fill:#C7CAC7;" width="26" height="16"/>
-<g>
- <path style="fill:#FFFFFF;" d="M12.5,31h7c0.553,0,1-0.447,1-1s-0.447-1-1-1h-7c-0.553,0-1,0.447-1,1S11.947,31,12.5,31z"/>
- <path style="fill:#FFFFFF;" d="M22.5,33h-10c-0.553,0-1,0.447-1,1s0.447,1,1,1h10c0.553,0,1-0.447,1-1S23.053,33,22.5,33z"/>
- <path style="fill:#FFFFFF;" d="M26.21,33.29c-0.37-0.37-1.04-0.37-1.41,0c-0.19,0.189-0.3,0.439-0.3,0.71
- c0,0.27,0.109,0.52,0.29,0.71C24.979,34.89,25.229,35,25.5,35c0.27,0,0.52-0.11,0.71-0.29c0.18-0.19,0.29-0.45,0.29-0.71
- S26.39,33.479,26.21,33.29z"/>
-</g>
-<rect x="27.5" y="4" style="fill:none;stroke:#424A60;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" width="4" height="8"/>
-<polygon style="fill:#E7ECED;" points="24.5,16 9.5,16 9.5,0 16.5,0 "/>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Capa_1"
+ x="0px"
+ y="0px"
+ viewBox="0 0 47 47"
+ style="enable-background:new 0 0 47 47;"
+ xml:space="preserve"
+ sodipodi:docname="save.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
+ id="metadata271"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs269" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1853"
+ inkscape:window-height="1025"
+ id="namedview267"
+ showgrid="false"
+ inkscape:zoom="8.9787234"
+ inkscape:cx="37.328643"
+ inkscape:cy="19.596668"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="Capa_1" />
+<polygon
+ style="fill:#424A60;"
+ points="46.5,8 46.5,47 0.5,47 0.5,0 38.5,0 "
+ id="polygon216" />
+<rect
+ x="7.5"
+ y="26"
+ style="fill:#E7ECED;"
+ width="31"
+ height="21"
+ id="rect218" />
+
+<rect
+ x="9.5"
+ style="fill:#C7CAC7;"
+ width="26"
+ height="16"
+ id="rect222" />
+
+<rect
+ x="27.5"
+ y="4"
+ style="fill:none;stroke:#424A60;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;"
+ width="4"
+ height="8"
+ id="rect232" />
+<polygon
+ style="fill:#E7ECED;"
+ points="24.5,16 9.5,16 9.5,0 16.5,0 "
+ id="polygon234" />
+<g
+ id="g236">
+</g>
+<g
+ id="g238">
+</g>
+<g
+ id="g240">
+</g>
+<g
+ id="g242">
+</g>
+<g
+ id="g244">
+</g>
+<g
+ id="g246">
+</g>
+<g
+ id="g248">
+</g>
+<g
+ id="g250">
+</g>
+<g
+ id="g252">
+</g>
+<g
+ id="g254">
+</g>
+<g
+ id="g256">
+</g>
+<g
+ id="g258">
+</g>
+<g
+ id="g260">
+</g>
+<g
+ id="g262">
+</g>
+<g
+ id="g264">
</g>
</svg>
\ No newline at end of file

ADD
resources/icons/saveas.svg
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Capa_1"
+ x="0px"
+ y="0px"
+ viewBox="0 0 47 47"
+ style="enable-background:new 0 0 47 47;"
+ xml:space="preserve"
+ sodipodi:docname="saveas.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
+ id="metadata271"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs269" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1853"
+ inkscape:window-height="1025"
+ id="namedview267"
+ showgrid="false"
+ inkscape:zoom="8.9787234"
+ inkscape:cx="37.328643"
+ inkscape:cy="19.596668"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="Capa_1" />
+<polygon
+ style="fill:#424A60;"
+ points="46.5,8 46.5,47 0.5,47 0.5,0 38.5,0 "
+ id="polygon216" />
+<rect
+ x="7.5"
+ y="26"
+ style="fill:#E7ECED;"
+ width="31"
+ height="21"
+ id="rect218" />
+
+<rect
+ x="9.5"
+ style="fill:#C7CAC7;"
+ width="26"
+ height="16"
+ id="rect222" />
+
+<rect
+ x="27.5"
+ y="4"
+ style="fill:none;stroke:#424A60;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;"
+ width="4"
+ height="8"
+ id="rect232" />
+<polygon
+ style="fill:#E7ECED;"
+ points="24.5,16 9.5,16 9.5,0 16.5,0 "
+ id="polygon234" />
+<g
+ id="g236">
+</g>
+<g
+ id="g238">
+</g>
+<g
+ id="g240">
+</g>
+<g
+ id="g242">
+</g>
+<g
+ id="g244">
+</g>
+<g
+ id="g246">
+</g>
+<g
+ id="g248">
+</g>
+<g
+ id="g250">
+</g>
+<g
+ id="g252">
+</g>
+<g
+ id="g254">
+</g>
+<g
+ id="g256">
+</g>
+<g
+ id="g258">
+</g>
+<g
+ id="g260">
+</g>
+<g
+ id="g262">
+</g>
+<g
+ id="g264">
+</g>
+<g
+ id="g358"
+ transform="matrix(0.4420831,0,0,0.4420831,20.415636,20.972508)"><path
+ id="path273"
+ d="m 39.598,2.343 c 3.124,-3.124 8.19,-3.124 11.314,0 3.124,3.124 3.124,8.19 0,11.314 z"
+ style="fill:#d75a4a"
+ inkscape:connector-curvature="0" /><polygon
+ id="polygon275"
+ points="42.426,17.899 16.512,43.814 15.982,48.587 44.548,20.02 "
+ style="fill:#ed8a19" /><polygon
+ id="polygon277"
+ points="41.012,16.485 36.77,12.243 10.855,38.157 10.325,42.93 15.098,42.4 "
+ style="fill:#ed8a19" /><polygon
+ id="polygon279"
+ points="35.356,10.829 33.234,8.707 4.668,37.273 9.441,36.743 "
+ style="fill:#ed8a19" /><polygon
+ id="polygon281"
+ points="50.912,13.657 39.598,2.343 37.476,4.465 37.477,4.465 48.79,15.778 "
+ style="fill:#c7cac7" /><polygon
+ id="polygon283"
+ points="34.648,7.293 45.962,18.606 47.376,17.192 36.062,5.879 "
+ style="fill:#c7cac7" /><path
+ id="path285"
+ d="m 14.424,44.488 -5.122,0.569 c -0.036,0.004 -0.073,0.006 -0.109,0.006 0,0 -10e-4,0 -10e-4,0 v 0 0 c -10e-4,0 -10e-4,0 -10e-4,0 -0.036,0 -0.073,-0.002 -0.109,-0.006 C 9.043,45.053 9.011,45.031 8.974,45.022 8.902,45.005 8.833,44.987 8.767,44.955 8.717,44.931 8.674,44.902 8.629,44.871 8.572,44.831 8.52,44.788 8.472,44.737 8.434,44.697 8.403,44.656 8.372,44.61 8.334,44.553 8.303,44.494 8.277,44.429 8.255,44.375 8.239,44.322 8.227,44.264 8.22,44.232 8.203,44.205 8.199,44.172 c -0.004,-0.038 0.01,-0.073 0.01,-0.11 0,-0.038 -0.014,-0.072 -0.01,-0.11 L 8.768,38.83 3.646,39.399 c -0.037,0.004 -0.075,0.006 -0.111,0.006 -0.079,0 -0.152,-0.024 -0.227,-0.042 L 0.442,51.399 2.548,49.293 c 0.391,-0.391 1.023,-0.391 1.414,0 0.391,0.391 0.391,1.023 0,1.414 l -2.106,2.106 12.03,-2.864 C 13.86,49.84 13.843,49.727 13.856,49.61 Z"
+ style="fill:#fbce9d"
+ inkscape:connector-curvature="0" /><path
+ id="path287"
+ d="m 3.962,49.293 c -0.391,-0.391 -1.023,-0.391 -1.414,0 L 0.442,51.399 0,53.255 1.856,52.813 3.962,50.707 c 0.39,-0.391 0.39,-1.023 0,-1.414 z"
+ style="fill:#38454f"
+ inkscape:connector-curvature="0" /><polygon
+ id="polygon289"
+ points="48.79,15.778 37.477,4.465 37.476,4.465 36.062,5.879 47.376,17.192 "
+ style="fill:#f2ecbf" /><path
+ id="path291"
+ d="M 41.012,16.485 15.098,42.4 10.325,42.93 10.855,38.157 36.77,12.243 35.356,10.829 9.441,36.743 4.668,37.273 3.535,38.406 3.307,39.363 c 0.075,0.018 0.147,0.042 0.227,0.042 0.036,0 0.074,-0.002 0.111,-0.006 L 8.767,38.83 8.198,43.952 c -0.004,0.038 0.01,0.073 0.01,0.11 0,0.038 -0.014,0.072 -0.01,0.11 0.004,0.033 0.021,0.06 0.028,0.092 0.012,0.057 0.029,0.112 0.05,0.165 0.026,0.064 0.057,0.124 0.095,0.181 0.03,0.045 0.063,0.088 0.1,0.127 0.047,0.05 0.1,0.094 0.157,0.134 0.044,0.031 0.089,0.061 0.138,0.084 0.065,0.031 0.135,0.05 0.207,0.067 0.038,0.009 0.069,0.03 0.108,0.035 0.036,0.004 0.072,0.006 0.109,0.006 h 0.001 v 0 h 10e-4 10e-4 c 0,0 0.001,0 0.001,0 v 0 c 0.035,0 0.072,-0.002 0.109,-0.006 l 5.122,-0.569 -0.569,5.122 c -0.013,0.118 0.004,0.23 0.03,0.339 l 0.963,-0.229 1.133,-1.132 0.53,-4.773 L 42.426,17.9 Z"
+ style="fill:#ebba16"
+ inkscape:connector-curvature="0" /><polygon
+ id="polygon293"
+ points="42.426,17.899 44.548,20.02 45.962,18.606 34.648,7.293 33.234,8.707 35.356,10.829 36.77,12.243 41.012,16.485 "
+ style="fill:#f2ecbf" /><g
+ id="g295" /><g
+ id="g297" /><g
+ id="g299" /><g
+ id="g301" /><g
+ id="g303" /><g
+ id="g305" /><g
+ id="g307" /><g
+ id="g309" /><g
+ id="g311" /><g
+ id="g313" /><g
+ id="g315" /><g
+ id="g317" /><g
+ id="g319" /><g
+ id="g321" /><g
+ id="g323" /></g></svg>
\ No newline at end of file

RENAME
src/programfiletab.cpp
src/edittab.cpp
-#include "programfiletab.h"
-#include "ui_programfiletab.h"
+#include "edittab.h"
+#include "ui_edittab.h"
#include "parser.h"
#include "pipeline.h"
-ProgramfileTab::ProgramfileTab(QToolBar* toolbar, QWidget* parent)
- : RipesTab(toolbar, parent), m_ui(new Ui::ProgramfileTab) {
+EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_ui(new Ui::EditTab) {
m_ui->setupUi(this);
// Only add syntax highlighter for code edit view - not for translated code. This is assumed to be correct after a
@@ -23,57 +22,47 @@ ProgramfileTab::ProgramfileTab(QToolBar* toolbar, QWidget* parent)
&QScrollBar::setValue);
// Connect data parsing signals from the assembler to this
- connect(m_ui->assemblyedit, &CodeEditor::assembledSuccessfully, this, &ProgramfileTab::assemblingComplete);
+ connect(m_ui->assemblyedit, &CodeEditor::assembledSuccessfully, this, &EditTab::assemblingComplete);
}
-QString ProgramfileTab::getAssemblyText() {
+QString EditTab::getAssemblyText() {
return m_ui->assemblyedit->toPlainText();
}
-const QByteArray& ProgramfileTab::getBinaryData() {
+const QByteArray& EditTab::getBinaryData() {
return m_ui->assemblyedit->getCurrentOutputArray();
}
-void ProgramfileTab::clearOutputArray() {
+void EditTab::clearOutputArray() {
m_ui->assemblyedit->clearOutputArray();
}
-ProgramfileTab::~ProgramfileTab() {
+EditTab::~EditTab() {
delete m_ui;
}
-void ProgramfileTab::setTimerEnabled(bool state) {
+void EditTab::setTimerEnabled(bool state) {
m_ui->assemblyedit->setTimerEnabled(state);
}
-void ProgramfileTab::newProgram() {
- m_ui->assemblyfile->toggle();
+void EditTab::newProgram() {
m_ui->assemblyedit->reset();
m_ui->assemblyedit->clear();
}
-void ProgramfileTab::on_pushButton_clicked() {
- // load file based on current file type selection
- if (m_ui->binaryfile->isChecked()) {
- emit loadBinaryFile();
- } else {
- loadAssemblyFile();
- }
-}
-
-void ProgramfileTab::setAssemblyText(const QString& text) {
+void EditTab::setAssemblyText(const QString& text) {
m_ui->assemblyedit->reset();
m_ui->assemblyedit->setPlainText(text);
}
-void ProgramfileTab::setDisassemblerText() {
+void EditTab::setDisassemblerText() {
const QString& text = m_ui->disassembledViewButton->isChecked() ? Parser::getParser()->getDisassembledRepr()
: Parser::getParser()->getBinaryRepr();
m_ui->binaryedit->setPlainText(text);
m_ui->binaryedit->updateBreakpoints();
}
-void ProgramfileTab::assemblingComplete(const QByteArray& arr, bool clear, uint32_t baseAddress) {
+void EditTab::assemblingComplete(const QByteArray& arr, bool clear, uint32_t baseAddress) {
if (clear)
Parser::getParser()->clear();
// Pretty hacky way to discern between the text and data segments
@@ -86,7 +75,7 @@ void ProgramfileTab::assemblingComplete(const QByteArray& arr, bool clear, uint3
emit updateSimulator();
}
-void ProgramfileTab::on_assemblyfile_toggled(bool checked) {
+void EditTab::on_assemblyfile_toggled(bool checked) {
// Since we are removing the input text/binary info, we need to reset the pipeline
Pipeline::getPipeline()->reset();
@@ -105,19 +94,21 @@ void ProgramfileTab::on_assemblyfile_toggled(bool checked) {
m_ui->binaryedit->clear();
}
-void ProgramfileTab::setInputMode(bool isAssembly) {
+void EditTab::setInputMode(bool isAssembly) {
+ /*
if (isAssembly) {
m_ui->assemblyfile->setChecked(true);
} else {
m_ui->binaryfile->setChecked(true);
}
+ */
}
-void ProgramfileTab::on_disassembledViewButton_toggled(bool checked) {
+void EditTab::on_disassembledViewButton_toggled(bool checked) {
Q_UNUSED(checked)
- if (m_ui->binaryfile->isChecked()) {
- assemblingComplete(Parser::getParser()->getFileByteArray());
- } else {
+ // if (m_ui->binaryfile->isChecked()) {
+ // assemblingComplete(Parser::getParser()->getFileByteArray());
+ //} else {
assemblingComplete(m_ui->assemblyedit->getCurrentOutputArray());
- }
+ // }
}

RENAME
src/programfiletab.h
src/edittab.h
-#ifndef PROGRAMFILETAB_H
-#define PROGRAMFILETAB_H
-
+#pragma once
#include <QFile>
#include <QWidget>
#include "ripestab.h"
namespace Ui {
-class ProgramfileTab;
+class EditTab;
}
-class ProgramfileTab : public RipesTab {
+class EditTab : public RipesTab {
Q_OBJECT
public:
- ProgramfileTab(QToolBar* toolbar, QWidget* parent = nullptr);
- ~ProgramfileTab() override;
+ EditTab(QToolBar* toolbar, QWidget* parent = nullptr);
+ ~EditTab() override;
void setAssemblyText(const QString& text);
void setDisassemblerText();
@@ -33,15 +31,11 @@ signals:
// sent to the processor
private slots:
- void on_pushButton_clicked();
-
void on_assemblyfile_toggled(bool checked);
void assemblingComplete(const QByteArray& binaryCode, bool clear = true, uint32_t baseAddress = 0x0);
void on_disassembledViewButton_toggled(bool checked);
private:
- Ui::ProgramfileTab* m_ui;
+ Ui::EditTab* m_ui;
};
-
-#endif // PROGRAMFILETAB_H

RENAME
src/programfiletab.ui
src/edittab.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>ProgramfileTab</class>
- <widget class="QWidget" name="ProgramfileTab">
+ <class>EditTab</class>
+ <widget class="QWidget" name="EditTab">
<property name="geometry">
<rect>
<x>0</x>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Input type</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_7">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QRadioButton" name="assemblyfile">
- <property name="text">
- <string>Assembly</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="binaryfile">
- <property name="text">
- <string>Binary file</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="placeholderText">
- <string>Current file path...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="pushButton">
- <property name="text">
- <string>Load file</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
#include "aboutwidget.h"
#include "defines.h"
+#include "edittab.h"
#include "memorytab.h"
#include "parser.h"
#include "processortab.h"
-#include "programfiletab.h"
#include "registerwidget.h"
#include "fancytabbar/fancytabbar.h"
@@ -25,15 +25,13 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
setWindowIcon(QIcon(":/icons/logo.svg"));
showMaximized();
- setupMenus();
-
// Create tabs
m_stackedTabs = new QStackedWidget(this);
m_ui->centrallayout->addWidget(m_stackedTabs);
auto* tb = addToolBar("Edit");
tb->setVisible(false);
- m_editTab = new ProgramfileTab(tb, this);
+ m_editTab = new EditTab(tb, this);
m_stackedTabs->insertWidget(0, m_editTab);
tb = addToolBar("Processor");
@@ -54,28 +52,21 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
m_ui->tabbar->setActiveIndex(0);
connect(m_stackedTabs, &QStackedWidget::currentChanged, this, &MainWindow::tabChanged);
-
- m_binaryStoreAction = new QActionGroup(this);
- m_binaryStoreAction->addAction(m_ui->actionSave_as_flat_binary);
- m_binaryStoreAction->addAction(m_ui->actionSave_as_text);
- m_binaryStoreAction->addAction(m_ui->actionDisable);
- m_binaryStoreAction->setExclusive(true);
- m_ui->actionDisable->setChecked(true);
+ tabChanged();
// Setup tab pointers
m_processorTab->initRegWidget();
m_processorTab->initInstructionView();
m_memoryTab->initMemoryTab();
- // setup example projects
- setupExamples();
+ setupMenus();
// setup and connect widgets
- connect(m_editTab, &ProgramfileTab::loadBinaryFile, this, &MainWindow::on_actionLoadBinaryFile_triggered);
- connect(m_editTab, &ProgramfileTab::loadAssemblyFile, this, &MainWindow::on_actionLoadAssemblyFile_triggered);
+ connect(m_editTab, &EditTab::loadBinaryFile, this, &MainWindow::loadBinaryFileTriggered);
+ connect(m_editTab, &EditTab::loadAssemblyFile, this, &MainWindow::loadAssemblyFileTriggered);
connect(m_processorTab, &ProcessorTab::update, this, &MainWindow::updateMemoryTab);
- connect(m_editTab, &ProgramfileTab::updateSimulator, [this] { emit update(); });
+ connect(m_editTab, &EditTab::updateSimulator, [this] { emit update(); });
connect(this, &MainWindow::update, m_processorTab, &ProcessorTab::restart);
connect(this, &MainWindow::updateMemoryTab, m_memoryTab, &MemoryTab::update);
connect(m_stackedTabs, &QStackedWidget::currentChanged, m_memoryTab, &MemoryTab::update);
@@ -91,7 +82,51 @@ void MainWindow::tabChanged() {
}
}
-void MainWindow::setupMenus() {}
+void MainWindow::setupMenus() {
+ // Edit actions
+ const QIcon newIcon = QIcon(":/icons/file.svg");
+ auto* newAction = new QAction(newIcon, "New Assembly Program", this);
+ newAction->setShortcut(QKeySequence::New);
+ connect(newAction, &QAction::triggered, this, &MainWindow::newProgramTriggered);
+ m_ui->menuFile->addAction(newAction);
+ m_editTab->getToolbar()->addAction(newAction);
+
+ const QIcon loadIcon = QIcon(":/icons/loadfile.svg");
+ auto* loadAction = new QAction(loadIcon, "Load file", this);
+ loadAction->setShortcut(QKeySequence::Open);
+ connect(loadAction, &QAction::triggered, this, &MainWindow::loadAssemblyFileTriggered);
+ m_editTab->getToolbar()->addAction(loadAction);
+ m_ui->menuFile->addAction(loadAction);
+
+ m_ui->menuFile->addSeparator();
+
+ auto* examplesMenu = m_ui->menuFile->addMenu("Load Example...");
+ setupExamplesMenu(examplesMenu);
+
+ m_ui->menuFile->addSeparator();
+
+ const QIcon saveIcon = QIcon(":/icons/save.svg");
+ auto* saveAction = new QAction(saveIcon, "Save File", this);
+ saveAction->setShortcut(QKeySequence::Save);
+ connect(saveAction, &QAction::triggered, this, &MainWindow::saveFilesTriggered);
+ m_editTab->getToolbar()->addAction(saveAction);
+ m_ui->menuFile->addAction(saveAction);
+
+ const QIcon saveAsIcon = QIcon(":/icons/saveas.svg");
+ auto* saveAsAction = new QAction(saveAsIcon, "Save File As...", this);
+ saveAsAction->setShortcut(QKeySequence::SaveAs);
+ connect(saveAsAction, &QAction::triggered, this, &MainWindow::saveFilesAsTriggered);
+ m_editTab->getToolbar()->addAction(saveAsAction);
+ m_ui->menuFile->addAction(saveAsAction);
+
+ m_ui->menuFile->addSeparator();
+
+ const QIcon exitIcon = QIcon(":/icons/cancel.svg");
+ auto* exitAction = new QAction(exitIcon, "Exit", this);
+ exitAction->setShortcut(QKeySequence::Quit);
+ connect(exitAction, &QAction::triggered, this, &MainWindow::close);
+ m_ui->menuFile->addAction(exitAction);
+}
void MainWindow::run() {
// Function for triggering the run dialog from unit tests
@@ -103,7 +138,7 @@ MainWindow::~MainWindow() {
}
#include <QDebug>
-void MainWindow::setupExamples() {
+void MainWindow::setupExamplesMenu(QMenu* parent) {
auto binaryExamples = QDir(":/examples/binary/").entryList(QDir::Files);
auto assemblyExamples = QDir(":/examples/assembly/").entryList(QDir::Files);
@@ -118,7 +153,7 @@ void MainWindow::setupExamples() {
});
}
// Add binary example menu to example menu
- m_ui->menuExamples->addMenu(binaryExampleMenu);
+ parent->addMenu(binaryExampleMenu);
}
if (!assemblyExamples.isEmpty()) {
@@ -131,21 +166,21 @@ void MainWindow::setupExamples() {
});
}
// Add binary example menu to example menu
- m_ui->menuExamples->addMenu(assemblyExampleMenu);
+ parent->addMenu(assemblyExampleMenu);
}
}
-void MainWindow::on_actionexit_triggered() {
+void MainWindow::exit() {
close();
}
-void MainWindow::on_actionLoadBinaryFile_triggered() {
+void MainWindow::loadBinaryFileTriggered() {
auto filename = QFileDialog::getOpenFileName(this, "Open binary file", "", "Binary file (*)");
if (!filename.isNull())
loadBinaryFile(filename);
}
-void MainWindow::on_actionLoadAssemblyFile_triggered() {
+void MainWindow::loadAssemblyFileTriggered() {
auto filename = QFileDialog::getOpenFileName(this, "Open assembly file", "", "Assembly file (*.s *.as *.asm)");
if (!filename.isNull())
loadAssemblyFile(filename);
@@ -176,12 +211,12 @@ void MainWindow::loadAssemblyFile(QString fileName) {
m_editTab->setDisassemblerText();
}
-void MainWindow::on_actionAbout_triggered() {
+void MainWindow::about() {
AboutWidget about;
about.exec();
}
-void MainWindow::on_actionOpen_wiki_triggered() {
+void MainWindow::wiki() {
QDesktopServices::openUrl(QUrl(QString("https://github.com/mortbopet/Ripes/wiki")));
}
@@ -207,43 +242,52 @@ void writeBinaryFile(QFile& file, const QByteArray& data) {
} // namespace
-void MainWindow::on_actionSave_Files_triggered() {
+void MainWindow::saveFilesTriggered() {
if (m_currentFile.isEmpty()) {
- on_actionSave_Files_As_triggered();
+ saveFilesAsTriggered();
}
- if (m_ui->actionSave_Source->isChecked()) {
+ // if (m_ui->actionSave_Source->isChecked()) {
+ {
QFile file(m_currentFile);
writeTextFile(file, m_editTab->getAssemblyText());
}
+ //}
- if (m_ui->actionSave_Disassembled->isChecked()) {
+ // if (m_ui->actionSave_Disassembled->isChecked()) {
+ {
QFile file(removeFileExt(m_currentFile) + "_dis.s");
writeTextFile(file, Parser::getParser()->getDisassembledRepr());
}
+ //}
- QAction* binaryStoreAction = m_binaryStoreAction->checkedAction();
- if (binaryStoreAction == m_ui->actionSave_as_flat_binary) {
+ // QAction* binaryStoreAction = m_binaryStoreAction->checkedAction();
+ // if (binaryStoreAction == m_ui->actionSave_as_flat_binary) {
+ {
QFile file(removeFileExt(m_currentFile) + ".bin");
writeBinaryFile(file, m_editTab->getBinaryData());
- } else if (binaryStoreAction == m_ui->actionSave_as_text) {
+ }
+ //} else if (binaryStoreAction == m_ui->actionSave_as_text) {
+
+ {
QFile file(removeFileExt(m_currentFile) + "_bin.txt");
writeTextFile(file, Parser::getParser()->getBinaryRepr());
}
+ //}
}
-void MainWindow::on_actionSave_Files_As_triggered() {
+void MainWindow::saveFilesAsTriggered() {
QFileDialog dialog;
dialog.setNameFilter("*.as *.s");
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix(".s");
if (dialog.exec()) {
m_currentFile = dialog.selectedFiles()[0];
- on_actionSave_Files_triggered();
+ saveFilesTriggered();
}
}
-void MainWindow::on_actionNew_Program_triggered() {
+void MainWindow::newProgramTriggered() {
QMessageBox mbox;
mbox.setWindowTitle("New Program...");
mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
@@ -253,7 +297,7 @@ void MainWindow::on_actionNew_Program_triggered() {
auto ret = mbox.exec();
switch (ret) {
case QMessageBox::Yes: {
- on_actionSave_Files_As_triggered();
+ saveFilesAsTriggered();
break;
}
case QMessageBox::No: {
@@ -270,7 +314,7 @@ void MainWindow::on_actionNew_Program_triggered() {
auto ret = mbox.exec();
switch (ret) {
case QMessageBox::Yes: {
- on_actionSave_Files_triggered();
+ saveFilesTriggered();
break;
}
case QMessageBox::No: {

MODIFY
src/mainwindow.h
src/mainwindow.h
@@ -9,7 +9,7 @@ class MainWindow;
QT_FORWARD_DECLARE_CLASS(QToolBar)
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
-class ProgramfileTab;
+class EditTab;
class MemoryTab;
class ProcessorTab;
@@ -28,22 +28,18 @@ public:
void run();
private slots:
- void on_actionexit_triggered();
+ void exit();
+ void about();
+ void wiki();
- void on_actionLoadBinaryFile_triggered();
- void on_actionLoadAssemblyFile_triggered();
+ void loadBinaryFileTriggered();
+ void loadAssemblyFileTriggered();
+ void saveFilesTriggered();
+ void saveFilesAsTriggered();
+ void newProgramTriggered();
- void on_actionAbout_triggered();
-
- void on_actionOpen_wiki_triggered();
void processorUpdated() { emit updateMemoryTab(); }
- void on_actionSave_Files_triggered();
-
- void on_actionSave_Files_As_triggered();
-
- void on_actionNew_Program_triggered();
-
void tabChanged();
signals:
@@ -54,7 +50,7 @@ private:
void setupMenus();
Ui::MainWindow* m_ui;
- void setupExamples();
+ void setupExamplesMenu(QMenu* parent);
QString m_currentFile = QString();
QActionGroup* m_binaryStoreAction;
QToolBar* m_toolbar = nullptr;
@@ -62,6 +58,6 @@ private:
// Tabs
QStackedWidget* m_stackedTabs = nullptr;
ProcessorTab* m_processorTab = nullptr;
- ProgramfileTab* m_editTab = nullptr;
+ EditTab* m_editTab = nullptr;
MemoryTab* m_memoryTab = nullptr;
};

MODIFY
src/mainwindow.ui
src/mainwindow.ui
<property name="title">
<string>File</string>
</property>
- <widget class="QMenu" name="menuExamples">
- <property name="title">
- <string>Load Example...</string>
- </property>
- </widget>
- <widget class="QMenu" name="menuSave_Binary">
- <property name="title">
- <string>Save Binary</string>
- </property>
- <addaction name="actionDisable"/>
- <addaction name="actionSave_as_text"/>
- <addaction name="actionSave_as_flat_binary"/>
- </widget>
- <addaction name="actionNew_Program"/>
- <addaction name="actionLoadBinaryFile"/>
- <addaction name="actionLoadAssemblyFile"/>
- <addaction name="separator"/>
- <addaction name="menuExamples"/>
- <addaction name="separator"/>
- <addaction name="actionSave_Files"/>
- <addaction name="actionSave_Files_As"/>
- <addaction name="actionSave_Source"/>
- <addaction name="actionSave_Disassembled"/>
- <addaction name="menuSave_Binary"/>
- <addaction name="separator"/>
- <addaction name="actionexit"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<addaction name="menuFile"/>
<addaction name="menuHelp"/>
</widget>
- <action name="actionLoadBinaryFile">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/loadfile.svg</normaloff>:/icons/loadfile.svg</iconset>
- </property>
- <property name="text">
- <string>Load Binary File</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+O</string>
- </property>
- </action>
- <action name="actionexit">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/exit.svg</normaloff>:/icons/exit.svg</iconset>
- </property>
- <property name="text">
- <string>Exit</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+Q</string>
- </property>
- </action>
- <action name="actionRun">
- <property name="text">
- <string>Run</string>
- </property>
- </action>
- <action name="actionStep">
- <property name="text">
- <string>Step</string>
- </property>
- </action>
- <action name="actionPrev">
- <property name="text">
- <string>Prev</string>
- </property>
- </action>
- <action name="actionReset">
- <property name="text">
- <string>Reset</string>
- </property>
- </action>
- <action name="actionDump">
- <property name="text">
- <string>Dump</string>
- </property>
- </action>
- <action name="actionLoadAssemblyFile">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/loadfile.svg</normaloff>:/icons/loadfile.svg</iconset>
- </property>
- <property name="text">
- <string>Load Assembly File</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+Shift+O</string>
- </property>
- </action>
- <action name="actionShow_consoles">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Show application output console</string>
- </property>
- </action>
<action name="actionAbout">
<property name="icon">
<iconset>
<string>Wiki</string>
</property>
</action>
- <action name="actionSave_Files">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/save.svg</normaloff>:/icons/save.svg</iconset>
- </property>
- <property name="text">
- <string>Save Files</string>
- </property>
- <property name="toolTip">
- <string>Save Selected Files</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+S</string>
- </property>
- </action>
- <action name="actionSave_Files_As">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/save.svg</normaloff>:/icons/save.svg</iconset>
- </property>
- <property name="text">
- <string>Save Files As...</string>
- </property>
- <property name="toolTip">
- <string>Save Selected Files As...</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+Shift+S</string>
- </property>
- </action>
- <action name="actionSave_Source">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Save Source</string>
- </property>
- </action>
- <action name="actionSave_Disassembled">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Save Disassembled</string>
- </property>
- </action>
- <action name="actionDisable">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Disable</string>
- </property>
- </action>
- <action name="actionSave_as_text">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Save as text</string>
- </property>
- </action>
- <action name="actionSave_as_flat_binary">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Save as flat binary</string>
- </property>
- </action>
- <action name="actionNew_Program">
- <property name="icon">
- <iconset>
- <normaloff>:/icons/file.svg</normaloff>:/icons/file.svg</iconset>
- </property>
- <property name="text">
- <string>New Program...</string>
- </property>
- </action>
</widget>
<customwidgets>
<customwidget>

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -77,13 +77,14 @@ void ProcessorTab::setupSimulatorActions() {
m_autoClockAction->setChecked(false);
m_toolbar->addAction(m_autoClockAction);
- QSpinBox* stepSpinBox = new QSpinBox();
- stepSpinBox->setRange(1, 10000);
- stepSpinBox->setSuffix(" ms");
- stepSpinBox->setToolTip("Auto clock interval");
- connect(stepSpinBox, qOverload<int>(&QSpinBox::valueChanged), [timer](int msec) { timer->setInterval(msec); });
- stepSpinBox->setValue(100);
- m_toolbar->addWidget(stepSpinBox);
+ m_autoClockInterval = new QSpinBox(this);
+ m_autoClockInterval->setRange(1, 10000);
+ m_autoClockInterval->setSuffix(" ms");
+ m_autoClockInterval->setToolTip("Auto clock interval");
+ connect(m_autoClockInterval, qOverload<int>(&QSpinBox::valueChanged),
+ [timer](int msec) { timer->setInterval(msec); });
+ m_autoClockInterval->setValue(100);
+ m_toolbar->addWidget(m_autoClockInterval);
const QIcon runIcon = QIcon(":/icons/run.svg");
m_runAction = new QAction(runIcon, "Run (F8)", this);

MODIFY
src/processortab.h
src/processortab.h
#define PROCESSORTAB_H
#include <QAction>
+#include <QSpinBox>
#include <QTimer>
#include <QToolBar>
#include <QWidget>
@@ -65,6 +66,8 @@ private:
QAction* m_pipelineTableAction = nullptr;
QAction* m_reverseAction = nullptr;
QAction* m_resetAction = nullptr;
+
+ QSpinBox* m_autoClockInterval = nullptr;
};
#endif // PROCESSORTAB_H

Refactor EditTab to use its toolbar for editor control