6#include <QtQuick/qquickrendercontrol.h>
8#include <QtQuick/private/qquickitem_p.h>
9#include <QtQuick/private/qquickrectangle_p.h>
10#include <QtQuick/private/qquickwindowmodule_p.h>
11#include <QtQuick/private/qquickimplicitsizeitem_p_p.h>
17using namespace
Qt::StringLiterals;
105 bool transformChanged(
QQuickItem *transformedItem)
override;
129 qCDebug(lcWindowContainer).verbosity(1) <<
"Creating window container"
130 <<
this <<
"with parent" <<
parent <<
"and" << containerMode;
132 d->containerMode = containerMode;
136 connect(
this, &QQuickItem::windowChanged,
137 this, &QQuickWindowContainer::parentWindowChanged);
139 if (lcWindowContainer().isDebugEnabled()) {
141 debugRectangle->setColor(
QColor(255, 0, 255, 20));
142 auto *
border = debugRectangle->border();
146 rectPrivate->anchors()->setFill(
this);
153 qCDebug(lcWindowContainer) <<
"Destructing window container" <<
this;
158 qCDebug(lcWindowContainer) <<
"Contained window" <<
d->window
160 "JavaScript" :
"C++") <<
"ownership";
164 d->window->destroy();
165 d->window->setParent(
nullptr);
173 qCDebug(lcWindowContainer) <<
"Destroying" <<
d->window
174 <<
"with platform window" << (
d->window ?
d->window->handle() :
nullptr);
176 d->window->destroy();
181 qCDebug(lcWindowContainer) <<
"Class begin for" <<
this;
190 qCDebug(lcWindowContainer) <<
"Component completed for" <<
this;
194 initializeContainedWindow();
205 qCDebug(lcWindowContainer) <<
"Setting contained window for" <<
this <<
"to" <<
window;
212 if (
auto *previousWindow =
d->window) {
213 qCDebug(lcWindowContainer) <<
"Decoupling container from" <<
d->window;
214 previousWindow->disconnect(
this);
215 previousWindow->removeEventFilter(
this);
216 previousWindow->setParent(
nullptr);
223 if (
auto *quickWindow = qobject_cast<QQuickWindowQmlImpl*>(
d->window)) {
225 quickWindow->setVisualParent(
this);
241 d->window->installEventFilter(
this);
243 if (
d->componentComplete)
244 initializeContainedWindow();
253void QQuickWindowContainer::initializeContainedWindow()
259 qCDebug(lcWindowContainer) <<
"Doing initial sync between" <<
d->window <<
"and" <<
this;
275void QQuickWindowContainer::syncWindowToItem()
279 const auto windowGeometry =
d->window ?
d->window->geometry() :
QRect();
281 qCDebug(lcWindowContainer) <<
"Syncing window state from" <<
d->window
282 <<
"with geometry" << windowGeometry <<
"to" <<
this
283 <<
"with mode" <<
d->containerMode;
289 auto itemSize =
d->window ?
transform.mapRect(windowGeometry).size()
318 qCDebug(lcWindowContainer) <<
"Propagating" <<
this <<
"state"
319 <<
"to" <<
d->window;
321 auto *parentWindow =
window();
329 if (!
d->window || !parentWindow)
332 if (
d->window->parent() != parentWindow) {
333 qCDebug(lcWindowContainer) <<
"Updating window parent to" << parentWindow;
334 d->window->setParent(parentWindow);
346 QRect windowGeometry = itemSceneRect.toRect();
347 if (windowGeometry !=
d->window->geometry()) {
349 qCDebug(lcWindowContainer) <<
"Updating window geometry to" << windowGeometry
350 <<
"based on item rect" << itemRect <<
"and scene rect" << itemSceneRect;
351 d->window->setGeometry(windowGeometry);
363 const auto clipMask = [&]{
372 auto rect = scaleTransform.mapRect(
clipRect()).toRect();
380 return QRect(-1, -1, 1, 1);
385 if (clipMask !=
d->window->mask().boundingRect()) {
386 qCDebug(lcWindowContainer) <<
"Updating window clip mask to" << clipMask
387 <<
"based on clip rect" <<
clipRect();
388 d->window->setMask(clipMask);
402 qCDebug(lcWindowContainer) <<
"Updating window visibility"
403 <<
"based on item visible" <<
isVisible();
430 rect = mappedViewportRect.intersected(
rect);
450void QQuickWindowContainer::windowUpdated()
454 if (lcWindowContainer().isDebugEnabled()) {
457 qCDebug(lcWindowContainer).noquote() <<
d->window << signalName;
463 qCDebug(lcWindowContainer) <<
"Overriding window state by polishing";
485 qCDebug(lcWindowContainer) <<
"Surface created for" <<
object;
492 if (
auto *quickWindow = qobject_cast<QQuickWindow*>(
window()))
500void QQuickWindowContainer::windowDestroyed()
503 qCDebug(lcWindowContainer) <<
"Window" << (
void*)
d->window <<
"destroyed";
505 d->window->removeEventFilter(
this);
521 qCDebug(lcWindowContainer) <<
this <<
"geometry changed from"
522 << oldGeometry <<
"to" << newGeometry;
538 qCDebug(lcWindowContainer) <<
"Visible changed for" <<
this <<
"to" <<
isVisible();
553void QQuickWindowContainer::parentWindowChanged(
QQuickWindow *parentWindow)
555 qCDebug(lcWindowContainer) <<
this <<
"parent window changed to" << parentWindow;
572 d->window->destroy();
574 d->window->setParent(
nullptr);
587 qCDebug(lcWindowContainer) <<
"Transform changed for" << transformedItem
588 <<
"with dirty state" << transformedItemPrivate->dirtyToString();
590 if (transformedItemPrivate->dirtyAttributes
The QColor class provides colors based on RGB, HSV or CMYK values.
static ObjectOwnership objectOwnership(QObject *)
Returns the ownership of object.
int senderSignalIndex() const
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
virtual void classBegin()=0
Invoked after class creation, but before any properties have been set.
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
virtual bool transformChanged(QQuickItem *transformedItem)
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setSize(const QSizeF &size)
QQuickItem * viewportItem() const
If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport fla...
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
virtual QRectF boundingRect() const
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const
Maps the given rect in item's coordinate system to the equivalent rectangular area within this item's...
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
QQuickItem * parent
\qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
void setImplicitHeight(qreal)
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
@ ItemClipsChildrenToShape
void setImplicitWidth(qreal)
void polish()
Schedules a polish event for this item.
\qmltype WindowContainer \inqmlmodule QtQuick\inherits Item
QQuickWindowContainer::ContainerMode containerMode
bool transformChanged(QQuickItem *transformedItem) override
void setContainedWindow(QWindow *window)
QWindow * containedWindow() const
QQuickWindowContainer(QQuickItem *parent=nullptr, ContainerMode containerMode=ItemControlsWindow)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) override
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void classBegin() override
\reimp Derived classes should call the base class method before adding their own action to perform at...
Q_SIGNAL void containedWindowChanged(QWindow *window)
QRectF clipRect() const override
void releaseResources() override
This function is called when an item should release graphics resources which are not already managed ...
void updatePolish() override
bool eventFilter(QObject *object, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
static QQuickWindowPrivate * get(QQuickWindow *c)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
\inmodule QtCore\reentrant
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void heightChanged(int arg)
void visibleChanged(bool arg)
void widthChanged(int arg)
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
static QTransform sanitizeTransform(const QTransform &transform)
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)