Play-/Source/ui_qt/settingsdialog.cpp

91 lines
3.2 KiB
C++
Raw Normal View History

2016-08-23 00:54:10 +01:00
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "PS2VM_Preferences.h"
2016-08-23 00:54:10 +01:00
#include "PreferenceDefs.h"
#include "../gs/GSH_OpenGL/GSH_OpenGL.h"
2020-02-11 07:53:35 +00:00
#include <cassert>
#include <cmath>
2016-08-23 00:54:10 +01:00
2018-04-30 21:01:23 +01:00
SettingsDialog::SettingsDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SettingsDialog)
2016-08-23 00:54:10 +01:00
{
2018-04-30 21:01:23 +01:00
ui->setupUi(this);
2016-08-23 00:54:10 +01:00
2018-04-30 21:01:23 +01:00
//Not needed, as it can be set in the ui editor, but left for ease of ui edit.
ui->stackedWidget->setCurrentIndex(0);
2016-08-23 00:54:10 +01:00
ui->comboBox_gs_selection->blockSignals(true);
2020-02-11 07:53:35 +00:00
ui->comboBox_gs_selection->insertItem(SettingsDialog::GS_HANDLERS::OPENGL, "OpenGL");
#ifdef HAS_GSH_VULKAN
ui->comboBox_gs_selection->insertItem(SettingsDialog::GS_HANDLERS::VULKAN, "Vulkan");
#else
ui->gs_option_widget->hide();
#endif
ui->comboBox_gs_selection->blockSignals(false);
2020-02-11 07:53:35 +00:00
// this assert is to ensure no one adds an item to the combobox through qt creator by accident
assert(ui->comboBox_gs_selection->count() == SettingsDialog::GS_HANDLERS::MAX_HANDLER);
2018-04-30 21:01:23 +01:00
LoadPreferences();
connect(ui->listWidget, &QListWidget::currentItemChanged, this, &SettingsDialog::changePage);
2016-08-23 00:54:10 +01:00
}
SettingsDialog::~SettingsDialog()
{
2018-04-30 21:01:23 +01:00
CAppConfig::GetInstance().Save();
delete ui;
2016-08-23 00:54:10 +01:00
}
2018-04-30 21:01:23 +01:00
void SettingsDialog::changePage(QListWidgetItem* current, QListWidgetItem* previous)
2016-08-23 00:54:10 +01:00
{
2018-04-30 21:01:23 +01:00
if(!current)
current = previous;
2016-08-23 00:54:10 +01:00
2018-04-30 21:01:23 +01:00
ui->stackedWidget->setCurrentIndex(ui->listWidget->row(current));
2016-08-23 00:54:10 +01:00
}
void SettingsDialog::LoadPreferences()
{
int factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
int factor_index = std::log2(factor);
ui->comboBox_res_multiplyer->setCurrentIndex(factor_index);
2018-04-30 21:01:23 +01:00
ui->checkBox_force_bilinear_filtering->setChecked(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES));
2020-02-10 22:11:18 +00:00
ui->comboBox_gs_selection->setCurrentIndex(CAppConfig::GetInstance().GetPreferenceInteger(PREF_VIDEO_GS_HANDLER));
2016-08-23 00:54:10 +01:00
2018-04-30 21:01:23 +01:00
ui->checkBox_enable_audio->setChecked(CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT));
ui->spinBox_spuBlockCount->setValue(CAppConfig::GetInstance().GetPreferenceInteger(PREF_AUDIO_SPUBLOCKCOUNT));
2018-04-30 21:01:23 +01:00
ui->comboBox_presentation_mode->setCurrentIndex(CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSHANDLER_PRESENTATION_MODE));
2016-08-23 00:54:10 +01:00
}
void SettingsDialog::on_checkBox_force_bilinear_filtering_clicked(bool checked)
2016-08-23 00:54:10 +01:00
{
2018-04-30 21:01:23 +01:00
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, checked);
2016-08-23 00:54:10 +01:00
}
2020-02-10 22:11:18 +00:00
void SettingsDialog::on_comboBox_gs_selection_currentIndexChanged(int index)
{
2020-02-10 22:11:18 +00:00
CAppConfig::GetInstance().SetPreferenceInteger(PREF_VIDEO_GS_HANDLER, index);
}
2016-08-23 00:54:10 +01:00
void SettingsDialog::on_checkBox_enable_audio_clicked(bool checked)
{
2018-04-30 21:01:23 +01:00
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT, checked);
2016-08-23 00:54:10 +01:00
}
void SettingsDialog::on_comboBox_presentation_mode_currentIndexChanged(int index)
{
2018-04-30 21:01:23 +01:00
CAppConfig::GetInstance().SetPreferenceInteger(PREF_CGSHANDLER_PRESENTATION_MODE, index);
2016-08-23 00:54:10 +01:00
}
void SettingsDialog::on_comboBox_res_multiplyer_currentIndexChanged(int index)
{
int factor = pow(2, index);
CAppConfig::GetInstance().SetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR, factor);
}
void SettingsDialog::on_spinBox_spuBlockCount_valueChanged(int value)
{
CAppConfig::GetInstance().SetPreferenceInteger(PREF_AUDIO_SPUBLOCKCOUNT, value);
}