Allow to use enter/return key within list widgets to navigate (#200)

This commit is contained in:
p-state 2020-03-12 20:38:22 +03:00 committed by GitHub
parent ac1f24ec77
commit 07dbfa3f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 18 deletions

View File

@ -160,6 +160,11 @@ void UEFITool::init()
connect(ui->builderMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->fitTableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(scrollTreeView(QTableWidgetItem*)));
connect(ui->messagesTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
// allow enter/return pressing to scroll tree view
ui->parserMessagesListWidget->installEventFilter(this);
ui->finderMessagesListWidget->installEventFilter(this);
ui->builderMessagesListWidget->installEventFilter(this);
}
void UEFITool::populateUi(const QItemSelection &selected)
@ -747,6 +752,23 @@ void UEFITool::toggleBootGuardMarking(bool enabled)
markingEnabled = enabled;
}
/* emit double click signal of QListWidget on enter/return key pressed */
bool UEFITool::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent* key = static_cast<QKeyEvent*>(event);
if (key->key() == Qt::Key_Enter || key->key() == Qt::Key_Return) {
QListWidget* list = qobject_cast<QListWidget*>(obj);
if (list != NULL && list->currentItem() != NULL)
emit list->itemDoubleClicked(list->currentItem());
}
}
return QObject::eventFilter(obj, event);
}
void UEFITool::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasFormat("text/uri-list"))

View File

@ -146,6 +146,7 @@ private:
bool enableExtractBodyUncompressed(const QModelIndex &current);
bool eventFilter(QObject* obj, QEvent* event);
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
void contextMenuEvent(QContextMenuEvent* event);