]> git.lyx.org Git - features.git/commitdiff
Fix InsertTableWidget interference with tooltip geometry on Qt6 (#12776)
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 10 Aug 2023 14:43:06 +0000 (16:43 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 10 Aug 2023 14:43:06 +0000 (16:43 +0200)
The current method played badly with Qt6 on wayland

src/frontends/qt/InsertTableWidget.cpp
src/frontends/qt/InsertTableWidget.h

index 325c0533b3a64def4abd61f0feb4ecc5e5684f90..45855274a830f752b27f0c0f3655e09fd28212a0 100644 (file)
@@ -37,6 +37,8 @@ InsertTableWidget::InsertTableWidget(QWidget * parent)
 {
        init();
        setMouseTracking(true);
+       // display tooltip without any delay
+       setStyle(new ProxyStyle(style()));
 }
 
 
@@ -120,11 +122,7 @@ void InsertTableWidget::mouseMoveEvent(QMouseEvent * event)
        if (bottom_ != b0 || right_ != r0) {
                update();
                QString const status = QString("%1x%2").arg(bottom_).arg(right_);
-#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
-               QToolTip::showText(event->globalPosition().toPoint(), status , this);
-#else
-               QToolTip::showText(event->globalPos(), status , this);
-#endif
+               setToolTip(status);
        }
 }
 
index e5d764854416b56523d958a48184c6ce7eee9b33..162c87010d90ab0a505bc9bf5e7d03e45d7faf26 100644 (file)
 #define INSERTTABLEWIDGET_H
 
 #include <QWidget>
+#include <QProxyStyle>
 
 namespace lyx {
 namespace frontend {
 
 class GuiView;
 
+// A proxy style to get rif of the style-specific tool tip delay
+// (https://forum.qt.io/topic/90403/show-tooltip-immediatly/6)
+class ProxyStyle : public QProxyStyle
+{
+public:
+       using QProxyStyle::QProxyStyle;
+       int styleHint(StyleHint hint, const QStyleOption * option = nullptr,
+                     const QWidget* widget = nullptr,
+                     QStyleHintReturn* returnData = nullptr) const override
+       {
+               if (hint == QStyle::SH_ToolTip_WakeUpDelay)
+                       return 0;
+               else if (hint == QStyle::SH_ToolTip_FallAsleepDelay)
+                       return 0;
+               return QProxyStyle::styleHint(hint, option, widget, returnData);
+       }
+};
+
 class InsertTableWidget : public QWidget {
        Q_OBJECT
 public: