Commit 6e275624 authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: add init root element size settings

Task-number: QTCREATORBUG-17965
Change-Id: Id2a3bef8d4becdecc9f358021a18feb2353743b5
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent a991ecec
......@@ -34,6 +34,7 @@
#include "formeditorscene.h"
#include "abstractcustomtool.h"
#include <designersettings.h>
#include <designmodecontext.h>
#include <modelnode.h>
#include <model.h>
......@@ -452,6 +453,8 @@ void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeL
void FormEditorView::instanceInformationsChanged(const QMultiHash<ModelNode, InformationName> &informationChangedHash)
{
QList<FormEditorItem*> changedItems;
const int rootElementInitWidth = DesignerSettings::getValue(DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH).toInt();
const int rootElementInitHeight = DesignerSettings::getValue(DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT).toInt();
QList<ModelNode> informationChangedNodes = Utils::filtered(informationChangedHash.keys(), [](const ModelNode &node) {
return QmlItemNode::isValidQmlItemNode(node);
......@@ -466,9 +469,9 @@ void FormEditorView::instanceInformationsChanged(const QMultiHash<ModelNode, Inf
!(qmlItemNode.propertyAffectedByCurrentState("width")
&& qmlItemNode.propertyAffectedByCurrentState("height"))) {
if (!(rootModelNode().hasAuxiliaryData("width")))
rootModelNode().setAuxiliaryData("width", 640);
rootModelNode().setAuxiliaryData("width", rootElementInitWidth);
if (!(rootModelNode().hasAuxiliaryData("height")))
rootModelNode().setAuxiliaryData("height", 480);
rootModelNode().setAuxiliaryData("height", rootElementInitHeight);
rootModelNode().setAuxiliaryData("autoSize", true);
formEditorWidget()->updateActions();
} else {
......
......@@ -54,6 +54,8 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::CONTAINERPADDING, 8);
restoreValue(settings, DesignerSettingsKey::CANVASWIDTH, 10000);
restoreValue(settings, DesignerSettingsKey::CANVASHEIGHT, 10000);
restoreValue(settings, DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH, 640);
restoreValue(settings, DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT, 480);
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER, true);
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_QML_FILES_INSTEAD_OF_UIQML_FILES, true);
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR, false);
......
......@@ -41,6 +41,8 @@ const char ITEMSPACING[] = "ItemSpacing";
const char CONTAINERPADDING[] = "ContainerPadding";
const char CANVASWIDTH[] = "CanvasWidth";
const char CANVASHEIGHT[] = "CanvasHeight";
const char ROOT_ELEMENT_INIT_WIDTH[] = "RootElementInitWidth";
const char ROOT_ELEMENT_INIT_HEIGHT[] = "RootElementInitHeight";
const char WARNING_FOR_FEATURES_IN_DESIGNER[] = "WarnAboutQtQuickFeaturesInDesigner";
const char WARNING_FOR_QML_FILES_INSTEAD_OF_UIQML_FILES[] = "WarnAboutQmlFilesInsteadOfUiQmlFiles";
const char WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR[] = "WarnAboutQtQuickDesignerFeaturesInCodeEditor";
......
......@@ -93,6 +93,8 @@ DesignerSettings SettingsPageWidget::settings() const
settings.insert(DesignerSettingsKey::CONTAINERPADDING, m_ui.spinSnapMargin->value());
settings.insert(DesignerSettingsKey::CANVASWIDTH, m_ui.spinCanvasWidth->value());
settings.insert(DesignerSettingsKey::CANVASHEIGHT, m_ui.spinCanvasHeight->value());
settings.insert(DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH, m_ui.spinRootItemInitWidth->value());
settings.insert(DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT, m_ui.spinRootItemInitHeight->value());
settings.insert(DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER,
m_ui.designerWarningsCheckBox->isChecked());
settings.insert(DesignerSettingsKey::WARNING_FOR_QML_FILES_INSTEAD_OF_UIQML_FILES,
......@@ -156,6 +158,10 @@ void SettingsPageWidget::setSettings(const DesignerSettings &settings)
DesignerSettingsKey::CANVASWIDTH).toInt());
m_ui.spinCanvasHeight->setValue(settings.value(
DesignerSettingsKey::CANVASHEIGHT).toInt());
m_ui.spinRootItemInitWidth->setValue(settings.value(
DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH).toInt());
m_ui.spinRootItemInitHeight->setValue(settings.value(
DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT).toInt());
m_ui.designerWarningsCheckBox->setChecked(settings.value(
DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER).toBool());
m_ui.designerWarningsUiQmlfiles->setChecked(settings.value(
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>678</width>
<width>685</width>
<height>555</height>
</rect>
</property>
......@@ -102,6 +102,55 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Root Item Init Size</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinRootItemInitHeight">
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>480</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinRootItemInitWidth">
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>640</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_03">
<property name="minimumSize">
......
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