Rename widgets, reset on close button

This commit is contained in:
rainmakerv2 2024-12-17 05:40:46 +08:00
parent f8619dbfb5
commit a83c3648b1
3 changed files with 18 additions and 15 deletions

View File

@ -109,9 +109,8 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
Config::save(config_dir / "config.toml");
LoadValuesFromConfig();
} else if (button == ui->buttonBox->button(QDialogButtonBox::Close)) {
ResetInstallFolders();
SyncRealTimeWidgetstoConfig();
}
if (Common::Log::IsActive()) {
Common::Log::Filter filter;
filter.ParseFilterString(Config::getLogFilter());
@ -294,8 +293,6 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->vkSyncValidationCheckBox->setChecked(
toml::find_or<bool>(data, "Vulkan", "validation_sync", false));
ui->rdocCheckBox->setChecked(toml::find_or<bool>(data, "Vulkan", "rdocEnable", false));
ui->GammaSlider->setValue(toml::find_or<int>(data, "GPU", "GammaValue", 1000));
ui->GammaLabel->setText(QString::number(ui->GammaSlider->value()));
#ifdef ENABLE_UPDATER
ui->updateCheckBox->setChecked(toml::find_or<bool>(data, "General", "autoUpdate", false));
@ -316,7 +313,10 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
ui->removeFolderButton->setEnabled(!ui->gameFoldersListWidget->selectedItems().isEmpty());
ResetInstallFolders();
SyncRealTimeWidgetstoConfig();
float Gammafloat = static_cast<float>((ui->GammaSlider->value() / 1000.0f));
ui->GammaLabel->setText(QString::number(Gammafloat));
}
void SettingsDialog::InitializeEmulatorLanguages() {
@ -376,9 +376,10 @@ void SettingsDialog::OnCursorStateChanged(s16 index) {
}
void SettingsDialog::GammaSliderChange(int value) {
ui->GammaLabel->setText(QString::number(ui->GammaSlider->value()));
float Gammafloat = static_cast<float>((value / 1000.0f));
ui->GammaLabel->setText(QString::number(Gammafloat));
// presenter crashes if game is running, set isGameRunning to off when stop game is implemented
if (isGameRunning) {
presenter->GetGammaRef() = Gammafloat;
}
@ -551,7 +552,7 @@ void SettingsDialog::UpdateSettings() {
BackgroundMusicPlayer::getInstance().setVolume(ui->BGMVolumeSlider->value());
}
void SettingsDialog::ResetInstallFolders() {
void SettingsDialog::SyncRealTimeWidgetstoConfig() {
std::filesystem::path userdir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
const toml::value data = toml::parse(userdir / "config.toml");
@ -577,4 +578,6 @@ void SettingsDialog::ResetInstallFolders() {
}
Config::setGameInstallDirs(settings_install_dirs_config);
}
ui->GammaSlider->setValue(toml::find_or<int>(data, "GPU", "GammaValue", 1000));
}

View File

@ -32,7 +32,7 @@ signals:
private:
void LoadValuesFromConfig();
void UpdateSettings();
void ResetInstallFolders();
void SyncRealTimeWidgetstoConfig();
void InitializeEmulatorLanguages();
void OnLanguageChanged(int index);
void OnCursorStateChanged(s16 index);

View File

@ -897,15 +897,15 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="GammaGroupBox">
<property name="title">
<string>Gamma Correction</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="GammaVLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="GammaLabelsHLayout">
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="CurrentValueLabel">
<property name="text">
<string>Current Value:</string>
</property>
@ -946,16 +946,16 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="LighterDarkerHLayout">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="LighterLabel">
<property name="text">
<string>Lighter</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="DarkerLabel">
<property name="text">
<string>Darker</string>
</property>