diff --git a/include/DeprecationHelper.h b/include/DeprecationHelper.h index 5bd9c739718..81bf47be88c 100644 --- a/include/DeprecationHelper.h +++ b/include/DeprecationHelper.h @@ -55,7 +55,7 @@ inline int horizontalAdvance(const QFontMetrics& metrics, const QString& text) * @param wheelEvent * @return the position of wheelEvent */ -inline QPoint position(QWheelEvent *wheelEvent) +inline QPoint position(const QWheelEvent *wheelEvent) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) return wheelEvent->position().toPoint(); @@ -70,7 +70,7 @@ inline QPoint position(QWheelEvent *wheelEvent) * @param me * @return the position of the mouse event */ -inline QPoint position(QMouseEvent* me) +inline QPoint position(const QMouseEvent* me) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) return me->position().toPoint(); @@ -85,7 +85,7 @@ inline QPoint position(QMouseEvent* me) * @param me * @return the position of the drop event */ -inline QPoint position(QDropEvent* de) +inline QPoint position(const QDropEvent* de) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) return de->position().toPoint(); diff --git a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp index 7ea30186578..cc71ebf853e 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp @@ -478,17 +478,11 @@ void AudioFileProcessorWaveView::reverse() m_reversed = ! m_reversed; } -void AudioFileProcessorWaveView::updateCursor(QMouseEvent * me) +void AudioFileProcessorWaveView::updateCursor(const QMouseEvent * me) { - const auto pos = position(me); - bool const waveIsDragged = m_isDragging && (m_draggingType == DraggingType::Wave); - bool const pointerCloseToStartEndOrLoop = (me != nullptr) && - (isCloseTo(pos.x(), m_startFrameX) || - isCloseTo(pos.x(), m_endFrameX) || - isCloseTo(pos.x(), m_loopFrameX)); - if (!m_isDragging && pointerCloseToStartEndOrLoop) + if (!m_isDragging && pointerCloseToStartEndOrLoop(me)) setCursor(Qt::SizeHorCursor); else if (waveIsDragged) setCursor(Qt::ClosedHandCursor); @@ -496,6 +490,18 @@ void AudioFileProcessorWaveView::updateCursor(QMouseEvent * me) setCursor(Qt::OpenHandCursor); } +bool AudioFileProcessorWaveView::pointerCloseToStartEndOrLoop(const QMouseEvent * me) const +{ + if (me == nullptr) + { + return false; + } + + const QPoint pos = position(me); + + return isCloseTo(pos.x(), m_startFrameX) || isCloseTo(pos.x(), m_endFrameX) || isCloseTo(pos.x(), m_loopFrameX); +} + void AudioFileProcessorWaveView::configureKnobRelationsAndWaveViews() { m_startKnob->setWaveView(this); diff --git a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.h b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.h index 1251501b02d..43fb4a68849 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.h +++ b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.h @@ -170,7 +170,8 @@ public slots: void updateGraph(); void reverse(); - void updateCursor(QMouseEvent* me = nullptr); + void updateCursor(const QMouseEvent* me = nullptr); + bool pointerCloseToStartEndOrLoop(const QMouseEvent* me) const; void configureKnobRelationsAndWaveViews();