diff options
author | Harshit Maurya <hmaurya999@gmail.com> | 2020-05-13 01:44:34 +0530 |
---|---|---|
committer | Harshit Maurya <hmaurya999@gmail.com> | 2020-05-16 02:17:43 +0530 |
commit | e129710c8b5b210f747fe0b8832be3b6b7eb3e9d (patch) | |
tree | 3348178c4defeb818dc81e34bc6abbc371fedad5 | |
parent | 10ce4c441377389010a7a901747337f9f724e958 (diff) |
wwaveformviewer: handle menu close
-rw-r--r-- | src/widget/wcuemenupopup.cpp | 5 | ||||
-rw-r--r-- | src/widget/wcuemenupopup.h | 7 | ||||
-rw-r--r-- | src/widget/wwaveformviewer.cpp | 16 | ||||
-rw-r--r-- | src/widget/wwaveformviewer.h | 4 |
4 files changed, 24 insertions, 8 deletions
diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp index 66bd49d378..6b270f5559 100644 --- a/src/widget/wcuemenupopup.cpp +++ b/src/widget/wcuemenupopup.cpp @@ -132,3 +132,8 @@ void WCueMenuPopup::slotDeleteCue() { m_pTrack->removeCue(m_pCue); hide(); } + +void WCueMenuPopup::closeEvent(QCloseEvent* event) { + emit aboutToHide(); + QWidget::closeEvent(event); +} diff --git a/src/widget/wcuemenupopup.h b/src/widget/wcuemenupopup.h index 7e1743590d..fafb1527c7 100644 --- a/src/widget/wcuemenupopup.h +++ b/src/widget/wcuemenupopup.h @@ -37,11 +37,6 @@ class WCueMenuPopup : public QWidget { show(); } - void hide() { - emit aboutToHide(); - QWidget::hide(); - } - void show() { setColorPalette(m_colorPaletteSettings.getHotcueColorPalette()); m_pEditLabel->setFocus(); @@ -59,6 +54,8 @@ class WCueMenuPopup : public QWidget { void slotChangeCueColor(mixxx::RgbColor::optional_t color); private: + void closeEvent(QCloseEvent* event) override; + ColorPaletteSettings m_colorPaletteSettings; CuePointer m_pCue; TrackPointer m_pTrack; diff --git a/src/widget/wwaveformviewer.cpp b/src/widget/wwaveformviewer.cpp index 0fb4e989bb..b180b56f94 100644 --- a/src/widget/wwaveformviewer.cpp +++ b/src/widget/wwaveformviewer.cpp @@ -23,6 +23,7 @@ WWaveformViewer::WWaveformViewer(const char* group, UserSettingsPointer pConfig, m_zoomZoneWidth(20), m_bScratching(false), m_bBending(false), + m_bHotcueMenuShowing(false), m_pCueMenuPopup(make_parented<WCueMenuPopup>(pConfig, this)), m_waveformWidget(nullptr) { setAcceptDrops(true); @@ -37,6 +38,10 @@ WWaveformViewer::WWaveformViewer(const char* group, UserSettingsPointer pConfig, m_pWheel = new ControlProxy( group, "wheel", this); + connect(m_pCueMenuPopup.get(), + &WCueMenuPopup::aboutToHide, + this, + &WWaveformViewer::slotCueMenuPopupAboutToHide); setAttribute(Qt::WA_OpaquePaintEvent); } @@ -79,10 +84,11 @@ void WWaveformViewer::mousePressEvent(QMouseEvent* event) { m_pScratchPositionEnable->slotSet(1.0); } else if (event->button() == Qt::RightButton) { const auto currentTrack = m_waveformWidget->getTrackInfo(); - auto cueAtClickPos = m_waveformWidget->getCueAtPoint(event->pos()); + auto cueAtClickPos = m_waveformWidget->getCueAtPoint(m_mouseAnchor); if (cueAtClickPos) { m_pCueMenuPopup->setTrackAndCue(currentTrack, *cueAtClickPos); m_pCueMenuPopup->popup(event->globalPos()); + m_bHotcueMenuShowing = true; } // If we are scratching then disable and reset because the two shouldn't // be used at once. @@ -95,7 +101,9 @@ void WWaveformViewer::mousePressEvent(QMouseEvent* event) { } // Set the cursor to a hand while the mouse is down. - setCursor(Qt::ClosedHandCursor); + if (!m_bHotcueMenuShowing) { + setCursor(Qt::ClosedHandCursor); + } } void WWaveformViewer::mouseMoveEvent(QMouseEvent* event) { @@ -225,3 +233,7 @@ void WWaveformViewer::setWaveformWidget(WaveformWidgetAbstract* waveformWidget) this, SLOT(slotWidgetDead())); } } + +void WWaveformViewer::slotCueMenuPopupAboutToHide() { + m_bHotcueMenuShowing = false; +} diff --git a/src/widget/wwaveformviewer.h b/src/widget/wwaveformviewer.h index af23fcb917..29e1154533 100644 --- a/src/widget/wwaveformviewer.h +++ b/src/widget/wwaveformviewer.h @@ -52,8 +52,9 @@ private slots: void slotWidgetDead() { m_waveformWidget = nullptr; } + void slotCueMenuPopupAboutToHide(); -private: + private: void setWaveformWidget(WaveformWidgetAbstract* waveformWidget); WaveformWidgetAbstract* getWaveformWidget() { return m_waveformWidget; @@ -73,6 +74,7 @@ private: ControlProxy* m_pWheel; bool m_bScratching; bool m_bBending; + bool m_bHotcueMenuShowing; QPoint m_mouseAnchor; parented_ptr<WCueMenuPopup> m_pCueMenuPopup; |