mirror of
https://github.com/redstrate/Astra.git
synced 2025-05-01 08:27:45 +00:00
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.
This commit is contained in:
parent
8f43744366
commit
d7eff61882
3 changed files with 26 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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"
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue