forked from qt-creator/qt-creator
Welcome: Added keyboard hotkeys to open sessions and recent projects
Change-Id: Ia7c1ec11b2fa3e4b61b842fd1e9e4df7aa6f7be3 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -1056,15 +1056,21 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
QMenu *menu = aci->menu();
|
||||
menu->clear();
|
||||
|
||||
bool hasRecentFiles = false;
|
||||
foreach (const DocumentManager::RecentFile &file, DocumentManager::recentFiles()) {
|
||||
hasRecentFiles = true;
|
||||
QAction *action = menu->addAction(
|
||||
QDir::toNativeSeparators(Utils::withTildeHomePath(file.first)));
|
||||
const QList<DocumentManager::RecentFile> recentFiles = DocumentManager::recentFiles();
|
||||
for (int i = 0; i < recentFiles.count(); ++i) {
|
||||
const DocumentManager::RecentFile file = recentFiles[i];
|
||||
|
||||
int acceleratorKey = i + 1;
|
||||
QString textPattern = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
||||
QString filePath = QDir::toNativeSeparators(withTildeHomePath(file.first));
|
||||
QString actionText = textPattern.arg(acceleratorKey).arg(filePath);
|
||||
QAction *action = menu->addAction(actionText);
|
||||
connect(action, &QAction::triggered, this, [file] {
|
||||
EditorManager::openEditor(file.first, file.second);
|
||||
});
|
||||
}
|
||||
|
||||
bool hasRecentFiles = !recentFiles.isEmpty();
|
||||
menu->setEnabled(hasRecentFiles);
|
||||
|
||||
// add the Clear Menu item
|
||||
|
||||
Reference in New Issue
Block a user