Setup QFileDialog side urls for various windows.
This commit is contained in:
parent
a5a0a5edee
commit
769ab81027
|
@ -1019,7 +1019,10 @@ void consoleWin_t::openROMFile(void)
|
|||
QString filename;
|
||||
std::string last;
|
||||
char dir[512];
|
||||
char *romDir;
|
||||
QFileDialog dialog(this, tr("Open ROM File") );
|
||||
QList<QUrl> urls;
|
||||
QDir d;
|
||||
|
||||
const QStringList filters(
|
||||
{ "All Useable files (*.nes *.NES *.nsf *.NSF *.fds *.FDS *.unf *.UNF *.unif *.UNIF *.zip *.ZIP)",
|
||||
|
@ -1030,6 +1033,23 @@ void consoleWin_t::openROMFile(void)
|
|||
"Any files (*)"
|
||||
});
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
|
||||
|
||||
romDir = getenv("FCEUX_ROM_PATH");
|
||||
|
||||
if ( romDir != NULL )
|
||||
{
|
||||
d.setPath(romDir);
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
dialog.setNameFilters( filters );
|
||||
|
@ -1048,6 +1068,7 @@ void consoleWin_t::openROMFile(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
@ -1092,8 +1113,27 @@ void consoleWin_t::loadNSF(void)
|
|||
QString filename;
|
||||
std::string last;
|
||||
char dir[512];
|
||||
char *romDir;
|
||||
QFileDialog dialog(this, tr("Load NSF File") );
|
||||
QList<QUrl> urls;
|
||||
QDir d;
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
|
||||
|
||||
romDir = getenv("FCEUX_ROM_PATH");
|
||||
|
||||
if ( romDir != NULL )
|
||||
{
|
||||
d.setPath(romDir);
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
}
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
dialog.setNameFilter(tr("NSF Sound Files (*.nsf *.NSF) ;; Zip Files (*.zip *.ZIP) ;; All files (*)"));
|
||||
|
@ -1112,6 +1152,7 @@ void consoleWin_t::loadNSF(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
@ -1146,7 +1187,36 @@ void consoleWin_t::loadStateFrom(void)
|
|||
QString filename;
|
||||
std::string last;
|
||||
char dir[512];
|
||||
const char *base;
|
||||
QFileDialog dialog(this, tr("Load State From File") );
|
||||
QList<QUrl> urls;
|
||||
QDir d;
|
||||
|
||||
base = FCEUI_GetBaseDirectory();
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
|
||||
if ( base )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( QDir( base ).absolutePath() );
|
||||
|
||||
d.setPath( QString(base) + "/fcs");
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
|
||||
d.setPath( QString(base) + "/sav");
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
|
@ -1166,6 +1236,7 @@ void consoleWin_t::loadStateFrom(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
@ -1200,7 +1271,35 @@ void consoleWin_t::saveStateAs(void)
|
|||
QString filename;
|
||||
std::string last;
|
||||
char dir[512];
|
||||
const char *base;
|
||||
QFileDialog dialog(this, tr("Save State To File") );
|
||||
QList<QUrl> urls;
|
||||
QDir d;
|
||||
|
||||
base = FCEUI_GetBaseDirectory();
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
|
||||
if ( base )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( QDir( base ).absolutePath() );
|
||||
|
||||
d.setPath( QString(base) + "/fcs");
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
|
||||
d.setPath( QString(base) + "/sav");
|
||||
|
||||
if ( d.exists() )
|
||||
{
|
||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
|
@ -1213,6 +1312,13 @@ void consoleWin_t::saveStateAs(void)
|
|||
|
||||
g_config->getOption ("SDL.LastSaveStateAs", &last );
|
||||
|
||||
if ( last.size() == 0 )
|
||||
{
|
||||
if ( base )
|
||||
{
|
||||
last = std::string(base) + "/sav";
|
||||
}
|
||||
}
|
||||
getDirFromFile( last.c_str(), dir );
|
||||
|
||||
dialog.setDirectory( tr(dir) );
|
||||
|
@ -1221,6 +1327,7 @@ void consoleWin_t::saveStateAs(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
@ -1644,6 +1751,11 @@ void consoleWin_t::loadGameGenieROM(void)
|
|||
std::string last;
|
||||
char dir[512];
|
||||
QFileDialog dialog(this, tr("Open Game Genie ROM") );
|
||||
QList<QUrl> urls;
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
|
@ -1663,6 +1775,7 @@ void consoleWin_t::loadGameGenieROM(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
@ -1727,6 +1840,11 @@ void consoleWin_t::fdsLoadBiosFile(void)
|
|||
std::string last;
|
||||
char dir[512];
|
||||
QFileDialog dialog(this, tr("Load FDS BIOS (disksys.rom)") );
|
||||
QList<QUrl> urls;
|
||||
|
||||
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first());
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
|
@ -1746,6 +1864,7 @@ void consoleWin_t::fdsLoadBiosFile(void)
|
|||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
dialog.setSidebarUrls(urls);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
|
|
@ -195,7 +195,7 @@ GetBaseDirectory(std::string &dir)
|
|||
Config *
|
||||
InitConfig()
|
||||
{
|
||||
std::string dir, prefix;
|
||||
std::string dir, prefix, savPath, movPath;
|
||||
Config *config;
|
||||
|
||||
GetBaseDirectory(dir);
|
||||
|
@ -340,21 +340,15 @@ InitConfig()
|
|||
//TODO implement this
|
||||
config->addOption("periodicsaves", "SDL.PeriodicSaves", 0);
|
||||
|
||||
char* home_dir = getenv("HOME");
|
||||
if ( home_dir == NULL )
|
||||
{
|
||||
home_dir = getenv("HOMEPATH");
|
||||
}
|
||||
if ( home_dir == NULL )
|
||||
{
|
||||
home_dir = "";
|
||||
}
|
||||
savPath = dir + "/sav";
|
||||
movPath = dir + "/movies";
|
||||
|
||||
// prefixed with _ because they are internal (not cli options)
|
||||
config->addOption("_lastopenfile", "SDL.LastOpenFile", home_dir);
|
||||
config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", home_dir);
|
||||
config->addOption("_lastopennsf", "SDL.LastOpenNSF", home_dir);
|
||||
config->addOption("_lastsavestateas", "SDL.LastSaveStateAs", home_dir);
|
||||
config->addOption("_lastopenmovie", "SDL.LastOpenMovie", home_dir);
|
||||
config->addOption("_lastopenfile", "SDL.LastOpenFile", dir);
|
||||
config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", savPath );
|
||||
config->addOption("_lastopennsf", "SDL.LastOpenNSF", dir);
|
||||
config->addOption("_lastsavestateas", "SDL.LastSaveStateAs", savPath );
|
||||
config->addOption("_lastopenmovie", "SDL.LastOpenMovie", movPath);
|
||||
config->addOption("_lastloadlua", "SDL.LastLoadLua", "");
|
||||
|
||||
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
||||
|
|
Loading…
Reference in New Issue