Merge pull request #2342 from KLayout/feature/issue-2335

Fixing issue #2335
This commit is contained in:
Matthias Köfferlein 2026-05-20 19:03:40 +02:00 committed by GitHub
commit 8488c59c15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 9 deletions

View File

@ -252,7 +252,7 @@ public:
/**
* @brief Gets a value indicating whether the page is for that specific plugin (given by a declaration object)
*/
bool for_plugin_declaration (const lay::PluginDeclaration *pd)
bool for_plugin_declaration (const lay::PluginDeclaration *pd) const
{
return m_plugin_declarations.find (pd) != m_plugin_declarations.end ();
}

View File

@ -2225,6 +2225,14 @@ public:
return pi;
}
/**
* @brief Gets the active plugin
*/
lay::Plugin *active_plugin () const
{
return mp_active_plugin;
}
/**
* @brief Create a plugin of the given type
*
@ -3214,11 +3222,6 @@ protected:
void init (db::Manager *mgr);
lay::Plugin *active_plugin () const
{
return mp_active_plugin;
}
virtual LayoutView *get_ui ();
bool configure (const std::string &name, const std::string &value);

View File

@ -332,6 +332,14 @@ public:
{
return new SelectionService (view);
}
virtual std::vector<std::string> additional_editor_options_pages () const
{
std::vector<std::string> names;
// TODO: provide in a central place instead of borrowing from the edt module
names.push_back ("GenericEditorOptions");
return names;
}
};
static tl::RegisteredClass<lay::PluginDeclaration> selection_service_decl (new SelectionServiceDeclaration (), -980, "laybasic::SelectionServicePlugin");

View File

@ -120,8 +120,13 @@ EditorOptionsPages::editor_options_pages ()
bool
EditorOptionsPages::has_content () const
{
lay::Plugin *plugin = mp_view->active_plugin ();
if (! plugin) {
return false;
}
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->active () && ! p->is_modal_page () && ! p->is_toolbox_widget ()) {
if (! p->is_modal_page () && ! p->is_toolbox_widget () && p->for_plugin_declaration (plugin->plugin_declaration ())) {
return true;
}
}
@ -131,8 +136,13 @@ EditorOptionsPages::has_content () const
bool
EditorOptionsPages::has_modal_content () const
{
lay::Plugin *plugin = mp_view->active_plugin ();
if (! plugin) {
return false;
}
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->active () && p->is_modal_page () && ! p->is_toolbox_widget ()) {
if (p->is_modal_page () && ! p->is_toolbox_widget () && p->for_plugin_declaration (plugin->plugin_declaration ())) {
return true;
}
}
@ -173,7 +183,7 @@ EditorOptionsPages::activate (const lay::Plugin *plugin)
bool is_active = plugin && op->for_plugin_declaration (plugin->plugin_declaration ());
// The zero order page is picked as the initial one
if (is_active && ! op->active () && op->order () == 0 && page == 0) {
if (is_active && ! op->active () && (op->order () == 0 || page == 0)) {
page = op.operator-> ();
}