import QtQuick import QtQuick.Controls import QtQuick.Layouts // Центральная панель: панель вкладок + редактор. // Поддержка двух панелей рядом («открыть рядом»): правая = вторая вкладка. Item { id: root function baseName(p) { const idx = p.lastIndexOf("/") return idx >= 0 ? p.substring(idx + 1) : p } ColumnLayout { anchors.fill: parent spacing: 0 // ----- Панель вкладок ----- Rectangle { Layout.fillWidth: true implicitHeight: 32 color: "#ececec" RowLayout { anchors.fill: parent anchors.leftMargin: 4 anchors.rightMargin: 4 spacing: 2 Repeater { model: documentManager.openTabs Rectangle { id: tab required property string modelData readonly property bool active: index === documentManager.activeIndex width: Math.max(96, Math.min(200, tabLabel.implicitWidth + 44)) height: 26 radius: 4 color: active ? "white" : "#e0e0e0" RowLayout { anchors.fill: parent anchors.leftMargin: 8 anchors.rightMargin: 2 spacing: 4 Label { id: tabLabel Layout.fillWidth: true elide: Text.ElideMiddle text: root.baseName(modelData) + (documentManager.isDirty(index) ? " •" : "") font.pixelSize: 12 color: active ? "#111" : "#555" } ToolButton { text: "\u2715" implicitWidth: 20 implicitHeight: 20 font.pixelSize: 9 opacity: tab.active || hovered ? 1 : 0 onClicked: documentManager.closeTab(index) } } MouseArea { anchors.fill: parent onClicked: documentManager.setActiveIndex(index) onDoubleClicked: documentManager.closeTab(index) } } } Item { Layout.fillWidth: true } Label { visible: documentManager.openTabs.length === 0 text: qsTr("Откройте файл из дерева") color: "#999" font.pixelSize: 12 } ToolButton { id: splitBtn text: "\u25A1\u25A1" checkable: true checked: documentManager.sideBySide enabled: documentManager.openTabs.length > 0 ToolTip.visible: hovered ToolTip.text: qsTr("Открыть рядом (две панели)") onToggled: { if (checked) { documentManager.setSecondaryIndex(documentManager.activeIndex) documentManager.setSideBySide(true) } else { documentManager.setSideBySide(false) } } } } } // ----- Область редактора (одна или две панели) ----- RowLayout { Layout.fillWidth: true Layout.fillHeight: true spacing: 0 EditorPane { id: primaryPane Layout.fillWidth: true docIndex: documentManager.activeIndex canOpenBeside: true onOpenBeside: { documentManager.setSecondaryIndex(documentManager.activeIndex) documentManager.setSideBySide(true) splitBtn.checked = true } } Rectangle { visible: documentManager.sideBySide Layout.fillHeight: true width: 1 color: "#ccc" } EditorPane { id: secondaryPane visible: documentManager.sideBySide Layout.preferredWidth: 360 Layout.maximumWidth: 640 docIndex: documentManager.secondaryIndex closable: true onClosePane: { documentManager.setSideBySide(false) splitBtn.checked = false } } } } // ----- Горячие клавиши ----- 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: { const n = documentManager.openTabs.length if (n > 0) documentManager.setActiveIndex((documentManager.activeIndex + 1) % n) } } }