diff --git a/include/FileBrowser.h b/include/FileBrowser.h index a890506bdf3..8cc50f48e79 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -108,6 +108,7 @@ class FileBrowserTreeWidget : public QTreeWidget void keyPressEvent( QKeyEvent * ke ) override; void keyReleaseEvent( QKeyEvent * ke ) override; void hideEvent( QHideEvent * he ) override; + void focusOutEvent( QFocusEvent * fe ) override; private: diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 0524146069e..a7d78bf5463 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -433,6 +433,16 @@ void FileBrowserTreeWidget::hideEvent(QHideEvent* he) +void FileBrowserTreeWidget::focusOutEvent(QFocusEvent* fe) +{ + // Cancel previews when the user clicks outside the browser + stopPreview(); + QTreeWidget::focusOutEvent(fe); +} + + + + void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) { FileItem * file = dynamic_cast( itemAt( e->pos() ) ); @@ -674,22 +684,8 @@ void FileBrowserTreeWidget::mouseReleaseEvent(QMouseEvent * me ) QMutexLocker previewLocker(&m_pphMutex); - if (m_previewPlayHandle != nullptr) - { - // If less than 3 seconds remain of the sample, we don't - // stop them if the user releases mouse-button... - if (m_previewPlayHandle->type() == PlayHandle::TypeSamplePlayHandle) - { - SamplePlayHandle* s = dynamic_cast(m_previewPlayHandle); - auto second = static_cast(Engine::mixer()->processingSampleRate()); - if (s && s->totalFrames() - s->framesDone() <= second * 3) - { - s->setDoneMayReturnTrue(true); - } - else { stopPreview(); } - } - else { stopPreview(); } - } + //TODO: User setting to allow samples to play until completion instead + if (m_previewPlayHandle != nullptr) { stopPreview(); } }