From 9760ed0fca36990ea69e68e6057266e27cba62a9 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: Thu, 13 Apr 2023 10:49:18 +0800 Subject: Children inherit mode --- Bootstrap.cxx | 7 +++++++ Label.qml | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Bootstrap.cxx b/Bootstrap.cxx index d123dca..38bbba5 100644 --- a/Bootstrap.cxx +++ b/Bootstrap.cxx @@ -136,6 +136,13 @@ void Bootstrap::setMode(Mode mode) emit bodyBgChanged(); emit borderColorChanged(); emit headingColorChanged(); + for (auto sibling : parent()->findChildren()) + if (strstr(sibling->metaObject()->className(), "_QMLTYPE_")) + for (auto child : sibling->children()) + if (!strcmp(child->metaObject()->className(), + "Bootstrap")) + qobject_cast(child) + ->setMode(mode); } Bootstrap::Theme Bootstrap::theme() const diff --git a/Label.qml b/Label.qml index 3b12c5d..5230131 100644 --- a/Label.qml +++ b/Label.qml @@ -1,9 +1,11 @@ import QtQuick 2.15 +import QtQuick.Window 2.15 import QtQuick.Templates 2.15 import Bootstrap 5.3 Label { id: control + Bootstrap.mode: Window.window.Bootstrap.mode font { family: Bootstrap.heading ? Bootstrap.headingFont.family -- cgit v1.2.3