Skip to content

Commit

Permalink
History: make 'recently played' threshold configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Apr 15, 2022
1 parent fbfc888 commit 03ec672
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/library/library_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const ConfigKey mixxx::library::prefs::kHistoryCleanupKeepLockedConfigKey =
mixxx::library::prefs::kConfigGroup,
QStringLiteral("history_cleanup_keep_locked")};

const ConfigKey mixxx::library::prefs::kHistoryRecentlyPlayedThresholdConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("history_recently_played_threshold")};

const ConfigKey mixxx::library::prefs::kSearchDebouncingTimeoutMillisConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
Expand Down
4 changes: 4 additions & 0 deletions src/library/library_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ extern const ConfigKey kHistoryCleanupMinTracksConfigKey;

extern const ConfigKey kHistoryCleanupKeepLockedConfigKey;

extern const ConfigKey kHistoryRecentlyPlayedThresholdConfigKey;

const int kHistoryRecentlyPlayedThresholdDefault = 6;

const bool kEditMetadataSelectedClickDefault = false;

extern const ConfigKey kSyncTrackMetadataConfigKey;
Expand Down
6 changes: 4 additions & 2 deletions src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@ void SetlogFeature::slotPlayingTrackChanged(TrackPointer currentPlayingTrack) {
m_recentTracks.push_front(currentPlayingTrackId);

// Keep a window of 6 tracks (inspired by 2 decks, 4 samplers)
constexpr int kRecentTrackWindow = 6;
while (m_recentTracks.size() > kRecentTrackWindow) {
const unsigned int recentTrackWindow = m_pConfig->getValue(
kHistoryRecentlyPlayedThresholdConfigKey,
kHistoryRecentlyPlayedThresholdDefault);
while (m_recentTracks.size() > recentTrackWindow) {
m_recentTracks.pop_back();
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ void DlgPrefLibrary::initializeDirList() {

void DlgPrefLibrary::slotResetToDefaults() {
checkBox_library_scan->setChecked(false);
spinbox_history_recently_played_threshold->setValue(
kHistoryRecentlyPlayedThresholdDefault);
spinbox_min_history_tracks->setValue(1);
checkBox_history_cleanup_keep_locked->setChecked(false);
checkBox_SyncTrackMetadata->setChecked(false);
Expand All @@ -201,8 +203,8 @@ void DlgPrefLibrary::slotResetToDefaults() {
checkBox_show_itunes->setChecked(true);
checkBox_show_traktor->setChecked(true);
checkBox_show_rekordbox->setChecked(true);
radioButton_dbclick_bottom->setChecked(false);
checkBoxEditMetadataSelectedClicked->setChecked(kEditMetadataSelectedClickDefault);
radioButton_dbclick_bottom->setChecked(false);
radioButton_dbclick_top->setChecked(false);
radioButton_dbclick_deck->setChecked(true);
spinBoxRowHeight->setValue(Library::kDefaultRowHeightPx);
Expand All @@ -216,6 +218,9 @@ void DlgPrefLibrary::slotUpdate() {
checkBox_library_scan->setChecked(m_pConfig->getValue(
kRescanOnStartupConfigKey, false));

spinbox_history_recently_played_threshold->setValue(m_pConfig->getValue(
kHistoryRecentlyPlayedThresholdConfigKey,
kHistoryRecentlyPlayedThresholdDefault));
spinbox_min_history_tracks->setValue(m_pConfig->getValue(
kHistoryCleanupMinTracksConfigKey, 1));
checkBox_history_cleanup_keep_locked->setChecked(m_pConfig->getValue(
Expand Down Expand Up @@ -395,6 +400,8 @@ void DlgPrefLibrary::slotApply() {
m_pConfig->set(kRescanOnStartupConfigKey,
ConfigValue((int)checkBox_library_scan->isChecked()));

m_pConfig->set(kHistoryRecentlyPlayedThresholdConfigKey,
ConfigValue(spinbox_history_recently_played_threshold->value()));
m_pConfig->set(kHistoryCleanupMinTracksConfigKey,
ConfigValue(spinbox_min_history_tracks->value()));
m_pConfig->set(kHistoryCleanupKeepLockedConfigKey,
Expand Down
50 changes: 39 additions & 11 deletions src/preferences/dialog/dlgpreflibrarydlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,33 @@
</item>

<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_history_recently_played_threshold">
<property name="text">
<string>When playing a track again log it only if more than ... other tracks have been played in the meantime</string>
</property>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="spinbox_history_recently_played_threshold">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>

<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_history_cleanup">
<property name="text">
<string>Delete history playlist with less than ... tracks</string>
Expand All @@ -182,7 +209,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="spinbox_min_history_tracks">
<property name="minimum">
<number>1</number>
Expand All @@ -196,31 +223,31 @@
</widget>
</item>

<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_history_cleanup_keep_locked">
<property name="text">
<string>Keep locked history playlists</string>
</property>
</widget>
</item>

<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxEditMetadataSelectedClicked">
<property name="text">
<string>Edit metadata after clicking selected track</string>
</property>
</widget>
</item>

<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_use_relative_path">
<property name="text">
<string>Use relative paths for playlist export if possible</string>
</property>
</widget>
</item>

<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="rowHeightLabel">
<property name="text">
<string>Library Row Height:</string>
Expand All @@ -230,7 +257,7 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<item row="6" column="1" colspan="2">
<widget class="QSpinBox" name="spinBoxRowHeight">
<property name="suffix">
<string> px</string>
Expand All @@ -247,7 +274,7 @@
</widget>
</item>

<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="libraryFontLabel">
<property name="text">
<string>Library Font:</string>
Expand All @@ -257,22 +284,22 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QLineEdit" name="libraryFont">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QToolButton" name="libraryFontButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>

<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="searchDebouncingTimeoutLabel">
<property name="text">
<string>Search-as-you-type timeout:</string>
Expand All @@ -282,7 +309,7 @@
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<item row="8" column="1" colspan="2">
<widget class="QSpinBox" name="searchDebouncingTimeoutSpinBox">
<property name="suffix">
<string> ms</string>
Expand Down Expand Up @@ -501,6 +528,7 @@
<tabstop>checkBox_SyncTrackMetadata</tabstop>
<tabstop>checkBox_SeratoMetadataExport</tabstop>
<tabstop>checkBox_library_scan</tabstop>
<tabstop>spinbox_history_recently_played_threshold</tabstop>
<tabstop>spinbox_min_history_tracks</tabstop>
<tabstop>checkBox_history_cleanup_keep_locked</tabstop>
<tabstop>checkBoxEditMetadataSelectedClicked</tabstop>
Expand Down

0 comments on commit 03ec672

Please sign in to comment.