[LyX/master] Fix InsertTableWidget interference with tooltip geometry on Qt6 (#12776)
Juergen Spitzmueller
spitz at lyx.org
Thu Aug 10 13:29:31 UTC 2023
commit f75f73a402b1ca13010e689641529a5926edf814
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Thu Aug 10 16:43:06 2023 +0200
Fix InsertTableWidget interference with tooltip geometry on Qt6 (#12776)
The current method played badly with Qt6 on wayland
---
src/frontends/qt/InsertTableWidget.cpp | 8 +++-----
src/frontends/qt/InsertTableWidget.h | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/frontends/qt/InsertTableWidget.cpp b/src/frontends/qt/InsertTableWidget.cpp
index 325c053..4585527 100644
--- a/src/frontends/qt/InsertTableWidget.cpp
+++ b/src/frontends/qt/InsertTableWidget.cpp
@@ -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);
}
}
diff --git a/src/frontends/qt/InsertTableWidget.h b/src/frontends/qt/InsertTableWidget.h
index e5d7648..162c870 100644
--- a/src/frontends/qt/InsertTableWidget.h
+++ b/src/frontends/qt/InsertTableWidget.h
@@ -14,12 +14,31 @@
#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:
More information about the lyx-cvs
mailing list