all repos — mgba @ f64629448fc395f248e7d5485ee6a9958eaacfdd

mGBA Game Boy Advance Emulator

Qt: Split out ROM types in load menu
Jeffrey Pfau jeffrey@endrift.com
Sat, 09 Jul 2016 14:41:51 -0700
commit

f64629448fc395f248e7d5485ee6a9958eaacfdd

parent

6fe17bc0f8526e3974f534be7d5489b393dc735f

2 files changed, 31 insertions(+), 15 deletions(-)

jump to
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -271,11 +271,13 @@ m_inputController.saveConfiguration();

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 @@ "*.agb",

"*.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 @@ "*.7z",

#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); }
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -146,6 +146,8 @@ QAction* addHiddenAction(QMenu* menu, QAction* action, const QString& name);

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