all repos — mgba @ 1089285b45c1213fff87e0518fc45a327b8ede8b

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 selectPath(QLineEdit*, QCheckBox*);
 70	void updateConfig();
 71	void reloadConfig();
 72
 73private:
 74	Ui::SettingsView m_ui;
 75
 76	ConfigController* m_controller;
 77	InputController* m_input;
 78	ShaderSelector* m_shader = nullptr;
 79	LogConfigModel m_logModel;
 80
 81#ifdef M_CORE_GB
 82	uint32_t m_gbColors[12]{};
 83	ColorPicker m_colorPickers[12];
 84#endif
 85
 86	QMap<Page, int> m_pageIndex;
 87
 88	QString makePortablePath(const QString& path);
 89
 90	void addPage(const QString& name, QWidget* view, Page index);
 91
 92	void saveSetting(const char* key, const QAbstractButton*);
 93	void saveSetting(const char* key, const QComboBox*);
 94	void saveSetting(const char* key, const QDoubleSpinBox*);
 95	void saveSetting(const char* key, const QLineEdit*);
 96	void saveSetting(const char* key, const QSlider*);
 97	void saveSetting(const char* key, const QSpinBox*);
 98	void saveSetting(const char* key, const QVariant&);
 99
100	void loadSetting(const char* key, QAbstractButton*, bool defaultVal = false);
101	void loadSetting(const char* key, QComboBox*);
102	void loadSetting(const char* key, QDoubleSpinBox*);
103	void loadSetting(const char* key, QLineEdit*);
104	void loadSetting(const char* key, QSlider*, int defaultVal = 0);
105	void loadSetting(const char* key, QSpinBox*, int defaultVal = 0);
106	QString loadSetting(const char* key);
107};
108
109}