1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Adds an 'about' box and a hypothetical 'New' file option.

This commit is contained in:
Thomas Harte 2020-06-16 23:15:47 -04:00
parent 59458f6444
commit 9ca6a1031c
3 changed files with 33 additions and 13 deletions

View File

@ -14,6 +14,8 @@ int main(int argc, char *argv[])
format.setStencilBufferSize(0); format.setStencilBufferSize(0);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
// TODO: something with QCommandLineParser to accept a file to launch.
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -35,33 +35,52 @@ void MainWindow::createActions() {
// Create a file menu. // Create a file menu.
QMenu *fileMenu = menuBar()->addMenu(tr("&File")); QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
// QAction *newAct = new QAction(tr("&New"), this); // Add file option: 'New...'
// newAct->setShortcuts(QKeySequence::New); QAction *newAct = new QAction(tr("&New"), this);
// newAct->setStatusTip(tr("Create a new file")); newAct->setShortcuts(QKeySequence::New);
// connect(newAct, &QAction::triggered, this, &MainWindow::newFile); newAct->setStatusTip(tr("Create a new file"));
// fileMenu->addAction(newAct); connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
fileMenu->addAction(newAct);
// Add file option: 'Open..." // Add file option: 'Open...'
QAction *openAct = new QAction(tr("&Open..."), this); QAction *openAct = new QAction(tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open); openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file")); openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, &QAction::triggered, this, &MainWindow::open); connect(openAct, &QAction::triggered, this, &MainWindow::open);
fileMenu->addAction(openAct); fileMenu->addAction(openAct);
// Add Help menu, with an 'About...' option.
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
aboutAct->setStatusTip(tr("Show the application's About box"));
} }
void MainWindow::open() { void MainWindow::open() {
QString fileName = QFileDialog::getOpenFileName(this); QString fileName = QFileDialog::getOpenFileName(this);
if(!fileName.isEmpty()) { if(!fileName.isEmpty()) {
targets = Analyser::Static::GetTargets(fileName.toStdString()); targets = Analyser::Static::GetTargets(fileName.toStdString());
if(targets.empty()) { if(!targets.empty()) {
qDebug() << "Not media:" << fileName;
} else {
qDebug() << "Got media:" << fileName;
launchMachine(); launchMachine();
} }
} }
} }
void MainWindow::newFile() {
}
void MainWindow::about() {
QMessageBox::about(this, tr("About Clock Signal"),
tr( "<p>Clock Signal is an emulator of various platforms by "
"<a href=\"mailto:thomas.harte@gmail.com\">Thomas Harte</a>.</p>"
"<p>This emulator is offered under the MIT licence; its source code "
"is available from <a href=\"https://github.com/tomharte/CLK\">GitHub</a>.</p>"
"<p>This port is experimental, especially with regard to latency; "
"please don't hesitate to provide feedback.</p>"
));
}
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
// Stop the audio output, and its thread. // Stop the audio output, and its thread.
if(audioOutput) { if(audioOutput) {
@ -111,8 +130,6 @@ void MainWindow::launchMachine() {
const std::string source = path.toStdString() + "/ROMImages/" + rom.machine_name + "/" + rom.file_name; const std::string source = path.toStdString() + "/ROMImages/" + rom.machine_name + "/" + rom.file_name;
const std::string nativeSource = QDir::toNativeSeparators(QString::fromStdString(source)).toStdString(); const std::string nativeSource = QDir::toNativeSeparators(QString::fromStdString(source)).toStdString();
qDebug() << "Taking a run at " << nativeSource.c_str();
file = fopen(nativeSource.c_str(), "rb"); file = fopen(nativeSource.c_str(), "rb");
if(file) break; if(file) break;
} }
@ -276,7 +293,6 @@ void MainWindow::dropEvent(QDropEvent* event) {
case UIPhase::RunningMachine: case UIPhase::RunningMachine:
// Attempt to insert into the running machine. // Attempt to insert into the running machine.
qDebug() << "Should start machine";
break; break;
} }
} }

View File

@ -61,6 +61,8 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
private slots: private slots:
void open(); void open();
void newFile();
void about();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H