Fix: корень EditorPanel — ColumnLayout вместо Item (исправляет layout в SplitView: вкладки сверху, редактор снизу); убрана обёртка Item; color:text на TextArea; автооткрытие первого .md
This commit is contained in:
+36
-48
@@ -3,8 +3,9 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
// Центральная панель: панель вкладок + редактор.
|
// Центральная панель: панель вкладок + редактор.
|
||||||
// Поддержка двух панелей рядом («открыть рядом»): правая = вторая вкладка.
|
// Корень — ColumnLayout (без обёртки Item), чтобы SplitView корректно
|
||||||
Item {
|
// задавал размеры и вкладки были сверху, а редактор снизу.
|
||||||
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
function baseName(p) {
|
function baseName(p) {
|
||||||
@@ -12,11 +13,34 @@ Item {
|
|||||||
return idx >= 0 ? p.substring(idx + 1) : p
|
return idx >= 0 ? p.substring(idx + 1) : p
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
function activePane() {
|
||||||
anchors.fill: parent
|
if (secondaryPane.visible && secondaryPane.hasFocus)
|
||||||
spacing: 0
|
return secondaryPane
|
||||||
|
return primaryPane
|
||||||
|
}
|
||||||
|
|
||||||
// ----- Панель вкладок -----
|
function toolbarShouldShow() {
|
||||||
|
const p = primaryPane
|
||||||
|
const s = secondaryPane
|
||||||
|
return p.editMode
|
||||||
|
|| (s.visible && s.editMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: primaryPane
|
||||||
|
function onActiveFocusChanged() { formatToolbar.targetPane = root.activePane() }
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: secondaryPane
|
||||||
|
function onActiveFocusChanged() { formatToolbar.targetPane = root.activePane() }
|
||||||
|
}
|
||||||
|
|
||||||
|
TableEditor {
|
||||||
|
id: tableEditor
|
||||||
|
onMarkdownReady: (md) => root.activePane().insertText(md)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Панель вкладок ----------
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitHeight: 32
|
implicitHeight: 32
|
||||||
@@ -104,7 +128,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Панель форматирования (Фаза 5) -----
|
// ---------- Панель форматирования ----------
|
||||||
FormatToolbar {
|
FormatToolbar {
|
||||||
id: formatToolbar
|
id: formatToolbar
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@@ -116,7 +140,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Область редактора (одна или две панели) -----
|
// ---------- Область редактора (одна или две панели) ----------
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
@@ -154,58 +178,22 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ----- Функции активной панели и таблица -----
|
// ---------- Горячие клавиши ----------
|
||||||
function activePane() {
|
|
||||||
if (secondaryPane.visible && secondaryPane.hasFocus)
|
|
||||||
return secondaryPane
|
|
||||||
return primaryPane
|
|
||||||
}
|
|
||||||
function toolbarShouldShow() {
|
|
||||||
const p = primaryPane
|
|
||||||
const s = secondaryPane
|
|
||||||
return (p.hasFocus && p.editMode)
|
|
||||||
|| (s.visible && s.hasFocus && s.editMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: primaryPane
|
|
||||||
function onActiveFocusChanged() { formatToolbar.targetPane = root.activePane() }
|
|
||||||
}
|
|
||||||
Connections {
|
|
||||||
target: secondaryPane
|
|
||||||
function onActiveFocusChanged() { formatToolbar.targetPane = root.activePane() }
|
|
||||||
}
|
|
||||||
|
|
||||||
TableEditor {
|
|
||||||
id: tableEditor
|
|
||||||
onMarkdownReady: (md) => {
|
|
||||||
root.activePane().insertText(md)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----- Горячие клавиши -----
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+S"
|
sequence: "Ctrl+S"
|
||||||
context: Qt.WindowShortcut
|
context: Qt.WindowShortcut
|
||||||
onActivated: {
|
onActivated: documentManager.saveAll()
|
||||||
documentManager.saveAll()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+W"
|
sequence: "Ctrl+W"
|
||||||
context: Qt.WindowShortcut
|
context: Qt.WindowShortcut
|
||||||
onActivated: {
|
onActivated: documentManager.closeTab(documentManager.activeIndex)
|
||||||
documentManager.closeTab(documentManager.activeIndex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+E"
|
sequence: "Ctrl+E"
|
||||||
context: Qt.WindowShortcut
|
context: Qt.WindowShortcut
|
||||||
onActivated: {
|
onActivated: primaryPane.editMode = !primaryPane.editMode
|
||||||
primaryPane.editMode = !primaryPane.editMode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+Tab"
|
sequence: "Ctrl+Tab"
|
||||||
|
|||||||
Reference in New Issue
Block a user