Warning, /maui/nota/src/views/editor/EditorLayout.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.14 0002 import QtQuick.Controls 2.14 0003 0004 import org.mauikit.controls 1.3 as Maui 0005 import org.mauikit.filebrowsing 1.3 as FB 0006 0007 import org.maui.nota 1.0 as Nota 0008 0009 Item 0010 { 0011 id: control 0012 0013 Maui.TabViewInfo.tabTitle: title 0014 Maui.TabViewInfo.tabToolTipText: currentItem.fileUrl 0015 0016 property url path 0017 0018 property alias currentIndex : _splitView.currentIndex 0019 property alias orientation : _splitView.orientation 0020 0021 readonly property alias count : _splitView.count 0022 readonly property alias currentItem : _splitView.currentItem 0023 readonly property alias model : _splitView.contentModel 0024 readonly property string title : count === 2 ? model.get(0).title + " - " + model.get(1).title : currentItem.title 0025 0026 readonly property alias editor : _splitView.currentItem 0027 readonly property alias terminal : terminalLoader.item 0028 property bool terminalVisible : false 0029 0030 Keys.enabled: true 0031 Keys.onPressed: (event) => 0032 { 0033 if(event.key === Qt.Key_F3) 0034 { 0035 if(control.count === 2) 0036 { 0037 pop() 0038 return 0039 }//close the inactive split 0040 0041 split("") 0042 event.accepted = true 0043 } 0044 0045 if((event.key === Qt.Key_Space) && (event.modifiers & Qt.ControlModifier)) 0046 { 0047 tabView.findTab() 0048 event.accepted = true 0049 } 0050 0051 0052 if(event.key === Qt.Key_F4) 0053 { 0054 toggleTerminal() 0055 event.accepted = true 0056 } 0057 } 0058 0059 Maui.SplitView 0060 { 0061 anchors.fill: parent 0062 orientation: Qt.Vertical 0063 0064 Maui.SplitView 0065 { 0066 id: _splitView 0067 0068 SplitView.fillHeight: true 0069 SplitView.fillWidth: true 0070 0071 orientation : width >= 600 ? Qt.Horizontal : Qt.Vertical 0072 0073 onCurrentItemChanged: syncTerminal(control.editor.fileUrl) 0074 0075 Component.onCompleted: split(control.path) 0076 } 0077 0078 Loader 0079 { 0080 id: terminalLoader 0081 asynchronous: true 0082 active: Maui.Handy.isLinux 0083 visible: active && control.terminalVisible 0084 SplitView.fillWidth: true 0085 SplitView.preferredHeight: 200 0086 SplitView.maximumHeight: parent.height * 0.5 0087 SplitView.minimumHeight : 100 0088 source: "../Terminal.qml" 0089 } 0090 } 0091 0092 Component 0093 { 0094 id: _editorComponent 0095 Editor {} 0096 } 0097 0098 function syncTerminal(path) 0099 { 0100 if(control.terminal && appSettings.syncTerminal) 0101 control.terminal.session.changeDir(String(FB.FM.fileDir(path)).replace("file://", "")) 0102 } 0103 0104 function toggleTerminal() 0105 { 0106 control.terminalVisible = !control.terminalVisible 0107 0108 if(terminalVisible) 0109 { 0110 terminalLoader.item.forceActiveFocus() 0111 }else 0112 { 0113 control.forceActiveFocus() 0114 } 0115 } 0116 0117 function split(path) 0118 { 0119 if(_splitView.count === 1 && !settings.supportSplit) 0120 { 0121 return 0122 } 0123 0124 if(_splitView.count === 2) 0125 { 0126 return 0127 } 0128 0129 _splitView.addSplit(_editorComponent, {'fileUrl': path}) 0130 } 0131 0132 function pop() 0133 { 0134 if(_splitView.count === 1) 0135 { 0136 return //can not pop all the browsers, leave at leats 1 0137 } 0138 0139 closeSplit(_splitView.currentIndex === 1 ? 0 : 1) 0140 } 0141 0142 function closeSplit(index) //closes a split but triggering a warning before 0143 { 0144 if(index >= _splitView.count) 0145 { 0146 return 0147 } 0148 0149 const item = _splitView.itemAt(index) 0150 if( item.editor.document.modified) 0151 { 0152 _dialogLoader.sourceComponent = _unsavedDialogComponent 0153 dialog.callback = function () { destroyItem(index) } 0154 dialog.open() 0155 return 0156 } else 0157 { 0158 destroyItem(index) 0159 } 0160 } 0161 0162 function destroyItem(index) //deestroys a split view withouth warning 0163 { 0164 _splitView.closeSplit(index) 0165 } 0166 0167 function forceActiveFocus() 0168 { 0169 control.currentItem.forceActiveFocus() 0170 } 0171 } 0172 0173