Skip to content

Commit

Permalink
fix: fallback to parent theme for the windowRadius property
Browse files Browse the repository at this point in the history
支持读取windowRadius属性时fallback到上一级的theme主题

Change-Id: I78a801b6ee216139b9aaf5644731b7ac6390704c
Reviewed-on: http://gerrit.uniontech.com/c/dtkgui/+/8260
Reviewed-by: zhangjide <[email protected]>
Reviewed-by: <[email protected]>
Tested-by: zhangjide <[email protected]>
Tested-by: <[email protected]>
  • Loading branch information
zccrs authored and XMuli committed Oct 21, 2020
1 parent 6ae8f77 commit ea60f6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/dplatformhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion src/dplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ea60f6b

Please sign in to comment.