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

Usability/Keyboard: Add a rebindable keyboard shortcut for editing items as a replacement for F2 #13148

Merged
merged 6 commits into from
Feb 12, 2025
3 changes: 3 additions & 0 deletions res/keyboard/cs_CZ.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+\

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/da_DK.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/de_CH.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/de_DE.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/el_GR.kbd.cfg
Original file line number Diff line number Diff line change
@@ -168,3 +168,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+`

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/en_US.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+`

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/es_ES.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/fi_FI.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/fr_CH.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/fr_FR.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+`

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/it_IT.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+<

[Library]
EditItem r
3 changes: 3 additions & 0 deletions res/keyboard/ru_RU.kbd.cfg
Original file line number Diff line number Diff line change
@@ -163,3 +163,6 @@ OptionsMenu_DeveloperStatsExperiment Ctrl+Shift+E
OptionsMenu_DeveloperStatsBase Ctrl+Shift+B
DeveloperMenu_EnableDebugger Ctrl+Shift+D
OptionsMenu_EnableShortcuts Ctrl+|

[Library]
EditItem r
35 changes: 35 additions & 0 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
@@ -257,6 +257,18 @@ LibraryControl::LibraryControl(Library* pLibrary)
&LibraryControl::refocusPrevLibraryWidget);
}

// Control to "edit" the currently selected item/field in focused widget (context dependent)
m_pEditItem = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "EditItem"));
#ifdef MIXXX_USE_QML
if (!CmdlineArgs::Instance().isQml())
#endif
{
connect(m_pEditItem.get(),
&ControlPushButton::valueChanged,
this,
&LibraryControl::slotEditItem);
}

// Control to "goto" the currently selected item in focused widget (context dependent)
m_pGoToItem = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "GoToItem"));
#ifdef MIXXX_USE_QML
@@ -1046,6 +1058,29 @@ void LibraryControl::slotToggleSelectedSidebarItem(double v) {
}
}

void LibraryControl::slotEditItem(double v) {
if (v <= 0) {
return;
}

switch (m_focusedWidget) {
case FocusWidget::Sidebar: {
m_pSidebarWidget->renameSelectedItem();
break;
}
case FocusWidget::TracksTable: {
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->editSelectedItem();
}
break;
}
default: {
break;
}
}
}

void LibraryControl::slotGoToItem(double v) {
if (v <= 0) {
return;
4 changes: 4 additions & 0 deletions src/library/librarycontrol.h
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ class LibraryControl : public QObject {
void slotMoveTrackUp(double);
void slotMoveTrackDown(double);
void slotMoveTrack(double);
void slotEditItem(double);
void slotGoToItem(double v);

void slotTrackColorPrev(double v);
@@ -168,6 +169,9 @@ class LibraryControl : public QObject {
std::unique_ptr<ControlPushButton> m_pMoveTrackDown;
std::unique_ptr<ControlEncoder> m_pMoveTrack;

// Control to edit the currently selected item/field in focused widget
std::unique_ptr<ControlObject> m_pEditItem;

// Control to choose the currently selected item in focused widget (double click)
std::unique_ptr<ControlObject> m_pGoToItem;

1 change: 0 additions & 1 deletion src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
@@ -76,7 +76,6 @@ void BasePlaylistFeature::initActions() {
&BasePlaylistFeature::slotCreatePlaylist);

m_pRenamePlaylistAction = new QAction(tr("Rename"), this);
m_pRenamePlaylistAction->setShortcut(kRenameSidebarItemShortcutKey);
connect(m_pRenamePlaylistAction,
&QAction::triggered,
this,
1 change: 0 additions & 1 deletion src/library/trackset/crate/cratefeature.cpp
Original file line number Diff line number Diff line change
@@ -69,7 +69,6 @@ void CrateFeature::initActions() {
&CrateFeature::slotCreateCrate);

m_pRenameCrateAction = make_parented<QAction>(tr("Rename"), this);
m_pRenameCrateAction->setShortcut(kRenameSidebarItemShortcutKey);
connect(m_pRenameCrateAction.get(),
&QAction::triggered,
this,
21 changes: 11 additions & 10 deletions src/widget/wlibrarysidebar.cpp
Original file line number Diff line number Diff line change
@@ -178,6 +178,16 @@ void WLibrarySidebar::dropEvent(QDropEvent * event) {
}
}

void WLibrarySidebar::renameSelectedItem() {
// Rename crate or playlist (internal, external, history)
QModelIndex selIndex = selectedIndex();
if (!selIndex.isValid()) {
return;
}
emit renameItem(selIndex);
return;
}

void WLibrarySidebar::toggleSelectedItem() {
QModelIndex index = selectedIndex();
if (index.isValid()) {
@@ -307,16 +317,7 @@ void WLibrarySidebar::keyPressEvent(QKeyEvent* event) {
emit setLibraryFocus(FocusWidget::TracksTable);
return;
case kRenameSidebarItemShortcutKey: { // F2
// Rename crate or playlist (internal, external, history)
QModelIndex selIndex = selectedIndex();
if (!selIndex.isValid()) {
return;
}
if (isExpanded(selIndex)) {
// Root views / knots can not be renamed
return;
}
emit renameItem(selIndex);
renameSelectedItem();
return;
}
case kHideRemoveShortcutKey: { // Del (macOS: Cmd+Backspace)
1 change: 1 addition & 0 deletions src/widget/wlibrarysidebar.h
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class WLibrarySidebar : public QTreeView, public WBaseWidget {
void focusInEvent(QFocusEvent* event) override;
void timerEvent(QTimerEvent* event) override;
void toggleSelectedItem();
void renameSelectedItem();
bool isLeafNodeSelected();
bool isChildIndexSelected(const QModelIndex& index);
bool isFeatureRootIndexSelected(LibraryFeature* pFeature);
8 changes: 8 additions & 0 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
@@ -1297,6 +1297,14 @@ void WTrackTableView::hideOrRemoveSelectedTracks() {
restoreCurrentIndex();
}

/// If applicable, requests that the selected field/item be edited
/// Does nothing otherwise.
void WTrackTableView::editSelectedItem() {
if (state() != EditingState) {
edit(currentIndex(), EditKeyPressed, nullptr);
}
}

void WTrackTableView::activateSelectedTrack() {
const QModelIndexList indices = getSelectedRows();
if (indices.isEmpty()) {
1 change: 1 addition & 0 deletions src/widget/wtracktableview.h
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ class WTrackTableView : public WLibraryTableView {
void pasteFromSidebar() override;
void keyPressEvent(QKeyEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void editSelectedItem();
void activateSelectedTrack();
#ifdef __STEM__
void loadSelectedTrackToGroup(const QString& group,

Unchanged files with check annotations Beta

// from m_pMarkNodesParent and store each with their mark
// (transferring ownership). Later in this function we move the
// visible nodes back to m_pMarkNodesParent children.
while (auto pChild = m_pMarkNodesParent->firstChild()) {

Check warning on line 228 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pChild' can be declared as 'auto *pChild' [readability-qualified-auto]
auto pNode = m_pMarkNodesParent->detachChildNode(pChild);
WaveformMarkNode* pWaveformMarkNode = static_cast<WaveformMarkNode*>(pNode.get());
// Determine its WaveformMark
auto pMark = pWaveformMarkNode->m_pOwner;

Check warning on line 232 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pMark' can be declared as 'auto *pMark' [readability-qualified-auto]
auto pGraphics = static_cast<WaveformMarkNodeGraphics*>(pMark->m_pGraphics.get());

Check warning on line 233 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pGraphics' can be declared as 'auto *pGraphics' [readability-qualified-auto]
// Store the node with the WaveformMark
pGraphics->attachNode(std::move(pNode));
}
continue;
}
auto pMarkGraphics = pMark->m_pGraphics.get();

Check warning on line 275 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pMarkGraphics' can be declared as 'auto *pMarkGraphics' [readability-qualified-auto]
auto pMarkNodeGraphics = static_cast<WaveformMarkNodeGraphics*>(pMarkGraphics);

Check warning on line 276 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pMarkNodeGraphics' can be declared as 'auto *pMarkNodeGraphics' [readability-qualified-auto]
if (!pMarkGraphics) // is this even possible?

Check warning on line 277 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

statement should be inside braces [readability-braces-around-statements]
continue;
const float currentMarkPos = static_cast<float>(
pMark->generateImage(
m_waveformRenderer->getDevicePixelRatio()));
} else {
auto pGraphics = static_cast<WaveformMarkNodeGraphics*>(pMark->m_pGraphics.get());

Check warning on line 529 in src/waveform/renderers/allshader/waveformrendermark.cpp

GitHub Actions / clang-tidy

'auto pGraphics' can be declared as 'auto *pGraphics' [readability-qualified-auto]
pGraphics->updateTexture(m_waveformRenderer->getContext(),
pMark->generateImage(
m_waveformRenderer->getDevicePixelRatio()));