diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-08-19 22:04:03 +0200 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-08-19 22:04:03 +0200 |
commit | 08325e51e58eb48230e87b60ff1a4768f7b9aa10 (patch) | |
tree | 80e41b374dc17b311c40055a4eb90c19928ca5b4 /src | |
parent | Merge pull request #996 from yuriks/texture-copy (diff) | |
parent | Improvements for MRU (diff) | |
download | yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar.gz yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar.bz2 yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar.lz yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar.xz yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.tar.zst yuzu-08325e51e58eb48230e87b60ff1a4768f7b9aa10.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/citra_qt/main.cpp | 26 | ||||
-rw-r--r-- | src/citra_qt/main.h | 18 |
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() { render_window->hide(); } +void GMainWindow::StoreRecentFile(const QString& filename) +{ + QSettings settings; + QStringList recent_files = settings.value("recentFiles").toStringList(); + recent_files.prepend(filename); + recent_files.removeDuplicates(); + settings.setValue("recentFiles", recent_files); + + UpdateRecentFiles(); +} + void GMainWindow::UpdateRecentFiles() { QSettings settings; QStringList recent_files = settings.value("recentFiles").toStringList(); @@ -297,6 +308,7 @@ void GMainWindow::UpdateRecentFiles() { QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName()); actions_recent_files[i]->setText(text); actions_recent_files[i]->setData(recent_files[i]); + actions_recent_files[i]->setToolTip(recent_files[i]); actions_recent_files[i]->setVisible(true); } @@ -319,11 +331,7 @@ void GMainWindow::OnMenuLoadFile() { QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); if (filename.size()) { settings.setValue("romsPath", QFileInfo(filename).path()); - // Update recent files list - QStringList recent_files = settings.value("recentFiles").toStringList(); - recent_files.prepend(filename); - settings.setValue("recentFiles", recent_files); - UpdateRecentFiles(); // Update UI + StoreRecentFile(filename); BootGame(filename.toLatin1().data()); } @@ -349,6 +357,7 @@ void GMainWindow::OnMenuRecentFile() { QFileInfo file_info(filename); if (file_info.exists()) { BootGame(filename.toLatin1().data()); + StoreRecentFile(filename); // Put the filename on top of the list } else { // Display an error message and remove the file from the list. QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); @@ -357,12 +366,7 @@ void GMainWindow::OnMenuRecentFile() { QStringList recent_files = settings.value("recentFiles").toStringList(); recent_files.removeOne(filename); settings.setValue("recentFiles", recent_files); - - action->setVisible(false); - // Grey out the recent files menu if the list is empty - if (ui.menu_recent_files->isEmpty()) { - ui.menu_recent_files->setEnabled(false); - } + UpdateRecentFiles(); } } 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: void BootGame(const std::string& filename); void ShutdownGame(); + /** + * Stores the filename in the recently loaded files list. + * The new filename is stored at the beginning of the recently loaded files list. + * After inserting the new entry, duplicates are removed meaning that if + * this was inserted from \a OnMenuRecentFile(), the entry will be put on top + * and remove from its previous position. + * + * Finally, this function calls \a UpdateRecentFiles() to update the UI. + * + * @param filename the filename to store + */ + void StoreRecentFile(const QString& filename); + + /** + * Updates the recent files menu. + * Menu entries are rebuilt from the configuration file. + * If there is no entry in the menu, the menu is greyed out. + */ void UpdateRecentFiles(); void closeEvent(QCloseEvent* event) override; |