aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-05-04 00:17:21 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-09 10:37:34 +0000
commit09706e8f9fc481d848a3616cace58baf5bc8b67c (patch)
tree53addd2a72e4c08302774929dd54bf246344814c /src/quicktemplates2
parentb4cc1fc862df43d9fed90b25ee2a9ef6692d2a5a (diff)
Popup: expose flip API
[ChangeLog][Popup] Added allowVerticalFlip and allowHorizontalFlip properties to control whether flipping is allowed to fit a popup inside the window. Change-Id: Id14a8846a1e2d07e98207da7c2b2765c202dbaf9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp2
-rw-r--r--src/quicktemplates2/qquickpopup.cpp58
-rw-r--r--src/quicktemplates2/qquickpopup_p.h10
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp5
4 files changed, 71 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index cce61509..c70f8839 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -651,7 +651,7 @@ void QQuickComboBox::setPopup(QQuickPopup *popup)
delete d->popup;
if (popup) {
- QQuickPopupPrivate::get(popup)->allowVerticalFlip = true;
+ popup->setAllowVerticalFlip(true);
popup->setClosePolicy(QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutsideParent);
}
d->popup = popup;
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 2c661a1b..d1b7f85c 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -1324,6 +1324,64 @@ void QQuickPopup::resetBottomPadding()
}
/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::Popup::allowVerticalFlip
+
+ This property holds whether the popup is allowed to flip vertically.
+
+ A popup can be flipped from above its parent item to below it, or vice
+ versa, in order to make the popup fit inside the window.
+
+ The default value is \c false.
+
+ \sa allowHorizontalFlip
+*/
+bool QQuickPopup::allowVerticalFlip() const
+{
+ Q_D(const QQuickPopup);
+ return d->allowVerticalFlip;
+}
+
+void QQuickPopup::setAllowVerticalFlip(bool allow)
+{
+ Q_D(QQuickPopup);
+ if (d->allowVerticalFlip == allow)
+ return;
+
+ d->allowVerticalFlip = allow;
+ emit allowVerticalFlipChanged();
+}
+
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::Popup::allowHorizontalFlip
+
+ This property holds whether the popup is allowed to flip horizontally.
+
+ A popup can be flipped from the left side of its parent item to the right
+ side, or vice versa, in order to make the popup fit inside the window.
+
+ The default value is \c false.
+
+ \sa allowVerticalFlip
+*/
+bool QQuickPopup::allowHorizontalFlip() const
+{
+ Q_D(const QQuickPopup);
+ return d->allowHorizontalFlip;
+}
+
+void QQuickPopup::setAllowHorizontalFlip(bool allow)
+{
+ Q_D(QQuickPopup);
+ if (d->allowHorizontalFlip == allow)
+ return;
+
+ d->allowHorizontalFlip = allow;
+ emit allowHorizontalFlipChanged();
+}
+
+/*!
\qmlproperty Locale QtQuick.Controls::Popup::locale
This property holds the locale of the popup.
diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
index be6a8e22..1f2cabcf 100644
--- a/src/quicktemplates2/qquickpopup_p.h
+++ b/src/quicktemplates2/qquickpopup_p.h
@@ -94,6 +94,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL)
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL)
+ Q_PROPERTY(bool allowVerticalFlip READ allowVerticalFlip WRITE setAllowVerticalFlip NOTIFY allowVerticalFlipChanged FINAL REVISION 1)
+ Q_PROPERTY(bool allowHorizontalFlip READ allowHorizontalFlip WRITE setAllowHorizontalFlip NOTIFY allowHorizontalFlipChanged FINAL REVISION 1)
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL)
Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL)
Q_PROPERTY(QQuickItem *parent READ parentItem WRITE setParentItem NOTIFY parentChanged FINAL)
@@ -194,6 +196,12 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
+ bool allowVerticalFlip() const;
+ void setAllowVerticalFlip(bool allow);
+
+ bool allowHorizontalFlip() const;
+ void setAllowHorizontalFlip(bool allow);
+
QLocale locale() const;
void setLocale(const QLocale &locale);
void resetLocale();
@@ -303,6 +311,8 @@ Q_SIGNALS:
void leftPaddingChanged();
void rightPaddingChanged();
void bottomPaddingChanged();
+ Q_REVISION(1) void allowVerticalFlipChanged();
+ Q_REVISION(1) void allowHorizontalFlipChanged();
void fontChanged();
void localeChanged();
void parentChanged();
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 9cc9a0d9..42ae8edd 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -163,9 +163,8 @@ void QQuickToolTipPrivate::stopTimeout()
QQuickToolTip::QQuickToolTip(QQuickItem *parent) :
QQuickPopup(*(new QQuickToolTipPrivate), parent)
{
- Q_D(QQuickToolTip);
- d->allowVerticalFlip = true;
- d->allowHorizontalFlip = true;
+ setAllowVerticalFlip(true);
+ setAllowHorizontalFlip(true);
}
/*!