diff --git a/TODO b/TODO new file mode 100644 index 000000000..89e60ff94 --- /dev/null +++ b/TODO @@ -0,0 +1,51 @@ + +Plan: + +DONE 1. Combine AbstractMenuProvider, PluginRoot and the AbstractMenuProvider's + implementation in MainWindow/LayoutView into lay::Dispatcher + +DONE 2. Base MainWindow and LayoutView on lay::Dispatcher + +DONE 3. lay::Plugin::plugin_root -> lay::Dispatcher *lay::Plugin::dispatcher() + This method will find the MainWindow or LayoutView depending + which is the root. + +DONE 4. Don't use AbstractMenuProvider::instance anymore, rather use lay::Dispatcher::instance + when necessary (should not be) + +DONE 5. Instead of slots, bind abstract menu items to symbols passed to + Dispatcher::menu_activated + +DONE 6. MainWindow will automatically dispatch menu_activated to LayoutView + +DONE 7. GSI-expose menu_activated in LayoutView and MainWindow as "call_menu" + +DONE 8. We can move menu initialization of LV-specifics to the LayoutView and + remove the cm_... and the code which just passes signals to the current view! :) + +9. BTW: make QWidget::setParent and QObject::setParent transfer ownership for + Qt binding. + +10. Provide the layer toolbox for GSI + +11. Tests for new features and GSI tests + +12. Default ctor for MainWindow so a pymod script can instantiate one (?) + +DONE 13. Re-think concept of Action as "smart pointers": ConfigureAction + violates this. ConfigureAction should be ActionHandle variant? + Action as pointer and smart pointers for managing? + + +Tests: + - DONE: compare menu layout + - DONE: test every menu function + - adding of new tech + - DONE: adding of rulers/removing + - ruby plugin (debugging, re-running) + - DONE: changing of macro title, move macro to different place + - DONE: funktionieren die check marks vor den menus? (Mode, selection modes, ruler template) + - DONE: check whether there is a replacement for the "cm_..." methods and tests them (at least one) + - DONE: check if changing the default grid works + - Run unit tests -> klayout_main_tests:main is failing + diff --git a/src/ant/ant/antConfigPage.cc b/src/ant/ant/antConfigPage.cc index ca06d1b93..64c07fcae 100644 --- a/src/ant/ant/antConfigPage.cc +++ b/src/ant/ant/antConfigPage.cc @@ -28,6 +28,7 @@ #include "ui_RulerConfigPage4.h" #include "antConfig.h" #include "layConverters.h" +#include "layDispatcher.h" #include "layQtTools.h" #include "tlExceptions.h" @@ -53,7 +54,7 @@ ConfigPage::~ConfigPage () } void -ConfigPage::setup (lay::PluginRoot *root) +ConfigPage::setup (lay::Dispatcher *root) { // Snap range int snap_range = 0; @@ -69,7 +70,7 @@ ConfigPage::setup (lay::PluginRoot *root) } void -ConfigPage::commit (lay::PluginRoot *root) +ConfigPage::commit (lay::Dispatcher *root) { root->config_set (cfg_ruler_obj_snap, mp_ui->ruler_obj_snap_cbx->isChecked ()); root->config_set (cfg_ruler_grid_snap, mp_ui->ruler_grid_snap_cbx->isChecked ()); @@ -99,7 +100,7 @@ ConfigPage2::~ConfigPage2 () } void -ConfigPage2::setup (lay::PluginRoot *root) +ConfigPage2::setup (lay::Dispatcher *root) { // Max. number of rulers int max_number_of_rulers = -1; @@ -122,7 +123,7 @@ ConfigPage2::setup (lay::PluginRoot *root) } void -ConfigPage2::commit (lay::PluginRoot *root) +ConfigPage2::commit (lay::Dispatcher *root) { int mr; try { @@ -153,7 +154,7 @@ ConfigPage3::~ConfigPage3 () } void -ConfigPage3::setup (lay::PluginRoot *root) +ConfigPage3::setup (lay::Dispatcher *root) { // snap mode lay::angle_constraint_type rm = lay::AC_Any; @@ -166,7 +167,7 @@ ConfigPage3::setup (lay::PluginRoot *root) } void -ConfigPage3::commit (lay::PluginRoot *root) +ConfigPage3::commit (lay::Dispatcher *root) { lay::angle_constraint_type rm = lay::AC_Any; if (mp_ui->ruler_any_angle_rb->isChecked ()) { @@ -215,7 +216,7 @@ ConfigPage4::~ConfigPage4 () } void -ConfigPage4::setup (lay::PluginRoot *root) +ConfigPage4::setup (lay::Dispatcher *root) { // templates root->config_get (cfg_ruler_templates, m_ruler_templates, TemplatesConverter ()); @@ -236,7 +237,7 @@ ConfigPage4::setup (lay::PluginRoot *root) } void -ConfigPage4::commit (lay::PluginRoot *root) +ConfigPage4::commit (lay::Dispatcher *root) { commit (); diff --git a/src/ant/ant/antConfigPage.h b/src/ant/ant/antConfigPage.h index 9142b4d7e..fe5853948 100644 --- a/src/ant/ant/antConfigPage.h +++ b/src/ant/ant/antConfigPage.h @@ -50,8 +50,8 @@ public: ConfigPage (QWidget *parent); ~ConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage *mp_ui; @@ -69,8 +69,8 @@ public: ConfigPage2 (QWidget *parent); ~ConfigPage2 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage2 *mp_ui; @@ -88,8 +88,8 @@ public: ConfigPage3 (QWidget *parent); ~ConfigPage3 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage3 *mp_ui; @@ -107,8 +107,8 @@ public: ConfigPage4 (QWidget *parent); ~ConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void add_clicked (); diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index af283337f..eebe762f5 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -23,9 +23,9 @@ #include "layPlugin.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layConverters.h" #include "layConfigurationDialog.h" +#include "layDispatcher.h" #include "antConfigPage.h" #include "antConfig.h" #include "antPlugin.h" @@ -85,13 +85,13 @@ void PluginDeclaration::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("rulers_group", "edit_menu.end")); - menu_entries.push_back (lay::MenuEntry ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); - menu_entries.push_back (lay::MenuEntry ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); + menu_entries.push_back (lay::separator ("rulers_group", "edit_menu.end")); + menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); + menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { return new ant::Service (manager, view); } @@ -101,7 +101,7 @@ PluginDeclaration::menu_activated (const std::string &symbol) const { if (symbol == "ant::configure") { - lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::PluginRoot::instance (), "ant::Plugin"); + lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::Dispatcher::instance (), "ant::Plugin"); config_dialog.exec (); return true; @@ -150,10 +150,6 @@ PluginDeclaration::configure (const std::string &name, const std::string &value) void PluginDeclaration::config_finalize () { - if (!lay::AbstractMenuProvider::instance ()) { - return; - } - if (m_templates_updated) { update_menu (); @@ -169,7 +165,7 @@ PluginDeclaration::config_finalize () } void -PluginDeclaration::initialized (lay::PluginRoot *root) +PluginDeclaration::initialized (lay::Dispatcher *root) { // Check if we already have templates (initial setup) bool any_templates = false; @@ -205,31 +201,35 @@ PluginDeclaration::initialized (lay::PluginRoot *root) } void -PluginDeclaration::uninitialize (lay::PluginRoot *) +PluginDeclaration::uninitialize (lay::Dispatcher *) { - for (std::vector::iterator a = m_actions.begin (); a != m_actions.end (); ++a) { - delete *a; - } m_actions.clear (); } void PluginDeclaration::update_current_template () { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); + if (! mp || ! mp->has_ui ()) { + return; + } if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) { std::vector menu_entries = mp->menu ()->group ("ruler_mode_group"); for (std::vector::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { - lay::Action action = mp->menu ()->action (*m); - action.set_title (m_templates [m_current_template].title ()); + lay::Action *action = mp->menu ()->action (*m); + action->set_title (m_templates [m_current_template].title ()); } if (m_templates.size () > 1) { - int it = 0; - for (std::vector