Skip to content

Commit

Permalink
Merge pull request #2696 from hacksdump/load-track
Browse files Browse the repository at this point in the history
WTrackTableView: bring back load track overrides
  • Loading branch information
uklotzde authored Apr 22, 2020
2 parents 9f92b22 + 9a833dc commit 6f4fc0b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,37 @@ void WTrackTableView::keyPressEvent(QKeyEvent* event) {
}
}

void WTrackTableView::loadSelectedTrack() {
auto indices = selectionModel()->selectedRows();
if (indices.size() > 0) {
slotMouseDoubleClicked(indices.at(0));
}
}

void WTrackTableView::loadSelectedTrackToGroup(QString group, bool play) {
auto indices = selectionModel()->selectedRows();
if (indices.size() > 0) {
// If the track load override is disabled, check to see if a track is
// playing before trying to load it
if (!(m_pConfig->getValueString(
ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck"))
.toInt())) {
// TODO(XXX): Check for other than just the first preview deck.
if (group != "[PreviewDeck1]" &&
ControlObject::get(ConfigKey(group, "play")) > 0.0) {
return;
}
}
auto index = indices.at(0);
auto trackModel = getTrackModel();
TrackPointer pTrack;
if (trackModel &&
(pTrack = trackModel->getTrack(index))) {
emit loadTrackToPlayer(pTrack, group, play);
}
}
}

QList<TrackId> WTrackTableView::getSelectedTrackIds() const {
QList<TrackId> trackIds;

Expand Down
2 changes: 2 additions & 0 deletions src/widget/wtracktableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class WTrackTableView : public WLibraryTableView {
void onShow() override;
bool hasFocus() const override;
void keyPressEvent(QKeyEvent* event) override;
void loadSelectedTrack() override;
void loadSelectedTrackToGroup(QString group, bool play) override;
void assignNextTrackColor() override;
void assignPreviousTrackColor() override;
QList<TrackId> getSelectedTrackIds() const;
Expand Down

0 comments on commit 6f4fc0b

Please sign in to comment.