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_ELEMENT
|
||||||
QML_UNCREATABLE("Use LauncherCore.createCompatInstaller")
|
QML_UNCREATABLE("Use LauncherCore.createCompatInstaller")
|
||||||
|
|
||||||
|
Q_PROPERTY(bool isInstalled READ isInstalled NOTIFY isInstalledChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent = nullptr);
|
explicit CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE void installCompatibilityTool();
|
Q_INVOKABLE void installCompatibilityTool();
|
||||||
Q_INVOKABLE void removeCompatibilityTool();
|
Q_INVOKABLE void removeCompatibilityTool();
|
||||||
|
|
||||||
|
bool isInstalled() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void installFinished();
|
void installFinished();
|
||||||
void error(QString message);
|
void error(QString message);
|
||||||
void removalFinished();
|
void removalFinished();
|
||||||
|
void isInstalledChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LauncherCore &m_launcher;
|
LauncherCore &m_launcher;
|
||||||
|
|
|
@ -86,6 +86,7 @@ void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
compatibilityToolFile.close();
|
compatibilityToolFile.close();
|
||||||
|
|
||||||
Q_EMIT installFinished();
|
Q_EMIT installFinished();
|
||||||
|
Q_EMIT isInstalledChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompatibilityToolInstaller::removeCompatibilityTool()
|
void CompatibilityToolInstaller::removeCompatibilityTool()
|
||||||
|
@ -108,6 +109,21 @@ void CompatibilityToolInstaller::removeCompatibilityTool()
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT removalFinished();
|
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"
|
#include "moc_compatibilitytoolinstaller.cpp"
|
|
@ -24,29 +24,26 @@ FormCard.FormCardPage {
|
||||||
FormCard.FormTextDelegate {
|
FormCard.FormTextDelegate {
|
||||||
text: i18n("Press the button below to install the compatibility tool for Steam.")
|
text: i18n("Press the button below to install the compatibility tool for Steam.")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {
|
FormCard.FormCard {
|
||||||
below: installToolButton
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
id: installToolButton
|
id: installToolButton
|
||||||
|
|
||||||
text: i18n("Install Tool")
|
text: i18n("Install Tool")
|
||||||
icon.name: "install"
|
icon.name: "install"
|
||||||
|
visible: !page.installer.isInstalled
|
||||||
onClicked: page.installer.installCompatibilityTool()
|
onClicked: page.installer.installCompatibilityTool()
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {
|
|
||||||
above: installToolButton
|
|
||||||
below: removeToolButton
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
id: removeToolButton
|
id: removeToolButton
|
||||||
|
|
||||||
text: i18n("Remove Tool")
|
text: i18n("Remove Tool")
|
||||||
icon.name: "delete"
|
icon.name: "delete"
|
||||||
|
visible: page.installer.isInstalled
|
||||||
onClicked: page.installer.removeCompatibilityTool()
|
onClicked: page.installer.removeCompatibilityTool()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue