From 7cb82b43d3b3789e5f6cff3543deeb2daa283cb2 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 5 May 2025 16:14:42 -0400 Subject: [PATCH] When displaying default location for install/wine prefix, hide the path For most users, this ends up being a long useless string (because of the UUID included.) If it's the default, Astra-managed path then it simply says "Default Location". When it's a custom path, it shows the full path as per usual. This affects the visible game paths, but also the wine prefix path. --- launcher/include/profile.h | 5 +++++ launcher/src/profile.cpp | 11 +++++++++++ launcher/ui/Components/FormFolderDelegate.qml | 3 ++- launcher/ui/Settings/ProfileSettings.qml | 7 +++++++ launcher/ui/Setup/InstallBenchmark.qml | 2 +- launcher/ui/Setup/InstallGame.qml | 2 +- launcher/ui/Setup/SetupPage.qml | 2 +- 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/launcher/include/profile.h b/launcher/include/profile.h index e49a7b2..037ea5a 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -25,6 +25,8 @@ class Profile : public QObject Q_PROPERTY(QString wineVersionText READ wineVersionText NOTIFY wineChanged) Q_PROPERTY(QString subtitle READ subtitle NOTIFY gameInstallChanged) Q_PROPERTY(ProfileConfig *config READ config CONSTANT) + Q_PROPERTY(bool isGamePathDefault READ isGamePathDefault NOTIFY gameInstallChanged) + Q_PROPERTY(bool isWinePrefixDefault READ isWinePrefixDefault NOTIFY winePrefixChanged) public: explicit Profile(const QString &key, QObject *parent = nullptr); @@ -101,10 +103,13 @@ public: [[nodiscard]] QString subtitle() const; ProfileConfig *config() const; + bool isGamePathDefault() const; + bool isWinePrefixDefault() const; Q_SIGNALS: void gameInstallChanged(); void winePathChanged(); + void winePrefixChanged(); void accountChanged(); void wineChanged(); void hasDirectx9Changed(); diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index 15902fa..f013c6d 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -28,6 +28,7 @@ Profile::Profile(const QString &key, QObject *parent) connect(m_config, &ProfileConfig::WineTypeChanged, this, &Profile::readWineInfo); connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::readGameVersion); connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::hasDirectx9Changed); + connect(m_config, &ProfileConfig::WinePrefixPathChanged, this, &Profile::winePrefixChanged); } Profile::~Profile() @@ -398,4 +399,14 @@ ProfileConfig *Profile::config() const return m_config; } +bool Profile::isGamePathDefault() const +{ + return m_config->gamePath() == m_config->defaultGamePathValue(); +} + +bool Profile::isWinePrefixDefault() const +{ + return m_config->winePrefixPath() == m_config->defaultWinePrefixPathValue(); +} + #include "moc_profile.cpp" diff --git a/launcher/ui/Components/FormFolderDelegate.qml b/launcher/ui/Components/FormFolderDelegate.qml index 247af85..67adeee 100644 --- a/launcher/ui/Components/FormFolderDelegate.qml +++ b/launcher/ui/Components/FormFolderDelegate.qml @@ -14,6 +14,7 @@ FormCard.AbstractFormDelegate { id: root property string folder + property string displayText: folder signal accepted(string folder) @@ -34,7 +35,7 @@ FormCard.AbstractFormDelegate { } QQC2.Label { - text: root.folder + text: root.displayText elide: Text.ElideRight maximumLineCount: 1 color: Kirigami.Theme.disabledTextColor diff --git a/launcher/ui/Settings/ProfileSettings.qml b/launcher/ui/Settings/ProfileSettings.qml index 012e0fc..e7eb692 100644 --- a/launcher/ui/Settings/ProfileSettings.qml +++ b/launcher/ui/Settings/ProfileSettings.qml @@ -85,6 +85,7 @@ FormCard.FormCardPage { text: i18n("Game Folder") folder: page.profile.config.gamePath + displayText: page.profile.isGamePathDefault ? i18n("Default Location") : folder onAccepted: (folder) => { page.profile.config.gamePath = folder; @@ -185,6 +186,12 @@ FormCard.FormCardPage { text: i18n("Wine Prefix Folder") folder: page.profile.config.winePrefixPath + displayText: page.profile.isWinePrefixDefault ? i18n("Default Location") : folder + + onAccepted: (path) => { + page.profile.config.winePrefixPath = path; + page.profile.config.save(); + } } FormCard.FormDelegateSeparator { diff --git a/launcher/ui/Setup/InstallBenchmark.qml b/launcher/ui/Setup/InstallBenchmark.qml index 2c17d2e..1ff992a 100644 --- a/launcher/ui/Setup/InstallBenchmark.qml +++ b/launcher/ui/Setup/InstallBenchmark.qml @@ -33,7 +33,7 @@ FormCard.FormCardPage { icon.name: "document-open-folder" text: i18n("Select Install Folder") - description: profile.config.gamePath + description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath onClicked: installFolderDialog.open() } diff --git a/launcher/ui/Setup/InstallGame.qml b/launcher/ui/Setup/InstallGame.qml index 7c454ad..f499a43 100644 --- a/launcher/ui/Setup/InstallGame.qml +++ b/launcher/ui/Setup/InstallGame.qml @@ -33,7 +33,7 @@ FormCard.FormCardPage { icon.name: "document-open-folder" text: i18n("Select Install Folder") - description: profile.config.gamePath + description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath onClicked: installFolderDialog.open() } diff --git a/launcher/ui/Setup/SetupPage.qml b/launcher/ui/Setup/SetupPage.qml index 96aa375..e0173a2 100644 --- a/launcher/ui/Setup/SetupPage.qml +++ b/launcher/ui/Setup/SetupPage.qml @@ -82,7 +82,7 @@ FormCard.FormCardPage { required property var profile text: profile.config.name - description: profile.config.gamePath + description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath visible: profile.isGameInstalled onClicked: {