From e6ca4b4568e311b47239bfe83de15ed9e91c57b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 15 Dec 2017 22:45:28 +0100 Subject: Implement few initial graphic elements --- qtmips_gui/mainwindow.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'qtmips_gui/mainwindow.cpp') diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index ea48736..157baf4 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -18,11 +18,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { registers->hide(); // Connect signals from menu - QObject::connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); - QObject::connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); - QObject::connect(ui->actionCache, SIGNAL(triggered(bool)), this, SLOT(show_cache_content())); - QObject::connect(ui->actionCache_statistics, SIGNAL(triggered(bool)), this, SLOT(show_cache_statictics())); - QObject::connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); + connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); + connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); + connect(ui->actionCache, SIGNAL(triggered(bool)), this, SLOT(show_cache_content())); + connect(ui->actionCache_statistics, SIGNAL(triggered(bool)), this, SLOT(show_cache_statictics())); + connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); // Restore application state from settings restoreState(settings->value("windowState").toByteArray()); @@ -39,6 +39,8 @@ MainWindow::~MainWindow() { delete cache_statictics; delete registers; delete ui; + if (machine != nullptr) + delete machine; } void MainWindow::start() { @@ -50,9 +52,19 @@ void MainWindow::create_core(MachineConfig *config) { // Create machine machine = new QtMipsMachine(config); // Create machine view - coreview = new CoreView(this); + coreview = new CoreView(this, machine); this->setCentralWidget(coreview); - // TODO connect signals + + machine->set_speed(1000); // Set default speed to 1 sec + + // Connect machine signals + connect(ui->actionRun, SIGNAL(triggered(bool)), machine, SLOT(play())); + connect(ui->actionPause, SIGNAL(triggered(bool)), machine, SLOT(pause())); + connect(ui->actionStep, SIGNAL(triggered(bool)), machine, SLOT(step())); + connect(ui->actionRestart, SIGNAL(triggered(bool)), machine, SLOT(restart())); + + // Setup docks + registers->setup(machine); } void MainWindow::new_machine() { -- cgit v1.2.3