From 4b4f6220c1c223febb338c68a95e5e5791fecbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 15 Apr 2023 14:33:26 +0800 Subject: Newly instantiated components check root mode The ui.qml would be the root, when any attached property is set. Make sure that UI's mode is set by its implementation. --- Bootstrap.cxx | 12 ++++++++++++ Label.qml | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Bootstrap.cxx b/Bootstrap.cxx index 38bbba5..e6b07ef 100644 --- a/Bootstrap.cxx +++ b/Bootstrap.cxx @@ -115,6 +115,18 @@ Bootstrap::Bootstrap(QObject *parent): OVERRIDE_HX_FONT_SIZE("H6FontSize", h6FontSize); toml_free(toml); + + QObject *ancestor; + QObject *grandAncestor = parent->parent(); + while ((ancestor = grandAncestor)) + if (!(grandAncestor = ancestor->parent())) + for (auto child : ancestor->findChildren()) + if (!strcmp(child->metaObject()->className(), + "Bootstrap")) { + bsMode = qobject_cast + (child)->mode(); + break; + } } Bootstrap *Bootstrap::qmlAttachedProperties(QObject *object) diff --git a/Label.qml b/Label.qml index 5230131..be125ff 100644 --- a/Label.qml +++ b/Label.qml @@ -5,7 +5,6 @@ import Bootstrap 5.3 Label { id: control - Bootstrap.mode: Window.window.Bootstrap.mode font { family: Bootstrap.heading ? Bootstrap.headingFont.family -- cgit v1.2.3