vcl/inc/qt5/QtInstanceDrawingArea.hxx |    1 +
 vcl/inc/qt5/QtInstanceWidget.hxx      |    2 ++
 vcl/qt5/QtInstanceDrawingArea.cxx     |   20 ++++++++++++++++++++
 vcl/qt5/QtInstanceWidget.cxx          |   12 ++++++++++++
 4 files changed, 35 insertions(+)

New commits:
commit 2ceea3e05bdc777d9c1093ef8f838d4a716e0b75
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Apr 11 16:44:22 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 11 19:45:18 2025 +0200

    tdf#130857 qt weld: Show drawing area tooltips
    
    This is similar to what
    
        commit dd9096736e2e89cc533bc04c77bf539bcc5df6bc
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Feb 13 21:31:04 2025 +0100
    
            tdf#130857 qt weld: Show IconView item tooltips
    
    implemented for weld::IconView, but now for weld::DrawingArea.
    
    Note that `aHelpArea` is an in/out param for
    weld::DrawingArea::signal_query_tooltip, see also
    the gtk3 implementation in
    GtkInstanceDrawingArea::signalQueryTooltip.
    
    In a WIP branch (also containing various other changes)
    for the "File" -> "Templates" -> "Manage Templates" dialog,
    this results in the tooltip for the currently hovered
    template to appear when hovering with the mouse and waiting
    for a few seconds in thumbnail mode.
    
    Change-Id: Ic829d1d1984aedddc0eaccba7538937defea57f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184053
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/qt5/QtInstanceDrawingArea.hxx 
b/vcl/inc/qt5/QtInstanceDrawingArea.hxx
index c403662ef6f9..05c9676af2fd 100644
--- a/vcl/inc/qt5/QtInstanceDrawingArea.hxx
+++ b/vcl/inc/qt5/QtInstanceDrawingArea.hxx
@@ -48,6 +48,7 @@ public:
 private:
     void handlePaintEvent();
     void handleResizeEvent();
+    bool handleToolTipEvent(QHelpEvent& rEvent);
 
 private:
     virtual void click(const Point&) override;
diff --git a/vcl/qt5/QtInstanceDrawingArea.cxx 
b/vcl/qt5/QtInstanceDrawingArea.cxx
index 4610f554a18c..86929c836d9a 100644
--- a/vcl/qt5/QtInstanceDrawingArea.cxx
+++ b/vcl/qt5/QtInstanceDrawingArea.cxx
@@ -14,6 +14,9 @@
 
 #include <vcl/qt/QtUtils.hxx>
 
+#include <QtGui/QHelpEvent>
+#include <QtWidgets/QToolTip>
+
 QtInstanceDrawingArea::QtInstanceDrawingArea(QLabel* pLabel)
     : QtInstanceWidget(pLabel)
     , m_pLabel(pLabel)
@@ -102,6 +105,11 @@ bool QtInstanceDrawingArea::eventFilter(QObject* pObject, 
QEvent* pEvent)
         case QEvent::Resize:
             handleResizeEvent();
             return false;
+        case QEvent::ToolTip:
+        {
+            QHelpEvent* pHelpEvent = static_cast<QHelpEvent*>(pEvent);
+            return handleToolTipEvent(*pHelpEvent);
+        }
         default:
             return QtInstanceWidget::eventFilter(pObject, pEvent);
     }
@@ -131,4 +139,16 @@ void QtInstanceDrawingArea::handleResizeEvent()
     m_aSizeAllocateHdl.Call(aSize);
 }
 
+bool QtInstanceDrawingArea::handleToolTipEvent(QHelpEvent& rEvent)
+{
+    tools::Rectangle aHelpArea(toPoint(rEvent.pos()), Size(0, 0));
+    const OUString sToolTipText = signal_query_tooltip(aHelpArea);
+    if (sToolTipText.isEmpty())
+        return false;
+
+    const QPoint aPos = 
getQWidget()->mapToGlobal(toQRect(aHelpArea).topLeft());
+    QToolTip::showText(aPos, toQString(sToolTipText), getQWidget());
+    return true;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
commit 2cca27e91e3110457099cea0ec66caf790e6feaf
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Apr 11 16:13:53 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 11 19:45:11 2025 +0200

    tdf#130857 qt weld: Forward mouse move events
    
    Similar to what
    
        Change-Id: I507deb1ed4aa2ae39c5f2b14f8bcb1fc1069ccf3
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Fri Apr 11 15:58:16 2025 +0200
    
            tdf#130857 qt weld: Forward mouse click/release events
    
    implement for mouse click/release events, also forward
    mouse move events.
    
    Quoting from the QWidget::mouseTracking doc [1]:
    
    > If mouse tracking is disabled (the default), the widget only
    > receives mouse move events when at least one mouse button is
    > pressed while the mouse is being moved.
    
    Therefore, override weld::Widget::connect_mouse_move to
    explicitly enable mouse tracking for the widget when
    a handler gets set (and disable otherwise).
    
    In a WIP branch (also containing various other changes)
    for the "File" -> "Templates" -> "Manage Templates" dialog,
    this results in mouse-hover highlighting (light bue with
    the Fusion style) to work in thumbnail mode.
    
    [1] https://doc.qt.io/qt-6/qwidget.html#mouseTracking-prop
    
    Change-Id: I28ac58caafef9721168338ec145bbd41327be9b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184049
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index 3ec744177c1f..53ace384176e 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -32,6 +32,8 @@ public:
 
     virtual QWidget* getQWidget() const { return m_pWidget; }
 
+    virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& 
rLink) override;
+
     virtual void set_sensitive(bool bSensitive) override;
 
     virtual bool get_sensitive() const override;
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index f228ec504917..9429fccc6bdf 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -30,6 +30,13 @@ QtInstanceWidget::QtInstanceWidget(QWidget* pWidget)
     pWidget->installEventFilter(this);
 }
 
+void QtInstanceWidget::connect_mouse_move(const Link<const MouseEvent&, bool>& 
rLink)
+{
+    getQWidget()->setMouseTracking(rLink.IsSet());
+
+    weld::Widget::connect_mouse_move(rLink);
+}
+
 void QtInstanceWidget::set_sensitive(bool bSensitive)
 {
     SolarMutexGuard g;
@@ -270,6 +277,11 @@ bool QtInstanceWidget::eventFilter(QObject* pObject, 
QEvent* pEvent)
             QMouseEvent* pMouseEvent = static_cast<QMouseEvent*>(pEvent);
             return signal_mouse_release(toVclMouseEvent(*pMouseEvent));
         }
+        case QEvent::MouseMove:
+        {
+            QMouseEvent* pMouseEvent = static_cast<QMouseEvent*>(pEvent);
+            return signal_mouse_motion(toVclMouseEvent(*pMouseEvent));
+        }
         default:
             return QObject::eventFilter(pObject, pEvent);
     }

Reply via email to