Minor config improvements. Modified Qt recent ROM menu to drop file entries that no longer exist on disk.

This commit is contained in:
harry 2024-02-20 04:54:07 -05:00
parent cb45321433
commit 36614540fd
3 changed files with 66 additions and 3 deletions

View File

@ -317,6 +317,9 @@ consoleWin_t::~consoleWin_t(void)
#ifdef __FCEU_QSCRIPT_ENABLE__
QtScriptManager::destroy();
#endif
NetPlayCloseSession();
// The closeApp function call stops all threads.
// Calling quit on threads should not happen here.
//printf("Thread Finished: %i \n", emulatorThread->isFinished() );
@ -931,9 +934,9 @@ void consoleWin_t::createMainMenu(void)
movieMenu = menubar->addMenu(tr("&Movie"));
optMenu = menubar->addMenu(tr("&Options"));
emuMenu = menubar->addMenu(tr("&Emulation"));
netPlayMenu = menubar->addMenu(tr("&NetPlay"));
toolsMenu = menubar->addMenu(tr("&Tools"));
debugMenu = menubar->addMenu(tr("&Debug"));
netPlayMenu = menubar->addMenu(tr("&NetPlay"));
helpMenu = menubar->addMenu(tr("&Help"));
//-----------------------------------------------------------------------
@ -2219,8 +2222,9 @@ void consoleWin_t::buildRecentRomMenu(void)
g_config->getOption( buf, &s);
//printf("Recent Rom:%i '%s'\n", i, s.c_str() );
bool fileExists = !s.empty() && QFile::exists(tr(s.c_str()));
if ( s.size() > 0 )
if ( fileExists )
{
act = new consoleRecentRomAction( tr(s.c_str()), recentRomMenu);
@ -2234,6 +2238,13 @@ void consoleWin_t::buildRecentRomMenu(void)
romList.push_front( sptr );
}
else
{
// Clear the option if file does not exist
s.clear();
g_config->setOption( buf, s);
}
}
}
//---------------------------------------------------------------------------
@ -2251,11 +2262,17 @@ void consoleWin_t::saveRecentRomMenu(void)
s = *it;
sprintf(buf, "SDL.RecentRom%02i", i);
g_config->setOption( buf, s->c_str() );
g_config->setOption( buf, *s );
//printf("Recent Rom:%u '%s'\n", i, s->c_str() );
i--;
}
for (i = romList.size(); i < 10; i++)
{
sprintf(buf, "SDL.RecentRom%02i", i);
g_config->setOption( buf, "");
}
}
//---------------------------------------------------------------------------
void consoleWin_t::addRecentRom( const char *rom )

View File

@ -355,6 +355,26 @@ Config::setOption(const std::string &name,
return 0;
}
/**
* Sets the specified option to the given string value.
*/
int
Config::setOption(const std::string &name,
const char *value)
{
std::map<std::string, std::string>::iterator opt_i;
// confirm that the option exists
opt_i = _strOptMap.find(name);
if(opt_i == _strOptMap.end()) {
return -1;
}
// set the option
opt_i->second = value;
return 0;
}
/**
* Sets the specified option to the given string value.
*/
@ -375,6 +395,28 @@ Config::setOption(const std::string &name,
return 0;
}
#ifdef __QT_DRIVER__
/**
* Sets the specified option to the given string value.
*/
int
Config::setOption(const std::string &name,
const QString &value)
{
std::map<std::string, std::string>::iterator opt_i;
// confirm that the option exists
opt_i = _strOptMap.find(name);
if(opt_i == _strOptMap.end()) {
return -1;
}
// set the option
opt_i->second = value.toLocal8Bit().constData();
return 0;
}
#endif
/**
* Sets the specified option to the given function.
*/

View File

@ -65,10 +65,14 @@ public:
/**
* Sets a configuration option. Can be called at any time.
*/
int setOption(const std::string &, const char *);
int setOption(const std::string &, const std::string &);
int setOption(const std::string &, int);
int setOption(const std::string &, double);
int setOption(const std::string &, void (*)(const std::string &));
#ifdef __QT_DRIVER__
int setOption(const std::string &, const QString &);
#endif
#ifdef __QT_DRIVER__
int getOption(const std::string &, QString *) const;