diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-01-31 09:39:34 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-12 15:33:53 +0000 |
commit | 04d4dca69d526611b60ec32e873d5de51d10be4d (patch) | |
tree | 936ec7b3d0ded1b73e538d75de79edc0fe902a00 /src/quick/items/qquickwindowattached.cpp | |
parent | 20a51e87fd15b8a6c1503b905399f7befe31114b (diff) |
Add Window.window attached property
The Window attached property exposes all kinds of window attributes,
but not the window itself. Being able to access the window is often
useful for various purposes. For example, in QML TestCase, to be able
to access the window of the TestCase so that one can call various
slots such as requestActivate().
Change-Id: Id03c9f277bb17810b41a60957011ccf07399e149
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickwindowattached.cpp')
-rw-r--r-- | src/quick/items/qquickwindowattached.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/quick/items/qquickwindowattached.cpp b/src/quick/items/qquickwindowattached.cpp index 992bbae382..c6380e2b9a 100644 --- a/src/quick/items/qquickwindowattached.cpp +++ b/src/quick/items/qquickwindowattached.cpp @@ -51,9 +51,9 @@ QQuickWindowAttached::QQuickWindowAttached(QObject* attachee) { m_attachee = qobject_cast<QQuickItem*>(attachee); if (m_attachee && m_attachee->window()) // It might not be in a window yet - windowChanged(m_attachee->window()); + windowChange(m_attachee->window()); if (m_attachee) - connect(m_attachee, &QQuickItem::windowChanged, this, &QQuickWindowAttached::windowChanged); + connect(m_attachee, &QQuickItem::windowChanged, this, &QQuickWindowAttached::windowChange); } QWindow::Visibility QQuickWindowAttached::visibility() const @@ -86,7 +86,12 @@ int QQuickWindowAttached::height() const return (m_window ? m_window->height() : 0); } -void QQuickWindowAttached::windowChanged(QQuickWindow *window) +QQuickWindow *QQuickWindowAttached::window() const +{ + return m_window; +} + +void QQuickWindowAttached::windowChange(QQuickWindow *window) { if (window != m_window) { QQuickWindow* oldWindow = m_window; @@ -95,6 +100,8 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window) if (oldWindow) oldWindow->disconnect(this); + emit windowChanged(); + if (!oldWindow || !window || window->visibility() != oldWindow->visibility()) emit visibilityChanged(); if (!oldWindow || !window || window->isActive() != oldWindow->isActive()) |