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
23 changes: 23 additions & 0 deletions reader/browser/SheetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DWIDGET_USE_NAMESPACE

#define REPEAT_MOVE_DELAY 500
const qreal deltaManhattanLength = 12.0;

SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(parent)
{
setMouseTracking(true);
Expand Down Expand Up @@ -93,6 +94,9 @@ SheetBrowser::SheetBrowser(DocSheet *parent) : DGraphicsView(parent), m_sheet(pa
this->horizontalScrollBar()->setProperty("_d_slider_spaceLeft", 8);
this->horizontalScrollBar()->setProperty("_d_slider_spaceRight", 8);
this->horizontalScrollBar()->setAccessibleName("horizontalScrollBar");

connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SheetBrowser::onUpdateTheme);
onUpdateTheme();
}

SheetBrowser::~SheetBrowser()
Expand Down Expand Up @@ -2060,3 +2064,22 @@ TextEditShadowWidget *SheetBrowser::getNoteEditWidget() const
{
return m_noteEditWidget;
}

void SheetBrowser::onUpdateTheme()
{
DPalette plt = DGuiApplicationHelper::instance()->applicationPalette();

setPalette(plt);
setBackgroundBrush(QBrush(plt.itemBackground().color()));

// 文档页面恒为浅色,而 DTK ChameleonStyle 依据滚动条 palette(Base) 的明暗
// 决定滑块颜色:深色模式下 Base 为深色会绘制白色半透明滑块,在白色页面上
// 不可见。此处强制 Base 为浅色,使滑块始终为深色,保证滚动条清晰可见。
auto syncScrollBarPalette = [&plt](QScrollBar *bar) {
DPalette barPalette = plt;
barPalette.setColor(QPalette::Base, Qt::white);
bar->setPalette(barPalette);
};
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 @@ -550,6 +550,12 @@ private slots:
*/
void onRemoveIconAnnotSelect();

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

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