From: Steinar H. Gunderson Date: Sat, 22 Sep 2018 10:27:08 +0000 (+0200) Subject: Support the delete key to remove elements from the playlist. X-Git-Tag: 1.8.0~76^2~96 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e6dd4055a226d31ecb29bc0746bb896e6ff7ff66;p=nageru Support the delete key to remove elements from the playlist. --- 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); });