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: add keyboard short to open track properties Ctrl+Enter #4347

Merged
merged 3 commits into from
Oct 4, 2021
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
5 changes: 5 additions & 0 deletions src/util/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
constexpr unsigned int MAX_BUFFER_LEN = 160000;

constexpr int kMaxNumberOfDecks = 4;

// Keyboard shortcut components for showing the Track Properties dialog and
// for displaying the shortcut in the track context menu
const Qt::Modifier kPropertiesShortcutModifier = Qt::CTRL;
const Qt::Key kPropertiesShortcutKey = Qt::Key_Return;
8 changes: 8 additions & 0 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "preferences/colorpalettesettings.h"
#include "sources/soundsourceproxy.h"
#include "track/track.h"
#include "util/defs.h"
#include "util/desktophelper.h"
#include "util/parented_ptr.h"
#include "util/qt.h"
Expand Down Expand Up @@ -211,6 +212,13 @@ void WTrackMenu::createActions() {

if (featureIsEnabled(Feature::Properties)) {
m_pPropertiesAct = new QAction(tr("Properties"), this);
// This is just for having the shortcut displayed next to the action
// when the menu is invoked from the tracks table.
// The keypress is caught in WTrackTableView::keyPressEvent
if (m_pTrackModel) {
m_pPropertiesAct->setShortcut(
QKeySequence(kPropertiesShortcutModifier + kPropertiesShortcutKey));
}
connect(m_pPropertiesAct, &QAction::triggered, this, &WTrackMenu::slotShowDlgTrackInfo);
}

Expand Down
20 changes: 13 additions & 7 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "track/track.h"
#include "track/trackref.h"
#include "util/assert.h"
#include "util/defs.h"
#include "util/dnd.h"
#include "util/time.h"
#include "widget/wtrackmenu.h"
Expand Down Expand Up @@ -755,14 +756,19 @@ TrackModel* WTrackTableView::getTrackModel() const {
}

void WTrackTableView::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_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
return;
} else {
QTableView::keyPressEvent(event);
// Ctrl+Return opens track properties dialog.
// Ignore it if any cell editor is open.
// Note: the shortcut is displayed in the track context menu
if (event->key() == kPropertiesShortcutKey &&
(event->modifiers() & kPropertiesShortcutModifier) &&
state() != QTableView::EditingState) {
QModelIndexList indices = selectionModel()->selectedRows();
if (indices.length() == 1) {
m_pTrackMenu->loadTrackModelIndices(indices);
m_pTrackMenu->slotShowDlgTrackInfo();
}
}
QTableView::keyPressEvent(event);
}

void WTrackTableView::loadSelectedTrack() {
Expand Down