forked from qt-creator/qt-creator
QmlDesigner: Use AUX property to remember state
Use AUX properties to save the StateThumbnail state (property changes or thumbnail). Also the save the state of the property changes state section (expanded or collapsed). Task-number: QDS-7732 Change-Id: I607bb05b7c71bb98e7781d058bb5736ab4b77e72 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
ac0251e106
commit
cf9b36a6c7
@@ -659,7 +659,7 @@ Rectangle {
|
||||
required property var extendString
|
||||
|
||||
function setPropertyChangesVisible(value) {
|
||||
stateThumbnail.propertyChangesVisible = value
|
||||
stateThumbnail.setPropertyChangesVisible(value)
|
||||
}
|
||||
|
||||
width: Constants.thumbnailSize
|
||||
|
@@ -46,7 +46,7 @@ Item {
|
||||
property alias menuChecked: menuButton.checked
|
||||
property bool baseState: false
|
||||
property bool isTiny: false
|
||||
property bool propertyChangesVisible: false
|
||||
property bool propertyChangesVisible: propertyChangesModel.propertyChangesVisible
|
||||
property bool isChecked: false
|
||||
|
||||
property bool hasExtend: false
|
||||
@@ -80,6 +80,11 @@ Item {
|
||||
return statesEditorModel.hasAnnotation(root.internalNodeId)
|
||||
}
|
||||
|
||||
function setPropertyChangesVisible(value) {
|
||||
root.propertyChangesVisible = value
|
||||
propertyChangesModel.setPropertyChangesVisible(value)
|
||||
}
|
||||
|
||||
onIsTinyChanged: {
|
||||
if (root.isTiny) {
|
||||
buttonGrid.rows = 2
|
||||
@@ -315,6 +320,9 @@ Item {
|
||||
Column {
|
||||
id: column
|
||||
|
||||
property bool hoverEnabled: false
|
||||
onPositioningComplete: column.hoverEnabled = true
|
||||
|
||||
// Grid sizes
|
||||
property int gridSpacing: 20
|
||||
property int gridRowSpacing: 5
|
||||
@@ -354,7 +362,7 @@ Item {
|
||||
Item {
|
||||
id: section
|
||||
property int animationDuration: 120
|
||||
property bool expanded: false
|
||||
property bool expanded: propertyModel.expanded
|
||||
|
||||
clip: true
|
||||
width: stateBackground.innerWidth
|
||||
@@ -416,6 +424,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
section.expanded = !section.expanded
|
||||
propertyModel.setExpanded(section.expanded)
|
||||
if (!section.expanded)
|
||||
section.forceActiveFocus()
|
||||
root.focusSignal()
|
||||
@@ -519,6 +528,8 @@ Item {
|
||||
Repeater {
|
||||
model: propertyModel
|
||||
|
||||
onModelChanged: column.hoverEnabled = false
|
||||
|
||||
delegate: ItemDelegate {
|
||||
id: propertyDelegate
|
||||
|
||||
@@ -528,7 +539,7 @@ Item {
|
||||
|
||||
width: stateBackground.innerWidth - 2 * column.gridPadding
|
||||
height: 26
|
||||
hoverEnabled: true
|
||||
hoverEnabled: column.hoverEnabled
|
||||
|
||||
onClicked: root.focusSignal()
|
||||
|
||||
@@ -561,7 +572,7 @@ Item {
|
||||
MouseArea {
|
||||
id: propertyDelegateMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
hoverEnabled: column.hoverEnabled
|
||||
onClicked: {
|
||||
root.focusSignal()
|
||||
propertyModel.removeProperty(
|
||||
@@ -718,7 +729,7 @@ Item {
|
||||
onClone: root.clone()
|
||||
onExtend: root.extend()
|
||||
onRemove: root.remove()
|
||||
onToggle: root.propertyChangesVisible = !root.propertyChangesVisible
|
||||
onToggle: root.setPropertyChangesVisible(!root.propertyChangesVisible)
|
||||
onResetWhenCondition: statesEditorModel.resetWhenCondition(root.internalNodeId)
|
||||
onEditAnnotation: {
|
||||
statesEditorModel.setAnnotation(root.internalNodeId)
|
||||
|
@@ -123,6 +123,7 @@ void PropertyChangesModel::setModelNodeBackend(const QVariant &modelNodeBackend)
|
||||
m_view->registerPropertyChangesModel(this);
|
||||
|
||||
emit modelNodeBackendChanged();
|
||||
emit propertyChangesVisibleChanged();
|
||||
}
|
||||
|
||||
void PropertyChangesModel::reset()
|
||||
@@ -138,6 +139,25 @@ int PropertyChangesModel::count() const
|
||||
return rowCount();
|
||||
}
|
||||
|
||||
void PropertyChangesModel::setPropertyChangesVisible(bool value)
|
||||
{
|
||||
if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached())
|
||||
return;
|
||||
|
||||
if (value)
|
||||
m_modelNode.setAuxiliaryData("propertyChangesVisible@Internal", value);
|
||||
else
|
||||
m_modelNode.removeAuxiliaryData("propertyChangesVisible@Internal");
|
||||
}
|
||||
|
||||
bool PropertyChangesModel::propertyChangesVisible() const
|
||||
{
|
||||
if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached())
|
||||
return false;
|
||||
|
||||
return m_modelNode.hasAuxiliaryData("propertyChangesVisible@Internal");
|
||||
}
|
||||
|
||||
void PropertyChangesModel::registerDeclarativeType()
|
||||
{
|
||||
qmlRegisterType<PropertyChangesModel>("HelperWidgets", 2, 0, "PropertyChangesModel");
|
||||
|
@@ -42,6 +42,8 @@ class PropertyChangesModel : public QAbstractListModel
|
||||
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
||||
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
||||
NOTIFY modelNodeBackendChanged)
|
||||
Q_PROPERTY(bool propertyChangesVisible READ propertyChangesVisible NOTIFY
|
||||
propertyChangesVisibleChanged)
|
||||
|
||||
enum {
|
||||
Target = Qt::DisplayRole,
|
||||
@@ -62,11 +64,15 @@ public:
|
||||
void reset();
|
||||
int count() const;
|
||||
|
||||
Q_INVOKABLE void setPropertyChangesVisible(bool value);
|
||||
Q_INVOKABLE bool propertyChangesVisible() const;
|
||||
|
||||
static void registerDeclarativeType();
|
||||
|
||||
signals:
|
||||
void modelNodeBackendChanged();
|
||||
void countChanged();
|
||||
void propertyChangesVisibleChanged();
|
||||
|
||||
private:
|
||||
QVariant modelNodeBackend() const;
|
||||
|
@@ -114,6 +114,7 @@ void PropertyModel::setModelNodeBackend(const QVariant &modelNodeBackend)
|
||||
|
||||
setupModel();
|
||||
emit modelNodeBackendChanged();
|
||||
emit expandedChanged();
|
||||
}
|
||||
|
||||
void PropertyModel::setExplicit(bool value)
|
||||
@@ -146,6 +147,25 @@ void PropertyModel::removeProperty(const QString &name)
|
||||
m_modelNode.removeProperty(name.toUtf8());
|
||||
}
|
||||
|
||||
void PropertyModel::setExpanded(bool value)
|
||||
{
|
||||
if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached())
|
||||
return;
|
||||
|
||||
if (value)
|
||||
m_modelNode.setAuxiliaryData("expanded@Internal", value);
|
||||
else
|
||||
m_modelNode.removeAuxiliaryData("expanded@Internal");
|
||||
}
|
||||
|
||||
bool PropertyModel::expanded() const
|
||||
{
|
||||
if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached())
|
||||
return false;
|
||||
|
||||
return m_modelNode.hasAuxiliaryData("expanded@Internal");
|
||||
}
|
||||
|
||||
void PropertyModel::registerDeclarativeType()
|
||||
{
|
||||
qmlRegisterType<PropertyModel>("HelperWidgets", 2, 0, "PropertyModel");
|
||||
|
@@ -39,6 +39,7 @@ class PropertyModel : public QAbstractListModel
|
||||
|
||||
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
||||
NOTIFY modelNodeBackendChanged)
|
||||
Q_PROPERTY(bool expanded READ expanded NOTIFY expandedChanged)
|
||||
|
||||
enum { Name = Qt::DisplayRole, Value = Qt::UserRole, Type };
|
||||
|
||||
@@ -55,10 +56,14 @@ public:
|
||||
Q_INVOKABLE void setRestoreEntryValues(bool value);
|
||||
Q_INVOKABLE void removeProperty(const QString &name);
|
||||
|
||||
Q_INVOKABLE void setExpanded(bool value);
|
||||
Q_INVOKABLE bool expanded() const;
|
||||
|
||||
static void registerDeclarativeType();
|
||||
|
||||
signals:
|
||||
void modelNodeBackendChanged();
|
||||
void expandedChanged();
|
||||
|
||||
private:
|
||||
QVariant modelNodeBackend() const;
|
||||
|
Reference in New Issue
Block a user