summaryrefslogtreecommitdiff
path: root/src/citra_qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt')
-rw-r--r--src/citra_qt/main.cpp26
-rw-r--r--src/citra_qt/main.h18
2 files changed, 33 insertions, 11 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index a1a4865bd..8bf2a3e13 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -287,6 +287,17 @@ void GMainWindow::ShutdownGame() {
287 render_window->hide(); 287 render_window->hide();
288} 288}
289 289
290void GMainWindow::StoreRecentFile(const QString& filename)
291{
292 QSettings settings;
293 QStringList recent_files = settings.value("recentFiles").toStringList();
294 recent_files.prepend(filename);
295 recent_files.removeDuplicates();
296 settings.setValue("recentFiles", recent_files);
297
298 UpdateRecentFiles();
299}
300
290void GMainWindow::UpdateRecentFiles() { 301void GMainWindow::UpdateRecentFiles() {
291 QSettings settings; 302 QSettings settings;
292 QStringList recent_files = settings.value("recentFiles").toStringList(); 303 QStringList recent_files = settings.value("recentFiles").toStringList();
@@ -297,6 +308,7 @@ void GMainWindow::UpdateRecentFiles() {
297 QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName()); 308 QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName());
298 actions_recent_files[i]->setText(text); 309 actions_recent_files[i]->setText(text);
299 actions_recent_files[i]->setData(recent_files[i]); 310 actions_recent_files[i]->setData(recent_files[i]);
311 actions_recent_files[i]->setToolTip(recent_files[i]);
300 actions_recent_files[i]->setVisible(true); 312 actions_recent_files[i]->setVisible(true);
301 } 313 }
302 314
@@ -319,11 +331,7 @@ void GMainWindow::OnMenuLoadFile() {
319 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); 331 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
320 if (filename.size()) { 332 if (filename.size()) {
321 settings.setValue("romsPath", QFileInfo(filename).path()); 333 settings.setValue("romsPath", QFileInfo(filename).path());
322 // Update recent files list 334 StoreRecentFile(filename);
323 QStringList recent_files = settings.value("recentFiles").toStringList();
324 recent_files.prepend(filename);
325 settings.setValue("recentFiles", recent_files);
326 UpdateRecentFiles(); // Update UI
327 335
328 BootGame(filename.toLatin1().data()); 336 BootGame(filename.toLatin1().data());
329 } 337 }
@@ -349,6 +357,7 @@ void GMainWindow::OnMenuRecentFile() {
349 QFileInfo file_info(filename); 357 QFileInfo file_info(filename);
350 if (file_info.exists()) { 358 if (file_info.exists()) {
351 BootGame(filename.toLatin1().data()); 359 BootGame(filename.toLatin1().data());
360 StoreRecentFile(filename); // Put the filename on top of the list
352 } else { 361 } else {
353 // Display an error message and remove the file from the list. 362 // Display an error message and remove the file from the list.
354 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); 363 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename));
@@ -357,12 +366,7 @@ void GMainWindow::OnMenuRecentFile() {
357 QStringList recent_files = settings.value("recentFiles").toStringList(); 366 QStringList recent_files = settings.value("recentFiles").toStringList();
358 recent_files.removeOne(filename); 367 recent_files.removeOne(filename);
359 settings.setValue("recentFiles", recent_files); 368 settings.setValue("recentFiles", recent_files);
360 369 UpdateRecentFiles();
361 action->setVisible(false);
362 // Grey out the recent files menu if the list is empty
363 if (ui.menu_recent_files->isEmpty()) {
364 ui.menu_recent_files->setEnabled(false);
365 }
366 } 370 }
367} 371}
368 372
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index 4b260ae8b..6f1292295 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -60,6 +60,24 @@ private:
60 void BootGame(const std::string& filename); 60 void BootGame(const std::string& filename);
61 void ShutdownGame(); 61 void ShutdownGame();
62 62
63 /**
64 * Stores the filename in the recently loaded files list.
65 * The new filename is stored at the beginning of the recently loaded files list.
66 * After inserting the new entry, duplicates are removed meaning that if
67 * this was inserted from \a OnMenuRecentFile(), the entry will be put on top
68 * and remove from its previous position.
69 *
70 * Finally, this function calls \a UpdateRecentFiles() to update the UI.
71 *
72 * @param filename the filename to store
73 */
74 void StoreRecentFile(const QString& filename);
75
76 /**
77 * Updates the recent files menu.
78 * Menu entries are rebuilt from the configuration file.
79 * If there is no entry in the menu, the menu is greyed out.
80 */
63 void UpdateRecentFiles(); 81 void UpdateRecentFiles();
64 82
65 void closeEvent(QCloseEvent* event) override; 83 void closeEvent(QCloseEvent* event) override;