aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp10
-rw-r--r--src/quicktemplates2/qquickaction.cpp4
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp5
-rw-r--r--src/quicktemplates2/qquickbutton.cpp2
-rw-r--r--src/quicktemplates2/qquickcheckbox.cpp7
-rw-r--r--src/quicktemplates2/qquickcheckbox_p.h4
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp38
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp9
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp12
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp44
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox_p_p.h2
-rw-r--r--src/quicktemplates2/qquickicon.cpp25
-rw-r--r--src/quicktemplates2/qquickicon_p.h2
-rw-r--r--src/quicktemplates2/qquickitemdelegate.cpp2
-rw-r--r--src/quicktemplates2/qquicklabel.cpp5
-rw-r--r--src/quicktemplates2/qquickmenu.cpp15
-rw-r--r--src/quicktemplates2/qquickmenubar.cpp10
-rw-r--r--src/quicktemplates2/qquickmenubar_p_p.h2
-rw-r--r--src/quicktemplates2/qquickmenuitem.cpp2
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp20
-rw-r--r--src/quicktemplates2/qquickoverlay_p.h2
-rw-r--r--src/quicktemplates2/qquickpage.cpp2
-rw-r--r--src/quicktemplates2/qquickpane.cpp2
-rw-r--r--src/quicktemplates2/qquickpopup.cpp8
-rw-r--r--src/quicktemplates2/qquickpopup_p_p.h2
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp31
-rw-r--r--src/quicktemplates2/qquickscrollview.cpp5
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp2
-rw-r--r--src/quicktemplates2/qquicksplitview.cpp51
-rw-r--r--src/quicktemplates2/qquickstackview.cpp2
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp2
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp2
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp33
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp5
-rw-r--r--src/quicktemplates2/qquicktheme.cpp2
-rw-r--r--src/quicktemplates2/qquicktoolbutton.cpp2
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp9
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp17
38 files changed, 265 insertions, 134 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index a2992191..2099f2db 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -105,6 +105,7 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick.Controls::AbstractButton::pressAndHold()
This signal is emitted when the button is interactively pressed and held down by the user via touch or mouse.
+ It is not emitted when \l autoRepeat is enabled.
*/
/*!
@@ -658,6 +659,9 @@ void QQuickAbstractButton::setAutoExclusive(bool exclusive)
This property holds whether the button repeats \l pressed(), \l released()
and \l clicked() signals while the button is pressed and held down.
+ If this property is set to \c true, the \l pressAndHold() signal will not
+ be emitted.
+
The default value is \c false.
The initial delay and the repetition interval are defined in milliseconds
@@ -736,7 +740,7 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
\include qquickicon.qdocinc grouped-properties
- \sa text, display, {Icons in Qt Quick Controls 2}
+ \sa text, display, {Icons in Qt Quick Controls}
*/
QQuickIcon QQuickAbstractButton::icon() const
@@ -1157,6 +1161,10 @@ void QQuickAbstractButton::accessibilityActiveChanged(bool active)
QAccessible::Role QQuickAbstractButton::accessibleRole() const
{
+ Q_D(const QQuickAbstractButton);
+ if (d->checkable) {
+ return QAccessible::CheckBox;
+ }
return QAccessible::Button;
}
#endif
diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index e83fd353..9120db37 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -185,7 +185,7 @@ void QQuickActionPrivate::setShortcut(const QVariant &var)
for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries))
entry->ungrab();
- vshortcut = var.toString();
+ vshortcut = var;
keySequence = variantToKeySequence(var);
defaultShortcutEntry->grab(keySequence, enabled);
@@ -487,7 +487,7 @@ void QQuickAction::setCheckable(bool checkable)
\code
Action {
- sequence: "Ctrl+E,Ctrl+W"
+ shortcut: "Ctrl+E,Ctrl+W"
onTriggered: edit.wrapMode = TextEdit.Wrap
}
\endcode
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index acd98470..19f6f82b 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -113,7 +113,7 @@ QT_BEGIN_NAMESPACE
attached properties works in any window regardless of its \c id.
\sa {Customizing ApplicationWindow}, Overlay, Page, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
static const QQuickItemPrivate::ChangeTypes ItemChanges = QQuickItemPrivate::Visibility
@@ -684,6 +684,9 @@ void QQuickApplicationWindow::setFont(const QFont &font)
return;
QFont resolvedFont = font.resolve(QQuickTheme::font(QQuickTheme::System));
+ // See comment in QQuickControlPrivate::inheritFont
+ if (font.families().isEmpty())
+ resolvedFont.setFamilies(QStringList());
d->setFont_helper(resolvedFont);
}
diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp
index fbce5225..b4188a95 100644
--- a/src/quicktemplates2/qquickbutton.cpp
+++ b/src/quicktemplates2/qquickbutton.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\e Yes, \e No, and \e Help.
Button inherits its API from AbstractButton. For instance, you can set
- \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon},
+ \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon},
and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API.
A button emits the signal \l {AbstractButton::}{clicked()} when it is activated by the user.
diff --git a/src/quicktemplates2/qquickcheckbox.cpp b/src/quicktemplates2/qquickcheckbox.cpp
index 461fae30..0227e95d 100644
--- a/src/quicktemplates2/qquickcheckbox.cpp
+++ b/src/quicktemplates2/qquickcheckbox.cpp
@@ -243,13 +243,6 @@ void QQuickCheckBox::nextCheckState()
QQuickAbstractButton::nextCheckState();
}
-#if QT_CONFIG(accessibility)
-QAccessible::Role QQuickCheckBox::accessibleRole() const
-{
- return QAccessible::CheckBox;
-}
-#endif
-
QT_END_NAMESPACE
#include "moc_qquickcheckbox_p.cpp"
diff --git a/src/quicktemplates2/qquickcheckbox_p.h b/src/quicktemplates2/qquickcheckbox_p.h
index 81bd680c..f0293c11 100644
--- a/src/quicktemplates2/qquickcheckbox_p.h
+++ b/src/quicktemplates2/qquickcheckbox_p.h
@@ -84,10 +84,6 @@ protected:
void buttonChange(ButtonChange change) override;
void nextCheckState() override;
-#if QT_CONFIG(accessibility)
- QAccessible::Role accessibleRole() const override;
-#endif
-
private:
Q_DISABLE_COPY(QQuickCheckBox)
Q_DECLARE_PRIVATE(QQuickCheckBox)
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 78ec7ef8..8dc70934 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -90,21 +90,7 @@ QT_BEGIN_NAMESPACE
The following example demonstrates appending content to an editable
combo box by reacting to the \l accepted signal.
- \code
- ComboBox {
- editable: true
- model: ListModel {
- id: model
- ListElement { text: "Banana" }
- ListElement { text: "Apple" }
- ListElement { text: "Coconut" }
- }
- onAccepted: {
- if (find(editText) === -1)
- model.append({text: editText})
- }
- }
- \endcode
+ \snippet qtquickcontrols2-combobox-accepted.qml combobox
\section1 ComboBox Model Roles
@@ -134,7 +120,7 @@ QT_BEGIN_NAMESPACE
\l textRole is not defined, ComboBox is unable to visualize it and throws a
\c {ReferenceError: modelData is not defined}.
- \sa {Customizing ComboBox}, {Input Controls}, {Focus Management in Qt Quick Controls 2}
+ \sa {Customizing ComboBox}, {Input Controls}, {Focus Management in Qt Quick Controls}
*/
/*!
@@ -167,9 +153,22 @@ QT_BEGIN_NAMESPACE
\qmlsignal void QtQuick.Controls::ComboBox::accepted()
This signal is emitted when the \uicontrol Return or \uicontrol Enter key is pressed
- on an \l editable combo box. If the confirmed string is not currently in the model,
- the \l currentIndex will be set to \c -1 and the \l currentText will be updated
- accordingly.
+ on an \l editable combo box.
+
+ You can handle this signal in order to add the newly entered
+ item to the model, for example:
+
+ \snippet qtquickcontrols2-combobox-accepted.qml combobox
+
+ Before the signal is emitted, a check is done to see if the string
+ exists in the model. If it does, \l currentIndex will be set to its index,
+ and \l currentText to the string itself.
+
+ After the signal has been emitted, and if the first check failed (that is,
+ the item did not exist), another check will be done to see if the item was
+ added by the signal handler. If it was, the \l currentIndex and
+ \l currentText are updated accordingly. Otherwise, they will be set to
+ \c -1 and \c "", respectively.
\note If there is a \l validator set on the combo box, the signal will only be
emitted if the input is in an acceptable state.
@@ -828,6 +827,7 @@ void QQuickComboBox::setModel(const QVariant& m)
d->model = model;
d->createDelegateModel();
+ emit countChanged();
if (isComponentComplete()) {
setCurrentIndex(count() > 0 ? 0 : -1);
d->updateCurrentText();
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 2c357f82..5f38c5b9 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -241,7 +241,7 @@ void QQuickContainerPrivate::insertItem(int index, QQuickItem *item)
updatingCurrent = true;
- item->setParentItem(effectiveContentItem(getContentItem()));
+ item->setParentItem(effectiveContentItem(q->contentItem()));
QQuickItemPrivate::get(item)->addItemChangeListener(this, changeTypes);
contentModel->insert(index, item);
@@ -294,8 +294,9 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
updatingCurrent = true;
+ int count = contentModel->count();
bool currentChanged = false;
- if (index == currentIndex) {
+ if (index == currentIndex && (index != 0 || count == 1)) {
q->setCurrentIndex(currentIndex - 1);
} else if (index < currentIndex) {
--currentIndex;
@@ -305,10 +306,10 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
item->setParentItem(nullptr);
contentModel->remove(index);
+ --count;
q->itemRemoved(index, item);
- int count = contentModel->count();
for (int i = index; i < count; ++i)
q->itemMoved(i, itemAt(i));
@@ -382,7 +383,7 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
QQuickItem *item = qobject_cast<QQuickItem *>(obj);
if (item) {
if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
- item->setParentItem(effectiveContentItem(p->contentItem));
+ item->setParentItem(effectiveContentItem(q->contentItem()));
else if (p->contentModel->indexOf(item, nullptr) == -1)
q->addItem(item);
} else {
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index dd954b2b..0ebaf9a3 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -549,7 +549,13 @@ void QQuickControlPrivate::inheritFont(const QFont &font)
parentFont.resolve(extra.isAllocated() ? extra->requestedFont.resolve() | font.resolve() : font.resolve());
const QFont defaultFont = q->defaultFont();
- const QFont resolvedFont = parentFont.resolve(defaultFont);
+ QFont resolvedFont = parentFont.resolve(defaultFont);
+ // Since resolving the font will put the family() into the
+ // families() list if it is empty then we need to unset it
+ // so it does not act as if the font has changed (when it
+ // has not actually changed)
+ if (defaultFont.families().isEmpty())
+ resolvedFont.setFamilies(QStringList());
setFont_helper(resolvedFont);
}
@@ -1470,9 +1476,9 @@ void QQuickControl::setHovered(bool hovered)
Setting this property propagates the value to all child controls that do not have
\c hoverEnabled explicitly set.
- You can also enable or disable hover effects for all Qt Quick Controls 2 applications
+ You can also enable or disable hover effects for all Qt Quick Controls applications
by setting the \c QT_QUICK_CONTROLS_HOVER_ENABLED \l {Supported Environment Variables
- in Qt Quick Controls 2}{environment variable}.
+ in Qt Quick Controls}{environment variable}.
\sa hovered
*/
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index 91fb41f2..10d80778 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -430,7 +430,8 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons()
while (i >= 0) {
QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(q->itemAt(i));
if (button) {
- QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, false));
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(
+ qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, false));
if (attached) {
QQuickDialogButtonBoxAttachedPrivate *p = QQuickDialogButtonBoxAttachedPrivate::get(attached);
if (p->standardButton != QPlatformDialogHelper::NoButton) {
@@ -443,6 +444,24 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons()
}
}
+void QQuickDialogButtonBoxPrivate::updateLanguage()
+{
+ Q_Q(QQuickDialogButtonBox);
+ int i = q->count() - 1;
+ while (i >= 0) {
+ QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(itemAt(i));
+ if (button) {
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(
+ qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, true));
+ const auto boxAttachedPrivate = QQuickDialogButtonBoxAttachedPrivate::get(attached);
+ const QPlatformDialogHelper::StandardButton standardButton = boxAttachedPrivate->standardButton;
+ const QString buttonText = QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton);
+ button->setText(QPlatformTheme::removeMnemonics(buttonText));
+ }
+ --i;
+ }
+}
+
QQuickDialogButtonBox::QQuickDialogButtonBox(QQuickItem *parent)
: QQuickContainer(*(new QQuickDialogButtonBoxPrivate), parent)
{
@@ -684,11 +703,34 @@ void QQuickDialogButtonBox::updatePolish()
d->updateLayout();
}
+class LanguageEventFilter : public QObject
+{
+public:
+ LanguageEventFilter(QQuickDialogButtonBoxPrivate *box)
+ : QObject(box->q_ptr)
+ , boxPrivate(box)
+ {
+ }
+
+protected:
+ bool eventFilter(QObject *, QEvent *event)
+ {
+ if (event->type() == QEvent::LanguageChange)
+ boxPrivate->updateLanguage();
+ return false;
+ }
+
+private:
+ QQuickDialogButtonBoxPrivate *boxPrivate;
+};
+
void QQuickDialogButtonBox::componentComplete()
{
Q_D(QQuickDialogButtonBox);
QQuickContainer::componentComplete();
d->updateLayout();
+ // TODO: use the solution in QTBUG-78141 instead, when it's implemented.
+ qApp->installEventFilter(new LanguageEventFilter(d));
}
void QQuickDialogButtonBox::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
index 66386911..6f9c9033 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
+++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
@@ -78,6 +78,8 @@ public:
QQuickAbstractButton *createStandardButton(QPlatformDialogHelper::StandardButton button);
void removeStandardButtons();
+ void updateLanguage();
+
Qt::Alignment alignment = 0;
QQuickDialogButtonBox::Position position = QQuickDialogButtonBox::Footer;
QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton;
diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp
index 5a689108..bf0a4658 100644
--- a/src/quicktemplates2/qquickicon.cpp
+++ b/src/quicktemplates2/qquickicon.cpp
@@ -112,12 +112,14 @@ void QQuickIcon::setName(const QString &name)
if ((d->resolveMask & QQuickIconPrivate::NameResolved) && d->name == name)
return;
+ d.detach();
d->name = name;
d->resolveMask |= QQuickIconPrivate::NameResolved;
}
void QQuickIcon::resetName()
{
+ d.detach();
d->name = QString();
d->resolveMask &= ~QQuickIconPrivate::NameResolved;
}
@@ -132,12 +134,14 @@ void QQuickIcon::setSource(const QUrl &source)
if ((d->resolveMask & QQuickIconPrivate::SourceResolved) && d->source == source)
return;
+ d.detach();
d->source = source;
d->resolveMask |= QQuickIconPrivate::SourceResolved;
}
void QQuickIcon::resetSource()
{
+ d.detach();
d->source = QString();
d->resolveMask &= ~QQuickIconPrivate::SourceResolved;
}
@@ -152,12 +156,14 @@ void QQuickIcon::setWidth(int width)
if ((d->resolveMask & QQuickIconPrivate::WidthResolved) && d->width == width)
return;
+ d.detach();
d->width = width;
d->resolveMask |= QQuickIconPrivate::WidthResolved;
}
void QQuickIcon::resetWidth()
{
+ d.detach();
d->width = 0;
d->resolveMask &= ~QQuickIconPrivate::WidthResolved;
}
@@ -172,12 +178,14 @@ void QQuickIcon::setHeight(int height)
if ((d->resolveMask & QQuickIconPrivate::HeightResolved) && d->height == height)
return;
+ d.detach();
d->height = height;
d->resolveMask |= QQuickIconPrivate::HeightResolved;
}
void QQuickIcon::resetHeight()
{
+ d.detach();
d->height = 0;
d->resolveMask &= ~QQuickIconPrivate::HeightResolved;
}
@@ -192,12 +200,14 @@ void QQuickIcon::setColor(const QColor &color)
if ((d->resolveMask & QQuickIconPrivate::ColorResolved) && d->color == color)
return;
+ d.detach();
d->color = color;
d->resolveMask |= QQuickIconPrivate::ColorResolved;
}
void QQuickIcon::resetColor()
{
+ d.detach();
d->color = Qt::transparent;
d->resolveMask &= ~QQuickIconPrivate::ColorResolved;
}
@@ -212,12 +222,14 @@ void QQuickIcon::setCache(bool cache)
if ((d->resolveMask & QQuickIconPrivate::CacheResolved) && d->cache == cache)
return;
+ d.detach();
d->cache = cache;
d->resolveMask |= QQuickIconPrivate::CacheResolved;
}
void QQuickIcon::resetCache()
{
+ d.detach();
d->cache = true;
d->resolveMask &= ~QQuickIconPrivate::CacheResolved;
}
@@ -225,24 +237,25 @@ void QQuickIcon::resetCache()
QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const
{
QQuickIcon resolved = *this;
+ resolved.d.detach();
if (!(d->resolveMask & QQuickIconPrivate::NameResolved))
- resolved.setName(other.name());
+ resolved.d->name = other.d->name;
if (!(d->resolveMask & QQuickIconPrivate::SourceResolved))
- resolved.setSource(other.source());
+ resolved.d->source = other.d->source;
if (!(d->resolveMask & QQuickIconPrivate::WidthResolved))
- resolved.setWidth(other.width());
+ resolved.d->width = other.d->width;
if (!(d->resolveMask & QQuickIconPrivate::HeightResolved))
- resolved.setHeight(other.height());
+ resolved.d->height = other.d->height;
if (!(d->resolveMask & QQuickIconPrivate::ColorResolved))
- resolved.setColor(other.color());
+ resolved.d->color = other.d->color;
if (!(d->resolveMask & QQuickIconPrivate::CacheResolved))
- resolved.setCache(other.cache());
+ resolved.d->cache = other.d->cache;
return resolved;
}
diff --git a/src/quicktemplates2/qquickicon_p.h b/src/quicktemplates2/qquickicon_p.h
index 57cab720..1835585d 100644
--- a/src/quicktemplates2/qquickicon_p.h
+++ b/src/quicktemplates2/qquickicon_p.h
@@ -107,7 +107,7 @@ public:
QQuickIcon resolve(const QQuickIcon &other) const;
private:
- QSharedDataPointer<QQuickIconPrivate> d;
+ QExplicitlySharedDataPointer<QQuickIconPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickitemdelegate.cpp b/src/quicktemplates2/qquickitemdelegate.cpp
index ac409118..8156ab65 100644
--- a/src/quicktemplates2/qquickitemdelegate.cpp
+++ b/src/quicktemplates2/qquickitemdelegate.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
in various views and controls, such as \l ListView and \l ComboBox.
ItemDelegate inherits its API from AbstractButton. For instance, you can set
- \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon},
+ \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon},
and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API.
\snippet qtquickcontrols2-itemdelegate.qml 1
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index 124483fb..f3e0d512 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -183,7 +183,10 @@ void QQuickLabelPrivate::inheritFont(const QFont &font)
parentFont.resolve(extra.isAllocated() ? extra->requestedFont.resolve() | font.resolve() : font.resolve());
const QFont defaultFont = QQuickTheme::font(QQuickTheme::Label);
- const QFont resolvedFont = parentFont.resolve(defaultFont);
+ QFont resolvedFont = parentFont.resolve(defaultFont);
+ // See comment in QQuickControlPrivate::inheritFont
+ if (defaultFont.families().isEmpty())
+ resolvedFont.setFamilies(QStringList());
setFont_helper(resolvedFont);
}
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index aa44e845..67e2d806 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -173,6 +173,19 @@ static const int SUBMENU_DELAY = 225;
\sa {Customizing Menu}, MenuItem, {Menu Controls}, {Popup Controls}
*/
+/*!
+ \qmlproperty bool QtQuick.Controls::Menu::focus
+
+ This property holds whether the popup wants focus.
+
+ When the popup actually receives focus, \l activeFocus will be \c true.
+ For more information, see \l {Keyboard Focus in Qt Quick}.
+
+ The default value is \c false.
+
+ \sa activeFocus
+*/
+
static const QQuickPopup::ClosePolicy cascadingSubMenuClosePolicy = QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutsideParent;
static bool shouldCascade()
@@ -1474,7 +1487,9 @@ void QQuickMenu::timerEvent(QTimerEvent *event)
if (QQuickMenu *subMenu = d->currentSubMenu())
subMenu->open();
d->stopHoverTimer();
+ return;
}
+ QQuickPopup::timerEvent(event);
}
QFont QQuickMenu::defaultFont() const
diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp
index 6016e70d..f909193f 100644
--- a/src/quicktemplates2/qquickmenubar.cpp
+++ b/src/quicktemplates2/qquickmenubar.cpp
@@ -73,10 +73,10 @@ QT_BEGIN_NAMESPACE
menus in a menu bar can be accessed using \l menuAt().
\sa {Customizing MenuBar}, Menu, MenuBarItem, {Menu Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
-QQuickItem *QQuickMenuBarPrivate::beginCreateItem()
+QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu)
{
Q_Q(QQuickMenuBar);
if (!delegate)
@@ -96,6 +96,8 @@ QQuickItem *QQuickMenuBarPrivate::beginCreateItem()
return nullptr;
}
+ if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item))
+ menuBarItem->setMenu(menu);
item->setParentItem(q);
QQml_setParent_noEvent(item, q);
@@ -112,9 +114,7 @@ void QQuickMenuBarPrivate::completeCreateItem()
QQuickItem *QQuickMenuBarPrivate::createItem(QQuickMenu *menu)
{
- QQuickItem *item = beginCreateItem();
- if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item))
- menuBarItem->setMenu(menu);
+ QQuickItem *item = beginCreateItem(menu);
completeCreateItem();
return item;
}
diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h
index 75fbed73..c214962b 100644
--- a/src/quicktemplates2/qquickmenubar_p_p.h
+++ b/src/quicktemplates2/qquickmenubar_p_p.h
@@ -69,7 +69,7 @@ public:
QQmlListProperty<QQuickMenu> menus();
QQmlListProperty<QObject> contentData();
- QQuickItem *beginCreateItem();
+ QQuickItem *beginCreateItem(QQuickMenu *menu);
void completeCreateItem();
QQuickItem *createItem(QQuickMenu *menu);
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp
index 22fe664a..a7fc63e8 100644
--- a/src/quicktemplates2/qquickmenuitem.cpp
+++ b/src/quicktemplates2/qquickmenuitem.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
example.
MenuItem inherits its API from AbstractButton. For instance, you can set
- \l {AbstractButton::text}{text} and \l {Icons in Qt Quick Controls 2}{icon}
+ \l {AbstractButton::text}{text} and \l {Icons in Qt Quick Controls}{icon}
using the AbstractButton API.
\code
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index cf72c8a6..3f358706 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -126,11 +126,6 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos)
return false;
}
-static bool isTouchEvent(QEvent *event)
-{
- return event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd;
-}
-
bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target)
{
if (target) {
@@ -139,7 +134,18 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick
return true;
}
return false;
- } else if (!mouseGrabberPopup || isTouchEvent(event)) {
+ }
+
+ switch (event->type()) {
+ default: {
+ if (mouseGrabberPopup)
+ break;
+#if QT_CONFIG(quicktemplates2_multitouch)
+ Q_FALLTHROUGH();
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+#endif
// allow non-modal popups to close themselves,
// and non-dimming modal popups to block the event
const auto popups = stackingOrderPopups();
@@ -149,6 +155,8 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick
return true;
}
}
+ break;
+ }
}
event->ignore();
diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h
index 0d8bccf5..1d238163 100644
--- a/src/quicktemplates2/qquickoverlay_p.h
+++ b/src/quicktemplates2/qquickoverlay_p.h
@@ -86,7 +86,7 @@ Q_SIGNALS:
protected:
void itemChange(ItemChange change, const ItemChangeData &data) override;
- void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp
index cb90ac48..78bae921 100644
--- a/src/quicktemplates2/qquickpage.cpp
+++ b/src/quicktemplates2/qquickpage.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
\endqml
\sa ApplicationWindow, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
static const QQuickItemPrivate::ChangeTypes LayoutChanges = QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility | QQuickItemPrivate::Destroyed
diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp
index fd9d2cf0..18c8bd51 100644
--- a/src/quicktemplates2/qquickpane.cpp
+++ b/src/quicktemplates2/qquickpane.cpp
@@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE
\endcode
\sa {Customizing Pane}, {Container Controls},
- {Focus Management in Qt Quick Controls 2}, {Event Handling}
+ {Focus Management in Qt Quick Controls}, {Event Handling}
*/
void QQuickPanePrivate::init()
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index dd7dede6..f272c5cf 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -2409,6 +2409,13 @@ void QQuickPopup::componentComplete()
d->complete = true;
d->popupItem->componentComplete();
+
+ if (isVisible()) {
+ if (d->closePolicy & QQuickPopup::CloseOnEscape)
+ d->popupItem->grabShortcut();
+ else
+ d->popupItem->ungrabShortcut();
+ }
}
bool QQuickPopup::isComponentComplete() const
@@ -2582,6 +2589,7 @@ void QQuickPopup::itemChange(QQuickItem::ItemChange change, const QQuickItem::It
else
d->popupItem->ungrabShortcut();
}
+ break;
default:
break;
}
diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h
index e32fdb28..8a85f914 100644
--- a/src/quicktemplates2/qquickpopup_p_p.h
+++ b/src/quicktemplates2/qquickpopup_p_p.h
@@ -187,7 +187,7 @@ public:
QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy;
QQuickItem *parentItem = nullptr;
QQuickItem *dimmer = nullptr;
- QQuickWindow *window = nullptr;
+ QPointer<QQuickWindow> window;
QQuickTransition *enter = nullptr;
QQuickTransition *exit = nullptr;
QQuickPopupItem *popupItem = nullptr;
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index ff488dac..378ece50 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE
For a slider that allows the user to select a single value, see \l Slider.
\sa {Customizing RangeSlider}, {Input Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
class QQuickRangeSliderNodePrivate : public QObjectPrivate
@@ -752,7 +752,6 @@ qreal QQuickRangeSlider::valueAt(qreal position) const
\qmlproperty bool QtQuick.Controls::RangeSlider::first.hovered
\qmlproperty real QtQuick.Controls::RangeSlider::first.implicitHandleWidth
\qmlproperty real QtQuick.Controls::RangeSlider::first.implicitHandleHeight
- \qmlsignal void QtQuick.Controls::RangeSlider::moved()
\table
\header
@@ -801,15 +800,9 @@ qreal QQuickRangeSlider::valueAt(qreal position) const
\li implicitHandleHeight
\li This property holds the implicit height of the first handle.
This property was introduced in QtQuick.Controls 2.5.
- \row
- \li moved()
- \li This signal is emitted when the first handle has been interactively moved
- by the user by either touch, mouse, or keys.
-
- This signal was introduced in QtQuick.Controls 2.5.
\endtable
- \sa first.increase(), first.decrease()
+ \sa first.moved(), first.increase(), first.decrease()
*/
QQuickRangeSliderNode *QQuickRangeSlider::first() const
{
@@ -818,6 +811,17 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
}
/*!
+ \qmlsignal void QtQuick.Controls::RangeSlider::first.moved()
+ \qmlsignal void QtQuick.Controls::RangeSlider::second.moved()
+ \since QtQuick.Controls 2.5
+
+ This signal is emitted when either the first or second handle has been
+ interactively moved by the user by either touch, mouse, or keys.
+
+ \sa first, second
+*/
+
+/*!
\qmlpropertygroup QtQuick.Controls::RangeSlider::second
\qmlproperty real QtQuick.Controls::RangeSlider::second.value
\qmlproperty real QtQuick.Controls::RangeSlider::second.position
@@ -827,7 +831,6 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\qmlproperty bool QtQuick.Controls::RangeSlider::second.hovered
\qmlproperty real QtQuick.Controls::RangeSlider::second.implicitHandleWidth
\qmlproperty real QtQuick.Controls::RangeSlider::second.implicitHandleHeight
- \qmlsignal void QtQuick.Controls::RangeSlider::moved()
\table
\header
@@ -876,15 +879,9 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\li implicitHandleHeight
\li This property holds the implicit height of the second handle.
This property was introduced in QtQuick.Controls 2.5.
- \row
- \li moved()
- \li This signal is emitted when the second handle has been interactively moved
- by the user by either touch, mouse, or keys.
-
- This signal was introduced in QtQuick.Controls 2.5.
\endtable
- \sa second.increase(), second.decrease()
+ \sa second.moved(), second.increase(), second.decrease()
*/
QQuickRangeSliderNode *QQuickRangeSlider::second() const
{
diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp
index c0f73692..70390351 100644
--- a/src/quicktemplates2/qquickscrollview.cpp
+++ b/src/quicktemplates2/qquickscrollview.cpp
@@ -78,7 +78,8 @@ QT_BEGIN_NAMESPACE
\li If only a single item is used within a ScrollView, the content size is
automatically calculated based on the implicit size of its contained item.
However, if more than one item is used (or an implicit size is not
- provided), the \l contentWidth and \l contentHeight properties must
+ provided), the \l {QtQuick.Controls::Pane::}{contentWidth} and
+ \l {QtQuick.Controls::Pane::}{contentHeight} properties must
be set to the combined size of its contained items.
\li If the content size is less than or equal to the size of the ScrollView,
it will not be flickable.
@@ -112,7 +113,7 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-scrollview-interactive.qml file
\sa ScrollBar, ScrollIndicator, {Customizing ScrollView}, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
class QQuickScrollViewPrivate : public QQuickPanePrivate
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 274929b0..389e5c54 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -92,7 +92,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
\snippet qtquickcontrols2-spinbox-double.qml 1
- \sa Tumbler, {Customizing SpinBox}, {Focus Management in Qt Quick Controls 2}
+ \sa Tumbler, {Customizing SpinBox}, {Focus Management in Qt Quick Controls}
*/
/*!
diff --git a/src/quicktemplates2/qquicksplitview.cpp b/src/quicktemplates2/qquicksplitview.cpp
index d1e7a8ae..56392e9a 100644
--- a/src/quicktemplates2/qquicksplitview.cpp
+++ b/src/quicktemplates2/qquicksplitview.cpp
@@ -202,8 +202,8 @@ QT_BEGIN_NAMESPACE
SplitView.preferredWidth and \c SplitView.preferredHeight properties can be
serialized using the \l saveState() and \l restoreState() functions:
- \code
- import QtQuick.Controls 2.5
+ \qml \QtMinorVersion
+ import QtQuick.Controls 2.\1
import Qt.labs.settings 1.0
ApplicationWindow {
@@ -222,13 +222,13 @@ QT_BEGIN_NAMESPACE
// ...
}
}
- \endcode
+ \endqml
Alternatively, the \l {Settings::}{value()} and \l {Settings::}{setValue()}
functions of \l Settings can be used:
- \code
- import QtQuick.Controls 2.5
+ \qml \QtMinorVersion
+ import QtQuick.Controls 2.\1
import Qt.labs.settings 1.0
ApplicationWindow {
@@ -246,7 +246,7 @@ QT_BEGIN_NAMESPACE
// ...
}
}
- \endcode
+ \endqml
\sa SplitHandle, {Customizing SplitView}, {Container Controls}
*/
@@ -849,6 +849,8 @@ QQuickSplitViewPrivate::EffectiveSizeData QQuickSplitViewPrivate::effectiveSizeD
int QQuickSplitViewPrivate::handleIndexForSplitIndex(int splitIndex) const
{
+ // If it's the first and only item in the view, it doesn't have a handle,
+ // so return -1: splitIndex (0) - 1.
// If it's the last item in the view, it doesn't have a handle, so use
// the handle for the previous item.
return splitIndex == contentModel->count() - 1 ? splitIndex - 1 : splitIndex;
@@ -928,7 +930,6 @@ QQuickItem *QQuickSplitViewPrivate::getContentItem()
if (QQuickItem *item = QQuickContainerPrivate::getContentItem())
return item;
- // TODO: why are several created?
return new QQuickContentItem(q);
}
@@ -1016,11 +1017,13 @@ void QQuickSplitViewPrivate::itemVisibilityChanged(QQuickItem *item)
// of the corresponding handle (if one exists).
const int handleIndex = handleIndexForSplitIndex(itemIndex);
- QQuickItem *handleItem = m_handleItems.at(handleIndex);
- handleItem->setVisible(item->isVisible());
+ if (handleIndex != -1) {
+ QQuickItem *handleItem = m_handleItems.at(handleIndex);
+ handleItem->setVisible(item->isVisible());
- qCDebug(qlcQQuickSplitView) << "set visible property of handle item"
- << handleItem << "at index" << handleIndex << "to" << item->isVisible();
+ qCDebug(qlcQQuickSplitView) << "set visible property of handle item"
+ << handleItem << "at index" << handleIndex << "to" << item->isVisible();
+ }
updateHandleVisibilities();
updateFillIndex();
@@ -1337,10 +1340,6 @@ void QQuickSplitView::hoverMoveEvent(QHoverEvent *event)
qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << d->m_hoveredHandleIndex << "is no longer hovered";
d->m_hoveredHandleIndex = -1;
-
-#if QT_CONFIG(cursor)
- setCursor(Qt::ArrowCursor);
-#endif
} else {
// A child item of ours is hovered.
@@ -1353,23 +1352,23 @@ void QQuickSplitView::hoverMoveEvent(QHoverEvent *event)
}
// Now check if the newly hovered item is actually a handle.
- const int hoveredHandleIndex = d->m_handleItems.indexOf(hoveredItem);
- if (hoveredHandleIndex == -1)
- return;
+ d->m_hoveredHandleIndex = d->m_handleItems.indexOf(hoveredItem);
- // It's a handle, so it's now hovered.
- d->m_hoveredHandleIndex = hoveredHandleIndex;
+ if (d->m_hoveredHandleIndex != -1) {
+ QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>(
+ qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(hoveredItem, true));
+ QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(true);
- QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>(
- qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(hoveredItem, true));
- QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(true);
+ qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << d->m_hoveredHandleIndex << "is now hovered";
+ }
+ }
#if QT_CONFIG(cursor)
+ if (d->m_hoveredHandleIndex != -1)
setCursor(d->m_orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor);
+ else
+ setCursor(Qt::ArrowCursor);
#endif
-
- qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << d->m_hoveredHandleIndex << "is now hovered";
- }
}
void QQuickSplitView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index 18f65127..b2a95731 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -373,7 +373,7 @@ QT_BEGIN_NAMESPACE
\endlist
\sa {Customizing StackView}, {Navigation Controls}, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
QQuickStackView::QQuickStackView(QQuickItem *parent)
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index e6a88b47..3ba4f4d3 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE
or using anchors for its children works as expected.
\sa TabBar, PageIndicator, {Customizing SwipeView}, {Navigation Controls}, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
class QQuickSwipeViewPrivate : public QQuickContainerPrivate
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index 745023c3..5a439b4b 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-tabbar-flickable.qml 1
\sa TabButton, {Customizing TabBar}, {Navigation Controls}, {Container Controls},
- {Focus Management in Qt Quick Controls 2}
+ {Focus Management in Qt Quick Controls}
*/
class QQuickTabBarPrivate : public QQuickContainerPrivate
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 95dd9f93..ef59bd93 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -253,7 +253,10 @@ void QQuickTextAreaPrivate::inheritFont(const QFont &font)
parentFont.resolve(extra.isAllocated() ? extra->requestedFont.resolve() | font.resolve() : font.resolve());
const QFont defaultFont = QQuickTheme::font(QQuickTheme::TextArea);
- const QFont resolvedFont = parentFont.resolve(defaultFont);
+ QFont resolvedFont = parentFont.resolve(defaultFont);
+ // See comment in QQuickControlPrivate::inheritFont
+ if (defaultFont.families().isEmpty())
+ resolvedFont.setFamilies(QStringList());
setFont_helper(resolvedFont);
}
@@ -369,6 +372,8 @@ void QQuickTextAreaPrivate::detachFlickable()
QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
flickable = nullptr;
+
+ resizeBackground();
}
void QQuickTextAreaPrivate::ensureCursorVisible()
@@ -433,11 +438,21 @@ void QQuickTextAreaPrivate::resizeFlickableContent()
void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff)
{
- Q_UNUSED(item);
- Q_UNUSED(change);
Q_UNUSED(diff);
+ if (!resizingBackground && item == background) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(item);
+ // Only set hasBackgroundWidth/Height if it was a width/height change,
+ // otherwise we're prevented from setting a width/height in the future.
+ if (change.widthChange())
+ extra.value().hasBackgroundWidth = p->widthValid;
+ if (change.heightChange())
+ extra.value().hasBackgroundHeight = p->heightValid;
+ }
- resizeFlickableControl();
+ if (flickable)
+ resizeFlickableControl();
+ else
+ resizeBackground();
}
qreal QQuickTextAreaPrivate::getImplicitWidth() const
@@ -622,17 +637,17 @@ void QQuickTextArea::setBackground(QQuickItem *background)
d->background = background;
if (background) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(background);
+ if (p->widthValid || p->heightValid) {
+ d->extra.value().hasBackgroundWidth = p->widthValid;
+ d->extra.value().hasBackgroundHeight = p->heightValid;
+ }
if (d->flickable)
background->setParentItem(d->flickable);
else
background->setParentItem(this);
if (qFuzzyIsNull(background->z()))
background->setZ(-1);
- QQuickItemPrivate *p = QQuickItemPrivate::get(background);
- if (p->widthValid || p->heightValid) {
- d->extra.value().hasBackgroundWidth = p->widthValid;
- d->extra.value().hasBackgroundHeight = p->heightValid;
- }
if (isComponentComplete())
d->resizeBackground();
QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry);
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 56ffc52f..740edff0 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -223,7 +223,10 @@ void QQuickTextFieldPrivate::inheritFont(const QFont &font)
parentFont.resolve(extra.isAllocated() ? extra->requestedFont.resolve() | font.resolve() : font.resolve());
const QFont defaultFont = QQuickTheme::font(QQuickTheme::TextField);
- const QFont resolvedFont = parentFont.resolve(defaultFont);
+ QFont resolvedFont = parentFont.resolve(defaultFont);
+ // See comment in QQuickControlPrivate::inheritFont
+ if (defaultFont.families().isEmpty())
+ resolvedFont.setFamilies(QStringList());
setFont_helper(resolvedFont);
}
diff --git a/src/quicktemplates2/qquicktheme.cpp b/src/quicktemplates2/qquicktheme.cpp
index af49ffc9..1228714b 100644
--- a/src/quicktemplates2/qquicktheme.cpp
+++ b/src/quicktemplates2/qquicktheme.cpp
@@ -167,6 +167,8 @@ void QQuickTheme::setFont(Scope scope, const QFont &font)
{
Q_D(QQuickTheme);
d->fonts[scope] = QSharedPointer<QFont>::create(d->defaultFont ? d->defaultFont->resolve(font) : font);
+ // See comment in QQuickControlPrivate::inheritFont
+ d->fonts[scope]->setFamilies(QStringList());
}
void QQuickTheme::setPalette(Scope scope, const QPalette &palette)
diff --git a/src/quicktemplates2/qquicktoolbutton.cpp b/src/quicktemplates2/qquicktoolbutton.cpp
index eb70fbc4..b613e69b 100644
--- a/src/quicktemplates2/qquicktoolbutton.cpp
+++ b/src/quicktemplates2/qquicktoolbutton.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-toolbar.qml 1
ToolButton inherits its API from AbstractButton. For instance, you can set
- \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon},
+ \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon},
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 ddf434a2..0a36e0c7 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -238,12 +238,13 @@ void QQuickToolTip::setTimeout(int timeout)
if (d->timeout == timeout)
return;
+ d->timeout = timeout;
+
if (timeout <= 0)
d->stopTimeout();
else if (isVisible())
d->startTimeout();
- d->timeout = timeout;
emit timeoutChanged();
}
@@ -327,10 +328,14 @@ void QQuickToolTip::timerEvent(QTimerEvent *event)
if (event->timerId() == d->timeoutTimer.timerId()) {
d->stopTimeout();
QQuickPopup::setVisible(false);
- } else if (event->timerId() == d->delayTimer.timerId()) {
+ return;
+ }
+ if (event->timerId() == d->delayTimer.timerId()) {
d->stopDelay();
QQuickPopup::setVisible(true);
+ return;
}
+ QQuickPopup::timerEvent(event);
}
#if QT_CONFIG(accessibility)
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 8b702c60..85c70b1b 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -949,9 +949,20 @@ void QQuickTumblerAttachedPrivate::calculateDisplacement()
const qreal contentY = tumblerPrivate->viewContentY;
const qreal delegateH = delegateHeight(tumbler);
const qreal preferredHighlightBegin = tumblerPrivate->view->property("preferredHighlightBegin").toReal();
- // Tumbler's displacement goes from negative at the top to positive towards the bottom, so we must switch this around.
- const qreal reverseDisplacement = (contentY + preferredHighlightBegin) / delegateH;
- displacement = reverseDisplacement - index;
+ const qreal itemY = qobject_cast<QQuickItem*>(parent)->y();
+ qreal currentItemY = 0;
+ auto currentItem = tumblerPrivate->view->property("currentItem").value<QQuickItem*>();
+ if (currentItem)
+ currentItemY = currentItem->y();
+ // Start from the y position of the current item.
+ const qreal topOfCurrentItemInViewport = currentItemY - contentY;
+ // Then, calculate the distance between it and the preferredHighlightBegin.
+ const qreal relativePositionToPreferredHighlightBegin = topOfCurrentItemInViewport - preferredHighlightBegin;
+ // Next, calculate the distance between us and the current item.
+ const qreal distanceFromCurrentItem = currentItemY - itemY;
+ const qreal displacementInPixels = distanceFromCurrentItem - relativePositionToPreferredHighlightBegin;
+ // Convert it from pixels to a floating point index.
+ displacement = displacementInPixels / delegateH;
}
emitIfDisplacementChanged(previousDisplacement, displacement);