From d923c5dfe7c58069646b8a581bb53af96d07db83 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 21 Dec 2015 01:08:40 +0100 Subject: [PATCH] Add keyboard shortcuts for recently opened files actions See issue #432. --- src/MainWindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 557dcd8d..3bcd0a44 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1164,6 +1164,11 @@ void MainWindow::updateRecentFileActions() recentFileActs[i]->setText(text); recentFileActs[i]->setData(files[i]); recentFileActs[i]->setVisible(true); + + // Add shortcut for opening the file using the keyboard. However, if the application is configured to store + // more than nine recently opened files don't set shortcuts for the later ones which wouldn't be single digit anymore. + if(i < 9) + recentFileActs[i]->setShortcut(QKeySequence(Qt::CTRL + (Qt::Key_1+i))); } for (int j = numRecentFiles; j < MaxRecentFiles; ++j) recentFileActs[j]->setVisible(false);