Factor out GUI code.
This commit is contained in:
27
src/gui.rs
Normal file
27
src/gui.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use cxx_qt_lib::QString;
|
||||
use std::error::Error;
|
||||
|
||||
pub mod colors;
|
||||
pub mod filesystem;
|
||||
|
||||
pub fn run(root_path: std::path::PathBuf) -> Result<(), Box<dyn Error>> {
|
||||
println!("Starting the GUI editor at {:?}", root_path);
|
||||
|
||||
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};
|
||||
|
||||
let mut app = QGuiApplication::new();
|
||||
let mut engine = QQmlApplicationEngine::new();
|
||||
|
||||
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(())
|
||||
}
|
||||
Reference in New Issue
Block a user