aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-10-07 14:25:50 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-10-11 09:39:28 +0200
commitf51231164e7074bfcd4deea31e82428b31483e53 (patch)
tree405c02b2f98b46b2a701e2839bc2f536a881b57a /src/qml/qml/qqmlengine_p.h
parentd8fcc1b8f4c20536cad4f806c4c42d3b8086115f (diff)
QQmlEngine: Fine grained translation binding tracking
This commit changes translation bindings in such a way that they always depend on the a newly introduced translationLanguage property of the QML engine. Moreover, captureTranslationBinding is changed in the same way, hence any binding containing a call to a translation function like qsTr will also be refreshed. After those changes, QQmlEngine::retranslate can be implemented as a notify on translationLanguage. Finally, QQmlTranslationPropertyBinding is also changed to depend on translationLanguage instead of uiLanguage to ensure consistency between the various binding types. Note that we do not use the existing uiLanguage property of QJSEngine. If we were to do this, changing uiLanguage would already trigger the binding reevaluation, which is a behavior change. In case someone is manually connecting uiLanguageChanged to QQmlEngine::retranslate, this would cause a double evaluation of translation bindings. In a future change, we can however introduce a new enableAutoTranslationUpdate method, which would cause binding evaluation as soon as uiLanguage is changed. Special care is taken for ListModel/ListElement, which does not store a proper translation binding, but instead operates on QV4::CompiledData::Binding. For now, we simply refresh the complete ListModel in case it contains a translation binding. It should be possible to optimize this further in a future change. Note that only "static" ListElement properties can contain translations: The dynamic insertion API makes it impossible to insert a translation, as it would already be resolved to a string when insert is called. [ChangeLog][QQmlEngine] QQmlEngine::retranslate no longer refreshes all bindings, but only translation bindings. Fixes: QTBUG-96192 Change-Id: I54d213fd46b6914e8f686843b49e155909117218 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit d4039298e710b6b79c018589bcc2145e22e1d5aa)
Diffstat (limited to 'src/qml/qml/qqmlengine_p.h')
-rw-r--r--src/qml/qml/qqmlengine_p.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 18a0164028..9e83aa9470 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -162,6 +162,7 @@ public:
QRecyclePool<TriggerList> qPropertyTriggerPool;
QQmlContext *rootContext;
+ Q_OBJECT_BINDABLE_PROPERTY(QQmlEnginePrivate, QString, translationLanguage);
#if !QT_CONFIG(qml_debug)
static const quintptr profiler = 0;