Play-/Source/ui_qt/settingsdialog.cpp

117 lines
3.8 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>
#include <QMessageBox>
#ifdef HAS_GSH_VULKAN
#include "gs/GSH_Vulkan/GSH_VulkanDeviceInfo.h"
#endif
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
// this assert is to ensure no one adds an item to the combobox through qt creator by accident
assert(ui->comboBox_gs_selection->count() == 0);
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
2020-04-26 16:53:27 -04:00
auto devices = GSH_Vulkan::CDeviceInfo::GetInstance().GetAvailableDevices();
if(!devices.empty())
{
ui->comboBox_gs_selection->insertItem(SettingsDialog::GS_HANDLERS::VULKAN, "Vulkan");
2020-04-26 16:53:27 -04:00
for(const auto& device : devices)
{
ui->comboBox_vulkan_device->insertItem(0, QString::fromUtf8(device.deviceName.c_str()));
}
}
2020-02-11 07:53:35 +00:00
#else
2020-04-26 11:01:31 -04:00
ui->button_vulkanDeviceInfo->hide();
#endif
if(ui->comboBox_gs_selection->count() <= 1)
{
ui->gs_option_widget->hide();
}
ui->comboBox_gs_selection->blockSignals(false);
2020-02-11 07:53:35 +00: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));
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);
}
void SettingsDialog::on_button_vulkanDeviceInfo_clicked()
{
#if HAS_GSH_VULKAN
auto log = GSH_Vulkan::CDeviceInfo::GetInstance().GetLog();
QMessageBox::information(this, "Vulkan Device Info", log.c_str());
#endif
}