diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2020-07-31 23:11:38 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-31 15:11:38 -0500 |
| commit | bab10ea14ddaf7af7aeeff925b373be1c347d0d7 (patch) | |
| tree | 74b43afcfe26fd6eb9a83511450184e24d036bca /src | |
| parent | 56d7fff50044ef72626ac40ccf13da1e34b5f0a1 (diff) | |
Add "Play Random Song" option (#200)
It also respects the search string, so only visible tracks are chosen from the pool. Categories (i.e. entries with children) are also ignored.
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index bc182a87..b203cf08 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4098,6 +4098,9 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { QMenu *menu = new QMenu(); + menu->addAction(QString(tr("Play Random Song")), this, + SLOT(music_random())); + menu->addSeparator(); menu->addAction(QString(tr("Expand All Categories")), this, SLOT(music_list_expand_all())); menu->addAction(QString(tr("Collapse All Categories")), this, @@ -4149,6 +4152,18 @@ void Courtroom::music_synchronize(bool toggle) music_flags &= ~SYNC_POS; } +void Courtroom::music_random() +{ + QList<QTreeWidgetItem *> clist; + QTreeWidgetItemIterator it(ui_music_list, QTreeWidgetItemIterator::NotHidden | QTreeWidgetItemIterator::NoChildren); + while (*it) { + clist += (*it); + ++it; + } + int i = qrand() % clist.length(); + on_music_list_double_clicked(clist.at(i), 1); +} + void Courtroom::music_list_expand_all() { ui_music_list->expandAll(); } void Courtroom::music_list_collapse_all() { |
