2021-03-29 01:51:34 -07:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
import Cutefish.FileManager 1.0
|
2021-04-09 07:49:19 -07:00
|
|
|
import FishUI 1.0 as FishUI
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
import "./Dialogs"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: folderPage
|
|
|
|
|
2021-04-05 00:21:39 -07:00
|
|
|
property alias currentUrl: dirModel.url
|
2021-03-29 01:51:34 -07:00
|
|
|
property Item currentView: _viewLoader.item
|
2021-04-14 19:26:54 -07:00
|
|
|
property int statusBarHeight: 22
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
signal requestPathEditor()
|
|
|
|
|
|
|
|
onCurrentUrlChanged: {
|
2021-04-04 13:06:24 -07:00
|
|
|
_viewLoader.item.reset()
|
2021-03-29 01:51:34 -07:00
|
|
|
_viewLoader.item.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: _background
|
|
|
|
anchors.fill: parent
|
2021-04-18 13:30:00 -07:00
|
|
|
anchors.rightMargin: FishUI.Units.smallSpacing * 1.5
|
|
|
|
anchors.bottomMargin: FishUI.Units.smallSpacing * 1.5
|
2021-04-09 07:49:19 -07:00
|
|
|
radius: FishUI.Theme.smallRadius
|
|
|
|
color: FishUI.Theme.backgroundColor
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: _fileTips
|
2021-04-04 13:06:24 -07:00
|
|
|
text: qsTr("Empty folder")
|
2021-04-14 19:26:54 -07:00
|
|
|
font.pointSize: 15
|
2021-03-29 01:51:34 -07:00
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
|
|
|
FolderModel {
|
2021-04-05 00:21:39 -07:00
|
|
|
id: dirModel
|
2021-03-29 01:51:34 -07:00
|
|
|
viewAdapter: viewAdapter
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2021-03-30 21:45:51 -07:00
|
|
|
if (arg)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.url = arg
|
2021-03-30 21:45:51 -07:00
|
|
|
else
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.url = dirModel.homePath()
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemViewAdapter {
|
|
|
|
id: viewAdapter
|
|
|
|
adapterView: _viewLoader.item
|
2021-04-05 00:21:39 -07:00
|
|
|
adapterModel: _viewLoader.item.positioner ? _viewLoader.item.positioner : dirModel
|
2021-03-29 01:51:34 -07:00
|
|
|
adapterIconSize: 40
|
|
|
|
adapterVisibleArea: Qt.rect(_viewLoader.item.contentX, _viewLoader.item.contentY,
|
|
|
|
_viewLoader.item.contentWidth, _viewLoader.item.contentHeight)
|
|
|
|
}
|
|
|
|
|
2021-04-09 07:49:19 -07:00
|
|
|
FishUI.DesktopMenu {
|
|
|
|
id: folderMenu
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Open")
|
|
|
|
onTriggered: dirModel.openSelected()
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Properties")
|
|
|
|
onTriggered: dirModel.openPropertiesDialog()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2021-04-09 07:49:19 -07:00
|
|
|
anchors.bottomMargin: FishUI.Theme.smallRadius
|
2021-03-29 01:51:34 -07:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: _viewLoader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
sourceComponent: switch (settings.viewMethod) {
|
|
|
|
case 0: return _listViewComponent
|
|
|
|
case 1: return _gridViewComponent
|
|
|
|
}
|
2021-04-04 13:06:24 -07:00
|
|
|
|
|
|
|
onSourceComponentChanged: {
|
|
|
|
// 焦点
|
|
|
|
_viewLoader.item.forceActiveFocus()
|
|
|
|
}
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
sourceComponent: _statusBar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 18:22:32 -07:00
|
|
|
function rename() {
|
|
|
|
_viewLoader.item.rename()
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.requestRename.connect(rename)
|
2021-03-30 18:22:32 -07:00
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
Component {
|
|
|
|
id: _statusBar
|
|
|
|
|
|
|
|
Item {
|
|
|
|
height: statusBarHeight
|
|
|
|
z: 999
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
2021-04-14 19:26:54 -07:00
|
|
|
anchors.leftMargin: FishUI.Units.smallSpacing
|
2021-04-09 07:49:19 -07:00
|
|
|
anchors.rightMargin: FishUI.Units.largeSpacing
|
2021-03-29 07:53:21 -07:00
|
|
|
anchors.bottomMargin: 1
|
2021-04-09 07:49:19 -07:00
|
|
|
spacing: FishUI.Units.largeSpacing
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2021-04-14 19:26:54 -07:00
|
|
|
font.pointSize: 10
|
|
|
|
text: dirModel.count === 1 ? qsTr("%1 item").arg(dirModel.count)
|
|
|
|
: qsTr("%1 items").arg(dirModel.count)
|
2021-04-01 01:05:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2021-04-14 19:26:54 -07:00
|
|
|
font.pointSize: 10
|
2021-04-05 00:21:39 -07:00
|
|
|
text: qsTr("%1 selected").arg(dirModel.selectionCound)
|
|
|
|
visible: dirModel.selectionCound >= 1
|
2021-04-01 01:05:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: qsTr("Empty Trash")
|
2021-04-14 19:26:54 -07:00
|
|
|
font.pointSize: 10
|
2021-04-05 00:21:39 -07:00
|
|
|
onClicked: dirModel.emptyTrash()
|
|
|
|
visible: dirModel.url === "trash:/"
|
2021-04-05 20:40:27 -07:00
|
|
|
focusPolicy: Qt.NoFocus
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: _gridViewComponent
|
|
|
|
|
|
|
|
FolderGridView {
|
|
|
|
id: _gridView
|
2021-04-05 00:21:39 -07:00
|
|
|
model: dirModel
|
2021-03-29 01:51:34 -07:00
|
|
|
delegate: FolderGridItem {}
|
|
|
|
|
2021-04-14 19:26:54 -07:00
|
|
|
leftMargin: FishUI.Units.smallSpacing
|
2021-04-09 07:49:19 -07:00
|
|
|
rightMargin: FishUI.Units.largeSpacing
|
2021-04-18 03:52:00 -07:00
|
|
|
topMargin: 0
|
2021-04-09 07:49:19 -07:00
|
|
|
bottomMargin: FishUI.Units.smallSpacing
|
2021-03-29 07:53:21 -07:00
|
|
|
|
2021-03-30 23:01:22 -07:00
|
|
|
onIconSizeChanged: {
|
|
|
|
// Save
|
|
|
|
settings.gridIconSize = _gridView.iconSize
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
onCountChanged: {
|
|
|
|
_fileTips.visible = count === 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: _listViewComponent
|
|
|
|
|
|
|
|
FolderListView {
|
|
|
|
id: _folderListView
|
2021-04-05 00:21:39 -07:00
|
|
|
model: dirModel
|
2021-03-29 01:51:34 -07:00
|
|
|
|
2021-04-12 19:46:20 -07:00
|
|
|
topMargin: FishUI.Units.smallSpacing
|
2021-04-09 07:49:19 -07:00
|
|
|
leftMargin: FishUI.Units.largeSpacing
|
|
|
|
rightMargin: FishUI.Units.largeSpacing + FishUI.Theme.smallRadius
|
|
|
|
spacing: FishUI.Units.largeSpacing
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
onCountChanged: {
|
|
|
|
_fileTips.visible = count === 0
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: FolderListItem {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: rubberBandObject
|
|
|
|
|
|
|
|
RubberBand {
|
|
|
|
id: rubberBand
|
|
|
|
|
|
|
|
width: 0
|
|
|
|
height: 0
|
|
|
|
z: 99999
|
2021-04-09 07:49:19 -07:00
|
|
|
color: FishUI.Theme.highlightColor
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
function close() {
|
|
|
|
opacityAnimation.restart()
|
|
|
|
}
|
|
|
|
|
|
|
|
OpacityAnimator {
|
|
|
|
id: opacityAnimation
|
|
|
|
target: rubberBand
|
|
|
|
to: 0
|
|
|
|
from: 1
|
|
|
|
duration: 150
|
|
|
|
|
|
|
|
easing {
|
|
|
|
bezierCurve: [0.4, 0.0, 1, 1]
|
|
|
|
type: Easing.Bezier
|
|
|
|
}
|
|
|
|
|
|
|
|
onFinished: {
|
|
|
|
rubberBand.visible = false
|
|
|
|
rubberBand.enabled = false
|
|
|
|
rubberBand.destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: _viewLoader.item
|
|
|
|
|
|
|
|
function onKeyPress(event) {
|
|
|
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.openSelected()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_C && event.modifiers & Qt.ControlModifier)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.copy()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_X && event.modifiers & Qt.ControlModifier)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.cut()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.paste()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_F2)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.requestRename()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_L && event.modifiers & Qt.ControlModifier)
|
|
|
|
folderPage.requestPathEditor()
|
|
|
|
else if (event.key === Qt.Key_A && event.modifiers & Qt.ControlModifier)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.selectAll()
|
2021-03-29 01:51:34 -07:00
|
|
|
else if (event.key === Qt.Key_Backspace)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.up()
|
2021-03-31 19:25:20 -07:00
|
|
|
else if (event.key === Qt.Key_Delete)
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.keyDeletePress()
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openUrl(url) {
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.url = url
|
2021-03-29 01:51:34 -07:00
|
|
|
_viewLoader.item.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
function goBack() {
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.goBack()
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function goForward() {
|
2021-04-05 00:21:39 -07:00
|
|
|
dirModel.goForward()
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
}
|