Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion reader/browser/SheetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(pa
QPalette pal = viewport()->palette();
pal.setColor(viewport()->backgroundRole(), EyeProtectionManager::instance()->viewportBackgroundColor());
viewport()->setPalette(pal);


// 主题切换时同步滚动条调色板,保证深色模式下滑块可见
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SheetBrowser::onUpdateTheme);
onUpdateTheme();

qCDebug(appLog) << "SheetBrowser constructor completed";
}

Expand Down Expand Up @@ -2474,3 +2478,18 @@ void SheetBrowser::restoreScrollPosition(float position)
vBar->setValue(value);
qCDebug(appLog) << "restoreScrollPosition set value=" << value << "-> after val=" << vBar->value();
}

void SheetBrowser::onUpdateTheme()
{
// 文档页面与视口背景恒为浅色,而 DTK ChameleonStyle 依据滚动条 palette(Base)
// 的明暗决定滑块颜色:深色模式下 Base 为深色会绘制白色半透明滑块,在浅色
// 背景上不可见。此处强制 Base 为浅色,使滑块始终为深色,保证滚动条清晰可见。
const QPalette appPalette = DGuiApplicationHelper::instance()->applicationPalette();
auto syncScrollBarPalette = [&appPalette](QScrollBar *bar) {
QPalette barPalette = appPalette;
barPalette.setColor(QPalette::Base, Qt::white);
bar->setPalette(barPalette);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): barPalette.setColor(QPalette::Base, Qt::white) forces ChameleonStyle to draw a dark scrollbar handle even when EyeProtectionManager is in Night mode, where the document page and viewport are dark (#1E1E1E/#252525); the handle therefore loses contrast and becomes difficult to see in the mode this fix is intended to cover.

Triggers: When EyeProtectionManager is in Night mode and a scrollbar is visible.

Suggested fix: Choose the scrollbar Base color based on the effective document/viewport background, or reapply a light Base only when the page background is light.

};
syncScrollBarPalette(verticalScrollBar());
syncScrollBarPalette(horizontalScrollBar());
}
6 changes: 6 additions & 0 deletions reader/browser/SheetBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ private slots:
*/
void onRemoveIconAnnotSelect();

/**
* @brief onUpdateTheme
* 主题变化时更新滚动条调色板,确保深色模式下滚动条颜色正确
*/
void onUpdateTheme();

private:
/**
* @brief calcIconAnnotRect
Expand Down
Loading