From 44b2a3d53646bd3c55993af29121d007fb177c55 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 4 Dec 2024 23:15:41 +0100 Subject: [PATCH] tdf#130857 qt weld: Implement QtInstanceWidget::get_extents_relative_to This e.g. gets called when pressing the "Find Next" button in the "Find and Replace" dialog. Change-Id: I30e33d52d19b0afe44564486bfa79e3b500ae856 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177832 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/inc/qt5/QtInstanceWidget.hxx | 3 ++- vcl/qt5/QtInstanceWidget.cxx | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx index a98288908084..f50f4de1e84a 100644 --- a/vcl/inc/qt5/QtInstanceWidget.hxx +++ b/vcl/inc/qt5/QtInstanceWidget.hxx @@ -130,7 +130,8 @@ public: virtual void grab_remove() override; - virtual bool get_extents_relative_to(const Widget&, int&, int&, int&, int&) const override; + virtual bool get_extents_relative_to(const Widget& rRelative, int& rX, int& rY, int& rWidth, + int& rHeight) const override; virtual bool get_direction() const override; diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx index da0c0112dab0..5a770e4a479d 100644 --- a/vcl/qt5/QtInstanceWidget.cxx +++ b/vcl/qt5/QtInstanceWidget.cxx @@ -459,10 +459,27 @@ bool QtInstanceWidget::has_grab() const void QtInstanceWidget::grab_remove() { assert(false && "Not implemented yet"); } -bool QtInstanceWidget::get_extents_relative_to(const Widget&, int&, int&, int&, int&) const +bool QtInstanceWidget::get_extents_relative_to(const Widget& rRelative, int& rX, int& rY, + int& rWidth, int& rHeight) const { - assert(false && "Not implemented yet"); - return false; + SolarMutexGuard g; + + bool bRet = false; + GetQtInstance().RunInMainThread([&] { + QRect aGeometry = m_pWidget->geometry(); + rWidth = aGeometry.width(); + rHeight = aGeometry.height(); + const QtInstanceWidget* pRelativeWidget = dynamic_cast(&rRelative); + if (!pRelativeWidget) + return; + + QPoint aRelativePos = m_pWidget->mapTo(pRelativeWidget->getQWidget(), QPoint(0, 0)); + rX = aRelativePos.x(); + rY = aRelativePos.y(); + bRet = true; + }); + + return bRet; } bool QtInstanceWidget::get_direction() const