Skip to content

Commit

Permalink
GUI: Settings improvements (#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSvoboda authored Jan 22, 2025
1 parent d7c2cb1 commit 1fcfb07
Show file tree
Hide file tree
Showing 32 changed files with 1,474 additions and 680 deletions.
13 changes: 12 additions & 1 deletion src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static std::string logFilter;
static std::string logType = "async";
static std::string userName = "shadPS4";
static std::string updateChannel;
static std::string chooseHomeTab;
static u16 deadZoneLeft = 2.0;
static u16 deadZoneRight = 2.0;
static std::string backButtonBehavior = "left";
Expand Down Expand Up @@ -194,6 +195,10 @@ std::string getUpdateChannel() {
return updateChannel;
}

std::string getChooseHomeTab() {
return chooseHomeTab;
}

std::string getBackButtonBehavior() {
return backButtonBehavior;
}
Expand Down Expand Up @@ -399,6 +404,9 @@ void setUserName(const std::string& type) {
void setUpdateChannel(const std::string& type) {
updateChannel = type;
}
void setChooseHomeTab(const std::string& type) {
chooseHomeTab = type;
}

void setBackButtonBehavior(const std::string& type) {
backButtonBehavior = type;
Expand Down Expand Up @@ -637,6 +645,7 @@ void load(const std::filesystem::path& path) {
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false);
checkCompatibilityOnStartup =
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", "Release");
}

if (data.contains("Input")) {
Expand Down Expand Up @@ -760,6 +769,7 @@ void save(const std::filesystem::path& path) {
data["General"]["logType"] = logType;
data["General"]["userName"] = userName;
data["General"]["updateChannel"] = updateChannel;
data["General"]["chooseHomeTab"] = chooseHomeTab;
data["General"]["showSplash"] = isShowSplash;
data["General"]["autoUpdate"] = isAutoUpdate;
data["General"]["separateUpdateEnabled"] = separateupdatefolder;
Expand Down Expand Up @@ -871,6 +881,7 @@ void setDefaultValues() {
} else {
updateChannel = "Nightly";
}
chooseHomeTab = "General";
cursorState = HideCursorState::Idle;
cursorHideTimeout = 5;
backButtonBehavior = "left";
Expand Down Expand Up @@ -898,4 +909,4 @@ void setDefaultValues() {
checkCompatibilityOnStartup = false;
}

} // namespace Config
} // namespace Config
2 changes: 2 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std::string getLogFilter();
std::string getLogType();
std::string getUserName();
std::string getUpdateChannel();
std::string getChooseHomeTab();

u16 leftDeadZone();
u16 rightDeadZone();
Expand Down Expand Up @@ -81,6 +82,7 @@ void setLanguage(u32 language);
void setNeoMode(bool enable);
void setUserName(const std::string& type);
void setUpdateChannel(const std::string& type);
void setChooseHomeTab(const std::string& type);
void setSeparateUpdateEnabled(bool use);
void setGameInstallDirs(const std::vector<std::filesystem::path>& settings_install_dirs_config);
void setSaveDataPath(const std::filesystem::path& path);
Expand Down
23 changes: 19 additions & 4 deletions src/qt_gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
: QDialog(parent), ui(new Ui::SettingsDialog) {
ui->setupUi(this);
ui->tabWidgetSettings->setUsesScrollButtons(false);

initialHeight = this->height();
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);

Expand Down Expand Up @@ -150,7 +151,6 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
});
#else
ui->updaterGroupBox->setVisible(false);
ui->GUIgroupBox->setMaximumSize(265, 16777215);
#endif
connect(ui->updateCompatibilityButton, &QPushButton::clicked, this,
[this, parent, m_compat_info]() {
Expand All @@ -169,6 +169,11 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
});
}

// Gui TAB
{
connect(ui->chooseHomeTabComboBox, &QComboBox::currentTextChanged, this,
[](const QString& hometab) { Config::setChooseHomeTab(hometab.toStdString()); });
}
// Input TAB
{
connect(ui->hideCursorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
Expand Down Expand Up @@ -246,7 +251,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
#ifdef ENABLE_UPDATER
ui->updaterGroupBox->installEventFilter(this);
#endif
ui->GUIgroupBox->installEventFilter(this);
ui->GUIMusicGroupBox->installEventFilter(this);
ui->disableTrophycheckBox->installEventFilter(this);
ui->enableCompatibilityCheckBox->installEventFilter(this);
ui->checkCompatibilityOnStartupCheckBox->installEventFilter(this);
Expand Down Expand Up @@ -373,6 +378,15 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel));
#endif

std::string chooseHomeTab = toml::find_or<std::string>(data, "General", "chooseHomeTab", "");
ui->chooseHomeTabComboBox->setCurrentText(QString::fromStdString(chooseHomeTab));
QStringList tabNames = {tr("General"), tr("Gui"), tr("Graphics"), tr("User"),
tr("Input"), tr("Paths"), tr("Debug")};
QString chooseHomeTabQString = QString::fromStdString(chooseHomeTab);
int indexTab = tabNames.indexOf(chooseHomeTabQString);
indexTab = (indexTab == -1) ? 0 : indexTab;
ui->tabWidgetSettings->setCurrentIndex(indexTab);

QString backButtonBehavior = QString::fromStdString(
toml::find_or<std::string>(data, "Input", "backButtonBehavior", "left"));
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
Expand Down Expand Up @@ -476,8 +490,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
} else if (elementName == "updaterGroupBox") {
text = tr("updaterGroupBox");
#endif
} else if (elementName == "GUIgroupBox") {
text = tr("GUIgroupBox");
} else if (elementName == "GUIMusicGroupBox") {
text = tr("GUIMusicGroupBox");
} else if (elementName == "disableTrophycheckBox") {
text = tr("disableTrophycheckBox");
} else if (elementName == "enableCompatibilityCheckBox") {
Expand Down Expand Up @@ -592,6 +606,7 @@ void SettingsDialog::UpdateSettings() {
Config::setRdocEnabled(ui->rdocCheckBox->isChecked());
Config::setAutoUpdate(ui->updateCheckBox->isChecked());
Config::setUpdateChannel(ui->updateComboBox->currentText().toStdString());
Config::setChooseHomeTab(ui->chooseHomeTabComboBox->currentText().toStdString());
Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked());
Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked());

Expand Down
Loading

0 comments on commit 1fcfb07

Please sign in to comment.