2026-01-31 04:25:14 +00:00
|
|
|
use crate::AppContext;
|
2026-01-25 20:57:36 +00:00
|
|
|
use anyhow::Result;
|
2026-01-31 04:25:14 +00:00
|
|
|
use cxx_qt_lib::{QMapPair, QMapPair_QString_QVariant, QString, QVariant};
|
2026-01-25 20:57:36 +00:00
|
|
|
use log::trace;
|
|
|
|
|
|
|
|
|
|
pub mod colors;
|
|
|
|
|
pub mod filesystem;
|
|
|
|
|
|
2026-01-31 04:25:14 +00:00
|
|
|
pub fn run(app_context: AppContext) -> Result<()> {
|
|
|
|
|
trace!(target:"gui::run()", "Starting the GUI editor at {:?}", app_context.path);
|
2026-01-25 20:57:36 +00:00
|
|
|
|
|
|
|
|
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};
|
|
|
|
|
|
|
|
|
|
let mut app = QGuiApplication::new();
|
|
|
|
|
let mut engine = QQmlApplicationEngine::new();
|
|
|
|
|
|
2026-01-31 04:25:14 +00:00
|
|
|
// Set QML property for the directory provided to the CLI.
|
|
|
|
|
let path = QString::from(app_context.path.to_string_lossy().to_string());
|
|
|
|
|
let mut map = QMapPair_QString_QVariant::default();
|
|
|
|
|
map.insert(QString::from("appContextPath"), QVariant::from(&path));
|
|
|
|
|
engine.as_mut().unwrap().set_initial_properties(&map);
|
|
|
|
|
|
2026-01-25 20:57:36 +00:00
|
|
|
if let Some(engine) = engine.as_mut() {
|
|
|
|
|
engine.add_import_path(&QString::from("qml/"));
|
|
|
|
|
}
|
|
|
|
|
if let Some(engine) = engine.as_mut() {
|
|
|
|
|
engine.load(&QUrl::from("qml/main.qml"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let Some(app) = app.as_mut() {
|
|
|
|
|
app.exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|