diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
| commit | b58ec3b086518da5aa573f99426235854c23e35f (patch) | |
| tree | 861a9935d8f1cdba2fdca546836a351736dbddbf /src/quick/items/qquickitem.cpp | |
| parent | 4826f86e274f1b29bd769e6790824f9e62a40f62 (diff) | |
| parent | 22032227d16c39211e2ebceef97d21f4d89c7c87 (diff) | |
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
| -rw-r--r-- | src/quick/items/qquickitem.cpp | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 1e4af6838d..82587a178a 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2375,6 +2375,20 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item) if (item == item->window()->contentItem()) return true; + const auto tabFocus = QGuiApplication::styleHints()->tabFocusBehavior(); + if (tabFocus == Qt::NoTabFocus) + return false; + if (tabFocus == Qt::TabFocusAllControls) + return true; + + QVariant editable = item->property("editable"); + if (editable.isValid()) + return editable.toBool(); + + QVariant readonly = item->property("readOnly"); + if (readonly.isValid()) + return !readonly.toBool() && item->property("text").isValid(); + #if QT_CONFIG(accessibility) QAccessible::Role role = QQuickItemPrivate::get(item)->effectiveAccessibleRole(); if (role == QAccessible::EditableText || role == QAccessible::Table || role == QAccessible::List) { @@ -2385,14 +2399,6 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item) } #endif - QVariant editable = item->property("editable"); - if (editable.isValid()) - return editable.toBool(); - - QVariant readonly = item->property("readOnly"); - if (readonly.isValid() && !readonly.toBool() && item->property("text").isValid()) - return true; - return false; } @@ -2473,8 +2479,6 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo if (!contentItem) return item; - bool all = QGuiApplication::styleHints()->tabFocusBehavior() == Qt::TabFocusAllControls; - QQuickItem *from = nullptr; bool isTabFence = item->d_func()->isTabFence; if (forward) { @@ -2594,7 +2598,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo } } } while (skip || !current->activeFocusOnTab() || !current->isEnabled() || !current->isVisible() - || !(all || QQuickItemPrivate::canAcceptTabFocus(current))); + || !(QQuickItemPrivate::canAcceptTabFocus(current))); return current; } @@ -2666,9 +2670,10 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) while (!scopeItem->isFocusScope() && scopeItem->parentItem()) scopeItem = scopeItem->parentItem(); if (d->window) { - d->deliveryAgentPrivate()-> - clearFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, + if (QQuickDeliveryAgentPrivate *da = d->deliveryAgentPrivate()) { + da->clearFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, QQuickDeliveryAgentPrivate::DontChangeFocusProperty); + } if (scopeFocusedItem != this) QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true); } else { @@ -2742,9 +2747,10 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) emit scopeFocusedItem->focusChanged(false); } else { if (d->window) { - d->deliveryAgentPrivate()-> - setFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, + if (QQuickDeliveryAgentPrivate *da = d->deliveryAgentPrivate()) { + da->setFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, QQuickDeliveryAgentPrivate::DontChangeFocusProperty); + } } else { QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, true); } @@ -6499,9 +6505,10 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible) dirty(Visible); if (parentItem) QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); - if (window) - if (auto agent = deliveryAgentPrivate(); agent) + if (window) { + if (auto agent = deliveryAgentPrivate()) agent->removeGrabber(q, true, true, true); + } bool childVisibilityChanged = false; for (int ii = 0; ii < childItems.size(); ++ii) @@ -6839,12 +6846,26 @@ void QQuickItem::setSmooth(bool smooth) key events used by Keys or KeyNavigation have precedence over focus chain behavior; ignore the events in other key handlers to allow it to propagate. + + \note {QStyleHints::tabFocusBehavior}{tabFocusBehavior} can further limit focus + to only specific types of controls, such as only text or list controls. This is + the case on macOS, where focus to particular controls may be restricted based on + system settings. + + \sa QStyleHints::tabFocusBehavior, focusPolicy */ /*! \property QQuickItem::activeFocusOnTab This property holds whether the item wants to be in the tab focus chain. By default, this is set to \c false. + + \note {QStyleHints::tabFocusBehavior}{tabFocusBehavior} can further limit focus + to only specific types of controls, such as only text or list controls. This is + the case on macOS, where focus to particular controls may be restricted based on + system settings. + + \sa QStyleHints::tabFocusBehavior, focusPolicy */ bool QQuickItem::activeFocusOnTab() const { @@ -8381,7 +8402,8 @@ void QQuickItem::ungrabTouchPoints() Q_D(QQuickItem); if (!d->window) return; - d->deliveryAgentPrivate()->removeGrabber(this, false, true); + if (QQuickDeliveryAgentPrivate *da = d->deliveryAgentPrivate()) + da->removeGrabber(this, false, true); } /*! @@ -9877,7 +9899,7 @@ QRectF QQuickItem::mapFromItem(const QQuickItem *item, qreal x, qreal y, qreal w //! \internal QPointF QQuickItem::mapToItem(const QQuickItem *item, qreal x, qreal y) -{ return mapToItem(item, QPoint(x, y)); } +{ return mapToItem(item, QPointF(x, y)); } //! \internal QRectF QQuickItem::mapToItem(const QQuickItem *item, const QRectF &rect) const |
