Files
clide/qml/ClideProjectView.qml

113 lines
3.4 KiB
QML
Raw Normal View History

2026-01-31 08:02:16 -05:00
// SPDX-FileCopyrightText: 2026, Shaun Reed <shaunrd0@gmail.com>
//
// SPDX-License-Identifier: GNU General Public License v3.0 or later
2026-01-25 20:57:36 +00:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import clide.module 1.0
2026-02-01 20:20:39 -05:00
import Logger 1.0
2026-01-25 20:57:36 +00:00
SplitView {
id: root
2026-01-31 04:25:14 +00:00
// Path to the directory of the project opened in clide.
required property string projectDir
2026-01-25 20:57:36 +00:00
Layout.fillHeight: true
Layout.fillWidth: true
anchors.fill: parent
// Customized handle to drag between the Navigation and the Editor.
handle: Rectangle {
id: verticalSplitHandle
2026-02-02 18:08:37 -05:00
2026-01-25 20:57:36 +00:00
border.color: SplitHandle.pressed ? RustColors.pressed : SplitHandle.hovered ? RustColors.hovered : RustColors.gutter
color: SplitHandle.pressed ? RustColors.pressed : SplitHandle.hovered ? RustColors.hovered : RustColors.gutter
implicitWidth: 8
radius: 2.5
// Execute these behaviors when the color is changed.
Behavior on color {
ColorAnimation {
duration: 400
}
}
}
Rectangle {
id: navigationView
SplitView.fillHeight: true
2026-02-02 18:08:37 -05:00
SplitView.maximumWidth: 250
2026-01-25 20:57:36 +00:00
SplitView.minimumWidth: 0
SplitView.preferredWidth: 200
2026-02-02 18:08:37 -05:00
color: RustColors.explorer_background
2026-01-25 20:57:36 +00:00
2026-02-01 15:35:40 -05:00
ColumnLayout {
spacing: 2
2026-02-02 18:08:37 -05:00
// TODO: Make a ClideBreadCrumb element to support select parent paths as root
2026-02-01 15:35:40 -05:00
Rectangle {
color: RustColors.explorer_background
2026-02-02 18:08:37 -05:00
height: 25
width: navigationView.width
2026-02-01 15:35:40 -05:00
Text {
id: breadCrumb
2026-02-02 18:08:37 -05:00
anchors.fill: parent
color: RustColors.explorer_text
2026-02-01 15:35:40 -05:00
elide: Text.ElideLeft
horizontalAlignment: Text.AlignHCenter
2026-02-02 18:08:37 -05:00
text: clideTreeView.rootDirectory
verticalAlignment: Text.AlignVCenter
2026-02-01 15:35:40 -05:00
}
TapHandler {
acceptedButtons: Qt.RightButton
2026-02-02 18:08:37 -05:00
2026-02-01 20:20:39 -05:00
onSingleTapped: (eventPoint, button) => contextMenu.popup()
}
Menu {
id: contextMenu
2026-02-02 18:08:37 -05:00
Action {
text: qsTr("Reset root index")
2026-02-02 18:08:37 -05:00
onTriggered: {
2026-02-02 18:08:37 -05:00
Logger.log("Resetting root directory: " + clideTreeView.originalRootDirectory);
clideTreeView.rootDirectory = clideTreeView.originalRootDirectory;
}
}
}
2026-02-01 15:35:40 -05:00
}
2026-01-25 20:57:36 +00:00
ClideTreeView {
id: clideTreeView
2026-02-02 18:08:37 -05:00
2026-02-01 15:35:40 -05:00
height: navigationView.height
2026-01-31 04:25:14 +00:00
// Path to the directory opened in the file explorer.
originalRootDirectory: root.projectDir
2026-01-31 04:25:14 +00:00
rootDirectory: root.projectDir
2026-02-02 18:08:37 -05:00
width: navigationView.width
onFileClicked: path => clideEditor.filePath = path
onRootDirectoryChanged: {
2026-02-02 18:08:37 -05:00
Logger.log("Setting root directory: " + clideTreeView.rootDirectory);
breadCrumb.text = clideTreeView.rootDirectory;
}
2026-01-25 20:57:36 +00:00
}
}
}
2026-02-06 19:32:02 -05:00
ClideEditorView {
id: clideEditor
2026-02-02 18:08:37 -05:00
2026-01-25 20:57:36 +00:00
SplitView.fillWidth: true
2026-01-31 04:25:14 +00:00
// 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
2026-01-25 20:57:36 +00:00
}
}