QmlDesigner: Allow setting Section category

Section collapse all and expand all functionalities are controlled via
a singleton instance. Since multiple views are now sharing QML engine,
they also share this controller singleton. Therefore it is necessary
to allow user of the Section to specify which category the section
belongs to, so that invoking expand all from one view doesn't
expand sections in another view, but only sections in the same
category.

This also allows fine tuning which sections are grouped within a view,
which was not possible previously.

Fixes: QDS-9248
Change-Id: I0a1c870e6746580255a02f91d590eb80ce6ebcbe
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Miikka Heikkinen
2023-03-09 15:46:42 +02:00
parent f4f13d0bf4
commit 15ebc22aeb
7 changed files with 30 additions and 11 deletions

View File

@@ -107,6 +107,7 @@ Item {
width: root.width
model: ContentLibraryBackend.texturesModel
sectionCategory: "ContentLib_Tex"
searchBox: searchBox
}
@@ -116,6 +117,7 @@ Item {
width: root.width
model: ContentLibraryBackend.environmentsModel
sectionCategory: "ContentLib_Env"
searchBox: searchBox
}

View File

@@ -62,6 +62,8 @@ HelperWidgets.ScrollView {
visible: bundleCategoryVisible && !materialsModel.isEmpty
expanded: bundleCategoryExpanded
expandOnClick: false
category: "ContentLib_Mat"
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
onExpand: bundleCategoryExpanded = true
onCollapse: bundleCategoryExpanded = false

View File

@@ -21,6 +21,7 @@ HelperWidgets.ScrollView {
required property var searchBox
required property var model
required property string sectionCategory
signal unimport(var bundleMat);
@@ -57,6 +58,8 @@ HelperWidgets.ScrollView {
visible: bundleCategoryVisible && !root.model.isEmpty
expanded: bundleCategoryExpanded
expandOnClick: false
category: root.sectionCategory
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
onExpand: bundleCategoryExpanded = true
onCollapse: bundleCategoryExpanded = false

View File

@@ -245,6 +245,8 @@ Item {
expanded: importExpanded
expandOnClick: false
useDefaulContextMenu: false
category: "ItemsView"
onToggleExpand: {
if (categoryModel.rowCount() > 0)
importExpanded = !importExpanded
@@ -277,6 +279,8 @@ Item {
expandOnClick: false
onToggleExpand: categoryExpanded = !categoryExpanded
useDefaulContextMenu: false
category: "ItemsView"
onShowContextMenu: {
if (!ItemLibraryBackend.rootView.searchActive) {
itemsView.currentCategory = model
@@ -354,6 +358,8 @@ Item {
expanded: importExpanded
expandOnClick: false
useDefaulContextMenu: false
category: "ItemsView"
onToggleExpand: {
if (categoryModel.rowCount() > 0)
importExpanded = !importExpanded

View File

@@ -628,6 +628,7 @@ Item {
width: root.width
caption: qsTr("Materials")
dropEnabled: true
category: "MaterialBrowser"
onDropEnter: (drag) => {
drag.accepted = drag.formats[0] === "application/vnd.qtdesignstudio.bundlematerial"
@@ -716,6 +717,7 @@ Item {
width: root.width
caption: qsTr("Textures")
category: "MaterialBrowser"
dropEnabled: true

View File

@@ -9,6 +9,6 @@ QtObject {
property Item mainScrollView
signal collapseAll()
signal expandAll()
signal collapseAll(string category)
signal expandAll(string category)
}

View File

@@ -38,6 +38,8 @@ Item {
property bool useDefaulContextMenu: true
property string category: "properties"
clip: true
Connections {
@@ -49,19 +51,21 @@ Item {
Connections {
target: Controller
function onCollapseAll() {
if (collapsible) {
function onCollapseAll(cat) {
if (collapsible && cat === section.category) {
if (section.expandOnClick)
section.expanded = false
else
section.collapse()
}
}
function onExpandAll() {
if (section.expandOnClick)
section.expanded = true
else
section.expand()
function onExpandAll(cat) {
if (cat === section.category) {
if (section.expandOnClick)
section.expanded = true
else
section.expand()
}
}
}
@@ -100,12 +104,12 @@ Item {
StudioControls.MenuItem {
text: qsTr("Expand All")
onTriggered: Controller.expandAll()
onTriggered: Controller.expandAll(section.category)
}
StudioControls.MenuItem {
text: qsTr("Collapse All")
onTriggered: Controller.collapseAll()
onTriggered: Controller.collapseAll(section.category)
}
}
}