Warning, /maui/booth/src/widgets/views/Browser.qml is written in an unsupported language. File is not indexed.
0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com>
0002 // Copyright 2018-2020 Nitrux Latinoamericana S.C.
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-or-later
0005
0006
0007 import QtQuick 2.14
0008 import QtQuick.Controls 2.13
0009 import QtQuick.Layouts 1.3
0010 import org.kde.kirigami 2.8 as Kirigami
0011 import org.kde.mauikit 1.0 as Maui
0012 import QtQml.Models 2.3
0013
0014 SplitView
0015 {
0016 id: control
0017
0018 readonly property int _index : ObjectModel.index
0019 property alias browser : _browser
0020 property alias currentPath: _browser.currentPath
0021 property alias settings : _browser.settings
0022 property alias title : _browser.title
0023
0024 // property bool terminalVisible : Maui.FM.loadSettings("TERMINAL", "EXTENSIONS", false) == "true"
0025 property bool terminalVisible : false
0026 readonly property bool supportsTerminal : terminalLoader.item
0027
0028 spacing: 0
0029 orientation: Qt.Vertical
0030 SplitView.fillHeight: true
0031 SplitView.fillWidth: true
0032
0033 SplitView.preferredHeight: _splitView.orientation === Qt.Vertical ? _splitView.height / (_splitView.count) : _splitView.height
0034 SplitView.minimumHeight: _splitView.orientation === Qt.Vertical ? 200 : 0
0035
0036 SplitView.preferredWidth: _splitView.orientation === Qt.Horizontal ? _splitView.width / (_splitView.count) : _splitView.width
0037 SplitView.minimumWidth: _splitView.orientation === Qt.Horizontal ? 300 : 0
0038
0039 opacity: _splitView.currentIndex === _index ? 1 : 0.7
0040
0041 onCurrentPathChanged:
0042 {
0043 syncTerminal(currentBrowser.currentPath)
0044 }
0045
0046 handle: Rectangle
0047 {
0048 implicitWidth: 6
0049 implicitHeight: 6
0050 color: SplitHandle.pressed ? Kirigami.Theme.highlightColor
0051 : (SplitHandle.hovered ? Qt.lighter(Kirigami.Theme.backgroundColor, 1.1) : Kirigami.Theme.backgroundColor)
0052
0053 Rectangle
0054 {
0055 anchors.centerIn: parent
0056 width: 48
0057 height: parent.height
0058 color: _splitSeparator.color
0059 }
0060
0061 Kirigami.Separator
0062 {
0063 id: _splitSeparator
0064 anchors.bottom: parent.bottom
0065 anchors.right: parent.right
0066 anchors.left: parent.left
0067 }
0068
0069 Kirigami.Separator
0070 {
0071 anchors.top: parent.top
0072 anchors.right: parent.right
0073 anchors.left: parent.left
0074 }
0075 }
0076
0077 Maui.FileBrowser
0078 {
0079 id: _browser
0080 SplitView.fillWidth: true
0081 SplitView.fillHeight: true
0082
0083 selectionBar: root.selectionBar
0084 previewer: root.previewer
0085 shareDialog: root.shareDialog
0086 openWithDialog: root.openWithDialog
0087 tagsDialog: root.tagsDialog
0088 thumbnailsSize: root.iconSize * 1.7
0089 selectionMode: root.selectionMode
0090 onSelectionModeChanged:
0091 {
0092 root.selectionMode = selectionMode
0093 selectionMode = Qt.binding(function() { return root.selectionMode })
0094 } // rebind this property in case filebrowser breaks it
0095
0096 settings.showHiddenFiles: root.showHiddenFiles
0097 settings.showThumbnails: root.showThumbnails
0098
0099 Rectangle
0100 {
0101 anchors.bottom: parent.bottom
0102 anchors.left: parent.left
0103 anchors.right: parent.right
0104 height: 2
0105 opacity: 1
0106 color: Kirigami.Theme.highlightColor
0107 visible: _splitView.currentIndex === _index && _splitView.count === 2
0108 }
0109
0110 itemMenu.contentData : [
0111
0112 MenuSeparator {visible: _browser.itemMenu.isDir},
0113
0114 MenuItem
0115 {
0116 visible: _browser.itemMenu.isDir
0117 text: i18n("Open in new tab")
0118 icon.name: "tab-new"
0119 onTriggered: root.openTab(_browser.itemMenu.item.path)
0120 },
0121
0122 MenuItem
0123 {
0124 visible: _browser.itemMenu.isDir && root.currentTab.count === 1 && root.supportSplit
0125 text: i18n("Open in split view")
0126 icon.name: "view-split-left-right"
0127 onTriggered: root.currentTab.split(_browser.itemMenu.item.path, Qt.Horizontal)
0128 }
0129 ]
0130
0131 Connections
0132 {
0133 target: _browser.dropArea
0134 ignoreUnknownSignals: true
0135 function onEntered()
0136 {
0137 _splitView.currentIndex = control._index
0138 }
0139 }
0140
0141 MouseArea
0142 {
0143 anchors.fill: parent
0144 propagateComposedEvents: true
0145 // hoverEnabled: true
0146 // onEntered: _splitView.currentIndex = control.index
0147 onPressed:
0148 {
0149 _splitView.currentIndex = control._index
0150 mouse.accepted = false
0151 }
0152 }
0153
0154 onKeyPress:
0155 {
0156 if((event.key == Qt.Key_T) && (event.modifiers & Qt.ControlModifier))
0157 {
0158 openTab(control.currentPath)
0159 }
0160
0161 // Shortcut for closing tab
0162 if((event.key == Qt.Key_W) && (event.modifiers & Qt.ControlModifier))
0163 {
0164 if(tabsBar.count > 1)
0165 closeTab(tabsBar.currentIndex)
0166 }
0167
0168 if(event.key === Qt.Key_F4)
0169 {
0170 toogleTerminal()
0171 }
0172
0173 if(event.key === Qt.Key_F3)
0174 {
0175 toogleSplitView()
0176 }
0177
0178 if((event.key === Qt.Key_N) && (event.modifiers & Qt.ControlModifier))
0179 {
0180 newFolder()
0181 }
0182
0183 if((event.key === Qt.Key_N) && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier))
0184 {
0185 newFile()
0186 }
0187 }
0188
0189 onItemClicked:
0190 {
0191 if(root.singleClick)
0192 openItem(index)
0193 }
0194
0195 onItemDoubleClicked:
0196 {
0197 if(!root.singleClick)
0198 {
0199 openItem(index)
0200 return;
0201 }
0202
0203 if(Kirigami.Settings.isMobile)
0204 return
0205
0206 const item = currentFMList.get(index)
0207 if(item.mime === "inode/directory")
0208 control.openFolder(item.path)
0209 else
0210 control.openFile(item.path)
0211 }
0212 }
0213
0214 Loader
0215 {
0216 id: terminalLoader
0217 active: inx.supportsEmbededTerminal()
0218 visible: active && terminalVisible
0219 SplitView.fillWidth: true
0220 SplitView.preferredHeight: 200
0221 SplitView.maximumHeight: parent.height * 0.5
0222 SplitView.minimumHeight : 100
0223 source: "Terminal.qml"
0224
0225 Behavior on Layout.preferredHeight
0226 {
0227 NumberAnimation
0228 {
0229 duration: Kirigami.Units.longDuration
0230 easing.type: Easing.InQuad
0231 }
0232 }
0233
0234 onVisibleChanged: syncTerminal(control.currentPath)
0235 }
0236
0237 Component.onCompleted: syncTerminal(control.currentPath)
0238 Component.onDestruction: console.log("Destroyed browsers!!!!!!!!")
0239
0240 function syncTerminal(path)
0241 {
0242 if(terminalLoader.item && terminalVisible)
0243 terminalLoader.item.session.sendText("cd '" + String(path).replace("file://", "") + "'\n")
0244 }
0245
0246 function toogleTerminal()
0247 {
0248 terminalVisible = !terminalVisible
0249 // Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS")
0250 }
0251 }