diff --git a/OSBindings/Qt/main.cpp b/OSBindings/Qt/main.cpp index 2b1771628..59912a79f 100644 --- a/OSBindings/Qt/main.cpp +++ b/OSBindings/Qt/main.cpp @@ -14,6 +14,8 @@ int main(int argc, char *argv[]) format.setStencilBufferSize(0); QSurfaceFormat::setDefaultFormat(format); + // TODO: something with QCommandLineParser to accept a file to launch. + QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 6c841f024..11e7273b5 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -35,33 +35,52 @@ void MainWindow::createActions() { // Create a file menu. QMenu *fileMenu = menuBar()->addMenu(tr("&File")); -// QAction *newAct = new QAction(tr("&New"), this); -// newAct->setShortcuts(QKeySequence::New); -// newAct->setStatusTip(tr("Create a new file")); -// connect(newAct, &QAction::triggered, this, &MainWindow::newFile); -// fileMenu->addAction(newAct); + // Add file option: 'New...' + QAction *newAct = new QAction(tr("&New"), this); + newAct->setShortcuts(QKeySequence::New); + newAct->setStatusTip(tr("Create a new file")); + 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); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); connect(openAct, &QAction::triggered, this, &MainWindow::open); 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() { QString fileName = QFileDialog::getOpenFileName(this); if(!fileName.isEmpty()) { targets = Analyser::Static::GetTargets(fileName.toStdString()); - if(targets.empty()) { - qDebug() << "Not media:" << fileName; - } else { - qDebug() << "Got media:" << fileName; + if(!targets.empty()) { launchMachine(); } } } +void MainWindow::newFile() { +} + +void MainWindow::about() { + QMessageBox::about(this, tr("About Clock Signal"), + tr( "

Clock Signal is an emulator of various platforms by " + "Thomas Harte.

" + + "

This emulator is offered under the MIT licence; its source code " + "is available from GitHub.

" + + "

This port is experimental, especially with regard to latency; " + "please don't hesitate to provide feedback.

" + )); +} + MainWindow::~MainWindow() { // Stop the audio output, and its thread. 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 nativeSource = QDir::toNativeSeparators(QString::fromStdString(source)).toStdString(); - qDebug() << "Taking a run at " << nativeSource.c_str(); - file = fopen(nativeSource.c_str(), "rb"); if(file) break; } @@ -276,7 +293,6 @@ void MainWindow::dropEvent(QDropEvent* event) { case UIPhase::RunningMachine: // Attempt to insert into the running machine. - qDebug() << "Should start machine"; break; } } diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index ff5ddc53d..36dfb4ec8 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -61,6 +61,8 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat private slots: void open(); + void newFile(); + void about(); }; #endif // MAINWINDOW_H