mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 15:47:26 +00:00

Instead, pass a reference to the root item when mapping the window, at which point we can downcast to the new Window item. If we have one, then we'll read its width/height (for initial values) and install bindings to keep them up-to-date.
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use structopt::StructOpt;
|
|
|
|
#[derive(StructOpt)]
|
|
struct Cli {
|
|
#[structopt(short = "I", name = "include path for other .60 files", number_of_values = 1)]
|
|
include_paths: Vec<std::path::PathBuf>,
|
|
|
|
#[structopt(name = "path to .60 file", parse(from_os_str))]
|
|
path: std::path::PathBuf,
|
|
|
|
/// The style name (empty, or 'qt')
|
|
#[structopt(long, name = "style name", default_value)]
|
|
style: String,
|
|
}
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
let args = Cli::from_args();
|
|
let source = std::fs::read_to_string(&args.path)?;
|
|
|
|
let mut include_paths = args.include_paths;
|
|
if args.style == "qt" {
|
|
// FIXME: that's not how it should work
|
|
include_paths.push(
|
|
[env!("CARGO_MANIFEST_DIR"), "..", "..", "sixtyfps_runtime", "qt_style"]
|
|
.iter()
|
|
.collect(),
|
|
);
|
|
}
|
|
|
|
let c = match sixtyfps_interpreter::load(source, &args.path, &include_paths) {
|
|
Ok(c) => c,
|
|
Err(diag) => {
|
|
diag.print();
|
|
std::process::exit(-1);
|
|
}
|
|
};
|
|
|
|
let component = c.create();
|
|
component.window().run(component.borrow(), component.root_item());
|
|
Ok(())
|
|
}
|