From 3f1ed5b934879a13dbf823af1f7112e547441de0 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 25 Apr 2022 15:01:59 +0100 Subject: [PATCH] Restore cursor when moved over child widget --- sdrgui/channel/channelgui.cpp | 2 ++ sdrgui/device/devicegui.cpp | 2 ++ sdrgui/feature/featuregui.cpp | 2 ++ sdrgui/gui/framelesswindowresizer.cpp | 8 ++++++++ sdrgui/gui/framelesswindowresizer.h | 3 +++ sdrgui/gui/glspectrum.cpp | 2 ++ sdrgui/mainspectrum/mainspectrumgui.cpp | 1 + 7 files changed, 20 insertions(+) diff --git a/sdrgui/channel/channelgui.cpp b/sdrgui/channel/channelgui.cpp index 4772363e9..6f2f91cf0 100644 --- a/sdrgui/channel/channelgui.cpp +++ b/sdrgui/channel/channelgui.cpp @@ -184,6 +184,8 @@ ChannelGUI::ChannelGUI(QWidget *parent) : this, &ChannelGUI::onWidgetRolled ); + + m_resizer.enableChildMouseTracking(); } ChannelGUI::~ChannelGUI() diff --git a/sdrgui/device/devicegui.cpp b/sdrgui/device/devicegui.cpp index a782cdff5..eefa2355b 100644 --- a/sdrgui/device/devicegui.cpp +++ b/sdrgui/device/devicegui.cpp @@ -193,6 +193,8 @@ DeviceGUI::DeviceGUI(QWidget *parent) : this, &DeviceGUI::addChannelEmitted ); + + m_resizer.enableChildMouseTracking(); } DeviceGUI::~DeviceGUI() diff --git a/sdrgui/feature/featuregui.cpp b/sdrgui/feature/featuregui.cpp index c7d1f6481..583256a18 100644 --- a/sdrgui/feature/featuregui.cpp +++ b/sdrgui/feature/featuregui.cpp @@ -141,6 +141,8 @@ FeatureGUI::FeatureGUI(QWidget *parent) : this, &FeatureGUI::onWidgetRolled ); + + m_resizer.enableChildMouseTracking(); } FeatureGUI::~FeatureGUI() diff --git a/sdrgui/gui/framelesswindowresizer.cpp b/sdrgui/gui/framelesswindowresizer.cpp index ba5c0d7c5..ff5e4a8b3 100644 --- a/sdrgui/gui/framelesswindowresizer.cpp +++ b/sdrgui/gui/framelesswindowresizer.cpp @@ -34,6 +34,14 @@ FramelessWindowResizer::FramelessWindowResizer(QWidget *widget) : { } +void FramelessWindowResizer::enableChildMouseTracking() +{ + QList widgets = m_widget->findChildren(); + for (auto widget : widgets) { + widget->setMouseTracking(true); + } +} + bool FramelessWindowResizer::mouseOnTopBorder(QPoint pos) const { return (pos.y() >= 0) && (pos.y() < m_gripSize); diff --git a/sdrgui/gui/framelesswindowresizer.h b/sdrgui/gui/framelesswindowresizer.h index 7b2e106eb..c3827c4ba 100644 --- a/sdrgui/gui/framelesswindowresizer.h +++ b/sdrgui/gui/framelesswindowresizer.h @@ -28,6 +28,8 @@ // by clicking and draging on the border // The window needs to forward the mousePressEvent, mouseReleaseEvent, mouseMoveEvent // and leaveEvent events to this class +// Child widgets should have mouse tracking enabled, so cursor can be controlled properly +// This can be achieved by calling enableChildMouseTracking class SDRGUI_API FramelessWindowResizer { private: @@ -49,6 +51,7 @@ private: public: FramelessWindowResizer(QWidget *widget); + void enableChildMouseTracking(); void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index f6a6485e4..4004ed4c5 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -2565,6 +2565,8 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) return; } + + event->setAccepted(false); } void GLSpectrum::mousePressEvent(QMouseEvent* event) diff --git a/sdrgui/mainspectrum/mainspectrumgui.cpp b/sdrgui/mainspectrum/mainspectrumgui.cpp index f0424c16c..dfc44d99e 100644 --- a/sdrgui/mainspectrum/mainspectrumgui.cpp +++ b/sdrgui/mainspectrum/mainspectrumgui.cpp @@ -140,6 +140,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGU connect(this, SIGNAL(forceShrink()), this, SLOT(shrinkWindow())); connect(m_hideButton, SIGNAL(clicked()), this, SLOT(hide())); + m_resizer.enableChildMouseTracking(); shrinkWindow(); }