Skip to content

Commit ad0ed8c

Browse files
committed
fix: adjust scrollbar visibility based on system theme policy
Changed the scrollbar visibility initialization logic in ChameleonStyle to respect system theme's scrollbar policy. Previously, scrollbars were always set to visible by default, then hidden via animation. Now, when the system theme specifies Qt::ScrollBarAsNeeded policy, scrollbars start as invisible; otherwise, they remain visible by default. This ensures proper scrollbar behavior alignment with user's system preferences. fix: 根据系统主题策略调整滚动条可见性 修改了ChameleonStyle中滚动条可见性的初始化逻辑,以遵循系统主题的滚动条 策略。之前滚动条始终默认设置为可见,然后通过动画隐藏。现在,当系统主题指 定Qt::ScrollBarAsNeeded策略时,滚动条初始为不可见;其他情况下保持默认可 见。这确保了滚动条行为与用户系统偏好设置的一致性。 PMS: BUG-339051
1 parent 6094967 commit ad0ed8c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

styleplugins/chameleon/chameleonstyle.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4623,8 +4623,16 @@ void ChameleonStyle::resetAttribute(QWidget *w, bool polish)
46234623
w->setAttribute(Qt::WA_Hover, enableHover);
46244624

46254625
if (auto scrollbar = qobject_cast<QScrollBar *>(w)) {
4626-
// 默认初始显示滚动条,然后启动隐藏动画
4627-
scrollbar->setProperty("_d_dtk_scrollbar_visible", true);
4626+
// 默认按需显示时不显示滚动条,其余情况默认显示,然后启动隐藏动画
4627+
DPlatformTheme *theme = DGuiApplicationHelper::instance()->systemTheme();
4628+
if (theme && theme->isValid()) {
4629+
int sb = theme->scrollBarPolicy();
4630+
if (sb == Qt::ScrollBarAsNeeded) {
4631+
scrollbar->setProperty("_d_dtk_scrollbar_visible", false);
4632+
} else {
4633+
scrollbar->setProperty("_d_dtk_scrollbar_visible", true);
4634+
}
4635+
}
46284636
scrollbar->setAttribute(Qt::WA_OpaquePaintEvent, !polish);
46294637
}
46304638
}

0 commit comments

Comments
 (0)