Skip to content

Commit

Permalink
Library: Enter triggers mouse double click action...
Browse files Browse the repository at this point in the history
if no cell is in edit mode.
  • Loading branch information
ronso0 committed Oct 3, 2021
1 parent a2e5373 commit c859196
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgpreflibrarydlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
<string/>
</property>
<property name="title">
<string extracomment="Sets default action when double-clicking a track in the library.">Track Double-Click Action</string>
<string extracomment="Sets default action when double-clicking on a track in the library or pressing Return.">Track Double-Click / Return Key Action</string>
</property>
<layout class="QGridLayout" name="gridLayout_dblick">
<item row="0" column="0">
Expand Down
17 changes: 10 additions & 7 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,25 @@ TrackModel* WTrackTableView::getTrackModel() const {
}

void WTrackTableView::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Return) {
// Ctrl+Enter opens track properties dialog
// If Ignore all Enter combos if any cell editor is open
if (event->key() == Qt::Key_Return &&
state() != QTableView::EditingState) {
// Ctrl+Return opens track properties dialog.
// The shortcut display string needs to be set in WTrackMenu accordingly.
if (event->modifiers() & Qt::ControlModifier) {
QModelIndexList indices = selectionModel()->selectedRows();
if (indices.length() == 1) {
m_pTrackMenu->loadTrackModelIndices(indices);
m_pTrackMenu->slotShowDlgTrackInfo();
return;
}
} else if (!event->modifiers()) {
// Return alone triggers the double-click action.
slotMouseDoubleClicked(this->currentIndex());
return;
}
// It is not a good idea if 'key_return'
// causes a track to load since we allow in-line editing
// of table items in general
} else {
QTableView::keyPressEvent(event);
}
QTableView::keyPressEvent(event);
}

void WTrackTableView::loadSelectedTrack() {
Expand Down

0 comments on commit c859196

Please sign in to comment.