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:
parent
1bc72b69cb
commit
6f99f2974f
2 changed files with 79 additions and 14 deletions
|
@ -59,28 +59,52 @@ Kirigami.ApplicationWindow {
|
|||
|
||||
maximumWidth: Kirigami.Units.gridUnit * 20
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: characterNameField
|
||||
label: i18n("Character Name")
|
||||
placeholderText: "Full name of the character"
|
||||
focus: true
|
||||
FormCard.FormRadioSelectorDelegate {
|
||||
consistentWidth: true
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
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 {
|
||||
id: dalamudCheckbox
|
||||
text: i18n("Use Dalamud Plugin")
|
||||
text: i18n("Connect to the Dalamud Plugin")
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {}
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: dalamudCheckbox
|
||||
below: loginButton
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: loginButton
|
||||
icon.name: "cloud-download-symbolic"
|
||||
text: i18nc("@action:button", "Archive")
|
||||
enabled: characterNameField.text.length > 0
|
||||
enabled: inputField.text.length > 0
|
||||
onClicked: {
|
||||
fileDialog.selectedFile = characterNameField.text;
|
||||
fileDialog.selectedFile = inputField.text;
|
||||
fileDialog.open();
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +151,11 @@ Kirigami.ApplicationWindow {
|
|||
let path = selectedFile.toString();
|
||||
// Remove file://
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,22 @@ pub mod bridge {
|
|||
|
||||
unsafe extern "RustQt" {
|
||||
#[qinvokable]
|
||||
#[cxx_name = "archiveCharacter"]
|
||||
fn archive_character(
|
||||
#[cxx_name = "archiveCharacterByName"]
|
||||
fn archive_character_by_name(
|
||||
self: Pin<&mut Backend>,
|
||||
character_name: &QString,
|
||||
use_dalamud: bool,
|
||||
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 {}
|
||||
|
||||
impl bridge::Backend {
|
||||
pub fn archive_character(
|
||||
pub fn archive_character_by_name(
|
||||
mut self: Pin<&mut Self>,
|
||||
character_name: &QString,
|
||||
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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue