forked from qt-creator/qt-creator
PropertyEditor: Persistent state of Property Editor sections
The state of the sections (collapsed or not) should be persistent. This gives the user more control over the property editor. We can e.g. provide large sections that are on the top and the user decides wheather they are extended or not. Task-number: QDS-14941 Change-Id: I5bb7ea1aa29c688082c17e375ea4c924403e4cdc Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Ali Kianian <ali.kianian@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -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"
|
||||
|
@@ -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
|
||||
|
@@ -142,15 +142,15 @@ PropertyEditorPane {
|
||||
}
|
||||
|
||||
EffectsSection {
|
||||
expanded: false
|
||||
defaultExpanded: false
|
||||
}
|
||||
|
||||
AdvancedSection {
|
||||
expanded: false
|
||||
defaultExpanded: false
|
||||
}
|
||||
|
||||
LayerSection {
|
||||
expanded: false
|
||||
defaultExpanded: false
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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<EasingCurveEditor>("HelperWidgets", 2, 0, "EasingCurveEditor");
|
||||
|
@@ -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<QString, bool> s_expandedStateHash;
|
||||
};
|
||||
|
||||
class EasingCurveEditor : public QObject
|
||||
|
Reference in New Issue
Block a user