mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-05 05:34:20 +00:00
Reduces boilerplate and key repetition.
This commit is contained in:
parent
293ab25634
commit
21c41ed4cb
@ -726,88 +726,69 @@ void MainWindow::launchTarget(std::unique_ptr<Analyser::Static::Target> &&target
|
|||||||
// than indices. This has historically been true on the Mac, as I tend to add additional
|
// than indices. This has historically been true on the Mac, as I tend to add additional
|
||||||
// options but the existing text is rarely affected.
|
// options but the existing text is rarely affected.
|
||||||
|
|
||||||
|
#define AllSettings() \
|
||||||
|
/* Machine selection. */ \
|
||||||
|
Tabs(machineSelectionTabs, "machineSelection"); \
|
||||||
|
\
|
||||||
|
/* Apple II. */ \
|
||||||
|
ComboBox(appleIIModelComboBox, "appleII.model"); \
|
||||||
|
ComboBox(appleIIDiskControllerComboBox, "appleII.diskController"); \
|
||||||
|
\
|
||||||
|
/* Amstrad CPC. */ \
|
||||||
|
ComboBox(amstradCPCModelComboBox, "amstradcpc.model"); \
|
||||||
|
\
|
||||||
|
/* Atari ST: nothing */ \
|
||||||
|
\
|
||||||
|
/* Electron. */ \
|
||||||
|
CheckBox(electronDFSCheckBox, "electron.hasDFS"); \
|
||||||
|
CheckBox(electronADFSCheckBox, "electron.hasADFS"); \
|
||||||
|
\
|
||||||
|
/* Macintosh. */ \
|
||||||
|
ComboBox(macintoshModelComboBox, "macintosh.model"); \
|
||||||
|
\
|
||||||
|
/* MSX. */ \
|
||||||
|
ComboBox(msxRegionComboBox, "msx.region"); \
|
||||||
|
CheckBox(msxDiskDriveCheckBox, "msx.hasDiskDrive"); \
|
||||||
|
\
|
||||||
|
/* Oric. */ \
|
||||||
|
ComboBox(oricModelComboBox, "msx.model"); \
|
||||||
|
ComboBox(oricDiskInterfaceComboBox, "msx.diskInterface"); \
|
||||||
|
\
|
||||||
|
/* Vic-20 */ \
|
||||||
|
ComboBox(vic20RegionComboBox, "vic20.region"); \
|
||||||
|
ComboBox(vic20MemorySizeComboBox, "vic20.memorySize"); \
|
||||||
|
CheckBox(vic20C1540CheckBox, "vic20.has1540"); \
|
||||||
|
\
|
||||||
|
/* ZX80. */ \
|
||||||
|
ComboBox(zx80MemorySizeComboBox, "zx80.memorySize"); \
|
||||||
|
CheckBox(zx80UseZX81ROMCheckBox, "zx80.usesZX81ROM"); \
|
||||||
|
\
|
||||||
|
/* ZX81. */ \
|
||||||
|
ComboBox(zx81MemorySizeComboBox, "zx81.memorySize");
|
||||||
|
|
||||||
void MainWindow::storeSelections() {
|
void MainWindow::storeSelections() {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
#define Tabs(name, key) settings.setValue(key, ui->name->currentIndex())
|
||||||
|
#define CheckBox(name, key) settings.setValue(key, ui->name->isChecked())
|
||||||
|
#define ComboBox(name, key) settings.setValue(key, ui->name->currentText())
|
||||||
|
|
||||||
// Machine selection.
|
AllSettings();
|
||||||
settings.setValue("machineSelection", ui->machineSelectionTabs->currentIndex());
|
|
||||||
|
|
||||||
// Apple II.
|
#undef Tabs
|
||||||
settings.setValue("appleII.model", ui->appleIIModelComboBox->currentText());
|
#undef CheckBox
|
||||||
settings.setValue("appleII.diskController", ui->appleIIDiskControllerComboBox->currentText());
|
#undef ComboBox
|
||||||
|
|
||||||
// Amstrad CPC.
|
|
||||||
settings.setValue("amstradcpc.model", ui->amstradCPCModelComboBox->currentText());
|
|
||||||
|
|
||||||
// Atari ST: nothing.
|
|
||||||
|
|
||||||
// Electron.
|
|
||||||
settings.setValue("electron.hasDFS", ui->electronDFSCheckBox->isChecked());
|
|
||||||
settings.setValue("electron.hasADFS", ui->electronADFSCheckBox->isChecked());
|
|
||||||
|
|
||||||
// Macintosh.
|
|
||||||
settings.setValue("macintosh.model", ui->macintoshModelComboBox->currentText());
|
|
||||||
|
|
||||||
// MSX.
|
|
||||||
settings.setValue("msx.region", ui->msxRegionComboBox->currentText());
|
|
||||||
settings.setValue("msx.hasDiskDrive", ui->msxDiskDriveCheckBox->isChecked());
|
|
||||||
|
|
||||||
// Oric.
|
|
||||||
settings.setValue("msx.model", ui->oricModelComboBox->currentText());
|
|
||||||
settings.setValue("msx.diskInterface", ui->oricDiskInterfaceComboBox->currentText());
|
|
||||||
|
|
||||||
// Vic-20.
|
|
||||||
settings.setValue("vic20.region", ui->vic20RegionComboBox->currentText());
|
|
||||||
settings.setValue("vic20.memorySize", ui->vic20MemorySizeComboBox->currentText());
|
|
||||||
settings.setValue("vic20.has1540", ui->vic20C1540CheckBox->isChecked());
|
|
||||||
|
|
||||||
// ZX80.
|
|
||||||
settings.setValue("zx80.memorySize", ui->zx80MemorySizeComboBox->currentText());
|
|
||||||
settings.setValue("zx80.usesZX81ROM", ui->zx80UseZX81ROMCheckBox->isChecked());
|
|
||||||
|
|
||||||
// ZX81.
|
|
||||||
settings.setValue("zx81.memorySize", ui->zx81MemorySizeComboBox->currentText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::restoreSelections() {
|
void MainWindow::restoreSelections() {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
||||||
// Machine selection.
|
#define Tabs(name, key) ui->name->setCurrentIndex(settings.value(key).toInt())
|
||||||
ui->machineSelectionTabs->setCurrentIndex(settings.value("machineSelection").toInt());
|
#define CheckBox(name, key) ui->name->setCheckState(settings.value(key).toBool() ? Qt::Checked : Qt::Unchecked)
|
||||||
|
#define ComboBox(name, key) ui->name->setCurrentText(settings.value(key).toString())
|
||||||
|
|
||||||
// Apple II.
|
AllSettings();
|
||||||
ui->appleIIModelComboBox->setCurrentText(settings.value("appleII.model").toString());
|
|
||||||
ui->appleIIDiskControllerComboBox->setCurrentText(settings.value("appleII.diskController").toString());
|
|
||||||
|
|
||||||
// Amstrad CPC.
|
#undef Tabs
|
||||||
ui->amstradCPCModelComboBox->setCurrentText(settings.value("amstradcpc.model").toString());
|
#undef CheckBox
|
||||||
|
#undef ComboBox
|
||||||
// Atari ST: nothing.
|
|
||||||
|
|
||||||
// Electron.
|
|
||||||
ui->electronDFSCheckBox->setCheckState(settings.value("electron.hasDFS").toBool() ? Qt::Checked : Qt::Unchecked);
|
|
||||||
ui->electronADFSCheckBox->setCheckState(settings.value("electron.hasADFS").toBool() ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
// Macintosh.
|
|
||||||
ui->macintoshModelComboBox->setCurrentText(settings.value("macintosh.model").toString());
|
|
||||||
|
|
||||||
// MSX.
|
|
||||||
ui->msxRegionComboBox->setCurrentText(settings.value("msx.region").toString());
|
|
||||||
ui->msxDiskDriveCheckBox->setCheckState(settings.value("msx.hasDiskDrive").toBool() ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
// Oric.
|
|
||||||
ui->oricModelComboBox->setCurrentText(settings.value("msx.model").toString());
|
|
||||||
ui->oricDiskInterfaceComboBox->setCurrentText(settings.value("msx.diskInterface").toString());
|
|
||||||
|
|
||||||
// Vic-20.
|
|
||||||
ui->vic20RegionComboBox->setCurrentText(settings.value("vic20.region").toString());
|
|
||||||
ui->vic20MemorySizeComboBox->setCurrentText(settings.value("vic20.memorySize").toString());
|
|
||||||
ui->vic20C1540CheckBox->setCheckState(settings.value("vic20.has1540").toBool() ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
// ZX80.
|
|
||||||
ui->zx80MemorySizeComboBox->setCurrentText(settings.value("zx80.memorySize").toString());
|
|
||||||
ui->zx80UseZX81ROMCheckBox->setCheckState(settings.value("zx80.usesZX81ROM").toBool() ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
// ZX81.
|
|
||||||
ui->zx81MemorySizeComboBox->setCurrentText(settings.value("zx81.memorySize").toString());
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user