mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 11:47:46 +00:00
Modernize CompatibilityToolInstaller
This commit is contained in:
parent
3a471553ab
commit
dc298a24f1
2 changed files with 18 additions and 16 deletions
|
@ -16,7 +16,7 @@ class CompatibilityToolInstaller : public QObject
|
||||||
QML_UNCREATABLE("Use LauncherCore.createCompatInstaller")
|
QML_UNCREATABLE("Use LauncherCore.createCompatInstaller")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
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();
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "compatibilitytoolinstaller.h"
|
#include "compatibilitytoolinstaller.h"
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
|
|
||||||
CompatibilityToolInstaller::CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent)
|
CompatibilityToolInstaller::CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent)
|
||||||
|
@ -14,16 +16,16 @@ CompatibilityToolInstaller::CompatibilityToolInstaller(LauncherCore &launcher, Q
|
||||||
void CompatibilityToolInstaller::installCompatibilityTool()
|
void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
{
|
{
|
||||||
const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::GenericDataLocation)[0];
|
const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::GenericDataLocation)[0];
|
||||||
const QDir steamDir = appDataDir.absoluteFilePath("Steam");
|
const QDir steamDir = appDataDir.absoluteFilePath(QStringLiteral("Steam"));
|
||||||
if (!steamDir.exists()) {
|
if (!steamDir.exists()) {
|
||||||
Q_EMIT error("Could not find a Steam installation.");
|
Q_EMIT error(i18n("Could not find a Steam installation."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDir compatToolDir = steamDir.absoluteFilePath("compatibilitytools.d");
|
const QDir compatToolDir = steamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d"));
|
||||||
const QDir astraToolDir = compatToolDir.absoluteFilePath("astra");
|
const QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra"));
|
||||||
if (astraToolDir.exists()) {
|
if (astraToolDir.exists()) {
|
||||||
Q_EMIT error("The compatibility tool is already installed.");
|
Q_EMIT error(i18n("The compatibility tool is already installed."));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
QDir().mkpath(astraToolDir.absolutePath());
|
QDir().mkpath(astraToolDir.absolutePath());
|
||||||
|
@ -31,7 +33,7 @@ void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
|
|
||||||
const QString appPath = QCoreApplication::applicationFilePath();
|
const QString appPath = QCoreApplication::applicationFilePath();
|
||||||
QFile appFile(appPath);
|
QFile appFile(appPath);
|
||||||
appFile.link(astraToolDir.absoluteFilePath("astra"));
|
appFile.link(astraToolDir.absoluteFilePath(QStringLiteral("astra")));
|
||||||
|
|
||||||
const QString toolManifestContents = QStringLiteral(
|
const QString toolManifestContents = QStringLiteral(
|
||||||
"\"manifest\"\n"
|
"\"manifest\"\n"
|
||||||
|
@ -40,8 +42,8 @@ void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
" \"commandline\" \"/astra --steam %verb%\"\n"
|
" \"commandline\" \"/astra --steam %verb%\"\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
QFile toolManifestFile(astraToolDir.absoluteFilePath("toolmanifest.vdf"));
|
QFile toolManifestFile(astraToolDir.absoluteFilePath(QStringLiteral("toolmanifest.vdf")));
|
||||||
toolManifestFile.open(QIODevice::WriteOnly);
|
toolManifestFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
toolManifestFile.write(toolManifestContents.toUtf8());
|
toolManifestFile.write(toolManifestContents.toUtf8());
|
||||||
toolManifestFile.close();
|
toolManifestFile.close();
|
||||||
|
|
||||||
|
@ -61,8 +63,8 @@ void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
" }\n"
|
" }\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
QFile compatibilityToolFile(astraToolDir.absoluteFilePath("compatibilitytool.vdf"));
|
QFile compatibilityToolFile(astraToolDir.absoluteFilePath(QStringLiteral("compatibilitytool.vdf")));
|
||||||
compatibilityToolFile.open(QIODevice::WriteOnly);
|
compatibilityToolFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
compatibilityToolFile.write(compatibilityToolContents.toUtf8());
|
compatibilityToolFile.write(compatibilityToolContents.toUtf8());
|
||||||
compatibilityToolFile.close();
|
compatibilityToolFile.close();
|
||||||
|
|
||||||
|
@ -72,16 +74,16 @@ void CompatibilityToolInstaller::installCompatibilityTool()
|
||||||
void CompatibilityToolInstaller::removeCompatibilityTool()
|
void CompatibilityToolInstaller::removeCompatibilityTool()
|
||||||
{
|
{
|
||||||
const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::GenericDataLocation)[0];
|
const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::GenericDataLocation)[0];
|
||||||
const QDir steamDir = appDataDir.absoluteFilePath("Steam");
|
const QDir steamDir = appDataDir.absoluteFilePath(QStringLiteral("Steam"));
|
||||||
if (!steamDir.exists()) {
|
if (!steamDir.exists()) {
|
||||||
Q_EMIT error("Could not find a Steam installation.");
|
Q_EMIT error(i18n("Could not find a Steam installation."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDir compatToolDir = steamDir.absoluteFilePath("compatibilitytools.d");
|
const QDir compatToolDir = steamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d"));
|
||||||
QDir astraToolDir = compatToolDir.absoluteFilePath("astra");
|
QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra"));
|
||||||
if (!astraToolDir.exists()) {
|
if (!astraToolDir.exists()) {
|
||||||
Q_EMIT error("The compatibility tool is not installed.");
|
Q_EMIT error(i18n("The compatibility tool is not installed."));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
astraToolDir.removeRecursively();
|
astraToolDir.removeRecursively();
|
||||||
|
|
Loading…
Add table
Reference in a new issue