Browse Source

applauncherwidget: enter key to launch current/first shown app (#3331)

* applauncherwidget: enter key to launch current/first shown app

* fix clang formatting
d-a-s 1 year ago
parent
commit
1d276a2cd3
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/tools/launcher/applauncherwidget.cpp

+ 11 - 0
src/tools/launcher/applauncherwidget.cpp

@@ -305,6 +305,17 @@ void AppLauncherWidget::keyPressEvent(QKeyEvent* keyEvent)
 {
     if (keyEvent->key() == Qt::Key_Escape) {
         close();
+    } else if (keyEvent->key() == Qt::Key_Return) {
+        auto* widget = (QListWidget*)m_tabWidget->currentWidget();
+        if (m_filterList->isVisible())
+            widget = m_filterList;
+        auto* item = widget->currentItem();
+        if (item == nullptr) {
+            item = widget->item(0);
+            widget->setCurrentItem(item);
+        }
+        QModelIndex const idx = widget->currentIndex();
+        AppLauncherWidget::launch(idx);
     } else {
         QWidget::keyPressEvent(keyEvent);
     }