vcl/inc/qt5/QtInstance.hxx    |    5 ++---
 vcl/qt5/QtInstancePopover.cxx |   26 +++++++++++++++++++++++---
 2 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 6105b78a4c473971b1fc5cadecfad8fea95d7d03
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Aug 13 12:52:26 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Aug 13 21:48:19 2025 +0200

    tdf#130857 qt weld: Implement QtInstancePopover::popup_at_rect
    
    ... and QtInstancePopover::popup.
    
    See QtInstanceMenuButton::handleButtonClicked and
    QtInstanceMenu::popup_at_rect for similar implementations
    to show some kind of popup.
    
    This will be used e.g. by the Calc autofilter dropdown
    once support for it is declared.
    
    For now, use QtInstance::GetNativeParentFromWeldParent to get
    the native parent and don't assume that the
    passed weld::Widget is a QtInstanceWidget.
    For the Calc autofilter popup, the passed parent is
    retrieved via Window::GetFrameWeld (see
    ScGridWindow::LaunchAutoFilterMenu) which calls
    SalFrame::GetFrameWeld, which is not overriden
    in QtFrame yet to return a QtInstanceWindow. Doing so
    would break the cases of dialogs which are not yet using
    native Qt widgets (as the VCL/SalInstanceDialog implementation
    requires a SalInstanceWidget parent, e.g. for proper modality),
    so implementing QtFrame::GetFrameWeld needs to wait for now.
    
    Change-Id: I9ecd04d0935944d08fb280313b80594fa588e42f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189506
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index 21cf0498e277..dbb9afb63847 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -90,9 +90,6 @@ class VCLPLUG_QT_PUBLIC QtInstance : public QObject,
 
     DECL_DLLPRIVATE_LINK(updateStyleHdl, Timer*, void);
     void AfterAppInit() override;
-
-    static QWidget* GetNativeParentFromWeldParent(weld::Widget* pParent);
-
     void EmscriptenLightweightRunInMainThread_(std::function<void()> func);
 
 private Q_SLOTS:
@@ -235,6 +232,8 @@ public:
     bool DoExecute(int& nExitCode) override;
     void DoQuit() override;
 
+    static QWidget* GetNativeParentFromWeldParent(weld::Widget* pParent);
+
     QtFrame* activePopup() const { return m_pActivePopup; }
     void setActivePopup(QtFrame*);
 };
diff --git a/vcl/qt5/QtInstancePopover.cxx b/vcl/qt5/QtInstancePopover.cxx
index e35665e8289c..df88afcf1741 100644
--- a/vcl/qt5/QtInstancePopover.cxx
+++ b/vcl/qt5/QtInstancePopover.cxx
@@ -15,12 +15,32 @@ QtInstancePopover::QtInstancePopover(QWidget* pWidget)
 {
 }
 
-void QtInstancePopover::popup_at_rect(weld::Widget*, const tools::Rectangle&, 
weld::Placement)
+void QtInstancePopover::popup_at_rect(weld::Widget* pParent, const 
tools::Rectangle& rRect,
+                                      weld::Placement ePlace)
 {
-    assert(false && "Not implemented yet");
+    SolarMutexGuard g;
+
+    assert(ePlace == weld::Placement::Under && "placement type not supported 
yet");
+    (void)ePlace;
+
+    GetQtInstance().RunInMainThread([&] {
+        QWidget* pPopoverWidget = getQWidget();
+        pPopoverWidget->adjustSize();
+        QWidget* pParentWidget = 
QtInstance::GetNativeParentFromWeldParent(pParent);
+        QPoint aPos = pParentWidget->mapToGlobal(toQPoint(rRect.BottomLeft()));
+        aPos.setX(aPos.x() + rRect.GetWidth() - pPopoverWidget->width() / 2);
+
+        pPopoverWidget->move(aPos);
+        pPopoverWidget->show();
+    });
 }
 
-void QtInstancePopover::popdown() { assert(false && "Not implemented yet"); }
+void QtInstancePopover::popdown()
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] { getQWidget()->hide(); });
+}
 
 void QtInstancePopover::resize_to_request() { assert(false && "Not implemented 
yet"); }
 

Reply via email to