filemanager/qml/Desktop/main.qml

174 lines
4.7 KiB
QML
Raw Normal View History

2021-03-29 01:51:34 -07:00
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import Cutefish.FileManager 1.0
import MeuiKit 1.0 as Meui
import "../"
Item {
id: rootItem
DesktopSettings {
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
sourceSize: Qt.size(width, height)
fillMode: Image.PreserveAspectCrop
clip: true
cache: false
ColorOverlay {
id: dimsWallpaper
anchors.fill: parent
source: parent
color: "#000000"
opacity: Meui.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
}
}
}
2021-03-30 21:45:51 -07:00
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
}
ItemViewAdapter {
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-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
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
onIconSizeChanged: {
globalSettings.desktopIconSize = _folderView.iconSize
}
2021-03-29 01:51:34 -07:00
leftMargin: desktopView.screenAvailableRect ? desktopView.screenAvailableRect.x : 0
topMargin: desktopView.screenAvailableRect ? desktopView.screenAvailableRect.y : 0
rightMargin: desktopView.screenRect.width - (desktopView.screenAvailableRect.x + desktopView.screenAvailableRect.width)
bottomMargin: desktopView.screenRect.height - (desktopView.screenAvailableRect.y + desktopView.screenAvailableRect.height)
flow: GridView.FlowTopToBottom
2021-03-29 01:51:34 -07:00
delegate: FolderGridItem {}
onActiveFocusChanged: {
if (!activeFocus)
2021-04-05 00:24:52 -07:00
dirModel.clearSelection()
}
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-03-30 21:45:51 -07:00
Connections {
target: _folderView
function onKeyPress(event) {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)
2021-04-05 00:24:52 -07:00
dirModel.openSelected()
2021-03-30 21:45:51 -07:00
else if (event.key === Qt.Key_C && event.modifiers & Qt.ControlModifier)
2021-04-05 00:24:52 -07:00
dirModel.copy()
2021-03-30 21:45:51 -07:00
else if (event.key === Qt.Key_X && event.modifiers & Qt.ControlModifier)
2021-04-05 00:24:52 -07:00
dirModel.cut()
2021-03-30 21:45:51 -07:00
else if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier)
2021-04-05 00:24:52 -07:00
dirModel.paste()
2021-03-30 21:45:51 -07:00
else if (event.key === Qt.Key_F2)
2021-04-05 00:24:52 -07:00
dirModel.requestRename()
2021-03-30 21:45:51 -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:24:52 -07:00
dirModel.selectAll()
2021-03-30 21:45:51 -07:00
else if (event.key === Qt.Key_Backspace)
2021-04-05 00:24:52 -07:00
dirModel.up()
2021-03-30 21:45:51 -07:00
}
}
2021-03-29 01:51:34 -07:00
Component {
id: rubberBandObject
RubberBand {
id: rubberBand
width: 0
height: 0
z: 99999
color: Meui.Theme.highlightColor
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()
}
}
}
}
}