forked from qt-creator/qt-creator
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:
@@ -107,6 +107,7 @@ Item {
|
|||||||
|
|
||||||
width: root.width
|
width: root.width
|
||||||
model: ContentLibraryBackend.texturesModel
|
model: ContentLibraryBackend.texturesModel
|
||||||
|
sectionCategory: "ContentLib_Tex"
|
||||||
|
|
||||||
searchBox: searchBox
|
searchBox: searchBox
|
||||||
}
|
}
|
||||||
@@ -116,6 +117,7 @@ Item {
|
|||||||
|
|
||||||
width: root.width
|
width: root.width
|
||||||
model: ContentLibraryBackend.environmentsModel
|
model: ContentLibraryBackend.environmentsModel
|
||||||
|
sectionCategory: "ContentLib_Env"
|
||||||
|
|
||||||
searchBox: searchBox
|
searchBox: searchBox
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,8 @@ HelperWidgets.ScrollView {
|
|||||||
visible: bundleCategoryVisible && !materialsModel.isEmpty
|
visible: bundleCategoryVisible && !materialsModel.isEmpty
|
||||||
expanded: bundleCategoryExpanded
|
expanded: bundleCategoryExpanded
|
||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
|
category: "ContentLib_Mat"
|
||||||
|
|
||||||
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
|
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
|
||||||
onExpand: bundleCategoryExpanded = true
|
onExpand: bundleCategoryExpanded = true
|
||||||
onCollapse: bundleCategoryExpanded = false
|
onCollapse: bundleCategoryExpanded = false
|
||||||
|
@@ -21,6 +21,7 @@ HelperWidgets.ScrollView {
|
|||||||
|
|
||||||
required property var searchBox
|
required property var searchBox
|
||||||
required property var model
|
required property var model
|
||||||
|
required property string sectionCategory
|
||||||
|
|
||||||
signal unimport(var bundleMat);
|
signal unimport(var bundleMat);
|
||||||
|
|
||||||
@@ -57,6 +58,8 @@ HelperWidgets.ScrollView {
|
|||||||
visible: bundleCategoryVisible && !root.model.isEmpty
|
visible: bundleCategoryVisible && !root.model.isEmpty
|
||||||
expanded: bundleCategoryExpanded
|
expanded: bundleCategoryExpanded
|
||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
|
category: root.sectionCategory
|
||||||
|
|
||||||
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
|
onToggleExpand: bundleCategoryExpanded = !bundleCategoryExpanded
|
||||||
onExpand: bundleCategoryExpanded = true
|
onExpand: bundleCategoryExpanded = true
|
||||||
onCollapse: bundleCategoryExpanded = false
|
onCollapse: bundleCategoryExpanded = false
|
||||||
|
@@ -245,6 +245,8 @@ Item {
|
|||||||
expanded: importExpanded
|
expanded: importExpanded
|
||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
useDefaulContextMenu: false
|
useDefaulContextMenu: false
|
||||||
|
category: "ItemsView"
|
||||||
|
|
||||||
onToggleExpand: {
|
onToggleExpand: {
|
||||||
if (categoryModel.rowCount() > 0)
|
if (categoryModel.rowCount() > 0)
|
||||||
importExpanded = !importExpanded
|
importExpanded = !importExpanded
|
||||||
@@ -277,6 +279,8 @@ Item {
|
|||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
onToggleExpand: categoryExpanded = !categoryExpanded
|
onToggleExpand: categoryExpanded = !categoryExpanded
|
||||||
useDefaulContextMenu: false
|
useDefaulContextMenu: false
|
||||||
|
category: "ItemsView"
|
||||||
|
|
||||||
onShowContextMenu: {
|
onShowContextMenu: {
|
||||||
if (!ItemLibraryBackend.rootView.searchActive) {
|
if (!ItemLibraryBackend.rootView.searchActive) {
|
||||||
itemsView.currentCategory = model
|
itemsView.currentCategory = model
|
||||||
@@ -354,6 +358,8 @@ Item {
|
|||||||
expanded: importExpanded
|
expanded: importExpanded
|
||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
useDefaulContextMenu: false
|
useDefaulContextMenu: false
|
||||||
|
category: "ItemsView"
|
||||||
|
|
||||||
onToggleExpand: {
|
onToggleExpand: {
|
||||||
if (categoryModel.rowCount() > 0)
|
if (categoryModel.rowCount() > 0)
|
||||||
importExpanded = !importExpanded
|
importExpanded = !importExpanded
|
||||||
|
@@ -628,6 +628,7 @@ Item {
|
|||||||
width: root.width
|
width: root.width
|
||||||
caption: qsTr("Materials")
|
caption: qsTr("Materials")
|
||||||
dropEnabled: true
|
dropEnabled: true
|
||||||
|
category: "MaterialBrowser"
|
||||||
|
|
||||||
onDropEnter: (drag) => {
|
onDropEnter: (drag) => {
|
||||||
drag.accepted = drag.formats[0] === "application/vnd.qtdesignstudio.bundlematerial"
|
drag.accepted = drag.formats[0] === "application/vnd.qtdesignstudio.bundlematerial"
|
||||||
@@ -716,6 +717,7 @@ Item {
|
|||||||
|
|
||||||
width: root.width
|
width: root.width
|
||||||
caption: qsTr("Textures")
|
caption: qsTr("Textures")
|
||||||
|
category: "MaterialBrowser"
|
||||||
|
|
||||||
dropEnabled: true
|
dropEnabled: true
|
||||||
|
|
||||||
|
@@ -9,6 +9,6 @@ QtObject {
|
|||||||
|
|
||||||
property Item mainScrollView
|
property Item mainScrollView
|
||||||
|
|
||||||
signal collapseAll()
|
signal collapseAll(string category)
|
||||||
signal expandAll()
|
signal expandAll(string category)
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,8 @@ Item {
|
|||||||
|
|
||||||
property bool useDefaulContextMenu: true
|
property bool useDefaulContextMenu: true
|
||||||
|
|
||||||
|
property string category: "properties"
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -49,19 +51,21 @@ Item {
|
|||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Controller
|
target: Controller
|
||||||
function onCollapseAll() {
|
function onCollapseAll(cat) {
|
||||||
if (collapsible) {
|
if (collapsible && cat === section.category) {
|
||||||
if (section.expandOnClick)
|
if (section.expandOnClick)
|
||||||
section.expanded = false
|
section.expanded = false
|
||||||
else
|
else
|
||||||
section.collapse()
|
section.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onExpandAll() {
|
function onExpandAll(cat) {
|
||||||
if (section.expandOnClick)
|
if (cat === section.category) {
|
||||||
section.expanded = true
|
if (section.expandOnClick)
|
||||||
else
|
section.expanded = true
|
||||||
section.expand()
|
else
|
||||||
|
section.expand()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,12 +104,12 @@ Item {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Expand All")
|
text: qsTr("Expand All")
|
||||||
onTriggered: Controller.expandAll()
|
onTriggered: Controller.expandAll(section.category)
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Collapse All")
|
text: qsTr("Collapse All")
|
||||||
onTriggered: Controller.collapseAll()
|
onTriggered: Controller.collapseAll(section.category)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user