2023-04-18 14:09:48 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import HelperWidgets as HelperWidgets
|
|
|
|
import StudioControls as StudioControls
|
|
|
|
import StudioTheme as StudioTheme
|
|
|
|
import ContentLibraryBackend
|
|
|
|
|
|
|
|
HelperWidgets.ScrollView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
interactive: !ctxMenu.opened && !ContentLibraryBackend.rootView.isDragging
|
|
|
|
&& !HelperWidgets.Controller.contextMenuOpened
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
property real cellWidth: 100
|
|
|
|
property real cellHeight: 120
|
|
|
|
property int numColumns: 4
|
|
|
|
|
|
|
|
property int count: 0
|
|
|
|
function assignMaxCount() {
|
|
|
|
let c = 0
|
|
|
|
for (let i = 0; i < categoryRepeater.count; ++i)
|
|
|
|
c = Math.max(c, categoryRepeater.itemAt(i)?.count ?? 0)
|
|
|
|
|
|
|
|
root.count = c
|
|
|
|
}
|
2023-04-18 14:09:48 +03:00
|
|
|
|
|
|
|
required property var searchBox
|
|
|
|
|
|
|
|
signal unimport(var bundleItem);
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
function closeContextMenu() {
|
2023-04-18 14:09:48 +03:00
|
|
|
ctxMenu.close()
|
|
|
|
}
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
function expandVisibleSections() {
|
2023-04-18 14:09:48 +03:00
|
|
|
for (let i = 0; i < categoryRepeater.count; ++i) {
|
|
|
|
let cat = categoryRepeater.itemAt(i)
|
|
|
|
if (cat.visible && !cat.expanded)
|
|
|
|
cat.expandSection()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
ContentLibraryEffectContextMenu {
|
|
|
|
id: ctxMenu
|
|
|
|
|
|
|
|
onUnimport: (bundleEff) => root.unimport(bundleEff)
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: categoryRepeater
|
|
|
|
|
|
|
|
model: ContentLibraryBackend.effectsModel
|
|
|
|
|
|
|
|
delegate: HelperWidgets.Section {
|
2023-10-05 20:13:19 +02:00
|
|
|
id: section
|
|
|
|
|
2023-04-18 14:09:48 +03:00
|
|
|
width: root.width
|
2023-10-05 20:13:19 +02:00
|
|
|
leftPadding: StudioTheme.Values.sectionPadding
|
|
|
|
rightPadding: StudioTheme.Values.sectionPadding
|
|
|
|
topPadding: StudioTheme.Values.sectionPadding
|
|
|
|
bottomPadding: StudioTheme.Values.sectionPadding
|
|
|
|
|
2023-04-18 14:09:48 +03:00
|
|
|
caption: bundleCategoryName
|
|
|
|
visible: bundleCategoryVisible && !ContentLibraryBackend.effectsModel.isEmpty
|
|
|
|
expanded: bundleCategoryExpanded
|
|
|
|
expandOnClick: false
|
|
|
|
category: "ContentLib_Effect"
|
|
|
|
|
|
|
|
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
|
|
|
|
onExpand: bundleCategoryExpanded = true
|
|
|
|
onCollapse: bundleCategoryExpanded = false
|
|
|
|
|
|
|
|
function expandSection() {
|
|
|
|
bundleCategoryExpanded = true
|
|
|
|
}
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
property alias count: repeater.count
|
|
|
|
|
|
|
|
onCountChanged: root.assignMaxCount()
|
|
|
|
|
2023-04-18 14:09:48 +03:00
|
|
|
Grid {
|
2023-10-05 20:13:19 +02:00
|
|
|
width: section.width - section.leftPadding - section.rightPadding
|
|
|
|
spacing: StudioTheme.Values.sectionGridSpacing
|
|
|
|
columns: root.numColumns
|
2023-04-18 14:09:48 +03:00
|
|
|
|
|
|
|
Repeater {
|
2023-10-05 20:13:19 +02:00
|
|
|
id: repeater
|
2023-04-18 14:09:48 +03:00
|
|
|
model: bundleCategoryItems
|
|
|
|
|
|
|
|
delegate: ContentLibraryEffect {
|
|
|
|
width: root.cellWidth
|
|
|
|
height: root.cellHeight
|
|
|
|
|
|
|
|
onShowContextMenu: ctxMenu.popupMenu(modelData)
|
|
|
|
}
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
onCountChanged: root.assignMaxCount()
|
2023-04-18 14:09:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: infoText
|
|
|
|
text: {
|
|
|
|
if (!ContentLibraryBackend.effectsModel.bundleExists)
|
|
|
|
qsTr("No effects available.")
|
2023-09-14 17:08:56 +03:00
|
|
|
else if (!ContentLibraryBackend.rootView.isQt6Project)
|
|
|
|
qsTr("<b>Content Library</b> effects are not supported in Qt5 projects.")
|
2023-04-18 14:09:48 +03:00
|
|
|
else if (!ContentLibraryBackend.rootView.hasQuick3DImport)
|
|
|
|
qsTr("To use <b>Content Library</b>, first add the QtQuick3D module in the <b>Components</b> view.")
|
|
|
|
else if (!ContentLibraryBackend.effectsModel.hasRequiredQuick3DImport)
|
|
|
|
qsTr("To use <b>Content Library</b>, version 6.4 or later of the QtQuick3D module is required.")
|
|
|
|
else if (!ContentLibraryBackend.rootView.hasMaterialLibrary)
|
|
|
|
qsTr("<b>Content Library</b> is disabled inside a non-visual component.")
|
|
|
|
else if (!searchBox.isEmpty())
|
|
|
|
qsTr("No match found.")
|
|
|
|
else
|
|
|
|
""
|
|
|
|
}
|
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
|
|
|
topPadding: 10
|
|
|
|
leftPadding: 10
|
|
|
|
visible: ContentLibraryBackend.effectsModel.isEmpty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|