From ea60f6b0bb40cad111548a8374060f06473f66b1 Mon Sep 17 00:00:00 2001 From: zccrs Date: Wed, 21 Oct 2020 17:14:45 +0800 Subject: [PATCH] fix: fallback to parent theme for the windowRadius property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持读取windowRadius属性时fallback到上一级的theme主题 Change-Id: I78a801b6ee216139b9aaf5644731b7ac6390704c Reviewed-on: http://gerrit.uniontech.com/c/dtkgui/+/8260 Reviewed-by: zhangjide Reviewed-by: Tested-by: zhangjide Tested-by: --- src/dplatformhandle.cpp | 5 +---- src/dplatformtheme.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dplatformhandle.cpp b/src/dplatformhandle.cpp index a582a48e..83eec326 100644 --- a/src/dplatformhandle.cpp +++ b/src/dplatformhandle.cpp @@ -549,10 +549,7 @@ static void initWindowRadius(QWindow *window) return; auto theme = DGuiApplicationHelper::instance()->windowTheme(window); - int radius = theme->windowRadius(); - - if (radius == -1) - radius =theme->windowRadius(18); //###(zccrs): 暂时在此处给窗口默认设置为18px的圆角 + int radius = theme->windowRadius(18); //###(zccrs): 暂时在此处给窗口默认设置为18px的圆角 setWindowProperty(window, _windowRadius, radius); window->connect(theme, &DPlatformTheme::windowRadiusChanged, window, [=] (int radius) { diff --git a/src/dplatformtheme.cpp b/src/dplatformtheme.cpp index e2da4773..870949f4 100644 --- a/src/dplatformtheme.cpp +++ b/src/dplatformtheme.cpp @@ -391,8 +391,15 @@ int DPlatformTheme::windowRadius() const int DPlatformTheme::windowRadius(int defaultValue) const { + Q_D(const DPlatformTheme); + + QVariant value = d->theme->getSetting(QByteArrayLiteral("DTK/WindowRadius")); bool ok = false; - int radius = this->property("windowRadius").toInt(&ok); + + if (d->fallbackProperty && !value.isValid() && d->parent) + return d->parent->windowRadius(defaultValue); + + int radius = value.toInt(&ok); return ok ? radius : defaultValue; }