From e6dd4055a226d31ecb29bc0746bb896e6ff7ff66 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 22 Sep 2018 12:27:08 +0200 Subject: [PATCH] Support the delete key to remove elements from the playlist. --- mainwindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index febcacf..f0a0341 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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); }); -- 2.39.2