1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-22 12:47:44 +00:00

Use UUIDs as keys for profile settings, and enforce a well-known order

This commit is contained in:
redstrate 2021-11-09 13:24:38 -05:00
parent e1d4be7aff
commit 083d8a970c
2 changed files with 22 additions and 8 deletions

View file

@ -122,13 +122,17 @@ void LauncherWindow::readInitialInformation() {
// create the Default profile if it doesnt exist // create the Default profile if it doesnt exist
if(profiles.empty()) if(profiles.empty())
profiles.append("Default"); profiles.append(QUuid::createUuid().toString());
for(const auto& profile_name : profiles) { profileSettings.resize(profiles.size());
for(const auto& uuid : profiles) {
ProfileSettings profile; ProfileSettings profile;
profile.name = profile_name; profile.uuid = QUuid(uuid);
settings.beginGroup(profile_name); settings.beginGroup(uuid);
profile.name = settings.value("name").toString();
profile.wineVersion = settings.value("wineVersion", 0).toInt(); profile.wineVersion = settings.value("wineVersion", 0).toInt();
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
@ -195,9 +199,9 @@ void LauncherWindow::readInitialInformation() {
profile.useGamescope = settings.value("useGamescope", false).toBool(); profile.useGamescope = settings.value("useGamescope", false).toBool();
profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool(); profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool();
settings.endGroup(); profileSettings[settings.value("index").toInt()] = profile;
profileSettings.append(profile); settings.endGroup();
} }
readGameVersion(); readGameVersion();
@ -378,6 +382,7 @@ QList<QString> LauncherWindow::profileList() const {
int LauncherWindow::addProfile() { int LauncherWindow::addProfile() {
ProfileSettings newProfile; ProfileSettings newProfile;
newProfile.uuid = QUuid::createUuid();
newProfile.name = "New Profile"; newProfile.name = "New Profile";
profileSettings.append(newProfile); profileSettings.append(newProfile);
@ -388,8 +393,15 @@ int LauncherWindow::addProfile() {
} }
void LauncherWindow::saveSettings() { void LauncherWindow::saveSettings() {
for(auto profile : profileSettings) { settings.setValue("defaultProfile", defaultProfileIndex);
settings.beginGroup(profile.name);
for(int i = 0; i < profileSettings.size(); i++) {
const auto& profile = profileSettings[i];
settings.beginGroup(profile.uuid.toString());
settings.setValue("name", profile.name);
settings.setValue("index", i);
// game // game
settings.setValue("useDX9", profile.useDX9); settings.setValue("useDX9", profile.useDX9);

View file

@ -7,12 +7,14 @@
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QPushButton> #include <QPushButton>
#include <QUuid>
class SapphireLauncher; class SapphireLauncher;
class SquareLauncher; class SquareLauncher;
class SquareBoot; class SquareBoot;
struct ProfileSettings { struct ProfileSettings {
QUuid uuid;
QString name; QString name;
int language = 1; // 1 is english, thats all i know int language = 1; // 1 is english, thats all i know