Rename configuration.* options.*

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2019-12-01 18:40:28 +00:00
parent e8022bf6a0
commit bad18cafbf
6 changed files with 39 additions and 29 deletions

View file

@ -17,7 +17,7 @@ add_executable(qapple
gamepadpaddle.cpp
video.cpp
registry.cpp
configuration.cpp
options.cpp
audiogenerator.cpp
loggingcategory.cpp
viewbuffer.cpp

View file

@ -1,4 +1,4 @@
#include "configuration.h"
#include "options.h"
#include "StdAfx.h"
#include "Common.h"
@ -97,17 +97,25 @@ namespace
GlobalOptions::GlobalOptions()
{
QSettings settings;
this->screenshotTemplate = settings.value(REG_SCREENSHOT_TEMPLATE, "/tmp/qapple_%1.png").toString();
this->gamepadName = settings.value(REG_GAMEPAD_NAME, QString()).toString();
this->slot0Card = settings.value(REG_SLOT0_CARD, 0).toInt();
this->ramWorksMemorySize = settings.value(REG_RAMWORKS_SIZE, 0).toInt();
}
this->msGap = settings.value(REG_TIMER, 5).toInt();
this->msFullSpeed = settings.value(REG_FULL_SPEED, 5).toInt();
this->audioLatency = settings.value(REG_AUDIO_LATENCY, 200).toInt();
this->silenceDelay = settings.value(REG_SILENCE_DELAY, 10000).toInt();
this->volume = settings.value(REG_VOLUME, 0x0fff).toInt();
GlobalOptions GlobalOptions::fromQSettings()
{
QSettings settings;
GlobalOptions options;
options.screenshotTemplate = settings.value(REG_SCREENSHOT_TEMPLATE, "/tmp/qapple_%1.png").toString();
options.gamepadName = settings.value(REG_GAMEPAD_NAME, QString()).toString();
options.slot0Card = settings.value(REG_SLOT0_CARD, 0).toInt();
options.ramWorksMemorySize = settings.value(REG_RAMWORKS_SIZE, 0).toInt();
options.msGap = settings.value(REG_TIMER, 5).toInt();
options.msFullSpeed = settings.value(REG_FULL_SPEED, 5).toInt();
options.audioLatency = settings.value(REG_AUDIO_LATENCY, 200).toInt();
options.silenceDelay = settings.value(REG_SILENCE_DELAY, 10000).toInt();
options.volume = settings.value(REG_VOLUME, 0x0fff).toInt();
return options;
}
void GlobalOptions::setData(const Preferences::Data & data)

View file

@ -6,7 +6,9 @@
class GlobalOptions
{
public:
GlobalOptions(); // initialise from QSettings
GlobalOptions(); // empty, uninitialised
static GlobalOptions fromQSettings();
QString screenshotTemplate;
QString gamepadName;

View file

@ -24,7 +24,6 @@
#include "emulator.h"
#include "memorycontainer.h"
#include "configuration.h"
#include "audiogenerator.h"
#include "gamepadpaddle.h"
#include "preferences.h"
@ -212,12 +211,12 @@ QApple::QApple(QWidget *parent) :
connect(AudioGenerator::instance().getAudioOutput(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(on_stateChanged(QAudio::State)));
myOptions.reset(new GlobalOptions());
myOptions = GlobalOptions::fromQSettings();
reloadOptions();
on_actionPause_triggered();
initialiseEmulator();
startEmulator(myEmulatorWindow, myEmulator, *myOptions);
startEmulator(myEmulatorWindow, myEmulator, myOptions);
}
void QApple::closeEvent(QCloseEvent *)
@ -243,7 +242,7 @@ void QApple::on_timer()
}
// target x ms ahead of where we are now, which is when the timer should be called again
const qint64 target = myElapsedTimer.elapsed() + myOptions->msGap;
const qint64 target = myElapsedTimer.elapsed() + myOptions.msGap;
const qint64 current = emulatorTimeInMS() - myCpuTimeReference;
if (current > target)
{
@ -276,7 +275,7 @@ void QApple::on_timer()
g_dwCyclesThisFrame = g_dwCyclesThisFrame % dwClksPerFrame;
++count;
}
while (sg_Disk2Card.IsConditionForFullSpeed() && (myElapsedTimer.elapsed() < target + myOptions->msFullSpeed));
while (sg_Disk2Card.IsConditionForFullSpeed() && (myElapsedTimer.elapsed() < target + myOptions.msFullSpeed));
// just repaint each time, to make it simpler
// we run @ 60 fps anyway
@ -312,7 +311,7 @@ void QApple::restartTimeCounters()
void QApple::on_actionStart_triggered()
{
// always restart with the same timer gap that was last used
myTimerID = startTimer(myOptions->msGap, Qt::PreciseTimer);
myTimerID = startTimer(myOptions.msGap, Qt::PreciseTimer);
ui->actionPause->setEnabled(true);
ui->actionStart->setEnabled(false);
restartTimeCounters();
@ -344,7 +343,7 @@ void QApple::on_actionReboot_triggered()
{
emit endEmulator();
stopEmulator();
startEmulator(myEmulatorWindow, myEmulator, *myOptions);
startEmulator(myEmulatorWindow, myEmulator, myOptions);
myEmulatorWindow->setWindowTitle(QString::fromStdString(g_pAppTitle));
myEmulator->updateVideo();
restartTimeCounters();
@ -386,7 +385,7 @@ void QApple::on_actionOptions_triggered()
Preferences::Data currentData;
getAppleWinPreferences(currentData);
myOptions->getData(currentData);
myOptions.getData(currentData);
QSettings settings; // the function will "modify" it
myPreferences->setup(currentData, settings);
@ -395,7 +394,7 @@ void QApple::on_actionOptions_triggered()
{
const Preferences::Data newData = myPreferences->getData();
setAppleWinPreferences(currentData, newData);
myOptions->setData(newData);
myOptions.setData(newData);
reloadOptions();
}
@ -406,8 +405,8 @@ void QApple::reloadOptions()
SetWindowTitle();
myEmulatorWindow->setWindowTitle(QString::fromStdString(g_pAppTitle));
Paddle::instance() = GamepadPaddle::fromName(myOptions->gamepadName);
AudioGenerator::instance().setOptions(myOptions->audioLatency, myOptions->silenceDelay, myOptions->volume);
Paddle::instance() = GamepadPaddle::fromName(myOptions.gamepadName);
AudioGenerator::instance().setOptions(myOptions.audioLatency, myOptions.silenceDelay, myOptions.volume);
}
void QApple::on_actionSave_state_triggered()
@ -456,7 +455,7 @@ QString getImageFilename(const GlobalOptions & options)
void QApple::on_actionScreenshot_triggered()
{
const QString filename = getImageFilename(*myOptions);
const QString filename = getImageFilename(myOptions);
if (filename.isEmpty())
{
QMessageBox::warning(this, "Screenshot", "Cannot determine the screenshot filename.");

View file

@ -8,11 +8,12 @@
#include <memory>
#include "options.h"
class QMdiSubWindow;
class Emulator;
class Preferences;
class GlobalOptions;
namespace Ui {
class QApple;
@ -99,7 +100,7 @@ private:
Emulator * myEmulator;
qint64 myCpuTimeReference;
std::shared_ptr<GlobalOptions> myOptions;
GlobalOptions myOptions;
private:
Ui::QApple *ui;

View file

@ -25,6 +25,7 @@ SOURCES += main.cpp\
QHexView/qhexview.cpp \
audiogenerator.cpp \
loggingcategory.cpp \
options.cpp \
qapple.cpp \
qresources.cpp \
emulator.cpp \
@ -33,7 +34,6 @@ SOURCES += main.cpp\
memorycontainer.cpp \
preferences.cpp \
gamepadpaddle.cpp \
configuration.cpp \
viewbuffer.cpp
HEADERS += qapple.h \
@ -52,12 +52,12 @@ HEADERS += qapple.h \
audiogenerator.h \
emulator.h \
loggingcategory.h \
options.h \
registry.h \
video.h \
memorycontainer.h \
preferences.h \
gamepadpaddle.h \
configuration.h \
viewbuffer.h
FORMS += qapple.ui \