2021-05-24 04:01:26 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 CutefishOS Team.
|
|
|
|
*
|
|
|
|
* Author: revenmartin <revenmartin@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2021-04-12 22:56:09 -07:00
|
|
|
import QtQuick.Window 2.12
|
2021-03-29 01:51:34 -07:00
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
import Cutefish.FileManager 1.0 as FM
|
2021-04-09 07:49:19 -07:00
|
|
|
import FishUI 1.0 as FishUI
|
2021-03-29 01:51:34 -07:00
|
|
|
import "../"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: rootItem
|
|
|
|
|
2021-09-10 23:41:22 -07:00
|
|
|
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
|
|
|
LayoutMirroring.childrenInherit: true
|
|
|
|
|
2021-03-29 07:53:21 -07:00
|
|
|
GlobalSettings {
|
|
|
|
id: globalSettings
|
|
|
|
}
|
|
|
|
|
2021-09-05 14:39:56 -07:00
|
|
|
Wallpaper {
|
2021-03-29 01:51:34 -07:00
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
FM.FolderModel {
|
2021-04-05 00:24:52 -07:00
|
|
|
id: dirModel
|
2021-03-30 21:45:51 -07:00
|
|
|
url: desktopPath()
|
|
|
|
isDesktop: true
|
2021-11-05 14:04:37 -07:00
|
|
|
sortMode: -1
|
2021-04-04 13:06:24 -07:00
|
|
|
viewAdapter: viewAdapter
|
|
|
|
}
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
FM.ItemViewAdapter {
|
2021-04-04 13:06:24 -07:00
|
|
|
id: viewAdapter
|
|
|
|
adapterView: _folderView
|
2021-04-05 00:24:52 -07:00
|
|
|
adapterModel: dirModel
|
2021-04-04 13:06:24 -07:00
|
|
|
adapterIconSize: 40
|
|
|
|
adapterVisibleArea: Qt.rect(_folderView.contentX, _folderView.contentY,
|
|
|
|
_folderView.contentWidth, _folderView.contentHeight)
|
2021-03-30 21:45:51 -07:00
|
|
|
}
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: _folderView.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
FolderGridView {
|
2021-03-30 21:45:51 -07:00
|
|
|
id: _folderView
|
2021-03-29 01:51:34 -07:00
|
|
|
anchors.fill: parent
|
2021-03-30 09:20:52 -07:00
|
|
|
|
|
|
|
isDesktopView: true
|
|
|
|
iconSize: globalSettings.desktopIconSize
|
2021-03-30 23:01:22 -07:00
|
|
|
maximumIconSize: globalSettings.maximumIconSize
|
2021-09-15 00:46:38 -07:00
|
|
|
minimumIconSize: 22
|
2021-03-30 21:54:58 -07:00
|
|
|
focus: true
|
2021-04-05 00:24:52 -07:00
|
|
|
model: dirModel
|
2021-03-29 01:51:34 -07:00
|
|
|
|
2021-04-05 20:40:27 -07:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
|
2021-06-01 22:25:04 -07:00
|
|
|
// Handle for topbar
|
2021-09-07 20:55:28 -07:00
|
|
|
topMargin: 28
|
2021-03-30 23:01:22 -07:00
|
|
|
|
2021-09-07 20:55:28 -07:00
|
|
|
// From dock
|
2021-09-26 21:24:42 -07:00
|
|
|
leftMargin: Dock.leftMargin
|
|
|
|
rightMargin: Dock.rightMargin
|
|
|
|
bottomMargin: Dock.bottomMargin
|
2021-03-29 01:51:34 -07:00
|
|
|
|
2021-03-30 05:44:50 -07:00
|
|
|
flow: GridView.FlowTopToBottom
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
delegate: FolderGridItem {}
|
2021-03-30 23:01:22 -07:00
|
|
|
|
2021-06-01 22:25:04 -07:00
|
|
|
onIconSizeChanged: {
|
|
|
|
globalSettings.desktopIconSize = _folderView.iconSize
|
|
|
|
}
|
|
|
|
|
2021-03-30 23:01:22 -07:00
|
|
|
onActiveFocusChanged: {
|
2021-05-05 07:27:33 -07:00
|
|
|
if (!activeFocus) {
|
|
|
|
_folderView.cancelRename()
|
2021-04-05 00:24:52 -07:00
|
|
|
dirModel.clearSelection()
|
2021-05-05 07:27:33 -07:00
|
|
|
}
|
2021-03-30 23:01:22 -07:00
|
|
|
}
|
2021-04-04 13:06:24 -07:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2021-04-05 00:24:52 -07:00
|
|
|
dirModel.requestRename.connect(rename)
|
2021-04-04 13:06:24 -07:00
|
|
|
}
|
2021-03-29 01:51:34 -07:00
|
|
|
}
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
FM.ShortCut {
|
|
|
|
id: shortCut
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
shortCut.install(_folderView)
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpen: {
|
|
|
|
dirModel.openSelected()
|
|
|
|
}
|
|
|
|
onCopy: {
|
|
|
|
dirModel.copy()
|
|
|
|
}
|
|
|
|
onCut: {
|
|
|
|
dirModel.cut()
|
|
|
|
}
|
|
|
|
onPaste: {
|
|
|
|
dirModel.paste()
|
|
|
|
}
|
|
|
|
onRename: {
|
|
|
|
dirModel.requestRename()
|
|
|
|
}
|
|
|
|
onOpenPathEditor: {
|
|
|
|
folderPage.requestPathEditor()
|
|
|
|
}
|
|
|
|
onSelectAll: {
|
|
|
|
dirModel.selectAll()
|
|
|
|
}
|
|
|
|
onDeleteFile: {
|
|
|
|
dirModel.keyDeletePress()
|
2021-03-30 21:45:51 -07:00
|
|
|
}
|
2021-09-27 21:00:19 -07:00
|
|
|
onKeyPressed: {
|
|
|
|
dirModel.keyboardSearch(text)
|
|
|
|
}
|
2021-10-22 07:25:16 -07:00
|
|
|
onShowHidden: {
|
|
|
|
dirModel.showHiddenFiles = !dirModel.showHiddenFiles
|
|
|
|
}
|
2021-12-26 01:14:45 -08:00
|
|
|
onUndo: {
|
|
|
|
dirModel.undo()
|
|
|
|
}
|
2021-03-30 21:45:51 -07:00
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
Component {
|
|
|
|
id: rubberBandObject
|
|
|
|
|
2021-06-15 21:43:43 -07:00
|
|
|
FM.RubberBand {
|
2021-03-29 01:51:34 -07:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|