1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-04-24 05:37:44 +00:00
auracite/src/bin/ui/bridge.rs
Joshua Goins 06b8afad24 Add Qt UI and add a separate CLI target
The Qt UI is basic for now, to be expanded upon later - but it does
work!
2024-10-31 18:18:06 -04:00

39 lines
No EOL
987 B
Rust

#[cxx_qt::bridge]
pub mod bridge {
unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
}
unsafe extern "RustQt" {
#[qobject]
#[qml_element]
type Backend = super::BackendRust;
}
unsafe extern "RustQt" {
#[qinvokable]
#[cxx_name = "archiveCharacter"]
fn archive_character(self: &Backend, character_name: &QString, use_dalamud: bool);
}
}
use std::fs::write;
use cxx_qt_lib::QString;
use auracite::archive_character;
#[derive(Default)]
pub struct BackendRust {
}
impl bridge::Backend {
pub fn archive_character(&self, character_name: &QString, use_dalamud: bool) {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let inner = rt.block_on(archive_character(&character_name.to_string(), use_dalamud));
write("/home/josh/test.zip", inner);
}
}