Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickpopupanchors.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
8
10
11QQuickPopupAnchors::QQuickPopupAnchors(QQuickPopup *popup)
12 : QObject(*(new QQuickPopupAnchorsPrivate), popup)
13{
14 Q_D(QQuickPopupAnchors);
15 d->popup = popup;
16}
17
18QQuickPopupAnchors::~QQuickPopupAnchors()
19{
20 Q_D(const QQuickPopupAnchors);
21 if (d->centerIn) {
22 auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
23 centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
24 }
25}
26
27QQuickItem *QQuickPopupAnchors::centerIn() const
28{
29 Q_D(const QQuickPopupAnchors);
30 return d->centerIn;
31}
32
33void QQuickPopupAnchors::setCenterIn(QQuickItem *item)
34{
35 Q_D(QQuickPopupAnchors);
36 if (item == d->centerIn)
37 return;
38
39 if (d->centerIn) {
40 auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
41 centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
42 }
43
44 d->centerIn = item;
45
46 if (d->centerIn) {
47 auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
48 centerInPrivate->addItemChangeListener(this, QQuickItemPrivate::Destroyed);
49 }
50
51 QQuickPopupPrivate::get(d->popup)->reposition();
52
53 emit centerInChanged();
54}
55
56void QQuickPopupAnchors::resetCenterIn()
57{
58 setCenterIn(nullptr);
59}
60
61void QQuickPopupAnchors::itemDestroyed(QQuickItem *)
62{
63 resetCenterIn();
64}
65
66QT_END_NAMESPACE
67
68#include "moc_qquickpopupanchors_p.cpp"