12#include <QtQuick/private/qquickattachedpropertypropagator_p.h>
14#if QT_CONFIG(accessibility)
15#include <QtQuick/private/qquickaccessibleattached_p.h>
20Q_STATIC_LOGGING_CATEGORY(lcPopupItem,
"qt.quick.controls.popupitem")
22QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup)
28QQuickPopupItemPrivate *QQuickPopupItemPrivate::get(QQuickPopupItem *popupItem)
30 return popupItem->d_func();
33void QQuickPopupItemPrivate::implicitWidthChanged()
35 qCDebug(lcPopupItem).nospace() <<
"implicitWidthChanged called on " << q_func() <<
"; new implicitWidth is " << implicitWidth;
36 QQuickPagePrivate::implicitWidthChanged();
37 emit popup->implicitWidthChanged();
40void QQuickPopupItemPrivate::implicitHeightChanged()
42 qCDebug(lcPopupItem).nospace() <<
"implicitHeightChanged called on " << q_func() <<
"; new implicitHeight is " << implicitHeight;
43 QQuickPagePrivate::implicitHeightChanged();
44 emit popup->implicitHeightChanged();
47void QQuickPopupItemPrivate::resolveFont()
49 if (QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(popup->window()))
50 inheritFont(window->font());
52 inheritFont(QQuickTheme::font(QQuickTheme::System));
55QQuickItem *QQuickPopupItemPrivate::getContentItem()
58 if (QQuickItem *item = QQuickPagePrivate::getContentItem())
61 return new QQuickContentItem(popup, q);
66void QQuickPopupItemPrivate::cancelContentItem()
68 quickCancelDeferred(popup, contentItemName());
71void QQuickPopupItemPrivate::executeContentItem(
bool complete)
73 if (contentItem.wasExecuted())
76 if (!contentItem || complete)
77 quickBeginDeferred(popup, contentItemName(), contentItem);
79 quickCompleteDeferred(popup, contentItemName(), contentItem);
82void QQuickPopupItemPrivate::cancelBackground()
84 quickCancelDeferred(popup, backgroundName());
87void QQuickPopupItemPrivate::executeBackground(
bool complete)
89 if (background.wasExecuted())
92 if (!background || complete)
93 quickBeginDeferred(popup, backgroundName(), background);
95 quickCompleteDeferred(popup, backgroundName(), background);
98QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup)
99 : QQuickPage(*(
new QQuickPopupItemPrivate(popup)),
nullptr)
102 setFlag(ItemIsFocusScope);
103 setAcceptedMouseButtons(Qt::AllButtons);
104#if QT_CONFIG(quicktemplates2_multitouch)
105 setAcceptTouchEvents(
true);
108 setCursor(Qt::ArrowCursor);
111 connect(popup, &QQuickPopup::paletteChanged,
this, &QQuickItem::paletteChanged);
112 connect(popup, &QQuickPopup::paletteCreated,
this, &QQuickItem::paletteCreated);
114#if QT_CONFIG(quicktemplates2_hover)
116 setHoverEnabled(
true);
122QQuickPalette *QQuickPopupItemPrivate::palette()
const
124 return QQuickPopupPrivate::get(popup)->palette();
127void QQuickPopupItemPrivate::setPalette(QQuickPalette *p)
129 QQuickPopupPrivate::get(popup)->setPalette(p);
132void QQuickPopupItemPrivate::resetPalette()
134 QQuickPopupPrivate::get(popup)->resetPalette();
137QPalette QQuickPopupItemPrivate::defaultPalette()
const
139 return QQuickPopupPrivate::get(popup)->defaultPalette();
142bool QQuickPopupItemPrivate::providesPalette()
const
144 return QQuickPopupPrivate::get(popup)->providesPalette();
147QPalette QQuickPopupItemPrivate::parentPalette(
const QPalette &fallbackPalette)
const
149 return QQuickPopupPrivate::get(popup)->parentPalette(fallbackPalette);
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185QtPrivate::QQuickAttachedPropertyPropagator *QQuickPopupItemPrivate::attachedPropertyPropagator_parent(
186 const QMetaObject *attachedType)
188 qCDebug(lcAttachedPropertyPropagator).noquote() <<
"- attachee is a popup item" << q_func()
189 <<
"- checking if it has an attached object";
190 QtPrivate::QQuickAttachedPropertyPropagator *popupAttached
191 = QtPrivate::QQuickAttachedPropertyPropagator::attachedObject(attachedType, popup);
193 qCDebug(lcAttachedPropertyPropagator).noquote() <<
"- popup item has attached object"
194 << popupAttached <<
"- returning";
195 return popupAttached;
198 qCDebug(lcAttachedPropertyPropagator).noquote() <<
"- popup item does not have attached object";
204void QQuickPopupItem::updatePolish()
206 Q_D(QQuickPopupItem);
207 return QQuickPopupPrivate::get(d->popup)->reposition();
210bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
212 Q_D(QQuickPopupItem);
213 return d->popup->childMouseEventFilter(child, event);
216void QQuickPopupItem::focusInEvent(QFocusEvent *event)
218 Q_D(QQuickPopupItem);
219 d->popup->focusInEvent(event);
222void QQuickPopupItem::focusOutEvent(QFocusEvent *event)
224 Q_D(QQuickPopupItem);
225 d->popup->focusOutEvent(event);
228void QQuickPopupItem::keyPressEvent(QKeyEvent *event)
230 Q_D(QQuickPopupItem);
231 d->popup->keyPressEvent(event);
234void QQuickPopupItem::keyReleaseEvent(QKeyEvent *event)
236 Q_D(QQuickPopupItem);
237 d->popup->keyReleaseEvent(event);
240void QQuickPopupItem::mousePressEvent(QMouseEvent *event)
242 Q_D(QQuickPopupItem);
243 d->popup->mousePressEvent(event);
246void QQuickPopupItem::mouseMoveEvent(QMouseEvent *event)
248 Q_D(QQuickPopupItem);
249 d->popup->mouseMoveEvent(event);
252void QQuickPopupItem::mouseReleaseEvent(QMouseEvent *event)
254 Q_D(QQuickPopupItem);
255 d->popup->mouseReleaseEvent(event);
258void QQuickPopupItem::mouseDoubleClickEvent(QMouseEvent *event)
260 Q_D(QQuickPopupItem);
261 d->popup->mouseDoubleClickEvent(event);
264void QQuickPopupItem::mouseUngrabEvent()
266 Q_D(QQuickPopupItem);
267 d->popup->mouseUngrabEvent();
270#if QT_CONFIG(quicktemplates2_multitouch)
271void QQuickPopupItem::touchEvent(QTouchEvent *event)
273 Q_D(QQuickPopupItem);
274 d->popup->touchEvent(event);
277void QQuickPopupItem::touchUngrabEvent()
279 Q_D(QQuickPopupItem);
280 d->popup->touchUngrabEvent();
284#if QT_CONFIG(wheelevent)
285void QQuickPopupItem::wheelEvent(QWheelEvent *event)
287 Q_D(QQuickPopupItem);
288 d->popup->wheelEvent(event);
292#if QT_CONFIG(quick_draganddrop)
293void QQuickPopupItem::dragEnterEvent(QDragEnterEvent *event)
295 Q_D(QQuickPopupItem);
296 d->popup->dragEnterEvent(event);
299void QQuickPopupItem::dragMoveEvent(QDragMoveEvent *event)
301 Q_D(QQuickPopupItem);
302 d->popup->dragMoveEvent(event);
304void QQuickPopupItem::dragLeaveEvent(QDragLeaveEvent *event)
306 Q_D(QQuickPopupItem);
307 d->popup->dragLeaveEvent(event);
309void QQuickPopupItem::dropEvent(QDropEvent *event)
311 Q_D(QQuickPopupItem);
312 d->popup->dropEvent(event);
317void QQuickPopupItem::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
319 Q_D(QQuickPopupItem);
320 QQuickPage::contentItemChange(newItem, oldItem);
321 d->popup->contentItemChange(newItem, oldItem);
324void QQuickPopupItem::contentSizeChange(
const QSizeF &newSize,
const QSizeF &oldSize)
326 Q_D(QQuickPopupItem);
327 qCDebug(lcPopupItem) <<
"contentSizeChange called on" <<
this <<
"newSize" << newSize <<
"oldSize" << oldSize;
328 QQuickPage::contentSizeChange(newSize, oldSize);
329 d->popup->contentSizeChange(newSize, oldSize);
332void QQuickPopupItem::fontChange(
const QFont &newFont,
const QFont &oldFont)
334 Q_D(QQuickPopupItem);
335 QQuickPage::fontChange(newFont, oldFont);
336 d->popup->fontChange(newFont, oldFont);
339void QQuickPopupItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
341 Q_D(QQuickPopupItem);
342 qCDebug(lcPopupItem) <<
"geometryChange called on" <<
this <<
"newGeometry" << newGeometry <<
"oldGeometry" << oldGeometry;
343 QQuickPage::geometryChange(newGeometry, oldGeometry);
344 d->popup->geometryChange(newGeometry, oldGeometry);
347void QQuickPopupItem::localeChange(
const QLocale &newLocale,
const QLocale &oldLocale)
349 Q_D(QQuickPopupItem);
350 QQuickPage::localeChange(newLocale, oldLocale);
351 d->popup->localeChange(newLocale, oldLocale);
354void QQuickPopupItem::mirrorChange()
356 Q_D(QQuickPopupItem);
357 emit d->popup->mirroredChanged();
360void QQuickPopupItem::itemChange(ItemChange change,
const ItemChangeData &data)
362 Q_D(QQuickPopupItem);
363 QQuickPage::itemChange(change, data);
364 d->popup->itemChange(change, data);
367void QQuickPopupItem::paddingChange(
const QMarginsF &newPadding,
const QMarginsF &oldPadding)
369 Q_D(QQuickPopupItem);
370 QQuickPage::paddingChange(newPadding, oldPadding);
371 d->popup->paddingChange(newPadding, oldPadding);
374void QQuickPopupItem::insetChange(
const QMarginsF &newInset,
const QMarginsF &oldInset)
376 Q_D(QQuickPopupItem);
377 QQuickPage::insetChange(newInset, oldInset);
378 d->popup->insetChange(newInset, oldInset);
381void QQuickPopupItem::spacingChange(qreal newSpacing, qreal oldSpacing)
383 Q_D(QQuickPopupItem);
384 QQuickPage::spacingChange(newSpacing, oldSpacing);
385 d->popup->spacingChange(newSpacing, oldSpacing);
388void QQuickPopupItem::enabledChange()
390 Q_D(QQuickPopupItem);
397 emit d->popup->enabledChanged();
400QFont QQuickPopupItem::defaultFont()
const
402 Q_D(
const QQuickPopupItem);
403 return d->popup->defaultFont();
406#if QT_CONFIG(accessibility)
407QAccessible::Role QQuickPopupItem::accessibleRole()
const
409 Q_D(
const QQuickPopupItem);
410 return d->popup->effectiveAccessibleRole();
413void QQuickPopupItem::accessibilityActiveChanged(
bool active)
415 Q_D(
const QQuickPopupItem);
418 const QQuickAccessibleAttached *popupAccessibleAttached = QQuickControlPrivate::accessibleAttached(d->popup);
419 const QString oldPopupName = popupAccessibleAttached ? popupAccessibleAttached->name() : QString();
420 const bool wasNameExplicitlySetOnPopup = popupAccessibleAttached && popupAccessibleAttached->wasNameExplicitlySet();
422 QQuickPage::accessibilityActiveChanged(active);
424 QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(
this);
425 const QString ourName = accessibleAttached ? accessibleAttached->name() : QString();
426 if (wasNameExplicitlySetOnPopup && accessibleAttached && ourName != oldPopupName) {
433 accessibleAttached->setName(oldPopupName);
438 d->popup->accessibilityActiveChanged(active);
444#include "moc_qquickpopupitem_p_p.cpp"
Combined button and popup list for selecting options.