diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml index e22f23dc12e..48db2229b10 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml @@ -247,7 +247,7 @@ Item { : StudioTheme.Values.themeTextColor leftPadding: 0 rightPadding: 0 - expanded: importExpanded + defaultExpanded: importExpanded expandOnClick: false useDefaulContextMenu: false category: "ItemsView" @@ -278,7 +278,7 @@ Item { addBottomPadding: index !== categoryModel.rowCount() - 1 caption: displayNMame + " (" + itemModel.rowCount() + ")" visible: categoryVisible - expanded: categoryExpanded + defaultExpanded: categoryExpanded expandOnClick: false onToggleExpand: categoryExpanded = !categoryExpanded useDefaulContextMenu: false @@ -362,7 +362,7 @@ Item { : StudioTheme.Values.themeTextColor leftPadding: 0 rightPadding: 0 - expanded: importExpanded + defaultExpanded: importExpanded expandOnClick: false useDefaulContextMenu: false category: "ItemsView" diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml index 4da7d9fb5d3..7119bfd84e2 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml @@ -195,7 +195,8 @@ Section { labelCapitalization: Font.MixedCase visible: root.hasDesignerEffect category: "DesignEffects" - expanded: false + defaultExpanded: false + expanded: defaultExpanded SectionLayout { @@ -243,7 +244,8 @@ Section { labelCapitalization: Font.MixedCase visible: root.hasDesignerEffect category: "DesignEffects" - expanded: false + defaultExpanded: false + expanded: defaultExpanded SectionLayout { @@ -355,7 +357,8 @@ Section { anchors.right: parent.right category: "DesignEffects" fillBackground: true - expanded: false + defaultExpanded: false + expanded: defaultExpanded draggable: true showCloseButton: true diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml index 536ba9dd90d..2fda6717290 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml @@ -142,15 +142,15 @@ PropertyEditorPane { } EffectsSection { - expanded: false + defaultExpanded: false } AdvancedSection { - expanded: false + defaultExpanded: false } LayerSection { - expanded: false + defaultExpanded: false } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml index 5af99822c71..8f3878797f5 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Section.qml @@ -49,7 +49,8 @@ Item { property int topPadding: StudioTheme.Values.sectionHeadSpacerHeight property int bottomPadding: StudioTheme.Values.sectionHeadSpacerHeight - property bool expanded: true + property bool defaultExpanded: true + property bool expanded: defaultExpanded property int level: 0 property int levelShift: 10 property bool hideHeader: false @@ -68,6 +69,39 @@ Item { clip: true + Component.onCompleted: { + updateExpansion() + } + + function updateExpansion() { + // Check if function 'loadExpandedState' exists in current context + if (typeof loadExpandedState === "function") { + if (section.expandOnClick) + section.expanded = loadExpandedState(section.caption, section.defaultExpanded) + else if (loadExpandedState(section.caption, section.defaultExpanded)) + section.expand() + else + section.collapse() + } else { + // Fallback to default value + if (section.expandOnClick) + section.expanded = section.defaultExpanded + else if (section.defaultExpanded) + section.expand() + else + section.collapse() + } + } + + Connections { + target: modelNodeBackend ?? null + ignoreUnknownSignals: true + + function onSelectionChanged() { + updateExpansion() + } + } + Connections { id: connection target: section @@ -165,6 +199,10 @@ Item { section.expanded = !section.expanded else section.toggleExpand() + + // Check if function 'saveExpandedState' exists in current context + if (typeof saveExpandedState === "function") + saveExpandedState(section.caption, section.expanded) } else { section.showContextMenu() } @@ -249,6 +287,10 @@ Item { section.expanded = !section.expanded else section.toggleExpand() + + // Check if function 'saveExpandedState' exists in current context + if (typeof saveExpandedState === "function") + saveExpandedState(section.caption, section.expanded) } } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 46436c135f5..e894e2a054b 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -693,6 +693,16 @@ void PropertyEditorContextObject::handleToolBarAction(int action) emit toolBarAction(action); } +void PropertyEditorContextObject::saveExpandedState(const QString §ionName, bool expanded) +{ + s_expandedStateHash.insert(sectionName, expanded); +} + +bool PropertyEditorContextObject::loadExpandedState(const QString §ionName, bool defaultValue) const +{ + return s_expandedStateHash.value(sectionName, defaultValue); +} + void EasingCurveEditor::registerDeclarativeType() { qmlRegisterType("HelperWidgets", 2, 0, "EasingCurveEditor"); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h index 650f2bbbae8..e58d8c58299 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h @@ -104,6 +104,9 @@ public: Q_INVOKABLE void handleToolBarAction(int action); + Q_INVOKABLE void saveExpandedState(const QString §ionName, bool expanded); + Q_INVOKABLE bool loadExpandedState(const QString §ionName, bool defaultValue) const; + enum ToolBarAction { SelectionLock, SelectionUnlock }; Q_ENUM(ToolBarAction) @@ -241,6 +244,8 @@ private: QStringList m_insightCategories; ModelNodes m_editorNodes; // Nodes that are being edited by PropertyEditor + + inline static QHash s_expandedStateHash; }; class EasingCurveEditor : public QObject