]> git.sesse.net Git - nageru/commitdiff
Support the delete key to remove elements from the playlist.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Sep 2018 10:27:08 +0000 (12:27 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Sep 2018 10:27:08 +0000 (12:27 +0200)
mainwindow.cpp

index febcacf950bd7d7004fab030de5ae85c675c84d8..f0a0341b89c0a758e0d61d325ac70a566d3b32eb 100644 (file)
@@ -84,8 +84,13 @@ MainWindow::MainWindow()
 
        connect(ui->playlist_duplicate_btn, &QPushButton::clicked, this, &MainWindow::playlist_duplicate);
 
-       // TODO: support the delete key iff the widget has focus?
        connect(ui->playlist_remove_btn, &QPushButton::clicked, this, &MainWindow::playlist_remove);
+       QShortcut *delete_key = new QShortcut(QKeySequence(Qt::Key_Delete), ui->playlist);
+       connect(delete_key, &QShortcut::activated, [this] {
+               if (ui->playlist->hasFocus()) {
+                       playlist_remove();
+               }
+       });
 
        // TODO: support drag-and-drop.
        connect(ui->playlist_move_up_btn, &QPushButton::clicked, [this]{ playlist_move(-1); });