DolphinQt: Add Show/Hide All options to gamelist region menu

This commit is contained in:
Dentomologist 2020-10-29 09:29:41 -07:00
parent f665ddae51
commit 7ded075561
1 changed files with 20 additions and 11 deletions

View File

@ -695,20 +695,29 @@ void MenuBar::AddShowRegionsMenu(QMenu* view_menu)
{tr("Show World"), &SConfig::GetInstance().m_ListWorld},
{tr("Show Unknown"), &SConfig::GetInstance().m_ListUnknown}};
QActionGroup* region_group = new QActionGroup(this);
QMenu* region_menu = view_menu->addMenu(tr("Show Regions"));
region_group->setExclusive(false);
QMenu* const region_menu = view_menu->addMenu(tr("Show Regions"));
const QAction* const show_all_regions = region_menu->addAction(tr("Show All"));
const QAction* const hide_all_regions = region_menu->addAction(tr("Hide All"));
region_menu->addSeparator();
for (const auto& key : region_map.keys())
{
bool* config = region_map[key];
QAction* action = region_group->addAction(region_menu->addAction(key));
action->setCheckable(true);
action->setChecked(*config);
connect(action, &QAction::toggled, [this, config, key](bool value) {
*config = value;
emit GameListRegionVisibilityToggled(key, value);
});
bool* const config = region_map[key];
QAction* const menu_item = region_menu->addAction(key);
menu_item->setCheckable(true);
menu_item->setChecked(*config);
const auto set_visibility = [this, config, key, menu_item](bool visibility) {
menu_item->setChecked(visibility);
*config = visibility;
emit GameListRegionVisibilityToggled(key, visibility);
};
const auto set_visible = std::bind(set_visibility, true);
const auto set_hidden = std::bind(set_visibility, false);
connect(menu_item, &QAction::toggled, set_visibility);
connect(show_all_regions, &QAction::triggered, menu_item, set_visible);
connect(hide_all_regions, &QAction::triggered, menu_item, set_hidden);
}
}