Skip to content

Commit

Permalink
Add option to continue sidebar previews when mouse released (#5787)
Browse files Browse the repository at this point in the history
* Add option to continue sidebar previews when mouse released

* Cancel non-sample previews regardless of setting
  • Loading branch information
Spekular authored Nov 24, 2020
1 parent 8d4bcd7 commit ed9abe5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private slots:
void toggleCompactTrackButtons(bool enabled);
void toggleOneInstrumentTrackWindow(bool enabled);
void toggleSideBarOnRight(bool enabled);
void toggleLetPreviewsFinish(bool enabled);
void toggleSoloLegacyBehavior(bool enabled);
void toggleMMPZ(bool enabled);
void toggleDisableBackup(bool enabled);
Expand Down Expand Up @@ -133,6 +134,7 @@ private slots:
bool m_compactTrackButtons;
bool m_oneInstrumentTrackWindow;
bool m_sideBarOnRight;
bool m_letPreviewsFinish;
bool m_soloLegacyBehavior;
bool m_MMPZ;
bool m_disableBackup;
Expand Down
12 changes: 9 additions & 3 deletions src/gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,16 @@ void FileBrowserTreeWidget::mouseReleaseEvent(QMouseEvent * me )
{
m_mousePressed = false;

// If a preview is running, we may need to stop it. Otherwise, we're done
QMutexLocker previewLocker(&m_pphMutex);

//TODO: User setting to allow samples to play until completion instead
if (m_previewPlayHandle != nullptr) { stopPreview(); }
if (m_previewPlayHandle == nullptr) { return; }

// Only sample previews may continue after mouse up. Is this a sample preview?
bool isSample = m_previewPlayHandle->type() == PlayHandle::TypeSamplePlayHandle;
// Even sample previews should only continue if the user wants them to. Do they?
bool shouldContinue = ConfigManager::inst()->value("ui", "letpreviewsfinish").toInt();
// If both are true the preview may continue, otherwise we stop it
if (!(isSample && shouldContinue)) { stopPreview(); }
}


Expand Down
14 changes: 13 additions & 1 deletion src/gui/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) :
"ui", "oneinstrumenttrackwindow").toInt()),
m_sideBarOnRight(ConfigManager::inst()->value(
"ui", "sidebaronright").toInt()),
m_letPreviewsFinish(ConfigManager::inst()->value(
"ui", "letpreviewsfinish").toInt()),
m_soloLegacyBehavior(ConfigManager::inst()->value(
"app", "sololegacybehavior", "0").toInt()),
m_MMPZ(!ConfigManager::inst()->value(
Expand Down Expand Up @@ -237,6 +239,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) :
m_oneInstrumentTrackWindow, SLOT(toggleOneInstrumentTrackWindow(bool)), true);
addLedCheckBox(tr("Show sidebar on the right-hand side"), gui_tw, counter,
m_sideBarOnRight, SLOT(toggleSideBarOnRight(bool)), true);
addLedCheckBox(tr("Let sample previews continue when mouse is released"), gui_tw, counter,
m_letPreviewsFinish, SLOT(toggleLetPreviewsFinish(bool)), false);
addLedCheckBox(tr("Mute automation tracks during solo"), gui_tw, counter,
m_soloLegacyBehavior, SLOT(toggleSoloLegacyBehavior(bool)), false);

Expand Down Expand Up @@ -466,7 +470,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) :
as_w_layout->setMargin(0);

#ifdef LMMS_HAVE_JACK
m_audioIfaceSetupWidgets[AudioJack::name()] =
m_audioIfaceSetupWidgets[AudioJack::name()] =
new AudioJack::setupWidget(as_w);
#endif

Expand Down Expand Up @@ -911,6 +915,8 @@ void SetupDialog::accept()
QString::number(m_oneInstrumentTrackWindow));
ConfigManager::inst()->setValue("ui", "sidebaronright",
QString::number(m_sideBarOnRight));
ConfigManager::inst()->setValue("ui", "letpreviewsfinish",
QString::number(m_letPreviewsFinish));
ConfigManager::inst()->setValue("app", "sololegacybehavior",
QString::number(m_soloLegacyBehavior));
ConfigManager::inst()->setValue("app", "nommpz",
Expand Down Expand Up @@ -1025,6 +1031,12 @@ void SetupDialog::toggleSideBarOnRight(bool enabled)
}


void SetupDialog::toggleLetPreviewsFinish(bool enabled)
{
m_letPreviewsFinish = enabled;
}


void SetupDialog::toggleMMPZ(bool enabled)
{
m_MMPZ = enabled;
Expand Down

0 comments on commit ed9abe5

Please sign in to comment.