[Libreoffice-commits] core.git: vcl/inc vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 12 09:12:28 UTC 2018


 vcl/inc/qt5/Qt5Frame.hxx  |    2 ++
 vcl/inc/qt5/Qt5Widget.hxx |    4 ++++
 vcl/qt5/Qt5Frame.cxx      |    9 +++++++++
 vcl/qt5/Qt5Widget.cxx     |    7 +++++++
 4 files changed, 22 insertions(+)

New commits:
commit e4e28359d688992deb8be5fbfdb3bcae855a7fe2
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Tue Dec 11 12:12:52 2018 +0100
Commit:     Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Wed Dec 12 10:12:04 2018 +0100

    tdf#120454: Implement native rendering of tooltips
    
    side-step the entire misery of proper positioning of non-native
    tooltips just like in gtk3
    
    Change-Id: I09a75fae672d3d999c946c50c547d5f2cfa3ec14
    Reviewed-on: https://gerrit.libreoffice.org/64956
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 766044a7b6d5..86f22e9d95eb 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -108,6 +108,7 @@ private Q_SLOTS:
 
 Q_SIGNALS:
     void setVisibleSignal(bool);
+    void tooltipRequest(const OUString& rTooltip);
 
 public:
     Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo);
@@ -157,6 +158,7 @@ public:
     virtual void SetPointer(PointerStyle ePointerStyle) override;
     virtual void CaptureMouse(bool bMouse) override;
     virtual void SetPointerPos(long nX, long nY) override;
+    virtual bool ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpArea);
     using SalFrame::Flush;
     virtual void Flush() override;
     virtual void SetInputContext(SalInputContext* pContext) override;
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 9f14d44fd5ef..ce68e1892c8c 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <QtWidgets/QWidget>
+#include <rtl/ustring.hxx>
 
 class Qt5Frame;
 class Qt5Object;
@@ -58,6 +59,9 @@ class Qt5Widget : public QWidget
 
     const QString m_InternalMimeType = "application/x-libreoffice-dnditem";
 
+public slots:
+    void showTooltip(const OUString& rTip);
+
 public:
     Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
     Qt5Frame* m_pFrame;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 3ab8ead48f50..1a39eefbab87 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -115,7 +115,10 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     }
     else
         m_pQWidget = new Qt5Widget(*this, aWinFlags);
+
     connect(this, SIGNAL(setVisibleSignal(bool)), SLOT(setVisible(bool)));
+    connect(this, &Qt5Frame::tooltipRequest, static_cast<Qt5Widget*>(m_pQWidget),
+            &Qt5Widget::showTooltip);
 
     if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
     {
@@ -637,6 +640,12 @@ void Qt5Frame::Flush()
     // destroyed, so that state should be safely flushed.
 }
 
+bool Qt5Frame::ShowTooltip(const OUString& rText, const tools::Rectangle& /*rHelpArea*/)
+{
+    emit tooltipRequest(rText);
+    return true;
+}
+
 // do we even need it? void Qt5Frame::Flush(const tools::Rectangle& /*rRect*/) {}
 
 void Qt5Frame::SetInputContext(SalInputContext* /*pContext*/)
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 2d108fa21cd5..373977693e0a 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -33,6 +33,7 @@
 #include <QtGui/QPaintEvent>
 #include <QtGui/QResizeEvent>
 #include <QtGui/QShowEvent>
+#include <QtGui/QToolTip>
 #include <QtGui/QWheelEvent>
 #include <QtWidgets/QtWidgets>
 #include <QtWidgets/QMainWindow>
@@ -410,6 +411,12 @@ void Qt5Widget::focusOutEvent(QFocusEvent*)
     m_pFrame->CallCallback(SalEvent::LoseFocus, nullptr);
 }
 
+void Qt5Widget::showTooltip(const OUString& rTooltip)
+{
+    QPoint pt = QCursor::pos();
+    QToolTip::showText(pt, toQString(rTooltip));
+}
+
 Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
     : QWidget(Q_NULLPTR, f)
     , m_pFrame(&rFrame)


More information about the Libreoffice-commits mailing list