Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library table: allow to ignore Track double-click #3194

Merged
merged 3 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,9 @@ void LibraryControl::slotGoToItem(double v) {

// Focus the library if this is a leaf node in the tree
if (m_pSidebarWidget->hasFocus()) {
// ToDo can't expand Tracks and AutoDJ, always returns false for those root items
// Note that Tracks and AutoDJ always return 'false':
// expanding those root items via controllers is considered dispensable
// because the subfeatures' actions can't be accessed by controllers anyway.
if (m_pSidebarWidget->isLeafNodeSelected()) {
return setLibraryFocus();
} else {
Expand All @@ -636,8 +638,9 @@ void LibraryControl::slotGoToItem(double v) {
}

// Load current track if a LibraryView object has focus
if (m_pLibraryWidget->hasFocus()) {
return slotLoadSelectedIntoFirstStopped(v);
LibraryView* activeView = m_pLibraryWidget->getActiveView();
if (activeView && activeView->hasFocus()) {
return activeView->loadSelectedTrack();
}

// Clear the search if the searchbox has focus
Expand Down
28 changes: 17 additions & 11 deletions src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,17 @@ void DlgPrefLibrary::slotUpdate() {
ConfigKey("[Library]", "ShowSeratoLibrary"), true));

switch (m_pConfig->getValue<int>(
ConfigKey("[Library]","TrackLoadAction"), LOAD_TO_DECK)) {
case ADD_TO_AUTODJ_BOTTOM:
radioButton_dbclick_bottom->setChecked(true);
break;
case ADD_TO_AUTODJ_TOP:
radioButton_dbclick_top->setChecked(true);
break;
ConfigKey("[Library]", "TrackLoadAction"),
static_cast<int>(TrackDoubleClickAction::LoadToDeck))) {
case static_cast<int>(TrackDoubleClickAction::AddToAutoDJBottom):
radioButton_dbclick_bottom->setChecked(true);
break;
case static_cast<int>(TrackDoubleClickAction::AddToAutoDJTop):
radioButton_dbclick_top->setChecked(true);
break;
case static_cast<int>(TrackDoubleClickAction::Ignore):
radioButton_dbclick_ignore->setChecked(true);
break;
default:
radioButton_dbclick_deck->setChecked(true);
break;
Expand Down Expand Up @@ -331,11 +335,13 @@ void DlgPrefLibrary::slotApply() {
ConfigValue((int)checkBox_show_serato->isChecked()));
int dbclick_status;
if (radioButton_dbclick_bottom->isChecked()) {
dbclick_status = ADD_TO_AUTODJ_BOTTOM;
dbclick_status = static_cast<int>(TrackDoubleClickAction::AddToAutoDJBottom);
} else if (radioButton_dbclick_top->isChecked()) {
dbclick_status = ADD_TO_AUTODJ_TOP;
} else {
dbclick_status = LOAD_TO_DECK;
dbclick_status = static_cast<int>(TrackDoubleClickAction::AddToAutoDJTop);
} else if (radioButton_dbclick_deck->isChecked()) {
dbclick_status = static_cast<int>(TrackDoubleClickAction::LoadToDeck);
} else { // radioButton_dbclick_ignore
dbclick_status = static_cast<int>(TrackDoubleClickAction::Ignore);
}
m_pConfig->set(ConfigKey("[Library]","TrackLoadAction"),
ConfigValue(dbclick_status));
Expand Down
9 changes: 5 additions & 4 deletions src/preferences/dialog/dlgpreflibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
class DlgPrefLibrary : public DlgPreferencePage, public Ui::DlgPrefLibraryDlg {
Q_OBJECT
public:
enum TrackDoubleClickAction {
LOAD_TO_DECK,
ADD_TO_AUTODJ_BOTTOM,
ADD_TO_AUTODJ_TOP
enum class TrackDoubleClickAction : int {
LoadToDeck = 0,
AddToAutoDJBottom = 1,
AddToAutoDJTop = 2,
Ignore = 3,
};

DlgPrefLibrary(
Expand Down
16 changes: 12 additions & 4 deletions src/preferences/dialog/dlgpreflibrarydlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@
<string/>
</property>
<property name="title">
<string extracomment="Sets default action when double-clicking a track in the library.">Track Load Action</string>
<string extracomment="Sets default action when double-clicking a track in the library.">Track Double-Click Action</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="gridLayout_dblick">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_dbclick_deck">
<property name="text">
Expand All @@ -260,14 +260,21 @@
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_dbclick_bottom">
<property name="text">
<string>Add track to Auto DJ Queue (bottom)</string>
<string>Add track to Auto DJ queue (bottom)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioButton_dbclick_top">
<property name="text">
<string>Add track to Auto DJ Queue (top)</string>
<string>Add track to Auto DJ queue (top)</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="radioButton_dbclick_ignore">
<property name="text">
<string>Ignore</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -396,6 +403,7 @@
<tabstop>radioButton_dbclick_deck</tabstop>
<tabstop>radioButton_dbclick_bottom</tabstop>
<tabstop>radioButton_dbclick_top</tabstop>
<tabstop>radioButton_dbclick_ignore</tabstop>
<tabstop>checkBox_show_rhythmbox</tabstop>
<tabstop>checkBox_show_banshee</tabstop>
<tabstop>checkBox_show_itunes</tabstop>
Expand Down
12 changes: 8 additions & 4 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,28 +335,32 @@ void WTrackTableView::slotMouseDoubleClicked(const QModelIndex& index) {
// Read the current TrackLoadAction settings
int doubleClickActionConfigValue =
m_pConfig->getValue(ConfigKey("[Library]", "TrackLoadAction"),
static_cast<int>(DlgPrefLibrary::LOAD_TO_DECK));
static_cast<int>(DlgPrefLibrary::TrackDoubleClickAction::LoadToDeck));
DlgPrefLibrary::TrackDoubleClickAction doubleClickAction =
static_cast<DlgPrefLibrary::TrackDoubleClickAction>(
doubleClickActionConfigValue);

if (doubleClickAction == DlgPrefLibrary::TrackDoubleClickAction::Ignore) {
return;
}

auto trackModel = getTrackModel();
VERIFY_OR_DEBUG_ASSERT(trackModel) {
return;
}

if (doubleClickAction == DlgPrefLibrary::LOAD_TO_DECK &&
if (doubleClickAction == DlgPrefLibrary::TrackDoubleClickAction::LoadToDeck &&
trackModel->hasCapabilities(
TrackModel::TRACKMODELCAPS_LOADTODECK)) {
TrackPointer pTrack = trackModel->getTrack(index);
if (pTrack) {
emit loadTrack(pTrack);
}
} else if (doubleClickAction == DlgPrefLibrary::ADD_TO_AUTODJ_BOTTOM &&
} else if (doubleClickAction == DlgPrefLibrary::TrackDoubleClickAction::AddToAutoDJBottom &&
trackModel->hasCapabilities(
TrackModel::TRACKMODELCAPS_ADDTOAUTODJ)) {
addToAutoDJ(PlaylistDAO::AutoDJSendLoc::BOTTOM);
} else if (doubleClickAction == DlgPrefLibrary::ADD_TO_AUTODJ_TOP &&
} else if (doubleClickAction == DlgPrefLibrary::TrackDoubleClickAction::AddToAutoDJTop &&
trackModel->hasCapabilities(
TrackModel::TRACKMODELCAPS_ADDTOAUTODJ)) {
addToAutoDJ(PlaylistDAO::AutoDJSendLoc::TOP);
Expand Down