Qt: Split out ROM types in load menu

This commit is contained in:
Jeffrey Pfau 2016-07-09 14:41:51 -07:00
parent 6fe17bc0f8
commit f64629448f
2 changed files with 31 additions and 15 deletions

View File

@ -271,11 +271,13 @@ void Window::saveConfig() {
m_config->write();
}
void Window::selectROM() {
QStringList formats{
QString Window::getFilters() const {
QStringList filters;
QStringList formats;
#ifdef M_CORE_GBA
QStringList gbaFormats{
"*.gba",
"*.gb",
"*.gbc",
#if defined(USE_LIBZIP) || defined(USE_ZLIB)
"*.zip",
#endif
@ -286,16 +288,12 @@ void Window::selectROM() {
"*.mb",
"*.rom",
"*.bin"};
QString filter = tr("Game Boy Advance ROMs (%1)").arg(formats.join(QChar(' ')));
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), filter);
if (!filename.isEmpty()) {
m_controller->loadGame(filename);
}
}
formats.append(gbaFormats);
filters.append(tr("Game Boy Advance ROMs (%1)").arg(gbaFormats.join(QChar(' '))));
#endif
void Window::replaceROM() {
QStringList formats{
"*.gba",
#ifdef M_CORE_GB
QStringList gbFormats{
"*.gb",
"*.gbc",
#if defined(USE_LIBZIP) || defined(USE_ZLIB)
@ -306,8 +304,24 @@ void Window::replaceROM() {
#endif
"*.rom",
"*.bin"};
QString filter = tr("Game Boy Advance ROMs (%1)").arg(formats.join(QChar(' ')));
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), filter);
formats.append(gbFormats);
filters.append(tr("Game Boy ROMs (%1)").arg(gbFormats.join(QChar(' '))));
#endif
formats.removeDuplicates();
filters.prepend(tr("All ROMs (%1)").arg(formats.join(QChar(' '))));
return filters.join(";;");
}
void Window::selectROM() {
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), getFilters());
if (!filename.isEmpty()) {
m_controller->loadGame(filename);
}
}
void Window::replaceROM() {
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), getFilters());
if (!filename.isEmpty()) {
m_controller->replaceGame(filename);
}

View File

@ -146,6 +146,8 @@ private:
void updateTitle(float fps = -1);
QString getFilters() const;
GameController* m_controller;
Display* m_display;
// TODO: Move these to a new class