12#if QT_CONFIG(accessibility)
13#include <QtQuick/private/qquickaccessibleattached_p.h>
18Q_STATIC_LOGGING_CATEGORY(lcPopupItem,
"qt.quick.controls.popupitem")
20QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup)
26QQuickPopupItemPrivate *QQuickPopupItemPrivate::get(QQuickPopupItem *popupItem)
28 return popupItem->d_func();
31void QQuickPopupItemPrivate::implicitWidthChanged()
33 qCDebug(lcPopupItem).nospace() <<
"implicitWidthChanged called on " << q_func() <<
"; new implicitWidth is " << implicitWidth;
34 QQuickPagePrivate::implicitWidthChanged();
35 emit popup->implicitWidthChanged();
38void QQuickPopupItemPrivate::implicitHeightChanged()
40 qCDebug(lcPopupItem).nospace() <<
"implicitHeightChanged called on " << q_func() <<
"; new implicitHeight is " << implicitHeight;
41 QQuickPagePrivate::implicitHeightChanged();
42 emit popup->implicitHeightChanged();
45void QQuickPopupItemPrivate::resolveFont()
47 if (QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(popup->window()))
48 inheritFont(window->font());
50 inheritFont(QQuickTheme::font(QQuickTheme::System));
53QQuickItem *QQuickPopupItemPrivate::getContentItem()
56 if (QQuickItem *item = QQuickPagePrivate::getContentItem())
59 return new QQuickContentItem(popup, q);
64void QQuickPopupItemPrivate::cancelContentItem()
66 quickCancelDeferred(popup, contentItemName());
69void QQuickPopupItemPrivate::executeContentItem(
bool complete)
71 if (contentItem.wasExecuted())
74 if (!contentItem || complete)
75 quickBeginDeferred(popup, contentItemName(), contentItem);
77 quickCompleteDeferred(popup, contentItemName(), contentItem);
80void QQuickPopupItemPrivate::cancelBackground()
82 quickCancelDeferred(popup, backgroundName());
85void QQuickPopupItemPrivate::executeBackground(
bool complete)
87 if (background.wasExecuted())
90 if (!background || complete)
91 quickBeginDeferred(popup, backgroundName(), background);
93 quickCompleteDeferred(popup, backgroundName(), background);
96QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup)
97 : QQuickPage(*(
new QQuickPopupItemPrivate(popup)),
nullptr)
100 setFlag(ItemIsFocusScope);
101 setAcceptedMouseButtons(Qt::AllButtons);
102#if QT_CONFIG(quicktemplates2_multitouch)
103 setAcceptTouchEvents(
true);
106 setCursor(Qt::ArrowCursor);
109 connect(popup, &QQuickPopup::paletteChanged,
this, &QQuickItem::paletteChanged);
110 connect(popup, &QQuickPopup::paletteCreated,
this, &QQuickItem::paletteCreated);
112#if QT_CONFIG(quicktemplates2_hover)
114 setHoverEnabled(
true);
120QQuickPalette *QQuickPopupItemPrivate::palette()
const
122 return QQuickPopupPrivate::get(popup)->palette();
125void QQuickPopupItemPrivate::setPalette(QQuickPalette *p)
127 QQuickPopupPrivate::get(popup)->setPalette(p);
130void QQuickPopupItemPrivate::resetPalette()
132 QQuickPopupPrivate::get(popup)->resetPalette();
135QPalette QQuickPopupItemPrivate::defaultPalette()
const
137 return QQuickPopupPrivate::get(popup)->defaultPalette();
140bool QQuickPopupItemPrivate::providesPalette()
const
142 return QQuickPopupPrivate::get(popup)->providesPalette();
145QPalette QQuickPopupItemPrivate::parentPalette(
const QPalette &fallbackPalette)
const
147 return QQuickPopupPrivate::get(popup)->parentPalette(fallbackPalette);
150void QQuickPopupItem::updatePolish()
152 Q_D(QQuickPopupItem);
153 return QQuickPopupPrivate::get(d->popup)->reposition();
156bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
158 Q_D(QQuickPopupItem);
159 return d->popup->childMouseEventFilter(child, event);
162void QQuickPopupItem::focusInEvent(QFocusEvent *event)
164 Q_D(QQuickPopupItem);
165 d->popup->focusInEvent(event);
168void QQuickPopupItem::focusOutEvent(QFocusEvent *event)
170 Q_D(QQuickPopupItem);
171 d->popup->focusOutEvent(event);
174void QQuickPopupItem::keyPressEvent(QKeyEvent *event)
176 Q_D(QQuickPopupItem);
177 d->popup->keyPressEvent(event);
180void QQuickPopupItem::keyReleaseEvent(QKeyEvent *event)
182 Q_D(QQuickPopupItem);
183 d->popup->keyReleaseEvent(event);
186void QQuickPopupItem::mousePressEvent(QMouseEvent *event)
188 Q_D(QQuickPopupItem);
189 d->popup->mousePressEvent(event);
192void QQuickPopupItem::mouseMoveEvent(QMouseEvent *event)
194 Q_D(QQuickPopupItem);
195 d->popup->mouseMoveEvent(event);
198void QQuickPopupItem::mouseReleaseEvent(QMouseEvent *event)
200 Q_D(QQuickPopupItem);
201 d->popup->mouseReleaseEvent(event);
204void QQuickPopupItem::mouseDoubleClickEvent(QMouseEvent *event)
206 Q_D(QQuickPopupItem);
207 d->popup->mouseDoubleClickEvent(event);
210void QQuickPopupItem::mouseUngrabEvent()
212 Q_D(QQuickPopupItem);
213 d->popup->mouseUngrabEvent();
216#if QT_CONFIG(quicktemplates2_multitouch)
217void QQuickPopupItem::touchEvent(QTouchEvent *event)
219 Q_D(QQuickPopupItem);
220 d->popup->touchEvent(event);
223void QQuickPopupItem::touchUngrabEvent()
225 Q_D(QQuickPopupItem);
226 d->popup->touchUngrabEvent();
230#if QT_CONFIG(wheelevent)
231void QQuickPopupItem::wheelEvent(QWheelEvent *event)
233 Q_D(QQuickPopupItem);
234 d->popup->wheelEvent(event);
238void QQuickPopupItem::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
240 Q_D(QQuickPopupItem);
241 QQuickPage::contentItemChange(newItem, oldItem);
242 d->popup->contentItemChange(newItem, oldItem);
245void QQuickPopupItem::contentSizeChange(
const QSizeF &newSize,
const QSizeF &oldSize)
247 Q_D(QQuickPopupItem);
248 qCDebug(lcPopupItem) <<
"contentSizeChange called on" <<
this <<
"newSize" << newSize <<
"oldSize" << oldSize;
249 QQuickPage::contentSizeChange(newSize, oldSize);
250 d->popup->contentSizeChange(newSize, oldSize);
253void QQuickPopupItem::fontChange(
const QFont &newFont,
const QFont &oldFont)
255 Q_D(QQuickPopupItem);
256 QQuickPage::fontChange(newFont, oldFont);
257 d->popup->fontChange(newFont, oldFont);
260void QQuickPopupItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
262 Q_D(QQuickPopupItem);
263 qCDebug(lcPopupItem) <<
"geometryChange called on" <<
this <<
"newGeometry" << newGeometry <<
"oldGeometry" << oldGeometry;
264 QQuickPage::geometryChange(newGeometry, oldGeometry);
265 d->popup->geometryChange(newGeometry, oldGeometry);
268void QQuickPopupItem::localeChange(
const QLocale &newLocale,
const QLocale &oldLocale)
270 Q_D(QQuickPopupItem);
271 QQuickPage::localeChange(newLocale, oldLocale);
272 d->popup->localeChange(newLocale, oldLocale);
275void QQuickPopupItem::mirrorChange()
277 Q_D(QQuickPopupItem);
278 emit d->popup->mirroredChanged();
281void QQuickPopupItem::itemChange(ItemChange change,
const ItemChangeData &data)
283 Q_D(QQuickPopupItem);
284 QQuickPage::itemChange(change, data);
285 d->popup->itemChange(change, data);
288void QQuickPopupItem::paddingChange(
const QMarginsF &newPadding,
const QMarginsF &oldPadding)
290 Q_D(QQuickPopupItem);
291 QQuickPage::paddingChange(newPadding, oldPadding);
292 d->popup->paddingChange(newPadding, oldPadding);
295void QQuickPopupItem::enabledChange()
297 Q_D(QQuickPopupItem);
304 emit d->popup->enabledChanged();
307QFont QQuickPopupItem::defaultFont()
const
309 Q_D(
const QQuickPopupItem);
310 return d->popup->defaultFont();
313#if QT_CONFIG(accessibility)
314QAccessible::Role QQuickPopupItem::accessibleRole()
const
316 Q_D(
const QQuickPopupItem);
317 return d->popup->effectiveAccessibleRole();
320void QQuickPopupItem::accessibilityActiveChanged(
bool active)
322 Q_D(
const QQuickPopupItem);
325 const QQuickAccessibleAttached *popupAccessibleAttached = QQuickControlPrivate::accessibleAttached(d->popup);
326 const QString oldPopupName = popupAccessibleAttached ? popupAccessibleAttached->name() : QString();
327 const bool wasNameExplicitlySetOnPopup = popupAccessibleAttached && popupAccessibleAttached->wasNameExplicitlySet();
329 QQuickPage::accessibilityActiveChanged(active);
331 QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(
this);
332 const QString ourName = accessibleAttached ? accessibleAttached->name() : QString();
333 if (wasNameExplicitlySetOnPopup && accessibleAttached && ourName != oldPopupName) {
340 accessibleAttached->setName(oldPopupName);
345 d->popup->accessibilityActiveChanged(active);
351#include "moc_qquickpopupitem_p_p.cpp"