Add statusbar with indicators for system call handling info
MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
#include <QFileDialog>
#include <QFontDatabase>
#include <QIcon>
+#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QStackedWidget>
+#include <QStatusBar>
#include <QTemporaryFile>
#include <QTextStream>
@@ -90,6 +92,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
connect(&SystemIO::get(), &SystemIO::doPrint, m_processorTab, &ProcessorTab::printToLog);
+ // Setup status bar
+ setupStatusBar();
+
// Reset and program reload signals
connect(m_memoryTab, &MemoryTab::reqProcessorReset, m_processorTab, &ProcessorTab::reset);
connect(ProcessorHandler::get(), &ProcessorHandler::reqProcessorReset, m_processorTab, &ProcessorTab::reset);
@@ -108,6 +113,22 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
m_processorToolbar->setVisible(true);
}
+#define setupStatusWidget(name) \
+ auto* name##StatusLabel = new QLabel(this); \
+ statusBar()->addWidget(name##StatusLabel); \
+ connect(&name##StatusManager::get().emitter, &StatusEmitter::statusChanged, name##StatusLabel, &QLabel::setText); \
+ connect(&name##StatusManager::get().emitter, &StatusEmitter::clear, name##StatusLabel, &QLabel::clear);
+
+void MainWindow::setupStatusBar() {
+ statusBar()->showMessage("");
+
+ // Setup syscall status widget
+ setupStatusWidget(Syscall);
+
+ // Setup systemIO status widget
+ setupStatusWidget(SystemIO);
+}
+
void MainWindow::tabChanged() {
m_editToolbar->setVisible(m_editTab->isVisible());
m_memoryToolbar->setVisible(m_memoryTab->isVisible());

MODIFY
src/mainwindow.h
src/mainwindow.h
@@ -51,6 +51,7 @@ signals:
private:
void loadFile(const QString& filename, SourceType type);
+ void setupStatusBar();
void setupMenus();
void setupExamplesMenu(QMenu* parent);

ADD
src/statusmanager.h
+#pragma once
+
+#include <QObject>
+#include <QString>
+
+namespace Ripes {
+class StatusEmitter : public QObject {
+ Q_OBJECT
+public:
+ void setStatus(const QString& s) { emit statusChanged(s); }
+ void clearStatus() { emit clear(); }
+
+signals:
+ void statusChanged(const QString&);
+ void clear();
+};
+} // namespace Ripes
+
+/**
+ * @brief StatusManager
+ * Defines a singleton class which may be used to send or clear a message to a specific label within the main window
+ * status bar.
+ */
+#define StatusManager(name) \
+ class name##StatusManager { \
+ public: \
+ static name##StatusManager& get() { \
+ static name##StatusManager s; \
+ return s; \
+ } \
+ \
+ static void setStatus(const QString& s) { get().emitter.setStatus(s); } \
+ static void clearStatus() { get().emitter.clearStatus(); } \
+ StatusEmitter emitter; \
+ \
+ private: \
+ name##StatusManager() {} \
+ };

MODIFY
src/syscall/ripes_syscall.h
src/syscall/ripes_syscall.h
#include <QAbstractEventDispatcher>
#include <QApplication>
+#include <QLabel>
#include <QMessageBox>
#include <QString>
#include <QThread>
#include <map>
#include <memory>
+#include "statusmanager.h"
+
namespace Ripes {
/**
@@ -55,6 +58,13 @@ protected:
const std::map<unsigned, QString> m_returnDescriptions;
};
+/**
+ * @brief SyscallStatusManager
+ * Any syscall status messages may be posted to the following class. This class is connected to a status bar widget
+ * in the mainwindow and subsequently displays all messages to the user.
+ */
+StatusManager(Syscall);
+
/**
* @brief The SyscallManager class
*
@@ -75,7 +85,11 @@ public:
"\nRefer to \"Help->System calls\" for a list of support system calls.");
});
} else {
- m_syscalls.at(id)->execute();
+ const auto& syscall = m_syscalls.at(id);
+ SyscallStatusManager::setStatus("Handling system call: " + syscall->name() + " (" + QString::number(id) +
+ ")");
+ syscall->execute();
+ SyscallStatusManager::clearStatus();
}
}

MODIFY
src/syscall/systemio.h
src/syscall/systemio.h
#include <sys/stat.h>
+#include "statusmanager.h"
+
namespace Ripes {
+StatusManager(SystemIO);
+
/*
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
@@ -325,6 +329,7 @@ public:
auto& InputStream = FileIOData::getStreamInUse(fd);
if (fd == STDIN) {
+ SystemIOStatusManager::setStatus("Waiting for user input...");
while (myBuffer.size() == 0) {
// Lock the stdio objects and try to read from stdio. If no data is present, wait until so.
FileIOData::s_stdioMutex.lock();
@@ -335,6 +340,7 @@ public:
if (s_abortSyscall) {
FileIOData::s_stdioMutex.unlock();
s_abortSyscall = false;
+ SystemIOStatusManager::clearStatus();
return -1;
}
if (dataInStdinStrm) {
@@ -357,6 +363,7 @@ public:
}
}
+ SystemIOStatusManager::clearStatus();
return myBuffer.size();
} // end readFromFile

Add statusbar with indicators for system call handling info