Add CompilerErrorDialog for displaying CC errors
ADD
src/compilererrordialog.cpp
+#include "compilererrordialog.h"
+#include "ui_compilererrordialog.h"
+
+namespace Ripes {
+
+CompilerErrorDialog::CompilerErrorDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::CompilerErrorDialog) {
+ m_ui->setupUi(this);
+
+ setWindowTitle("Compilation error");
+}
+
+void CompilerErrorDialog::setText(const QString& text) {
+ m_ui->infoText->setText(text);
+}
+void CompilerErrorDialog::setErrorText(const QString& text) {
+ m_ui->errorText->setPlainText(text);
+}
+
+CompilerErrorDialog::~CompilerErrorDialog() {
+ delete m_ui;
+}
+
+} // namespace Ripes

ADD
src/compilererrordialog.h
+#pragma once
+#include <QDialog>
+
+namespace Ripes {
+namespace Ui {
+class CompilerErrorDialog;
+}
+
+/**
+ * @brief The CompilerErrorDialog class
+ * Small class for displaying a QRichTextEdit along with a label, to nicely display a compiler output message. This
+ * class is used instead of QMessageBox and its "set detailed text" functionality, due to the missing option of manually
+ * resizing a QMessageBox.
+ */
+class CompilerErrorDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit CompilerErrorDialog(QWidget* parent = nullptr);
+ ~CompilerErrorDialog();
+
+ void setText(const QString&);
+ void setErrorText(const QString&);
+
+private:
+ Ui::CompilerErrorDialog* m_ui;
+};
+
+} // namespace Ripes

ADD
src/compilererrordialog.ui
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Ripes::CompilerErrorDialog</class>
+ <widget class="QDialog" name="Ripes::CompilerErrorDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>567</width>
+ <height>293</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="infoText">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="errorText">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>Ripes::CompilerErrorDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>Ripes::CompilerErrorDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>

MODIFY
src/edittab.cpp
src/edittab.cpp
#include <QPushButton>
#include "ccmanager.h"
+#include "compilererrordialog.h"
#include "editor/codeeditor.h"
#include "parser.h"
#include "processorhandler.h"
@@ -21,13 +22,12 @@ EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent)
m_ui->setupUi(this);
connect(m_ui->enableEditor, &QPushButton::clicked, this, &EditTab::enableAssemblyInput);
+ connect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
m_ui->programViewer->setReadOnly(true);
m_assembler = std::make_unique<Assembler>();
- connect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
-
connect(m_ui->setAssemblyInput, &QRadioButton::toggled, this, &EditTab::sourceTypeChanged);
connect(m_ui->setCInput, &QRadioButton::toggled, this, &EditTab::sourceTypeChanged);
@@ -163,11 +163,10 @@ void EditTab::compile() {
loadFile(params);
// Clean up temporary source and output files
} else {
- QMessageBox compileErrorMsg(this);
- compileErrorMsg.setWindowTitle("Compile error");
- compileErrorMsg.setText("Compilation failed.\nView detailed text for compiler output.");
- compileErrorMsg.setDetailedText(CCManager::getError());
- compileErrorMsg.exec();
+ CompilerErrorDialog errDiag(this);
+ errDiag.setText("Compilation failed. Error output was:");
+ errDiag.setErrorText(CCManager::getError());
+ errDiag.exec();
}
res.clean();
}
@@ -201,12 +200,10 @@ void EditTab::updateProgramViewer() {
}
void EditTab::enableEditor() {
- connect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
m_ui->editorStackedWidget->setCurrentIndex(0);
}
void EditTab::disableEditor() {
- disconnect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
m_ui->editorStackedWidget->setCurrentIndex(1);
clearAssemblyEditor();
m_editorEnabled = false;

Add CompilerErrorDialog for displaying CC errors