Play-/Source/ui_qt/settingsdialog.cpp

72 lines
2.4 KiB
C++
Raw Normal View History

2016-08-23 00:54:10 +01:00
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "PreferenceDefs.h"
#include "../gs/GSH_OpenGL/GSH_OpenGL.h"
#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
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));
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(PREFERENCE_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
}
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(PREFERENCE_AUDIO_SPUBLOCKCOUNT, value);
}