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

Takes a swing at adding a square pixels toggle for Qt.

This commit is contained in:
Thomas Harte 2021-06-08 17:37:46 -04:00
parent de3b37799c
commit 85fab2abc4
2 changed files with 39 additions and 1 deletions

View File

@ -403,7 +403,7 @@ void MainWindow::launchMachine() {
break; break;
case Analyser::Machine::AppleII: case Analyser::Machine::AppleII:
addDisplayMenu(settingsPrefix, "Colour", "Monochrome", "", ""); addAppleIIMenu();
break; break;
case Analyser::Machine::Atari2600: 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) { void MainWindow::speaker_did_complete_samples(Outputs::Speaker::Speaker *, const std::vector<int16_t> &buffer) {
audioBuffer.write(buffer); audioBuffer.write(buffer);
} }

View File

@ -137,6 +137,9 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
void addAtari2600Menu(); void addAtari2600Menu();
void toggleAtari2600Switch(Atari2600Switch toggleSwitch); void toggleAtari2600Switch(Atari2600Switch toggleSwitch);
void addAppleIIMenu();
void setAppleIISquarePixels(bool);
void setWindowTitle(); void setWindowTitle();
bool mouseIsCaptured = false; bool mouseIsCaptured = false;