diff options
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index d99bec4c52..f60f148495 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -450,6 +450,12 @@ The following functions are also on the Qt object. \li \c "windows" - Windows \li \c "winrt" - WinRT / UWP \endlist + + \row + \li \c platform.pluginName + \li This is the name of the platform set on the QGuiApplication instance + as returned by \l QGuiApplication::platformName() + \endtable */ @@ -767,7 +773,7 @@ class QQmlThreadNotifierProxyObject : public QObject public: QPointer<QObject> target; - virtual int qt_metacall(QMetaObject::Call, int methodIndex, void **a) { + int qt_metacall(QMetaObject::Call, int methodIndex, void **a) override { if (!target) return -1; @@ -1332,6 +1338,30 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled) } /*! + Refreshes all binding expressions that use strings marked for translation. + + Call this function after you have installed a new translator with + QCoreApplication::installTranslator, to ensure that your user-interface + shows up-to-date translations. + + \note Due to a limitation in the implementation, this function + refreshes all the engine's bindings, not only those that use strings + marked for translation. + This may be optimized in a future release. + + \since 5.10 +*/ +void QQmlEngine::retranslate() +{ + Q_D(QQmlEngine); + QQmlContextData *context = QQmlContextData::get(d->rootContext)->childContexts; + while (context) { + context->refreshExpressions(); + context = context->nextChild; + } +} + +/*! Returns the QQmlContext for the \a object, or 0 if no context has been set. @@ -1451,6 +1481,9 @@ bool QQmlEngine::event(QEvent *e) Q_D(QQmlEngine); if (e->type() == QEvent::User) d->doDeleteInEngineThread(); + else if (e->type() == QEvent::LanguageChange) { + retranslate(); + } return QJSEngine::event(e); } @@ -1500,9 +1533,9 @@ QQmlEngine *qmlEngine(const QObject *obj) QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create) { - QQmlData *data = QQmlData::get(object); + QQmlData *data = QQmlData::get(object, create); if (!data) - return 0; // Attached properties are only on objects created by QML + return 0; // Attached properties are only on objects created by QML, unless explicitly requested (create==true) QObject *rv = data->hasExtendedData()?data->attachedProperties()->value(id):0; if (rv || !create) |