@@ -53,6 +53,11 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
5353
5454 // Create and bind actions for them
5555 auto loadGameAction = fileMenu->addAction (tr (" Load game" ));
56+
57+ recentsMenu = fileMenu->addMenu (tr (" Recents" ));
58+ updateRecentsMenu ();
59+
60+ fileMenu->addSeparator ();
5661 auto loadLuaAction = fileMenu->addAction (tr (" Load Lua script" ));
5762 auto openAppFolderAction = fileMenu->addAction (tr (" Open Panda3DS folder" ));
5863
@@ -140,6 +145,10 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
140145 if (!emu->loadROM (romPath)) {
141146 // For some reason just .c_str() doesn't show the proper path
142147 Helpers::warn (" Failed to load ROM file: %s" , romPath.string ().c_str ());
148+ } else {
149+ emu->getConfig ().addToRecentGames (romPath);
150+ emu->getConfig ().save ();
151+ updateRecentsMenu ();
143152 }
144153 }
145154
@@ -240,11 +249,48 @@ void MainWindow::selectROM() {
240249 );
241250
242251 if (!path.isEmpty ()) {
243- std::filesystem::path* p = new std::filesystem::path (path.toStdU16String ());
252+ loadROMFromPath (std::filesystem::path (path.toStdU16String ()));
253+ }
254+ }
244255
245- EmulatorMessage message{.type = MessageType::LoadROM};
246- message.path .p = p;
247- sendMessage (message);
256+ void MainWindow::loadROMFromPath (const std::filesystem::path& path) {
257+ std::filesystem::path* p = new std::filesystem::path (path);
258+
259+ EmulatorMessage message{.type = MessageType::LoadROM};
260+ message.path .p = p;
261+ sendMessage (message);
262+
263+ emu->getConfig ().addToRecentGames (path);
264+ emu->getConfig ().save ();
265+ updateRecentsMenu ();
266+ }
267+
268+ void MainWindow::updateRecentsMenu () {
269+ recentsMenu->clear ();
270+ const auto & recentGames = emu->getConfig ().recentlyPlayed ;
271+
272+ if (recentGames.empty ()) {
273+ // Add a disabled "No recent games" item
274+ QAction* noRecentsAction = recentsMenu->addAction (tr (" No recent games" ));
275+ noRecentsAction->setEnabled (false );
276+ } else {
277+ for (const auto & gamePath : recentGames) {
278+ QString displayName = QString::fromStdU16String (gamePath.filename ().u16string ());
279+ QAction* action = recentsMenu->addAction (displayName);
280+
281+ // Store the full path in the action's data, set tooltip to show full path
282+ action->setData (QString::fromStdU16String (gamePath.u16string ()));
283+ action->setToolTip (QString::fromStdU16String (gamePath.u16string ()));
284+ connect (action, &QAction::triggered, this , [this , gamePath]() { loadROMFromPath (gamePath); });
285+ }
286+
287+ recentsMenu->addSeparator ();
288+ QAction* clearAction = recentsMenu->addAction (tr (" Clear recent games" ));
289+ connect (clearAction, &QAction::triggered, this , [this ]() {
290+ emu->getConfig ().recentlyPlayed .clear ();
291+ emu->getConfig ().save ();
292+ updateRecentsMenu ();
293+ });
248294 }
249295}
250296
0 commit comments