2023-02-09 09:17:00 +01:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2024-01-16 12:30:29 +01:00
|
|
|
import HelperWidgets as HelperWidgets
|
|
|
|
|
import StudioControls as StudioControls
|
|
|
|
|
import StudioTheme as StudioTheme
|
2023-03-02 13:21:40 +01:00
|
|
|
import ContentLibraryBackend
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
2023-09-21 13:55:26 +02:00
|
|
|
property bool adsFocus: false
|
|
|
|
|
// objectName is used by the dock widget to find this particular ScrollView
|
|
|
|
|
// and set the ads focus on it.
|
|
|
|
|
objectName: "__mainSrollView"
|
|
|
|
|
|
2022-10-26 19:57:41 +03:00
|
|
|
// Called also from C++ to close context menu on focus out
|
2023-10-05 20:13:19 +02:00
|
|
|
function closeContextMenu() {
|
2022-10-26 19:57:41 +03:00
|
|
|
materialsView.closeContextMenu()
|
|
|
|
|
texturesView.closeContextMenu()
|
|
|
|
|
environmentsView.closeContextMenu()
|
2023-04-18 14:09:48 +03:00
|
|
|
effectsView.closeContextMenu()
|
2023-03-28 15:49:22 +03:00
|
|
|
HelperWidgets.Controller.closeContextMenu()
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called from C++
|
2023-10-05 20:13:19 +02:00
|
|
|
function clearSearchFilter() {
|
|
|
|
|
searchBox.clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property int numColumns: 4
|
|
|
|
|
property real thumbnailSize: 100
|
|
|
|
|
|
|
|
|
|
readonly property int minThumbSize: 100
|
|
|
|
|
readonly property int maxThumbSize: 150
|
|
|
|
|
|
|
|
|
|
function responsiveResize(width: int, height: int) {
|
|
|
|
|
width -= 2 * StudioTheme.Values.sectionPadding
|
|
|
|
|
|
|
|
|
|
let numColumns = Math.floor(width / root.minThumbSize)
|
|
|
|
|
let remainder = width % root.minThumbSize
|
|
|
|
|
let space = (numColumns - 1) * StudioTheme.Values.sectionGridSpacing
|
|
|
|
|
|
|
|
|
|
if (remainder < space)
|
|
|
|
|
numColumns -= 1
|
|
|
|
|
|
|
|
|
|
if (numColumns < 1)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
let maxItems = Math.max(materialsView.count,
|
|
|
|
|
texturesView.count,
|
|
|
|
|
environmentsView.count,
|
|
|
|
|
effectsView.count)
|
|
|
|
|
|
|
|
|
|
if (numColumns > maxItems)
|
|
|
|
|
numColumns = maxItems
|
|
|
|
|
|
|
|
|
|
let rest = width - (numColumns * root.minThumbSize)
|
|
|
|
|
- ((numColumns - 1) * StudioTheme.Values.sectionGridSpacing)
|
|
|
|
|
|
|
|
|
|
root.thumbnailSize = Math.min(root.minThumbSize + (rest / numColumns),
|
|
|
|
|
root.maxThumbSize)
|
|
|
|
|
root.numColumns = numColumns
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
id: col
|
2023-02-22 13:34:17 +01:00
|
|
|
anchors.fill: parent
|
2022-10-26 19:57:41 +03:00
|
|
|
spacing: 5
|
|
|
|
|
|
2023-02-09 09:17:00 +01:00
|
|
|
Rectangle {
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: StudioTheme.Values.doubleToolbarHeight
|
|
|
|
|
color: StudioTheme.Values.themeToolbarBackground
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
anchors.fill: parent
|
2023-10-05 20:13:19 +02:00
|
|
|
anchors.topMargin: StudioTheme.Values.toolbarVerticalMargin
|
|
|
|
|
anchors.bottomMargin: StudioTheme.Values.toolbarVerticalMargin
|
|
|
|
|
anchors.leftMargin: StudioTheme.Values.toolbarHorizontalMargin
|
|
|
|
|
anchors.rightMargin: StudioTheme.Values.toolbarHorizontalMargin
|
|
|
|
|
spacing: StudioTheme.Values.toolbarColumnSpacing
|
2023-02-09 09:17:00 +01:00
|
|
|
|
|
|
|
|
StudioControls.SearchBox {
|
|
|
|
|
id: searchBox
|
2023-02-13 11:20:27 +01:00
|
|
|
width: parent.width
|
2023-02-09 09:17:00 +01:00
|
|
|
style: StudioTheme.Values.searchControlStyle
|
|
|
|
|
enabled: {
|
|
|
|
|
if (tabBar.currIndex === 0) { // Materials tab
|
2023-03-02 13:21:40 +01:00
|
|
|
ContentLibraryBackend.materialsModel.matBundleExists
|
|
|
|
|
&& ContentLibraryBackend.rootView.hasMaterialLibrary
|
|
|
|
|
&& ContentLibraryBackend.materialsModel.hasRequiredQuick3DImport
|
2023-02-09 09:17:00 +01:00
|
|
|
} else { // Textures / Environments tabs
|
2023-03-02 16:31:49 +02:00
|
|
|
ContentLibraryBackend.texturesModel.texBundleExists
|
2023-02-09 09:17:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSearchChanged: (searchText) => {
|
2023-03-02 13:21:40 +01:00
|
|
|
ContentLibraryBackend.rootView.handleSearchFilterChanged(searchText)
|
2023-02-09 09:17:00 +01:00
|
|
|
|
|
|
|
|
// make sure categories with matches are expanded
|
|
|
|
|
materialsView.expandVisibleSections()
|
|
|
|
|
texturesView.expandVisibleSections()
|
|
|
|
|
environmentsView.expandVisibleSections()
|
2023-06-29 14:52:24 +03:00
|
|
|
effectsView.expandVisibleSections()
|
2023-02-09 09:17:00 +01:00
|
|
|
}
|
2022-11-29 16:56:08 +02:00
|
|
|
}
|
2022-10-26 19:57:41 +03:00
|
|
|
|
2023-02-09 09:17:00 +01:00
|
|
|
ContentLibraryTabBar {
|
|
|
|
|
id: tabBar
|
2023-02-13 11:20:27 +01:00
|
|
|
width: parent.width
|
2023-02-09 09:17:00 +01:00
|
|
|
height: StudioTheme.Values.toolbarHeight
|
|
|
|
|
tabsModel: [{name: qsTr("Materials"), icon: StudioTheme.Constants.material_medium},
|
|
|
|
|
{name: qsTr("Textures"), icon: StudioTheme.Constants.textures_medium},
|
2023-04-18 14:09:48 +03:00
|
|
|
{name: qsTr("Environments"), icon: StudioTheme.Constants.languageList_medium},
|
|
|
|
|
{name: qsTr("Effects"), icon: StudioTheme.Constants.effects}]
|
2023-02-09 09:17:00 +01:00
|
|
|
}
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnimportBundleMaterialDialog {
|
|
|
|
|
id: confirmUnimportDialog
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackLayout {
|
2023-10-05 20:13:19 +02:00
|
|
|
id: stackLayout
|
2022-10-26 19:57:41 +03:00
|
|
|
width: root.width
|
|
|
|
|
height: root.height - y
|
|
|
|
|
currentIndex: tabBar.currIndex
|
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
onWidthChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
|
|
|
|
|
|
2022-10-26 19:57:41 +03:00
|
|
|
ContentLibraryMaterialsView {
|
|
|
|
|
id: materialsView
|
|
|
|
|
|
2023-09-21 13:55:26 +02:00
|
|
|
adsFocus: root.adsFocus
|
2022-10-26 19:57:41 +03:00
|
|
|
width: root.width
|
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
cellWidth: root.thumbnailSize
|
|
|
|
|
cellHeight: root.thumbnailSize + 20
|
|
|
|
|
numColumns: root.numColumns
|
|
|
|
|
hideHorizontalScrollBar: true
|
|
|
|
|
|
2022-10-26 19:57:41 +03:00
|
|
|
searchBox: searchBox
|
|
|
|
|
|
|
|
|
|
onUnimport: (bundleMat) => {
|
2023-04-18 14:09:48 +03:00
|
|
|
confirmUnimportDialog.targetBundleItem = bundleMat
|
|
|
|
|
confirmUnimportDialog.targetBundleType = "material"
|
2022-11-21 16:12:54 +02:00
|
|
|
confirmUnimportDialog.open()
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContentLibraryTexturesView {
|
|
|
|
|
id: texturesView
|
|
|
|
|
|
2023-09-21 13:55:26 +02:00
|
|
|
adsFocus: root.adsFocus
|
2022-10-26 19:57:41 +03:00
|
|
|
width: root.width
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
cellWidth: root.thumbnailSize
|
|
|
|
|
cellHeight: root.thumbnailSize
|
|
|
|
|
numColumns: root.numColumns
|
|
|
|
|
hideHorizontalScrollBar: true
|
|
|
|
|
|
2023-03-02 16:31:49 +02:00
|
|
|
model: ContentLibraryBackend.texturesModel
|
2023-03-09 15:46:42 +02:00
|
|
|
sectionCategory: "ContentLib_Tex"
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
searchBox: searchBox
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContentLibraryTexturesView {
|
|
|
|
|
id: environmentsView
|
|
|
|
|
|
2023-09-21 13:55:26 +02:00
|
|
|
adsFocus: root.adsFocus
|
2022-10-26 19:57:41 +03:00
|
|
|
width: root.width
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
cellWidth: root.thumbnailSize
|
|
|
|
|
cellHeight: root.thumbnailSize
|
|
|
|
|
numColumns: root.numColumns
|
|
|
|
|
hideHorizontalScrollBar: true
|
|
|
|
|
|
2023-03-02 16:31:49 +02:00
|
|
|
model: ContentLibraryBackend.environmentsModel
|
2023-03-09 15:46:42 +02:00
|
|
|
sectionCategory: "ContentLib_Env"
|
2022-10-26 19:57:41 +03:00
|
|
|
|
|
|
|
|
searchBox: searchBox
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
2023-04-18 14:09:48 +03:00
|
|
|
|
|
|
|
|
ContentLibraryEffectsView {
|
|
|
|
|
id: effectsView
|
|
|
|
|
|
2023-09-21 13:55:26 +02:00
|
|
|
adsFocus: root.adsFocus
|
2023-04-18 14:09:48 +03:00
|
|
|
width: root.width
|
|
|
|
|
|
2023-10-05 20:13:19 +02:00
|
|
|
cellWidth: root.thumbnailSize
|
|
|
|
|
cellHeight: root.thumbnailSize + 20
|
|
|
|
|
numColumns: root.numColumns
|
|
|
|
|
hideHorizontalScrollBar: true
|
|
|
|
|
|
2023-04-18 14:09:48 +03:00
|
|
|
searchBox: searchBox
|
|
|
|
|
|
|
|
|
|
onUnimport: (bundleItem) => {
|
|
|
|
|
confirmUnimportDialog.targetBundleItem = bundleItem
|
|
|
|
|
confirmUnimportDialog.targetBundleType = "effect"
|
|
|
|
|
confirmUnimportDialog.open()
|
|
|
|
|
}
|
2023-10-05 20:13:19 +02:00
|
|
|
|
|
|
|
|
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
|
2023-04-18 14:09:48 +03:00
|
|
|
}
|
2022-10-26 19:57:41 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|