From 2d0bbd3efbcfc313b61c043e69452fdf9ea6f915 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Tue, 10 Mar 2015 23:04:51 +0300 Subject: [PATCH] Limit recent files to 10 --- mainwindow.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4c5df36..6d9573e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -152,7 +152,7 @@ void MainWindow::open() if(!recentFiles.contains(filename)) { recentFiles.prepend(filename); - if(recentFiles.size() == 5) recentFiles.removeAt(5); + if(recentFiles.size() >= 10) recentFiles.removeLast(); } updateRecent(); @@ -638,17 +638,17 @@ void MainWindow::injectCommand(QString command) void MainWindow::updateRecent() { - if(!recentFiles.isEmpty()) + if(!recentFiles.isEmpty()) //If array is empty we should not be bothered { - recentMenu->clear(); + recentMenu->clear(); //Clear menu from previos actions foreach (QString str, recentFiles) { - if (!str.isEmpty()) + if (!str.isEmpty()) //Empty strings are not needed { QAction *action = new QAction(this); - action->setText(str); - action->setObjectName(str); - recentMenu->addAction(action); + action->setText(str); //Set filepath as a title + action->setObjectName(str); //Also set name to the path so we can get it later + recentMenu->addAction(action); //Add action to the menu connect(action, SIGNAL(triggered()), this, SLOT(recentClicked())); } }