From c06242f07721a7d86dc2d9795622d6646ae6c88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 4 Jan 2018 18:44:28 +0100 Subject: Implement some machine execution speed control for gui --- qtmips_gui/mainwindow.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'qtmips_gui/mainwindow.cpp') diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 9384890..d1a9770 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -21,12 +21,24 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { registers = new RegistersDock(this); registers->hide(); + // Execution speed actions + speed_group = new QActionGroup(this); + speed_group->addAction(ui->ips1); + speed_group->addAction(ui->ips5); + speed_group->addAction(ui->ips10); + speed_group->addAction(ui->ipsUnlimited); + ui->ips1->setChecked(true); + // Connect signals from menu 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())); + connect(ui->ips1, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ips5, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ips10, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ipsUnlimited, SIGNAL(toggled(bool)), this, SLOT(set_speed())); // Restore application state from settings restoreState(settings->value("windowState").toByteArray()); @@ -63,7 +75,7 @@ void MainWindow::create_core(machine::MachineConfig *config) { // Create machine view corescene = new CoreViewScene(coreview, machine); - machine->set_speed(1000); // Set default speed to 1 sec + set_speed(); // Update machine speed to current settings // Connect machine signals and slots connect(ui->actionRun, SIGNAL(triggered(bool)), machine, SLOT(play())); @@ -100,6 +112,20 @@ void MainWindow::show_registers() { show_dockwidget(registers); } +void MainWindow::set_speed() { + if (machine == nullptr) + return; // just ignore + + if (ui->ips1->isChecked()) + machine->set_speed(1000); + else if (ui->ips5->isChecked()) + machine->set_speed(500); + else if (ui->ips10->isChecked()) + machine->set_speed(100); + else + machine->set_speed(0); +} + void MainWindow::closeEvent(QCloseEvent *event) { settings->setValue("windowGeometry", saveGeometry()); settings->setValue("windowState", saveState()); -- cgit v1.2.3