Commit f07aec60 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Improve size management

parent b008e48c
......@@ -115,6 +115,8 @@ void FormEditorView::modelAttached(Model *model)
if (rootQmlObjectNode().toQmlItemNode().isValid())
setupFormEditorItemTree(rootQmlObjectNode().toQmlItemNode());
m_formEditorWidget->updateActions();
}
......@@ -144,6 +146,7 @@ void FormEditorView::modelAboutToBeDetached(Model *model)
m_anchorTool->clear();
m_dragTool->clear();
m_scene->clearFormEditorItems();
m_formEditorWidget->updateActions();
QmlModelView::modelAboutToBeDetached(model);
}
......
......@@ -225,6 +225,25 @@ void FormEditorWidget::wheelEvent(QWheelEvent *event)
}
void FormEditorWidget::updateActions()
{
if (m_formEditorView->model() && m_formEditorView->rootModelNode().isValid()) {
if (m_formEditorView->rootModelNode().hasAuxiliaryData("width") && m_formEditorView->rootModelNode().auxiliaryData("width").isValid()) {
m_rootWidthAction->setLineEditText(m_formEditorView->rootModelNode().auxiliaryData("width").toString());
} else {
m_rootWidthAction->clearLineEditText();
}
if (m_formEditorView->rootModelNode().hasAuxiliaryData("height") && m_formEditorView->rootModelNode().auxiliaryData("height").isValid()) {
m_rootHeightAction->setLineEditText(m_formEditorView->rootModelNode().auxiliaryData("height").toString());
} else {
m_rootHeightAction->clearLineEditText();
}
} else {
m_rootWidthAction->clearLineEditText();
m_rootHeightAction->clearLineEditText();
}
}
ZoomAction *FormEditorWidget::zoomAction() const
{
return m_zoomAction.data();
......
......@@ -78,6 +78,8 @@ public:
void setRootItemRect(const QRectF &rect);
QRectF rootItemRect() const;
void updateActions();
protected:
void enterEvent(QEvent *event);
void wheelEvent(QWheelEvent *event);
......
......@@ -11,6 +11,16 @@ LineEditAction::LineEditAction(const QString &placeHolderText, QObject *parent)
{
}
void LineEditAction::setLineEditText(const QString &text)
{
emit lineEditTextChange(text);
}
void LineEditAction::clearLineEditText()
{
emit lineEditTextClear();
}
QWidget *LineEditAction::createWidget(QWidget *parent)
{
QLineEdit *lineEdit = new QLineEdit(parent);
......@@ -20,6 +30,8 @@ QWidget *LineEditAction::createWidget(QWidget *parent)
lineEdit->setValidator(new QIntValidator(0, 4096, this));
connect(lineEdit, SIGNAL(textEdited(QString)), this, SIGNAL(textChanged(QString)));
connect(this, SIGNAL(lineEditTextClear()), lineEdit, SLOT(clear()));
connect(this, SIGNAL(lineEditTextChange(QString)), lineEdit, SLOT(setText(QString)));
return lineEdit;
}
......
......@@ -11,11 +11,16 @@ class LineEditAction : public QWidgetAction
public:
explicit LineEditAction(const QString &placeHolderText, QObject *parent = 0);
void setLineEditText(const QString &text);
void clearLineEditText();
protected:
QWidget *createWidget(QWidget *parent);
signals:
void textChanged(const QString &text);
void lineEditTextChange(const QString &text);
void lineEditTextClear();
private:
QString m_placeHolderText;
......
......@@ -751,8 +751,15 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
foreach(const VariantProperty &property, variantPropertyList) {
ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) {
QVariant value = property.value();
if (node.isRootNode()
&& (property.name() == "width" || property.name() == "height")
&& node.hasAuxiliaryData(property.name())
&& node.auxiliaryData(property.name()).isValid())
value = node.auxiliaryData(property.name());
NodeInstance instance = instanceForNode(node);
PropertyValueContainer container(instance.instanceId(), property.name(), property.value(), property.dynamicTypeName());
PropertyValueContainer container(instance.instanceId(), property.name(), value, property.dynamicTypeName());
valueContainerList.append(container);
}
}
......@@ -761,6 +768,12 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
foreach(const BindingProperty &property, bindingPropertyList) {
ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) {
if (node.isRootNode()
&& (property.name() == "width" || property.name() == "height")
&& node.hasAuxiliaryData(property.name())
&& node.auxiliaryData(property.name()).isValid())
continue;
NodeInstance instance = instanceForNode(node);
PropertyBindingContainer container(instance.instanceId(), property.name(), property.expression(), property.dynamicTypeName());
bindingContainerList.append(container);
......
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