Fix: EditorPanel переписан на anchors (tabBar → formatToolbar → editorArea) вместо ColumnLayout — SplitView теперь корректно задаёт высоту; вкладки сверху, тулбар под ними, редактор заполняет остаток
This commit is contained in:
+34
-75
@@ -2,10 +2,9 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
// Центральная панель: панель вкладок + редактор.
|
||||
// Корень — ColumnLayout (без обёртки Item), чтобы SplitView корректно
|
||||
// задавал размеры и вкладки были сверху, а редактор снизу.
|
||||
ColumnLayout {
|
||||
// Центральная панель: вкладки сверху, тулбар, редактор заполняет остаток.
|
||||
// Используем anchors вместо ColumnLayout — SplitView корректно работает с anchors.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
function baseName(p) {
|
||||
@@ -19,31 +18,13 @@ ColumnLayout {
|
||||
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 {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 32
|
||||
id: tabBar
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 32
|
||||
color: "#ececec"
|
||||
|
||||
RowLayout {
|
||||
@@ -54,8 +35,7 @@ ColumnLayout {
|
||||
|
||||
Repeater {
|
||||
model: documentManager.openTabs
|
||||
|
||||
Rectangle {
|
||||
delegate: Rectangle {
|
||||
id: tab
|
||||
required property string modelData
|
||||
required property int index
|
||||
@@ -70,13 +50,11 @@ ColumnLayout {
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 2
|
||||
spacing: 4
|
||||
|
||||
MouseArea {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
onClicked: documentManager.setActiveIndex(index)
|
||||
onDoubleClicked: documentManager.closeTab(index)
|
||||
|
||||
Label {
|
||||
id: tabLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -86,7 +64,6 @@ ColumnLayout {
|
||||
color: tab.active ? "#111" : "#555"
|
||||
}
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
text: "\u2715"
|
||||
implicitWidth: 20
|
||||
@@ -109,14 +86,12 @@ ColumnLayout {
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
id: splitBtn
|
||||
text: "\u25A1\u25A1"
|
||||
checkable: true
|
||||
checked: documentManager.sideBySide
|
||||
enabled: documentManager.openTabs.length > 0
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Открыть рядом (две панели)")
|
||||
onToggled: {
|
||||
ToolTip.text: qsTr("Открыть рядом")
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
documentManager.setSecondaryIndex(documentManager.activeIndex)
|
||||
documentManager.setSideBySide(true)
|
||||
@@ -128,22 +103,25 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Панель форматирования ----------
|
||||
// ---------- Формат-тулбар (под вкладками) ----------
|
||||
FormatToolbar {
|
||||
id: formatToolbar
|
||||
Layout.fillWidth: true
|
||||
visible: documentManager.activeIndex >= 0 && toolbarShouldShow()
|
||||
anchors.top: tabBar.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 34
|
||||
visible: documentManager.activeIndex >= 0
|
||||
targetPane: activePane()
|
||||
onTableRequested: {
|
||||
tableEditor.resetDialog()
|
||||
tableEditor.open()
|
||||
}
|
||||
onTableRequested: { tableEditor.resetDialog(); tableEditor.open() }
|
||||
}
|
||||
|
||||
// ---------- Область редактора (одна или две панели) ----------
|
||||
// ---------- Редактор (заполняет остаток) ----------
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
id: editorArea
|
||||
anchors.top: formatToolbar.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
spacing: 0
|
||||
|
||||
EditorPane {
|
||||
@@ -154,7 +132,6 @@ ColumnLayout {
|
||||
onOpenBeside: {
|
||||
documentManager.setSecondaryIndex(documentManager.activeIndex)
|
||||
documentManager.setSideBySide(true)
|
||||
splitBtn.checked = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,36 +149,18 @@ ColumnLayout {
|
||||
Layout.maximumWidth: 640
|
||||
docIndex: documentManager.secondaryIndex
|
||||
closable: true
|
||||
onClosePane: {
|
||||
documentManager.setSideBySide(false)
|
||||
splitBtn.checked = false
|
||||
}
|
||||
onClosePane: documentManager.setSideBySide(false)
|
||||
}
|
||||
}
|
||||
|
||||
TableEditor { id: tableEditor; onMarkdownReady: (md) => activePane().insertText(md) }
|
||||
|
||||
// ---------- Горячие клавиши ----------
|
||||
Shortcut {
|
||||
sequence: "Ctrl+S"
|
||||
context: Qt.WindowShortcut
|
||||
onActivated: documentManager.saveAll()
|
||||
}
|
||||
Shortcut {
|
||||
sequence: "Ctrl+W"
|
||||
context: Qt.WindowShortcut
|
||||
onActivated: documentManager.closeTab(documentManager.activeIndex)
|
||||
}
|
||||
Shortcut {
|
||||
sequence: "Ctrl+E"
|
||||
context: Qt.WindowShortcut
|
||||
onActivated: primaryPane.editMode = !primaryPane.editMode
|
||||
}
|
||||
Shortcut {
|
||||
sequence: "Ctrl+Tab"
|
||||
context: Qt.WindowShortcut
|
||||
onActivated: {
|
||||
Shortcut { sequence: "Ctrl+S"; onActivated: documentManager.saveAll() }
|
||||
Shortcut { sequence: "Ctrl+W"; onActivated: documentManager.closeTab(documentManager.activeIndex) }
|
||||
Shortcut { sequence: "Ctrl+E"; onActivated: primaryPane.editMode = !primaryPane.editMode }
|
||||
Shortcut { sequence: "Ctrl+Tab"; onActivated: {
|
||||
const n = documentManager.openTabs.length
|
||||
if (n > 0)
|
||||
documentManager.setActiveIndex((documentManager.activeIndex + 1) % n)
|
||||
}
|
||||
}
|
||||
if (n > 0) documentManager.setActiveIndex((documentManager.activeIndex + 1) % n)
|
||||
}}
|
||||
}
|
||||
Reference in New Issue
Block a user