diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2011-01-04 07:25:48 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2011-01-07 05:06:47 (GMT) |
commit | 0371e80ba76b7dcaf1809ba9345fd96610390222 (patch) | |
tree | 2d8d7c3132ee49d4eb4dd13585085681d48d36ce /src/declarative/util/qdeclarativeapplication.cpp | |
parent | d3a6fcd9174b893aaac9db7d5e541ceb54b12402 (diff) | |
download | Qt-0371e80ba76b7dcaf1809ba9345fd96610390222.zip Qt-0371e80ba76b7dcaf1809ba9345fd96610390222.tar.gz Qt-0371e80ba76b7dcaf1809ba9345fd96610390222.tar.bz2 |
Add layoutDirection property to Qt.application element
Task-number: QTBUG-16424
Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/util/qdeclarativeapplication.cpp')
-rw-r--r-- | src/declarative/util/qdeclarativeapplication.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp index 53d196f..f724c16 100644 --- a/src/declarative/util/qdeclarativeapplication.cpp +++ b/src/declarative/util/qdeclarativeapplication.cpp @@ -47,8 +47,10 @@ class QDeclarativeApplicationPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QDeclarativeApplication) public: - QDeclarativeApplicationPrivate() : active(QApplication::activeWindow() != 0) {} + QDeclarativeApplicationPrivate() : active(QApplication::activeWindow() != 0), + layoutDirection(QApplication::layoutDirection()) {} bool active; + Qt::LayoutDirection layoutDirection; }; /*! @@ -58,7 +60,8 @@ public: \brief The Application element provides access to global application state properties shared by many QML components. - These properties include application activity property \c active. + These properties include application activity property \c active, + and default layout direction property \c layoutDirection. \section1 Example Usage @@ -97,6 +100,24 @@ bool QDeclarativeApplication::active() const return d->active; } +/*! + \qmlproperty bool 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. + +*/ +bool QDeclarativeApplication::layoutDirection() const +{ + Q_D(const QDeclarativeApplication); + return d->layoutDirection; +} + bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) { Q_UNUSED(obj) @@ -114,5 +135,12 @@ bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) emit activeChanged(); } } + if (event->type() == QEvent::LayoutDirectionChange) { + Qt::LayoutDirection direction = QApplication::layoutDirection(); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + } + } return false; } |