diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 88762db58..b2a1c8e40 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -403,7 +403,7 @@ void MainWindow::launchMachine() { break; case Analyser::Machine::AppleII: - addDisplayMenu(settingsPrefix, "Colour", "Monochrome", "", ""); + addAppleIIMenu(); break; case Analyser::Machine::Atari2600: @@ -671,6 +671,41 @@ void MainWindow::toggleAtari2600Switch(Atari2600Switch toggleSwitch) { }); } +void MainWindow::addAppleIIMenu() { + // Add the standard display settings. + addDisplayMenu(settingsPrefix, "Colour", "Monochrome", "", ""); + + // Add an additional tick box, for square pixels. + QAction *const squarePixelsAction = new QAction(tr("Square Pixels")); + squarePixelsAction->setCheckable(true); + connect(squarePixelsAction, &QAction::triggered, this, [=] { + std::lock_guard lock_guard(machineMutex); + + // Apply the new setting to the machine. + setAppleIISquarePixels(squarePixelsAction->isChecked()); + + // Also store it. + Settings settings; + settings.setValue("appleII.squarePixels", squarePixelsAction->isChecked()); + }); + displayMenu->addAction(squarePixelsAction); + + // Establish initial selection. + Settings settings; + const bool useSquarePixels = settings.value("appleII.squarePixels").toBool(); + squarePixelsAction->setIsChecked(useSquarePixels); + setAppleIISquarePixels(useSquarePixels); +} + +void MainWindow::setAppleIISquarePixels(bool squarePixels) { + const auto configurable = dynamic_cast<Configurable::Device *>(machine->raw_pointer()); + auto options = configurable->get_options(); + auto appleii_configurable = static_cast<Apple::II::Machine::Options *>(options.get()); + + appleii_configurable->use_square_pixels = squarePixelsAction->isChecked(); + configurable->set_options(options); +} + void MainWindow::speaker_did_complete_samples(Outputs::Speaker::Speaker *, const std::vector<int16_t> &buffer) { audioBuffer.write(buffer); } diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index b83f92633..2fe4230ed 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -137,6 +137,9 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat void addAtari2600Menu(); void toggleAtari2600Switch(Atari2600Switch toggleSwitch); + void addAppleIIMenu(); + void setAppleIISquarePixels(bool); + void setWindowTitle(); bool mouseIsCaptured = false;