Skip to content

Commit

Permalink
Rename widgets, reset on close button
Browse files Browse the repository at this point in the history
  • Loading branch information
rainmakerv3 committed Dec 16, 2024
1 parent f8619db commit a83c364
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
17 changes: 10 additions & 7 deletions src/qt_gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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));
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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");
Expand All @@ -577,4 +578,6 @@ void SettingsDialog::ResetInstallFolders() {
}
Config::setGameInstallDirs(settings_install_dirs_config);
}

ui->GammaSlider->setValue(toml::find_or<int>(data, "GPU", "GammaValue", 1000));
}
2 changes: 1 addition & 1 deletion src/qt_gui/settings_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SettingsDialog : public QDialog {
private:
void LoadValuesFromConfig();
void UpdateSettings();
void ResetInstallFolders();
void SyncRealTimeWidgetstoConfig();
void InitializeEmulatorLanguages();
void OnLanguageChanged(int index);
void OnCursorStateChanged(s16 index);
Expand Down
14 changes: 7 additions & 7 deletions src/qt_gui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit a83c364

Please sign in to comment.