Ejemplo n.º 1
0
void Window::openShortcutWindow() {
#ifdef BUILD_SDL
	m_inputController.recalibrateAxes();
#endif
	ShortcutView* shortcutView = new ShortcutView();
	shortcutView->setController(m_shortcutController);
	shortcutView->setInputController(&m_inputController);
	openView(shortcutView);
}
Ejemplo n.º 2
0
SettingsView::SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
	, m_controller(controller)
{
	m_ui.setupUi(this);

	reloadConfig();

	if (m_ui.savegamePath->text().isEmpty()) {
		m_ui.savegameSameDir->setChecked(true);
	}
	connect(m_ui.savegameSameDir, &QAbstractButton::toggled, [this] (bool e) {
		if (e) {
			m_ui.savegamePath->clear();
		}
	});
	connect(m_ui.savegameBrowse, &QAbstractButton::pressed, [this] () {
		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
		if (!path.isNull()) {
			m_ui.savegameSameDir->setChecked(false);
			m_ui.savegamePath->setText(path);
		}
	});

	if (m_ui.savestatePath->text().isEmpty()) {
		m_ui.savestateSameDir->setChecked(true);
	}
	connect(m_ui.savestateSameDir, &QAbstractButton::toggled, [this] (bool e) {
		if (e) {
			m_ui.savestatePath->clear();
		}
	});
	connect(m_ui.savestateBrowse, &QAbstractButton::pressed, [this] () {
		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
		if (!path.isNull()) {
			m_ui.savestateSameDir->setChecked(false);
			m_ui.savestatePath->setText(path);
		}
	});

	if (m_ui.screenshotPath->text().isEmpty()) {
		m_ui.screenshotSameDir->setChecked(true);
	}
	connect(m_ui.screenshotSameDir, &QAbstractButton::toggled, [this] (bool e) {
		if (e) {
			m_ui.screenshotPath->clear();
		}
	});
	connect(m_ui.screenshotBrowse, &QAbstractButton::pressed, [this] () {
		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
		if (!path.isNull()) {
			m_ui.screenshotSameDir->setChecked(false);
			m_ui.screenshotPath->setText(path);
		}
	});

	if (m_ui.patchPath->text().isEmpty()) {
		m_ui.patchSameDir->setChecked(true);
	}
	connect(m_ui.patchSameDir, &QAbstractButton::toggled, [this] (bool e) {
		if (e) {
			m_ui.patchPath->clear();
		}
	});
	connect(m_ui.patchBrowse, &QAbstractButton::pressed, [this] () {
		QString path = GBAApp::app()->getOpenDirectoryName(this, "Select directory");
		if (!path.isNull()) {
			m_ui.patchSameDir->setChecked(false);
			m_ui.patchPath->setText(path);
		}
	});

	// TODO: Move to reloadConfig()
	QVariant audioDriver = m_controller->getQtOption("audioDriver");
#ifdef BUILD_QT_MULTIMEDIA
	m_ui.audioDriver->addItem(tr("Qt Multimedia"), static_cast<int>(AudioProcessor::Driver::QT_MULTIMEDIA));
	if (!audioDriver.isNull() && audioDriver.toInt() == static_cast<int>(AudioProcessor::Driver::QT_MULTIMEDIA)) {
		m_ui.audioDriver->setCurrentIndex(m_ui.audioDriver->count() - 1);
	}
#endif

#ifdef BUILD_SDL
	m_ui.audioDriver->addItem(tr("SDL"), static_cast<int>(AudioProcessor::Driver::SDL));
	if (audioDriver.isNull() || audioDriver.toInt() == static_cast<int>(AudioProcessor::Driver::SDL)) {
		m_ui.audioDriver->setCurrentIndex(m_ui.audioDriver->count() - 1);
	}
#endif

	// TODO: Move to reloadConfig()
	QVariant displayDriver = m_controller->getQtOption("displayDriver");
	m_ui.displayDriver->addItem(tr("Software (Qt)"), static_cast<int>(Display::Driver::QT));
	if (!displayDriver.isNull() && displayDriver.toInt() == static_cast<int>(Display::Driver::QT)) {
		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
	}

#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
	m_ui.displayDriver->addItem(tr("OpenGL"), static_cast<int>(Display::Driver::OPENGL));
	if (displayDriver.isNull() || displayDriver.toInt() == static_cast<int>(Display::Driver::OPENGL)) {
		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
	}
#endif

#ifdef BUILD_GL
	m_ui.displayDriver->addItem(tr("OpenGL (force version 1.x)"), static_cast<int>(Display::Driver::OPENGL1));
	if (displayDriver.isNull() || displayDriver.toInt() == static_cast<int>(Display::Driver::OPENGL1)) {
		m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
	}
#endif

	connect(m_ui.biosBrowse, SIGNAL(clicked()), this, SLOT(selectBios()));
	connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateConfig()));
	connect(m_ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button) {
		if (m_ui.buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
			updateConfig();
		}
	});

	GBAKeyEditor* editor = new GBAKeyEditor(inputController, InputController::KEYBOARD, QString(), this);
	m_ui.stackedWidget->addWidget(editor);
	m_ui.tabs->addItem("Keyboard");
	connect(m_ui.buttonBox, SIGNAL(accepted()), editor, SLOT(save()));

#ifdef BUILD_SDL
	inputController->recalibrateAxes();
	const char* profile = inputController->profileForType(SDL_BINDING_BUTTON);
	editor = new GBAKeyEditor(inputController, SDL_BINDING_BUTTON, profile);
	m_ui.stackedWidget->addWidget(editor);
	m_ui.tabs->addItem("Controllers");
	connect(m_ui.buttonBox, SIGNAL(accepted()), editor, SLOT(save()));
#endif

	ShortcutView* shortcutView = new ShortcutView();
	shortcutView->setController(shortcutController);
	shortcutView->setInputController(inputController);
	m_ui.stackedWidget->addWidget(shortcutView);
	m_ui.tabs->addItem("Shortcuts");
}