diff --git a/qml/panels/EditorPane.qml b/qml/panels/EditorPane.qml index f68849d..30061da 100644 --- a/qml/panels/EditorPane.qml +++ b/qml/panels/EditorPane.qml @@ -17,57 +17,41 @@ Item { textDisplay.insert(textDisplay.cursorPosition, t) } - // Шапка файла — плавающий оверлей - Rectangle { - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: 30 - z: 10 - color: "#f0f0f0" - border.color: "#ddd" - - RowLayout { - anchors.fill: parent - anchors.leftMargin: 8 - anchors.rightMargin: 4 - spacing: 6 - - Label { - Layout.fillWidth: true - elide: Text.ElideMiddle - color: "#444" - text: documentManager.titleAt(pane.docIndex) - } - - ToolButton { - text: "✎" - checkable: true - checked: pane.editMode - onClicked: pane.editMode = true - } - ToolButton { - text: "👁" - checkable: true - checked: !pane.editMode - onClicked: pane.editMode = false - } - ToolButton { - text: "\u2715" - visible: pane.closable - onClicked: pane.closePane() - } + function refresh() { + const idx = pane.docIndex + if (idx >= 0) { + const c = documentManager.contentAt(idx) + textDisplay.text = c + } else { + textDisplay.text = "" } } - // Текст файла — TextEdit напрямую + function filePathDir(p) { + const i = p.lastIndexOf("/") + return i >= 0 ? p.substring(0, i) : p + } + + onDocIndexChanged: refresh() + onEditModeChanged: refresh() + + Connections { + target: documentManager + function onActiveIndexChanged() { + if (documentManager.activeIndex === pane.docIndex) + refresh() + } + } + + Component.onCompleted: refresh() + + // --- Текстовый редактор (сверху до низу, без шапки) --- TextEdit { id: textDisplay - anchors.top: headerBar.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + anchors.fill: parent + anchors.bottomMargin: 32 visible: pane.editMode + clip: true text: documentManager.activeIndex >= 0 ? documentManager.contentAt(documentManager.activeIndex) : "" @@ -79,15 +63,14 @@ Item { onTextEdited: documentManager.updateContent(pane.docIndex, text) } - // Режим просмотра (read-only) + // --- Режим просмотра --- TextEdit { id: viewDisplay - anchors.top: headerBar.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + anchors.fill: parent + anchors.bottomMargin: 32 visible: !pane.editMode readOnly: true + clip: true text: pane.editMode ? "" : mdParser.render( documentManager.contentAt(pane.docIndex), fileStore.vault, @@ -117,32 +100,41 @@ Item { } } - // Загрузка контента при смене файла - function refresh() { - const idx = pane.docIndex - if (idx >= 0) { - const c = documentManager.contentAt(idx) - textDisplay.text = c - } else { - textDisplay.text = "" + // --- Серая панель ВНИЗУ: кнопки ✎👁 × --- + Rectangle { + id: toolbar + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: 32 + z: 10 + color: "#e0e0e0" + border.color: "#ccc" + + RowLayout { + anchors.fill: parent + anchors.rightMargin: 4 + spacing: 4 + + Item { Layout.fillWidth: true } + + ToolButton { + text: "✎" + checkable: true + checked: pane.editMode + onClicked: pane.editMode = true + } + ToolButton { + text: "👁" + checkable: true + checked: !pane.editMode + onClicked: pane.editMode = false + } + ToolButton { + text: "\u2715" + visible: pane.closable + onClicked: pane.closePane() + } } } - - function filePathDir(p) { - const i = p.lastIndexOf("/") - return i >= 0 ? p.substring(0, i) : p - } - - onDocIndexChanged: refresh() - onEditModeChanged: { refresh() } - - Connections { - target: documentManager - function onActiveIndexChanged() { - if (documentManager.activeIndex === pane.docIndex) - refresh() - } - } - - Component.onCompleted: refresh() }