diff options
-rw-r--r-- | doc/src/declarative/qmlviewer.qdoc | 3 | ||||
-rw-r--r-- | doc/src/snippets/declarative/application.qml | 14 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 60 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeapplication.cpp | 53 |
4 files changed, 69 insertions, 61 deletions
diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc index cfb762c..585b402 100644 --- a/doc/src/declarative/qmlviewer.qdoc +++ b/doc/src/declarative/qmlviewer.qdoc @@ -192,6 +192,9 @@ Rectangle { } \endqml +\note Since Qt Quick 1.1 this information is accessible outside of the QML Viewer, +through the \c active property of the \l {QML:Qt::application}{Qt.application} object. + \row \o \c runtime.orientation diff --git a/doc/src/snippets/declarative/application.qml b/doc/src/snippets/declarative/application.qml index 2820ff2..06f83f2 100644 --- a/doc/src/snippets/declarative/application.qml +++ b/doc/src/snippets/declarative/application.qml @@ -42,12 +42,12 @@ import QtQuick 1.1 Rectangle { - width: 300; height: 55 - color: Qt.application.active ? "white" : "lightgray" - Text { - text: "Application " + (Qt.application.active ? "active" : "inactive") - opacity: Qt.application.active ? 1.0 : 0.5 - anchors.centerIn: parent - } + width: 300; height: 55 + color: Qt.application.active ? "white" : "lightgray" + Text { + text: "Application " + (Qt.application.active ? "active" : "inactive") + opacity: Qt.application.active ? 1.0 : 0.5 + anchors.centerIn: parent + } } //! [document] diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index e3be599..890f500 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -204,8 +204,9 @@ void QDeclarativeEnginePrivate::defineModule() \brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files. -The \c Qt object is not a QML element; it cannot be instantiated. It is a global object -with enums and functions. To use it, call the members of the global \c Qt object directly. +The \c Qt object is a global object with utility functions, properties and enums. + +It is not instantiable; to use it, call the members of the global \c Qt object directly. For example: \qml @@ -220,8 +221,8 @@ Text { \section1 Enums -The Qt object contains enums that declared into Qt's Meta-Object System. For example, you can access -the \c Leftbutton member of the \c Qt::MouseButton enum with \c Qt.LeftButton. +The Qt object contains the enums available in the \l {Qt Namespace}. For example, you can access +the \l Qt::LeftButton and \l Qt::RightButton enum values as \c Qt.LeftButton and \c Qt.RightButton. \section1 Types @@ -263,6 +264,57 @@ of their use. \endlist */ + +/*! + \qmlproperty object QML:Qt::application + \since QtQuick 1.1 + + The \c application object provides access to global application state + properties shared by many QML components. + + Its properties are: + + \table + \row + \o \c application.active + \o + This read-only property indicates whether the application is the top-most and focused + application, and the user is able to interact with the application. The property + is false when the application is in the background, the device keylock or screen + saver is active, the screen backlight is turned off, or the global system dialog + is being displayed on top of the application. It can be used for stopping and + pausing animations, timers and active processing of data in order to save device + battery power and free device memory and processor load when the application is not + active. + + \row + \o \c application.layoutDirection + \o + This read-only property can be used to query the default layout direction of the + application. On system start-up, the default layout direction depends on the + application's language. The property has a value of \c Qt.RightToLeft in locales + where text and graphic elements are read from right to left, and \c Qt.LeftToRight + where the reading direction flows from left to right. You can bind to this + property to customize your application layouts to support both layout directions. + + Possible values are: + + \list + \o Qt.LeftToRight - Text and graphics elements should be positioned + from left to right. + \o Qt.RightToLeft - Text and graphics elements should be positioned + from right to left. + \endlist + \endtable + + The following example uses the \c application object to indicate + whether the application is currently active: + + \snippet doc/src/snippets/declarative/application.qml document + +*/ + + /*! \qmlmethod object Qt::include(string url, jsobject callback) diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp index 7ecce1e..e0f6df2 100644 --- a/src/declarative/util/qdeclarativeapplication.cpp +++ b/src/declarative/util/qdeclarativeapplication.cpp @@ -55,22 +55,9 @@ public: Qt::LayoutDirection layoutDirection; }; -/*! - \qmlclass Application QDeclarativeApplication - \since QtQuick 1.1 - \ingroup qml-utility-elements - \brief The Application element provides access to global application - state properties shared by many QML components. - - These properties include application activity property \c active, - and default layout direction property \c layoutDirection. - - \section1 Example Usage - - The following example shows the simplest usage of the Application element. - - \snippet doc/src/snippets/declarative/application.qml document - +/* + This object and its properties are documented as part of the Qt object, + in qdeclarativengine.cpp */ QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent) @@ -83,46 +70,12 @@ QDeclarativeApplication::~QDeclarativeApplication() { } -/*! - \qmlproperty bool Application::active - - This property indicates whether the application is the top-most and focused - application, and user is able to interact with the application. The property - is false when the application is on the background, device keylock or screen - saver is active, the screen backlight is turned off, or global system dialog - is being displayed on top of the application. It can be used for stopping and - pausing animations, timers, active processing of data to save device battery - and free device memory and processor load when the application is not active. - This property is readonly. - -*/ bool QDeclarativeApplication::active() const { Q_D(const QDeclarativeApplication); return d->active; } -/*! - \qmlproperty enumeration Application::layoutDirection - - This property can be used to query the default layout direction of the - application. On system start-up, the default layout direction depends on the - application's language. The property has a value Qt.RightToLeft in locales - where text and graphic elements are read from right to left, and Qt.LeftToRight - where the reading direction flows from left to right. You can bind to the - property to customize your application layouts to support both layout - directions. This property is readonly. - - Possible values are: - - \list - \o Qt.LeftToRight - Text and graphics elements should be positioned - from left to right. - \o Qt.RightToLeft - Text and graphics elements should be positioned - from right to left. - \endlist - -*/ Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const { Q_D(const QDeclarativeApplication); |