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.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn
2025-09-13 00:31:09 +02:00
parent 2c0c0ff155
commit e1f2a3e144
+19 -2
View File
@@ -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)