UI: Fix crash when pressing tab
key in rename
This commit is contained in:
parent
40a2cc0143
commit
34e346a011
@ -7,6 +7,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
|
||||
VisibilityItemWidget::VisibilityItemWidget(obs_source_t *source_)
|
||||
: source(source_),
|
||||
@ -144,6 +145,24 @@ void VisibilityItemDelegate::paint(QPainter *painter,
|
||||
widget->SetColor(palette.color(group, role), active, selected);
|
||||
}
|
||||
|
||||
bool VisibilityItemDelegate::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
QWidget *editor = qobject_cast<QWidget *>(object);
|
||||
if (!editor)
|
||||
return false;
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
||||
if (keyEvent->key() == Qt::Key_Tab ||
|
||||
keyEvent->key() == Qt::Key_Backtab) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return QStyledItemDelegate::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void SetupVisibilityItem(QListWidget *list, QListWidgetItem *item,
|
||||
obs_source_t *source)
|
||||
{
|
||||
|
@ -47,6 +47,9 @@ public:
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
};
|
||||
|
||||
void SetupVisibilityItem(QListWidget *list, QListWidgetItem *item,
|
||||
|
Loading…
x
Reference in New Issue
Block a user