MCPcopy Create free account
hub / github.com/TASEmulators/fceux / openROMFile

Method openROMFile

src/drivers/Qt/ConsoleWindow.cpp:2418–2503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2416//---------------------------------------------------------------------------
2417
2418void consoleWin_t::openROMFile(void)
2419{
2420 int ret, useNativeFileDialogVal;
2421 QString filename;
2422 std::string last;
2423 std::string dir;
2424 const char *romDir;
2425 QFileDialog dialog(this, tr("Open ROM File") );
2426 QList<QUrl> urls;
2427 QDir d;
2428
2429 const QStringList filters(
2430 { "All Useable files (*.nes *.NES *.nsf *.NSF *.fds *.FDS *.unf *.UNF *.unif *.UNIF *.zip *.ZIP, *.7z *.7zip)",
2431 "NES files (*.nes *.NES)",
2432 "NSF files (*.nsf *.NSF)",
2433 "UNF files (*.unf *.UNF *.unif *.UNIF)",
2434 "FDS files (*.fds *.FDS)",
2435 "Any files (*)"
2436 });
2437
2438 urls << QUrl::fromLocalFile( QDir::rootPath() );
2439 urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
2440 urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DesktopLocation).first());
2441 urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
2442 urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
2443
2444 romDir = getenv("FCEUX_ROM_PATH");
2445
2446 if ( romDir != NULL )
2447 {
2448 d.setPath(romDir);
2449
2450 if ( d.exists() )
2451 {
2452 urls << QUrl::fromLocalFile( d.absolutePath() );
2453 }
2454 }
2455
2456 dialog.setFileMode(QFileDialog::ExistingFile);
2457
2458 dialog.setNameFilters( filters );
2459
2460 dialog.setViewMode(QFileDialog::List);
2461 dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
2462 dialog.setLabelText( QFileDialog::Accept, tr("Open") );
2463
2464 g_config->getOption ("SDL.LastOpenFile", &last );
2465
2466 getDirFromFile( last.c_str(), dir);
2467
2468 dialog.setDirectory( tr(dir.c_str()) );
2469
2470 // Check config option to use native file dialog or not
2471 g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
2472
2473 dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
2474 dialog.setSidebarUrls(urls);
2475

Callers

nothing calls this directly

Calls 9

FCEUI_GetBaseDirectoryFunction · 0.85
getDirFromFileFunction · 0.85
getOptionMethod · 0.80
setOptionMethod · 0.80
execMethod · 0.80
CloseGameFunction · 0.70
LoadGameFunction · 0.70
trFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected