From 71d5afa10c297db4aabd032f992fb93fbaaf5470 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 13 Feb 2018 15:00:27 +0100 Subject: Add Popup::horizontal|verticalPadding This commit is just exposing the newly added Control properties in Popup. See the previous commit for details. [ChangeLog][Controls][Popup] Added horizontalPadding and verticalPadding properties as a convenient way to set both left and right, or top and bottom paddings in one go. Change-Id: I19a8190d323e63b5b3365aecdd81006cdd81f981 Reviewed-by: Mitch Curtis --- src/imports/templates/qtquicktemplates2plugin.cpp | 1 + src/quicktemplates2/qquickpopup.cpp | 86 ++++++++++++++++++++--- src/quicktemplates2/qquickpopup_p.h | 15 ++++ 3 files changed, 92 insertions(+), 10 deletions(-) diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 570aec0c..a67fca2c 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -328,6 +328,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) // QtQuick.Templates 2.5 (new types and revisions in Qt 5.12) qmlRegisterType(uri, 2, 5, "Control"); + qmlRegisterType(uri, 2, 5, "Popup"); qmlRegisterType(uri, 2, 5, "ToolTip"); } diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 1a4c90a4..0524c688 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -1285,11 +1285,12 @@ void QQuickPopup::resetPadding() /*! \qmlproperty real QtQuick.Controls::Popup::topPadding - This property holds the top padding. + This property holds the top padding. Unless explicitly set, the value + is equal to \c verticalPadding. \include qquickpopup-padding.qdocinc - \sa padding, bottomPadding, availableHeight + \sa padding, bottomPadding, verticalPadding, availableHeight */ qreal QQuickPopup::topPadding() const { @@ -1312,11 +1313,12 @@ void QQuickPopup::resetTopPadding() /*! \qmlproperty real QtQuick.Controls::Popup::leftPadding - This property holds the left padding. + This property holds the left padding. Unless explicitly set, the value + is equal to \c horizontalPadding. \include qquickpopup-padding.qdocinc - \sa padding, rightPadding, availableWidth + \sa padding, rightPadding, horizontalPadding, availableWidth */ qreal QQuickPopup::leftPadding() const { @@ -1339,11 +1341,12 @@ void QQuickPopup::resetLeftPadding() /*! \qmlproperty real QtQuick.Controls::Popup::rightPadding - This property holds the right padding. + This property holds the right padding. Unless explicitly set, the value + is equal to \c horizontalPadding. \include qquickpopup-padding.qdocinc - \sa padding, leftPadding, availableWidth + \sa padding, leftPadding, horizontalPadding, availableWidth */ qreal QQuickPopup::rightPadding() const { @@ -1366,11 +1369,12 @@ void QQuickPopup::resetRightPadding() /*! \qmlproperty real QtQuick.Controls::Popup::bottomPadding - This property holds the bottom padding. + This property holds the bottom padding. Unless explicitly set, the value + is equal to \c verticalPadding. \include qquickpopup-padding.qdocinc - \sa padding, topPadding, availableHeight + \sa padding, topPadding, verticalPadding, availableHeight */ qreal QQuickPopup::bottomPadding() const { @@ -2078,6 +2082,64 @@ void QQuickPopup::setExit(QQuickTransition *transition) emit exitChanged(); } +/*! + \since QtQuick.Controls 2.5 (Qt 5.12) + \qmlproperty real QtQuick.Controls::Popup::horizontalPadding + + This property holds the horizontal padding. Unless explicitly set, the value + is equal to \c padding. + + \include qquickpopup-padding.qdocinc + + \sa padding, leftPadding, rightPadding, verticalPadding +*/ +qreal QQuickPopup::horizontalPadding() const +{ + Q_D(const QQuickPopup); + return d->popupItem->horizontalPadding(); +} + +void QQuickPopup::setHorizontalPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->popupItem->setHorizontalPadding(padding); +} + +void QQuickPopup::resetHorizontalPadding() +{ + Q_D(QQuickPopup); + d->popupItem->resetHorizontalPadding(); +} + +/*! + \since QtQuick.Controls 2.5 (Qt 5.12) + \qmlproperty real QtQuick.Controls::Popup::verticalPadding + + This property holds the vertical padding. Unless explicitly set, the value + is equal to \c padding. + + \include qquickpopup-padding.qdocinc + + \sa padding, topPadding, bottomPadding, horizontalPadding +*/ +qreal QQuickPopup::verticalPadding() const +{ + Q_D(const QQuickPopup); + return d->popupItem->verticalPadding(); +} + +void QQuickPopup::setVerticalPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->popupItem->setVerticalPadding(padding); +} + +void QQuickPopup::resetVerticalPadding() +{ + Q_D(QQuickPopup); + d->popupItem->resetVerticalPadding(); +} + bool QQuickPopup::filtersChildMouseEvents() const { Q_D(const QQuickPopup); @@ -2328,10 +2390,14 @@ void QQuickPopup::paddingChange(const QMarginsF &newPadding, const QMarginsF &ol if (bp) emit bottomPaddingChanged(); - if (lp || rp) + if (lp || rp) { + emit horizontalPaddingChanged(); emit availableWidthChanged(); - if (tp || bp) + } + if (tp || bp) { + emit verticalPaddingChanged(); emit availableHeightChanged(); + } } void QQuickPopup::paletteChange(const QPalette &newPalette, const QPalette &oldPalette) diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h index 2a42ff27..9e2f3649 100644 --- a/src/quicktemplates2/qquickpopup_p.h +++ b/src/quicktemplates2/qquickpopup_p.h @@ -121,6 +121,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL REVISION 3) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL REVISION 3) Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) + // 2.5 (Qt 5.12) + Q_PROPERTY(qreal horizontalPadding READ horizontalPadding WRITE setHorizontalPadding RESET resetHorizontalPadding NOTIFY horizontalPaddingChanged FINAL) + Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding RESET resetVerticalPadding NOTIFY verticalPaddingChanged FINAL) Q_CLASSINFO("DeferredPropertyNames", "background,contentItem") Q_CLASSINFO("DefaultProperty", "contentData") @@ -304,6 +307,15 @@ public: void setPalette(const QPalette &palette); void resetPalette(); + // 2.5 (Qt 5.12) + qreal horizontalPadding() const; + void setHorizontalPadding(qreal padding); + void resetHorizontalPadding(); + + qreal verticalPadding() const; + void setVerticalPadding(qreal padding); + void resetVerticalPadding(); + public Q_SLOTS: void open(); void close(); @@ -359,6 +371,9 @@ Q_SIGNALS: Q_REVISION(3) void mirroredChanged(); Q_REVISION(3) void enabledChanged(); Q_REVISION(3) void paletteChanged(); + // 2.5 (Qt 5.12) + Q_REVISION(5) void horizontalPaddingChanged(); + Q_REVISION(5) void verticalPaddingChanged(); protected: QQuickPopup(QQuickPopupPrivate &dd, QObject *parent); -- cgit v1.2.3