diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/qt5/QtFrame.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/qt5/QtWidget.hxx | 2 | ||||
-rw-r--r-- | vcl/qt5/QtFrame.cxx | 8 | ||||
-rw-r--r-- | vcl/qt5/QtWidget.cxx | 19 |
4 files changed, 29 insertions, 3 deletions
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index a873cec76ad6..2d7c5718d6cf 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -110,6 +110,9 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame LanguageType m_nInputLanguage; + OUString m_aTooltipText; + QRect m_aTooltipArea; + void SetDefaultPos(); Size CalcDefaultSize(); void SetDefaultSize(); diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index 575cef11014f..878c8b1229ce 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -87,7 +87,7 @@ public: void endExtTextInput(); void fakeResize(); - static bool handleEvent(QtFrame&, const QWidget&, QEvent*); + static bool handleEvent(QtFrame&, QWidget&, QEvent*); // key events might be propagated further down => call base on false static inline bool handleKeyReleaseEvent(QtFrame&, const QWidget&, QKeyEvent*); // mouse events are always accepted diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 91361311d60e..440cd8048d76 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -173,7 +173,12 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) m_pTopLevel->setFocusProxy(m_pQWidget); } else + { m_pQWidget = new QtWidget(*this, aWinFlags); + // from Qt's POV the popup window doesn't have the input focus, so we must force tooltips... + if (isPopup()) + m_pQWidget->setAttribute(Qt::WA_AlwaysShowToolTips); + } QWindow* pChildWindow = windowHandle(); connect(pChildWindow, &QWindow::screenChanged, this, &QtFrame::screenChanged); @@ -859,7 +864,8 @@ bool QtFrame::ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpAr QRect aHelpArea(toQRect(rHelpArea)); if (QGuiApplication::isRightToLeft()) aHelpArea.moveLeft(maGeometry.nWidth - aHelpArea.width() - aHelpArea.left() - 1); - QToolTip::showText(QCursor::pos(), toQString(rText), m_pQWidget, aHelpArea); + m_aTooltipText = rText; + m_aTooltipArea = aHelpArea; return true; } diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index 612682ae987f..33320c577f94 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -42,6 +42,7 @@ #include <QtGui/QTextCharFormat> #include <QtGui/QWheelEvent> #include <QtWidgets/QMainWindow> +#include <QtWidgets/QToolTip> #include <QtWidgets/QWidget> #include <cairo.h> @@ -562,7 +563,7 @@ bool QtWidget::handleKeyEvent(QtFrame& rFrame, const QWidget& rWidget, QKeyEvent return bStopProcessingKey; } -bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& rWidget, QEvent* pEvent) +bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent) { if (pEvent->type() == QEvent::ShortcutOverride) { @@ -589,6 +590,22 @@ bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& rWidget, QEvent* pEve ButtonKeyState::Pressed)) return true; } + else if (pEvent->type() == QEvent::ToolTip) + { + // Qt's POV on focus is wrong for our fake popup windows, so check LO's state. + // Otherwise Qt will continue handling ToolTip events from the "parent" window. + const vcl::Window* pFocusWin = Application::GetFocusWindow(); + if (!rFrame.m_aTooltipText.isEmpty() && pFocusWin + && pFocusWin->GetFrameWindow() == rFrame.GetWindow()) + QToolTip::showText(QCursor::pos(), toQString(rFrame.m_aTooltipText), &rWidget, + rFrame.m_aTooltipArea); + else + { + QToolTip::hideText(); + pEvent->ignore(); + } + return true; + } return false; } |