diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-02 15:41:02 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-17 20:40:17 +0100 |
commit | 99b19fab5a106cbc34f2733da6689eb0afbc36e5 (patch) | |
tree | 00672b0126900b501e461faa907c745dba5df43e /src/qml | |
parent | 8d2227165723c76dbebb348f569a477f8e699870 (diff) |
Expose QStyleHints as Qt.styleHints
Change-Id: I0fc94e680b011963e645bdbf51110820751e53aa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 28 | ||||
-rw-r--r-- | src/qml/qml/qqmlglobal.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlglobal_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 7 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 1 |
5 files changed, 45 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index aececf915f..762e9880d2 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -523,6 +523,34 @@ The following functions are also on the Qt object. further details. */ +/*! + \qmlproperty object Qt::styleHints + \since 5.5 + + The \c styleHints object provides platform-specific style hints and settings. + See the QStyleHints documentation for further details. + + \note The \c styleHints object is only available when using the Qt Quick module. + + The following example uses the \c styleHints object to determine whether an + item should gain focus on mouse press or touch release: + \code + import QtQuick 2.4 + + MouseArea { + id: button + + onPressed: { + if (!Qt.styleHints.setFocusOnTouchRelease) + button.forceActiveFocus() + } + onReleased: { + if (Qt.styleHints.setFocusOnTouchRelease) + button.forceActiveFocus() + } + } + \endcode +*/ /*! \qmlmethod object Qt::include(string url, jsobject callback) diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index e100b53386..6f7582346f 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -364,6 +364,14 @@ QObject *QQmlGuiProvider::inputMethod() } #endif +QObject *QQmlGuiProvider::styleHints() +{ + QObject *o = new QObject(); + o->setObjectName(QString::fromLatin1("No styleHints available")); + QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership); + return o; +} + static QQmlGuiProvider *guiProvider = 0; Q_QML_PRIVATE_EXPORT QQmlGuiProvider *QQml_setGuiProvider(QQmlGuiProvider *newProvider) diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index da09956530..28cea20adb 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -296,6 +296,7 @@ public: #ifndef QT_NO_IM virtual QObject *inputMethod(); #endif + virtual QObject *styleHints(); virtual QStringList fontFamilies(); virtual bool openUrlExternally(QUrl &); }; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 19cb1edb60..6eaa020218 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -142,6 +142,7 @@ Heap::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) #ifndef QT_NO_IM o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0); #endif + o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, 0); } @@ -1272,6 +1273,12 @@ ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx) } #endif +ReturnedValue QtObject::method_get_styleHints(CallContext *ctx) +{ + QObject *o = QQml_guiProvider()->styleHints(); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, o); +} + QV4::Heap::ConsoleObject::ConsoleObject(ExecutionEngine *v4) : Heap::Object(v4) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index a6d1821cda..ca10a86ffc 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -116,6 +116,7 @@ struct QtObject : Object #ifndef QT_NO_IM static ReturnedValue method_get_inputMethod(CallContext *ctx); #endif + static ReturnedValue method_get_styleHints(CallContext *ctx); }; struct ConsoleObject : Object |