1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-05-08 19:47:45 +00:00

Add an option to input the Lodestone ID instead on the desktop version

This commit is contained in:
Joshua Goins 2025-05-07 21:04:16 -04:00
parent 1bc72b69cb
commit 6f99f2974f
2 changed files with 79 additions and 14 deletions

View file

@ -59,28 +59,52 @@ Kirigami.ApplicationWindow {
maximumWidth: Kirigami.Units.gridUnit * 20 maximumWidth: Kirigami.Units.gridUnit * 20
FormCard.FormTextFieldDelegate { FormCard.FormRadioSelectorDelegate {
id: characterNameField consistentWidth: true
label: i18n("Character Name") actions: [
placeholderText: "Full name of the character" Kirigami.Action {
focus: true id: nameAction
text: i18nc("@option:radio", "Name")
},
Kirigami.Action {
id: idAction
text: i18nc("@option:radio", "ID")
}
]
} }
FormCard.FormDelegateSeparator {} FormCard.AbstractFormDelegate {
id: inputDelegate
contentItem: QQC2.TextField {
id: inputField
placeholderText: nameAction.checked ? i18nc("@info:placeholder", "Character name") : i18nc("@info:placeholder", "Lodestone ID")
focus: true
}
}
FormCard.FormDelegateSeparator {
above: inputDelegate
below: dalamudCheckbox
}
FormCard.FormCheckDelegate { FormCard.FormCheckDelegate {
id: dalamudCheckbox id: dalamudCheckbox
text: i18n("Use Dalamud Plugin") text: i18n("Connect to the Dalamud Plugin")
} }
FormCard.FormDelegateSeparator {} FormCard.FormDelegateSeparator {
above: dalamudCheckbox
below: loginButton
}
FormCard.FormButtonDelegate { FormCard.FormButtonDelegate {
id: loginButton id: loginButton
icon.name: "cloud-download-symbolic"
text: i18nc("@action:button", "Archive") text: i18nc("@action:button", "Archive")
enabled: characterNameField.text.length > 0 enabled: inputField.text.length > 0
onClicked: { onClicked: {
fileDialog.selectedFile = characterNameField.text; fileDialog.selectedFile = inputField.text;
fileDialog.open(); fileDialog.open();
} }
} }
@ -127,7 +151,11 @@ Kirigami.ApplicationWindow {
let path = selectedFile.toString(); let path = selectedFile.toString();
// Remove file:// // Remove file://
path = path.replace(/^(file:\/{2})/,""); path = path.replace(/^(file:\/{2})/,"");
root.backend.archiveCharacter(characterNameField.text, dalamudCheckbox.checked, path); if (nameAction.checked) {
root.backend.archiveCharacterByName(inputField.text, dalamudCheckbox.checked, path);
} else {
root.backend.archiveCharacterById(inputField.text, dalamudCheckbox.checked, path);
}
root.lastArchiveFile = path; root.lastArchiveFile = path;
} }
} }

View file

@ -21,13 +21,22 @@ pub mod bridge {
unsafe extern "RustQt" { unsafe extern "RustQt" {
#[qinvokable] #[qinvokable]
#[cxx_name = "archiveCharacter"] #[cxx_name = "archiveCharacterByName"]
fn archive_character( fn archive_character_by_name(
self: Pin<&mut Backend>, self: Pin<&mut Backend>,
character_name: &QString, character_name: &QString,
use_dalamud: bool, use_dalamud: bool,
filename: &QString, filename: &QString,
); );
#[qinvokable]
#[cxx_name = "archiveCharacterById"]
fn archive_character_by_id(
self: Pin<&mut Backend>,
character_id: &QString,
use_dalamud: bool,
filename: &QString,
);
} }
} }
@ -41,7 +50,7 @@ use std::pin::Pin;
pub struct BackendRust {} pub struct BackendRust {}
impl bridge::Backend { impl bridge::Backend {
pub fn archive_character( pub fn archive_character_by_name(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
character_name: &QString, character_name: &QString,
use_dalamud: bool, use_dalamud: bool,
@ -72,4 +81,32 @@ impl bridge::Backend {
} }
} }
} }
pub fn archive_character_by_id(
mut self: Pin<&mut Self>,
character_id: &QString,
use_dalamud: bool,
filename: &QString,
) {
let id = character_id.to_string().parse().unwrap();
match archive_character_blocking(id, use_dalamud, &filename.to_string()) {
Ok(_) => self.archive_successful(),
Err(err) => {
match err {
// TODO: Pass the URL up
ArchiveError::DownloadFailed(_) => {
self.archive_failed(&i18n("Download failed"))
}
ArchiveError::CharacterNotFound => {
self.archive_failed(&i18n("Character not found"))
}
ArchiveError::ParsingError => self.archive_failed(&i18n("Parsing error")),
ArchiveError::UnknownError => self.archive_failed(&i18n("Unknown error")),
ArchiveError::CouldNotConnectToDalamud => {
self.archive_failed(&i18n("Could not connect to Dalamud plugin"))
}
}
}
}
}
} }