aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-03 18:20:15 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-03 19:20:42 +0100
commit6c88fe58a6037d252f40bf00aa5052b0f724a862 (patch)
tree9afdf0b638bc89e5e71eeac7b3c06ed53831e45b /src/quicktemplates2
parent83cbe4e899d2d22e923bdc10e90f91ef106edf58 (diff)
parent3f646aca34c25f7cc36df2f988790bb238026422 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/imports/controls/BusyIndicator.qml src/imports/controls/ProgressBar.qml src/quicktemplates2/qquickpopup.cpp src/quicktemplates2/qquickpopup_p_p.h src/quicktemplates2/qquickstackview.cpp Change-Id: I9a1028a991de9fc3e26d3f973106301e9ada631c
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp2
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp67
-rw-r--r--src/quicktemplates2/qquickbusyindicator.cpp14
-rw-r--r--src/quicktemplates2/qquickbutton.cpp2
-rw-r--r--src/quicktemplates2/qquickbuttongroup.cpp2
-rw-r--r--src/quicktemplates2/qquickcheckbox.cpp2
-rw-r--r--src/quicktemplates2/qquickcheckdelegate.cpp2
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp211
-rw-r--r--src/quicktemplates2/qquickcombobox_p.h5
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp2
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp2
-rw-r--r--src/quicktemplates2/qquickdial.cpp4
-rw-r--r--src/quicktemplates2/qquickdialog.cpp19
-rw-r--r--src/quicktemplates2/qquickdialog_p.h5
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp16
-rw-r--r--src/quicktemplates2/qquickframe.cpp9
-rw-r--r--src/quicktemplates2/qquickframe_p.h4
-rw-r--r--src/quicktemplates2/qquickgroupbox.cpp19
-rw-r--r--src/quicktemplates2/qquickgroupbox_p.h5
-rw-r--r--src/quicktemplates2/qquickitemdelegate.cpp2
-rw-r--r--src/quicktemplates2/qquicklabel.cpp2
-rw-r--r--src/quicktemplates2/qquickmenu.cpp2
-rw-r--r--src/quicktemplates2/qquickmenuitem.cpp2
-rw-r--r--src/quicktemplates2/qquickpage.cpp12
-rw-r--r--src/quicktemplates2/qquickpage_p.h1
-rw-r--r--src/quicktemplates2/qquickpopup.cpp203
-rw-r--r--src/quicktemplates2/qquickpopup_p.h7
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp59
-rw-r--r--src/quicktemplates2/qquickpopupitem_p_p.h5
-rw-r--r--src/quicktemplates2/qquickprogressbar.cpp24
-rw-r--r--src/quicktemplates2/qquickradiobutton.cpp2
-rw-r--r--src/quicktemplates2/qquickradiodelegate.cpp2
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp2
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp53
-rw-r--r--src/quicktemplates2/qquickscrollindicator.cpp45
-rw-r--r--src/quicktemplates2/qquickshortcutcontext.cpp83
-rw-r--r--src/quicktemplates2/qquickshortcutcontext_p_p.h65
-rw-r--r--src/quicktemplates2/qquickslider.cpp2
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp13
-rw-r--r--src/quicktemplates2/qquickstackview.cpp7
-rw-r--r--src/quicktemplates2/qquickstackview_p.h4
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp12
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp9
-rw-r--r--src/quicktemplates2/qquickswipeview_p.h4
-rw-r--r--src/quicktemplates2/qquickswitch.cpp2
-rw-r--r--src/quicktemplates2/qquickswitchdelegate.cpp2
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp13
-rw-r--r--src/quicktemplates2/qquicktabbutton.cpp2
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp2
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp2
-rw-r--r--src/quicktemplates2/qquicktoolbar.cpp19
-rw-r--r--src/quicktemplates2/qquicktoolbutton.cpp6
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp26
-rw-r--r--src/quicktemplates2/qquicktooltip_p.h1
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp2
-rw-r--r--src/quicktemplates2/quicktemplates2.pri2
56 files changed, 932 insertions, 161 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index ce75a497..e7c34065 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -56,7 +56,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief Base type of all button controls.
+ \brief Abstract base type providing functionality common to buttons.
AbstractButton provides the interface for controls with button-like
behavior; for example, push buttons and checkable controls like
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index 7f65b8bf..87dc8816 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief Provides a top-level application window.
+ \brief Styled top-level window with support for a header and footer.
ApplicationWindow is a \l Window which makes it convenient to add
a \l header and \l footer item to the window.
@@ -90,10 +90,45 @@ QT_BEGIN_NAMESPACE
ApplicationWindow supports popups via its \l overlay property, which
ensures that popups are displayed above other content and that the
- background is dimmed when a modal popup is visible.
+ background is dimmed when a \l {Popup::}{modal} or \l {Popup::dim}
+ {dimmed} popup is visible.
\note By default, an ApplicationWindow is not visible.
+ \section2 Attached ApplicationWindow Properties
+
+ Due to how \l {Scope and Naming Resolution} works in QML, it is possible
+ to reference the \c id of the application root element anywhere in its
+ child QML objects. Even though this approach is fine for many applications
+ and use cases, for a generic QML component it may not be acceptable as it
+ creates a dependency to the surrounding environment.
+
+ ApplicationWindow provides a set of attached properties that can be used
+ to access the window and its building blocks from places where no direct
+ access to the window is available, without creating a dependency to a
+ certain window \c id. A QML component that uses the ApplicationWindow
+ attached properties works in any window regardless of its \c id. The
+ following example uses the attached \c overlay property to position the
+ popup to the center of the window, despite the position of the button
+ that opens the popup.
+
+ \code
+ Button {
+ onClicked: popup.open()
+
+ Popup {
+ id: popup
+
+ parent: ApplicationWindow.overlay
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 100
+ height: 100
+ }
+ }
+ \endcode
+
\sa {Customizing ApplicationWindow}, Page, {Container Controls}
*/
@@ -315,6 +350,14 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background)
This property holds the window header item. The header item is positioned to
the top, and resized to the width of the window. The default value is \c null.
+ \code
+ ApplicationWindow {
+ header: TabBar {
+ // ...
+ }
+ }
+ \endcode
+
\note Assigning a ToolBar, TabBar, or DialogButtonBox as a window header
automatically sets the respective \l ToolBar::position, \l TabBar::position,
or \l DialogButtonBox::position property to \c Header.
@@ -364,6 +407,14 @@ void QQuickApplicationWindow::setHeader(QQuickItem *header)
This property holds the window footer item. The footer item is positioned to
the bottom, and resized to the width of the window. The default value is \c null.
+ \code
+ ApplicationWindow {
+ footer: ToolBar {
+ // ...
+ }
+ }
+ \endcode
+
\note Assigning a ToolBar, TabBar, or DialogButtonBox as a window footer
automatically sets the respective \l ToolBar::position, \l TabBar::position,
or \l DialogButtonBox::position property to \c Footer.
@@ -726,6 +777,8 @@ QQuickApplicationWindowAttached::QQuickApplicationWindowAttached(QObject *parent
This attached property holds the application window. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickApplicationWindow *QQuickApplicationWindowAttached::window() const
{
@@ -739,6 +792,8 @@ QQuickApplicationWindow *QQuickApplicationWindowAttached::window() const
This attached property holds the window content item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::contentItem() const
{
@@ -757,7 +812,7 @@ QQuickItem *QQuickApplicationWindowAttached::contentItem() const
The value is \c null if the item is not in an ApplicationWindow, or the window has
no active focus.
- \sa Window::activeFocusItem
+ \sa Window::activeFocusItem, {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
{
@@ -774,6 +829,8 @@ QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
This attached property holds the window header item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow, or
the window has no header item.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::header() const
{
@@ -790,6 +847,8 @@ QQuickItem *QQuickApplicationWindowAttached::header() const
This attached property holds the window footer item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow, or
the window has no footer item.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::footer() const
{
@@ -805,6 +864,8 @@ QQuickItem *QQuickApplicationWindowAttached::footer() const
This attached property holds the window overlay item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickOverlay *QQuickApplicationWindowAttached::overlay() const
{
diff --git a/src/quicktemplates2/qquickbusyindicator.cpp b/src/quicktemplates2/qquickbusyindicator.cpp
index 73181ec7..2cd3f62d 100644
--- a/src/quicktemplates2/qquickbusyindicator.cpp
+++ b/src/quicktemplates2/qquickbusyindicator.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-indicators
- \brief Indicates activity while content is being loaded.
+ \brief Indicates background activity, for example, while content is being loaded.
\image qtquickcontrols2-busyindicator.gif
@@ -61,6 +61,18 @@ QT_BEGIN_NAMESPACE
}
\endqml
+ BusyIndicator is similar to an indeterminate \l ProgressBar. Both can be
+ used to indicate background activity. The main difference is visual, and
+ that ProgressBar can also present a concrete amount of progress (when it
+ can be determined). Due to the visual difference, busy indicators and
+ indeterminate progress bars fit different places in user interfaces.
+ Typical places for a busy indicator:
+ \list
+ \li in the corner of a \l ToolBar
+ \li as an overlay on top of a \l Page
+ \li on the side of an \l ItemDelegate
+ \endlist
+
\sa {Customizing BusyIndicator}, {Indicator Controls}, ProgressBar
*/
diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp
index ca85b008..3d00e40c 100644
--- a/src/quicktemplates2/qquickbutton.cpp
+++ b/src/quicktemplates2/qquickbutton.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief A push-button control that can be clicked by the user.
+ \brief Push-button that can be clicked to perform a command or answer a question.
\image qtquickcontrols2-button.gif
diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp
index 9630cbaf..89941c19 100644
--- a/src/quicktemplates2/qquickbuttongroup.cpp
+++ b/src/quicktemplates2/qquickbuttongroup.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup utilities
- \brief A mutually-exclusive group of checkable controls.
+ \brief Mutually-exclusive group of checkable buttons.
ButtonGroup is a non-visual, mutually exclusive group of buttons.
It is used with controls such as RadioButton, where only one of the options
diff --git a/src/quicktemplates2/qquickcheckbox.cpp b/src/quicktemplates2/qquickcheckbox.cpp
index ae967c34..fd5ab6ba 100644
--- a/src/quicktemplates2/qquickcheckbox.cpp
+++ b/src/quicktemplates2/qquickcheckbox.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief An option button that can be checked or unchecked.
+ \brief Check button that can be toggled on or off.
\image qtquickcontrols2-checkbox.gif
diff --git a/src/quicktemplates2/qquickcheckdelegate.cpp b/src/quicktemplates2/qquickcheckdelegate.cpp
index 304d2b6c..51bc8501 100644
--- a/src/quicktemplates2/qquickcheckdelegate.cpp
+++ b/src/quicktemplates2/qquickcheckdelegate.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-delegates
- \brief An item delegate that can be checked or unchecked.
+ \brief Item delegate with a check indicator that can be toggled on or off.
\image qtquickcontrols2-checkdelegate.gif
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 3aa67688..a0fcbe8c 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A combined button and popup list taking minimal space.
+ \brief Combined button and popup list for selecting options.
\image qtquickcontrols2-combobox.gif
@@ -130,6 +130,11 @@ QT_BEGIN_NAMESPACE
\sa highlightedIndex
*/
+namespace {
+ enum Activation { NoActivate, Activate };
+ enum Highlighting { NoHighlight, Highlight };
+}
+
class QQuickComboBoxDelegateModel : public QQmlDelegateModel
{
public:
@@ -181,8 +186,12 @@ public:
void updateCurrentText();
void incrementCurrentIndex();
void decrementCurrentIndex();
+ void setCurrentIndex(int index, Activation activate);
void updateHighlightedIndex();
- void setHighlightedIndex(int index);
+ void setHighlightedIndex(int index, Highlighting highlight);
+
+ void keySearch(const QString &text);
+ int match(int start, const QString &text, Qt::MatchFlags flags) const;
void createDelegateModel();
@@ -242,8 +251,7 @@ void QQuickComboBoxPrivate::itemClicked()
Q_Q(QQuickComboBox);
int index = delegateModel->indexOf(q->sender(), nullptr);
if (index != -1) {
- setHighlightedIndex(index);
- emit q->highlighted(index);
+ setHighlightedIndex(index, Highlight);
hidePopup(true);
}
}
@@ -274,6 +282,8 @@ void QQuickComboBoxPrivate::updateCurrentText()
QString text = q->textAt(currentIndex);
if (currentText != text) {
currentText = text;
+ if (!hasDisplayText)
+ q->setAccessibleName(text);
emit q->currentTextChanged();
}
if (!hasDisplayText && displayText != text) {
@@ -282,44 +292,51 @@ void QQuickComboBoxPrivate::updateCurrentText()
}
}
+void QQuickComboBoxPrivate::setCurrentIndex(int index, Activation activate)
+{
+ Q_Q(QQuickComboBox);
+ if (currentIndex == index)
+ return;
+
+ currentIndex = index;
+ emit q->currentIndexChanged();
+
+ if (componentComplete)
+ updateCurrentText();
+
+ if (activate)
+ emit q->activated(index);
+}
+
void QQuickComboBoxPrivate::incrementCurrentIndex()
{
Q_Q(QQuickComboBox);
if (isPopupVisible()) {
- if (highlightedIndex < q->count() - 1) {
- setHighlightedIndex(highlightedIndex + 1);
- emit q->highlighted(highlightedIndex);
- }
+ if (highlightedIndex < q->count() - 1)
+ setHighlightedIndex(highlightedIndex + 1, Highlight);
} else {
- if (currentIndex < q->count() - 1) {
- q->setCurrentIndex(currentIndex + 1);
- emit q->activated(currentIndex);
- }
+ if (currentIndex < q->count() - 1)
+ setCurrentIndex(currentIndex + 1, Activate);
}
}
void QQuickComboBoxPrivate::decrementCurrentIndex()
{
- Q_Q(QQuickComboBox);
if (isPopupVisible()) {
- if (highlightedIndex > 0) {
- setHighlightedIndex(highlightedIndex - 1);
- emit q->highlighted(highlightedIndex);
- }
+ if (highlightedIndex > 0)
+ setHighlightedIndex(highlightedIndex - 1, Highlight);
} else {
- if (currentIndex > 0) {
- q->setCurrentIndex(currentIndex - 1);
- emit q->activated(currentIndex);
- }
+ if (currentIndex > 0)
+ setCurrentIndex(currentIndex - 1, Activate);
}
}
void QQuickComboBoxPrivate::updateHighlightedIndex()
{
- setHighlightedIndex(popup->isVisible() ? currentIndex : -1);
+ setHighlightedIndex(popup->isVisible() ? currentIndex : -1, NoHighlight);
}
-void QQuickComboBoxPrivate::setHighlightedIndex(int index)
+void QQuickComboBoxPrivate::setHighlightedIndex(int index, Highlighting highlight)
{
Q_Q(QQuickComboBox);
if (highlightedIndex == index)
@@ -327,6 +344,68 @@ void QQuickComboBoxPrivate::setHighlightedIndex(int index)
highlightedIndex = index;
emit q->highlightedIndexChanged();
+
+ if (highlight)
+ emit q->highlighted(index);
+}
+
+void QQuickComboBoxPrivate::keySearch(const QString &text)
+{
+ int index = match(currentIndex + 1, text, Qt::MatchStartsWith | Qt::MatchWrap);
+ if (index != -1)
+ setCurrentIndex(index, Activate);
+}
+
+int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags flags) const
+{
+ Q_Q(const QQuickComboBox);
+ uint matchType = flags & 0x0F;
+ bool wrap = flags & Qt::MatchWrap;
+ Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int from = start;
+ int to = q->count();
+
+ // iterates twice if wrapping
+ for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) {
+ for (int idx = from; idx < to; ++idx) {
+ QString t = q->textAt(idx);
+ switch (matchType) {
+ case Qt::MatchExactly:
+ if (t == text)
+ return idx;
+ break;
+ case Qt::MatchRegExp:
+ if (QRegExp(text, cs).exactMatch(t))
+ return idx;
+ break;
+ case Qt::MatchWildcard:
+ if (QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t))
+ return idx;
+ break;
+ case Qt::MatchStartsWith:
+ if (t.startsWith(text, cs))
+ return idx;
+ break;
+ case Qt::MatchEndsWith:
+ if (t.endsWith(text, cs))
+ return idx;
+ break;
+ case Qt::MatchFixedString:
+ if (t.compare(text, cs) == 0)
+ return idx;
+ break;
+ case Qt::MatchContains:
+ default:
+ if (t.contains(text, cs))
+ return idx;
+ break;
+ }
+ }
+ // prepare for the next iteration
+ from = 0;
+ to = start;
+ }
+ return -1;
}
void QQuickComboBoxPrivate::createDelegateModel()
@@ -539,13 +618,7 @@ void QQuickComboBox::setCurrentIndex(int index)
{
Q_D(QQuickComboBox);
d->hasCurrentIndex = true;
- if (d->currentIndex == index)
- return;
-
- d->currentIndex = index;
- emit currentIndexChanged();
- if (isComponentComplete())
- d->updateCurrentText();
+ d->setCurrentIndex(index, NoActivate);
}
/*!
@@ -595,6 +668,7 @@ void QQuickComboBox::setDisplayText(const QString &text)
return;
d->displayText = text;
+ setAccessibleName(text);
emit displayTextChanged();
}
@@ -789,45 +863,8 @@ QString QQuickComboBox::textAt(int index) const
*/
int QQuickComboBox::find(const QString &text, Qt::MatchFlags flags) const
{
- int itemCount = count();
- uint matchType = flags & 0x0F;
- Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
-
- for (int idx = 0; idx < itemCount; ++idx) {
- QString t = textAt(idx);
- switch (matchType) {
- case Qt::MatchExactly:
- if (t == text)
- return idx;
- break;
- case Qt::MatchRegExp:
- if (QRegExp(text, cs).exactMatch(t))
- return idx;
- break;
- case Qt::MatchWildcard:
- if (QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t))
- return idx;
- break;
- case Qt::MatchStartsWith:
- if (t.startsWith(text, cs))
- return idx;
- break;
- case Qt::MatchEndsWith:
- if (t.endsWith(text, cs))
- return idx;
- break;
- case Qt::MatchFixedString:
- if (t.compare(text, cs) == 0)
- return idx;
- break;
- case Qt::MatchContains:
- default:
- if (t.contains(text, cs))
- return idx;
- break;
- }
- }
- return -1;
+ Q_D(const QQuickComboBox);
+ return d->match(0, text, flags);
}
/*!
@@ -870,8 +907,6 @@ void QQuickComboBox::keyPressEvent(QKeyEvent *event)
{
Q_D(QQuickComboBox);
QQuickControl::keyPressEvent(event);
- if (!d->popup)
- return;
switch (event->key()) {
case Qt::Key_Escape:
@@ -898,7 +933,25 @@ void QQuickComboBox::keyPressEvent(QKeyEvent *event)
d->incrementCurrentIndex();
event->accept();
break;
+ case Qt::Key_Home:
+ if (d->isPopupVisible())
+ d->setHighlightedIndex(0, Highlight);
+ else
+ d->setCurrentIndex(0, Activate);
+ event->accept();
+ break;
+ case Qt::Key_End:
+ if (d->isPopupVisible())
+ d->setHighlightedIndex(count() - 1, Highlight);
+ else
+ d->setCurrentIndex(count() - 1, Activate);
+ event->accept();
+ break;
default:
+ if (!event->text().isEmpty())
+ d->keySearch(event->text());
+ else
+ event->ignore();
break;
}
}
@@ -996,4 +1049,20 @@ QFont QQuickComboBox::defaultFont() const
return QQuickControlPrivate::themeFont(QPlatformTheme::ComboMenuItemFont);
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickComboBox::accessibleRole() const
+{
+ return QAccessible::ComboBox;
+}
+
+void QQuickComboBox::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickComboBox);
+ QQuickControl::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->hasDisplayText ? d->displayText : d->currentText);
+}
+#endif // QT_NO_ACCESSIBILITY
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h
index 3788d56a..0e18a4d5 100644
--- a/src/quicktemplates2/qquickcombobox_p.h
+++ b/src/quicktemplates2/qquickcombobox_p.h
@@ -151,6 +151,11 @@ protected:
QFont defaultFont() const override;
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickComboBox)
Q_DECLARE_PRIVATE(QQuickComboBox)
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index f7b6da00..decc6e8a 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief A container control base type.
+ \brief Abstract base type providing functionality common to containers.
Container is the base type of container-like user interface controls that
allow dynamic insertion and removal of items.
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 20de449e..b5b98c8f 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickControl
\inqmlmodule QtQuick.Controls
\since 5.7
- \brief The base type of user interface controls.
+ \brief Abstract base type providing functionality common to all controls.
Control is the base type of user interface controls. It receives input
events from the window system, and paints a representation of itself on
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index eb60c93c..4c8576a7 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -49,12 +49,14 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A circular dial that is rotated to set a value.
+ \brief Circular dial that is rotated to set a value.
The Dial is similar to a traditional dial knob that is found on devices
such as stereos or industrial equipment. It allows the user to specify a
value within a range.
+ \image qtquickcontrols2-dial-no-wrap.gif
+
The value of the dial is set with the \l value property. The range is
set with the \l from and \l to properties. To enable or disable wrapping,
use the \l wrap property.
diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp
index 94378a15..ad35f3fc 100644
--- a/src/quicktemplates2/qquickdialog.cpp
+++ b/src/quicktemplates2/qquickdialog.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\ingroup qtquickcontrols2-dialogs
\ingroup qtquickcontrols2-popups
- \brief A dialog control.
+ \brief Popup dialog with standard buttons and a title, used for short-term interaction with the user.
\since 5.8
A dialog is a popup mostly used for short-term tasks and brief communications
@@ -152,6 +152,7 @@ void QQuickDialog::setTitle(const QString &title)
return;
d->title = title;
+ setAccessibleName(title);
emit titleChanged();
}
@@ -344,4 +345,20 @@ void QQuickDialog::spacingChange(qreal newSpacing, qreal oldSpacing)
d->layout->update();
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickDialog::accessibleRole() const
+{
+ return QAccessible::Dialog;
+}
+
+void QQuickDialog::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickDialog);
+ QQuickPopup::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->title);
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h
index ea03dddf..6ec440bf 100644
--- a/src/quicktemplates2/qquickdialog_p.h
+++ b/src/quicktemplates2/qquickdialog_p.h
@@ -97,6 +97,11 @@ protected:
void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
void spacingChange(qreal newSpacing, qreal oldSpacing) override;
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickDialog)
Q_DECLARE_PRIVATE(QQuickDialog)
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 839fb1c9..59caa230 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -54,21 +54,17 @@ QT_BEGIN_NAMESPACE
\since 5.7
\ingroup qtquickcontrols2-navigation
\ingroup qtquickcontrols2-popups
- \brief Provides a swipe-based side panel.
+ \brief Side panel that can be opened and closed using a swipe gesture.
Drawer provides a swipe-based side panel, similar to those often used in
touch interfaces to provide a central location for navigation.
- \table
- \row
- \li \image qtquickcontrols2-drawer-wireframe.png
- Drawer can be positioned at any of the four edges of the content item. \br
- In this image, it is against the left edge of the window.
+ \image qtquickcontrols2-drawer.gif
- \li \image qtquickcontrols2-drawer-expanded-wireframe.png
- The drawer is then opened by \e "dragging" it out from the left edge \br
- of the window.
- \endtable
+ Drawer can be positioned at any of the four edges of the content item.
+ The drawer above is positioned against the left edge of the window. The
+ drawer is then opened by \e "dragging" it out from the left edge of the
+ window.
\code
import QtQuick 2.7
diff --git a/src/quicktemplates2/qquickframe.cpp b/src/quicktemplates2/qquickframe.cpp
index bcc387c1..9deef6be 100644
--- a/src/quicktemplates2/qquickframe.cpp
+++ b/src/quicktemplates2/qquickframe.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief A logical group of controls within a visual frame.
+ \brief Visual frame for a logical group of controls.
Frame is used to layout a logical group of controls together within a
visual frame. Frame does not provide a layout of its own, but requires
@@ -78,4 +78,11 @@ QQuickFrame::QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent) :
{
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickFrame::accessibleRole() const
+{
+ return QAccessible::Border;
+}
+#endif // QT_NO_ACCESSIBILITY
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickframe_p.h b/src/quicktemplates2/qquickframe_p.h
index 12a65afd..093da248 100644
--- a/src/quicktemplates2/qquickframe_p.h
+++ b/src/quicktemplates2/qquickframe_p.h
@@ -64,6 +64,10 @@ public:
protected:
QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent);
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickFrame)
Q_DECLARE_PRIVATE(QQuickFrame)
diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp
index 5a5a8005..dd6d1883 100644
--- a/src/quicktemplates2/qquickgroupbox.cpp
+++ b/src/quicktemplates2/qquickgroupbox.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief A logical group of controls within a titled visual frame.
+ \brief Visual frame and title for a logical group of controls.
GroupBox is used to layout a logical group of controls together, within
a \l {title}{titled} visual frame. GroupBox does not provide a layout of its own, but
@@ -118,6 +118,7 @@ void QQuickGroupBox::setTitle(const QString &title)
return;
d->title = title;
+ setAccessibleName(title);
emit titleChanged();
}
@@ -152,4 +153,20 @@ QFont QQuickGroupBox::defaultFont() const
return QQuickControlPrivate::themeFont(QPlatformTheme::GroupBoxTitleFont);
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickGroupBox::accessibleRole() const
+{
+ return QAccessible::Grouping;
+}
+
+void QQuickGroupBox::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickGroupBox);
+ QQuickFrame::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->title);
+}
+#endif // QT_NO_ACCESSIBILITY
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickgroupbox_p.h b/src/quicktemplates2/qquickgroupbox_p.h
index 0f1bdc54..98f6ad06 100644
--- a/src/quicktemplates2/qquickgroupbox_p.h
+++ b/src/quicktemplates2/qquickgroupbox_p.h
@@ -76,6 +76,11 @@ Q_SIGNALS:
protected:
QFont defaultFont() const override;
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickGroupBox)
Q_DECLARE_PRIVATE(QQuickGroupBox)
diff --git a/src/quicktemplates2/qquickitemdelegate.cpp b/src/quicktemplates2/qquickitemdelegate.cpp
index 9b21eb30..411cb224 100644
--- a/src/quicktemplates2/qquickitemdelegate.cpp
+++ b/src/quicktemplates2/qquickitemdelegate.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickItemDelegate
\inqmlmodule QtQuick.Controls
\since 5.7
- \brief A standard view item that can be used in various views and controls.
+ \brief Basic item delegate that can be used in various views and controls.
\image qtquickcontrols2-itemdelegate.gif
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index b3596022..ebd1755a 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup text
- \brief A text label with inherited styling and font.
+ \brief Styled text label with inherited font.
Label extends \l Text with styling and \l {Control::font}{font}
inheritance. The default colors and font are style specific. Label
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index ed2cd7e0..ab5415d3 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
\since 5.7
\ingroup qtquickcontrols2-menus
\ingroup qtquickcontrols2-popups
- \brief A menu control that can be used as a context menu or popup menu.
+ \brief Menu popup that can be used as a context menu or popup menu.
\image qtquickcontrols2-menu.png
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp
index 902889b0..564d3f38 100644
--- a/src/quicktemplates2/qquickmenuitem.cpp
+++ b/src/quicktemplates2/qquickmenuitem.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-menus
- \brief A menu item within a Menu.
+ \brief Presents an item within a Menu.
MenuItem is a convenience type that implements the AbstractButton API,
providing a familiar way to respond to menu items being \l triggered, for
diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp
index 432c8c63..ad1e4ebd 100644
--- a/src/quicktemplates2/qquickpage.cpp
+++ b/src/quicktemplates2/qquickpage.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief A control that makes it convenient to add a header and footer to a page.
+ \brief Styled page control with support for a header and footer.
Page is a container control which makes it convenient to add
a \l header and \l footer item to a page.
@@ -169,6 +169,7 @@ void QQuickPage::setTitle(const QString &title)
return;
d->title = title;
+ setAccessibleName(title);
emit titleChanged();
}
@@ -361,6 +362,15 @@ QAccessible::Role QQuickPage::accessibleRole() const
{
return QAccessible::PageTab;
}
+
+void QQuickPage::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickPage);
+ QQuickControl::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->title);
+}
#endif
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickpage_p.h b/src/quicktemplates2/qquickpage_p.h
index 36ba9fff..6493cee7 100644
--- a/src/quicktemplates2/qquickpage_p.h
+++ b/src/quicktemplates2/qquickpage_p.h
@@ -104,6 +104,7 @@ protected:
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
#endif
private:
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index a7927d19..5155b339 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -56,16 +56,16 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-popups
- \brief The base type of popup-like user interface controls.
+ \brief Base type of popup-like user interface controls.
Popup is the base type of popup-like user interface controls. It can be
- used with Window or ApplicationWindow.
+ used with \l Window or \l ApplicationWindow.
\qml
import QtQuick.Window 2.2
import QtQuick.Controls 2.1
- Window {
+ ApplicationWindow {
id: window
width: 400
height: 400
@@ -93,8 +93,79 @@ QT_BEGIN_NAMESPACE
scene, it is recommended to use ApplicationWindow. ApplicationWindow also
provides background dimming effects.
- Popup lays out its content in a similar fashion to \l Control. For more
- information, see the \l {Control Layout} section of the documentation.
+ Popup does not provide a layout of its own, but requires you to position
+ its contents, for instance by creating a \l RowLayout or a \l ColumnLayout.
+
+ Items declared as children of a Popup are automatically parented to the
+ Popups's \l contentItem. Items created dynamically need to be explicitly
+ parented to the contentItem.
+
+ \section1 Popup Layout
+
+ The following diagram illustrates the layout of a typical popup:
+
+ \image qtquickcontrols2-popup.png
+
+ The \l implicitWidth and \l implicitHeight of a popup are typically based
+ on the implicit sizes of the background and the content item plus any
+ \l padding. These properties determine how large the popup will be when no
+ explicit \l width or \l height is specified.
+
+ The \l background item fills the entire width and height of the popup,
+ unless an explicit size has been given for it.
+
+ The geometry of the \l contentItem is determined by the \l padding.
+
+ \section1 Popup Sizing
+
+ If only a single item is used within a Popup, it will resize to fit the
+ implicit size of its contained item. This makes it particularly suitable
+ for use together with layouts.
+
+ \code
+ Popup {
+ ColumnLayout {
+ anchors.fill: parent
+ CheckBox { text: qsTr("E-mail") }
+ CheckBox { text: qsTr("Calendar") }
+ CheckBox { text: qsTr("Contacts") }
+ }
+ }
+ \endcode
+
+ Sometimes there might be two items within the popup:
+
+ \code
+ Popup {
+ SwipeView {
+ // ...
+ }
+ PageIndicator {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ }
+ }
+ \endcode
+
+ In this case, Popup cannot calculate a sensible implicit size. Since we're
+ anchoring the \l PageIndicator over the \l SwipeView, we can simply set the
+ content size to the view's implicit size:
+
+ \code
+ Popup {
+ contentWidth: view.implicitWidth
+ contentHeight: view.implicitHeight
+
+ SwipeView {
+ id: view
+ // ...
+ }
+ PageIndicator {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ }
+ }
+ \endcode
\sa {Popup Controls}, {Customizing Popup}, ApplicationWindow
*/
@@ -424,6 +495,7 @@ QQuickPopup::~QQuickPopup()
{
Q_D(QQuickPopup);
setParentItem(nullptr);
+ d->popupItem->ungrabShortcut();
delete d->popupItem;
}
@@ -643,8 +715,9 @@ void QQuickPopup::setImplicitHeight(qreal height)
This property holds the content width. It is used for calculating the
total implicit width of the Popup.
- \note If only a single item is used within the Popup, the implicit width
- of its contained item is used as the content width.
+ For more information, see \l {Popup Sizing}.
+
+ \sa contentHeight
*/
qreal QQuickPopup::contentWidth() const
{
@@ -668,8 +741,9 @@ void QQuickPopup::setContentWidth(qreal width)
This property holds the content height. It is used for calculating the
total implicit height of the Popup.
- \note If only a single item is used within the Popup, the implicit height
- of its contained item is used as the content height.
+ For more information, see \l {Popup Sizing}.
+
+ \sa contentWidth
*/
qreal QQuickPopup::contentHeight() const
{
@@ -1071,6 +1145,28 @@ void QQuickPopup::resetLocale()
\qmlproperty font QtQuick.Controls::Popup::font
This property holds the font currently set for the popup.
+
+ Popup propagates explicit font properties to its children. If you change a specific
+ property on a popup's font, that property propagates to all of the popup's children,
+ overriding any system defaults for that property.
+
+ \code
+ Popup {
+ font.family: "Courier"
+
+ Column {
+ Label {
+ text: qsTr("This will use Courier...")
+ }
+
+ Switch {
+ text: qsTr("... and so will this")
+ }
+ }
+ }
+ \endcode
+
+ \sa Control::font, ApplicationWindow::font
*/
QFont QQuickPopup::font() const
{
@@ -1410,7 +1506,10 @@ void QQuickPopup::setVisible(bool visible)
/*!
\qmlproperty real QtQuick.Controls::Popup::opacity
- This property holds the opacity of the popup. The default value is \c 1.0.
+ This property holds the opacity of the popup. Opacity is specified as a number between
+ \c 0.0 (fully transparent) and \c 1.0 (fully opaque). The default value is \c 1.0.
+
+ \sa visible
*/
qreal QQuickPopup::opacity() const
{
@@ -1428,6 +1527,10 @@ void QQuickPopup::setOpacity(qreal opacity)
\qmlproperty real QtQuick.Controls::Popup::scale
This property holds the scale factor of the popup. The default value is \c 1.0.
+
+ A scale of less than \c 1.0 causes the popup to be rendered at a smaller size,
+ and a scale greater than \c 1.0 renders the popup at a larger size. A negative
+ scale causes the popup to be mirrored when rendered.
*/
qreal QQuickPopup::scale() const
{
@@ -1473,6 +1576,12 @@ void QQuickPopup::setClosePolicy(ClosePolicy policy)
if (d->closePolicy == policy)
return;
d->closePolicy = policy;
+ if (isVisible()) {
+ if (policy & QQuickPopup::CloseOnEscape)
+ d->popupItem->grabShortcut();
+ else
+ d->popupItem->ungrabShortcut();
+ }
emit closePolicyChanged();
}
@@ -1503,8 +1612,20 @@ void QQuickPopup::setTransformOrigin(TransformOrigin origin)
/*!
\qmlproperty Transition QtQuick.Controls::Popup::enter
- This property holds the transition that is applied to the content item
+ This property holds the transition that is applied to the popup item
when the popup is opened and enters the screen.
+
+ The following example animates the opacity of the popup when it enters
+ the screen:
+ \code
+ Popup {
+ enter: Transition {
+ NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
+ }
+ }
+ \endcode
+
+ \sa exit
*/
QQuickTransition *QQuickPopup::enter() const
{
@@ -1524,8 +1645,20 @@ void QQuickPopup::setEnter(QQuickTransition *transition)
/*!
\qmlproperty Transition QtQuick.Controls::Popup::exit
- This property holds the transition that is applied to the content item
+ This property holds the transition that is applied to the popup item
when the popup is closed and exits the screen.
+
+ The following example animates the opacity of the popup when it exits
+ the screen:
+ \code
+ Popup {
+ exit: Transition {
+ NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
+ }
+ }
+ \endcode
+
+ \sa enter
*/
QQuickTransition *QQuickPopup::exit() const
{
@@ -1617,12 +1750,6 @@ void QQuickPopup::keyPressEvent(QKeyEvent *event)
if (hasActiveFocus() && (event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab))
QQuickItemPrivate::focusNextPrev(d->popupItem, event->key() == Qt::Key_Tab);
-
- if (event->key() != Qt::Key_Escape && event->key() != Qt::Key_Back)
- return;
-
- if (d->closePolicy.testFlag(CloseOnEscape))
- close();
}
void QQuickPopup::keyReleaseEvent(QKeyEvent *event)
@@ -1719,7 +1846,7 @@ void QQuickPopup::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe
void QQuickPopup::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
{
- Q_UNUSED(data);
+ Q_D(QQuickPopup);
switch (change) {
case QQuickItem::ItemActiveFocusHasChanged:
@@ -1728,6 +1855,13 @@ void QQuickPopup::itemChange(QQuickItem::ItemChange change, const QQuickItem::It
case QQuickItem::ItemOpacityHasChanged:
emit opacityChanged();
break;
+ case QQuickItem::ItemVisibleHasChanged:
+ if (isComponentComplete() && d->closePolicy & CloseOnEscape) {
+ if (data.boolValue)
+ d->popupItem->grabShortcut();
+ else
+ d->popupItem->ungrabShortcut();
+ }
default:
break;
}
@@ -1785,8 +1919,37 @@ QFont QQuickPopup::defaultFont() const
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role QQuickPopup::accessibleRole() const
{
- return QAccessible::LayeredPane;
+ return QAccessible::Dialog;
+}
+
+void QQuickPopup::accessibilityActiveChanged(bool active)
+{
+ Q_UNUSED(active);
}
#endif // QT_NO_ACCESSIBILITY
+QString QQuickPopup::accessibleName() const
+{
+ Q_D(const QQuickPopup);
+ return d->popupItem->accessibleName();
+}
+
+void QQuickPopup::setAccessibleName(const QString &name)
+{
+ Q_D(QQuickPopup);
+ d->popupItem->setAccessibleName(name);
+}
+
+QVariant QQuickPopup::accessibleProperty(const char *propertyName)
+{
+ Q_D(const QQuickPopup);
+ return d->popupItem->accessibleProperty(propertyName);
+}
+
+bool QQuickPopup::setAccessibleProperty(const char *propertyName, const QVariant &value)
+{
+ Q_D(QQuickPopup);
+ return d->popupItem->setAccessibleProperty(propertyName, value);
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
index de42b793..0cff8fd7 100644
--- a/src/quicktemplates2/qquickpopup_p.h
+++ b/src/quicktemplates2/qquickpopup_p.h
@@ -366,8 +366,15 @@ protected:
#ifndef QT_NO_ACCESSIBILITY
virtual QAccessible::Role accessibleRole() const;
+ virtual void accessibilityActiveChanged(bool active);
#endif
+ QString accessibleName() const;
+ void setAccessibleName(const QString &name);
+
+ QVariant accessibleProperty(const char *propertyName);
+ bool setAccessibleProperty(const char *propertyName, const QVariant &value);
+
private:
Q_DISABLE_COPY(QQuickPopup)
Q_DECLARE_PRIVATE(QQuickPopup)
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index b939d57c..877db347 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -36,9 +36,13 @@
#include "qquickpopupitem_p_p.h"
#include "qquickapplicationwindow_p.h"
+#include "qquickshortcutcontext_p_p.h"
#include "qquickcontrol_p_p.h"
#include "qquickpopup_p_p.h"
+#include <QtGui/private/qshortcutmap_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+
QT_BEGIN_NAMESPACE
class QQuickPopupItemPrivate : public QQuickControlPrivate
@@ -55,10 +59,15 @@ public:
QQuickItem *getContentItem() override;
+ int backId;
+ int escapeId;
QQuickPopup *popup;
};
-QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup) : popup(popup)
+QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup)
+ : backId(0),
+ escapeId(0),
+ popup(popup)
{
isTabFence = true;
}
@@ -103,12 +112,53 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents);
}
+void QQuickPopupItem::grabShortcut()
+{
+#ifndef QT_NO_SHORTCUT
+ Q_D(QQuickPopupItem);
+ QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
+ if (!d->backId)
+ d->backId = pApp->shortcutMap.addShortcut(this, Qt::Key_Back, Qt::WindowShortcut, QQuickShortcutContext::matcher);
+ if (!d->escapeId)
+ d->escapeId = pApp->shortcutMap.addShortcut(this, Qt::Key_Escape, Qt::WindowShortcut, QQuickShortcutContext::matcher);
+#endif // QT_NO_SHORTCUT
+}
+
+void QQuickPopupItem::ungrabShortcut()
+{
+#ifndef QT_NO_SHORTCUT
+ Q_D(QQuickPopupItem);
+ QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
+ if (d->backId) {
+ pApp->shortcutMap.removeShortcut(d->backId, this);
+ d->backId = 0;
+ }
+ if (d->escapeId) {
+ pApp->shortcutMap.removeShortcut(d->escapeId, this);
+ d->escapeId = 0;
+ }
+#endif // QT_NO_SHORTCUT
+}
+
void QQuickPopupItem::updatePolish()
{
Q_D(QQuickPopupItem);
return QQuickPopupPrivate::get(d->popup)->reposition();
}
+bool QQuickPopupItem::event(QEvent *event)
+{
+ Q_D(QQuickPopupItem);
+ if (event->type() == QEvent::Shortcut) {
+ QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
+ if (se->shortcutId() == d->escapeId || se->shortcutId() == d->backId) {
+ d->popup->close();
+ return true;
+ }
+ }
+ return QQuickItem::event(event);
+}
+
bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
{
Q_D(QQuickPopupItem);
@@ -229,6 +279,13 @@ QAccessible::Role QQuickPopupItem::accessibleRole() const
Q_D(const QQuickPopupItem);
return d->popup->accessibleRole();
}
+
+void QQuickPopupItem::accessibilityActiveChanged(bool active)
+{
+ Q_D(const QQuickPopupItem);
+ QQuickControl::accessibilityActiveChanged(active);
+ d->popup->accessibilityActiveChanged(active);
+}
#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickpopupitem_p_p.h b/src/quicktemplates2/qquickpopupitem_p_p.h
index 4b675010..c6d5e7d2 100644
--- a/src/quicktemplates2/qquickpopupitem_p_p.h
+++ b/src/quicktemplates2/qquickpopupitem_p_p.h
@@ -62,9 +62,13 @@ class QQuickPopupItem : public QQuickControl
public:
explicit QQuickPopupItem(QQuickPopup *popup);
+ void grabShortcut();
+ void ungrabShortcut();
+
protected:
void updatePolish() override;
+ bool event(QEvent *event) override;
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
@@ -88,6 +92,7 @@ protected:
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
#endif
private:
diff --git a/src/quicktemplates2/qquickprogressbar.cpp b/src/quicktemplates2/qquickprogressbar.cpp
index 7bf30318..5d5503e6 100644
--- a/src/quicktemplates2/qquickprogressbar.cpp
+++ b/src/quicktemplates2/qquickprogressbar.cpp
@@ -59,6 +59,30 @@ QT_BEGIN_NAMESPACE
}
\endcode
+ ProgressBar also supports a special \l indeterminate mode, which is useful,
+ for example, when unable to determine the size of the item being downloaded,
+ or if the download progress gets interrupted due to a network disconnection.
+
+ \image qtquickcontrols2-progressbar-indeterminate.gif
+
+ \code
+ ProgressBar {
+ indeterminate: true
+ }
+ \endcode
+
+ The indeterminate mode is similar to a \l BusyIndicator. Both can be used
+ to indicate background activity. The main difference is visual, and that
+ ProgressBar can also present a concrete amount of progress (when it can be
+ determined). Due to the visual difference, indeterminate progress bars and
+ busy indicators fit different places in user interfaces. Typical places for
+ an indeterminate progress bar:
+ \list
+ \li at the bottom of a \l ToolBar
+ \li inline within the content of a \l Page
+ \li in an \l ItemDelegate to show the progress of a particular item
+ \endlist
+
\sa {Customizing ProgressBar}, BusyIndicator, {Indicator Controls}
*/
diff --git a/src/quicktemplates2/qquickradiobutton.cpp b/src/quicktemplates2/qquickradiobutton.cpp
index a8d11377..acddb50d 100644
--- a/src/quicktemplates2/qquickradiobutton.cpp
+++ b/src/quicktemplates2/qquickradiobutton.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief An option button that can be toggled on or off.
+ \brief Exclusive radio button that can be toggled on or off.
\image qtquickcontrols2-radiobutton.gif
diff --git a/src/quicktemplates2/qquickradiodelegate.cpp b/src/quicktemplates2/qquickradiodelegate.cpp
index bf3557e8..4580dcf2 100644
--- a/src/quicktemplates2/qquickradiodelegate.cpp
+++ b/src/quicktemplates2/qquickradiodelegate.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-delegates
- \brief An item delegate that can be checked or unchecked.
+ \brief Exclusive item delegate with a radio indicator that can be toggled on or off.
\image qtquickcontrols2-radiodelegate.gif
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 83f34b5b..ffe2e976 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A slider control used to select a range of values.
+ \brief Used to select a range of values by sliding two handles along a track.
\image qtquickcontrols2-rangeslider.gif
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index 06cc8832..8e6db063 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-indicators
- \brief An interactive scroll bar control.
+ \brief Vertical or horizontal interactive scroll bar.
\image qtquickcontrols2-scrollbar.gif
@@ -65,9 +65,12 @@ QT_BEGIN_NAMESPACE
}
\endcode
+ \section1 Attaching ScrollBar to a Flickable
+
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:
+ \l {ScrollBar::horizontal}{horizontally} to a Flickable, its geometry and
+ the following properties are automatically set and updated as appropriate:
+
\list
\li \l orientation
\li \l position
@@ -113,6 +116,8 @@ QT_BEGIN_NAMESPACE
}
\endcode
+ \section1 Binding the Active State of Horizontal and Vertical Scroll Bars
+
Horizontal and vertical scroll bars do not share the \l active state with
each other by default. In order to keep both bars visible whilst scrolling
to either direction, establish a two-way binding between the active states
@@ -120,6 +125,29 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-scrollbar-active.qml 1
+ \section1 Non-attached Scroll Bars
+
+ It is possible to create an instance of ScrollBar without using the
+ attached property API. This is useful when the behavior of the attached
+ scoll bar is not sufficient or a \l Flickable is not in use. In the
+ following example, horizontal and vertical scroll bars are used to
+ scroll over the text without using \l Flickable:
+
+ \snippet qtquickcontrols2-scrollbar-non-attached.qml 1
+
+ \image qtquickcontrols2-scrollbar-non-attached.png
+
+ When using a non-attached ScrollBar, the following must be done manually:
+
+ \list
+ \li Layout the scroll bar (with the \l {Item::}{x} and \l {Item::}{y} or
+ \l {Item::anchors}{anchor} properties, for example).
+ \li Set the \l size and \l position properties to determine the size and position
+ of the scroll bar in relation to the scrolled item.
+ \li Set the \l active property to determine when the scroll bar will be
+ visible.
+ \endlist
+
\sa ScrollIndicator, {Customizing ScrollBar}, {Indicator Controls}
*/
@@ -205,6 +233,9 @@ QQuickScrollBarAttached *QQuickScrollBar::qmlAttachedProperties(QObject *object)
This property holds the size of the scroll bar, scaled to \c {0.0 - 1.0}.
\sa {Flickable::visibleArea.heightRatio}{Flickable::visibleArea}
+
+ This property is automatically set when the scroll bar is
+ \l {Attaching ScrollBar to a Flickable}{attached to a flickable}.
*/
qreal QQuickScrollBar::size() const
{
@@ -231,6 +262,9 @@ void QQuickScrollBar::setSize(qreal size)
This property holds the position of the scroll bar, scaled to \c {0.0 - 1.0}.
\sa {Flickable::visibleArea.yPosition}{Flickable::visibleArea}
+
+ This property is automatically set when the scroll bar is
+ \l {Attaching ScrollBar to a Flickable}{attached to a flickable}.
*/
qreal QQuickScrollBar::position() const
{
@@ -279,6 +313,12 @@ void QQuickScrollBar::setStepSize(qreal step)
This property holds whether the scroll bar is active, i.e. when it's \l pressed
or the attached Flickable is \l {Flickable::moving}{moving}.
+
+ It is possible to keep \l {Binding the Active State of Horizontal and Vertical Scroll Bars}
+ {both horizontal and vertical bars visible} while scrolling in either direction.
+
+ This property is automatically set when the scroll bar is
+ \l {Attaching ScrollBar to a Flickable}{attached to a flickable}.
*/
bool QQuickScrollBar::isActive() const
{
@@ -327,6 +367,9 @@ void QQuickScrollBar::setPressed(bool pressed)
Possible values:
\value Qt.Horizontal Horizontal
\value Qt.Vertical Vertical (default)
+
+ This property is automatically set when the scroll bar is
+ \l {Attaching ScrollBar to a Flickable}{attached to a flickable}.
*/
Qt::Orientation QQuickScrollBar::orientation() const
{
@@ -572,6 +615,8 @@ QQuickScrollBarAttached::~QQuickScrollBarAttached()
ScrollBar.horizontal: ScrollBar { }
}
\endcode
+
+ \sa {Attaching ScrollBar to a Flickable}
*/
QQuickScrollBar *QQuickScrollBarAttached::horizontal() const
{
@@ -630,6 +675,8 @@ void QQuickScrollBarAttached::setHorizontal(QQuickScrollBar *horizontal)
ScrollBar.vertical: ScrollBar { }
}
\endcode
+
+ \sa {Attaching ScrollBar to a Flickable}
*/
QQuickScrollBar *QQuickScrollBarAttached::vertical() const
{
diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp
index 6145a5b3..9f2f6eb9 100644
--- a/src/quicktemplates2/qquickscrollindicator.cpp
+++ b/src/quicktemplates2/qquickscrollindicator.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-indicators
- \brief A non-interactive scroll indicator control.
+ \brief Vertical or horizontal non-interactive scroll indicator.
\image qtquickcontrols2-scrollindicator.gif
@@ -65,9 +65,12 @@ QT_BEGIN_NAMESPACE
}
\endcode
- 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:
+ \section1 Attaching ScrollIndicator to a Flickable
+
+ \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:
+
\list
\li \l orientation
\li \l position
@@ -98,6 +101,8 @@ QT_BEGIN_NAMESPACE
}
\endcode
+ \section1 Binding the Active State of Horizontal and Vertical Scroll Indicators
+
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
@@ -105,6 +110,19 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-scrollindicator-active.qml 1
+ \section1 Non-attached Scroll Indicators
+
+ It is possible to create an instance of ScrollIndicator without using the
+ attached property API. This is useful when the behavior of the attached
+ scoll indicator is not sufficient or a \l Flickable is not in use. In the
+ following example, horizontal and vertical scroll indicators are used to
+ indicate how far the user has scrolled over the text (using \l MouseArea
+ instead of \l Flickable):
+
+ \snippet qtquickcontrols2-scrollindicator-non-attached.qml 1
+
+ \image qtquickcontrols2-scrollindicator-non-attached.png
+
\sa ScrollBar, {Customizing ScrollIndicator}, {Indicator Controls}
*/
@@ -166,6 +184,9 @@ QQuickScrollIndicatorAttached *QQuickScrollIndicator::qmlAttachedProperties(QObj
This property holds the size of the indicator, scaled to \c {0.0 - 1.0}.
\sa {Flickable::visibleArea.heightRatio}{Flickable::visibleArea}
+
+ This property is automatically set when the scroll indicator is
+ \l {Attaching ScrollIndicator to a Flickable}{attached to a flickable}.
*/
qreal QQuickScrollIndicator::size() const
{
@@ -190,6 +211,9 @@ void QQuickScrollIndicator::setSize(qreal size)
This property holds the position of the indicator, scaled to \c {0.0 - 1.0}.
+ This property is automatically set when the scroll indicator is
+ \l {Attaching ScrollIndicator to a Flickable}{attached to a flickable}.
+
\sa {Flickable::visibleArea.yPosition}{Flickable::visibleArea}
*/
qreal QQuickScrollIndicator::position() const
@@ -215,6 +239,12 @@ void QQuickScrollIndicator::setPosition(qreal position)
This property holds whether the indicator is active, that is, when the
attached Flickable is \l {Flickable::moving}{moving}.
+
+ It is possible to keep \l {Binding the Active State of Horizontal and Vertical Scroll Indicators}
+ {both horizontal and vertical indicators visible} while scrolling in either direction.
+
+ This property is automatically set when the scroll indicator is
+ \l {Attaching ScrollIndicator to a Flickable}{attached to a flickable}.
*/
bool QQuickScrollIndicator::isActive() const
{
@@ -240,6 +270,9 @@ void QQuickScrollIndicator::setActive(bool active)
Possible values:
\value Qt.Horizontal Horizontal
\value Qt.Vertical Vertical (default)
+
+ This property is automatically set when the scroll indicator is
+ \l {Attaching ScrollIndicator to a Flickable}{attached to a flickable}.
*/
Qt::Orientation QQuickScrollIndicator::orientation() const
{
@@ -363,6 +396,8 @@ QQuickScrollIndicatorAttached::~QQuickScrollIndicatorAttached()
ScrollIndicator.horizontal: ScrollIndicator { }
}
\endcode
+
+ \sa {Attaching ScrollIndicator to a Flickable}
*/
QQuickScrollIndicator *QQuickScrollIndicatorAttached::horizontal() const
{
@@ -419,6 +454,8 @@ void QQuickScrollIndicatorAttached::setHorizontal(QQuickScrollIndicator *horizon
ScrollIndicator.vertical: ScrollIndicator { }
}
\endcode
+
+ \sa {Attaching ScrollIndicator to a Flickable}
*/
QQuickScrollIndicator *QQuickScrollIndicatorAttached::vertical() const
{
diff --git a/src/quicktemplates2/qquickshortcutcontext.cpp b/src/quicktemplates2/qquickshortcutcontext.cpp
new file mode 100644
index 00000000..04aa4f4d
--- /dev/null
+++ b/src/quicktemplates2/qquickshortcutcontext.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 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$
+**
+****************************************************************************/
+
+#include "qquickshortcutcontext_p_p.h"
+#include "qquickoverlay_p_p.h"
+#include "qquickpopup_p.h"
+
+#include <QtGui/qguiapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+static bool isBlockedByPopup(QQuickItem *item)
+{
+ if (!item || !item->window())
+ return false;
+
+ QQuickOverlay *overlay = QQuickOverlay::overlay(item->window());
+ const auto popups = QQuickOverlayPrivate::get(overlay)->stackingOrderPopups();
+ for (QQuickPopup *popup : popups) {
+ if (popup->isModal() || popup->closePolicy() & QQuickPopup::CloseOnEscape)
+ return item != popup->popupItem() && !popup->popupItem()->isAncestorOf(item);
+ }
+
+ return false;
+}
+
+bool QQuickShortcutContext::matcher(QObject *obj, Qt::ShortcutContext context)
+{
+ QQuickItem *item = nullptr;
+ switch (context) {
+ case Qt::ApplicationShortcut:
+ return true;
+ case Qt::WindowShortcut:
+ while (obj && !obj->isWindowType()) {
+ obj = obj->parent();
+ item = qobject_cast<QQuickItem *>(obj);
+ if (item) {
+ obj = item->window();
+ } else if (QQuickPopup *popup = qobject_cast<QQuickPopup *>(obj)) {
+ obj = popup->window();
+ item = popup->popupItem();
+ }
+ }
+ return obj && obj == QGuiApplication::focusWindow() && !isBlockedByPopup(item);
+ default:
+ return false;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickshortcutcontext_p_p.h b/src/quicktemplates2/qquickshortcutcontext_p_p.h
new file mode 100644
index 00000000..3866dfd8
--- /dev/null
+++ b/src/quicktemplates2/qquickshortcutcontext_p_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 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 QQUICKSHORTCUTCONTEXT_P_P_H
+#define QQUICKSHORTCUTCONTEXT_P_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/qnamespace.h>
+#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+
+struct Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickShortcutContext
+{
+ static bool matcher(QObject *object, Qt::ShortcutContext context);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSHORTCUTCONTEXT_P_P_H
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index f587460f..0b91d61d 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief Selects a value by sliding a handle along a track.
+ \brief Used to select a value by sliding a handle along a track.
\image qtquickcontrols2-slider.gif
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index ec801b1a..957200a4 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -57,7 +57,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup input
- \brief A spinbox control that allows the user to select from a set of preset values.
+ \brief Allows the user to select from a set of preset values.
\image qtquickcontrols2-spinbox.png
@@ -430,7 +430,16 @@ void QQuickSpinBox::setEditable(bool editable)
This property holds the input text validator for editable spinboxes. By
default, SpinBox uses \l IntValidator to accept input of integer numbers.
- \snippet SpinBox.qml validator
+ \code
+ SpinBox {
+ id: control
+ validator: IntValidator {
+ locale: control.locale.name
+ bottom: Math.min(control.from, control.to)
+ top: Math.max(control.from, control.to)
+ }
+ }
+ \endcode
\sa editable, textFromValue, valueFromText, {Control::locale}{locale}
*/
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index 398b8c2b..b5bf0af7 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -994,6 +994,13 @@ bool QQuickStackView::childMouseEventFilter(QQuickItem *item, QEvent *event)
return window && !window->mouseGrabberItem();
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickStackView::accessibleRole() const
+{
+ return QAccessible::LayeredPane;
+}
+#endif
+
void QQuickStackViewAttachedPrivate::itemParentChanged(QQuickItem *item, QQuickItem *parent)
{
Q_Q(QQuickStackViewAttached);
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index e14bf2d4..8709e4a4 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -153,6 +153,10 @@ protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
bool childMouseEventFilter(QQuickItem *, QEvent *) override;
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickStackView)
Q_DECLARE_PRIVATE(QQuickStackView)
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index ef7f6ed5..fe678b80 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-delegates
- \brief A swipable item delegate.
+ \brief Swipable item delegate.
SwipeDelegate presents a view item that can be swiped left or right to
expose more options or information. It is used as a delegate in views such
@@ -818,13 +818,13 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
\li Description
\row
\li position
- \li This property holds the position of the swipe relative to either
+ \li This read-only property holds the position of the swipe relative to either
side of the control. When this value reaches either
\c -1.0 (left side) or \c 1.0 (right side) and the mouse button is
released, \c complete will be \c true.
\row
\li complete
- \li This property holds whether the control is fully exposed after
+ \li This read-only property holds whether the control is fully exposed after
having been swiped to the left or right.
When complete is \c true, any interactive items declared in \c left,
@@ -860,19 +860,19 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
\include qquickswipedelegate-interaction.qdocinc
\row
\li leftItem
- \li This property holds the item instantiated from the \c left component.
+ \li This read-only property holds the item instantiated from the \c left component.
If \c left has not been set, or the position hasn't changed since
creation of the SwipeDelegate, this property will be \c null.
\row
\li behindItem
- \li This property holds the item instantiated from the \c behind component.
+ \li This read-only property holds the item instantiated from the \c behind component.
If \c behind has not been set, or the position hasn't changed since
creation of the SwipeDelegate, this property will be \c null.
\row
\li rightItem
- \li This property holds the item instantiated from the \c right component.
+ \li This read-only property holds the item instantiated from the \c right component.
If \c right has not been set, or the position hasn't changed since
creation of the SwipeDelegate, this property will be \c null.
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index a3f52edd..ef98c59b 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
SwipeView provides a swipe-based navigation model.
- \image qtquickcontrols2-swipeview-wireframe.png
+ \image qtquickcontrols2-swipeview.gif
SwipeView is populated with a set of pages. One page is visible at a time.
The user can navigate between the pages by swiping sideways. Notice that
@@ -192,6 +192,13 @@ void QQuickSwipeView::itemAdded(int, QQuickItem *item)
item->setSize(QSizeF(d->contentItem->width(), d->contentItem->height()));
}
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickSwipeView::accessibleRole() const
+{
+ return QAccessible::PageTabList;
+}
+#endif
+
/*!
\qmlattachedproperty int QtQuick.Controls::SwipeView::index
\readonly
diff --git a/src/quicktemplates2/qquickswipeview_p.h b/src/quicktemplates2/qquickswipeview_p.h
index e29d2b28..8c489d53 100644
--- a/src/quicktemplates2/qquickswipeview_p.h
+++ b/src/quicktemplates2/qquickswipeview_p.h
@@ -75,6 +75,10 @@ protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void itemAdded(int index, QQuickItem *item) override;
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
private:
Q_DISABLE_COPY(QQuickSwipeView)
Q_DECLARE_PRIVATE(QQuickSwipeView)
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index 8c3d9f0b..fa08a1d8 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief An option button that can be toggled on or off.
+ \brief Switch button that can be toggled on or off.
\image qtquickcontrols2-switch.gif
diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp
index edfb15d5..81e282d9 100644
--- a/src/quicktemplates2/qquickswitchdelegate.cpp
+++ b/src/quicktemplates2/qquickswitchdelegate.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-delegates
- \brief An item delegate that can be toggled on or off.
+ \brief Item delegate with a switch indicator that can be toggled on or off.
\image qtquickcontrols2-switchdelegate.gif
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index ddcf7b12..9aead901 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\since 5.7
\ingroup qtquickcontrols2-navigation
\ingroup qtquickcontrols2-containers
- \brief A bar with icons allowing to switch between different views or subtasks.
+ \brief Allows the user to switch between different views or subtasks.
TabBar provides a tab-based navigation model.
@@ -60,6 +60,13 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-tabbar.qml 1
+ As shown above, TabBar is typically populated with a static set of tab buttons
+ that are defined inline as children of the tab bar. It is also possible to
+ \l {Container::addItem()}{add}, \l {Container::insertItem()}{insert},
+ \l {Container::moveItem()}{move}, and \l {Container::removeItem()}{remove}
+ items dynamically at run time. The items can be accessed using
+ \l {Container::}{itemAt()} or \l {Container::}{contentChildren}.
+
\section2 Resizing Tabs
By default, TabBar resizes its buttons to fit the width of the control.
@@ -176,8 +183,8 @@ QQuickTabBar::QQuickTabBar(QQuickItem *parent) :
This property holds the position of the tab bar.
- \note If the tab bar is assigned as a header or footer of ApplicationWindow
- or Page, the appropriate position is set automatically.
+ \note If the tab bar is assigned as a header or footer of \l ApplicationWindow
+ or \l Page, the appropriate position is set automatically.
Possible values:
\value TabBar.Header The tab bar is at the top, as a window or page header.
diff --git a/src/quicktemplates2/qquicktabbutton.cpp b/src/quicktemplates2/qquicktabbutton.cpp
index 3f097947..b5cbdd12 100644
--- a/src/quicktemplates2/qquicktabbutton.cpp
+++ b/src/quicktemplates2/qquicktabbutton.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-navigation
- \brief A tab button control that can be used in a TabBar.
+ \brief Button with a look suitable for a TabBar.
\image qtquickcontrols2-tabbutton.png
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 7d15a428..56a538ee 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A multi line text input control.
+ \brief Multi-line text input area.
TextArea is a multi-line text editor. TextArea extends TextEdit with
a \l {placeholderText}{placeholder text} functionality, and adds decoration.
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 85712865..2bb902a1 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A single line text input control.
+ \brief Single-line text input field.
TextField is a single line text editor. TextField extends TextInput with
a \l {placeholderText}{placeholder text} functionality, and adds decoration.
diff --git a/src/quicktemplates2/qquicktoolbar.cpp b/src/quicktemplates2/qquicktoolbar.cpp
index 5a767c73..12ecb702 100644
--- a/src/quicktemplates2/qquicktoolbar.cpp
+++ b/src/quicktemplates2/qquicktoolbar.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief A container for context-sensitive controls.
+ \brief Container for context-sensitive controls.
ToolBar is a container of application-wide and context sensitive
actions and controls, such as navigation buttons and search fields.
@@ -69,14 +69,19 @@ QT_BEGIN_NAMESPACE
RowLayout {
anchors.fill: parent
ToolButton {
- text: qsTr("\u25C0 %1").arg(Qt.application.name)
- enabled: stack.depth > 1
+ text: qsTr("‹")
onClicked: stack.pop()
}
- Item { Layout.fillWidth: true }
- Switch {
- checked: true
- text: qsTr("Notifications")
+ Label {
+ text: "Title"
+ elide: Label.ElideRight
+ horizontalAlignment: Qt.AlignHCenter
+ verticalAlignment: Qt.AlignVCenter
+ Layout.fillWidth: true
+ }
+ ToolButton {
+ text: qsTr("⋮")
+ onClicked: menu.open()
}
}
}
diff --git a/src/quicktemplates2/qquicktoolbutton.cpp b/src/quicktemplates2/qquicktoolbutton.cpp
index c1f47b97..e8827b4c 100644
--- a/src/quicktemplates2/qquicktoolbutton.cpp
+++ b/src/quicktemplates2/qquicktoolbutton.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-buttons
- \brief A button with a layout suitable for a ToolBar.
+ \brief Button with a look suitable for a ToolBar.
ToolButton is functionally similar to \l Button, but provides a look that
is more suitable within a \l ToolBar.
@@ -57,6 +57,10 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-toolbar.qml 1
+ ToolButton inherits its API from AbstractButton. For instance, you can set
+ \l {AbstractButton::text}{text}, and react to \l {AbstractButton::clicked}{clicks}
+ using the AbstractButton API.
+
\sa ToolBar, {Customizing ToolButton}, {Button Controls}
*/
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 8323dbd3..bc3f9d81 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -62,6 +62,8 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-tooltip.png
+ \section2 Attached Tool Tips
+
The most straight-forward way to setup tool tips for controls is to
specify \l text and \l {visible}{visibility} via attached properties.
The following example illustrates this approach:
@@ -186,6 +188,7 @@ void QQuickToolTip::setText(const QString &text)
return;
d->text = text;
+ setAccessibleName(text);
emit textChanged();
}
@@ -305,6 +308,15 @@ QAccessible::Role QQuickToolTip::accessibleRole() const
{
return QAccessible::ToolTip;
}
+
+void QQuickToolTip::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickToolTip);
+ QQuickPopup::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->text);
+}
#endif
class QQuickToolTipAttachedPrivate : public QObjectPrivate
@@ -358,6 +370,8 @@ QQuickToolTipAttached::QQuickToolTipAttached(QObject *parent) :
This attached property holds the text of the shared tool tip.
The property can be attached to any item.
+
+ \sa {Attached Tool Tips}
*/
QString QQuickToolTipAttached::text() const
{
@@ -384,7 +398,7 @@ void QQuickToolTipAttached::setText(const QString &text)
This attached property holds the delay (milliseconds) of the shared tool tip.
The property can be attached to any item.
- \sa {Delay and Timeout}
+ \sa {Attached Tool Tips}, {Delay and Timeout}
*/
int QQuickToolTipAttached::delay() const
{
@@ -411,7 +425,7 @@ void QQuickToolTipAttached::setDelay(int delay)
This attached property holds the timeout (milliseconds) of the shared tool tip.
The property can be attached to any item.
- \sa {Delay and Timeout}
+ \sa {Attached Tool Tips}, {Delay and Timeout}
*/
int QQuickToolTipAttached::timeout() const
{
@@ -437,6 +451,8 @@ void QQuickToolTipAttached::setTimeout(int timeout)
This attached property holds whether the shared tool tip is visible.
The property can be attached to any item.
+
+ \sa {Attached Tool Tips}
*/
bool QQuickToolTipAttached::isVisible() const
{
@@ -462,6 +478,8 @@ void QQuickToolTipAttached::setVisible(bool visible)
This attached property holds the shared tool tip instance. The property
can be attached to any item.
+
+ \sa {Attached Tool Tips}
*/
QQuickToolTip *QQuickToolTipAttached::toolTip() const
{
@@ -474,6 +492,8 @@ QQuickToolTip *QQuickToolTipAttached::toolTip() const
This attached method shows the shared tooltip with \a text and \a timeout (milliseconds).
The method can be attached to any item.
+
+ \sa {Attached Tool Tips}
*/
void QQuickToolTipAttached::show(const QString &text, int ms)
{
@@ -495,6 +515,8 @@ void QQuickToolTipAttached::show(const QString &text, int ms)
\qmlattachedmethod void QtQuick.Controls::ToolTip::hide()
This attached method hides the shared tooltip. The method can be attached to any item.
+
+ \sa {Attached Tool Tips}
*/
void QQuickToolTipAttached::hide()
{
diff --git a/src/quicktemplates2/qquicktooltip_p.h b/src/quicktemplates2/qquicktooltip_p.h
index d9f41f80..3be9214b 100644
--- a/src/quicktemplates2/qquicktooltip_p.h
+++ b/src/quicktemplates2/qquicktooltip_p.h
@@ -92,6 +92,7 @@ protected:
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
#endif
private:
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 068720bb..5206d766 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
- \brief A spinnable wheel of items that can be selected.
+ \brief Spinnable wheel of items that can be selected.
\image qtquickcontrols2-tumbler-wrap.gif
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 5ec4d3f3..2c387aa4 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -52,6 +52,7 @@ HEADERS += \
$$PWD/qquickroundbutton_p.h \
$$PWD/qquickscrollbar_p.h \
$$PWD/qquickscrollindicator_p.h \
+ $$PWD/qquickshortcutcontext_p_p.h \
$$PWD/qquickslider_p.h \
$$PWD/qquickspinbox_p.h \
$$PWD/qquickstackelement_p_p.h \
@@ -114,6 +115,7 @@ SOURCES += \
$$PWD/qquickroundbutton.cpp \
$$PWD/qquickscrollbar.cpp \
$$PWD/qquickscrollindicator.cpp \
+ $$PWD/qquickshortcutcontext.cpp \
$$PWD/qquickslider.cpp \
$$PWD/qquickspinbox.cpp \
$$PWD/qquickstackelement.cpp \