diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-21 01:22:04 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-21 09:32:40 +0100 |
commit | 71d90c236d57580e3e81adcd09ea5abe5be8a8d2 (patch) | |
tree | 6cc028862e892f7bc834f2cacf50dfe6d11c0eb0 | |
parent | d4317567357228f75eb10f22decc55ac2be26dd2 (diff) |
tdf#130857 qt weld: Implement scroll bar policy {g,s}etters
Change-Id: I0ee4cececc40f21a6ef4eeb034c44727578d309c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178976
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | vcl/inc/qt5/QtInstanceScrolledWindow.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceScrolledWindow.cxx | 64 |
2 files changed, 60 insertions, 8 deletions
diff --git a/vcl/inc/qt5/QtInstanceScrolledWindow.hxx b/vcl/inc/qt5/QtInstanceScrolledWindow.hxx index 548e7fbf4033..7a612372ae08 100644 --- a/vcl/inc/qt5/QtInstanceScrolledWindow.hxx +++ b/vcl/inc/qt5/QtInstanceScrolledWindow.hxx @@ -59,6 +59,10 @@ public: virtual void customize_scrollbars(const Color& rBackgroundColor, const Color& rShadowColor, const Color& rFaceColor) override; + +private: + static Qt::ScrollBarPolicy toQtPolicy(VclPolicyType eVclPolicy); + static VclPolicyType toVclPolicy(Qt::ScrollBarPolicy eQtPolicy); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtInstanceScrolledWindow.cxx b/vcl/qt5/QtInstanceScrolledWindow.cxx index da71b13fa73b..fd4f6f0a65ee 100644 --- a/vcl/qt5/QtInstanceScrolledWindow.cxx +++ b/vcl/qt5/QtInstanceScrolledWindow.cxx @@ -80,15 +80,23 @@ void QtInstanceScrolledWindow::hadjustment_set_step_increment(int) assert(false && "Not implemented yet"); } -void QtInstanceScrolledWindow::set_hpolicy(VclPolicyType) +void QtInstanceScrolledWindow::set_hpolicy(VclPolicyType eHPolicy) { - assert(false && "Not implemented yet"); + SolarMutexGuard g; + + GetQtInstance().RunInMainThread( + [&] { m_pScrollArea->setHorizontalScrollBarPolicy(toQtPolicy(eHPolicy)); }); } VclPolicyType QtInstanceScrolledWindow::get_hpolicy() const { - assert(false && "Not implemented yet"); - return VclPolicyType::ALWAYS; + SolarMutexGuard g; + + VclPolicyType ePolicy = VclPolicyType::AUTOMATIC; + GetQtInstance().RunInMainThread( + [&] { ePolicy = toVclPolicy(m_pScrollArea->horizontalScrollBarPolicy()); }); + + return ePolicy; } void QtInstanceScrolledWindow::vadjustment_configure(int, int, int, int, int, int) @@ -155,15 +163,23 @@ void QtInstanceScrolledWindow::vadjustment_set_lower(int) assert(false && "Not implemented yet"); } -void QtInstanceScrolledWindow::set_vpolicy(VclPolicyType) +void QtInstanceScrolledWindow::set_vpolicy(VclPolicyType eVPolicy) { - assert(false && "Not implemented yet"); + SolarMutexGuard g; + + GetQtInstance().RunInMainThread( + [&] { m_pScrollArea->setVerticalScrollBarPolicy(toQtPolicy(eVPolicy)); }); } VclPolicyType QtInstanceScrolledWindow::get_vpolicy() const { - assert(false && "Not implemented yet"); - return VclPolicyType::ALWAYS; + SolarMutexGuard g; + + VclPolicyType ePolicy = VclPolicyType::AUTOMATIC; + GetQtInstance().RunInMainThread( + [&] { ePolicy = toVclPolicy(m_pScrollArea->verticalScrollBarPolicy()); }); + + return ePolicy; } int QtInstanceScrolledWindow::get_scroll_thickness() const @@ -179,4 +195,36 @@ void QtInstanceScrolledWindow::customize_scrollbars(const Color&, const Color&, assert(false && "Not implemented yet"); } +Qt::ScrollBarPolicy QtInstanceScrolledWindow::toQtPolicy(VclPolicyType eVclPolicy) +{ + switch (eVclPolicy) + { + case VclPolicyType::ALWAYS: + return Qt::ScrollBarAlwaysOn; + case VclPolicyType::AUTOMATIC: + return Qt::ScrollBarAsNeeded; + case VclPolicyType::NEVER: + return Qt::ScrollBarAlwaysOff; + default: + assert(false && "Unhandled scroll bar policy"); + return Qt::ScrollBarAsNeeded; + } +} + +VclPolicyType QtInstanceScrolledWindow::toVclPolicy(Qt::ScrollBarPolicy eQtPolicy) +{ + switch (eQtPolicy) + { + case Qt::ScrollBarAlwaysOn: + return VclPolicyType::ALWAYS; + case Qt::ScrollBarAsNeeded: + return VclPolicyType::AUTOMATIC; + case Qt::ScrollBarAlwaysOff: + return VclPolicyType::NEVER; + default: + assert(false && "Unhandled scroll bar policy"); + return VclPolicyType::AUTOMATIC; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |