Skip to content

Commit c75b513

Browse files
strukturedclaude
andcommitted
Add keyboard shortcuts and UI improvements
- N/P keys for next/previous preset navigation - H key to toggle playlist visibility independently - M key now only toggles menu bar (preserves window geometry) - Hide .milk extension from preset names in playlist - Fix menu toggle shrinking window (use QTimer to restore geometry) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7b300fa commit c75b513

2 files changed

Lines changed: 56 additions & 20 deletions

File tree

src/common/qplaylistmodel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ QVariant QPlaylistModel::data(const QModelIndex & index, int role) const
8787
// Return full path for URL info
8888
return path;
8989
}
90-
// For DisplayRole and NameRole, return just the filename (default behavior)
91-
return QFileInfo(path).fileName();
90+
// For DisplayRole and NameRole, return just the filename without .milk extension
91+
QString name = QFileInfo(path).fileName();
92+
if (name.endsWith(".milk", Qt::CaseInsensitive)) {
93+
name.chop(5); // Remove ".milk"
94+
}
95+
return name;
9296
}
9397
return QVariant();
9498
}

src/common/qprojectm_mainwindow.cpp

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -488,37 +488,27 @@ void QProjectM_MainWindow::readPlaylistSettings() {
488488
}
489489

490490
void QProjectM_MainWindow::setMenuVisible(bool visible) {
491+
// Save current geometry before toggling
492+
QRect currentGeometry = geometry();
491493

492-
493-
494+
// Toggle menu/status bars only
495+
// Playlist visibility is controlled independently via 'h' key
494496
if (visible) {
495-
// Don't resize - playlist stays visible, no need to resize
496-
// ui->dockWidgetContents->resize(_oldPlaylistSize);
497-
498-
ui->presetPlayListDockWidget->show();
499497
if (_menuAndStatusBarsVisible) {
500498
menuBar()->show();
501499
statusBar()->show();
502500
}
503-
else {
504-
menuBar()->hide();
505-
statusBar()->hide();
506-
}
507501
_menuVisible = true;
508502
} else {
509-
// Don't save size - playlist stays visible, no need to save/restore
510-
// _oldPlaylistSize = ui->dockWidgetContents->size();
511-
512-
// Don't hide the playlist - it causes window to shrink to tiny rectangle
513-
// Keep playlist visible even in fullscreen/menu-hidden mode
514-
// if (!ui->presetPlayListDockWidget->isFloating())
515-
// ui->presetPlayListDockWidget->hide();
516-
517503
menuBar()->hide();
518504
statusBar()->hide();
519505
_menuVisible = false;
520506
}
521507

508+
// Restore geometry after a brief delay to let Qt finish layout
509+
QTimer::singleShot(10, this, [this, currentGeometry]() {
510+
setGeometry(currentGeometry);
511+
});
522512
}
523513

524514
void QProjectM_MainWindow::changePresetAttribute ( const QModelIndex & index )
@@ -645,6 +635,48 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e )
645635
}
646636

647637
return;
638+
639+
case Qt::Key_N:
640+
// Next preset
641+
if (!(e->modifiers() & Qt::ControlModifier)) {
642+
if ( ui->presetSearchBarLineEdit->hasFocus() )
643+
return;
644+
if (ui->tableView->hasFocus())
645+
return;
646+
}
647+
if (playlistModel && playlistModel->playlistHandle()) {
648+
projectm_playlist_play_next(playlistModel->playlistHandle(), true);
649+
}
650+
return;
651+
652+
case Qt::Key_P:
653+
// Previous preset
654+
if (!(e->modifiers() & Qt::ControlModifier)) {
655+
if ( ui->presetSearchBarLineEdit->hasFocus() )
656+
return;
657+
if (ui->tableView->hasFocus())
658+
return;
659+
}
660+
if (playlistModel && playlistModel->playlistHandle()) {
661+
projectm_playlist_play_previous(playlistModel->playlistHandle(), true);
662+
}
663+
return;
664+
665+
case Qt::Key_H:
666+
// Toggle playlist visibility independently
667+
if (!(e->modifiers() & Qt::ControlModifier)) {
668+
if ( ui->presetSearchBarLineEdit->hasFocus() )
669+
return;
670+
if (ui->tableView->hasFocus())
671+
return;
672+
}
673+
if (ui->presetPlayListDockWidget->isVisible()) {
674+
ui->presetPlayListDockWidget->hide();
675+
} else {
676+
ui->presetPlayListDockWidget->show();
677+
}
678+
return;
679+
648680
default:
649681
break;
650682
}

0 commit comments

Comments
 (0)