Commit bf1b4290 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.propertyEditor: fix fill button

The fill button should only be checked
if all 4 anchors are set and the margins are 0.

Reviewed-by: Kai Koehne
parent 2eb7f18b
......@@ -131,6 +131,7 @@ QWidget {
styleSheetFile: "anchorfill.css";
toolTip: enabled ? qsTr("Fill to parent") : qsTr("Setting anchors in states is not supported.")
checkable: true
checked: anchorBackend.isFilled;
onReleased: {
if (checked) {
......
......@@ -152,6 +152,15 @@ bool QmlAnchorBindingProxy::hasParent()
return m_fxItemNode.isValid() && m_fxItemNode.hasNodeParent();
}
bool QmlAnchorBindingProxy::isFilled()
{
return m_fxItemNode.isValid() && hasAnchors() && topAnchored() && bottomAnchored() && leftAnchored() && rightAnchored()
&& (m_fxItemNode.instanceValue("anchors.topMargin").toInt() == 0)
&& (m_fxItemNode.instanceValue("anchors.bottomMargin").toInt() == 0)
&& (m_fxItemNode.instanceValue("anchors.leftMargin").toInt() == 0)
&& (m_fxItemNode.instanceValue("anchors.rightMargin").toInt() == 0);
}
bool QmlAnchorBindingProxy::topAnchored()
{
return m_fxItemNode.isValid() && m_fxItemNode.anchors().instanceHasAnchor(AnchorLine::Top);
......
......@@ -65,6 +65,7 @@ class QmlAnchorBindingProxy : public QObject
Q_PROPERTY(QVariant horizontalTarget READ horizontalTarget WRITE setHorizontalTarget NOTIFY horizontalTargetChanged)
Q_PROPERTY(bool hasAnchors READ hasAnchors NOTIFY anchorsChanged)
Q_PROPERTY(bool isFilled READ isFilled NOTIFY anchorsChanged)
Q_PROPERTY(bool horizontalCentered READ horizontalCentered WRITE setHorizontalCentered NOTIFY centeredHChanged)
Q_PROPERTY(bool verticalCentered READ verticalCentered WRITE setVerticalCentered NOTIFY centeredVChanged)
......@@ -85,6 +86,7 @@ public:
bool rightAnchored();
bool hasParent();
bool isFilled();
void removeTopAnchor();
void removeBottomAnchor();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment