all repos — mgba @ d7fc09768d0c5771f11ad4cf1b40851e7a11a6aa

mGBA Game Boy Advance Emulator

src/platform/qt/SettingsView.cpp (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#include "SettingsView.h"
  7
  8#include "AudioProcessor.h"
  9#include "ConfigController.h"
 10#include "Display.h"
 11#include "GBAApp.h"
 12#include "GBAKeyEditor.h"
 13#include "InputController.h"
 14#include "ShaderSelector.h"
 15#include "ShortcutView.h"
 16
 17#include <mgba/core/serialize.h>
 18#include <mgba/core/version.h>
 19#include <mgba/internal/gba/gba.h>
 20
 21using namespace QGBA;
 22
 23SettingsView::SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, QWidget* parent)
 24	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
 25	, m_controller(controller)
 26{
 27	m_ui.setupUi(this);
 28
 29	reloadConfig();
 30
 31	if (m_ui.savegamePath->text().isEmpty()) {
 32		m_ui.savegameSameDir->setChecked(true);
 33	}
 34	connect(m_ui.savegameSameDir, &QAbstractButton::toggled, [this] (bool e) {
 35		if (e) {
 36			m_ui.savegamePath->clear();
 37		}
 38	});
 39	connect(m_ui.savegameBrowse, &QAbstractButton::pressed, [this] () {
 40		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
 41		if (!path.isNull()) {
 42			m_ui.savegameSameDir->setChecked(false);
 43			m_ui.savegamePath->setText(path);
 44		}
 45	});
 46
 47	if (m_ui.savestatePath->text().isEmpty()) {
 48		m_ui.savestateSameDir->setChecked(true);
 49	}
 50	connect(m_ui.savestateSameDir, &QAbstractButton::toggled, [this] (bool e) {
 51		if (e) {
 52			m_ui.savestatePath->clear();
 53		}
 54	});
 55	connect(m_ui.savestateBrowse, &QAbstractButton::pressed, [this] () {
 56		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
 57		if (!path.isNull()) {
 58			m_ui.savestateSameDir->setChecked(false);
 59			m_ui.savestatePath->setText(path);
 60		}
 61	});
 62
 63	if (m_ui.screenshotPath->text().isEmpty()) {
 64		m_ui.screenshotSameDir->setChecked(true);
 65	}
 66	connect(m_ui.screenshotSameDir, &QAbstractButton::toggled, [this] (bool e) {
 67		if (e) {
 68			m_ui.screenshotPath->clear();
 69		}
 70	});
 71	connect(m_ui.screenshotBrowse, &QAbstractButton::pressed, [this] () {
 72		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
 73		if (!path.isNull()) {
 74			m_ui.screenshotSameDir->setChecked(false);
 75			m_ui.screenshotPath->setText(path);
 76		}
 77	});
 78
 79	if (m_ui.patchPath->text().isEmpty()) {
 80		m_ui.patchSameDir->setChecked(true);
 81	}
 82	connect(m_ui.patchSameDir, &QAbstractButton::toggled, [this] (bool e) {
 83		if (e) {
 84			m_ui.patchPath->clear();
 85		}
 86	});
 87	connect(m_ui.patchBrowse, &QAbstractButton::pressed, [this] () {
 88		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
 89		if (!path.isNull()) {
 90			m_ui.patchSameDir->setChecked(false);
 91			m_ui.patchPath->setText(path);
 92		}
 93	});
 94	connect(m_ui.clearCache, &QAbstractButton::pressed, this, &SettingsView::libraryCleared);
 95
 96	// TODO: Move to reloadConfig()
 97	QVariant audioDriver = m_controller->getQtOption("audioDriver");
 98#ifdef BUILD_QT_MULTIMEDIA
 99	m_ui.audioDriver->addItem(tr("Qt Multimedia"), static_cast<int>(AudioProcessor::Driver::QT_MULTIMEDIA));
100	if (!audioDriver.isNull() && audioDriver.toInt() == static_cast<int>(AudioProcessor::Driver::QT_MULTIMEDIA)) {
101		m_ui.audioDriver->setCurrentIndex(m_ui.audioDriver->count() - 1);
102	}
103#endif
104
105#ifdef BUILD_SDL
106	m_ui.audioDriver->addItem(tr("SDL"), static_cast<int>(AudioProcessor::Driver::SDL));
107	if (audioDriver.isNull() || audioDriver.toInt() == static_cast<int>(AudioProcessor::Driver::SDL)) {
108		m_ui.audioDriver->setCurrentIndex(m_ui.audioDriver->count() - 1);
109	}
110#endif
111
112	// TODO: Move to reloadConfig()
113	QVariant displayDriver = m_controller->getQtOption("displayDriver");
114	m_ui.displayDriver->addItem(tr("Software (Qt)"), static_cast<int>(Display::Driver::QT));
115	if (!displayDriver.isNull() && displayDriver.toInt() == static_cast<int>(Display::Driver::QT)) {
116		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
117	}
118
119#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
120	m_ui.displayDriver->addItem(tr("OpenGL"), static_cast<int>(Display::Driver::OPENGL));
121	if (displayDriver.isNull() || displayDriver.toInt() == static_cast<int>(Display::Driver::OPENGL)) {
122		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
123	}
124#endif
125
126#ifdef BUILD_GL
127	m_ui.displayDriver->addItem(tr("OpenGL (force version 1.x)"), static_cast<int>(Display::Driver::OPENGL1));
128	if (!displayDriver.isNull() && displayDriver.toInt() == static_cast<int>(Display::Driver::OPENGL1)) {
129		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
130	}
131#endif
132
133	// TODO: Move to reloadConfig()
134	QVariant cameraDriver = m_controller->getQtOption("cameraDriver");
135	m_ui.cameraDriver->addItem(tr("None (Still Image)"), static_cast<int>(InputController::CameraDriver::NONE));
136	if (cameraDriver.isNull() || cameraDriver.toInt() == static_cast<int>(InputController::CameraDriver::NONE)) {
137		m_ui.cameraDriver->setCurrentIndex(m_ui.cameraDriver->count() - 1);
138	}
139
140#ifdef BUILD_QT_MULTIMEDIA
141	m_ui.cameraDriver->addItem(tr("Qt Multimedia"), static_cast<int>(InputController::CameraDriver::QT_MULTIMEDIA));
142	if (!cameraDriver.isNull() && cameraDriver.toInt() == static_cast<int>(InputController::CameraDriver::QT_MULTIMEDIA)) {
143		m_ui.cameraDriver->setCurrentIndex(m_ui.cameraDriver->count() - 1);
144	}
145#endif
146
147#ifdef M_CORE_GBA
148	connect(m_ui.gbaBiosBrowse, &QPushButton::clicked, [this]() {
149		selectBios(m_ui.gbaBios);
150	});
151#else
152	m_ui.gbaBiosBrowse->hide();
153#endif
154
155#ifdef M_CORE_GB
156	connect(m_ui.gbBiosBrowse, &QPushButton::clicked, [this]() {
157		selectBios(m_ui.gbBios);
158	});
159	connect(m_ui.gbcBiosBrowse, &QPushButton::clicked, [this]() {
160		selectBios(m_ui.gbcBios);
161	});
162	connect(m_ui.sgbBiosBrowse, &QPushButton::clicked, [this]() {
163		selectBios(m_ui.sgbBios);
164	});
165
166	QList<QColor> defaultColors;
167	defaultColors.append(QColor(0xF8, 0xF8, 0xF8));
168	defaultColors.append(QColor(0xA8, 0xA8, 0xA8));
169	defaultColors.append(QColor(0x50, 0x50, 0x50));
170	defaultColors.append(QColor(0x00, 0x00, 0x00));
171	bool ok;
172	if (m_controller->getOption("gb.pal[0]").toUInt(&ok) || ok) {
173		defaultColors[0] = QColor::fromRgb(m_controller->getOption("gb.pal[0]").toUInt());
174	}
175	if (m_controller->getOption("gb.pal[1]").toUInt(&ok) || ok) {
176		defaultColors[1] = QColor::fromRgb(m_controller->getOption("gb.pal[1]").toUInt());
177	}
178	if (m_controller->getOption("gb.pal[2]").toUInt(&ok) || ok) {
179		defaultColors[2] = QColor::fromRgb(m_controller->getOption("gb.pal[2]").toUInt());
180	}
181	if (m_controller->getOption("gb.pal[3]").toUInt(&ok) || ok) {
182		defaultColors[3] = QColor::fromRgb(m_controller->getOption("gb.pal[3]").toUInt());
183	}
184	m_colorPickers[0] = ColorPicker(m_ui.color0, defaultColors[0]);
185	m_colorPickers[1] = ColorPicker(m_ui.color1, defaultColors[1]);
186	m_colorPickers[2] = ColorPicker(m_ui.color2, defaultColors[2]);
187	m_colorPickers[3] = ColorPicker(m_ui.color3, defaultColors[3]);
188	for (int colorId = 0; colorId < 4; ++colorId) {
189		connect(&m_colorPickers[colorId], &ColorPicker::colorChanged, this, [this, colorId](const QColor& color) {
190			m_gbColors[colorId] = color.rgb();
191		});
192	}
193#else
194	m_ui.gbBiosBrowse->hide();
195	m_ui.gbcBiosBrowse->hide();
196	m_ui.sgbBiosBrowse->hide();
197	m_ui.gb->hide();
198#endif
199
200	GBAKeyEditor* editor = new GBAKeyEditor(inputController, InputController::KEYBOARD, QString(), this);
201	m_ui.stackedWidget->addWidget(editor);
202	m_ui.tabs->addItem(tr("Keyboard"));
203	connect(m_ui.buttonBox, &QDialogButtonBox::accepted, editor, &GBAKeyEditor::save);
204
205	GBAKeyEditor* buttonEditor = nullptr;
206#ifdef BUILD_SDL
207	inputController->recalibrateAxes();
208	const char* profile = inputController->profileForType(SDL_BINDING_BUTTON);
209	buttonEditor = new GBAKeyEditor(inputController, SDL_BINDING_BUTTON, profile);
210	m_ui.stackedWidget->addWidget(buttonEditor);
211	m_ui.tabs->addItem(tr("Controllers"));
212	connect(m_ui.buttonBox, &QDialogButtonBox::accepted, buttonEditor, &GBAKeyEditor::save);
213#endif
214
215	connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &SettingsView::updateConfig);
216	connect(m_ui.buttonBox, &QDialogButtonBox::clicked, [this, editor, buttonEditor](QAbstractButton* button) {
217		if (m_ui.buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
218			updateConfig();
219			editor->save();
220			if (buttonEditor) {
221				buttonEditor->save();
222			}
223		}
224	});
225
226	m_ui.languages->setItemData(0, QLocale("en"));
227	QDir ts(":/translations/");
228	for (auto name : ts.entryList()) {
229		if (!name.endsWith(".qm") || !name.startsWith(binaryName)) {
230			continue;
231		}
232		QLocale locale(name.remove(QString("%0-").arg(binaryName)).remove(".qm"));
233		m_ui.languages->addItem(locale.nativeLanguageName(), locale);
234		if (locale == QLocale()) {
235			m_ui.languages->setCurrentIndex(m_ui.languages->count() - 1);
236		}
237	}
238
239	ShortcutView* shortcutView = new ShortcutView();
240	shortcutView->setController(shortcutController);
241	shortcutView->setInputController(inputController);
242	m_ui.stackedWidget->addWidget(shortcutView);
243	m_ui.tabs->addItem(tr("Shortcuts"));
244}
245
246SettingsView::~SettingsView() {
247#if defined(BUILD_GL) || defined(BUILD_GLES)
248	setShaderSelector(nullptr);
249#endif
250}
251
252void SettingsView::setShaderSelector(ShaderSelector* shaderSelector) {
253#if defined(BUILD_GL) || defined(BUILD_GLES)
254	if (m_shader) {
255		auto items = m_ui.tabs->findItems(tr("Shaders"), Qt::MatchFixedString);
256		for (const auto& item : items) {
257			m_ui.tabs->removeItemWidget(item);
258		}
259		m_ui.stackedWidget->removeWidget(m_shader);
260		m_shader->setParent(nullptr);
261	}
262	m_shader = shaderSelector;
263	if (shaderSelector) {
264		m_ui.stackedWidget->addWidget(m_shader);
265		m_ui.tabs->addItem(tr("Shaders"));
266		connect(m_ui.buttonBox, &QDialogButtonBox::accepted, m_shader, &ShaderSelector::saved);
267	}
268#endif
269}
270
271void SettingsView::selectBios(QLineEdit* bios) {
272	QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS"));
273	if (!filename.isEmpty()) {
274		bios->setText(filename);
275	}
276}
277
278void SettingsView::updateConfig() {
279	saveSetting("gba.bios", m_ui.gbaBios);
280	saveSetting("gb.bios", m_ui.gbBios);
281	saveSetting("gbc.bios", m_ui.gbcBios);
282	saveSetting("sgb.bios", m_ui.sgbBios);
283	saveSetting("useBios", m_ui.useBios);
284	saveSetting("skipBios", m_ui.skipBios);
285	saveSetting("audioBuffers", m_ui.audioBufferSize);
286	saveSetting("sampleRate", m_ui.sampleRate);
287	saveSetting("videoSync", m_ui.videoSync);
288	saveSetting("audioSync", m_ui.audioSync);
289	saveSetting("frameskip", m_ui.frameskip);
290	saveSetting("fpsTarget", m_ui.fpsTarget);
291	saveSetting("autofireThreshold", m_ui.autofireThreshold);
292	saveSetting("lockAspectRatio", m_ui.lockAspectRatio);
293	saveSetting("lockIntegerScaling", m_ui.lockIntegerScaling);
294	saveSetting("volume", m_ui.volume);
295	saveSetting("mute", m_ui.mute);
296	saveSetting("rewindEnable", m_ui.rewind);
297	saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
298	saveSetting("rewindSave", m_ui.rewindSave);
299	saveSetting("resampleVideo", m_ui.resampleVideo);
300	saveSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
301	saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
302	saveSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
303	saveSetting("savegamePath", m_ui.savegamePath);
304	saveSetting("savestatePath", m_ui.savestatePath);
305	saveSetting("screenshotPath", m_ui.screenshotPath);
306	saveSetting("patchPath", m_ui.patchPath);
307	saveSetting("libraryStyle", m_ui.libraryStyle->currentIndex());
308	saveSetting("showLibrary", m_ui.showLibrary);
309	saveSetting("preload", m_ui.preload);
310
311	if (m_ui.fastForwardUnbounded->isChecked()) {
312		saveSetting("fastForwardRatio", "-1");
313	} else {
314		saveSetting("fastForwardRatio", m_ui.fastForwardRatio);
315	}
316
317	switch (m_ui.idleOptimization->currentIndex() + IDLE_LOOP_IGNORE) {
318	case IDLE_LOOP_IGNORE:
319		saveSetting("idleOptimization", "ignore");
320		break;
321	case IDLE_LOOP_REMOVE:
322		saveSetting("idleOptimization", "remove");
323		break;
324	case IDLE_LOOP_DETECT:
325		saveSetting("idleOptimization", "detect");
326		break;
327	}
328
329	int loadState = SAVESTATE_RTC;
330	loadState |= m_ui.loadStateScreenshot->isChecked() ? SAVESTATE_SCREENSHOT : 0;
331	loadState |= m_ui.loadStateSave->isChecked() ? SAVESTATE_SAVEDATA : 0;
332	loadState |= m_ui.loadStateCheats->isChecked() ? SAVESTATE_CHEATS : 0;
333	saveSetting("loadStateExtdata", loadState);
334
335	int saveState = SAVESTATE_RTC | SAVESTATE_METADATA;
336	saveState |= m_ui.saveStateScreenshot->isChecked() ? SAVESTATE_SCREENSHOT : 0;
337	saveState |= m_ui.saveStateSave->isChecked() ? SAVESTATE_SAVEDATA : 0;
338	saveState |= m_ui.saveStateCheats->isChecked() ? SAVESTATE_CHEATS : 0;
339	saveSetting("saveStateExtdata", saveState);
340
341	QVariant audioDriver = m_ui.audioDriver->itemData(m_ui.audioDriver->currentIndex());
342	if (audioDriver != m_controller->getQtOption("audioDriver")) {
343		m_controller->setQtOption("audioDriver", audioDriver);
344		AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(audioDriver.toInt()));
345		emit audioDriverChanged();
346	}
347
348	QVariant displayDriver = m_ui.displayDriver->itemData(m_ui.displayDriver->currentIndex());
349	if (displayDriver != m_controller->getQtOption("displayDriver")) {
350		m_controller->setQtOption("displayDriver", displayDriver);
351		Display::setDriver(static_cast<Display::Driver>(displayDriver.toInt()));
352		setShaderSelector(nullptr);
353		emit displayDriverChanged();
354	}
355
356	QVariant cameraDriver = m_ui.cameraDriver->itemData(m_ui.cameraDriver->currentIndex());
357	if (cameraDriver != m_controller->getQtOption("cameraDriver")) {
358		m_controller->setQtOption("cameraDriver", cameraDriver);
359		emit cameraDriverChanged();
360	}
361
362	QLocale language = m_ui.languages->itemData(m_ui.languages->currentIndex()).toLocale();
363	if (language != m_controller->getQtOption("language").toLocale() && !(language.bcp47Name() == QLocale::system().bcp47Name() && m_controller->getQtOption("language").isNull())) {
364		m_controller->setQtOption("language", language.bcp47Name());
365		emit languageChanged();
366	}
367
368	if (m_gbColors[0] | m_gbColors[1] | m_gbColors[2] | m_gbColors[3]) {
369		m_controller->setOption("gb.pal[0]", m_gbColors[0]);
370		m_controller->setOption("gb.pal[1]", m_gbColors[1]);
371		m_controller->setOption("gb.pal[2]", m_gbColors[2]);
372		m_controller->setOption("gb.pal[3]", m_gbColors[3]);
373	}
374
375	m_controller->write();
376
377	emit pathsChanged();
378	emit biosLoaded(PLATFORM_GBA, m_ui.gbaBios->text());
379}
380
381void SettingsView::reloadConfig() {	
382	loadSetting("bios", m_ui.gbaBios);
383	loadSetting("gba.bios", m_ui.gbaBios);
384	loadSetting("gb.bios", m_ui.gbBios);
385	loadSetting("gbc.bios", m_ui.gbcBios);
386	loadSetting("sgb.bios", m_ui.sgbBios);
387	loadSetting("useBios", m_ui.useBios);
388	loadSetting("skipBios", m_ui.skipBios);
389	loadSetting("audioBuffers", m_ui.audioBufferSize);
390	loadSetting("sampleRate", m_ui.sampleRate);
391	loadSetting("videoSync", m_ui.videoSync);
392	loadSetting("audioSync", m_ui.audioSync);
393	loadSetting("frameskip", m_ui.frameskip);
394	loadSetting("fpsTarget", m_ui.fpsTarget);
395	loadSetting("autofireThreshold", m_ui.autofireThreshold);
396	loadSetting("lockAspectRatio", m_ui.lockAspectRatio);
397	loadSetting("lockIntegerScaling", m_ui.lockIntegerScaling);
398	loadSetting("volume", m_ui.volume);
399	loadSetting("mute", m_ui.mute);
400	loadSetting("rewindEnable", m_ui.rewind);
401	loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
402	loadSetting("rewindSave", m_ui.rewindSave);
403	loadSetting("resampleVideo", m_ui.resampleVideo);
404	loadSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
405	loadSetting("suspendScreensaver", m_ui.suspendScreensaver);
406	loadSetting("pauseOnFocusLost", m_ui.pauseOnFocusLost);
407	loadSetting("savegamePath", m_ui.savegamePath);
408	loadSetting("savestatePath", m_ui.savestatePath);
409	loadSetting("screenshotPath", m_ui.screenshotPath);
410	loadSetting("patchPath", m_ui.patchPath);
411	loadSetting("showLibrary", m_ui.showLibrary);
412	loadSetting("preload", m_ui.preload);
413
414	m_ui.libraryStyle->setCurrentIndex(loadSetting("libraryStyle").toInt());
415
416	double fastForwardRatio = loadSetting("fastForwardRatio").toDouble();
417	if (fastForwardRatio <= 0) {
418		m_ui.fastForwardUnbounded->setChecked(true);
419		m_ui.fastForwardRatio->setEnabled(false);
420	} else {
421		m_ui.fastForwardUnbounded->setChecked(false);
422		m_ui.fastForwardRatio->setEnabled(true);
423		m_ui.fastForwardRatio->setValue(fastForwardRatio);
424	}
425
426	QString idleOptimization = loadSetting("idleOptimization");
427	if (idleOptimization == "ignore") {
428		m_ui.idleOptimization->setCurrentIndex(0);
429	} else if (idleOptimization == "remove") {
430		m_ui.idleOptimization->setCurrentIndex(1);
431	} else if (idleOptimization == "detect") {
432		m_ui.idleOptimization->setCurrentIndex(2);
433	}
434
435	bool ok;
436	int loadState = loadSetting("loadStateExtdata").toInt(&ok);
437	if (!ok) {
438		loadState = SAVESTATE_SCREENSHOT | SAVESTATE_RTC;
439	}
440	m_ui.loadStateScreenshot->setChecked(loadState & SAVESTATE_SCREENSHOT);
441	m_ui.loadStateSave->setChecked(loadState & SAVESTATE_SAVEDATA);
442	m_ui.loadStateCheats->setChecked(loadState & SAVESTATE_CHEATS);
443
444	int saveState = loadSetting("saveStateExtdata").toInt(&ok);
445	if (!ok) {
446		saveState = SAVESTATE_SCREENSHOT | SAVESTATE_SAVEDATA | SAVESTATE_CHEATS | SAVESTATE_RTC | SAVESTATE_METADATA;
447	}
448	m_ui.saveStateScreenshot->setChecked(saveState & SAVESTATE_SCREENSHOT);
449	m_ui.saveStateSave->setChecked(saveState & SAVESTATE_SAVEDATA);
450	m_ui.saveStateCheats->setChecked(saveState & SAVESTATE_CHEATS);
451}
452
453void SettingsView::saveSetting(const char* key, const QAbstractButton* field) {
454	m_controller->setOption(key, field->isChecked());
455	m_controller->updateOption(key);
456}
457
458void SettingsView::saveSetting(const char* key, const QComboBox* field) {
459	saveSetting(key, field->lineEdit());
460}
461
462void SettingsView::saveSetting(const char* key, const QDoubleSpinBox* field) {
463	saveSetting(key, field->value());
464}
465
466void SettingsView::saveSetting(const char* key, const QLineEdit* field) {
467	saveSetting(key, field->text());
468}
469
470void SettingsView::saveSetting(const char* key, const QSlider* field) {
471	saveSetting(key, field->value());
472}
473
474void SettingsView::saveSetting(const char* key, const QSpinBox* field) {
475	saveSetting(key, field->value());
476}
477
478void SettingsView::saveSetting(const char* key, const QVariant& field) {
479	m_controller->setOption(key, field);
480	m_controller->updateOption(key);
481}
482
483void SettingsView::loadSetting(const char* key, QAbstractButton* field) {
484	QString option = loadSetting(key);
485	field->setChecked(!option.isNull() && option != "0");
486}
487
488void SettingsView::loadSetting(const char* key, QComboBox* field) {
489	loadSetting(key, field->lineEdit());
490}
491
492void SettingsView::loadSetting(const char* key, QDoubleSpinBox* field) {
493	QString option = loadSetting(key);
494	field->setValue(option.toDouble());
495}
496
497void SettingsView::loadSetting(const char* key, QLineEdit* field) {
498	QString option = loadSetting(key);
499	field->setText(option);
500}
501
502void SettingsView::loadSetting(const char* key, QSlider* field) {
503	QString option = loadSetting(key);
504	field->setValue(option.toInt());
505}
506
507void SettingsView::loadSetting(const char* key, QSpinBox* field) {
508	QString option = loadSetting(key);
509	field->setValue(option.toInt());
510}
511
512QString SettingsView::loadSetting(const char* key) {
513	return m_controller->getOption(key);
514}