mirror of
https://github.com/redstrate/Auracite.git
synced 2025-04-22 20:57:46 +00:00
Improve the desktop UI
You can now select where to save the character archive. Errors and other information is passed up to the UI, and the page stack is improved a bit.
This commit is contained in:
parent
38eedd0477
commit
fd128c3f43
3 changed files with 96 additions and 48 deletions
|
@ -1,69 +1,99 @@
|
||||||
|
import QtCore
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
import org.kde.kirigamiaddons.formcard as FormCard
|
import org.kde.kirigamiaddons.formcard as FormCard
|
||||||
|
|
||||||
import zone.xiv.auracite
|
import zone.xiv.auracite
|
||||||
|
|
||||||
Kirigami.ApplicationWindow {
|
Kirigami.ApplicationWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
title: "Auracite"
|
|
||||||
|
|
||||||
readonly property Backend backend: Backend {}
|
readonly property Backend backend: Backend {}
|
||||||
|
|
||||||
pageStack.initialPage: Kirigami.Page {
|
property string lastArchiveFile
|
||||||
contentItem: ColumnLayout {
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
property Kirigami.Action openArchiveAction: Kirigami.Action {
|
||||||
|
text: i18nc("@action:button", "Open Archive")
|
||||||
|
icon.name: "document-open"
|
||||||
|
onTriggered: Qt.openUrlExternally("file://" + root.lastArchiveFile)
|
||||||
|
}
|
||||||
|
|
||||||
FormCard.FormCard {
|
pageStack {
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
defaultColumnWidth: root.width
|
||||||
|
|
||||||
maximumWidth: Kirigami.Units.gridUnit * 20
|
initialPage: Kirigami.Page {
|
||||||
|
globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
|
||||||
|
|
||||||
FormCard.FormTextFieldDelegate {
|
header: ColumnLayout {
|
||||||
id: characterNameField
|
Kirigami.Separator {
|
||||||
label: i18n("Character Name")
|
Layout.fillWidth: true
|
||||||
placeholderText: "Full name of the character"
|
|
||||||
focus: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {}
|
Kirigami.InlineMessage {
|
||||||
|
id: messageBanner
|
||||||
|
|
||||||
FormCard.FormCheckDelegate {
|
position: Kirigami.InlineMessage.Position.Header
|
||||||
id: dalamudCheckbox
|
actions: type === Kirigami.MessageType.Information ? [openArchiveAction] : []
|
||||||
text: i18n("Use Dalamud Plugin")
|
|
||||||
}
|
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {}
|
Layout.fillWidth: true
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
|
||||||
id: loginButton
|
|
||||||
text: i18nc("@action:button", "Archive")
|
|
||||||
onClicked: root.backend.archiveCharacter(characterNameField.text, dalamudCheckbox.checked)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormCard {
|
contentItem: ColumnLayout {
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
maximumWidth: Kirigami.Units.gridUnit * 20
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormCard {
|
||||||
id: aboutButton
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
text: i18nc("@action:button Application settings", "Settings")
|
|
||||||
icon.name: "settings-configure"
|
|
||||||
onClicked: applicationWindow().pageStack.layers.push(aboutPage)
|
|
||||||
|
|
||||||
Component {
|
maximumWidth: Kirigami.Units.gridUnit * 20
|
||||||
id: aboutPage
|
|
||||||
FormCard.AboutPage {}
|
FormCard.FormTextFieldDelegate {
|
||||||
|
id: characterNameField
|
||||||
|
label: i18n("Character Name")
|
||||||
|
placeholderText: "Full name of the character"
|
||||||
|
focus: true
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {}
|
||||||
|
|
||||||
|
FormCard.FormCheckDelegate {
|
||||||
|
id: dalamudCheckbox
|
||||||
|
text: i18n("Use Dalamud Plugin")
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {}
|
||||||
|
|
||||||
|
FormCard.FormButtonDelegate {
|
||||||
|
id: loginButton
|
||||||
|
text: i18nc("@action:button", "Archive")
|
||||||
|
enabled: characterNameField.text.length > 0
|
||||||
|
onClicked: {
|
||||||
|
fileDialog.selectedFile = characterNameField.text;
|
||||||
|
fileDialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormCard {
|
||||||
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
maximumWidth: Kirigami.Units.gridUnit * 20
|
||||||
|
|
||||||
|
FormCard.FormButtonDelegate {
|
||||||
|
id: aboutButton
|
||||||
|
text: i18nc("@action:button Application settings", "Settings")
|
||||||
|
icon.name: "settings-configure"
|
||||||
|
onClicked: applicationWindow().pageStack.push(Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutPage"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,11 +104,29 @@ Kirigami.ApplicationWindow {
|
||||||
target: backend
|
target: backend
|
||||||
|
|
||||||
function onArchiveSuccessful(): void {
|
function onArchiveSuccessful(): void {
|
||||||
console.info("Archive done!");
|
messageBanner.type = Kirigami.MessageType.Information;
|
||||||
|
messageBanner.text = i18n("Archive completed!");
|
||||||
|
messageBanner.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onArchiveFailed(message: string): void {
|
function onArchiveFailed(message: string): void {
|
||||||
console.error("Failed: " + message);
|
messageBanner.type = Kirigami.MessageType.Error;
|
||||||
|
messageBanner.text = message;
|
||||||
|
messageBanner.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: fileDialog
|
||||||
|
fileMode: FileDialog.SaveFile
|
||||||
|
nameFilters: ["ZIP files (*.zip)"]
|
||||||
|
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
|
||||||
|
onAccepted: {
|
||||||
|
let path = selectedFile.toString();
|
||||||
|
// Remove file://
|
||||||
|
path = path.replace(/^(file:\/{2})/,"");
|
||||||
|
root.backend.archiveCharacter(characterNameField.text, dalamudCheckbox.checked, path);
|
||||||
|
root.lastArchiveFile = path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@ pub mod bridge {
|
||||||
unsafe extern "RustQt" {
|
unsafe extern "RustQt" {
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
#[cxx_name = "archiveCharacter"]
|
#[cxx_name = "archiveCharacter"]
|
||||||
fn archive_character(self: Pin<&mut Backend>, character_name: &QString, use_dalamud: bool);
|
fn archive_character(self: Pin<&mut Backend>, character_name: &QString, use_dalamud: bool, filename: &QString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ pub struct BackendRust {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl bridge::Backend {
|
impl bridge::Backend {
|
||||||
pub fn archive_character(mut self: Pin<&mut Self>, character_name: &QString, use_dalamud: bool) {
|
pub fn archive_character(mut self: Pin<&mut Self>, character_name: &QString, use_dalamud: bool, filename: &QString) {
|
||||||
match archive_character_blocking(&character_name.to_string(), use_dalamud) {
|
match archive_character_blocking(&character_name.to_string(), use_dalamud, &filename.to_string()) {
|
||||||
Ok(_) => { self.archive_successful() }
|
Ok(_) => { self.archive_successful() }
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
match err {
|
match err {
|
||||||
|
|
|
@ -8,14 +8,14 @@ use auracite::{archive_character, ArchiveError};
|
||||||
|
|
||||||
pub mod bridge;
|
pub mod bridge;
|
||||||
|
|
||||||
fn archive_character_blocking(character_name: &String, use_dalamud: bool) -> Result<(), ArchiveError> {
|
fn archive_character_blocking(character_name: &String, use_dalamud: bool, filename: &String) -> Result<(), ArchiveError> {
|
||||||
let rt = tokio::runtime::Builder::new_current_thread()
|
let rt = tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
.map_err(|_| ArchiveError::UnknownError)?;
|
.map_err(|_| ArchiveError::UnknownError)?;
|
||||||
|
|
||||||
let inner = rt.block_on(archive_character(&character_name.to_string(), use_dalamud))?;
|
let inner = rt.block_on(archive_character(&character_name.to_string(), use_dalamud))?;
|
||||||
write("/home/josh/test.zip", inner)?;
|
write(filename, inner)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ fn main() {
|
||||||
|
|
||||||
println!("Downloading character data for {}...", character_name);
|
println!("Downloading character data for {}...", character_name);
|
||||||
|
|
||||||
archive_character_blocking(&character_name, command_line_parser.is_set(&QString::from("dalamud")));
|
archive_character_blocking(&character_name, command_line_parser.is_set(&QString::from("dalamud")), &format!("{}.zip", character_name));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue