From d7eff61882d11ee72c669dbab5a09fbac2ddbb8b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 29 Apr 2025 15:12:07 -0400 Subject: [PATCH] Only show either the "install tool" or "remove tool" buttons It doesn't make sense to show both, the compatibility tool is either installed *or* not installed yet. --- launcher/include/compatibilitytoolinstaller.h | 5 +++++ launcher/src/compatibilitytoolinstaller.cpp | 16 ++++++++++++++++ launcher/ui/Settings/CompatibilityToolSetup.qml | 13 +++++-------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/launcher/include/compatibilitytoolinstaller.h b/launcher/include/compatibilitytoolinstaller.h index c5c6d42..ac302d5 100644 --- a/launcher/include/compatibilitytoolinstaller.h +++ b/launcher/include/compatibilitytoolinstaller.h @@ -13,16 +13,21 @@ class CompatibilityToolInstaller : public QObject QML_ELEMENT QML_UNCREATABLE("Use LauncherCore.createCompatInstaller") + Q_PROPERTY(bool isInstalled READ isInstalled NOTIFY isInstalledChanged) + public: explicit CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent = nullptr); Q_INVOKABLE void installCompatibilityTool(); Q_INVOKABLE void removeCompatibilityTool(); + bool isInstalled() const; + Q_SIGNALS: void installFinished(); void error(QString message); void removalFinished(); + void isInstalledChanged(); private: LauncherCore &m_launcher; diff --git a/launcher/src/compatibilitytoolinstaller.cpp b/launcher/src/compatibilitytoolinstaller.cpp index 42ec106..0307844 100644 --- a/launcher/src/compatibilitytoolinstaller.cpp +++ b/launcher/src/compatibilitytoolinstaller.cpp @@ -86,6 +86,7 @@ void CompatibilityToolInstaller::installCompatibilityTool() compatibilityToolFile.close(); Q_EMIT installFinished(); + Q_EMIT isInstalledChanged(); } void CompatibilityToolInstaller::removeCompatibilityTool() @@ -108,6 +109,21 @@ void CompatibilityToolInstaller::removeCompatibilityTool() } Q_EMIT removalFinished(); + Q_EMIT isInstalledChanged(); +} + +bool CompatibilityToolInstaller::isInstalled() const +{ + const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::HomeLocation)[0]; + const QDir steamDir = appDataDir.absoluteFilePath(QStringLiteral(".steam")); + const QDir steamSteamDir = steamDir.absoluteFilePath(QStringLiteral("steam")); + if (!steamSteamDir.exists()) { + return false; + } + + const QDir compatToolDir = steamSteamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d")); + const QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra")); + return astraToolDir.exists(); } #include "moc_compatibilitytoolinstaller.cpp" \ No newline at end of file diff --git a/launcher/ui/Settings/CompatibilityToolSetup.qml b/launcher/ui/Settings/CompatibilityToolSetup.qml index d1c301e..5401c7e 100644 --- a/launcher/ui/Settings/CompatibilityToolSetup.qml +++ b/launcher/ui/Settings/CompatibilityToolSetup.qml @@ -24,29 +24,26 @@ FormCard.FormCardPage { FormCard.FormTextDelegate { text: i18n("Press the button below to install the compatibility tool for Steam.") } + } - FormCard.FormDelegateSeparator { - below: installToolButton - } + FormCard.FormCard { + Layout.topMargin: Kirigami.Units.largeSpacing FormCard.FormButtonDelegate { id: installToolButton text: i18n("Install Tool") icon.name: "install" + visible: !page.installer.isInstalled onClicked: page.installer.installCompatibilityTool() } - FormCard.FormDelegateSeparator { - above: installToolButton - below: removeToolButton - } - FormCard.FormButtonDelegate { id: removeToolButton text: i18n("Remove Tool") icon.name: "delete" + visible: page.installer.isInstalled onClicked: page.installer.removeCompatibilityTool() } }