diff --git a/src/widgets/views/Browser.qml b/src/widgets/views/Browser.qml index 954a3c5..cdc65ab 100644 --- a/src/widgets/views/Browser.qml +++ b/src/widgets/views/Browser.qml @@ -1,211 +1,227 @@ import QtQuick 2.9 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.8 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQml.Models 2.3 SplitView { id: control readonly property int _index : ObjectModel.index property alias browser : _browser property alias currentPath: _browser.currentPath property alias settings : _browser.settings property alias title : _browser.title // property bool terminalVisible : Maui.FM.loadSettings("TERMINAL", "EXTENSIONS", false) == "true" property bool terminalVisible : false readonly property bool supportsTerminal : terminalLoader.item spacing: 0 orientation: Qt.Vertical SplitView.fillHeight: true SplitView.fillWidth: true SplitView.preferredWidth: _splitView.width / (_splitView.count) SplitView.minimumWidth: _splitView.count > 1 ? 300 : 0 opacity: _splitView.currentIndex === _index ? 1 : 0.7 onCurrentPathChanged: { syncTerminal(currentBrowser.currentPath) } handle: Rectangle { - implicitWidth: 10 - implicitHeight: 10 + implicitWidth: 6 + implicitHeight: 6 color: SplitHandle.pressed ? Kirigami.Theme.highlightColor : (SplitHandle.hovered ? Qt.lighter(Kirigami.Theme.backgroundColor, 1.1) : Kirigami.Theme.backgroundColor) + Rectangle + { + anchors.centerIn: parent + width: 48 + height: parent.height + color: _splitSeparator.color + } + Kirigami.Separator { + id: _splitSeparator anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: parent.left } + + Kirigami.Separator + { + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + } } Maui.FileBrowser { id: _browser SplitView.fillWidth: true SplitView.fillHeight: true selectionBar: root.selectionBar previewer: root.previewer shareDialog: root.shareDialog openWithDialog: root.openWithDialog tagsDialog: root.tagsDialog thumbnailsSize: root.iconSize * 1.7 selectionMode: root.selectionMode onSelectionModeChanged: { root.selectionMode = selectionMode selectionMode = Qt.binding(function() { return root.selectionMode }) } // rebind this property in case filebrowser breaks it showStatusBar: root.showStatusBar settings.showHiddenFiles: root.showHiddenFiles settings.showThumbnails: root.showThumbnails Rectangle { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right height: 2 opacity: 1 color: Kirigami.Theme.highlightColor visible: _splitView.currentIndex === _index && _splitView.count === 2 } itemMenu.contentData : [ MenuSeparator {visible: _browser.itemMenu.isDir}, MenuItem { visible: _browser.itemMenu.isDir text: qsTr("Open in new tab") icon.name: "tab-new" onTriggered: root.openTab(_browser.itemMenu.item.path) }, MenuItem { visible: _browser.itemMenu.isDir && root.currentTab.count === 1 && root.supportSplit text: qsTr("Open in split view") icon.name: "view-split-left-right" onTriggered: root.currentTab.split(_browser.itemMenu.item.path, Qt.Horizontal) } ] MouseArea { anchors.fill: parent propagateComposedEvents: true // hoverEnabled: true // onEntered: _splitView.currentIndex = control.index onPressed: { _splitView.currentIndex = control._index mouse.accepted = false } } onKeyPress: { if((event.key == Qt.Key_T) && (event.modifiers & Qt.ControlModifier)) { openTab(control.currentPath) } // Shortcut for closing tab if((event.key == Qt.Key_W) && (event.modifiers & Qt.ControlModifier)) { if(tabsBar.count > 1) closeTab(tabsBar.currentIndex) } if(event.key === Qt.Key_F4) { toogleTerminal() } if(event.key === Qt.Key_F3) { toogleSplitView() } if((event.key === Qt.Key_K) && (event.modifiers & Qt.ControlModifier)) { _pathBar.showEntryBar() } } onItemClicked: { if(root.singleClick) openItem(index) } onItemDoubleClicked: { if(!root.singleClick) { openItem(index) return; } if(Kirigami.Settings.isMobile) return const item = currentFMList.get(index) if(item.mime === "inode/directory") control.openFolder(item.path) else control.openFile(item.path) } } Loader { id: terminalLoader active: inx.supportsEmbededTerminal() visible: active && terminalVisible SplitView.fillWidth: true SplitView.preferredHeight: 200 SplitView.maximumHeight: parent.height * 0.5 SplitView.minimumHeight : 100 source: "Terminal.qml" Behavior on Layout.preferredHeight { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InQuad } } onVisibleChanged: syncTerminal(control.currentPath) } Component.onCompleted: syncTerminal(control.currentPath) function syncTerminal(path) { if(terminalLoader.item && terminalVisible) terminalLoader.item.session.sendText("cd '" + String(path).replace("file://", "") + "'\n") } function toogleTerminal() { terminalVisible = !terminalVisible // Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS") } } diff --git a/src/widgets/views/BrowserLayout.qml b/src/widgets/views/BrowserLayout.qml index fc66fc7..07f8d0e 100644 --- a/src/widgets/views/BrowserLayout.qml +++ b/src/widgets/views/BrowserLayout.qml @@ -1,96 +1,112 @@ import QtQuick 2.9 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQml.Models 2.3 Item { id: control height: _browserList.height width: _browserList.width property url path property alias currentIndex : _splitView.currentIndex property alias count : _splitView.count readonly property alias currentItem : _splitView.currentItem readonly property alias model : splitObjectModel readonly property string title : count === 2 ? model.get(0).browser.title + " - " + model.get(1).browser.title : browser.title readonly property Maui.FileBrowser browser : currentItem.browser ObjectModel { id: splitObjectModel } SplitView { id: _splitView anchors.fill: parent orientation: Qt.Horizontal clip: true focus: true handle: Rectangle { - implicitWidth: 4 - implicitHeight: 4 + implicitWidth: 6 + implicitHeight: 6 color: SplitHandle.pressed ? Kirigami.Theme.highlightColor : (SplitHandle.hovered ? Qt.lighter(Kirigami.Theme.backgroundColor, 1.1) : Kirigami.Theme.backgroundColor) + Rectangle + { + anchors.centerIn: parent + height: 48 + width: parent.width + color: _splitSeparator.color + } + Kirigami.Separator { + id: _splitSeparator anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left } + + Kirigami.Separator + { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + } } onCurrentItemChanged: { currentItem.forceActiveFocus() } Component.onCompleted: split(control.path, Qt.Vertical) } function split(path, orientation) { _splitView.orientation = orientation if(_splitView.count === 1 && !root.supportSplit) { return } if(_splitView.count === 2) { return } const component = Qt.createComponent("qrc:/widgets/views/Browser.qml"); if (component.status === Component.Ready) { const object = component.createObject(splitObjectModel, {'browser.currentPath': path, 'browser.settings.viewType': _viewTypeGroup.currentIndex}); splitObjectModel.append(object) _splitView.insertItem(splitObjectModel.count, object) // duplicating object insertion due to bug on android not picking the repeater _splitView.currentIndex = splitObjectModel.count - 1 } } function pop() { if(_splitView.count === 1) { return //can not pop all the browsers, leave at leats 1 } const index = _splitView.currentIndex === 1 ? 0 : 1 splitObjectModel.remove(index) _splitView.takeItem(index) _splitView.currentIndex = 0 } }