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-06-15 21:43:43 -07:00
|
|
|
FM.DesktopSettings {
|
2021-03-29 01:51:34 -07:00
|
|
|
id: settings
|
|
|
|
}
|
|
|
|
|
2021-03-29 07:53:21 -07:00
|
|
|
GlobalSettings {
|
|
|
|
id: globalSettings
|
|
|
|
}
|
|
|
|
|
2021-03-29 01:51:34 -07:00
|
|
|
Loader {
|
|
|
|
id: backgroundLoader
|
|
|
|
anchors.fill: parent
|
|
|
|
sourceComponent: settings.backgroundType === 0 ? wallpaper : background
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: background
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: settings.backgroundColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: wallpaper
|
|
|
|
|
|
|
|
Image {
|
|
|
|
source: "file://" + settings.wallpaper
|
2021-04-12 22:56:09 -07:00
|
|
|
sourceSize: Qt.size(width * Screen.devicePixelRatio,
|
|
|
|
height * Screen.devicePixelRatio)
|
2021-03-29 01:51:34 -07:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
clip: true
|
|
|
|
cache: false
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
id: dimsWallpaper
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: "#000000"
|
2021-04-09 07:49:19 -07:00
|
|
|
opacity: FishUI.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0
|
2021-03-29 01:51:34 -07:00
|
|
|
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-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
|
|
|
|
minimumIconSize: globalSettings.minimumIconSize
|
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
|
|
|
|
anchors.topMargin: desktopView.screenAvailableRect.y
|
2021-03-30 23:01:22 -07:00
|
|
|
|
2021-06-01 22:25:04 -07:00
|
|
|
leftMargin: desktopView.screenAvailableRect.x
|
|
|
|
topMargin: 0
|
2021-03-29 01:51:34 -07:00
|
|
|
rightMargin: desktopView.screenRect.width - (desktopView.screenAvailableRect.x + desktopView.screenAvailableRect.width)
|
|
|
|
bottomMargin: desktopView.screenRect.height - (desktopView.screenAvailableRect.y + desktopView.screenAvailableRect.height)
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
onBackspace: {
|
|
|
|
dirModel.up()
|
|
|
|
}
|
|
|
|
onDeleteFile: {
|
|
|
|
dirModel.keyDeletePress()
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|