all repos — mgba @ e27e3333052238777f4acdb029f02f1fee90626c

mGBA Game Boy Advance Emulator

src/platform/qt/SettingsView.h (view raw)

  1/* Copyright (c) 2013-2014 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#pragma once
  7
  8#include <QDialog>
  9#include <QMap>
 10
 11#include "ColorPicker.h"
 12#include "LogConfigModel.h"
 13
 14#include <mgba/core/core.h>
 15
 16#ifdef M_CORE_GB
 17#include <mgba/gb/interface.h>
 18#endif
 19
 20#include "ui_SettingsView.h"
 21
 22namespace QGBA {
 23
 24class ConfigController;
 25class InputController;
 26class ShortcutController;
 27class ShaderSelector;
 28
 29class SettingsView : public QDialog {
 30Q_OBJECT
 31
 32public:
 33	enum class Page {
 34		AV,
 35		INTERFACE,
 36		EMULATION,
 37		ENHANCEMENTS,
 38		BIOS,
 39		PATHS,
 40		LOGGING,
 41		GB,
 42		KEYBOARD,
 43		CONTROLLERS,
 44		SHORTCUTS,
 45		SHADERS,
 46	};
 47
 48	SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, LogController* logController, QWidget* parent = nullptr);
 49	~SettingsView();
 50
 51	void setShaderSelector(ShaderSelector* shaderSelector);
 52
 53signals:
 54	void biosLoaded(int platform, const QString&);
 55	void audioDriverChanged();
 56	void displayDriverChanged();
 57	void cameraDriverChanged();
 58	void cameraChanged(const QByteArray&);
 59	void videoRendererChanged();
 60	void pathsChanged();
 61	void languageChanged();
 62	void libraryCleared();
 63
 64public slots:
 65	void selectPage(Page);
 66
 67private slots:
 68	void selectBios(QLineEdit*);
 69	void updateConfig();
 70	void reloadConfig();
 71
 72private:
 73	Ui::SettingsView m_ui;
 74
 75	ConfigController* m_controller;
 76	InputController* m_input;
 77	ShaderSelector* m_shader = nullptr;
 78	LogConfigModel m_logModel;
 79
 80#ifdef M_CORE_GB
 81	uint32_t m_gbColors[12]{};
 82	ColorPicker m_colorPickers[12];
 83#endif
 84
 85	QMap<Page, int> m_pageIndex;
 86
 87	void addPage(const QString& name, QWidget* view, Page index);
 88
 89	void saveSetting(const char* key, const QAbstractButton*);
 90	void saveSetting(const char* key, const QComboBox*);
 91	void saveSetting(const char* key, const QDoubleSpinBox*);
 92	void saveSetting(const char* key, const QLineEdit*);
 93	void saveSetting(const char* key, const QSlider*);
 94	void saveSetting(const char* key, const QSpinBox*);
 95	void saveSetting(const char* key, const QVariant&);
 96
 97	void loadSetting(const char* key, QAbstractButton*, bool defaultVal = false);
 98	void loadSetting(const char* key, QComboBox*);
 99	void loadSetting(const char* key, QDoubleSpinBox*);
100	void loadSetting(const char* key, QLineEdit*);
101	void loadSetting(const char* key, QSlider*, int defaultVal = 0);
102	void loadSetting(const char* key, QSpinBox*, int defaultVal = 0);
103	QString loadSetting(const char* key);
104};
105
106}