#include "qquickitem.h"
#include "qquickitem_p.h"
-#include "qquickcanvas.h"
+#include "qquickwindow.h"
#include <QScreen>
/*!
\qmlclass Screen QQuickScreenAttached
\inqmlmodule QtQuick.Window 2
+ \ingroup qtquick-visual-utility
\brief The Screen attached object provides information about the Screen an Item is displayed on.
- The Screen attached object is only valid inside Item or Item derived elements. Inside these elements
- it refers to the screen that the element is currently being displayed on.
+ The Screen attached object is only valid inside Item or Item derived types, after component completion.
+ Inside these items it refers to the screen that the item is currently being displayed on.
+
+ To use this type, you will need to import the module with the following line:
+ \code
+ import QtQuick.Window 2.0
+ \endcode
+
+ Note that the Screen type is not valid at Component.onCompleted, because the Item has not been displayed on
+ a screen by this time.
+
+ Restricting this import will allow you to have a QML environment without access to window system features.
*/
/*!
- \qmlattachedproperty int QtQuickWindow2::Screen::width
+ \qmlattachedproperty int QtQuick.Window2::Screen::width
\readonly
This contains the width of the screen in pixels.
*/
/*!
- \qmlattachedproperty int QtQuickWindow2::Screen::height
+ \qmlattachedproperty int QtQuick.Window2::Screen::height
\readonly
This contains the height of the screen in pixels.
*/
/*!
- \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::primaryOrientation
+ \qmlattachedproperty Qt::ScreenOrientation QtQuick.Window2::Screen::primaryOrientation
\readonly
This contains the primary orientation of the screen.
*/
/*!
- \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::orientation
+ \qmlattachedproperty Qt::ScreenOrientation QtQuick.Window2::Screen::orientation
\readonly
This contains the current orientation of the screen.
*/
/*!
- \qmlattachedmethod int QtQuickWindow2::Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
+ \qmlattachedmethod int QtQuick.Window2::Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
Returns the rotation angle, in degrees, between the two specified angles.
*/
if (m_attachee) {
QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this;
- if (m_attachee->canvas()) //It might not be assigned to a canvas yet
- canvasChanged(m_attachee->canvas());
+ if (m_attachee->window()) //It might not be assigned to a window yet
+ windowChanged(m_attachee->window());
}
}
return m_screen->angleBetween((Qt::ScreenOrientation)a,(Qt::ScreenOrientation)b);
}
-void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemPrivate::initCanvas
+void QQuickScreenAttached::windowChanged(QQuickWindow* c)//Called by QQuickItemPrivate::initWindow
{
QScreen* screen = c ? c->screen() : 0;
if (screen != m_screen) {