DolphinQt: Add Show/Hide All options to gamelist region menu
This commit is contained in:
parent
f665ddae51
commit
7ded075561
|
@ -695,20 +695,29 @@ void MenuBar::AddShowRegionsMenu(QMenu* view_menu)
|
||||||
{tr("Show World"), &SConfig::GetInstance().m_ListWorld},
|
{tr("Show World"), &SConfig::GetInstance().m_ListWorld},
|
||||||
{tr("Show Unknown"), &SConfig::GetInstance().m_ListUnknown}};
|
{tr("Show Unknown"), &SConfig::GetInstance().m_ListUnknown}};
|
||||||
|
|
||||||
QActionGroup* region_group = new QActionGroup(this);
|
QMenu* const region_menu = view_menu->addMenu(tr("Show Regions"));
|
||||||
QMenu* region_menu = view_menu->addMenu(tr("Show Regions"));
|
const QAction* const show_all_regions = region_menu->addAction(tr("Show All"));
|
||||||
region_group->setExclusive(false);
|
const QAction* const hide_all_regions = region_menu->addAction(tr("Hide All"));
|
||||||
|
region_menu->addSeparator();
|
||||||
|
|
||||||
for (const auto& key : region_map.keys())
|
for (const auto& key : region_map.keys())
|
||||||
{
|
{
|
||||||
bool* config = region_map[key];
|
bool* const config = region_map[key];
|
||||||
QAction* action = region_group->addAction(region_menu->addAction(key));
|
QAction* const menu_item = region_menu->addAction(key);
|
||||||
action->setCheckable(true);
|
menu_item->setCheckable(true);
|
||||||
action->setChecked(*config);
|
menu_item->setChecked(*config);
|
||||||
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
|
||||||
*config = value;
|
const auto set_visibility = [this, config, key, menu_item](bool visibility) {
|
||||||
emit GameListRegionVisibilityToggled(key, value);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue