From 85fab2abc4010f004c553efa2d7d1a3f9f0e2e6b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 8 Jun 2021 17:37:46 -0400 Subject: [PATCH] Takes a swing at adding a square pixels toggle for Qt. --- OSBindings/Qt/mainwindow.cpp | 37 +++++++++++++++++++++++++++++++++++- OSBindings/Qt/mainwindow.h | 3 +++ 2 files changed, 39 insertions(+), 1 deletion(-) 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(machine->raw_pointer()); + auto options = configurable->get_options(); + auto appleii_configurable = static_cast(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 &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;