Warning, /maui/strike/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 import QtQuick.Layouts 1.3
0004 
0005 import org.kde.kirigami 2.7 as Kirigami
0006 
0007 import org.mauikit.controls 1.3 as Maui
0008 
0009 Item
0010 {
0011     id: control
0012 
0013     height: ListView.view.height
0014     width: ListView.view.width
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     Maui.TabViewInfo.tabTitle: title
0027     Maui.TabViewInfo.tabToolTipText:  currentItem.fileUrl
0028 
0029     readonly property alias editor : _splitView.currentItem
0030 
0031     Keys.enabled: true
0032     Keys.onPressed:
0033     {
0034         if(event.key === Qt.Key_F3)
0035         {
0036             if(control.count === 2)
0037             {
0038                 pop()
0039                 return
0040             }//close the inactive split
0041 
0042             split("")
0043         }
0044 
0045         if((event.key === Qt.Key_Space) && (event.modifiers & Qt.ControlModifier))
0046         {
0047             console.log("KEYS PRESSED ON TABS LAYOUT OPEN TABS SEARCGH")
0048 
0049             tabView.findTab()
0050         }
0051 
0052 
0053 //        if(event.key === Qt.Key_F4)
0054 //        {
0055 //            terminalVisible = !terminalVisible
0056 //        }
0057     }
0058 
0059     Maui.SplitView
0060     {
0061         id: _splitView
0062 
0063         anchors.fill: parent
0064 
0065         orientation : width >= 600 ? Qt.Horizontal : Qt.Vertical
0066 
0067         onCurrentItemChanged: syncTerminal(control.editor.fileUrl)
0068 
0069         Component.onCompleted: split(control.path)
0070     }
0071 
0072 
0073     Component
0074     {
0075         id: _editorComponent
0076 
0077         Editor {}
0078     }
0079 
0080 
0081 
0082     function split(path)
0083     {
0084         if(_splitView.count === 1 && !settings.supportSplit)
0085         {
0086             return
0087         }
0088 
0089         if(_splitView.count === 2)
0090         {
0091             return
0092         }
0093 
0094         _splitView.addSplit(_editorComponent, {'fileUrl': path})
0095     }
0096 
0097     function pop()
0098     {
0099         if(_splitView.count === 1)
0100         {
0101             return //can not pop all the browsers, leave at leats 1
0102         }
0103 
0104         closeSplit(_splitView.currentIndex === 1 ? 0 : 1)
0105     }
0106 
0107     function closeSplit(index) //closes a split but triggering a warning before
0108     {
0109         if(index >= _splitView.count)
0110         {
0111             return
0112         }
0113 
0114         const item = _splitView.itemAt(index)
0115 
0116         console.log("supossed to close " , item.title, item.editor.document.modified)
0117         if(item.editor.document.modified)
0118         {
0119             _dialogLoader.sourceComponent = _unsavedDialogComponent
0120             dialog.callback = function () { destroyItem(index) }
0121             dialog.open()
0122             return
0123         } else
0124         {
0125             destroyItem(index)
0126         }
0127     }
0128 
0129     function destroyItem(index) //deestroys a split view withouth warning
0130     {
0131         _splitView.closeSplit(index)
0132     }
0133 }
0134 
0135