Qt: Split out ROM types in load menu
Jeffrey Pfau jeffrey@endrift.com
Sat, 09 Jul 2016 14:41:51 -0700
2 files changed,
31 insertions(+),
15 deletions(-)
M
src/platform/qt/Window.cpp
→
src/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.h
→
src/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