X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fquick%2Fitems%2Fqquickscreen.cpp;h=32b0d321db92805abcf93c10a63087346e901ae0;hb=feb996e3ab44e68082c97102556ea396f5df3f44;hp=b1b4ff1d8c057c7879ca52c30e55965dd3173144;hpb=8724847a9e26e17852ee08b9b0d70b1d648661a0;p=profile%2Fivi%2Fqtdeclarative.git diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp index b1b4ff1..32b0d32 100644 --- a/src/quick/items/qquickscreen.cpp +++ b/src/quick/items/qquickscreen.cpp @@ -1,10 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -43,7 +43,7 @@ #include "qquickitem.h" #include "qquickitem_p.h" -#include "qquickcanvas.h" +#include "qquickwindow.h" #include @@ -52,38 +52,49 @@ QT_BEGIN_NAMESPACE /*! \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. This can only change if the screen changes. + This contains the primary orientation of the screen. */ /*! - \qmlattachedproperty Qt::ScreenOrientation QtQuickWindow2::Screen::currentOrientation + \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. */ @@ -95,10 +106,10 @@ QQuickScreenAttached::QQuickScreenAttached(QObject* attachee) m_attachee = qobject_cast(attachee); if (m_attachee) { - QQuickItemPrivate::get(m_attachee)->screenAttached = this; + 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()); } } @@ -119,23 +130,25 @@ int QQuickScreenAttached::height() const Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const { if (!m_screen) - return Qt::UnknownOrientation; + return Qt::PrimaryOrientation; return m_screen->primaryOrientation(); } -Qt::ScreenOrientation QQuickScreenAttached::currentOrientation() const +Qt::ScreenOrientation QQuickScreenAttached::orientation() const { if (!m_screen) - return Qt::UnknownOrientation; - return m_screen->currentOrientation(); + return Qt::PrimaryOrientation; + return m_screen->orientation(); } -int QQuickScreenAttached::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) +int QQuickScreenAttached::angleBetween(int a, int b) { - return QScreen::angleBetween(a,b); + if (!m_screen) + return Qt::PrimaryOrientation; + 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) { @@ -147,8 +160,10 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP this, SIGNAL(widthChanged())); disconnect(oldScreen, SIGNAL(sizeChanged(QSize)), this, SIGNAL(heightChanged())); - disconnect(oldScreen, SIGNAL(currentOrientationChanged(Qt::ScreenOrientation)), - this, SIGNAL(currentOrientationChanged())); + disconnect(oldScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), + this, SIGNAL(orientationChanged())); + disconnect(oldScreen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), + this, SIGNAL(primaryOrientationChanged())); } if (!screen) @@ -158,8 +173,9 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP emit widthChanged(); emit heightChanged(); } - if (!oldScreen || screen->currentOrientation() != oldScreen->currentOrientation()) - emit currentOrientationChanged(); + + if (!oldScreen || screen->orientation() != oldScreen->orientation()) + emit orientationChanged(); if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation()) emit primaryOrientationChanged(); @@ -168,8 +184,10 @@ void QQuickScreenAttached::canvasChanged(QQuickCanvas* c)//Called by QQuickItemP this, SIGNAL(widthChanged())); connect(screen, SIGNAL(sizeChanged(QSize)), this, SIGNAL(heightChanged())); - connect(screen, SIGNAL(currentOrientationChanged(Qt::ScreenOrientation)), - this, SIGNAL(currentOrientationChanged())); + connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), + this, SIGNAL(orientationChanged())); + connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), + this, SIGNAL(primaryOrientationChanged())); } }