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:
parent
59458f6444
commit
9ca6a1031c
@ -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();
|
||||
|
@ -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( "<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() {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
|
||||
|
||||
private slots:
|
||||
void open();
|
||||
void newFile();
|
||||
void about();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user