aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-31 13:08:12 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-31 13:08:12 +0100
commit10972ca272ae59fbe0f18eef6d9237fbd4aaca86 (patch)
tree4c2766b234368b2e401dc955bd44faf8088deada /src/quicktemplates2
parente09a8591990e5281929ca2a7bb180bb3a35556ba (diff)
parent548b0bdd0f57c2209c8cbd7ac4ecda204cf69a2e (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/imports/controls/CheckIndicator.qml src/imports/controls/RadioIndicator.qml src/imports/controls/RangeSlider.qml src/imports/controls/Slider.qml src/imports/controls/SwitchIndicator.qml Change-Id: I32612d2f905ffa02dbaedbb1f84c8237fbd66db3
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp18
-rw-r--r--src/quicktemplates2/qquickgroupbox.cpp4
-rw-r--r--src/quicktemplates2/qquicklabel.cpp2
-rw-r--r--src/quicktemplates2/qquickpopup.cpp16
-rw-r--r--src/quicktemplates2/qquickpopup_p_p.h3
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp33
-rw-r--r--src/quicktemplates2/qquickscrollindicator.cpp33
-rw-r--r--src/quicktemplates2/qquickswitch.cpp14
-rw-r--r--src/quicktemplates2/qquickswitchdelegate.cpp8
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp8
10 files changed, 106 insertions, 33 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index f15d65ad..423e7513 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -156,7 +156,9 @@ QT_BEGIN_NAMESPACE
the drawer is opened, don't apply a translation.
\note On some platforms, certain edges may be reserved for system
- gestures and therefore cannot be used with Drawer.
+ gestures and therefore cannot be used with Drawer. For example, the
+ top and bottom edges may be reserved for system notifications and
+ control centers on Android and iOS.
\sa SwipeView, {Customizing Drawer}, {Navigation Controls}, {Popup Controls}
*/
@@ -481,13 +483,13 @@ QQuickDrawer::QQuickDrawer(QObject *parent) :
/*!
\qmlproperty enumeration QtQuick.Controls::Drawer::edge
- This property holds the edge of the content item at which the drawer will
+ This property holds the edge of the window at which the drawer will
open from. The acceptable values are:
- \value Qt.TopEdge The top edge of the content item.
- \value Qt.LeftEdge The left edge of the content item (default).
- \value Qt.RightEdge The right edge of the content item.
- \value Qt.BottomEdge The bottom edge of the content item.
+ \value Qt.TopEdge The top edge of the window.
+ \value Qt.LeftEdge The left edge of the window (default).
+ \value Qt.RightEdge The right edge of the window.
+ \value Qt.BottomEdge The bottom edge of the window.
*/
Qt::Edge QQuickDrawer::edge() const
{
@@ -511,8 +513,8 @@ void QQuickDrawer::setEdge(Qt::Edge edge)
\qmlproperty real QtQuick.Controls::Drawer::position
This property holds the position of the drawer relative to its final
- destination. That is, the position will be \c 0 when the drawer
- is fully closed, and \c 1 when fully open.
+ destination. That is, the position will be \c 0.0 when the drawer
+ is fully closed, and \c 1.0 when fully open.
*/
qreal QQuickDrawer::position() const
{
diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp
index 27c325ef..5a5a8005 100644
--- a/src/quicktemplates2/qquickgroupbox.cpp
+++ b/src/quicktemplates2/qquickgroupbox.cpp
@@ -56,8 +56,8 @@ QT_BEGIN_NAMESPACE
or a \l ColumnLayout.
Items declared as children of a GroupBox are automatically parented to the
- GroupBox's contentItem. Items created dynamically need to be explicitly
- parented to the contentItem.
+ GroupBox's \l {Control::}{contentItem}. Items created dynamically need to be
+ explicitly parented to the contentItem.
If only a single item is used within a GroupBox, it will resize to fit the
implicit size of its contained item. This makes it particularly suitable
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index 03bed16f..b3596022 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-label.qml 1
- You can use the properties of Text to change the appearance of the text as desired:
+ You can use the properties of \l Text to change the appearance of the text as desired:
\qml
Label {
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 63a9a0d9..660811bd 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -128,6 +128,7 @@ QQuickPopupPrivate::QQuickPopupPrivate()
, hasDim(false)
, visible(false)
, complete(false)
+ , positioning(false)
, hasWidth(false)
, hasHeight(false)
, hasTopMargin(false)
@@ -411,6 +412,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents);
}
+void QQuickPopupItem::updatePolish()
+{
+ Q_D(QQuickPopupItem);
+ return QQuickPopupPrivate::get(d->popup)->reposition();
+}
+
bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
{
Q_D(QQuickPopupItem);
@@ -611,6 +618,11 @@ void QQuickPopupPrivate::reposition()
if (!popupItem->isVisible())
return;
+ if (positioning) {
+ popupItem->polish();
+ return;
+ }
+
const qreal w = popupItem->width();
const qreal h = popupItem->height();
const qreal iw = popupItem->implicitWidth();
@@ -719,6 +731,8 @@ void QQuickPopupPrivate::reposition()
}
}
+ positioning = true;
+
popupItem->setPosition(rect.topLeft());
const QPointF effectivePos = parentItem ? parentItem->mapFromScene(rect.topLeft()) : rect.topLeft();
@@ -735,6 +749,8 @@ void QQuickPopupPrivate::reposition()
popupItem->setWidth(rect.width());
if (!hasHeight && heightAdjusted && rect.height() > 0)
popupItem->setHeight(rect.height());
+
+ positioning = false;
}
void QQuickPopupPrivate::resizeOverlay()
diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h
index 7675b151..d3239e91 100644
--- a/src/quicktemplates2/qquickpopup_p_p.h
+++ b/src/quicktemplates2/qquickpopup_p_p.h
@@ -87,6 +87,8 @@ public:
explicit QQuickPopupItem(QQuickPopup *popup);
protected:
+ void updatePolish() override;
+
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
@@ -186,6 +188,7 @@ public:
bool hasDim;
bool visible;
bool complete;
+ bool positioning;
bool hasWidth;
bool hasHeight;
bool hasTopMargin;
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index ebccbcba..06cc8832 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE
}
\endcode
- \note When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or
- \l {ScrollBar::horizontal}{horizontally} to a Flickable, its geometry and
- the following properties are automatically set and updated as appropriate:
+ When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or
+ \l {ScrollBar::horizontal}{horizontally} to a Flickable, the following
+ properties are automatically set and updated as appropriate:
\list
\li \l orientation
\li \l position
@@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE
\li \l active
\endlist
+ An attached ScrollBar re-parents itself to the target Flickable. A vertically
+ attached ScrollBar resizes itself to the height of the Flickable, and positions
+ itself to either side of it based on the \l {Control::mirrored}{layout direction}.
+ A horizontally attached ScrollBar resizes itself to the width of the Flickable,
+ and positions itself to the bottom. The automatic geometry management can be disabled
+ by specifying another parent for the attached ScrollBar. This can be useful, for
+ example, if the ScrollBar should be placed outside a clipping Flickable. This is
+ demonstrated by the following example:
+
+ \code
+ Flickable {
+ id: flickable
+ clip: true
+ // ...
+ ScrollBar.vertical: ScrollBar {
+ parent: flickable.parent
+ anchors.top: flickable.top
+ anchors.left: flickable.right
+ anchors.bottom: flickable.bottom
+ }
+ }
+ \endcode
+
Notice that ScrollBar does not filter key events of the Flickable it is
attached to. The following example illustrates how to implement scrolling
with up and down keys:
@@ -477,6 +500,8 @@ void QQuickScrollBarAttachedPrivate::mirrorVertical()
void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move)
{
Q_ASSERT(horizontal && flickable);
+ if (horizontal->parentItem() != flickable)
+ return;
horizontal->setWidth(flickable->width());
if (move)
horizontal->setY(flickable->height() - horizontal->height());
@@ -485,6 +510,8 @@ void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move)
void QQuickScrollBarAttachedPrivate::layoutVertical(bool move)
{
Q_ASSERT(vertical && flickable);
+ if (vertical->parentItem() != flickable)
+ return;
vertical->setHeight(flickable->height());
if (move)
vertical->setX(vertical->isMirrored() ? 0 : flickable->width() - vertical->width());
diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp
index b1a3e4ec..6145a5b3 100644
--- a/src/quicktemplates2/qquickscrollindicator.cpp
+++ b/src/quicktemplates2/qquickscrollindicator.cpp
@@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE
}
\endcode
- \note When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically}
- or \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, its geometry and
- the following properties are automatically set and updated as appropriate:
+ When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically} or
+ \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, the following
+ properties are automatically set and updated as appropriate:
\list
\li \l orientation
\li \l position
@@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE
\li \l active
\endlist
+ An attached ScrollIndicator re-parents itself to the target Flickable. A vertically
+ attached ScrollIndicator resizes itself to the height of the Flickable, and positions
+ itself to either side of it based on the \l {Control::mirrored}{layout direction}.
+ A horizontally attached ScrollIndicator resizes itself to the width of the Flickable,
+ and positions itself to the bottom. The automatic geometry management can be disabled
+ by specifying another parent for the attached ScrollIndicator. This can be useful, for
+ example, if the ScrollIndicator should be placed outside a clipping Flickable. This is
+ demonstrated by the following example:
+
+ \code
+ Flickable {
+ id: flickable
+ clip: true
+ // ...
+ ScrollIndicator.vertical: ScrollIndicator {
+ parent: flickable.parent
+ anchors.top: flickable.top
+ anchors.left: flickable.right
+ anchors.bottom: flickable.bottom
+ }
+ }
+ \endcode
+
Horizontal and vertical scroll indicators do not share the \l active state with
each other by default. In order to keep both indicators visible whilst scrolling
to either direction, establish a two-way binding between the active states as
@@ -268,6 +291,8 @@ void QQuickScrollIndicatorAttachedPrivate::activateVertical()
void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move)
{
Q_ASSERT(horizontal && flickable);
+ if (horizontal->parentItem() != flickable)
+ return;
horizontal->setWidth(flickable->width());
if (move)
horizontal->setY(flickable->height() - horizontal->height());
@@ -276,6 +301,8 @@ void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move)
void QQuickScrollIndicatorAttachedPrivate::layoutVertical(bool move)
{
Q_ASSERT(vertical && flickable);
+ if (vertical->parentItem() != flickable)
+ return;
vertical->setHeight(flickable->height());
if (move && !QQuickItemPrivate::get(vertical)->isMirrored())
vertical->setX(flickable->width() - vertical->width());
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index a7d17e86..8c3d9f0b 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -57,17 +57,11 @@ QT_BEGIN_NAMESPACE
Switch is an option button that can be dragged or toggled on (checked) or
off (unchecked). Switches are typically used to select between two states.
+ For larger sets of options, such as those in a list, consider using
+ \l SwitchDelegate instead.
- \table
- \row \li \image qtquickcontrols2-switch-normal.png
- \li A switch in its normal state.
- \row \li \image qtquickcontrols2-switch-checked.png
- \li A switch that is checked.
- \row \li \image qtquickcontrols2-switch-focused.png
- \li A switch that has active focus.
- \row \li \image qtquickcontrols2-switch-disabled.png
- \li A switch that is disabled.
- \endtable
+ Switch inherits its API from \l AbstractButton. For instance, the state
+ of the switch can be set with the \l {AbstractButton::}{checked} property.
\code
ColumnLayout {
diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp
index 62b677e5..edfb15d5 100644
--- a/src/quicktemplates2/qquickswitchdelegate.cpp
+++ b/src/quicktemplates2/qquickswitchdelegate.cpp
@@ -53,9 +53,13 @@ QT_BEGIN_NAMESPACE
SwitchDelegate presents an item delegate that can be toggled on (checked) or
off (unchecked). Switch delegates are typically used to select one or more
- options from a set of options.
+ options from a set of options. For smaller sets of options, or for options
+ that need to be uniquely identifiable, consider using \l Switch instead.
- The state of the check delegate can be set with the
+ SwitchDelegate inherits its API from \l ItemDelegate, which is inherited
+ from \l AbstractButton. For instance, you can set \l {AbstractButton::text}{text},
+ and react to \l {AbstractButton::clicked}{clicks} using the \l AbstractButton
+ API. The state of the switch delegate can be set with the
\l {AbstractButton::}{checked} property.
\code
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 9a5590a5..7d15a428 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -79,6 +79,8 @@ QT_BEGIN_NAMESPACE
decoration of the TextArea scrolls together with the rest of the scrollable
content.
+ \section2 Scrollable TextArea
+
If you want to make a TextArea scrollable, for example, when it covers
an entire application page, attach it to a \l Flickable and combine with a
\l ScrollBar or \l ScrollIndicator.
@@ -87,7 +89,7 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-textarea-flickable.qml 1
- A TextArea that is attached to a Flickable does the following:
+ A TextArea that is attached to a \l Flickable does the following:
\list
\li Sets the content size automatically
@@ -755,9 +757,7 @@ QQuickTextAreaAttached::~QQuickTextAreaAttached()
This property attaches a text area to a \l Flickable.
- \snippet qtquickcontrols2-textarea-flickable.qml 1
-
- \sa ScrollBar, ScrollIndicator
+ \sa ScrollBar, ScrollIndicator, {Scrollable TextArea}
*/
QQuickTextArea *QQuickTextAreaAttached::flickable() const
{