-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathonboardwindow.cpp
42 lines (36 loc) · 1.08 KB
/
onboardwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "onboardwindow.h"
#include "./ui_onboardwindow.h"
#include "chip8ui.h"
OnboardWindow::OnboardWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::OnboardWindow)
{
ui->setupUi(this);
selectedFilePath = "";
}
OnboardWindow::~OnboardWindow()
{
delete ui;
}
Q_NORETURN void OnboardWindow::on_cancelButton_released()
{
exit(0);
}
void OnboardWindow::on_selectFileButton_released()
{
QString selectedROMFilePath = QFileDialog::getOpenFileName(nullptr, tr("Select a Chip8 ROM file"));
if (selectedROMFilePath == "") { return; }
selectedFilePath = selectedROMFilePath;
ui->selectFileButton->setText(selectedFilePath);
}
void OnboardWindow::on_okButton_released()
{
if (selectedFilePath == "" || !fileExists(selectedFilePath) ) {
QMessageBox::warning(this, tr("Warning"), tr("Chip8 ROM not selected or file does not exist."));
} else {
Chip8UI* chip8Emu = new Chip8UI(this);
std::string filenameStdStr = selectedFilePath.toStdString();
chip8Emu->readChip8ROM(filenameStdStr.c_str());
chip8Emu->show();
}
}