Warning, /maui/station/src/widgets/TerminalLayout.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 
0006 Maui.SplitView
0007 {
0008     id: control
0009 
0010     orientation: width >= 600 ? Qt.Horizontal : Qt.Vertical
0011 
0012     property string path : "$PWD"
0013 
0014     readonly property bool hasActiveProcess : count === 2 ?  contentModel.get(0).session.hasActiveProcess || contentModel.get(1).session.hasActiveProcess : currentItem.session.hasActiveProcess
0015     readonly property bool isCurrentTab : SwipeView.isCurrentItem
0016 
0017     readonly property string title : count === 2 ?  contentModel.get(0).title  + " - " + contentModel.get(1).title : currentItem.title
0018 
0019     Maui.TabViewInfo.tabTitle: title
0020     Maui.TabViewInfo.tabToolTipText: currentItem.session.currentDir
0021     Maui.TabViewInfo.tabColor: currentItem.tabColor
0022     Maui.TabViewInfo.tabIcon: control.hasActiveProcess ? "run-build" : ""
0023 
0024     onHasActiveProcessChanged:
0025     {
0026         if(!control.isCurrentTab && settings.alertProcess)
0027         {
0028             root.notify("dialog-warning", i18n("Process Finished"), i18n("Running task has finished for tab: %1", control.title), ()=>{_layout.setCurrentIndex(control.SwipeView.index)}, i18n("Check"))
0029         }
0030     }
0031 
0032     function forceActiveFocus()
0033     {
0034         control.currentItem.forceActiveFocus()
0035     }
0036 
0037     Component
0038     {
0039         id: _terminalComponent
0040 
0041         Terminal
0042         {
0043             watchForSlience: settings.watchForSilence
0044             onSilenceWarning:
0045             {
0046                 if(!control.isCurrentTab)
0047                 {
0048                     root.notify("dialog-warning", i18n("Pending Process"), i18n("Running process '%1' has been inactive for more than 30 seconds.", title), ()=>{_layout.setCurrentIndex(control.SwipeView.index)}, i18n("Check"))
0049                 }
0050             }
0051         }
0052     }
0053 
0054     Component.onCompleted: split()
0055 
0056     function split()
0057     {
0058         if(control.count === 2)
0059         {
0060             pop()
0061             return
0062         }//close the innactive split
0063 
0064         control.addSplit(_terminalComponent, {'path': control.path});
0065     }
0066 
0067     function pop()
0068     {
0069         var index = control.currentIndex === 1 ? 0 : 1
0070         if(control.contentModel.get(index).session.hasActiveProcess && settings.preventClosing)
0071         {
0072             _dialogLoader.sourceComponent = _confirmCloseDialogComponent
0073             dialog.index = index
0074             dialog.cb = control.closeSplit
0075             dialog.open()
0076         }else
0077         {
0078             control.closeSplit(index)
0079         }
0080     }
0081 
0082     function closeCurrentView()
0083     {
0084         control.closeSplit(control.currentIndex)
0085     }
0086 }