2023-02-09 09:17:37 +01:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2023-01-04 08:52:22 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
import QtQuick
|
2024-12-05 23:50:23 +02:00
|
|
|
import QtQuick.Templates as T
|
2022-11-23 11:49:45 +02:00
|
|
|
import StudioTheme as StudioTheme
|
2024-11-12 14:03:37 +02:00
|
|
|
import StudioControls as StudioControls
|
2023-03-07 16:51:02 +01:00
|
|
|
import AssetsLibraryBackend
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2024-12-05 23:50:23 +02:00
|
|
|
T.TreeViewDelegate {
|
2022-11-23 11:49:45 +02:00
|
|
|
id: root
|
|
|
|
|
2023-06-16 17:30:39 +02:00
|
|
|
property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle
|
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
required property Item assetsView
|
|
|
|
required property Item assetsRoot
|
|
|
|
|
2023-03-07 16:51:02 +01:00
|
|
|
property var assetsModel: AssetsLibraryBackend.assetsModel
|
|
|
|
property var rootView: AssetsLibraryBackend.rootView
|
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
property bool hasChildWithDropHover: false
|
2022-12-01 22:05:55 +02:00
|
|
|
property bool isHighlighted: false
|
2024-12-03 22:49:51 +02:00
|
|
|
property bool isDelegateEmpty: false
|
2022-11-23 11:49:45 +02:00
|
|
|
readonly property string suffix: model.fileName.substr(-4)
|
|
|
|
readonly property bool isFont: root.suffix === ".ttf" || root.suffix === ".otf"
|
|
|
|
readonly property bool isEffect: root.suffix === ".qep"
|
|
|
|
property bool currFileSelected: false
|
|
|
|
property int initialDepth: -1
|
2022-11-23 15:47:34 +02:00
|
|
|
property bool __isDirectory: assetsModel.isDirectory(model.filePath)
|
|
|
|
property int __currentRow: model.index
|
|
|
|
property string __itemPath: model.filePath
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
readonly property int __fileItemHeight: thumbnailImage.height + 2 * StudioTheme.Values.border
|
2022-11-23 15:47:34 +02:00
|
|
|
readonly property int __dirItemHeight: 21
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
implicitHeight: root.__isDirectory ? root.__dirItemHeight : root.__fileItemHeight
|
2023-11-08 18:29:54 +01:00
|
|
|
implicitWidth: root.assetsView.width
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
// the depth of the root path will become available before we get to the actual
|
|
|
|
// items we display, so it's safe to set assetsView.rootPathDepth here. All other
|
|
|
|
// tree items (below the root) will have the indentation (basically, depth) adjusted.
|
|
|
|
if (model.filePath === assetsModel.rootPath()) {
|
|
|
|
root.assetsView.rootPathDepth = root.depth
|
2022-11-23 15:47:34 +02:00
|
|
|
root.assetsView.rootPathRow = root.__currentRow
|
2022-11-23 11:49:45 +02:00
|
|
|
} else if (model.filePath.includes(assetsModel.rootPath())) {
|
|
|
|
root.depth -= root.assetsView.rootPathDepth
|
|
|
|
root.initialDepth = root.depth
|
|
|
|
}
|
2024-10-09 14:02:12 +03:00
|
|
|
|
|
|
|
// expand/collapse folder based on its stored expanded state
|
|
|
|
if (root.__isDirectory) {
|
|
|
|
// if the folder expand state is not stored yet, stores it as true (expanded)
|
|
|
|
root.assetsModel.initializeExpandState(root.__itemPath)
|
|
|
|
|
|
|
|
let expandState = assetsModel.folderExpandState(root.__itemPath)
|
|
|
|
|
|
|
|
if (expandState)
|
|
|
|
root.assetsView.expand(root.__currentRow)
|
|
|
|
else
|
|
|
|
root.assetsView.collapse(root.__currentRow)
|
2024-12-03 22:49:51 +02:00
|
|
|
|
|
|
|
root.isDelegateEmpty = assetsModel.isDelegateEmpty(root.__itemPath)
|
2024-10-09 14:02:12 +03:00
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// workaround for a bug -- might be fixed by https://codereview.qt-project.org/c/qt/qtdeclarative/+/442721
|
|
|
|
onYChanged: {
|
2022-11-23 15:47:34 +02:00
|
|
|
if (root.__currentRow === root.assetsView.firstRow) {
|
2022-11-23 11:49:45 +02:00
|
|
|
if (root.y > root.assetsView.contentY) {
|
|
|
|
let item = root.assetsView.itemAtCell(0, root.assetsView.rootPathRow)
|
|
|
|
if (!item)
|
|
|
|
root.assetsView.contentY = root.y
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onDepthChanged: {
|
|
|
|
if (root.depth > root.initialDepth && root.initialDepth >= 0)
|
|
|
|
root.depth = root.initialDepth
|
|
|
|
}
|
|
|
|
|
2023-06-16 17:30:39 +02:00
|
|
|
indicator: Item {
|
2024-12-05 23:50:23 +02:00
|
|
|
id: arrowIndicator
|
|
|
|
|
|
|
|
implicitWidth: 10
|
2023-06-16 17:30:39 +02:00
|
|
|
implicitHeight: root.implicitHeight
|
|
|
|
anchors.left: bg.left
|
2024-12-05 23:50:23 +02:00
|
|
|
anchors.leftMargin: 5
|
2023-06-16 17:30:39 +02:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: arrow
|
2024-12-03 22:49:51 +02:00
|
|
|
|
2023-06-16 17:30:39 +02:00
|
|
|
width: 8
|
|
|
|
height: 4
|
2024-12-03 22:49:51 +02:00
|
|
|
visible: !root.isDelegateEmpty
|
2023-06-16 17:30:39 +02:00
|
|
|
source: "image://icons/down-arrow"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
rotation: root.expanded ? 0 : -90
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
background: Rectangle {
|
|
|
|
id: bg
|
|
|
|
|
2023-11-08 18:29:54 +01:00
|
|
|
x: root.indentation * (root.depth - 1)
|
2023-02-09 09:17:37 +01:00
|
|
|
width: root.implicitWidth - bg.x
|
2022-12-19 20:21:43 +02:00
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
color: {
|
2022-12-01 22:05:55 +02:00
|
|
|
if (root.__isDirectory && (root.isHighlighted || root.hasChildWithDropHover))
|
2022-11-23 11:49:45 +02:00
|
|
|
return StudioTheme.Values.themeInteraction
|
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
if (!root.__isDirectory && root.assetsView.selectedAssets[root.__itemPath])
|
2023-02-09 09:17:37 +01:00
|
|
|
return StudioTheme.Values.themeSectionHeadBackground
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
if (mouseArea.containsMouse)
|
|
|
|
return StudioTheme.Values.themeSectionHeadBackground
|
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
return root.__isDirectory
|
2022-11-23 11:49:45 +02:00
|
|
|
? StudioTheme.Values.themeSectionHeadBackground
|
|
|
|
: "transparent"
|
|
|
|
}
|
2023-02-09 09:17:37 +01:00
|
|
|
border.width: StudioTheme.Values.border
|
2024-08-29 22:27:13 +03:00
|
|
|
border.color: root.assetsView.selectedAssets[root.__itemPath] ? StudioTheme.Values.themeInteraction
|
|
|
|
: "transparent"
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Text {
|
|
|
|
id: assetLabel
|
2024-12-05 23:50:23 +02:00
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
text: assetLabel.__computeText()
|
2022-11-23 11:49:45 +02:00
|
|
|
color: StudioTheme.Values.themeTextColor
|
2023-06-16 17:30:39 +02:00
|
|
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
2022-11-23 11:49:45 +02:00
|
|
|
verticalAlignment: Qt.AlignVCenter
|
2024-12-05 23:50:23 +02:00
|
|
|
anchors.left: root.__isDirectory ? arrowIndicator.right : thumbnailImage.right
|
|
|
|
anchors.leftMargin: 8
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function __computeText() {
|
2022-11-23 15:47:34 +02:00
|
|
|
return root.__isDirectory
|
2024-12-03 22:49:51 +02:00
|
|
|
? (root.isDelegateEmpty
|
|
|
|
? model.display.toUpperCase() + qsTr(" (empty)")
|
|
|
|
: model.display.toUpperCase())
|
2022-11-23 11:49:45 +02:00
|
|
|
: model.display
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
property bool allowTooltip: true
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
2023-03-07 16:51:02 +01:00
|
|
|
onExited: AssetsLibraryBackend.tooltipBackend.hideTooltip()
|
2022-11-23 11:49:45 +02:00
|
|
|
onEntered: mouseArea.allowTooltip = true
|
|
|
|
|
|
|
|
onCanceled: {
|
2023-03-07 16:51:02 +01:00
|
|
|
AssetsLibraryBackend.tooltipBackend.hideTooltip()
|
2022-11-23 11:49:45 +02:00
|
|
|
mouseArea.allowTooltip = true
|
|
|
|
}
|
|
|
|
|
2023-08-25 16:53:39 +02:00
|
|
|
onPositionChanged: AssetsLibraryBackend.tooltipBackend.reposition()
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
onPressed: (mouse) => {
|
2023-02-09 09:17:37 +01:00
|
|
|
mouseArea.forceActiveFocus()
|
2022-11-23 11:49:45 +02:00
|
|
|
mouseArea.allowTooltip = false
|
2023-03-07 16:51:02 +01:00
|
|
|
AssetsLibraryBackend.tooltipBackend.hideTooltip()
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
var ctrlDown = mouse.modifiers & Qt.ControlModifier
|
2024-08-29 22:27:13 +03:00
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
if (mouse.button === Qt.LeftButton) {
|
2024-08-29 22:27:13 +03:00
|
|
|
if (root.__isDirectory) {
|
|
|
|
// ensure only one directory can be selected
|
|
|
|
root.assetsView.clearSelectedAssets()
|
|
|
|
root.currFileSelected = true
|
|
|
|
} else {
|
|
|
|
if (!root.assetsView.isAssetSelected(root.__itemPath) && !ctrlDown)
|
|
|
|
root.assetsView.clearSelectedAssets()
|
|
|
|
root.currFileSelected = ctrlDown ? !root.assetsView.isAssetSelected(root.__itemPath) : true
|
|
|
|
}
|
|
|
|
|
|
|
|
root.assetsView.setAssetSelected(root.__itemPath, root.currFileSelected)
|
|
|
|
|
|
|
|
if (root.currFileSelected) {
|
|
|
|
let selectedPaths = root.assetsView.selectedPathsAsList()
|
|
|
|
AssetsLibraryBackend.rootView.startDragAsset(selectedPaths, mapToGlobal(mouse.x, mouse.y))
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!root.assetsView.isAssetSelected(root.__itemPath) && !ctrlDown)
|
|
|
|
root.assetsView.clearSelectedAssets()
|
|
|
|
root.currFileSelected = root.assetsView.isAssetSelected(root.__itemPath) || !ctrlDown
|
|
|
|
root.assetsView.setAssetSelected(root.__itemPath, root.currFileSelected)
|
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onReleased: (mouse) => {
|
|
|
|
mouseArea.allowTooltip = true
|
|
|
|
|
2023-02-02 21:03:17 +02:00
|
|
|
if (root.__isDirectory)
|
|
|
|
return
|
|
|
|
|
2022-11-23 11:49:45 +02:00
|
|
|
if (mouse.button === Qt.LeftButton) {
|
|
|
|
if (!(mouse.modifiers & Qt.ControlModifier))
|
|
|
|
root.assetsView.selectedAssets = {}
|
2022-11-23 15:47:34 +02:00
|
|
|
root.assetsView.selectedAssets[root.__itemPath] = root.currFileSelected
|
2022-11-23 11:49:45 +02:00
|
|
|
root.assetsView.selectedAssetsChanged()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onDoubleClicked: (mouse) => {
|
2023-02-09 09:17:37 +01:00
|
|
|
mouseArea.forceActiveFocus()
|
|
|
|
mouseArea.allowTooltip = false
|
2023-03-07 16:51:02 +01:00
|
|
|
AssetsLibraryBackend.tooltipBackend.hideTooltip()
|
2023-02-09 09:17:37 +01:00
|
|
|
if (mouse.button === Qt.LeftButton && root.isEffect)
|
2024-01-26 14:55:50 +02:00
|
|
|
AssetsLibraryBackend.rootView.openEffectComposer(filePath)
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
2024-11-12 14:03:37 +02:00
|
|
|
StudioControls.ToolTip {
|
2022-12-15 23:20:43 +02:00
|
|
|
id: assetTooltip
|
2022-11-23 11:49:45 +02:00
|
|
|
visible: !root.isFont && mouseArea.containsMouse && !root.assetsView.contextMenu.visible
|
2022-12-15 23:20:43 +02:00
|
|
|
text: assetTooltip.__computeText()
|
2022-11-23 11:49:45 +02:00
|
|
|
delay: 1000
|
2022-12-15 23:20:43 +02:00
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function __computeText() {
|
2022-12-15 23:20:43 +02:00
|
|
|
let filePath = model.filePath.replace(assetsModel.contentDirPath(), "")
|
|
|
|
let fileSize = rootView.assetFileSize(model.filePath)
|
|
|
|
let fileExtMatches = model.filePath.match(/\.(.*)$/)
|
|
|
|
let fileExt = fileExtMatches ? "(" + fileExtMatches[1] + ")" : ""
|
|
|
|
|
2023-01-30 14:25:31 +02:00
|
|
|
if (root.__isDirectory)
|
|
|
|
return filePath
|
|
|
|
|
2023-03-06 17:27:25 +02:00
|
|
|
if (rootView.assetIsImageOrTexture(model.filePath)) {
|
2022-12-15 23:20:43 +02:00
|
|
|
let size = rootView.imageSize(model.filePath)
|
|
|
|
|
|
|
|
return filePath + "\n"
|
|
|
|
+ size.width + " x " + size.height
|
|
|
|
+ "\n" + fileSize
|
|
|
|
+ " " + fileExt
|
2024-12-13 10:56:56 +02:00
|
|
|
} else if (rootView.assetIsImported3d(model.filePath)) {
|
|
|
|
return filePath + "\n"
|
|
|
|
+ fileExt
|
2022-12-15 23:20:43 +02:00
|
|
|
} else {
|
|
|
|
return filePath + "\n"
|
|
|
|
+ fileSize
|
|
|
|
+ " " + fileExt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function refresh() {
|
|
|
|
assetTooltip.text = assetTooltip.__computeText()
|
2022-12-15 23:20:43 +02:00
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 1000
|
|
|
|
running: mouseArea.containsMouse && mouseArea.allowTooltip
|
|
|
|
onTriggered: {
|
2023-02-09 09:17:37 +01:00
|
|
|
if (root.isFont) {
|
2023-03-07 16:51:02 +01:00
|
|
|
AssetsLibraryBackend.tooltipBackend.name = model.fileName
|
|
|
|
AssetsLibraryBackend.tooltipBackend.path = model.filePath
|
|
|
|
AssetsLibraryBackend.tooltipBackend.showTooltip()
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
}
|
2023-02-09 09:17:37 +01:00
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
|
|
|
|
onClicked: (mouse) => {
|
2024-11-04 11:41:00 +02:00
|
|
|
if (mouse.button === Qt.LeftButton) {
|
2022-11-23 15:47:34 +02:00
|
|
|
root.__toggleExpandCurrentRow()
|
2024-11-04 11:41:00 +02:00
|
|
|
root.assetsView.currentFilePath = root.__itemPath
|
|
|
|
} else {
|
2022-11-23 15:47:34 +02:00
|
|
|
root.__openContextMenuForCurrentRow()
|
2024-11-04 11:41:00 +02:00
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
2023-02-09 09:17:37 +01:00
|
|
|
}
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function getDirPath() {
|
2022-12-01 22:05:55 +02:00
|
|
|
if (root.__isDirectory)
|
|
|
|
return model.filePath
|
|
|
|
else
|
|
|
|
return assetsModel.parentDirPath(model.filePath)
|
|
|
|
}
|
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function __openContextMenuForCurrentRow() {
|
2022-11-23 11:49:45 +02:00
|
|
|
let modelIndex = assetsModel.indexForPath(model.filePath)
|
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
function onFolderCreated(path) {
|
2023-01-26 23:40:01 +02:00
|
|
|
if (path)
|
|
|
|
root.assetsView.addCreatedFolder(path)
|
2022-11-23 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (root.__isDirectory) {
|
2022-11-23 11:49:45 +02:00
|
|
|
var allExpandedState = root.assetsView.computeAllExpandedState()
|
|
|
|
|
|
|
|
root.assetsView.contextMenu.openContextMenuForDir(modelIndex, model.filePath,
|
2023-01-26 23:40:01 +02:00
|
|
|
model.fileName, allExpandedState, onFolderCreated)
|
2022-11-23 11:49:45 +02:00
|
|
|
} else {
|
|
|
|
let parentDirIndex = assetsModel.parentDirIndex(model.filePath)
|
|
|
|
let selectedPaths = root.assetsView.selectedPathsAsList()
|
|
|
|
root.assetsView.contextMenu.openContextMenuForFile(modelIndex, parentDirIndex,
|
2022-11-23 15:47:34 +02:00
|
|
|
selectedPaths, onFolderCreated)
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function __toggleExpandCurrentRow() {
|
2024-12-03 22:49:51 +02:00
|
|
|
if (!root.__isDirectory || root.isDelegateEmpty)
|
2024-08-13 19:09:53 +03:00
|
|
|
return
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
let index = root.assetsView.__modelIndex(root.__currentRow)
|
2022-11-23 11:49:45 +02:00
|
|
|
// if the user manually clicked on a directory, then this is definitely not a
|
|
|
|
// an automatic request to expand all.
|
|
|
|
root.assetsView.requestedExpandAll = false
|
|
|
|
|
2022-11-23 15:47:34 +02:00
|
|
|
if (root.assetsView.isExpanded(root.__currentRow)) {
|
2022-11-23 11:49:45 +02:00
|
|
|
root.assetsView.requestedExpandAll = false
|
2022-11-23 15:47:34 +02:00
|
|
|
root.assetsView.collapse(root.__currentRow)
|
2022-11-23 11:49:45 +02:00
|
|
|
} else {
|
2022-11-23 15:47:34 +02:00
|
|
|
root.assetsView.expand(root.__currentRow)
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
2024-10-09 14:02:12 +03:00
|
|
|
|
|
|
|
assetsModel.saveExpandState(root.__itemPath, root.expanded)
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function reloadImage() {
|
2022-11-23 15:47:34 +02:00
|
|
|
if (root.__isDirectory)
|
2022-11-23 11:49:45 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
thumbnailImage.source = ""
|
2022-11-23 15:47:34 +02:00
|
|
|
thumbnailImage.source = thumbnailImage.__computeSource()
|
2022-11-23 11:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: thumbnailImage
|
2022-11-23 15:47:34 +02:00
|
|
|
visible: !root.__isDirectory
|
2023-02-09 09:17:37 +01:00
|
|
|
y: StudioTheme.Values.border
|
2024-08-12 17:39:58 +03:00
|
|
|
x: bg.x + StudioTheme.Values.border
|
2022-11-23 11:49:45 +02:00
|
|
|
width: 48
|
|
|
|
height: 48
|
|
|
|
cache: false
|
|
|
|
sourceSize.width: 48
|
|
|
|
sourceSize.height: 48
|
|
|
|
asynchronous: true
|
2023-09-21 16:13:43 +03:00
|
|
|
fillMode: Image.Pad
|
2022-11-23 15:47:34 +02:00
|
|
|
source: thumbnailImage.__computeSource()
|
2022-11-23 11:49:45 +02:00
|
|
|
|
2023-02-09 09:17:37 +01:00
|
|
|
function __computeSource() {
|
2022-11-23 15:47:34 +02:00
|
|
|
return root.__isDirectory
|
2022-11-23 11:49:45 +02:00
|
|
|
? ""
|
|
|
|
: "image://qmldesigner_assets/" + model.filePath
|
|
|
|
}
|
|
|
|
|
2022-12-15 23:20:43 +02:00
|
|
|
onStatusChanged: {
|
|
|
|
if (thumbnailImage.status === Image.Ready)
|
|
|
|
assetTooltip.refresh()
|
|
|
|
}
|
2023-02-09 09:17:37 +01:00
|
|
|
}
|
2024-08-13 19:09:53 +03:00
|
|
|
|
|
|
|
DropArea {
|
2024-08-27 14:00:21 +03:00
|
|
|
id: dropArea
|
|
|
|
|
2024-08-13 19:09:53 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
anchors.bottomMargin: -assetsView.rowSpacing
|
|
|
|
|
|
|
|
function updateParentHighlight(highlight) {
|
|
|
|
let index = root.assetsView.__modelIndex(root.__currentRow)
|
|
|
|
let parentItem = assetsView.__getDelegateParentForIndex(index)
|
|
|
|
if (parentItem)
|
|
|
|
parentItem.isHighlighted = highlight
|
|
|
|
|
|
|
|
// highlights the root folder canvas area when dragging over child
|
|
|
|
if (root.depth === 1 && !root.__isDirectory)
|
2024-08-27 14:00:21 +03:00
|
|
|
root.assetsRoot.highlightCanvas = highlight
|
2024-08-13 19:09:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onEntered: (drag) => {
|
|
|
|
root.assetsRoot.updateDropExtFiles(drag)
|
2024-08-29 22:27:13 +03:00
|
|
|
drag.accepted |= drag.formats[0] === "application/vnd.qtdesignstudio.assets"
|
|
|
|
&& !root.assetsModel.isSameOrDescendantPath(drag.urls[0], root.__itemPath)
|
2024-08-13 19:09:53 +03:00
|
|
|
|
|
|
|
if (root.__isDirectory)
|
2024-08-27 14:00:21 +03:00
|
|
|
root.isHighlighted = drag.accepted
|
2024-08-13 19:09:53 +03:00
|
|
|
else
|
2024-08-27 14:00:21 +03:00
|
|
|
dropArea.updateParentHighlight(drag.accepted)
|
2024-08-13 19:09:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onDropped: (drag) => {
|
|
|
|
if (drag.formats[0] === "application/vnd.qtdesignstudio.assets") {
|
2024-08-27 14:00:21 +03:00
|
|
|
root.rootView.invokeAssetsDrop(drag.urls, root.getDirPath())
|
2024-08-13 19:09:53 +03:00
|
|
|
} else {
|
2024-08-27 14:00:21 +03:00
|
|
|
root.rootView.emitExtFilesDrop(root.assetsRoot.dropSimpleExtFiles,
|
|
|
|
root.assetsRoot.dropComplexExtFiles,
|
|
|
|
root.getDirPath())
|
2024-08-13 19:09:53 +03:00
|
|
|
}
|
|
|
|
|
2024-08-27 14:00:21 +03:00
|
|
|
root.isHighlighted = false
|
|
|
|
dropArea.updateParentHighlight(false)
|
2024-08-13 19:09:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onExited: {
|
2024-08-27 14:00:21 +03:00
|
|
|
root.isHighlighted = false
|
|
|
|
dropArea.updateParentHighlight(false)
|
2024-08-13 19:09:53 +03:00
|
|
|
}
|
|
|
|
}
|
2023-02-09 09:17:37 +01:00
|
|
|
}
|