Qt configs: Make thread-safe, properly update audio enable & renderdoc settings

This commit is contained in:
wheremyfoodat 2024-12-01 19:12:02 +02:00
parent 266e637790
commit 87878d3cba
8 changed files with 116 additions and 74 deletions

View file

@ -118,6 +118,9 @@ class Emulator {
void setOutputSize(u32 width, u32 height) { gpu.setOutputSize(width, height); }
void deinitGraphicsContext() { gpu.deinitGraphicsContext(); }
// Reloads some settings that require special handling, such as audio enable
void reloadSettings();
EmulatorConfig& getConfig() { return config; }
Cheats& getCheats() { return cheats; }
ServiceManager& getServiceManager() { return kernel.getServiceManager(); }

View file

@ -19,7 +19,9 @@
class ConfigWindow : public QDialog {
Q_OBJECT
private:
private:
using ConfigCallback = std::function<void()>;
enum class Theme : int {
System = 0,
Light = 1,
@ -36,13 +38,20 @@ class ConfigWindow : public QDialog {
static constexpr size_t settingWidgetCount = 6;
std::array<QString, settingWidgetCount> helpTexts;
// The config class holds a copy of the emulator config which it edits and sends
// over to the emulator in a thread-safe manner
EmulatorConfig config;
ConfigCallback updateConfig;
void addWidget(QWidget* widget, QString title, QString icon, QString helpText);
void setTheme(Theme theme);
public:
ConfigWindow(Emulator* emu, QWidget* parent = nullptr);
public:
ConfigWindow(ConfigCallback callback, const EmulatorConfig& config, QWidget* parent = nullptr);
~ConfigWindow();
private:
EmulatorConfig& getConfig() { return config; }
private:
Emulator* emu;
};

View file

@ -51,6 +51,7 @@ class MainWindow : public QMainWindow {
ReleaseTouchscreen,
ReloadUbershader,
SetScreenSize,
UpdateConfig,
};
// Tagged union representing our message queue messages

View file

@ -23,6 +23,9 @@ namespace Renderdoc {
// Sets output directory for captures
void setOutputDir(const std::string& path, const std::string& prefix);
// Returns whether Renderdoc has been loaded
bool isLoaded();
// Returns whether we've compiled with Renderdoc support
static constexpr bool isSupported() { return true; }
} // namespace Renderdoc
@ -34,6 +37,7 @@ namespace Renderdoc {
static void triggerCapture() { Helpers::panic("Tried to trigger a Renderdoc capture while support for renderdoc is disabled"); }
static void setOutputDir(const std::string& path, const std::string& prefix) {}
static constexpr bool isSupported() { return false; }
static constexpr bool isLoaded() { return false; }
} // namespace Renderdoc
#endif