vcl/qt5/QtInstanceScrolledWindow.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
New commits: commit e1f2a3e14424ece4f8b365d315079436f92749b8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 12 23:03:03 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 13 00:31:09 2025 +0200 tdf#130857 tdf#160838 qt weld: Support custom scroll bar colors Add an initial implementation for QtInstanceScrolledWindow::customize_scrollbars. This will e.g. be used by the comment popup in Impress. To trigger the comment popup and scroll bar: * start Impress * "Insert Comment" * type multiple lines of text in the comment until it cannot all be shown at once anymore and a scroll bar appears This doesn't actually use native Qt widgets yet, but this commit is one step towards declaring support for using native widgets there. More work is still needed before that can be done. In a WIP branch experimenting with using native widgets for that popup with SAL_VCL_QT_USE_WELDED_WIDGETS=1, the colors for the scrollbar look somewhat sane for the Fusion style (provided by qtbase), but not as great for the KDE Breeze style (default in KDE Plasma), where the background color of the scrollbar is still white. Further tweaking of how colors are set might make sense later, but don't block any other work by this for now. Change-Id: I58dd0a434e032d48c489333304328b451b7c86c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190905 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtInstanceScrolledWindow.cxx b/vcl/qt5/QtInstanceScrolledWindow.cxx index a9f848cdc49b..fccec354b259 100644 --- a/vcl/qt5/QtInstanceScrolledWindow.cxx +++ b/vcl/qt5/QtInstanceScrolledWindow.cxx @@ -308,9 +308,26 @@ void QtInstanceScrolledWindow::set_scroll_thickness(int nThickness) }); } -void QtInstanceScrolledWindow::customize_scrollbars(const Color&, const Color&, const Color&) +void QtInstanceScrolledWindow::customize_scrollbars(const Color& rBackgroundColor, + const Color& rShadowColor, + const Color& rFaceColor) { - assert(false && "Not implemented yet"); + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + for (QScrollBar* pScrollBar : + { m_pScrollArea->horizontalScrollBar(), m_pScrollArea->verticalScrollBar() }) + { + if (pScrollBar) + { + QPalette aPalette = pScrollBar->palette(); + aPalette.setColor(QPalette::ColorRole::Base, toQColor(rBackgroundColor)); + aPalette.setColor(QPalette::ColorRole::Shadow, toQColor(rShadowColor)); + aPalette.setColor(QPalette::ColorRole::Button, toQColor(rFaceColor)); + pScrollBar->setPalette(aPalette); + } + } + }); } Qt::ScrollBarPolicy QtInstanceScrolledWindow::toQtPolicy(VclPolicyType eVclPolicy)