1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-05-13 21:07:46 +00:00

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.
This commit is contained in:
Joshua Goins 2025-05-05 16:14:42 -04:00
parent c38d77d087
commit 7cb82b43d3
7 changed files with 28 additions and 4 deletions

View file

@ -25,6 +25,8 @@ class Profile : public QObject
Q_PROPERTY(QString wineVersionText READ wineVersionText NOTIFY wineChanged) Q_PROPERTY(QString wineVersionText READ wineVersionText NOTIFY wineChanged)
Q_PROPERTY(QString subtitle READ subtitle NOTIFY gameInstallChanged) Q_PROPERTY(QString subtitle READ subtitle NOTIFY gameInstallChanged)
Q_PROPERTY(ProfileConfig *config READ config CONSTANT) Q_PROPERTY(ProfileConfig *config READ config CONSTANT)
Q_PROPERTY(bool isGamePathDefault READ isGamePathDefault NOTIFY gameInstallChanged)
Q_PROPERTY(bool isWinePrefixDefault READ isWinePrefixDefault NOTIFY winePrefixChanged)
public: public:
explicit Profile(const QString &key, QObject *parent = nullptr); explicit Profile(const QString &key, QObject *parent = nullptr);
@ -101,10 +103,13 @@ public:
[[nodiscard]] QString subtitle() const; [[nodiscard]] QString subtitle() const;
ProfileConfig *config() const; ProfileConfig *config() const;
bool isGamePathDefault() const;
bool isWinePrefixDefault() const;
Q_SIGNALS: Q_SIGNALS:
void gameInstallChanged(); void gameInstallChanged();
void winePathChanged(); void winePathChanged();
void winePrefixChanged();
void accountChanged(); void accountChanged();
void wineChanged(); void wineChanged();
void hasDirectx9Changed(); void hasDirectx9Changed();

View file

@ -28,6 +28,7 @@ Profile::Profile(const QString &key, QObject *parent)
connect(m_config, &ProfileConfig::WineTypeChanged, this, &Profile::readWineInfo); connect(m_config, &ProfileConfig::WineTypeChanged, this, &Profile::readWineInfo);
connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::readGameVersion); connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::readGameVersion);
connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::hasDirectx9Changed); connect(m_config, &ProfileConfig::GamePathChanged, this, &Profile::hasDirectx9Changed);
connect(m_config, &ProfileConfig::WinePrefixPathChanged, this, &Profile::winePrefixChanged);
} }
Profile::~Profile() Profile::~Profile()
@ -398,4 +399,14 @@ ProfileConfig *Profile::config() const
return m_config; 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" #include "moc_profile.cpp"

View file

@ -14,6 +14,7 @@ FormCard.AbstractFormDelegate {
id: root id: root
property string folder property string folder
property string displayText: folder
signal accepted(string folder) signal accepted(string folder)
@ -34,7 +35,7 @@ FormCard.AbstractFormDelegate {
} }
QQC2.Label { QQC2.Label {
text: root.folder text: root.displayText
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor

View file

@ -85,6 +85,7 @@ FormCard.FormCardPage {
text: i18n("Game Folder") text: i18n("Game Folder")
folder: page.profile.config.gamePath folder: page.profile.config.gamePath
displayText: page.profile.isGamePathDefault ? i18n("Default Location") : folder
onAccepted: (folder) => { onAccepted: (folder) => {
page.profile.config.gamePath = folder; page.profile.config.gamePath = folder;
@ -185,6 +186,12 @@ FormCard.FormCardPage {
text: i18n("Wine Prefix Folder") text: i18n("Wine Prefix Folder")
folder: page.profile.config.winePrefixPath 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 { FormCard.FormDelegateSeparator {

View file

@ -33,7 +33,7 @@ FormCard.FormCardPage {
icon.name: "document-open-folder" icon.name: "document-open-folder"
text: i18n("Select Install Folder") text: i18n("Select Install Folder")
description: profile.config.gamePath description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath
onClicked: installFolderDialog.open() onClicked: installFolderDialog.open()
} }

View file

@ -33,7 +33,7 @@ FormCard.FormCardPage {
icon.name: "document-open-folder" icon.name: "document-open-folder"
text: i18n("Select Install Folder") text: i18n("Select Install Folder")
description: profile.config.gamePath description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath
onClicked: installFolderDialog.open() onClicked: installFolderDialog.open()
} }

View file

@ -82,7 +82,7 @@ FormCard.FormCardPage {
required property var profile required property var profile
text: profile.config.name text: profile.config.name
description: profile.config.gamePath description: profile.isGamePathDefault ? i18n("Default Location") : profile.config.gamePath
visible: profile.isGameInstalled visible: profile.isGameInstalled
onClicked: { onClicked: {