1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00
astra/launcher/ui/Setup/SetupPage.qml
Joshua Goins d83faa6bbb Add button to change the install folder when setting up a profile
This is useful if you want to set up the game on an external disk or SD
card, for example.
2024-05-26 08:15:20 -04:00

221 lines
No EOL
7 KiB
QML

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtCore
import QtQuick
import QtQuick.Dialogs
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import zone.xiv.astra
FormCard.FormCardPage {
id: page
property var profile
readonly property bool isInitialSetup: !LauncherCore.profileManager.hasAnyExistingInstallations()
title: isInitialSetup ? i18n("Initial Setup") : i18n("Profile Setup")
data: FolderDialog {
id: installFolderDialog
onAccepted: page.profile.gamePath = decodeURIComponent(selectedFolder.toString().replace("file://", ""))
}
Image {
source: "qrc:/zone.xiv.astra.svg"
fillMode: Image.PreserveAspectFit
visible: !LauncherCore.profileManager.hasAnyExistingInstallations()
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: Kirigami.Units.largeSpacing * 3
}
FormCard.FormCard {
Layout.fillWidth: true
Layout.topMargin: LauncherCore.profileManager.hasAnyExistingInstallations() ? Kirigami.Units.largeSpacing : 0
FormCard.FormTextDelegate {
id: helpText
text: {
if (page.isInitialSetup) {
return i18n("You must have a legitimate installation of FFXIV to continue.");
} else {
return i18n("Select a game installation for '%1'.", page.profile.name);
}
}
}
FormCard.FormDelegateSeparator {
above: helpText
below: selectInstallFolder
}
FormCard.FormButtonDelegate {
id: selectInstallFolder
icon.name: "document-open-folder"
text: i18n("Select Install Folder")
description: profile.gamePath
onClicked: installFolderDialog.open()
}
}
FormCard.FormHeader {
title: i18n("Existing Installation")
visible: LauncherCore.profileManager.hasAnyExistingInstallations()
}
FormCard.FormCard {
visible: LauncherCore.profileManager.hasAnyExistingInstallations()
Layout.fillWidth: true
FormCard.FormTextDelegate {
id: existingHelpDelegate
text: i18n("You can select an existing game installation from another profile.")
}
FormCard.FormDelegateSeparator {
above: existingHelpDelegate
}
Repeater {
model: LauncherCore.profileManager
FormCard.FormButtonDelegate {
required property var profile
text: profile.name
description: profile.gamePath
visible: profile.isGameInstalled
onClicked: {
LauncherCore.currentProfile.gamePath = profile.gamePath;
applicationWindow().checkSetup();
}
}
}
FormCard.FormDelegateSeparator {
below: importDelegate
}
FormCard.FormButtonDelegate {
id: importDelegate
text: i18n("Import Existing Installation…")
description: i18n("Select an existing installation on disk or import from another launcher.")
icon.name: "document-import-symbolic"
onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "ExistingSetup"), {
profile: page.profile
})
}
}
FormCard.FormHeader {
title: i18n("Retail Game")
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
FormCard.FormButtonDelegate {
id: downloadDelegate
text: i18n("Download & Install Game")
description: i18n("Download the retail installer online from Square Enix.")
icon.name: "cloud-download"
onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "InstallProgress"), {
gameInstaller: LauncherCore.createInstaller(page.profile)
})
}
FormCard.FormDelegateSeparator {
above: downloadDelegate
below: selectInstallDelegate
}
FormCard.FormButtonDelegate {
id: selectInstallDelegate
text: i18n("Select Existing Installer…")
description: i18n("Use a previously downloaded installer. Useful if offline or can't otherwise access the official servers.")
icon.name: "edit-find"
FileDialog {
id: dialog
currentFolder: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0]
nameFilters: [i18n("Windows executable (*.exe)")]
onAccepted: {
const url = decodeURIComponent(selectedFile.toString().replace("file://", ""));
page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "InstallProgress"), {
gameInstaller: LauncherCore.createInstallerFromExisting(page.profile, url)
});
}
}
onClicked: dialog.open()
}
}
FormCard.FormHeader {
title: i18n("Benchmark")
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
FormCard.FormButtonDelegate {
id: downloadBenchmark
text: i18n("Download & Install Benchmark")
description: i18n("Download the official benchmark from Square Enix.")
icon.name: "cloud-download"
onClicked: page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BenchmarkInstallProgress"), {
benchmarkInstaller: LauncherCore.createBenchmarkInstaller(page.profile)
})
}
FormCard.FormDelegateSeparator {
above: downloadBenchmark
below: selectBenchmark
}
FormCard.FormButtonDelegate {
id: selectBenchmark
text: i18n("Select Existing Benchmark…")
description: i18n("Use a previously downloaded benchmark. Useful if offline or can't otherwise access the official servers.")
icon.name: "edit-find"
FileDialog {
id: benchmarkDialog
currentFolder: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0]
nameFilters: [i18n("Benchmark zip archive (*.zip)")]
onAccepted: {
const url = decodeURIComponent(selectedFile.toString().replace("file://", ""));
page.Window.window.pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "BenchmarkInstallProgress"), {
benchmarkInstaller: LauncherCore.createBenchmarkInstallerFromExisting(page.profile, url)
});
}
}
onClicked: benchmarkDialog.open()
}
}
}