forked from qt-creator/qt-creator
QmlDesigner: Adding support for padding
This property has been added to Qt Quick 2.6. We do not show the padding section for Qt Quick versions that do not support padding. Change-Id: I10123c65849e1708d452320ba3e3b4cb19f5b5bb Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
6884ab080e
commit
da202bff82
@@ -0,0 +1,122 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import HelperWidgets 2.0
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Controls 1.0 as Controls
|
||||||
|
|
||||||
|
Section {
|
||||||
|
caption: qsTr("Padding")
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
SectionLayout {
|
||||||
|
Label {
|
||||||
|
text: qsTr("Vertical")
|
||||||
|
}
|
||||||
|
SecondColumnLayout {
|
||||||
|
Label {
|
||||||
|
text: qsTr("Top")
|
||||||
|
tooltip: qsTr("Padding between the content and the top edge of the item.")
|
||||||
|
width: 42
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
maximumValue: 9999999
|
||||||
|
minimumValue: -9999999
|
||||||
|
decimals: 0
|
||||||
|
backendValue: backendValues.topPadding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
width: 4
|
||||||
|
height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Bottom")
|
||||||
|
tooltip: qsTr("Padding between the content and the bottom edge of the item.")
|
||||||
|
width: 42
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
maximumValue: 9999999
|
||||||
|
minimumValue: -9999999
|
||||||
|
decimals: 0
|
||||||
|
backendValue: backendValues.bottomPadding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Horizontal")
|
||||||
|
}
|
||||||
|
SecondColumnLayout {
|
||||||
|
Label {
|
||||||
|
text: qsTr("Left")
|
||||||
|
tooltip: qsTr("Padding between the content and the left edge of the item.")
|
||||||
|
width: 42
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
maximumValue: 9999999
|
||||||
|
minimumValue: -9999999
|
||||||
|
decimals: 0
|
||||||
|
backendValue: backendValues.leftPadding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
width: 4
|
||||||
|
height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Right")
|
||||||
|
tooltip: qsTr("Padding between the content and the right edge of the item.")
|
||||||
|
width: 42
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
maximumValue: 9999999
|
||||||
|
minimumValue: -9999999
|
||||||
|
decimals: 0
|
||||||
|
backendValue: backendValues.rightPadding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Padding")
|
||||||
|
tooltip: qsTr("Padding between the content and the edges of the items.")
|
||||||
|
}
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
maximumValue: 9999999
|
||||||
|
minimumValue: -9999999
|
||||||
|
decimals: 0
|
||||||
|
backendValue: backendValues.padding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -38,3 +38,4 @@ Tab 2.0 Tab.qml
|
|||||||
TabView 2.0 TabView.qml
|
TabView 2.0 TabView.qml
|
||||||
ToolTipArea 2.0 ToolTipArea.qml
|
ToolTipArea 2.0 ToolTipArea.qml
|
||||||
UrlChooser 2.0 UrlChooser.qml
|
UrlChooser 2.0 UrlChooser.qml
|
||||||
|
PaddingSection 2.0 PaddingSection.qml
|
||||||
|
@@ -68,4 +68,8 @@ Column {
|
|||||||
|
|
||||||
TextInputSection {
|
TextInputSection {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaddingSection {
|
||||||
|
visible: minorQtQuickVersion > 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,4 +68,9 @@ Column {
|
|||||||
TextInputSection {
|
TextInputSection {
|
||||||
isTextInput: true
|
isTextInput: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaddingSection {
|
||||||
|
visible: minorQtQuickVersion > 5
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -67,4 +67,8 @@ Column {
|
|||||||
FontSection {
|
FontSection {
|
||||||
showStyle: true
|
showStyle: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaddingSection {
|
||||||
|
visible: minorQtQuickVersion > 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -80,9 +80,6 @@ PropertyEditorContextObject::PropertyEditorContextObject(QObject *parent) :
|
|||||||
m_isBaseState(false),
|
m_isBaseState(false),
|
||||||
m_selectionChanged(false),
|
m_selectionChanged(false),
|
||||||
m_backendValues(0),
|
m_backendValues(0),
|
||||||
m_majorVersion(-1),
|
|
||||||
m_minorVersion(-1),
|
|
||||||
m_majorQtQuickVersion(-1),
|
|
||||||
m_qmlComponent(0),
|
m_qmlComponent(0),
|
||||||
m_qmlContext(0)
|
m_qmlContext(0)
|
||||||
{
|
{
|
||||||
@@ -170,6 +167,11 @@ int PropertyEditorContextObject::majorQtQuickVersion() const
|
|||||||
return m_majorQtQuickVersion;
|
return m_majorQtQuickVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PropertyEditorContextObject::minorQtQuickVersion() const
|
||||||
|
{
|
||||||
|
return m_minorQtQuickVersion;
|
||||||
|
}
|
||||||
|
|
||||||
void PropertyEditorContextObject::setMajorVersion(int majorVersion)
|
void PropertyEditorContextObject::setMajorVersion(int majorVersion)
|
||||||
{
|
{
|
||||||
if (m_majorVersion == majorVersion)
|
if (m_majorVersion == majorVersion)
|
||||||
@@ -191,6 +193,16 @@ void PropertyEditorContextObject::setMajorQtQuickVersion(int majorVersion)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyEditorContextObject::setMinorQtQuickVersion(int minorVersion)
|
||||||
|
{
|
||||||
|
if (m_minorQtQuickVersion == minorVersion)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_minorQtQuickVersion = minorVersion;
|
||||||
|
|
||||||
|
emit minorQtQuickVersionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
int PropertyEditorContextObject::minorVersion() const
|
int PropertyEditorContextObject::minorVersion() const
|
||||||
{
|
{
|
||||||
return m_minorVersion;
|
return m_minorVersion;
|
||||||
|
@@ -51,6 +51,7 @@ class PropertyEditorContextObject : public QObject
|
|||||||
Q_PROPERTY(int majorVersion READ majorVersion WRITE setMajorVersion NOTIFY majorVersionChanged)
|
Q_PROPERTY(int majorVersion READ majorVersion WRITE setMajorVersion NOTIFY majorVersionChanged)
|
||||||
Q_PROPERTY(int minorVersion READ minorVersion WRITE setMinorVersion NOTIFY minorVersionChanged)
|
Q_PROPERTY(int minorVersion READ minorVersion WRITE setMinorVersion NOTIFY minorVersionChanged)
|
||||||
Q_PROPERTY(int majorQtQuickVersion READ majorQtQuickVersion WRITE setMajorQtQuickVersion NOTIFY majorQtQuickVersionChanged)
|
Q_PROPERTY(int majorQtQuickVersion READ majorQtQuickVersion WRITE setMajorQtQuickVersion NOTIFY majorQtQuickVersionChanged)
|
||||||
|
Q_PROPERTY(int minorQtQuickVersion READ minorQtQuickVersion WRITE setMinorQtQuickVersion NOTIFY minorQtQuickVersionChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool hasAliasExport READ hasAliasExport NOTIFY hasAliasExportChanged)
|
Q_PROPERTY(bool hasAliasExport READ hasAliasExport NOTIFY hasAliasExportChanged)
|
||||||
|
|
||||||
@@ -81,8 +82,10 @@ public:
|
|||||||
|
|
||||||
int majorVersion() const;
|
int majorVersion() const;
|
||||||
int majorQtQuickVersion() const;
|
int majorQtQuickVersion() const;
|
||||||
|
int minorQtQuickVersion() const;
|
||||||
void setMajorVersion(int majorVersion);
|
void setMajorVersion(int majorVersion);
|
||||||
void setMajorQtQuickVersion(int majorVersion);
|
void setMajorQtQuickVersion(int majorVersion);
|
||||||
|
void setMinorQtQuickVersion(int minorVersion);
|
||||||
int minorVersion() const;
|
int minorVersion() const;
|
||||||
void setMinorVersion(int minorVersion);
|
void setMinorVersion(int minorVersion);
|
||||||
|
|
||||||
@@ -102,6 +105,7 @@ signals:
|
|||||||
void majorVersionChanged();
|
void majorVersionChanged();
|
||||||
void minorVersionChanged();
|
void minorVersionChanged();
|
||||||
void majorQtQuickVersionChanged();
|
void majorQtQuickVersionChanged();
|
||||||
|
void minorQtQuickVersionChanged();
|
||||||
void specificQmlComponentChanged();
|
void specificQmlComponentChanged();
|
||||||
void hasAliasExportChanged();
|
void hasAliasExportChanged();
|
||||||
|
|
||||||
@@ -137,9 +141,10 @@ private:
|
|||||||
|
|
||||||
QQmlPropertyMap* m_backendValues;
|
QQmlPropertyMap* m_backendValues;
|
||||||
|
|
||||||
int m_majorVersion;
|
int m_majorVersion = 1;
|
||||||
int m_minorVersion;
|
int m_minorVersion = 1;
|
||||||
int m_majorQtQuickVersion;
|
int m_majorQtQuickVersion = 1;
|
||||||
|
int m_minorQtQuickVersion = -1;
|
||||||
QQmlComponent *m_qmlComponent;
|
QQmlComponent *m_qmlComponent;
|
||||||
QQmlContext *m_qmlContext;
|
QQmlContext *m_qmlContext;
|
||||||
|
|
||||||
|
@@ -329,9 +329,11 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q
|
|||||||
contextObject()->setMajorVersion(-1);
|
contextObject()->setMajorVersion(-1);
|
||||||
contextObject()->setMinorVersion(-1);
|
contextObject()->setMinorVersion(-1);
|
||||||
contextObject()->setMajorQtQuickVersion(-1);
|
contextObject()->setMajorQtQuickVersion(-1);
|
||||||
|
contextObject()->setMinorQtQuickVersion(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
contextObject()->setMajorQtQuickVersion(qmlObjectNode.view()->majorQtQuickVersion());
|
contextObject()->setMajorQtQuickVersion(qmlObjectNode.view()->majorQtQuickVersion());
|
||||||
|
contextObject()->setMinorQtQuickVersion(qmlObjectNode.view()->minorQtQuickVersion());
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "PropertyEditor: invalid node for setup";
|
qWarning() << "PropertyEditor: invalid node for setup";
|
||||||
}
|
}
|
||||||
|
@@ -236,6 +236,7 @@ public:
|
|||||||
QmlModelState currentState() const;
|
QmlModelState currentState() const;
|
||||||
|
|
||||||
int majorQtQuickVersion() const;
|
int majorQtQuickVersion() const;
|
||||||
|
int minorQtQuickVersion() const;
|
||||||
|
|
||||||
void resetView();
|
void resetView();
|
||||||
|
|
||||||
|
@@ -672,6 +672,21 @@ QmlModelState AbstractView::currentState() const
|
|||||||
return QmlModelState(currentStateNode());
|
return QmlModelState(currentStateNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getMinorVersionFromImport(const Model *model)
|
||||||
|
{
|
||||||
|
foreach (const Import &import, model->imports()) {
|
||||||
|
if (import.isLibraryImport() && import.url() == "QtQuick") {
|
||||||
|
const QString versionString = import.version();
|
||||||
|
if (versionString.contains(".")) {
|
||||||
|
const QString minorVersionString = versionString.split(".").last();
|
||||||
|
return minorVersionString.toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int getMajorVersionFromImport(const Model *model)
|
static int getMajorVersionFromImport(const Model *model)
|
||||||
{
|
{
|
||||||
foreach (const Import &import, model->imports()) {
|
foreach (const Import &import, model->imports()) {
|
||||||
@@ -702,6 +717,21 @@ static int getMajorVersionFromNode(const ModelNode &modelNode)
|
|||||||
return 1; //default
|
return 1; //default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getMinorVersionFromNode(const ModelNode &modelNode)
|
||||||
|
{
|
||||||
|
if (modelNode.metaInfo().isValid()) {
|
||||||
|
if (modelNode.type() == "QtQuick.QtObject" || modelNode.type() == "QtQuick.Item")
|
||||||
|
return modelNode.minorVersion();
|
||||||
|
|
||||||
|
foreach (const NodeMetaInfo &superClass, modelNode.metaInfo().superClasses()) {
|
||||||
|
if (modelNode.type() == "QtQuick.QtObject" || modelNode.type() == "QtQuick.Item")
|
||||||
|
return superClass.minorVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1; //default
|
||||||
|
}
|
||||||
|
|
||||||
int AbstractView::majorQtQuickVersion() const
|
int AbstractView::majorQtQuickVersion() const
|
||||||
{
|
{
|
||||||
int majorVersionFromImport = getMajorVersionFromImport(model());
|
int majorVersionFromImport = getMajorVersionFromImport(model());
|
||||||
@@ -711,4 +741,14 @@ int AbstractView::majorQtQuickVersion() const
|
|||||||
return getMajorVersionFromNode(rootModelNode());
|
return getMajorVersionFromNode(rootModelNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AbstractView::minorQtQuickVersion() const
|
||||||
|
{
|
||||||
|
int minorVersionFromImport = getMinorVersionFromImport(model());
|
||||||
|
if (minorVersionFromImport >= 0)
|
||||||
|
return minorVersionFromImport;
|
||||||
|
|
||||||
|
return getMinorVersionFromNode(rootModelNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
Reference in New Issue
Block a user