aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-03-02 18:19:21 +0100
committerJari-Pekka Nurmi <jpnurmi@theqtcompany.com>2015-03-03 02:02:03 +0200
commitf965016e5d001e7a844893a46902fb5b0ef84262 (patch)
tree084b51525c3f70e526cbeb1b29011a73c1198146
parent90e83f240d8c9171074530c40e6ed64d150367f9 (diff)
Replace grouped padding property with top/left/right/bottomPadding
This is consistent with QQuickText, QQuickTextInput, QQuickTextEdit... Change-Id: I06aafa1bf73311cbb24ad9411872cac131863d47 Reviewed-by: Jari-Pekka Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/controls.pri1
-rw-r--r--src/controls/qquickcontrol.cpp74
-rw-r--r--src/controls/qquickcontrol_p.h22
-rw-r--r--src/controls/qquickcontrol_p_p.h6
-rw-r--r--src/controls/qquickpadding_p.h84
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp2
6 files changed, 86 insertions, 103 deletions
diff --git a/src/controls/controls.pri b/src/controls/controls.pri
index af2b7b8c..084c8387 100644
--- a/src/controls/controls.pri
+++ b/src/controls/controls.pri
@@ -31,7 +31,6 @@ HEADERS += \
$$PWD/qquickcontrol_p.h \
$$PWD/qquickcontrol_p_p.h \
$$PWD/qquickexclusivegroup_p.h \
- $$PWD/qquickpadding_p.h \
$$PWD/qquickstyle_p.h
SOURCES += \
diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp
index 65db0e96..b76f9b3e 100644
--- a/src/controls/qquickcontrol.cpp
+++ b/src/controls/qquickcontrol.cpp
@@ -52,7 +52,8 @@ QT_BEGIN_NAMESPACE
*/
QQuickControlPrivate::QQuickControlPrivate() :
- style(Q_NULLPTR), attributes(QQuickControl::Attr_Count), background(Q_NULLPTR), padding(Q_NULLPTR)
+ style(Q_NULLPTR), attributes(QQuickControl::Attr_Count), background(Q_NULLPTR),
+ topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0)
{
}
@@ -105,20 +106,71 @@ QQuickControl::QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent) :
}
/*!
- \qmlpropertygroup QtQuickControls2::Control::padding
- \qmlproperty real QtQuickControls2::Control::padding.top
- \qmlproperty real QtQuickControls2::Control::padding.left
- \qmlproperty real QtQuickControls2::Control::padding.right
- \qmlproperty real QtQuickControls2::Control::padding.bottom
+ \qmlproperty real QtQuickControls2::Control::topPadding
+ \qmlproperty real QtQuickControls2::Control::leftPadding
+ \qmlproperty real QtQuickControls2::Control::rightPadding
+ \qmlproperty real QtQuickControls2::Control::bottomPadding
- This property holds the padding.
+ These properties hold the padding.
*/
-QQuickPadding *QQuickControl::padding() const
+qreal QQuickControl::topPadding() const
{
Q_D(const QQuickControl);
- if (!d->padding)
- d->padding = new QQuickPadding(const_cast<QQuickControl *>(this));
- return d->padding;
+ return d->topPadding;
+}
+
+void QQuickControl::setTopPadding(qreal padding)
+{
+ Q_D(QQuickControl);
+ if (!qFuzzyCompare(d->topPadding, padding)) {
+ d->topPadding = padding;
+ emit topPaddingChanged();
+ }
+}
+
+qreal QQuickControl::leftPadding() const
+{
+ Q_D(const QQuickControl);
+ return d->leftPadding;
+}
+
+void QQuickControl::setLeftPadding(qreal padding)
+{
+ Q_D(QQuickControl);
+ if (!qFuzzyCompare(d->leftPadding, padding)) {
+ d->leftPadding = padding;
+ emit leftPaddingChanged();
+ }
+}
+
+qreal QQuickControl::rightPadding() const
+{
+ Q_D(const QQuickControl);
+ return d->rightPadding;
+}
+
+void QQuickControl::setRightPadding(qreal padding)
+{
+ Q_D(QQuickControl);
+ if (!qFuzzyCompare(d->rightPadding, padding)) {
+ d->rightPadding = padding;
+ emit rightPaddingChanged();
+ }
+}
+
+qreal QQuickControl::bottomPadding() const
+{
+ Q_D(const QQuickControl);
+ return d->bottomPadding;
+}
+
+void QQuickControl::setBottomPadding(qreal padding)
+{
+ Q_D(QQuickControl);
+ if (!qFuzzyCompare(d->bottomPadding, padding)) {
+ d->bottomPadding = padding;
+ emit bottomPaddingChanged();
+ }
}
/*!
diff --git a/src/controls/qquickcontrol_p.h b/src/controls/qquickcontrol_p.h
index de0def71..9b233660 100644
--- a/src/controls/qquickcontrol_p.h
+++ b/src/controls/qquickcontrol_p.h
@@ -54,20 +54,32 @@
QT_BEGIN_NAMESPACE
class QQuickStyle;
-class QQuickPadding;
class QQuickControlPrivate;
class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QQuickPadding *padding READ padding CONSTANT FINAL)
+ Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding NOTIFY topPaddingChanged FINAL)
+ Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding NOTIFY leftPaddingChanged FINAL)
+ Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding NOTIFY rightPaddingChanged FINAL)
+ Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding NOTIFY bottomPaddingChanged FINAL)
Q_PROPERTY(QQuickStyle *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
public:
explicit QQuickControl(QQuickItem *parent = Q_NULLPTR);
- QQuickPadding *padding() const;
+ qreal topPadding() const;
+ void setTopPadding(qreal padding);
+
+ qreal leftPadding() const;
+ void setLeftPadding(qreal padding);
+
+ qreal rightPadding() const;
+ void setRightPadding(qreal padding);
+
+ qreal bottomPadding() const;
+ void setBottomPadding(qreal padding);
QQuickStyle *style() const;
void setStyle(QQuickStyle *style);
@@ -87,6 +99,10 @@ public:
Q_SIGNALS:
void styleChanged();
void backgroundChanged();
+ void topPaddingChanged();
+ void leftPaddingChanged();
+ void rightPaddingChanged();
+ void bottomPaddingChanged();
protected:
QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent);
diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h
index 1b37d634..c16e59fe 100644
--- a/src/controls/qquickcontrol_p_p.h
+++ b/src/controls/qquickcontrol_p_p.h
@@ -50,7 +50,6 @@
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuickControls/private/qquickstyle_p.h>
-#include <QtQuickControls/private/qquickpadding_p.h>
QT_BEGIN_NAMESPACE
@@ -68,7 +67,10 @@ public:
QQuickStyle *style;
QBitArray attributes;
QQuickItem *background;
- mutable QQuickPadding *padding;
+ qreal topPadding;
+ qreal leftPadding;
+ qreal rightPadding;
+ qreal bottomPadding;
};
QT_END_NAMESPACE
diff --git a/src/controls/qquickpadding_p.h b/src/controls/qquickpadding_p.h
deleted file mode 100644
index 86a099b6..00000000
--- a/src/controls/qquickpadding_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKPADDING_P_H
-#define QQUICKPADDING_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_QUICKCONTROLS_EXPORT QQuickPadding : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal left MEMBER left NOTIFY leftChanged)
- Q_PROPERTY(qreal top MEMBER top NOTIFY topChanged)
- Q_PROPERTY(qreal right MEMBER right NOTIFY rightChanged)
- Q_PROPERTY(qreal bottom MEMBER bottom NOTIFY bottomChanged)
-
-public:
- QQuickPadding(QObject *parent = Q_NULLPTR) : QObject(parent),
- top(0), left(0), right(0), bottom(0)
- {
- }
-
- qreal top;
- qreal left;
- qreal right;
- qreal bottom;
-
-Q_SIGNALS:
- void leftChanged();
- void topChanged();
- void rightChanged();
- void bottomChanged();
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKPADDING_P_H
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 84a02f54..dc768fb1 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -61,7 +61,6 @@
#include <QtQuickControls/private/qquickcontrol_p.h>
#include <QtQuickControls/private/qquickexclusivegroup_p.h>
-#include <QtQuickControls/private/qquickpadding_p.h>
#include <QtQuickControls/private/qquickstyle_p.h>
void initResources()
@@ -112,7 +111,6 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickControl>(uri, 2, 0, "Control");
qmlRegisterType<QQuickExclusiveGroup>(uri, 2, 0, "ExclusiveGroup");
- qmlRegisterType<QQuickPadding>(uri, 2, 0, "Padding");
qmlRegisterType<QQuickStyle>(uri, 2, 0, "Style");
}