diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-05 21:00:40 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-09 21:40:52 +0100 |
commit | 40f394ef2e06a6466445e4df54735250939084f0 (patch) | |
tree | 815635f1adf7b2dee2ee271e9092f96695c41936 /src | |
parent | b40a2a881291b3eaea4b4834a162091537e6a34e (diff) |
Add Window.width and Window.height attached properties
[ChangeLog][QtQuick] Added Window.width and Window.height attached
properties
Change-Id: I3ef590a0d3e6fa660ed88992d5ae843deb09c7bc
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 9 | ||||
-rw-r--r-- | src/quick/items/qquickwindowattached.cpp | 18 | ||||
-rw-r--r-- | src/quick/items/qquickwindowattached_p.h | 6 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index aba36ce118..2c8b24baf6 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -3767,6 +3767,15 @@ void QQuickWindow::resetOpenGLState() */ /*! + \qmlattachedproperty int Window::width + \qmlattachedproperty int Window::height + \since 5.5 + + These attached properties hold the size of the item's window. + The Window attached property can be attached to any Item. +*/ + +/*! \qmlproperty int Window::x \qmlproperty int Window::y \qmlproperty int Window::width diff --git a/src/quick/items/qquickwindowattached.cpp b/src/quick/items/qquickwindowattached.cpp index f74e903be3..70985bdd45 100644 --- a/src/quick/items/qquickwindowattached.cpp +++ b/src/quick/items/qquickwindowattached.cpp @@ -70,6 +70,16 @@ QQuickItem *QQuickWindowAttached::contentItem() const return (m_window ? m_window->contentItem() : Q_NULLPTR); } +int QQuickWindowAttached::width() const +{ + return (m_window ? m_window->width() : 0); +} + +int QQuickWindowAttached::height() const +{ + return (m_window ? m_window->height() : 0); +} + void QQuickWindowAttached::windowChanged(QQuickWindow *window) { if (window != m_window) { @@ -89,6 +99,10 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window) if (!oldWindow || window->activeFocusItem() != oldWindow->activeFocusItem()) emit activeFocusItemChanged(); emit contentItemChanged(); + if (!oldWindow || window->width() != oldWindow->width()) + emit widthChanged(); + if (!oldWindow || window->height() != oldWindow->height()) + emit heightChanged(); // QQuickWindowQmlImpl::visibilityChanged also exists, and window might even // be QQuickWindowQmlImpl, but that's not what we are connecting to. @@ -102,6 +116,10 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window) this, &QQuickWindowAttached::activeChanged); connect(window, &QQuickWindow::activeFocusItemChanged, this, &QQuickWindowAttached::activeFocusItemChanged); + connect(window, &QQuickWindow::widthChanged, + this, &QQuickWindowAttached::widthChanged); + connect(window, &QQuickWindow::heightChanged, + this, &QQuickWindowAttached::heightChanged); } } diff --git a/src/quick/items/qquickwindowattached_p.h b/src/quick/items/qquickwindowattached_p.h index 7c2b0bc873..df1499c692 100644 --- a/src/quick/items/qquickwindowattached_p.h +++ b/src/quick/items/qquickwindowattached_p.h @@ -50,6 +50,8 @@ class Q_AUTOTEST_EXPORT QQuickWindowAttached : public QObject Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged) Q_PROPERTY(QQuickItem* contentItem READ contentItem NOTIFY contentItemChanged) + Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(int height READ height NOTIFY heightChanged) public: QQuickWindowAttached(QObject* attachee); @@ -58,6 +60,8 @@ public: bool isActive() const; QQuickItem* activeFocusItem() const; QQuickItem* contentItem() const; + int width() const; + int height() const; Q_SIGNALS: @@ -65,6 +69,8 @@ Q_SIGNALS: void activeChanged(); void activeFocusItemChanged(); void contentItemChanged(); + void widthChanged(); + void heightChanged(); protected Q_SLOTS: void windowChanged(QQuickWindow*); |