From 15ebc22aeb51f3981edaebafe356620b0df93791 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 9 Mar 2023 15:46:42 +0200 Subject: [PATCH] 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 Reviewed-by: Mahmoud Badri Reviewed-by: --- .../ContentLibrary.qml | 2 ++ .../ContentLibraryMaterialsView.qml | 2 ++ .../ContentLibraryTexturesView.qml | 3 +++ .../itemLibraryQmlSources/ItemsView.qml | 6 +++++ .../MaterialBrowser.qml | 2 ++ .../imports/HelperWidgets/Controller.qml | 4 ++-- .../imports/HelperWidgets/Section.qml | 22 +++++++++++-------- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibrary.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibrary.qml index ce0a8bd83b5..e835f4c7e3b 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibrary.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibrary.qml @@ -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 } diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryMaterialsView.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryMaterialsView.qml index 30ef4057415..f35bdf90eca 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryMaterialsView.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryMaterialsView.qml @@ -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 diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexturesView.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexturesView.qml index 85b73a99f19..f02d0e658fd 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexturesView.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTexturesView.qml @@ -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 diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml index 9a19a4cb20d..d787decb10c 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml @@ -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 diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml index abefaef1456..132bcac59ed 100644 --- a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml @@ -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 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Controller.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Controller.qml index 98d21c7f845..1d748410f55 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Controller.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Controller.qml @@ -9,6 +9,6 @@ QtObject { property Item mainScrollView - signal collapseAll() - signal expandAll() + signal collapseAll(string category) + signal expandAll(string category) } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml index d175b4b76cb..404dcb6246a 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml @@ -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) } } }