GUI: allow delete key to remove entries from string list configuration widgets

See #3585
This commit is contained in:
Moritz Bunkus 2023-07-16 13:48:53 +02:00
parent 5adb6c7cd6
commit d9372061ec
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,9 @@
properties has been changed: the old element is now titled "Language
(obsolete)" & the current, IETF BCP 47 based one is simply called
"Language".
* MKVToolNix GUI: preferences: you can now use the "delete" key to remove
entries from simple list widgets for strings (e.g. the list of recently used
destination directories).
## Bug fixes

View File

@ -2,6 +2,8 @@
#include <QDir>
#include <QInputDialog>
#include <QKeyEvent>
#include <QKeySequence>
#include <QListWidget>
#include <QPushButton>
#include <QRegularExpression>
@ -35,6 +37,8 @@ StringListConfigurationWidget::StringListConfigurationWidget(QWidget *parent)
p->ui->pbRemoveItem->setEnabled(false);
p->ui->lwItems->installEventFilter(this);
setupConnections();
}
@ -161,4 +165,19 @@ StringListConfigurationWidget::setItemType(ItemType itemType) {
p_func()->itemType = itemType;
}
bool
StringListConfigurationWidget::eventFilter(QObject *o,
QEvent *e) {
auto p = p_func();
if ( (o == p->ui->lwItems)
&& (e->type() == QEvent::KeyPress)
&& (static_cast<QKeyEvent *>(e)->matches(QKeySequence::Delete))) {
removeSelectedItems();
return true;
}
return QWidget::eventFilter(o, e);
}
}

View File

@ -2,6 +2,7 @@
#include "common/common_pch.h"
#include <QEvent>
#include <QList>
#include <QStringList>
#include <QWidget>
@ -47,6 +48,8 @@ public:
void addItem(QString const &name);
virtual bool eventFilter(QObject *o, QEvent *e) override;
public Q_SLOTS:
void enableControls();