ch
This commit is contained in:
parent
1d357c6c96
commit
d40c23038a
30 changed files with 208 additions and 100 deletions
|
|
@ -2,29 +2,38 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QGuiApplication::setWindowIcon(QIcon("logo.png"));
|
||||
QAction *actionLoad = new QAction(tr("Load"), this);
|
||||
ui->menuLoad->addAction(actionLoad);
|
||||
|
||||
executor = new Executor(&machine);
|
||||
executorThread = new QThread(this);
|
||||
executor.moveToThread(executorThread);
|
||||
connect(this, &MainWindow::startExecutor, &executor, &Executor::start);
|
||||
connect(this, &MainWindow::stopExecutor, &executor, &Executor::stop);
|
||||
connect(this, &MainWindow::stepExecutor, &executor, &Executor::step);
|
||||
|
||||
executor->moveToThread(executorThread);
|
||||
|
||||
connect(this, &MainWindow::startExecutor, executor, &Executor::start, Qt::QueuedConnection);
|
||||
connect(this, &MainWindow::stopExecutor, executor, &Executor::stop, Qt::QueuedConnection);
|
||||
connect(this, &MainWindow::stepExecutor, executor, &Executor::step, Qt::QueuedConnection);
|
||||
|
||||
connect(executor, &Executor::updateRequested, this, &MainWindow::updateUI, Qt::QueuedConnection);
|
||||
connect(executor, &Executor::signalStarted, this, &MainWindow::setStatusLightRunning, Qt::QueuedConnection);
|
||||
connect(executor, &Executor::signalStopped, this, &MainWindow::setStatusLightStopped, Qt::QueuedConnection);
|
||||
connect(executor, &Executor::signalEnded, this, &MainWindow::setStatusLightEnded, Qt::QueuedConnection);
|
||||
|
||||
executorThread->start();
|
||||
connect(&executor, &Executor::updateRequested, this, &MainWindow::updateUI);
|
||||
connect(&executor, &Executor::signalStarted, this, &MainWindow::setStatusLightRunning);
|
||||
connect(&executor, &Executor::signalStopped, this, &MainWindow::setStatusLightStopped);
|
||||
connect(&executor, &Executor::signalEnded, this, &MainWindow::setStatusLightEnded);
|
||||
|
||||
connect(ui->menuVizitka, &QMenu::aboutToShow, this, &MainWindow::on_menuVizitka_triggered);
|
||||
|
||||
connect(actionLoad, &QAction::triggered, this, &MainWindow::onLoadTriggered);
|
||||
connect(ui->runButton, &QPushButton::clicked, this, &MainWindow::on_runButton_clicked);
|
||||
connect(ui->stepButton, &QPushButton::clicked, this, &MainWindow::on_stepButton_clicked);
|
||||
//connect(ui->runButton, &QPushButton::clicked, this, &MainWindow::on_runButton_clicked);
|
||||
//connect(ui->stepButton, &QPushButton::clicked, this, &MainWindow::on_stepButton_clicked);
|
||||
|
||||
updateUI();
|
||||
ui->statusLight->setFixedSize(16,16);
|
||||
|
|
@ -66,6 +75,7 @@ MainWindow::~MainWindow()
|
|||
{
|
||||
executorThread->quit();
|
||||
executorThread->wait();
|
||||
delete executor;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +124,7 @@ void MainWindow::updateUI()
|
|||
void MainWindow::onLoadTriggered() {
|
||||
machine.resetRegisters();
|
||||
machine.resetMemory();
|
||||
executor.resetProgram();
|
||||
executor->resetProgram();
|
||||
updateUI();
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Object File"), "", tr("Object Files (*.obj)"));
|
||||
if (!filename.isEmpty()) {
|
||||
|
|
@ -162,7 +172,6 @@ void MainWindow::on_stopButton_clicked()
|
|||
emit stopExecutor();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setStatusLightRunning() {
|
||||
ui->statusLight->setStyleSheet("background-color: green; border-radius: 8px;");
|
||||
}
|
||||
|
|
@ -174,3 +183,16 @@ void MainWindow::setStatusLightStopped() {
|
|||
void MainWindow::setStatusLightEnded() {
|
||||
ui->statusLight->setStyleSheet("background-color: black; border-radius: 8px;");
|
||||
}
|
||||
|
||||
void MainWindow::on_menuVizitka_triggered()
|
||||
{
|
||||
QMessageBox::information(
|
||||
this,
|
||||
"Vizitka",
|
||||
"Aljaž Brodar\n"
|
||||
"Sistemska programska oprema\n"
|
||||
"Simulator SIC/XE\n"
|
||||
"2025\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue