Two bugs fixed: tech selection did not happen, enable all/disable all did not work

This commit is contained in:
Matthias Koefferlein 2020-02-13 00:53:20 +01:00
parent 0059d1bf24
commit 5853fecf37
3 changed files with 39 additions and 20 deletions

View File

@ -1865,22 +1865,6 @@ MainWindow::select_mode (int m)
}
}
void
MainWindow::enable_all ()
{
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
cls->set_editable_enabled (true);
}
}
void
MainWindow::disable_all ()
{
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
cls->set_editable_enabled (false);
}
}
void
MainWindow::cm_reset_window_state ()
{
@ -3848,6 +3832,13 @@ MainWindow::menu_activated (const std::string &symbol)
cm_help_about_qt ();
} else {
// Try the plugin declarations
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
if (cls->menu_activated (symbol)) {
return;
}
}
// TODO: this can be part of the Plugin scheme, but the plugin root has no idea which is the active
// view.
if (current_view ()) {

View File

@ -636,8 +636,6 @@ public slots:
void exit ();
void close_current_view ();
void tab_close_requested (int);
void enable_all ();
void disable_all ();
void open_recent (size_t n);
void view_selected (int index);
void view_title_changed ();

View File

@ -6632,6 +6632,15 @@ LayoutView::menu_symbols ()
void
LayoutView::menu_activated (const std::string &symbol)
{
// Try the plugin declarations if the view is the top-level dispatcher
if (dispatcher () == this) {
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
if (cls->menu_activated (symbol)) {
return;
}
}
}
if (symbol == "cm_show_properties") {
show_properties (this);
} else if (symbol == "cm_delete") {
@ -8042,8 +8051,8 @@ public:
menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All"))));
menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (QObject::tr ("Unselect All"))));
menu_entries.push_back (lay::separator ("edit_select_basic_group", at));
menu_entries.push_back (lay::menu_item ("enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All"))));
menu_entries.push_back (lay::menu_item ("disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All"))));
menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All"))));
menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All"))));
menu_entries.push_back (lay::separator ("edit_select_individual_group", at));
};
@ -8109,6 +8118,27 @@ public:
}
bool menu_activated (const std::string &symbol) const
{
if (symbol == "lv:enable_all") {
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
cls->set_editable_enabled (true);
}
return true;
} else if (symbol == "lv:disable_all") {
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
cls->set_editable_enabled (false);
}
return true;
} else {
return false;
}
}
void implements_primary_mouse_modes (std::vector<std::pair<std::string, std::pair<std::string, int> > > &modes)
{
std::vector <std::string> mode_titles;