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);
292void QQuickPopupItem::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
294 Q_D(QQuickPopupItem);
295 QQuickPage::contentItemChange(newItem, oldItem);
296 d->popup->contentItemChange(newItem, oldItem);
299void QQuickPopupItem::contentSizeChange(
const QSizeF &newSize,
const QSizeF &oldSize)
301 Q_D(QQuickPopupItem);
302 qCDebug(lcPopupItem) <<
"contentSizeChange called on" <<
this <<
"newSize" << newSize <<
"oldSize" << oldSize;
303 QQuickPage::contentSizeChange(newSize, oldSize);
304 d->popup->contentSizeChange(newSize, oldSize);
307void QQuickPopupItem::fontChange(
const QFont &newFont,
const QFont &oldFont)
309 Q_D(QQuickPopupItem);
310 QQuickPage::fontChange(newFont, oldFont);
311 d->popup->fontChange(newFont, oldFont);
314void QQuickPopupItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
316 Q_D(QQuickPopupItem);
317 qCDebug(lcPopupItem) <<
"geometryChange called on" <<
this <<
"newGeometry" << newGeometry <<
"oldGeometry" << oldGeometry;
318 QQuickPage::geometryChange(newGeometry, oldGeometry);
319 d->popup->geometryChange(newGeometry, oldGeometry);
322void QQuickPopupItem::localeChange(
const QLocale &newLocale,
const QLocale &oldLocale)
324 Q_D(QQuickPopupItem);
325 QQuickPage::localeChange(newLocale, oldLocale);
326 d->popup->localeChange(newLocale, oldLocale);
329void QQuickPopupItem::mirrorChange()
331 Q_D(QQuickPopupItem);
332 emit d->popup->mirroredChanged();
335void QQuickPopupItem::itemChange(ItemChange change,
const ItemChangeData &data)
337 Q_D(QQuickPopupItem);
338 QQuickPage::itemChange(change, data);
339 d->popup->itemChange(change, data);
342void QQuickPopupItem::paddingChange(
const QMarginsF &newPadding,
const QMarginsF &oldPadding)
344 Q_D(QQuickPopupItem);
345 QQuickPage::paddingChange(newPadding, oldPadding);
346 d->popup->paddingChange(newPadding, oldPadding);
349void QQuickPopupItem::enabledChange()
351 Q_D(QQuickPopupItem);
358 emit d->popup->enabledChanged();
361QFont QQuickPopupItem::defaultFont()
const
363 Q_D(
const QQuickPopupItem);
364 return d->popup->defaultFont();
367#if QT_CONFIG(accessibility)
368QAccessible::Role QQuickPopupItem::accessibleRole()
const
370 Q_D(
const QQuickPopupItem);
371 return d->popup->effectiveAccessibleRole();
374void QQuickPopupItem::accessibilityActiveChanged(
bool active)
376 Q_D(
const QQuickPopupItem);
379 const QQuickAccessibleAttached *popupAccessibleAttached = QQuickControlPrivate::accessibleAttached(d->popup);
380 const QString oldPopupName = popupAccessibleAttached ? popupAccessibleAttached->name() : QString();
381 const bool wasNameExplicitlySetOnPopup = popupAccessibleAttached && popupAccessibleAttached->wasNameExplicitlySet();
383 QQuickPage::accessibilityActiveChanged(active);
385 QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(
this);
386 const QString ourName = accessibleAttached ? accessibleAttached->name() : QString();
387 if (wasNameExplicitlySetOnPopup && accessibleAttached && ourName != oldPopupName) {
394 accessibleAttached->setName(oldPopupName);
399 d->popup->accessibilityActiveChanged(active);
405#include "moc_qquickpopupitem_p_p.cpp"
Combined button and popup list for selecting options.