diff --git a/qml/ClideAboutWindow.qml b/qml/ClideAboutWindow.qml index 2922764..1b7c8a8 100644 --- a/qml/ClideAboutWindow.qml +++ b/qml/ClideAboutWindow.qml @@ -58,7 +58,7 @@ ApplicationWindow { + "
Project notes knoats.com
" + "This project is developed at git.shaunreed.com
" + "" - + "Copyright (C) 2025 Shaun Reed, all rights reserved.
") + + "Copyright (C) 2026 Shaun Reed, all rights reserved.
") color: RustColors.editor_text wrapMode: Text.WordWrap readOnly: true diff --git a/qml/ClideEditor.qml b/qml/ClideEditor.qml index b16d9b5..512b470 100644 --- a/qml/ClideEditor.qml +++ b/qml/ClideEditor.qml @@ -13,7 +13,7 @@ SplitView { // The path to the file to show in the text editor. // This is updated by a signal caught within ClideProjectView. // Initialized by the Default trait for the Rust QML singleton FileSystem. - required property string filePath; + required property string filePath // Customized handle to drag between the Editor and the Console. handle: Rectangle { diff --git a/qml/ClideProjectView.qml b/qml/ClideProjectView.qml index 1f97333..05d55ef 100644 --- a/qml/ClideProjectView.qml +++ b/qml/ClideProjectView.qml @@ -7,8 +7,8 @@ import clide.module 1.0 SplitView { id: root - // Path to the file selected in the tree view. - default property string selectedFilePath: FileSystem.filePath; + // Path to the directory of the project opened in clide. + required property string projectDir Layout.fillHeight: true Layout.fillWidth: true @@ -43,13 +43,18 @@ SplitView { anchors.fill: parent ClideTreeView { id: clideTreeView - onFileClicked: path => root.selectedFilePath = path + onFileClicked: path => root.projectDir = path + + // Path to the directory opened in the file explorer. + rootDirectory: root.projectDir } } } ClideEditor { SplitView.fillWidth: true - // Initialize using the Default trait in Rust QML singleton FileSystem. - filePath: root.selectedFilePath + + // Provide a path to the file currently open in the text editor. + // Initialized using the Default trait in Rust QML singleton FileSystem. + filePath: FileSystem.filePath } } diff --git a/qml/ClideTreeView.qml b/qml/ClideTreeView.qml index fa4b483..76ea446 100644 --- a/qml/ClideTreeView.qml +++ b/qml/ClideTreeView.qml @@ -8,13 +8,14 @@ Rectangle { id: root color: RustColors.explorer_background + required property string rootDirectory + signal fileClicked(string filePath) TreeView { id: fileSystemTreeView anchors.margins: 15 - // rootIndex: FileSystem.rootIndex property int lastIndex: -1 model: FileSystem @@ -24,8 +25,8 @@ Rectangle { clip: true Component.onCompleted: { - FileSystem.setDirectory(FileSystem.filePath) - fileSystemTreeView.expandRecursively(0, 4) + FileSystem.setDirectory(root.rootDirectory) + fileSystemTreeView.expandRecursively(0, -1) } // The delegate represents a single entry in the filesystem. @@ -42,9 +43,7 @@ Rectangle { indicator: Image { id: directoryIcon - x: treeDelegate.leftMargin + (treeDelegate.depth * treeDelegate.indentation) - anchors.verticalCenter: parent.verticalCenter - source: { + function setSourceImage() { let folderOpen = "data:image/svg+xml;utf8,"; let folderClosed = "data:image/svg+xml;utf8,"; let file = "data:image/svg+xml;utf8,"; @@ -56,6 +55,10 @@ Rectangle { return file } } + + x: treeDelegate.leftMargin + (treeDelegate.depth * treeDelegate.indentation) + anchors.verticalCenter: parent.verticalCenter + source: setSourceImage() sourceSize.width: 15 sourceSize.height: 15 fillMode: Image.PreserveAspectFit diff --git a/qml/main.qml b/qml/main.qml index cba1e07..fdbbf11 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -13,6 +13,8 @@ ApplicationWindow { visible: true width: 1200 + required property string appContextPath + menuBar: ClideMenuBar { } @@ -27,6 +29,7 @@ ApplicationWindow { title: qsTr("Error") } ClideProjectView { + projectDir: appWindow.appContextPath } } diff --git a/src/gui.rs b/src/gui.rs index f843292..add9993 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,6 +1,6 @@ use crate::AppContext; use anyhow::Result; -use cxx_qt_lib::QString; +use cxx_qt_lib::{QMapPair, QMapPair_QString_QVariant, QString, QVariant}; use log::trace; pub mod colors; @@ -14,6 +14,12 @@ pub fn run(app_context: AppContext) -> Result<()> { let mut app = QGuiApplication::new(); let mut engine = QQmlApplicationEngine::new(); + // 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); + if let Some(engine) = engine.as_mut() { engine.add_import_path(&QString::from("qml/")); }