Files
qt-creator/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexturesView.qml
Miikka Heikkinen df622c9c3c QmlDesigner: Fix expand all and collapse all in content library
Fixes: QDS-8413
Change-Id: I98931c52f63bbbfd7a42e522a762d77b469df5da
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2022-12-09 13:27:25 +00:00

107 lines
3.0 KiB
QML

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
import QtQuick
import HelperWidgets as HelperWidgets
import StudioControls as StudioControls
import StudioTheme as StudioTheme
HelperWidgets.ScrollView {
id: root
clip: true
interactive: !ctxMenu.opened
readonly property int cellWidth: 100
readonly property int cellHeight: 100
property var currMaterialItem: null
property var rootItem: null
required property var searchBox
required property var model
signal unimport(var bundleMat);
function closeContextMenu()
{
ctxMenu.close()
}
function expandVisibleSections()
{
for (let i = 0; i < categoryRepeater.count; ++i) {
let cat = categoryRepeater.itemAt(i)
if (cat.visible && !cat.expanded)
cat.expandSection()
}
}
Column {
ContentLibraryTextureContextMenu {
id: ctxMenu
hasSceneEnv: root.model.hasSceneEnv
}
Repeater {
id: categoryRepeater
model: root.model
delegate: HelperWidgets.Section {
width: root.width
caption: bundleCategoryName
addTopPadding: false
sectionBackgroundColor: "transparent"
visible: bundleCategoryVisible && !root.model.isEmpty
expanded: bundleCategoryExpanded
expandOnClick: false
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
onExpand: bundleCategoryExpanded = true
onCollapse: bundleCategoryExpanded = false
function expandSection() {
bundleCategoryExpanded = true
}
Grid {
width: root.width
leftPadding: 5
rightPadding: 5
bottomPadding: 5
spacing: 5
columns: root.width / root.cellWidth
Repeater {
model: bundleCategoryTextures
delegate: ContentLibraryTexture {
width: root.cellWidth
height: root.cellHeight
onShowContextMenu: ctxMenu.popupMenu(modelData)
}
}
}
}
}
Text {
id: infoText
text: {
if (!root.model.texBundleExists)
qsTr("<b>Content Library</b> textures are not installed.")
else if (!searchBox.isEmpty())
qsTr("No match found.")
else
""
}
color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize
topPadding: 10
leftPadding: 10
visible: root.model.isEmpty
}
}
}