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
|
required property var extendString
|
||||||
|
|
||||||
function setPropertyChangesVisible(value) {
|
function setPropertyChangesVisible(value) {
|
||||||
stateThumbnail.propertyChangesVisible = value
|
stateThumbnail.setPropertyChangesVisible(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
width: Constants.thumbnailSize
|
width: Constants.thumbnailSize
|
||||||
|
@@ -46,7 +46,7 @@ Item {
|
|||||||
property alias menuChecked: menuButton.checked
|
property alias menuChecked: menuButton.checked
|
||||||
property bool baseState: false
|
property bool baseState: false
|
||||||
property bool isTiny: false
|
property bool isTiny: false
|
||||||
property bool propertyChangesVisible: false
|
property bool propertyChangesVisible: propertyChangesModel.propertyChangesVisible
|
||||||
property bool isChecked: false
|
property bool isChecked: false
|
||||||
|
|
||||||
property bool hasExtend: false
|
property bool hasExtend: false
|
||||||
@@ -80,6 +80,11 @@ Item {
|
|||||||
return statesEditorModel.hasAnnotation(root.internalNodeId)
|
return statesEditorModel.hasAnnotation(root.internalNodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPropertyChangesVisible(value) {
|
||||||
|
root.propertyChangesVisible = value
|
||||||
|
propertyChangesModel.setPropertyChangesVisible(value)
|
||||||
|
}
|
||||||
|
|
||||||
onIsTinyChanged: {
|
onIsTinyChanged: {
|
||||||
if (root.isTiny) {
|
if (root.isTiny) {
|
||||||
buttonGrid.rows = 2
|
buttonGrid.rows = 2
|
||||||
@@ -315,6 +320,9 @@ Item {
|
|||||||
Column {
|
Column {
|
||||||
id: column
|
id: column
|
||||||
|
|
||||||
|
property bool hoverEnabled: false
|
||||||
|
onPositioningComplete: column.hoverEnabled = true
|
||||||
|
|
||||||
// Grid sizes
|
// Grid sizes
|
||||||
property int gridSpacing: 20
|
property int gridSpacing: 20
|
||||||
property int gridRowSpacing: 5
|
property int gridRowSpacing: 5
|
||||||
@@ -354,7 +362,7 @@ Item {
|
|||||||
Item {
|
Item {
|
||||||
id: section
|
id: section
|
||||||
property int animationDuration: 120
|
property int animationDuration: 120
|
||||||
property bool expanded: false
|
property bool expanded: propertyModel.expanded
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
width: stateBackground.innerWidth
|
width: stateBackground.innerWidth
|
||||||
@@ -416,6 +424,7 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
section.expanded = !section.expanded
|
section.expanded = !section.expanded
|
||||||
|
propertyModel.setExpanded(section.expanded)
|
||||||
if (!section.expanded)
|
if (!section.expanded)
|
||||||
section.forceActiveFocus()
|
section.forceActiveFocus()
|
||||||
root.focusSignal()
|
root.focusSignal()
|
||||||
@@ -519,6 +528,8 @@ Item {
|
|||||||
Repeater {
|
Repeater {
|
||||||
model: propertyModel
|
model: propertyModel
|
||||||
|
|
||||||
|
onModelChanged: column.hoverEnabled = false
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
delegate: ItemDelegate {
|
||||||
id: propertyDelegate
|
id: propertyDelegate
|
||||||
|
|
||||||
@@ -528,7 +539,7 @@ Item {
|
|||||||
|
|
||||||
width: stateBackground.innerWidth - 2 * column.gridPadding
|
width: stateBackground.innerWidth - 2 * column.gridPadding
|
||||||
height: 26
|
height: 26
|
||||||
hoverEnabled: true
|
hoverEnabled: column.hoverEnabled
|
||||||
|
|
||||||
onClicked: root.focusSignal()
|
onClicked: root.focusSignal()
|
||||||
|
|
||||||
@@ -561,7 +572,7 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
id: propertyDelegateMouseArea
|
id: propertyDelegateMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: column.hoverEnabled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.focusSignal()
|
root.focusSignal()
|
||||||
propertyModel.removeProperty(
|
propertyModel.removeProperty(
|
||||||
@@ -718,7 +729,7 @@ Item {
|
|||||||
onClone: root.clone()
|
onClone: root.clone()
|
||||||
onExtend: root.extend()
|
onExtend: root.extend()
|
||||||
onRemove: root.remove()
|
onRemove: root.remove()
|
||||||
onToggle: root.propertyChangesVisible = !root.propertyChangesVisible
|
onToggle: root.setPropertyChangesVisible(!root.propertyChangesVisible)
|
||||||
onResetWhenCondition: statesEditorModel.resetWhenCondition(root.internalNodeId)
|
onResetWhenCondition: statesEditorModel.resetWhenCondition(root.internalNodeId)
|
||||||
onEditAnnotation: {
|
onEditAnnotation: {
|
||||||
statesEditorModel.setAnnotation(root.internalNodeId)
|
statesEditorModel.setAnnotation(root.internalNodeId)
|
||||||
|
@@ -123,6 +123,7 @@ void PropertyChangesModel::setModelNodeBackend(const QVariant &modelNodeBackend)
|
|||||||
m_view->registerPropertyChangesModel(this);
|
m_view->registerPropertyChangesModel(this);
|
||||||
|
|
||||||
emit modelNodeBackendChanged();
|
emit modelNodeBackendChanged();
|
||||||
|
emit propertyChangesVisibleChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyChangesModel::reset()
|
void PropertyChangesModel::reset()
|
||||||
@@ -138,6 +139,25 @@ int PropertyChangesModel::count() const
|
|||||||
return rowCount();
|
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()
|
void PropertyChangesModel::registerDeclarativeType()
|
||||||
{
|
{
|
||||||
qmlRegisterType<PropertyChangesModel>("HelperWidgets", 2, 0, "PropertyChangesModel");
|
qmlRegisterType<PropertyChangesModel>("HelperWidgets", 2, 0, "PropertyChangesModel");
|
||||||
|
@@ -42,6 +42,8 @@ class PropertyChangesModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
||||||
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
||||||
NOTIFY modelNodeBackendChanged)
|
NOTIFY modelNodeBackendChanged)
|
||||||
|
Q_PROPERTY(bool propertyChangesVisible READ propertyChangesVisible NOTIFY
|
||||||
|
propertyChangesVisibleChanged)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Target = Qt::DisplayRole,
|
Target = Qt::DisplayRole,
|
||||||
@@ -62,11 +64,15 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
int count() const;
|
int count() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void setPropertyChangesVisible(bool value);
|
||||||
|
Q_INVOKABLE bool propertyChangesVisible() const;
|
||||||
|
|
||||||
static void registerDeclarativeType();
|
static void registerDeclarativeType();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modelNodeBackendChanged();
|
void modelNodeBackendChanged();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
void propertyChangesVisibleChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariant modelNodeBackend() const;
|
QVariant modelNodeBackend() const;
|
||||||
|
@@ -114,6 +114,7 @@ void PropertyModel::setModelNodeBackend(const QVariant &modelNodeBackend)
|
|||||||
|
|
||||||
setupModel();
|
setupModel();
|
||||||
emit modelNodeBackendChanged();
|
emit modelNodeBackendChanged();
|
||||||
|
emit expandedChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyModel::setExplicit(bool value)
|
void PropertyModel::setExplicit(bool value)
|
||||||
@@ -146,6 +147,25 @@ void PropertyModel::removeProperty(const QString &name)
|
|||||||
m_modelNode.removeProperty(name.toUtf8());
|
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()
|
void PropertyModel::registerDeclarativeType()
|
||||||
{
|
{
|
||||||
qmlRegisterType<PropertyModel>("HelperWidgets", 2, 0, "PropertyModel");
|
qmlRegisterType<PropertyModel>("HelperWidgets", 2, 0, "PropertyModel");
|
||||||
|
@@ -39,6 +39,7 @@ class PropertyModel : public QAbstractListModel
|
|||||||
|
|
||||||
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend
|
||||||
NOTIFY modelNodeBackendChanged)
|
NOTIFY modelNodeBackendChanged)
|
||||||
|
Q_PROPERTY(bool expanded READ expanded NOTIFY expandedChanged)
|
||||||
|
|
||||||
enum { Name = Qt::DisplayRole, Value = Qt::UserRole, Type };
|
enum { Name = Qt::DisplayRole, Value = Qt::UserRole, Type };
|
||||||
|
|
||||||
@@ -55,10 +56,14 @@ public:
|
|||||||
Q_INVOKABLE void setRestoreEntryValues(bool value);
|
Q_INVOKABLE void setRestoreEntryValues(bool value);
|
||||||
Q_INVOKABLE void removeProperty(const QString &name);
|
Q_INVOKABLE void removeProperty(const QString &name);
|
||||||
|
|
||||||
|
Q_INVOKABLE void setExpanded(bool value);
|
||||||
|
Q_INVOKABLE bool expanded() const;
|
||||||
|
|
||||||
static void registerDeclarativeType();
|
static void registerDeclarativeType();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modelNodeBackendChanged();
|
void modelNodeBackendChanged();
|
||||||
|
void expandedChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariant modelNodeBackend() const;
|
QVariant modelNodeBackend() const;
|
||||||
|
Reference in New Issue
Block a user