TUI #1

Merged
shaunrd0 merged 73 commits from ui into master 2026-01-25 20:57:37 +00:00
5 changed files with 30 additions and 27 deletions
Showing only changes of commit fd3c8fb204 - Show all commits

View File

@ -13,7 +13,7 @@ fn main() {
.qt_module("Xml") .qt_module("Xml")
.qml_module(QmlModule { .qml_module(QmlModule {
uri: "clide.module", uri: "clide.module",
rust_files: &["src/colors.rs", "src/filesystem.rs"], rust_files: &["src/gui/colors.rs", "src/gui/filesystem.rs"],
qml_files: &[ qml_files: &[
"qml/main.qml", "qml/main.qml",
"qml/ClideAboutWindow.qml", "qml/ClideAboutWindow.qml",

27
src/gui.rs Normal file
View 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(())
}

View File

@ -1,34 +1,10 @@
// TODO: Header // TODO: Header
use cxx_qt_lib::QString;
use std::error::Error; use std::error::Error;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use structopt::StructOpt; use structopt::StructOpt;
pub mod colors; pub mod gui;
pub mod filesystem;
fn run_gui(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(())
}
fn run_tui(root_path: std::path::PathBuf) -> Result<(), Box<dyn Error>> { fn run_tui(root_path: std::path::PathBuf) -> Result<(), Box<dyn Error>> {
println!("Starting the TUI editor at {:?}", root_path); println!("Starting the TUI editor at {:?}", root_path);
@ -67,7 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
}; };
match args.gui { match args.gui {
true => run_gui(root_path), true => gui::run(root_path),
false => match args.tui { false => match args.tui {
// Open the TUI editor if requested, otherwise use the QML GUI by default. // Open the TUI editor if requested, otherwise use the QML GUI by default.
true => run_tui(root_path), true => run_tui(root_path),