diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-31 13:08:12 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-31 13:08:12 +0100 |
commit | 10972ca272ae59fbe0f18eef6d9237fbd4aaca86 (patch) | |
tree | 4c2766b234368b2e401dc955bd44faf8088deada | |
parent | e09a8591990e5281929ca2a7bb180bb3a35556ba (diff) | |
parent | 548b0bdd0f57c2209c8cbd7ac4ecda204cf69a2e (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
35 files changed, 340 insertions, 57 deletions
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml index c4b6c1a1..89c0c607 100644 --- a/examples/quickcontrols2/gallery/gallery.qml +++ b/examples/quickcontrols2/gallery/gallery.qml @@ -57,6 +57,15 @@ ApplicationWindow { property string style: "Default" } + Shortcut { + sequence: "Esc" + enabled: stackView.depth > 1 + onActivated: { + stackView.pop() + listView.currentIndex = -1 + } + } + header: ToolBar { Material.foreground: "white" @@ -126,6 +135,8 @@ ApplicationWindow { ListView { id: listView + + focus: true currentIndex: -1 anchors.fill: parent @@ -134,10 +145,8 @@ ApplicationWindow { text: model.title highlighted: ListView.isCurrentItem onClicked: { - if (listView.currentIndex != index) { - listView.currentIndex = index - stackView.push(model.source) - } + listView.currentIndex = index + stackView.push(model.source) drawer.close() } } diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml index 6bf30df0..5410afa9 100644 --- a/src/imports/controls/Button.qml +++ b/src/imports/controls/Button.qml @@ -70,7 +70,6 @@ T.Button { background: Rectangle { implicitWidth: 100 implicitHeight: 40 - opacity: enabled ? 1 : 0.3 visible: !control.flat || control.down || control.checked || control.highlighted color: control.checked || control.highlighted ? (control.visualFocus ? (control.down ? Default.buttonCheckedFocusColor : Default.focusColor) : (control.down ? Default.buttonCheckedPressedColor : Default.textColor)) : diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index dcfb54a7..38614b6a 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -51,7 +51,6 @@ T.CheckBox { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 //! [indicator] indicator: CheckIndicator { @@ -73,6 +72,7 @@ T.CheckBox { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml index b3d1b25e..9078e0c6 100644 --- a/src/imports/controls/CheckIndicator.qml +++ b/src/imports/controls/CheckIndicator.qml @@ -53,6 +53,7 @@ Rectangle { border.color: control.enabled ? (control.visualFocus ? Default.focusColor : (control.down ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : "transparent" + opacity: enabled ? 1 : 0.3 Image { x: (parent.width - width) / 2 diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 85a9cc13..f461b34e 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -55,8 +55,6 @@ T.ComboBox { leftPadding: padding + 6 rightPadding: padding + 6 - opacity: enabled ? 1 : 0.3 - //! [delegate] delegate: ItemDelegate { width: control.popup.width @@ -74,6 +72,7 @@ T.ComboBox { source: "image://default/double-arrow/" + (control.visualFocus ? Default.focusColor : Default.textColor) sourceSize.width: width sourceSize.height: height + opacity: enabled ? 1 : 0.3 } //! [indicator] @@ -88,6 +87,7 @@ T.ComboBox { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight + opacity: enabled ? 1 : 0.3 } //! [contentItem] diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 80e4e182..65c9328b 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -51,7 +51,6 @@ T.RadioButton { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 //! [indicator] indicator: RadioIndicator { @@ -73,6 +72,7 @@ T.RadioButton { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml index 43159e6c..15e6f9cf 100644 --- a/src/imports/controls/RadioIndicator.qml +++ b/src/imports/controls/RadioIndicator.qml @@ -48,6 +48,7 @@ Rectangle { : (control.visualFocus ? Default.focusLightColor : Default.backgroundColor) border.width: control.visualFocus ? 2 : 1 border.color: control.visualFocus ? Default.focusColor : (control.down ? Default.indicatorFramePressedColor : Default.indicatorFrameColor) + opacity: enabled ? 1 : 0.3 property Item control diff --git a/src/imports/controls/RangeSlider.qml b/src/imports/controls/RangeSlider.qml index 6b892fd1..e6b8b011 100644 --- a/src/imports/controls/RangeSlider.qml +++ b/src/imports/controls/RangeSlider.qml @@ -98,7 +98,6 @@ T.RangeSlider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: Default.buttonColor scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml index f7e95db9..bebd5591 100644 --- a/src/imports/controls/Slider.qml +++ b/src/imports/controls/Slider.qml @@ -77,7 +77,6 @@ T.Slider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: Default.buttonColor scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml index 0a562110..b9e2199e 100644 --- a/src/imports/controls/SpinBox.qml +++ b/src/imports/controls/SpinBox.qml @@ -139,7 +139,6 @@ T.SpinBox { //! [background] background: Rectangle { - opacity: control.enabled ? 1 : 0.3 implicitWidth: 140 border.color: Default.buttonColor } diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml index 37c23d80..362ebfef 100644 --- a/src/imports/controls/SwitchIndicator.qml +++ b/src/imports/controls/SwitchIndicator.qml @@ -49,7 +49,6 @@ Item { width: 56 height: 16 radius: 8 - opacity: control.enabled ? 1 : 0.3 color: control.checked ? (control.visualFocus ? Default.focusColor : Default.buttonCheckedColor) : Default.buttonColor border.width: control.visualFocus ? 2 : 0 border.color: Default.focusColor diff --git a/src/imports/controls/material/images/drop-indicator.png b/src/imports/controls/material/images/drop-indicator.png Binary files differindex b4396ec6..08bb4855 100644 --- a/src/imports/controls/material/images/drop-indicator.png +++ b/src/imports/controls/material/images/drop-indicator.png diff --git a/src/imports/controls/material/images/drop-indicator.svg b/src/imports/controls/material/images/drop-indicator.svg new file mode 100644 index 00000000..94b5ca15 --- /dev/null +++ b/src/imports/controls/material/images/drop-indicator.svg @@ -0,0 +1,5 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" version="1.1"> + <path d="M7,10l5,5,5-5z" fill="#757575"/> +</svg> diff --git a/src/imports/controls/material/images/drop-indicator@2x.png b/src/imports/controls/material/images/drop-indicator@2x.png Binary files differindex 1c711bc2..ccdfc2b1 100644 --- a/src/imports/controls/material/images/drop-indicator@2x.png +++ b/src/imports/controls/material/images/drop-indicator@2x.png diff --git a/src/imports/controls/material/images/drop-indicator@3x.png b/src/imports/controls/material/images/drop-indicator@3x.png Binary files differindex 06dd8bd2..00cae691 100644 --- a/src/imports/controls/material/images/drop-indicator@3x.png +++ b/src/imports/controls/material/images/drop-indicator@3x.png diff --git a/src/imports/controls/material/images/drop-indicator@4x.png b/src/imports/controls/material/images/drop-indicator@4x.png Binary files differindex b2157c30..0a61cb01 100644 --- a/src/imports/controls/material/images/drop-indicator@4x.png +++ b/src/imports/controls/material/images/drop-indicator@4x.png diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp index 0d2f8a70..1967a74b 100644 --- a/src/imports/controls/material/qquickmaterialtheme.cpp +++ b/src/imports/controls/material/qquickmaterialtheme.cpp @@ -45,15 +45,15 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { QFont font; - font.setFamily(QStringLiteral("Roboto")); + font.setFamily(QLatin1String("Roboto")); QString family = QFontInfo(font).family(); - if (family != QStringLiteral("Roboto")) { - font.setFamily(QStringLiteral("Noto")); + if (family != QLatin1String("Roboto")) { + font.setFamily(QLatin1String("Noto")); family = QFontInfo(font).family(); } - if (family == QStringLiteral("Roboto") || family == QStringLiteral("Noto")) { + if (family == QLatin1String("Roboto") || family == QLatin1String("Noto")) { systemFont.setFamily(family); buttonFont.setFamily(family); toolTipFont.setFamily(family); diff --git a/src/imports/controls/universal/qquickuniversaltheme.cpp b/src/imports/controls/universal/qquickuniversaltheme.cpp index 51642c4a..dc516b45 100644 --- a/src/imports/controls/universal/qquickuniversaltheme.cpp +++ b/src/imports/controls/universal/qquickuniversaltheme.cpp @@ -44,8 +44,8 @@ QT_BEGIN_NAMESPACE QQuickUniversalTheme::QQuickUniversalTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { - const QFont font(QStringLiteral("Segoe UI")); - if (QFontInfo(font).family() == QStringLiteral("Segoe UI")) { + const QFont font(QLatin1String("Segoe UI")); + if (QFontInfo(font).family() == QLatin1String("Segoe UI")) { const QString family = font.family(); systemFont.setFamily(family); groupBoxTitleFont.setFamily(family); 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 { diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index c81c6341..982ac7ab 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1229,4 +1229,35 @@ TestCase { control.destroy() } + + Component { + id: xyBindingLoop + ApplicationWindow { + id: window + width: 360 + height: 360 + visible: true + property alias popup: popup + + Popup { + id: popup + visible: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + Label { + text: "Content" + anchors.fill: parent + } + } + } + } + + function test_xyBindingLoop() { + var window = xyBindingLoop.createObject(testCase) + var control = window.popup + waitForRendering(control.contentItem) + compare(control.x, (control.parent.width - control.width) / 2) + compare(control.y, (control.parent.height - control.height) / 2) + window.destroy() + } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 15b4b3f0..54ecf15f 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -155,6 +155,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index 551247f6..1ec03b15 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -150,6 +150,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 58a5ba3c..a523beed 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -380,7 +380,7 @@ void tst_Drawer::reposition() window->setWidth(window->width() + 100); QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QCOMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); drawer->close(); QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); diff --git a/tests/manual/testbench/main.cpp b/tests/manual/testbench/main.cpp index a782b5fe..5a54dab3 100644 --- a/tests/manual/testbench/main.cpp +++ b/tests/manual/testbench/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // TODO: move style selection into app UI and use settings to save choices. // qputenv("QT_QUICK_CONTROLS_STYLE", "material"); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/testbench.qml"))); return app.exec(); } diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index 5f6483ac..9f4b1783 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -1,5 +1,5 @@ <RCC> <qresource prefix="/"> - <file>main.qml</file> + <file>testbench.qml</file> </qresource> </RCC> diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/testbench.qml index ea59d5b5..38fd06fc 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/testbench.qml @@ -745,14 +745,14 @@ ApplicationWindow { Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 } } Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 enabled: false } @@ -761,11 +761,147 @@ ApplicationWindow { RowLayout { Dial { + implicitWidth: 100 + implicitHeight: 100 } Dial { + implicitWidth: 100 + implicitHeight: 100 enabled: false } } + + ListModel { + id: checkableDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Checked"; check: true } + ListElement { label: "CH + PR"; check: true; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: CheckDelegate { + text: label + width: parent.width + down: press + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + ButtonGroup { + id: radioButtonGroup + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: RadioDelegate { + text: label + down: press + width: parent.width + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: SwitchDelegate { + text: label + width: parent.width + checked: check + down: press + enabled: !disabled + } + } + } + } + } + + ListModel { + id: regularDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: regularDelegateModel + delegate: ItemDelegate { + text: label + width: parent.width + down: press + enabled: !disabled + } + } + } + } + Frame { + Column { + id: listView + width: 200 + clip: true + + Repeater { + model: regularDelegateModel + delegate: SwipeDelegate { + id: swipeDelegate + text: label + width: parent.width + down: press + enabled: !disabled + + Component { + id: removeComponent + + Rectangle { + color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" + width: parent.width + height: parent.height + clip: true + + Label { + font.pixelSize: swipeDelegate.font.pixelSize + text: "Boop" + color: "white" + anchors.centerIn: parent + } + } + } + + swipe.left: removeComponent + swipe.right: removeComponent + } + } + } + } + } } } } |