diff --git a/src/qdbus/qdbusviewer/qdbusviewer.cpp b/src/qdbus/qdbusviewer/qdbusviewer.cpp index c96df0730d0264dd4ea6cc9a8e2c018765ad27ff..806cbc8ae6941239732dd794ff5c010a9458e7dd 100644 --- a/src/qdbus/qdbusviewer/qdbusviewer.cpp +++ b/src/qdbus/qdbusviewer/qdbusviewer.cpp @@ -36,6 +36,7 @@ #include <QtCore/QStringListModel> #include <QtCore/QMetaProperty> #include <QtCore/QSettings> +#include <QtGui/QKeyEvent> #include <QtWidgets/QLineEdit> #include <QtWidgets/QAction> #include <QtWidgets/QShortcut> @@ -87,6 +88,7 @@ QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent) : servicesProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); servicesView = new QTableView(this); + servicesView->installEventFilter(this); servicesView->setModel(servicesProxyModel); // Make services grid view behave like a list view with headers servicesView->verticalHeader()->hide(); @@ -176,6 +178,21 @@ void QDBusViewer::showEvent(QShowEvent *) serviceFilterLine->setFocus(); } +bool QDBusViewer::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == servicesView) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); + if (keyEvent->modifiers() == Qt::NoModifier) { + if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { + tree->setFocus(); + } + } + } + } + return false; +} + void QDBusViewer::logError(const QString &msg) { log->append(QLatin1String("<font color=\"red\">Error: </font>") + msg.toHtmlEscaped() + QLatin1String("<br>")); diff --git a/src/qdbus/qdbusviewer/qdbusviewer.h b/src/qdbus/qdbusviewer/qdbusviewer.h index 4ca9c7cbb9b426bc8f7b260cf53bea699dee7377..34002f8ff403d4b49e4073f3ddb37b2bc4965aee 100644 --- a/src/qdbus/qdbusviewer/qdbusviewer.h +++ b/src/qdbus/qdbusviewer/qdbusviewer.h @@ -87,6 +87,7 @@ private slots: private: void logMessage(const QString &msg); void showEvent(QShowEvent *) override; + bool eventFilter(QObject *obj, QEvent *event) override; QDBusConnection c; QString currentService;