Merge branch 'app-refactoring' into doc-args

This commit is contained in:
Matthias Koefferlein 2020-03-15 21:32:39 +01:00
commit c10ccccdf7
171 changed files with 4419 additions and 5346 deletions

51
TODO Normal file
View File

@ -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

View File

@ -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 ();

View File

@ -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 ();

View File

@ -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<lay::MenuEntry> &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<lay::Action *>::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<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::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<Template>::const_iterator tt = m_templates.begin (); tt != m_templates.end () && it < int (m_actions.size ()); ++tt, ++it) {
m_actions[it]->set_checked (it == m_current_template);
tl::weak_collection<lay::ConfigureAction>::iterator it = m_actions.begin ();
int index = 0;
for (std::vector<Template>::const_iterator tt = m_templates.begin (); tt != m_templates.end () && it != m_actions.end (); ++tt, ++it, ++index) {
if (it.operator -> ()) {
it->set_checked (index == m_current_template);
}
}
}
@ -239,7 +239,10 @@ PluginDeclaration::update_current_template ()
void
PluginDeclaration::update_menu ()
{
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 ())) {
m_current_template = 0;
@ -248,8 +251,8 @@ PluginDeclaration::update_menu ()
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::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 ());
}
}
@ -261,19 +264,17 @@ PluginDeclaration::update_menu ()
}
}
for (std::vector<lay::Action *>::iterator a = m_actions.begin (); a != m_actions.end (); ++a) {
delete *a;
}
m_actions.clear ();
if (m_templates.size () > 1) {
int it = 0;
for (std::vector<Template>::const_iterator tt = m_templates.begin (); tt != m_templates.end (); ++tt, ++it) {
m_actions.push_back (mp->create_config_action (tt->title (), cfg_current_ruler_template, tl::to_string (it)));
m_actions.back ()->set_checkable (true);
m_actions.back ()->set_checked (it == m_current_template);
lay::ConfigureAction *action = new lay::ConfigureAction (tt->title (), cfg_current_ruler_template, tl::to_string (it));
m_actions.push_back (action);
action->set_checkable (true);
action->set_checked (it == m_current_template);
for (std::vector<std::string>::const_iterator t = tmpl_group.begin (); t != tmpl_group.end (); ++t) {
mp->menu ()->insert_item (*t + ".end", "ruler_template_" + tl::to_string (it), *m_actions.back ());
mp->menu ()->insert_item (*t + ".end", "ruler_template_" + tl::to_string (it), action);
}
}
}
@ -294,8 +295,8 @@ PluginDeclaration::register_annotation_template (const ant::Template &t)
}
m_templates.push_back (t);
lay::PluginRoot::instance ()->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates));
lay::PluginRoot::instance ()->config_end ();
lay::Dispatcher::instance ()->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates));
lay::Dispatcher::instance ()->config_end ();
}
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new ant::PluginDeclaration (), 3000, "ant::Plugin");

View File

@ -40,14 +40,14 @@ public:
virtual void get_options (std::vector < std::pair<std::string, std::string> > &options) const;
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const;
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const;
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const;
virtual bool implements_editable (std::string &title) const;
virtual bool implements_mouse_mode (std::string &title) const;
virtual bool configure (const std::string &name, const std::string &value);
virtual std::vector<std::pair <std::string, lay::ConfigPage *> > config_pages (QWidget *parent) const;
virtual void config_finalize ();
virtual void initialized (lay::PluginRoot *);
virtual void uninitialize (lay::PluginRoot *);
virtual void initialized (lay::Dispatcher *);
virtual void uninitialize (lay::Dispatcher *);
virtual bool menu_activated (const std::string &symbol) const;
void register_annotation_template (const ant::Template &t);
@ -60,7 +60,7 @@ private:
std::vector<ant::Template> m_templates;
int m_current_template;
std::vector<lay::Action *> m_actions;
tl::weak_collection<lay::ConfigureAction> m_actions;
bool m_current_template_updated;
bool m_templates_updated;
};

View File

@ -33,10 +33,11 @@
namespace db
{
Manager::Manager ()
Manager::Manager (bool enabled)
: m_transactions (),
m_current (m_transactions.begin ()),
m_opened (false), m_replay (false)
m_opened (false), m_replay (false),
m_enabled (enabled)
{
// .. nothing yet ..
}
@ -110,7 +111,7 @@ Manager::erase_transactions (transactions_t::iterator from, transactions_t::iter
Manager::transaction_id_t
Manager::transaction (const std::string &description, transaction_id_t join_with)
{
if (db::transactions_enabled ()) {
if (m_enabled) {
// close transactions that are still open (was an assertion before)
if (m_opened) {
@ -146,7 +147,7 @@ Manager::last_transaction_id () const
void
Manager::cancel ()
{
if (db::transactions_enabled ()) {
if (m_enabled) {
// commit and undo - revert changes done so far
commit ();
@ -162,7 +163,7 @@ Manager::cancel ()
void
Manager::commit ()
{
if (db::transactions_enabled ()) {
if (m_enabled) {
tl_assert (m_opened);
tl_assert (! m_replay);

View File

@ -85,13 +85,21 @@ public:
/**
* @brief Default constructor
*/
Manager ();
Manager (bool enabled = true);
/**
* @brief Destructor
*/
~Manager ();
/**
* @brief Gets a value indicating whether the manager is enabled
*/
bool is_enabled () const
{
return m_enabled;
}
/**
* @brief Release an object with the given id.
*
@ -255,6 +263,7 @@ private:
transactions_t::iterator m_current;
bool m_opened;
bool m_replay;
bool m_enabled;
void erase_transactions (transactions_t::iterator from, transactions_t::iterator to);
};

View File

@ -130,6 +130,26 @@ public:
return manager () && manager ()->replaying ();
}
/**
* @brief Begins a transaction (same as calling manager ()->transaction (), but safe against null manager ())
*/
void transaction (const std::string &description, db::Manager::transaction_id_t join_with = 0)
{
if (manager ()) {
manager ()->transaction (description, join_with);
}
}
/**
* @brief Ends a transaction (same as calling manager ()->commit (), but safe against null manager ())
*/
void commit ()
{
if (manager ()) {
manager ()->commit ();
}
}
private:
db::Manager::ident_t m_id;
db::Manager *mp_manager;

View File

@ -70,25 +70,6 @@ inline unsigned int num_circle_points ()
*/
void DB_PUBLIC set_num_circle_points (unsigned int n);
// -----------------------------------------------------------
// transaction enable
/**
* @brief Return true, if undo buffering is enabled
*/
inline bool transactions_enabled ()
{
extern DB_PUBLIC bool ms_transactions_enabled;
return ms_transactions_enabled;
}
/**
* @brief Enable or disable transaction buffering
*
* @param enabled True to enable undo buffering
*/
void DB_PUBLIC enable_transactions (bool enable);
}
#endif

View File

@ -28,7 +28,7 @@
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c1 (g.cell (g.add_cell ()));
db::Cell &c2 (g.cell (g.add_cell ()));
@ -265,7 +265,7 @@ TEST(2)
{
::pi = 0;
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -615,7 +615,7 @@ TEST(3)
{
::pi = 0;
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -672,7 +672,7 @@ TEST(3a)
{
::pi = 0;
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -728,7 +728,7 @@ TEST(3b)
{
::pi = 0;
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -805,7 +805,7 @@ TEST(4)
{
::pi = 0;
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -842,7 +842,7 @@ TEST(4)
TEST(5)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));
@ -888,7 +888,7 @@ TEST(5)
TEST(6)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));

View File

@ -29,7 +29,7 @@
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
db::Cell &c0 (g.cell (g.add_cell ()));
db::Cell &c1 (g.cell (g.add_cell ()));

View File

@ -61,7 +61,7 @@ static bool check_hull (const std::vector<db::Polygon> &hull, const db::Shapes &
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
unsigned int l1 = g.insert_layer (db::LayerProperties (1, 0));
unsigned int l2 = g.insert_layer (db::LayerProperties (2, 0));
@ -238,7 +238,7 @@ TEST(1)
TEST(2)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
unsigned int l1 = g.insert_layer (db::LayerProperties (1, 0));
db::Cell &c1 (g.cell (g.add_cell ()));

View File

@ -417,7 +417,7 @@ TEST(3special)
void run_test_size (tl::TestBase *_this, const char *file, const char *au_file, int mode, db::Coord dx, db::Coord dy, bool min_coherence = true, bool flat = true)
{
db::Manager m;
db::Manager m (true);
db::Layout layout_org (&m);
db::Layout layout_au (&m);

View File

@ -308,7 +308,7 @@ TEST(1)
EXPECT_EQ (lib->layout ().get_properties(1).to_string (), "16/0");
EXPECT_EQ (lib->layout ().get_properties(2).to_string (), "24/0");
db::Manager m;
db::Manager m (true);
db::Layout layout(&m);
layout.dbu (0.001);
@ -460,7 +460,7 @@ TEST(2)
bool equal;
db::Writer writer = db::Writer (db::SaveLayoutOptions ());
db::Manager m;
db::Manager m (true);
db::Layout layout(&m);
layout.dbu (0.001);
@ -571,7 +571,7 @@ TEST(3)
// This test tests the ability to reference libraries out of other libraries ("B" references "A"),
// the ability to persist that and whether this survives a write/read cycle.
db::Manager m;
db::Manager m (true);
db::Layout layout(&m);
layout.dbu (0.001);

View File

@ -69,7 +69,7 @@ struct A : public db::Object
TEST(1)
{
db::Manager *man = new db::Manager ();
db::Manager *man = new db::Manager (true);
{
EXPECT_EQ (man->available_undo ().first, false);
EXPECT_EQ (man->available_redo ().first, false);
@ -176,7 +176,7 @@ struct B : public db::Object
TEST(2)
{
db::Manager *man = new db::Manager ();
db::Manager *man = new db::Manager (true);
{
EXPECT_EQ (man->available_undo ().first, false);
EXPECT_EQ (man->available_redo ().first, false);
@ -234,7 +234,7 @@ TEST(2)
TEST(3)
{
db::Manager *man = new db::Manager ();
db::Manager *man = new db::Manager (true);
{
EXPECT_EQ (man->available_undo ().first, false);
EXPECT_EQ (man->available_redo ().first, false);
@ -268,7 +268,7 @@ TEST(3)
TEST(4)
{
db::Manager *man = new db::Manager ();
db::Manager *man = new db::Manager (true);
{
EXPECT_EQ (man->available_undo ().first, false);
EXPECT_EQ (man->available_redo ().first, false);

View File

@ -92,7 +92,7 @@ class PD
TEST(0)
{
db::Manager m;
db::Manager m (true);
db::Layout layout(&m);
layout.dbu (0.001);
db::Layout layout_au(&m);
@ -114,7 +114,7 @@ TEST(0)
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Layout layout(&m);
layout.dbu (0.001);

View File

@ -65,7 +65,7 @@ std::string collect_with_copy(db::RecursiveShapeIterator s, const db::Layout &la
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer (0);
g.insert_layer (1);
@ -326,7 +326,7 @@ TEST(1)
TEST(1a)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer (0);
g.insert_layer (1);
@ -472,7 +472,7 @@ TEST(1a)
TEST(1b)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer (0);
db::Cell &c0 (g.cell (g.add_cell ()));
@ -508,7 +508,7 @@ TEST(1b)
TEST(2)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer(0);
@ -562,7 +562,7 @@ TEST(2)
TEST(3)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer(0);
@ -742,7 +742,7 @@ TEST(4)
{
// Big fun
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer(0);
@ -827,7 +827,7 @@ TEST(5)
{
// Big fun with cells
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer(0);
@ -1013,7 +1013,7 @@ private:
// Push mode with cells
TEST(10)
{
db::Manager m;
db::Manager m (true);
db::Layout g (&m);
g.insert_layer(0);

View File

@ -32,7 +32,7 @@
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -129,7 +129,7 @@ TEST(1)
TEST(2)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -209,7 +209,7 @@ TEST(2)
TEST(3)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -272,7 +272,7 @@ TEST(3)
TEST(1BOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -342,7 +342,7 @@ TEST(1BOX)
TEST(2BOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -400,7 +400,7 @@ TEST(2BOX)
TEST(3BOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -463,7 +463,7 @@ TEST(3BOX)
TEST(1SBOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -533,7 +533,7 @@ TEST(1SBOX)
TEST(2SBOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -591,7 +591,7 @@ TEST(2SBOX)
TEST(3SBOX)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Polygon p1;
@ -654,7 +654,7 @@ TEST(3SBOX)
TEST(4)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box bx1 (db::Point (0, 0), db::Point (1000, 100));
@ -684,7 +684,7 @@ TEST(4)
TEST(5)
{
if (db::default_editable_mode ()) { return; } // currently Boxes are treated as ones with properties
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box bx1 (db::Point (0, 0), db::Point (1000, 100));
@ -720,7 +720,7 @@ TEST(5)
TEST(6)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box bx1 (db::Point (0, 0), db::Point (1000, 100));
@ -745,7 +745,7 @@ TEST(6)
TEST(7)
{
if (db::default_editable_mode ()) { return; } // currently Boxes are treated as ones with properties
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box bx2 (db::Point (0, 1000), db::Point (100, 2000));
@ -766,7 +766,7 @@ TEST(7)
TEST(8)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::PropertiesRepository proprep;

View File

@ -256,7 +256,7 @@ TEST(2SIMPLE)
TEST(3)
{
db::GenericRepository *rep = new db::GenericRepository ();
db::Manager m;
db::Manager m (true);
std::vector <db::Point> c1;
c1.push_back (db::Point (100, 0));

View File

@ -30,7 +30,7 @@
TEST(1)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box b_empty;
@ -60,7 +60,7 @@ TEST(1)
TEST(1a)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, true);
db::Box b_empty;
@ -88,7 +88,7 @@ TEST(1a)
TEST(1b)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, false);
db::Box b_empty;
@ -393,7 +393,7 @@ struct plus1
TEST(2)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -644,7 +644,7 @@ TEST(2)
TEST(2A)
{
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -737,7 +737,7 @@ TEST(2A)
TEST(3)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -988,7 +988,7 @@ TEST(3)
TEST(4)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -1238,7 +1238,7 @@ TEST(4)
TEST(5)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -1489,7 +1489,7 @@ TEST(5)
TEST(6)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -1711,7 +1711,7 @@ TEST(6)
TEST(7)
{
db::Manager m;
db::Manager m (true);
db::Layout other_layout (&m);
db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ());
@ -2017,7 +2017,7 @@ TEST(10A)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -2076,7 +2076,7 @@ TEST(10C)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -2101,7 +2101,7 @@ TEST(10D)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -2126,7 +2126,7 @@ TEST(11A)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x20);
@ -2182,7 +2182,7 @@ TEST(11C)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x20);
@ -2207,7 +2207,7 @@ TEST(11D)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x20);
@ -2232,7 +2232,7 @@ TEST(11E)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
m.transaction ("y");
unsigned int lindex = read_testdata (layout, 0x20);
@ -2268,7 +2268,7 @@ TEST(11F)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
m.transaction ("y");
unsigned int lindex = read_testdata (layout, 0x20);
@ -2369,7 +2369,7 @@ TEST(12A)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x20 | 0x80); // short box, no arrays
@ -2414,7 +2414,7 @@ TEST(12B)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x20 | 0x80); // short box, no arrays
@ -2442,7 +2442,7 @@ TEST(12C)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x10 | 0x80); // box, no arrays
@ -2487,7 +2487,7 @@ TEST(12D)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x10 | 0x80); // box, no arrays
@ -2515,7 +2515,7 @@ TEST(12E)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x01 | 0x80); // simple polygon, no arrays
@ -2577,7 +2577,7 @@ TEST(12F)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x01 | 0x80); // simple polygon, no arrays
@ -2614,7 +2614,7 @@ TEST(12G)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x02 | 0x80); // polygon, no arrays
@ -2676,7 +2676,7 @@ TEST(12H)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x02 | 0x80); // polygon, no arrays
@ -2713,7 +2713,7 @@ TEST(12I)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x04 | 0x80); // path, no arrays
@ -2773,7 +2773,7 @@ TEST(12J)
{
if (db::default_editable_mode ()) {
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x08 | 0x80); // text, no arrays
@ -2831,7 +2831,7 @@ TEST(12J)
TEST(13)
{
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x3f); // all with arrays
@ -2859,7 +2859,7 @@ TEST(13)
TEST(14)
{
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x10); // boxes
@ -2947,7 +2947,7 @@ TEST(14)
TEST(15)
{
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -3058,7 +3058,7 @@ TEST(15)
TEST(16)
{
db::Manager m;
db::Manager m (true);
db::Layout layout (&m);
unsigned int lindex = read_testdata (layout, 0x1);
@ -3276,7 +3276,7 @@ TEST(22)
// Edge pairs
TEST(23)
{
db::Manager m;
db::Manager m (true);
db::Shapes s (&m, 0, db::default_editable_mode ());
db::Box b_empty;
@ -3312,7 +3312,7 @@ TEST(23)
// Bug #107
TEST(100)
{
db::Manager m;
db::Manager m (true);
db::Shapes shapes1 (&m, 0, true);
m.transaction ("y");

View File

@ -87,7 +87,7 @@ struct EOPCompareOp
}
};
EditorOptionsPages::EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::PluginRoot *root)
EditorOptionsPages::EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root)
: mp_root (root)
{
mp_ui = new Ui::EditorOptionsDialog ();
@ -515,7 +515,7 @@ EditorOptionsPath::setup (lay::Plugin *root)
// ------------------------------------------------------------------
// EditorOptionsInst implementation
EditorOptionsInst::EditorOptionsInst (lay::PluginRoot *root)
EditorOptionsInst::EditorOptionsInst (lay::Dispatcher *root)
: QWidget (), EditorOptionsPage (), mp_root (root), mp_pcell_parameters (0)
{
mp_ui = new Ui::EditorOptionsInst ();

View File

@ -44,7 +44,7 @@ namespace Ui
namespace lay
{
class PluginDeclaration;
class PluginRoot;
class Dispatcher;
class Plugin;
}
@ -92,7 +92,7 @@ class EditorOptionsPages
Q_OBJECT
public:
EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::PluginRoot *root);
EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root);
~EditorOptionsPages ();
void unregister_page (edt::EditorOptionsPage *page);
@ -106,7 +106,7 @@ public slots:
private:
std::vector <edt::EditorOptionsPage *> m_pages;
Ui::EditorOptionsDialog *mp_ui;
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
void update (edt::EditorOptionsPage *page);
void do_apply ();
@ -195,7 +195,7 @@ class EditorOptionsInst
Q_OBJECT
public:
EditorOptionsInst (lay::PluginRoot *root);
EditorOptionsInst (lay::Dispatcher *root);
~EditorOptionsInst ();
virtual QWidget *q_frame () { return this; }
@ -214,7 +214,7 @@ public slots:
private:
Ui::EditorOptionsInst *mp_ui;
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
edt::PCellParametersPage *mp_pcell_parameters;
int m_cv_index;

View File

@ -48,7 +48,7 @@ namespace edt
// -----------------------------------------------------------------------------
// Main Service implementation
MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root)
MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root)
: lay::Plugin (view),
lay::Editable (view),
db::Object (manager),

View File

@ -38,7 +38,7 @@
#include <vector>
namespace lay {
class PluginRoot;
class Dispatcher;
class FlattenInstOptionsDialog;
}
@ -63,7 +63,7 @@ public:
/**
* @brief The constructor
*/
MainService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root);
MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root);
/**
* @brief The destructor
@ -196,7 +196,7 @@ public:
private:
// The layout view that this service is attached to
lay::LayoutView *mp_view;
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
bool m_needs_update;
// options

View File

@ -1007,7 +1007,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box,
// -----------------------------------------------------------------------------
// Main Service implementation
PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root)
PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root)
: QObject (),
lay::ViewService (view->view_object_widget ()),
lay::Editable (view),

View File

@ -44,7 +44,7 @@ namespace db {
}
namespace lay {
class PluginRoot;
class Dispatcher;
class Marker;
class InstanceMarker;
}
@ -153,7 +153,7 @@ public:
/**
* @brief The constructor
*/
PartialService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root);
PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root);
/**
* @brief The destructor
@ -288,7 +288,7 @@ protected:
private:
// The layout view that this service is attached to
lay::LayoutView *mp_view;
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
bool m_dragging;
bool m_keep_selection;
db::DPoint m_start, m_current;

View File

@ -22,7 +22,6 @@
#include "layTipDialog.h"
#include "layAbstractMenuProvider.h"
#include "edtPlugin.h"
#include "edtConfig.h"
#include "edtService.h"
@ -46,7 +45,7 @@ void get_text_options (std::vector < std::pair<std::string, std::string> > &opti
}
static
void get_text_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::PluginRoot *)
void get_text_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *)
{
ret.push_back (new edt::EditorOptionsText ());
}
@ -61,7 +60,7 @@ void get_path_options (std::vector < std::pair<std::string, std::string> > &opti
}
static
void get_path_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::PluginRoot *)
void get_path_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *)
{
ret.push_back (new EditorOptionsPath ());
}
@ -86,7 +85,7 @@ void get_inst_options (std::vector < std::pair<std::string, std::string> > &opti
}
static
void get_inst_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::PluginRoot *root)
void get_inst_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *root)
{
ret.push_back (new EditorOptionsInst (root));
}
@ -98,7 +97,7 @@ class PluginDeclaration
public:
PluginDeclaration (const std::string &title, const std::string &mouse_mode,
void (*option_get_f) (std::vector < std::pair<std::string, std::string> > &) = 0,
void (*pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::PluginRoot *) = 0)
void (*pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::Dispatcher *) = 0)
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f)
{
// .. nothing yet ..
@ -121,7 +120,7 @@ public:
// .. nothing yet ..
}
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &pages, lay::PluginRoot *root) const
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root) const
{
if (mp_pages_f != 0) {
size_t nstart = pages.size ();
@ -132,7 +131,7 @@ public:
}
}
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const
{
Svc *service = new Svc (manager, view);
service->set_plugin_declaration (this);
@ -156,7 +155,7 @@ private:
std::string m_mouse_mode;
void (*mp_option_get_f) (std::vector < std::pair<std::string, std::string> > &options);
void (*mp_pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::PluginRoot *);
void (*mp_pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::Dispatcher *);
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl1 (
@ -215,33 +214,33 @@ public:
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("edt::hier_group", "zoom_menu.end"));
menu_entries.push_back (lay::MenuEntry ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)"));
menu_entries.push_back (lay::MenuEntry ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)"));
menu_entries.push_back (lay::separator ("edt::hier_group", "zoom_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)"));
menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)"));
menu_entries.push_back (lay::MenuEntry ("edit_options_group:edit_mode", "edit_menu.end"));
menu_entries.push_back (lay::MenuEntry ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)"));
menu_entries.push_back (lay::MenuEntry ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array"))));
menu_entries.push_back (lay::MenuEntry ("selection_group:edit_mode", "edit_menu.selection_menu.end"));
menu_entries.push_back (lay::MenuEntry ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_tap", "tap:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)"));
menu_entries.push_back (lay::MenuEntry ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others"))));
menu_entries.push_back (lay::MenuEntry ("hier_group:edit_mode", "edit_menu.selection_menu.end"));
menu_entries.push_back (lay::MenuEntry ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell"))));
menu_entries.push_back (lay::MenuEntry ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell"))));
menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)"));
menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array"))));
menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer"))));
menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)"));
menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align"))));
menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners"))));
menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes"))));
menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes"))));
menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First"))));
menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First"))));
menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others"))));
menu_entries.push_back (lay::separator ("hier_group:edit_mode", "edit_menu.selection_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances"))));
menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays"))));
menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy"))));
menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell"))));
menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants"))));
menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell"))));
menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell"))));
menu_entries.push_back (lay::MenuEntry ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}"))));
menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}"))));
}
bool configure (const std::string &name, const std::string &value)
@ -255,7 +254,7 @@ public:
return false;
}
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new edt::MainService (manager, view, root);
}
@ -270,10 +269,10 @@ public:
return false;
}
virtual void initialize (lay::PluginRoot *root)
virtual void initialize (lay::Dispatcher *root)
{
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
if (! mp) {
lay::Dispatcher *mp = lay::Dispatcher::instance ();
if (! mp || ! mp->has_ui ()) {
return;
}
@ -298,45 +297,43 @@ public:
}
// add entries to the combine mode dialog
lay::Action combine_menu = mp->menu ()->action ("@toolbar.combine_mode");
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", *mp->create_config_action (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", *mp->create_config_action (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", *mp->create_config_action (tl::to_string (QObject::tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", *mp->create_config_action (tl::to_string (QObject::tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", *mp->create_config_action (tl::to_string (QObject::tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", new lay::ConfigureAction (tl::to_string (QObject::tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", new lay::ConfigureAction (tl::to_string (QObject::tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", new lay::ConfigureAction (tl::to_string (QObject::tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff)));
update_menu (CM_Add);
}
void update_menu (combine_mode_type cm)
{
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
if (! mp) {
lay::Dispatcher *mp = lay::Dispatcher::instance ();
if (! mp || ! mp->has_ui ()) {
return;
}
lay::Action combine_menu = mp->menu ()->action ("@toolbar.combine_mode");
lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode");
if (cm == CM_Add) {
combine_menu.set_title (tl::to_string (QObject::tr ("Add")));
combine_menu.set_icon (":/cm_add.png");
combine_menu->set_title (tl::to_string (QObject::tr ("Add")));
combine_menu->set_icon (":/cm_add.png");
} else if (cm == CM_Merge) {
combine_menu.set_title (tl::to_string (QObject::tr ("Merge")));
combine_menu.set_icon (":/cm_merge.png");
combine_menu->set_title (tl::to_string (QObject::tr ("Merge")));
combine_menu->set_icon (":/cm_merge.png");
} else if (cm == CM_Erase) {
combine_menu.set_title (tl::to_string (QObject::tr ("Erase")));
combine_menu.set_icon (":/cm_erase.png");
combine_menu->set_title (tl::to_string (QObject::tr ("Erase")));
combine_menu->set_icon (":/cm_erase.png");
} else if (cm == CM_Mask) {
combine_menu.set_title (tl::to_string (QObject::tr ("Mask")));
combine_menu.set_icon (":/cm_mask.png");
combine_menu->set_title (tl::to_string (QObject::tr ("Mask")));
combine_menu->set_icon (":/cm_mask.png");
} else if (cm == CM_Diff) {
combine_menu.set_title (tl::to_string (QObject::tr ("Diff")));
combine_menu.set_icon (":/cm_diff.png");
combine_menu->set_title (tl::to_string (QObject::tr ("Diff")));
combine_menu->set_icon (":/cm_diff.png");
}
}
virtual void uninitialize (lay::PluginRoot *)
virtual void uninitialize (lay::Dispatcher *)
{
if (mp_obj_prop_dialog) {
delete mp_obj_prop_dialog;
@ -372,20 +369,20 @@ public:
}
}
void initialized (lay::PluginRoot *root)
void initialized (lay::Dispatcher *root)
{
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
if (! mp) {
lay::Dispatcher *mp = lay::Dispatcher::instance ();
if (! mp || ! mp->has_ui ()) {
return;
}
lay::Action combine_menu = mp->menu ()->action ("@toolbar.combine_mode");
lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode");
// Do some more initialization here.
combine_mode_type cm = CM_Add;
root->config_get (cfg_edit_combine_mode, cm, CMConverter ());
if (cm != CM_Add && combine_menu.is_visible ()) {
if (cm != CM_Add && combine_menu->is_visible ()) {
lay::TipDialog td (QApplication::activeWindow (),
tl::to_string (QObject::tr ("The background combination mode of the shape editor is set to some other mode than 'Add'.\n"
"This can be confusing, because a shape may not be drawn as expected.\n\nTo switch back to normal mode, choose 'Add' for the background combination mode in the toolbar.")),
@ -398,7 +395,7 @@ public:
}
private:
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
std::string m_title;
edt::EditorOptionsPages *mp_obj_prop_dialog;
std::vector<edt::EditorOptionsPage *> m_prop_dialog_pages;
@ -447,7 +444,7 @@ public:
// .. nothing yet ..
}
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new edt::PartialService (manager, view, root);
}

View File

@ -30,7 +30,7 @@
namespace lay
{
class PluginRoot;
class Dispatcher;
}
namespace edt
@ -44,7 +44,7 @@ namespace edt
: public lay::PluginDeclaration
{
public:
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &, lay::PluginRoot *) const = 0;
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &, lay::Dispatcher *) const = 0;
};
/**

View File

@ -334,8 +334,8 @@ Service::copy_selected ()
// store the given value "forever"
if (dont_ask_again) {
plugin_root ()->config_set (cfg_edit_hier_copy_mode, tl::to_string (inst_mode));
plugin_root ()->config_end ();
dispatcher ()->config_set (cfg_edit_hier_copy_mode, tl::to_string (inst_mode));
dispatcher ()->config_end ();
}
// create one ClipboardData object per cv_index because, this one assumes that there is

View File

@ -1282,14 +1282,14 @@ InstService::sync_to_config ()
{
// push the current setup to configuration so the instance dialog will take these as default
// and "apply" of these instance properties doesn't fail because of insistency.
plugin_root ()->config_set (cfg_edit_inst_lib_name, m_lib_name);
plugin_root ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name);
dispatcher ()->config_set (cfg_edit_inst_lib_name, m_lib_name);
dispatcher ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name);
if (m_is_pcell) {
plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters));
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters));
} else {
plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, std::string ());
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ());
}
plugin_root ()->config_end ();
dispatcher ()->config_end ();
}
void

View File

@ -406,7 +406,7 @@ LandmarksDialog::LandmarksDialog (QWidget *parent, img::Object &img)
setupUi (this);
mp_image = navigator->setup (lay::PluginRoot::instance (), &img);
mp_image = navigator->setup (lay::Dispatcher::instance (), &img);
connect (new_pb, SIGNAL (clicked ()), this, SLOT (update_mode ()));
connect (delete_pb, SIGNAL (clicked ()), this, SLOT (update_mode ()));

View File

@ -48,7 +48,7 @@ Navigator::Navigator (QWidget *parent)
}
img::Object *
Navigator::setup (lay::PluginRoot *root, img::Object *img)
Navigator::setup (lay::Dispatcher *root, img::Object *img)
{
mp_view = new lay::LayoutView (0, false, root, this, "img_navigator_view", lay::LayoutView::LV_Naked + lay::LayoutView::LV_NoZoom + lay::LayoutView::LV_NoServices + lay::LayoutView::LV_NoGrid);
mp_view->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);

View File

@ -28,7 +28,7 @@
namespace lay
{
class PluginRoot;
class Dispatcher;
class LayoutView;
class ZoomService;
class ViewService;
@ -52,7 +52,7 @@ public:
~Navigator ();
void background_color (QColor c);
img::Object *setup (lay::PluginRoot *root, img::Object *img);
img::Object *setup (lay::Dispatcher *root, img::Object *img);
lay::LayoutView *view ()
{

View File

@ -33,16 +33,16 @@ void
PluginDeclaration::get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("image_group", "edit_menu.end"));
menu_entries.push_back (lay::MenuEntry ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image"))));
menu_entries.push_back (lay::MenuEntry ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images")), true));
menu_entries.push_back (lay::MenuEntry ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front"))));
menu_entries.push_back (lay::MenuEntry ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back"))));
menu_entries.push_back (lay::MenuEntry ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images"))));
menu_entries.push_back (lay::separator ("image_group", "edit_menu.end"));
menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image"))));
menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images"))));
menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front"))));
menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back"))));
menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images"))));
}
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 img::Service (manager, view);
}

View File

@ -39,7 +39,7 @@ public:
}
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const;
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const;
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const;
virtual bool implements_editable (std::string &title) const;
};

View File

@ -90,8 +90,8 @@ static gsi::Methods application_methods ()
method<C, bool> ("is_editable?", &C::is_editable,
"@brief Returns true if the application is in editable mode\n"
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C, std::string, const std::string &> ("get_config", &C::get_config, gsi::arg ("name"),
"@brief Gets the value for a configuration parameter\n"
@ -108,8 +108,8 @@ static gsi::Methods application_methods ()
"to the configuration parameter. The values delivered by this method correspond to the values stored "
"in the configuration file "
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C, std::vector<std::string> > ("get_config_names", &C::get_config_names,
"@brief Gets the configuration parameter names\n"
@ -119,8 +119,8 @@ static gsi::Methods application_methods ()
"This method returns the names of all known configuration parameters. These names can be used to "
"get and set configuration parameter values."
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C, const std::string &, const std::string &> ("set_config", &C::set_config, gsi::arg ("name"), gsi::arg ("value"),
"@brief Sets a configuration parameter with the given name to the given value\n"
@ -136,8 +136,8 @@ static gsi::Methods application_methods ()
"It is possible to write an arbitrary name/value pair into the configuration database which then is "
"written to the configuration file."
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C> ("commit_config", &C::config_end,
"@brief Commits the configuration settings\n"
@ -148,8 +148,8 @@ static gsi::Methods application_methods ()
"\n"
"This method has been introduced in version 0.25.\n"
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C, bool, const std::string &> ("write_config", &C::write_config, gsi::arg ("file_name"),
"@brief Writes configuration to a file\n"
@ -158,8 +158,8 @@ static gsi::Methods application_methods ()
"If the configuration file cannot be written, \n"
"is returned but no exception is thrown.\n"
) +
// TODO: basically this method belongs to PluginRoot (aka MainWindow).
// There is separate declaration for PluginRoot which we have to synchronize
// TODO: basically this method belongs to Dispatcher (aka MainWindow).
// There is separate declaration for Dispatcher which we have to synchronize
// with this method.
method<C, bool, const std::string &> ("read_config", &C::read_config, gsi::arg ("file_name"),
"@brief Reads the configuration from a file\n"

View File

@ -43,10 +43,159 @@ void enable_edits (lay::MainWindow * /*main_window*/, bool enable)
}
}
// NOTE: match this with the cm_method_decl's below
static const char *cm_symbols[] = {
"cm_reset_window_state",
"cm_select_all",
"cm_unselect_all",
"cm_undo",
"cm_redo",
"cm_delete",
"cm_show_properties",
"cm_copy",
"cm_paste",
"cm_cut",
"cm_zoom_fit_sel",
"cm_zoom_fit",
"cm_zoom_in",
"cm_zoom_out",
"cm_pan_up",
"cm_pan_down",
"cm_pan_left",
"cm_pan_right",
"cm_save_session",
"cm_restore_session",
"cm_setup",
"cm_save_as",
"cm_save",
"cm_save_all",
"cm_reload",
"cm_close",
"cm_close_all",
"cm_clone",
"cm_layout_props",
"cm_inc_max_hier",
"cm_dec_max_hier",
"cm_max_hier",
"cm_max_hier_0",
"cm_max_hier_1",
"cm_prev_display_state|#cm_last_display_state",
"cm_next_display_state",
"cm_cancel",
"cm_redraw",
"cm_screenshot",
"cm_save_layer_props",
"cm_load_layer_props",
"cm_save_bookmarks",
"cm_load_bookmarks",
"cm_select_cell",
"cm_select_current_cell",
"cm_print",
"cm_exit",
"cm_view_log",
"cm_bookmark_view",
"cm_manage_bookmarks",
"cm_macro_editor",
"cm_goto_position",
"cm_help_about",
"cm_technologies",
"cm_packages",
"cm_open_too",
"cm_open_new_view",
"cm_open",
"cm_pull_in",
"cm_reader_options",
"cm_new_layout",
"cm_new_panel",
"cm_adjust_origin",
"cm_new_cell",
"cm_new_layer",
"cm_clear_layer",
"cm_delete_layer",
"cm_edit_layer",
"cm_copy_layer",
"cm_sel_flip_x",
"cm_sel_flip_y",
"cm_sel_rot_cw",
"cm_sel_rot_ccw",
"cm_sel_free_rot",
"cm_sel_scale",
"cm_sel_move",
"cm_sel_move_to",
"cm_lv_new_tab",
"cm_lv_remove_tab",
"cm_lv_rename_tab",
"cm_lv_hide",
"cm_lv_hide_all",
"cm_lv_show",
"cm_lv_show_all",
"cm_lv_show_only",
"cm_lv_rename",
"cm_lv_select_all",
"cm_lv_delete",
"cm_lv_insert",
"cm_lv_group",
"cm_lv_ungroup",
"cm_lv_source",
"cm_lv_sort_by_name",
"cm_lv_sort_by_ild",
"cm_lv_sort_by_idl",
"cm_lv_sort_by_ldi",
"cm_lv_sort_by_dli",
"cm_lv_regroup_by_index",
"cm_lv_regroup_by_datatype",
"cm_lv_regroup_by_layer",
"cm_lv_regroup_flatten",
"cm_lv_expand_all",
"cm_lv_add_missing",
"cm_lv_remove_unused",
"cm_cell_delete",
"cm_cell_rename",
"cm_cell_copy",
"cm_cell_cut",
"cm_cell_paste",
"cm_cell_select",
"cm_open_current_cell",
"cm_save_current_cell_as",
"cm_cell_hide",
"cm_cell_flatten",
"cm_cell_show",
"cm_cell_show_all",
"cm_navigator_close",
"cm_navigator_freeze"
};
template <unsigned int NUM>
void call_cm_method (lay::MainWindow *mw)
{
tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0]));
mw->menu_activated (cm_symbols [NUM]);
}
template <unsigned int NUM>
gsi::Methods cm_method_decl ()
{
tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0]));
return gsi::method_ext (std::string ("#") + cm_symbols [NUM], &call_cm_method<NUM>,
std::string ("@brief '") + cm_symbols[NUM] + "' action.\n"
"This method is deprecated in version 0.27.\n"
"Use \"call_menu('" + std::string (cm_symbols[NUM]) + "')\" instead.");
}
// NOTE: this avoids an issue with binding: C++ (at least clang
// will resolve lay::MainWindow::menu to lay::Dispatcher::menu,
// the method declaration will be based on "lay::Dispatcher", and
// calling this on a MainWindow object fails, because Dispatcher
// is not the first base class.
static lay::AbstractMenu *menu (lay::MainWindow *mw)
{
return mw->menu ();
}
Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "MainWindow",
// QMainWindow interface
gsi::method ("menu", &lay::MainWindow::menu,
gsi::method_ext ("menu", &menu,
"@brief Returns a reference to the abstract menu\n"
"\n"
"@return A reference to an \\AbstractMenu object representing the menu system"
@ -361,405 +510,138 @@ Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M
"\n"
"This method has been introduced in version 0.26.\n"
) +
gsi::method ("cm_reset_window_state", &lay::MainWindow::cm_reset_window_state,
"@brief 'cm_reset_window_state' action (bound to a menu)"
gsi::method ("call_menu", &lay::MainWindow::menu_activated,
"@brief Calls the menu item with the provided symbol.\n"
"To obtain all symbols, use menu_symbols.\n"
"\n"
"This method has been added in version 0.25.\n"
"This method has been introduced in version 0.27 and replaces the previous cm_... methods. "
"Instead of calling a specific cm_... method, use LayoutView#call_menu with 'cm_...' as the symbol."
) +
gsi::method ("cm_select_all", &lay::MainWindow::cm_select_all,
"@brief 'cm_select_all' action (bound to a menu)"
gsi::method ("menu_symbols", &lay::MainWindow::menu_symbols,
"@brief Gets all available menu symbols (see \\call_menu).\n"
"NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n"
"\n"
"This method has been added in version 0.22.\n"
) +
gsi::method ("cm_unselect_all", &lay::MainWindow::cm_unselect_all,
"@brief 'cm_unselect_all' action (bound to a menu)"
"\n"
"This method has been added in version 0.22.\n"
) +
gsi::method ("cm_undo", &lay::MainWindow::cm_undo,
"@brief 'cm_undo' action (bound to a menu)"
) +
gsi::method ("cm_redo", &lay::MainWindow::cm_redo,
"@brief 'cm_redo' action (bound to a menu)"
) +
gsi::method ("cm_delete", &lay::MainWindow::cm_delete,
"@brief 'cm_delete' action (bound to a menu)"
) +
gsi::method ("cm_show_properties", &lay::MainWindow::cm_show_properties,
"@brief 'cm_show_properties' action (bound to a menu)"
) +
gsi::method ("cm_copy", &lay::MainWindow::cm_copy,
"@brief 'cm_copy' action (bound to a menu)"
) +
gsi::method ("cm_paste", &lay::MainWindow::cm_paste,
"@brief 'cm_paste' action (bound to a menu)"
) +
gsi::method ("cm_cut", &lay::MainWindow::cm_cut,
"@brief 'cm_cut' action (bound to a menu)"
) +
gsi::method ("cm_zoom_fit_sel", &lay::MainWindow::cm_zoom_fit,
"@brief 'cm_zoom_fit_sel' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_zoom_fit", &lay::MainWindow::cm_zoom_fit,
"@brief 'cm_zoom_fit' action (bound to a menu)"
) +
gsi::method ("cm_zoom_in", &lay::MainWindow::cm_zoom_in,
"@brief 'cm_zoom_in' action (bound to a menu)"
) +
gsi::method ("cm_zoom_out", &lay::MainWindow::cm_zoom_out,
"@brief 'cm_zoom_out' action (bound to a menu)"
) +
gsi::method ("cm_pan_up", &lay::MainWindow::cm_pan_up,
"@brief 'cm_pan_up' action (bound to a menu)"
) +
gsi::method ("cm_pan_down", &lay::MainWindow::cm_pan_down,
"@brief 'cm_pan_down' action (bound to a menu)"
) +
gsi::method ("cm_pan_left", &lay::MainWindow::cm_pan_left,
"@brief 'cm_pan_left' action (bound to a menu)"
) +
gsi::method ("cm_pan_right", &lay::MainWindow::cm_pan_right,
"@brief 'cm_pan_right' action (bound to a menu)"
) +
gsi::method ("cm_save_session", &lay::MainWindow::cm_save_session,
"@brief 'cm_save_session' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_restore_session", &lay::MainWindow::cm_restore_session,
"@brief 'cm_restore_session' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_setup", &lay::MainWindow::cm_setup,
"@brief 'cm_setup' action (bound to a menu)"
) +
gsi::method ("cm_save_as", &lay::MainWindow::cm_save_as,
"@brief 'cm_save_as' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_save", &lay::MainWindow::cm_save,
"@brief 'cm_save' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_save_all", &lay::MainWindow::cm_save_all,
"@brief 'cm_save_all' action (bound to a menu)\n"
"This method has been added in version 0.24.\n"
) +
gsi::method ("cm_reload", &lay::MainWindow::cm_reload,
"@brief 'cm_reload' action (bound to a menu)"
) +
gsi::method ("cm_close", &lay::MainWindow::cm_close,
"@brief 'cm_close' action (bound to a menu)"
) +
gsi::method ("cm_close_all", &lay::MainWindow::cm_close_all,
"@brief 'cm_close_all' action (bound to a menu)\n"
"This method has been added in version 0.24.\n"
) +
gsi::method ("cm_clone", &lay::MainWindow::cm_clone,
"@brief 'cm_clone' action (bound to a menu)"
) +
gsi::method ("cm_layout_props", &lay::MainWindow::cm_layout_props,
"@brief 'cm_layout_props' action (bound to a menu)"
) +
gsi::method ("cm_inc_max_hier", &lay::MainWindow::cm_inc_max_hier,
"@brief 'cm_inc_max_hier' action (bound to a menu)"
) +
gsi::method ("cm_dec_max_hier", &lay::MainWindow::cm_dec_max_hier,
"@brief 'cm_dec_max_hier' action (bound to a menu)"
) +
gsi::method ("cm_max_hier", &lay::MainWindow::cm_max_hier,
"@brief 'cm_max_hier' action (bound to a menu)"
) +
gsi::method ("cm_max_hier_0", &lay::MainWindow::cm_max_hier_0,
"@brief 'cm_max_hier_0' action (bound to a menu)"
) +
gsi::method ("cm_max_hier_1", &lay::MainWindow::cm_max_hier_1,
"@brief 'cm_max_hier_1' action (bound to a menu)"
) +
gsi::method ("cm_prev_display_state|#cm_last_display_state", &lay::MainWindow::cm_prev_display_state,
"@brief 'cm_prev_display_state' action (bound to a menu)"
) +
gsi::method ("cm_next_display_state", &lay::MainWindow::cm_next_display_state,
"@brief 'cm_next_display_state' action (bound to a menu)"
) +
gsi::method ("cm_cancel", &lay::MainWindow::cm_cancel,
"@brief 'cm_cancel' action (bound to a menu)"
) +
gsi::method ("cm_redraw", &lay::MainWindow::cm_redraw,
"@brief 'cm_redraw' action (bound to a menu)"
) +
gsi::method ("cm_screenshot", &lay::MainWindow::cm_screenshot,
"@brief 'cm_screenshot' action (bound to a menu)"
) +
gsi::method ("cm_save_layer_props", &lay::MainWindow::cm_save_layer_props,
"@brief 'cm_save_layer_props' action (bound to a menu)"
) +
gsi::method ("cm_load_layer_props", &lay::MainWindow::cm_load_layer_props,
"@brief 'cm_load_layer_props' action (bound to a menu)"
) +
gsi::method ("cm_save_bookmarks", &lay::MainWindow::cm_save_bookmarks,
"@brief 'cm_save_bookmarks' action (bound to a menu)"
) +
gsi::method ("cm_load_bookmarks", &lay::MainWindow::cm_load_bookmarks,
"@brief 'cm_load_bookmarks' action (bound to a menu)"
) +
gsi::method ("cm_select_cell", &lay::MainWindow::cm_select_cell,
"@brief 'cm_select_cell' action (bound to a menu)"
) +
gsi::method ("cm_select_current_cell", &lay::MainWindow::cm_select_current_cell,
"@brief 'cm_select_current_cell' action (bound to a menu)"
) +
gsi::method ("cm_print", &lay::MainWindow::cm_print,
"@brief 'cm_print' action (bound to a menu)\n"
"This method has been added in version 0.21.13."
) +
gsi::method ("cm_exit", &lay::MainWindow::cm_exit,
"@brief 'cm_exit' action (bound to a menu)"
) +
gsi::method ("cm_view_log", &lay::MainWindow::cm_view_log,
"@brief 'cm_view_log' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_bookmark_view", &lay::MainWindow::cm_bookmark_view,
"@brief 'cm_bookmark_view' action (bound to a menu)"
) +
gsi::method ("cm_manage_bookmarks", &lay::MainWindow::cm_manage_bookmarks,
"@brief 'cm_manage_bookmarks' action (bound to a menu)"
) +
gsi::method ("cm_macro_editor", &lay::MainWindow::cm_macro_editor,
"@brief 'cm_macro_editor' action (bound to a menu)"
) +
gsi::method ("cm_goto_position", &lay::MainWindow::cm_goto_position,
"@brief 'cm_goto_position' action (bound to a menu)"
) +
gsi::method ("cm_help_about", &lay::MainWindow::cm_help_about,
"@brief 'cm_help_about' action (bound to a menu)"
) +
gsi::method ("cm_technologies", &lay::MainWindow::cm_technologies,
"@brief 'cm_technologies' action (bound to a menu)"
"\nThis method has been added in version 0.22."
) +
gsi::method ("cm_packages", &lay::MainWindow::cm_packages,
"@brief 'cm_packages' action (bound to a menu)"
"\nThis method has been added in version 0.25."
) +
gsi::method ("cm_open_too", &lay::MainWindow::cm_open_too,
"@brief 'cm_open_too' action (bound to a menu)"
) +
gsi::method ("cm_open_new_view", &lay::MainWindow::cm_open_new_view,
"@brief 'cm_open_new_view' action (bound to a menu)"
) +
gsi::method ("cm_open", &lay::MainWindow::cm_open,
"@brief 'cm_open' action (bound to a menu)"
) +
gsi::method ("cm_pull_in", &lay::MainWindow::cm_pull_in,
"@brief 'cm_pull_in' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_reader_options", &lay::MainWindow::cm_reader_options,
"@brief 'cm_reader_options' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_new_layout", &lay::MainWindow::cm_new_layout,
"@brief 'cm_new_layout' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_new_panel", &lay::MainWindow::cm_new_panel,
"@brief 'cm_new_panel' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_adjust_origin", &lay::MainWindow::cm_adjust_origin,
"@brief 'cm_adjust_origin' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_new_cell", &lay::MainWindow::cm_new_cell,
"@brief 'cm_new_cell' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_new_layer", &lay::MainWindow::cm_new_layer,
"@brief 'cm_new_layer' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_clear_layer", &lay::MainWindow::cm_clear_layer,
"@brief 'cm_clear_layer' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_delete_layer", &lay::MainWindow::cm_delete_layer,
"@brief 'cm_delete_layer' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_edit_layer", &lay::MainWindow::cm_edit_layer,
"@brief 'cm_edit_layer' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_copy_layer", &lay::MainWindow::cm_copy_layer,
"@brief 'cm_copy_layer' action (bound to a menu)"
"\nThis method has been added in version 0.22."
) +
gsi::method ("cm_sel_flip_x", &lay::MainWindow::cm_sel_flip_x,
"@brief 'cm_sel_flip_x' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_flip_y", &lay::MainWindow::cm_sel_flip_y,
"@brief 'cm_sel_flip_y' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_rot_cw", &lay::MainWindow::cm_sel_rot_cw,
"@brief 'cm_sel_rot_cw' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_rot_ccw", &lay::MainWindow::cm_sel_rot_ccw,
"@brief 'cm_sel_rot_ccw' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_free_rot", &lay::MainWindow::cm_sel_free_rot,
"@brief 'cm_sel_free_rot' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_scale", &lay::MainWindow::cm_sel_scale,
"@brief 'cm_sel_scale' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_move", &lay::MainWindow::cm_sel_move,
"@brief 'cm_sel_move' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_sel_move_to", &lay::MainWindow::cm_sel_move_to,
"@brief 'cm_sel_move_to' action (bound to a menu)"
"\nThis method has been added in version 0.24."
) +
gsi::method ("cm_lv_new_tab", &lay::MainWindow::cm_lv_new_tab,
"@brief 'cm_lv_new_tab' action (bound to a menu)"
) +
gsi::method ("cm_lv_remove_tab", &lay::MainWindow::cm_lv_remove_tab,
"@brief 'cm_lv_remove_tab' action (bound to a menu)"
) +
gsi::method ("cm_lv_rename_tab", &lay::MainWindow::cm_lv_rename_tab,
"@brief 'cm_lv_rename_tab' action (bound to a menu)"
) +
gsi::method ("cm_lv_hide", &lay::MainWindow::cm_lv_hide,
"@brief 'cm_lv_hide' action (bound to a menu)"
) +
gsi::method ("cm_lv_hide_all", &lay::MainWindow::cm_lv_hide_all,
"@brief 'cm_lv_hide_all' action (bound to a menu)"
) +
gsi::method ("cm_lv_show", &lay::MainWindow::cm_lv_show,
"@brief 'cm_lv_show' action (bound to a menu)"
) +
gsi::method ("cm_lv_show_all", &lay::MainWindow::cm_lv_show_all,
"@brief 'cm_lv_show_all' action (bound to a menu)"
) +
gsi::method ("cm_lv_show_only", &lay::MainWindow::cm_lv_show_only,
"@brief 'cm_lv_show_only' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_lv_rename", &lay::MainWindow::cm_lv_rename,
"@brief 'cm_lv_rename' action (bound to a menu)"
) +
gsi::method ("cm_lv_select_all", &lay::MainWindow::cm_lv_select_all,
"@brief 'cm_lv_select_all' action (bound to a menu)"
) +
gsi::method ("cm_lv_delete", &lay::MainWindow::cm_lv_delete,
"@brief 'cm_lv_delete' action (bound to a menu)"
) +
gsi::method ("cm_lv_insert", &lay::MainWindow::cm_lv_insert,
"@brief 'cm_lv_insert' action (bound to a menu)"
) +
gsi::method ("cm_lv_group", &lay::MainWindow::cm_lv_group,
"@brief 'cm_lv_group' action (bound to a menu)"
) +
gsi::method ("cm_lv_ungroup", &lay::MainWindow::cm_lv_ungroup,
"@brief 'cm_lv_ungroup' action (bound to a menu)"
) +
gsi::method ("cm_lv_source", &lay::MainWindow::cm_lv_source,
"@brief 'cm_lv_source' action (bound to a menu)"
) +
gsi::method ("cm_lv_sort_by_name", &lay::MainWindow::cm_lv_sort_by_name,
"@brief 'cm_lv_sort_by_name' action (bound to a menu)"
) +
gsi::method ("cm_lv_sort_by_ild", &lay::MainWindow::cm_lv_sort_by_ild,
"@brief 'cm_lv_sort_by_ild' action (bound to a menu)"
) +
gsi::method ("cm_lv_sort_by_idl", &lay::MainWindow::cm_lv_sort_by_idl,
"@brief 'cm_lv_sort_by_idl' action (bound to a menu)"
) +
gsi::method ("cm_lv_sort_by_ldi", &lay::MainWindow::cm_lv_sort_by_ldi,
"@brief 'cm_lv_sort_by_ldi' action (bound to a menu)"
) +
gsi::method ("cm_lv_sort_by_dli", &lay::MainWindow::cm_lv_sort_by_dli,
"@brief 'cm_lv_sort_by_dli' action (bound to a menu)"
) +
gsi::method ("cm_lv_regroup_by_index", &lay::MainWindow::cm_lv_regroup_by_index,
"@brief 'cm_lv_regroup_by_index' action (bound to a menu)"
) +
gsi::method ("cm_lv_regroup_by_datatype", &lay::MainWindow::cm_lv_regroup_by_datatype,
"@brief 'cm_lv_regroup_by_datatype' action (bound to a menu)"
) +
gsi::method ("cm_lv_regroup_by_layer", &lay::MainWindow::cm_lv_regroup_by_layer,
"@brief 'cm_lv_regroup_by_layer' action (bound to a menu)"
) +
gsi::method ("cm_lv_regroup_flatten", &lay::MainWindow::cm_lv_regroup_flatten,
"@brief 'cm_lv_regroup_flatten' action (bound to a menu)"
) +
gsi::method ("cm_lv_expand_all", &lay::MainWindow::cm_lv_expand_all,
"@brief 'cm_lv_expand_all' action (bound to a menu)"
) +
gsi::method ("cm_lv_add_missing", &lay::MainWindow::cm_lv_add_missing,
"@brief 'cm_lv_add_missing' action (bound to a menu)"
) +
gsi::method ("cm_lv_remove_unused", &lay::MainWindow::cm_lv_remove_unused,
"@brief 'cm_lv_remove_unused' action (bound to a menu)"
) +
gsi::method ("cm_cell_delete", &lay::MainWindow::cm_cell_delete,
"@brief 'cm_cell_delete' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_cell_rename", &lay::MainWindow::cm_cell_rename,
"@brief 'cm_cell_rename' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_cell_copy", &lay::MainWindow::cm_cell_copy,
"@brief 'cm_cell_copy' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_cell_cut", &lay::MainWindow::cm_cell_cut,
"@brief 'cm_cell_cut' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_cell_paste", &lay::MainWindow::cm_cell_paste,
"@brief 'cm_cell_paste' action (bound to a menu)"
"\nThis method has been added in version 0.20."
) +
gsi::method ("cm_cell_select", &lay::MainWindow::cm_cell_select,
"@brief 'cm_cell_select' action (bound to a menu)"
) +
gsi::method ("cm_open_current_cell", &lay::MainWindow::cm_open_current_cell,
"@brief 'cm_open_current_cell' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_save_current_cell_as", &lay::MainWindow::cm_save_current_cell_as,
"@brief 'cm_save_current_cell_as' action (bound to a menu)"
"\nThis method has been added in version 0.18."
) +
gsi::method ("cm_cell_hide", &lay::MainWindow::cm_cell_hide,
"@brief 'cm_cell_hide' action (bound to a menu)"
) +
gsi::method ("cm_cell_flatten", &lay::MainWindow::cm_cell_flatten,
"@brief 'cm_cell_flatten' action (bound to a menu)"
) +
gsi::method ("cm_cell_show", &lay::MainWindow::cm_cell_show,
"@brief 'cm_cell_show' action (bound to a menu)"
) +
gsi::method ("cm_cell_show_all", &lay::MainWindow::cm_cell_show_all,
"@brief 'cm_cell_show_all' action (bound to a menu)"
) +
gsi::method ("cm_navigator_close", &lay::MainWindow::cm_navigator_close,
"@brief 'cm_navigator_close' action (bound to a menu)"
) +
gsi::method ("cm_navigator_freeze", &lay::MainWindow::cm_navigator_freeze,
"@brief 'cm_navigator_freeze' action (bound to a menu)"
),
"This method has been introduced in version 0.27."
) +
// backward compatibility (cm_... methods, deprecated)
cm_method_decl<0> () +
cm_method_decl<1> () +
cm_method_decl<2> () +
cm_method_decl<3> () +
cm_method_decl<4> () +
cm_method_decl<5> () +
cm_method_decl<6> () +
cm_method_decl<7> () +
cm_method_decl<8> () +
cm_method_decl<9> () +
cm_method_decl<10> () +
cm_method_decl<11> () +
cm_method_decl<12> () +
cm_method_decl<13> () +
cm_method_decl<14> () +
cm_method_decl<15> () +
cm_method_decl<16> () +
cm_method_decl<17> () +
cm_method_decl<18> () +
cm_method_decl<19> () +
cm_method_decl<20> () +
cm_method_decl<21> () +
cm_method_decl<22> () +
cm_method_decl<23> () +
cm_method_decl<24> () +
cm_method_decl<25> () +
cm_method_decl<26> () +
cm_method_decl<27> () +
cm_method_decl<28> () +
cm_method_decl<29> () +
cm_method_decl<30> () +
cm_method_decl<31> () +
cm_method_decl<32> () +
cm_method_decl<33> () +
cm_method_decl<34> () +
cm_method_decl<35> () +
cm_method_decl<36> () +
cm_method_decl<37> () +
cm_method_decl<38> () +
cm_method_decl<39> () +
cm_method_decl<40> () +
cm_method_decl<41> () +
cm_method_decl<42> () +
cm_method_decl<43> () +
cm_method_decl<44> () +
cm_method_decl<45> () +
cm_method_decl<46> () +
cm_method_decl<47> () +
cm_method_decl<48> () +
cm_method_decl<49> () +
cm_method_decl<50> () +
cm_method_decl<51> () +
cm_method_decl<52> () +
cm_method_decl<53> () +
cm_method_decl<54> () +
cm_method_decl<55> () +
cm_method_decl<56> () +
cm_method_decl<57> () +
cm_method_decl<58> () +
cm_method_decl<59> () +
cm_method_decl<60> () +
cm_method_decl<61> () +
cm_method_decl<62> () +
cm_method_decl<63> () +
cm_method_decl<64> () +
cm_method_decl<65> () +
cm_method_decl<66> () +
cm_method_decl<67> () +
cm_method_decl<68> () +
cm_method_decl<69> () +
cm_method_decl<70> () +
cm_method_decl<71> () +
cm_method_decl<72> () +
cm_method_decl<73> () +
cm_method_decl<74> () +
cm_method_decl<75> () +
cm_method_decl<76> () +
cm_method_decl<77> () +
cm_method_decl<78> () +
cm_method_decl<79> () +
cm_method_decl<80> () +
cm_method_decl<81> () +
cm_method_decl<82> () +
cm_method_decl<83> () +
cm_method_decl<84> () +
cm_method_decl<85> () +
cm_method_decl<86> () +
cm_method_decl<87> () +
cm_method_decl<88> () +
cm_method_decl<89> () +
cm_method_decl<90> () +
cm_method_decl<91> () +
cm_method_decl<92> () +
cm_method_decl<93> () +
cm_method_decl<94> () +
cm_method_decl<95> () +
cm_method_decl<96> () +
cm_method_decl<97> () +
cm_method_decl<98> () +
cm_method_decl<99> () +
cm_method_decl<100> () +
cm_method_decl<101> () +
cm_method_decl<102> () +
cm_method_decl<103> () +
cm_method_decl<104> () +
cm_method_decl<105> () +
cm_method_decl<106> () +
cm_method_decl<107> () +
cm_method_decl<108> () +
cm_method_decl<109> () +
cm_method_decl<110> () +
cm_method_decl<111> () +
cm_method_decl<112> () +
cm_method_decl<113> () +
cm_method_decl<114> () +
cm_method_decl<115> () +
cm_method_decl<116> () +
cm_method_decl<117> (),
"@brief The main application window and central controller object\n"
"\n"
"This object first is the main window but also the main controller. The main controller "

View File

@ -15,7 +15,6 @@ HEADERS = \
layHelpDialog.h \
layHelpProvider.h \
layHelpSource.h \
layLayoutStatisticsForm.h \
layLogViewerDialog.h \
layMacroEditorDialog.h \
layMacroEditorPage.h \
@ -32,7 +31,6 @@ HEADERS = \
laySearchReplaceConfigPage.h \
laySearchReplaceDialog.h \
laySearchReplacePropertiesWidgets.h \
laySelectCellViewForm.h \
laySession.h \
laySettingsForm.h \
layTechSetupDialog.h \
@ -68,7 +66,6 @@ FORMS = \
DeleteModeDialog.ui \
FillDialog.ui \
HelpAboutDialog.ui \
LayoutStatistics.ui \
LogViewerDialog.ui \
MacroEditorDialog.ui \
MacroPropertiesDialog.ui \
@ -122,7 +119,6 @@ SOURCES = \
layHelpDialog.cc \
layHelpProvider.cc \
layHelpSource.cc \
layLayoutStatisticsForm.cc \
layLogViewerDialog.cc \
layMacroEditorDialog.cc \
layMacroEditorPage.cc \

View File

@ -605,7 +605,7 @@ ApplicationBase::init_app ()
bool editable_from_config = false;
{
lay::PluginRoot cfg;
lay::Dispatcher cfg (0);
for (std::vector <std::string>::const_iterator c = m_config_files.begin (); c != m_config_files.end (); ++c) {
try {
@ -731,7 +731,6 @@ ApplicationBase::init_app ()
}
db::set_default_editable_mode (m_editable);
db::enable_transactions (m_enable_undo);
if (! m_gtf_record.empty ()) {
// since the recorder tracks QAction connections etc., it must be instantiated before every other
@ -771,11 +770,11 @@ ApplicationBase::init_app ()
if (tl::verbosity () >= 20) {
tl::info << " " << cls.current_name () << " [" << cls.current_position () << "]";
}
pd->initialize (plugin_root ());
pd->initialize (dispatcher ());
}
// establish the configuration
plugin_root ()->config_setup ();
dispatcher ()->config_setup ();
// Some info output
if (tl::verbosity () >= 20) {
@ -863,7 +862,7 @@ ApplicationBase::exit (int result)
// uninitialize the plugins
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->uninitialize (plugin_root ());
pd->uninitialize (dispatcher ());
}
shutdown ();
@ -874,13 +873,13 @@ ApplicationBase::exit (int result)
void
ApplicationBase::finish ()
{
if (plugin_root () && m_write_config_file) {
if (dispatcher () && m_write_config_file) {
if (! m_config_file_to_write.empty ()) {
if (tl::verbosity () >= 20) {
tl::info << tl::to_string (QObject::tr ("Updating configuration file ")) << m_config_file_to_write;
}
plugin_root ()->write_config (m_config_file_to_write);
dispatcher ()->write_config (m_config_file_to_write);
}
if (! m_config_file_to_delete.empty () && m_config_file_to_delete != m_config_file_to_write) {
if (tl::verbosity () >= 20) {
@ -1009,7 +1008,7 @@ ApplicationBase::run ()
for (std::vector <std::string>::const_iterator c = m_config_files.begin (); c != m_config_files.end (); ++c) {
BEGIN_PROTECTED_CLEANUP
plugin_root ()->read_config (*c);
dispatcher ()->read_config (*c);
// if the last config was read successfully no reset will happen:
config_failed = false;
END_PROTECTED_CLEANUP {
@ -1131,7 +1130,7 @@ ApplicationBase::run ()
// Give the plugins a change to do some last-minute initialisation and checks
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->initialized (plugin_root ());
pd->initialized (dispatcher ());
}
if (! m_no_gui && m_gtf_replay.empty () && m_gtf_record.empty ()) {
@ -1139,12 +1138,12 @@ ApplicationBase::run ()
mw->about_to_exec ();
}
} else if (plugin_root ()) {
} else if (dispatcher ()) {
// Give the plugins a change to do some last-minute initialisation and checks
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->initialized (plugin_root ());
pd->initialized (dispatcher ());
}
}
@ -1219,7 +1218,7 @@ ApplicationBase::process_events_impl (QEventLoop::ProcessEventsFlags /*flags*/,
bool
ApplicationBase::write_config (const std::string &config_file)
{
return plugin_root () ? plugin_root ()->write_config (config_file) : 0;
return dispatcher () ? dispatcher ()->write_config (config_file) : 0;
}
void
@ -1236,38 +1235,38 @@ ApplicationBase::reset_config ()
void
ApplicationBase::clear_config ()
{
if (plugin_root ()) {
plugin_root ()->clear_config ();
if (dispatcher ()) {
dispatcher ()->clear_config ();
}
}
bool
ApplicationBase::read_config (const std::string &config_file)
{
return plugin_root () ? plugin_root ()->read_config (config_file) : true;
return dispatcher () ? dispatcher ()->read_config (config_file) : true;
}
void
ApplicationBase::set_config (const std::string &name, const std::string &value)
{
if (plugin_root ()) {
plugin_root ()->config_set (name, value);
if (dispatcher ()) {
dispatcher ()->config_set (name, value);
}
}
void
ApplicationBase::config_end ()
{
if (plugin_root ()) {
plugin_root ()->config_end ();
if (dispatcher ()) {
dispatcher ()->config_end ();
}
}
std::string
ApplicationBase::get_config (const std::string &name) const
{
if (plugin_root ()) {
return plugin_root ()->config_get (name);
if (dispatcher ()) {
return dispatcher ()->config_get (name);
} else {
return std::string ();
}
@ -1277,8 +1276,8 @@ std::vector<std::string>
ApplicationBase::get_config_names () const
{
std::vector<std::string> names;
if (plugin_root ()) {
plugin_root ()->get_config_names (names);
if (dispatcher ()) {
dispatcher ()->get_config_names (names);
}
return names;
}
@ -1289,7 +1288,6 @@ ApplicationBase::get_config_names () const
GuiApplication::GuiApplication (int &argc, char **argv)
: QApplication (argc, argv), ApplicationBase (false),
mp_mw (0),
mp_plugin_root (0),
mp_recorder (0)
{
// install a special style proxy to overcome the issue of black-on-black tree expanders
@ -1306,13 +1304,10 @@ GuiApplication::~GuiApplication ()
// uninitialize the plugins
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->uninitialize (plugin_root ());
pd->uninitialize (dispatcher ());
}
shutdown ();
delete mp_plugin_root;
mp_plugin_root = 0;
}
bool
@ -1409,6 +1404,14 @@ GuiApplication::exec ()
void
GuiApplication::shutdown ()
{
// avoid deferred execution later on where there isn't a valid main window anymore
// (problem case: showing a dialog inside main windows's destroyed signal - this will
// process events and trigger execution if not disabled)
if (! tl::DeferredMethodScheduler::instance ()->is_disabled ()) {
tl::DeferredMethodScheduler::instance ()->execute ();
}
tl::DeferredMethodScheduler::instance ()->enable (false);
if (mp_mw) {
delete mp_mw;
mp_mw = 0;
@ -1465,20 +1468,18 @@ GuiApplication::start_recording ()
}
}
lay::PluginRoot *
GuiApplication::plugin_root () const
lay::Dispatcher *
GuiApplication::dispatcher () const
{
return mp_plugin_root;
return mp_mw;
}
void
GuiApplication::setup ()
{
tl_assert (mp_mw == 0 && mp_plugin_root == 0);
tl_assert (mp_mw == 0);
mp_plugin_root = new lay::PluginRootToMainWindow ();
mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window");
mp_plugin_root->attach_to (mp_mw);
mp_mw = new lay::MainWindow (this, 0, "main_window", is_undo_enabled ());
QObject::connect (mp_mw, SIGNAL (closed ()), this, SLOT (quit ()));
@ -1522,7 +1523,7 @@ NonGuiApplication::NonGuiApplication (int &argc, char **argv)
: QCoreApplication (argc, argv), ApplicationBase (true),
mp_pr (0),
mp_pb (0),
mp_plugin_root (0)
mp_dispatcher (0)
{
// .. nothing yet ..
}
@ -1532,7 +1533,7 @@ NonGuiApplication::~NonGuiApplication ()
// uninitialize the plugins
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->uninitialize (plugin_root ());
pd->uninitialize (dispatcher ());
}
shutdown ();
@ -1548,9 +1549,9 @@ NonGuiApplication::exec ()
void
NonGuiApplication::shutdown ()
{
if (mp_plugin_root) {
delete mp_plugin_root;
mp_plugin_root = 0;
if (mp_dispatcher) {
delete mp_dispatcher;
mp_dispatcher = 0;
}
if (mp_pr) {
@ -1572,7 +1573,7 @@ NonGuiApplication::setup ()
mp_pr = new lay::ProgressReporter ();
mp_pb = new TextProgress (10 /*verbosity level*/);
mp_pr->set_progress_bar (mp_pb);
mp_plugin_root = new lay::PluginRoot ();
mp_dispatcher = new lay::Dispatcher (0);
}
}

View File

@ -57,8 +57,7 @@ namespace lay
{
class MainWindow;
class PluginRootToMainWindow;
class PluginRoot;
class Dispatcher;
class ProgressReporter;
class ProgressBar;
@ -311,7 +310,7 @@ protected:
virtual void shutdown ();
virtual void prepare_recording (const std::string &gtf_record, bool gtf_record_incremental);
virtual void start_recording ();
virtual lay::PluginRoot *plugin_root () const = 0;
virtual lay::Dispatcher *dispatcher () const = 0;
virtual void finish ();
virtual void process_events_impl (QEventLoop::ProcessEventsFlags flags, bool silent = false);
@ -431,11 +430,10 @@ protected:
virtual void start_recording ();
virtual void process_events_impl (QEventLoop::ProcessEventsFlags flags, bool silent);
virtual lay::PluginRoot *plugin_root () const;
virtual lay::Dispatcher *dispatcher () const;
private:
MainWindow *mp_mw;
PluginRootToMainWindow *mp_plugin_root;
gtf::Recorder *mp_recorder;
};
@ -483,15 +481,15 @@ protected:
virtual void setup ();
virtual void shutdown ();
virtual lay::PluginRoot *plugin_root () const
virtual lay::Dispatcher *dispatcher () const
{
return mp_plugin_root;
return mp_dispatcher;
}
private:
lay::ProgressReporter *mp_pr;
lay::ProgressBar *mp_pb;
lay::PluginRoot *mp_plugin_root;
lay::Dispatcher *mp_dispatcher;
};
} // namespace lay

View File

@ -52,10 +52,10 @@ public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool"))));
menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new ClipDialog (root, view);
}
@ -66,7 +66,7 @@ static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new ClipDialogPl
// ------------------------------------------------------------
ClipDialog::ClipDialog (lay::PluginRoot *root, lay::LayoutView *vw)
ClipDialog::ClipDialog (lay::Dispatcher *root, lay::LayoutView *vw)
: lay::Browser (root, vw),
Ui::ClipDialog ()
{

View File

@ -40,7 +40,7 @@ class ClipDialog
Q_OBJECT
public:
ClipDialog (lay::PluginRoot *root, lay::LayoutView *view);
ClipDialog (lay::Dispatcher *root, lay::LayoutView *view);
~ClipDialog ();
public slots:

View File

@ -59,10 +59,10 @@ public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool"))));
menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new FillDialog (root, view);
}
@ -73,7 +73,7 @@ static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new FillDialogPl
// ------------------------------------------------------------
FillDialog::FillDialog (lay::PluginRoot *main, lay::LayoutView *view)
FillDialog::FillDialog (lay::Dispatcher *main, lay::LayoutView *view)
: QDialog (view),
lay::Plugin (main),
Ui::FillDialog (),

View File

@ -43,7 +43,7 @@ class FillDialog
Q_OBJECT
public:
FillDialog (lay::PluginRoot *root, lay::LayoutView *view);
FillDialog (lay::Dispatcher *root, lay::LayoutView *view);
~FillDialog ();
public slots:

View File

@ -40,7 +40,7 @@ FontController::FontController ()
}
void
FontController::initialize (lay::PluginRoot * /*root*/)
FontController::initialize (lay::Dispatcher * /*root*/)
{
// NOTE: we initialize the dirs in the stage once to have them available for the autorun
// macros. We'll do that later again in order to pull in the dirs from the packages.
@ -48,7 +48,7 @@ FontController::initialize (lay::PluginRoot * /*root*/)
}
void
FontController::initialized (lay::PluginRoot * /*root*/)
FontController::initialized (lay::Dispatcher * /*root*/)
{
if (lay::SaltController::instance ()) {
connect (lay::SaltController::instance (), SIGNAL (salt_changed ()), this, SLOT (sync_with_external_sources ()));
@ -64,7 +64,7 @@ FontController::initialized (lay::PluginRoot * /*root*/)
}
void
FontController::uninitialize (lay::PluginRoot * /*root*/)
FontController::uninitialize (lay::Dispatcher * /*root*/)
{
if (m_file_watcher) {
disconnect (m_file_watcher, SIGNAL (fileChanged (const QString &)), this, SLOT (file_watcher_triggered ()));
@ -103,7 +103,7 @@ FontController::config_finalize()
}
bool
FontController::can_exit (lay::PluginRoot * /*root*/) const
FontController::can_exit (lay::Dispatcher * /*root*/) const
{
// .. nothing yet ..
return true;

View File

@ -65,17 +65,17 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialize (lay::PluginRoot *root);
virtual void initialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialized (lay::PluginRoot *root);
virtual void initialized (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void uninitialize (lay::PluginRoot *root);
virtual void uninitialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
@ -100,7 +100,7 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
bool can_exit (lay::PluginRoot *root) const;
bool can_exit (lay::Dispatcher *root) const;
/**
* @brief Gets the singleton instance for this object

View File

@ -825,7 +825,12 @@ method_arguments (const gsi::MethodBase *method, const gsi::ClassBase *cls_obj,
if (! a->spec ()->init_doc ().empty ()) {
r += replace_references (escape_xml (a->spec ()->init_doc ()), cls_obj);
} else {
r += escape_xml (a->spec ()->default_value ().to_string ());
try {
r += escape_xml (a->spec ()->default_value ().to_string ());
} catch (tl::Exception &ex) {
tl::error << cls_obj->name () << "#" << method->begin_synonyms ()->name << ": " << ex.msg ();
r += "?";
}
}
}
} else if (n < int (doc.args.size ())) {
@ -1339,11 +1344,11 @@ GSIHelpProvider::produce_class_doc (const std::string &cls) const
os << "<p>" << tl::to_string (QObject::tr ("Use of this method is deprecated")) << "</p>" << std::endl;
}
} else {
std::string dh = method_doc.doc;
if (! tl::Extractor (dh.c_str ()).at_end ()) {
os << "<p>" << replace_references (method_doc.doc_html (), cls_obj) << "</p>" << std::endl;
}
}
std::string dh = method_doc.doc;
if (! tl::Extractor (dh.c_str ()).at_end ()) {
os << "<p>" << replace_references (method_doc.doc_html (), cls_obj) << "</p>" << std::endl;
}
if (! pydoc.empty ()) {

View File

@ -45,7 +45,7 @@ LibraryController::LibraryController ()
}
void
LibraryController::initialize (lay::PluginRoot * /*root*/)
LibraryController::initialize (lay::Dispatcher * /*root*/)
{
// NOTE: we initialize the libraries in the stage once to have them available for the autorun
// macros. We'll do that later again in order to pull in the libraries from the packages.
@ -53,7 +53,7 @@ LibraryController::initialize (lay::PluginRoot * /*root*/)
}
void
LibraryController::initialized (lay::PluginRoot * /*root*/)
LibraryController::initialized (lay::Dispatcher * /*root*/)
{
if (lay::SaltController::instance ()) {
connect (lay::SaltController::instance (), SIGNAL (salt_changed ()), this, SLOT (sync_with_external_sources ()));
@ -69,7 +69,7 @@ LibraryController::initialized (lay::PluginRoot * /*root*/)
}
void
LibraryController::uninitialize (lay::PluginRoot * /*root*/)
LibraryController::uninitialize (lay::Dispatcher * /*root*/)
{
if (m_file_watcher) {
disconnect (m_file_watcher, SIGNAL (fileChanged (const QString &)), this, SLOT (file_watcher_triggered ()));
@ -108,7 +108,7 @@ LibraryController::config_finalize()
}
bool
LibraryController::can_exit (lay::PluginRoot * /*root*/) const
LibraryController::can_exit (lay::Dispatcher * /*root*/) const
{
// .. nothing yet ..
return true;

View File

@ -65,17 +65,17 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialize (lay::PluginRoot *root);
virtual void initialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialized (lay::PluginRoot *root);
virtual void initialized (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void uninitialize (lay::PluginRoot *root);
virtual void uninitialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
@ -100,7 +100,7 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
bool can_exit (lay::PluginRoot *root) const;
bool can_exit (lay::Dispatcher *root) const;
/**
* @brief Gets the singleton instance for this object

View File

@ -169,7 +169,7 @@ MacroController::finish ()
}
void
MacroController::initialized (lay::PluginRoot *root)
MacroController::initialized (lay::Dispatcher *root)
{
connect (&m_temp_macros, SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
connect (&m_temp_macros, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
@ -205,7 +205,7 @@ MacroController::initialized (lay::PluginRoot *root)
}
void
MacroController::uninitialize (lay::PluginRoot * /*root*/)
MacroController::uninitialize (lay::Dispatcher * /*root*/)
{
disconnect (&lym::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
disconnect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
@ -247,7 +247,7 @@ MacroController::config_finalize()
}
bool
MacroController::can_exit (lay::PluginRoot * /*root*/) const
MacroController::can_exit (lay::Dispatcher * /*root*/) const
{
if (mp_macro_editor) {
return mp_macro_editor->can_exit ();
@ -666,6 +666,40 @@ static std::string menu_name (std::set<std::string> &used_names, const std::stri
return name;
}
namespace {
class RunMacroAction
: public lay::Action
{
public:
RunMacroAction (lym::Macro *lym)
: lay::Action (), mp_lym (lym)
{
if (lym->description ().empty ()) {
set_title (lym->path ());
} else {
set_title (lym->description ());
}
}
void triggered ()
{
if (mp_lym.get ()) {
mp_lym->run ();
}
}
lym::Macro *macro () const
{
return const_cast<lym::Macro *> (mp_lym.get ());
}
private:
tl::weak_ptr<lym::Macro> mp_lym;
};
}
void
MacroController::add_macro_items_to_menu (lym::MacroCollection &collection, std::set<std::string> &used_names, std::set<std::string> &groups, const db::Technology *tech)
{
@ -702,62 +736,32 @@ MacroController::add_macro_items_to_menu (lym::MacroCollection &collection, std:
std::string gn = tl::trim (c->second->group_name ());
if (! gn.empty () && groups.find (gn) == groups.end ()) {
groups.insert (gn);
lay::Action as;
as.set_separator (true);
lay::Action *as = new lay::Action ();
as->set_separator (true);
m_macro_actions.push_back (as);
mp_mw->menu ()->insert_item (mp, menu_name (used_names, std::string ()), as);
}
lay::Action a;
if (c->second->description ().empty ()) {
a.set_title (c->second->path ());
} else {
a.set_title (c->second->description ());
}
a.set_default_shortcut (sc);
lay::Action *a = new RunMacroAction (c->second);
a->set_default_shortcut (sc);
m_macro_actions.push_back (a);
mp_mw->menu ()->insert_item (mp, menu_name (used_names, c->second->name ()), a);
m_action_to_macro.insert (std::make_pair (a.qaction (), c->second));
lym::MacroSignalAdaptor *adaptor = new lym::MacroSignalAdaptor (a.qaction (), c->second);
QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ()));
} else if (! sc.empty ()) {
// Create actions for shortcut-only actions too and add them to the main window
// to register their shortcut.
lay::Action a;
if (c->second->description ().empty ()) {
a.set_title (c->second->path ());
} else {
a.set_title (c->second->description ());
}
a.set_shortcut (sc);
lay::Action *a = new RunMacroAction (c->second);
a->set_shortcut (sc);
m_macro_actions.push_back (a);
mp_mw->addAction (a.qaction ());
lym::MacroSignalAdaptor *adaptor = new lym::MacroSignalAdaptor (a.qaction (), c->second);
QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ()));
mp_mw->addAction (a->qaction ());
}
}
}
lym::Macro *
MacroController::macro_for_action (const lay::Action *action)
{
if (action) {
std::map<QAction *, lym::Macro *>::const_iterator a2m = m_action_to_macro.find (action->qaction ());
if (a2m != m_action_to_macro.end ()) {
return a2m->second;
}
}
return 0;
}
void
MacroController::sync_with_external_sources ()
{
@ -778,7 +782,6 @@ void
MacroController::macro_collection_changed ()
{
// empty action to macro table now we know it's invalid
m_action_to_macro.clear ();
dm_do_update_menu_with_macros ();
dm_sync_file_watcher ();
}
@ -796,11 +799,16 @@ MacroController::do_update_menu_with_macros ()
}
// delete all existing items
for (std::vector<lay::Action>::iterator a = m_macro_actions.begin (); a != m_macro_actions.end (); ++a) {
std::vector<lay::Action *> actions;
for (tl::weak_collection<lay::Action>::iterator a = m_macro_actions.begin (); a != m_macro_actions.end (); ++a) {
if (a.operator-> ()) {
actions.push_back (a.operator-> ());
}
}
for (std::vector<lay::Action *>::const_iterator a = actions.begin (); a != actions.end (); ++a) {
mp_mw->menu ()->delete_items (*a);
}
m_macro_actions.clear ();
m_action_to_macro.clear ();
std::set<std::string> groups;
std::set<std::string> used_names;
@ -810,16 +818,16 @@ MacroController::do_update_menu_with_macros ()
// apply the custom keyboard shortcuts
for (std::vector<std::pair<std::string, std::string> >::const_iterator kb = m_key_bindings.begin (); kb != m_key_bindings.end (); ++kb) {
if (mp_mw->menu ()->is_valid (kb->first)) {
lay::Action a = mp_mw->menu ()->action (kb->first);
a.set_shortcut (kb->second);
lay::Action *a = mp_mw->menu ()->action (kb->first);
a->set_shortcut (kb->second);
}
}
// apply the custom hidden flags
for (std::vector<std::pair<std::string, bool> >::const_iterator hf = m_menu_items_hidden.begin (); hf != m_menu_items_hidden.end (); ++hf) {
if (mp_mw->menu ()->is_valid (hf->first)) {
lay::Action a = mp_mw->menu ()->action (hf->first);
a.set_hidden (hf->second);
lay::Action *a = mp_mw->menu ()->action (hf->first);
a->set_hidden (hf->second);
}
}
}
@ -876,7 +884,8 @@ static tl::RegisteredClass<lay::PluginDeclaration> macro_controller_decl (new la
static lym::Macro *macro_for_action (const lay::Action *action)
{
return MacroController::instance () ? MacroController::instance ()->macro_for_action (action) : 0;
const RunMacroAction *rma = dynamic_cast<const RunMacroAction *> (action);
return rma ? rma->macro () : 0;
}
// extend lay::Action with the ability to associate a macro with it

View File

@ -89,12 +89,12 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialized (lay::PluginRoot *root);
virtual void initialized (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void uninitialize (lay::PluginRoot *root);
virtual void uninitialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
@ -109,7 +109,7 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual bool can_exit (lay::PluginRoot *root) const;
virtual bool can_exit (lay::Dispatcher *root) const;
/**
* @brief Gets a value indicating whether the plugin will accept a dropped file with the given URL or path
@ -162,11 +162,6 @@ public:
*/
void add_temp_macro (lym::Macro *m);
/**
* @brief Gets the macro associated with an Action or nil if there is none
*/
lym::Macro *macro_for_action (const lay::Action *action);
/**
* @brief Obtain the list of macro categories
*/
@ -236,8 +231,7 @@ private:
lay::MacroEditorDialog *mp_macro_editor;
lay::MainWindow *mp_mw;
bool m_no_implicit_macros;
std::vector<lay::Action> m_macro_actions;
std::map<QAction *, lym::Macro *> m_action_to_macro;
tl::weak_collection<lay::Action> m_macro_actions;
lym::MacroCollection m_temp_macros;
std::vector<MacroCategory> m_macro_categories;
std::vector<InternalPathDescriptor> m_internal_paths;

View File

@ -228,7 +228,7 @@ public:
static lay::MacroEditorDialog *s_macro_editor_instance = 0;
MacroEditorDialog::MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection *root)
MacroEditorDialog::MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection *root)
: QDialog (0 /*show as individual top widget*/, Qt::Window),
lay::Plugin (pr, true),
mp_plugin_root (pr),
@ -2309,7 +2309,7 @@ MacroEditorDialog::ensure_writeable_collection_selected ()
}
static std::vector<std::pair<std::string, std::string> >
get_custom_paths (lay::PluginRoot *root)
get_custom_paths (lay::Dispatcher *root)
{
std::vector <std::pair<std::string, std::string> > paths;
@ -2337,7 +2337,7 @@ get_custom_paths (lay::PluginRoot *root)
}
static void
set_custom_paths (lay::PluginRoot *root, const std::vector<std::pair<std::string, std::string> > &paths)
set_custom_paths (lay::Dispatcher *root, const std::vector<std::pair<std::string, std::string> > &paths)
{
std::string mp;

View File

@ -98,7 +98,7 @@ public:
/**
* @brief Constructor
*/
MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection *root);
MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection *root);
/**
* @brief Destructor
@ -291,7 +291,7 @@ private:
bool configure (const std::string &name, const std::string &value);
void config_finalize ();
lay::PluginRoot *mp_plugin_root;
lay::Dispatcher *mp_plugin_root;
lym::MacroCollection *mp_root;
bool m_first_show;
bool m_in_processing;

View File

@ -25,6 +25,7 @@
#include "layMacroEditorPage.h"
#include "layMacroEditorDialog.h"
#include "layGenericSyntaxHighlighter.h"
#include "layDispatcher.h"
#include "lymMacro.h"
@ -56,7 +57,7 @@ struct MacroEditorSetupDialogData
int font_size;
std::set <std::string> ignore_exceptions_list;
void setup (lay::PluginRoot *root)
void setup (lay::Dispatcher *root)
{
lay::MacroEditorHighlighters highlighters (this);
std::string styles;
@ -91,7 +92,7 @@ struct MacroEditorSetupDialogData
}
}
void commit (lay::PluginRoot *root)
void commit (lay::Dispatcher *root)
{
lay::MacroEditorHighlighters highlighters (this);
@ -201,7 +202,7 @@ MacroEditorSetupPage::update_font ()
}
void
MacroEditorSetupPage::setup (PluginRoot *root)
MacroEditorSetupPage::setup (Dispatcher *root)
{
delete mp_data;
mp_data = new MacroEditorSetupDialogData (this);
@ -268,7 +269,7 @@ MacroEditorSetupPage::setup (PluginRoot *root)
}
void
MacroEditorSetupPage::commit (PluginRoot *root)
MacroEditorSetupPage::commit (Dispatcher *root)
{
if (styles_list->currentItem ()) {
commit_attributes (styles_list->currentItem ());

View File

@ -44,8 +44,8 @@ public:
MacroEditorSetupPage (QWidget *parent);
~MacroEditorSetupPage ();
virtual void setup (PluginRoot *root);
virtual void commit (PluginRoot *root);
virtual void setup (Dispatcher *root);
virtual void commit (Dispatcher *root);
protected slots:
void current_attribute_changed (QListWidgetItem *current, QListWidgetItem *previous);

View File

@ -116,7 +116,7 @@ MainConfigPage::~MainConfigPage ()
}
void
MainConfigPage::setup (lay::PluginRoot *root)
MainConfigPage::setup (lay::Dispatcher *root)
{
double grid_micron = 0.0;
root->config_get (cfg_grid, grid_micron);
@ -124,7 +124,7 @@ MainConfigPage::setup (lay::PluginRoot *root)
}
void
MainConfigPage::commit (lay::PluginRoot *root)
MainConfigPage::commit (lay::Dispatcher *root)
{
try {
double g;
@ -150,7 +150,7 @@ MainConfigPage6::~MainConfigPage6 ()
}
void
MainConfigPage6::setup (lay::PluginRoot *root)
MainConfigPage6::setup (lay::Dispatcher *root)
{
int cp = 32;
root->config_get (cfg_circle_points, cp);
@ -158,7 +158,7 @@ MainConfigPage6::setup (lay::PluginRoot *root)
}
void
MainConfigPage6::commit (lay::PluginRoot *root)
MainConfigPage6::commit (lay::Dispatcher *root)
{
try {
int cp = 32;
@ -185,7 +185,7 @@ MainConfigPage7::~MainConfigPage7 ()
}
void
MainConfigPage7::setup (lay::PluginRoot *root)
MainConfigPage7::setup (lay::Dispatcher *root)
{
bool en = true;
root->config_get (cfg_layout_file_watcher_enabled, en);
@ -193,7 +193,7 @@ MainConfigPage7::setup (lay::PluginRoot *root)
}
void
MainConfigPage7::commit (lay::PluginRoot *root)
MainConfigPage7::commit (lay::Dispatcher *root)
{
try {
root->config_set (cfg_layout_file_watcher_enabled, mp_ui->check_for_updates->isChecked ());
@ -217,7 +217,7 @@ MainConfigPage2::~MainConfigPage2 ()
}
void
MainConfigPage2::setup (lay::PluginRoot *root)
MainConfigPage2::setup (lay::Dispatcher *root)
{
bool flag = false;
root->config_get (cfg_synchronized_views, flag);
@ -225,7 +225,7 @@ MainConfigPage2::setup (lay::PluginRoot *root)
}
void
MainConfigPage2::commit (lay::PluginRoot *root)
MainConfigPage2::commit (lay::Dispatcher *root)
{
root->config_set (cfg_synchronized_views, mp_ui->sync_views_cbx->isChecked ());
}
@ -247,7 +247,7 @@ MainConfigPage3::~MainConfigPage3 ()
}
void
MainConfigPage3::setup (lay::PluginRoot *root)
MainConfigPage3::setup (lay::Dispatcher *root)
{
std::string default_grids;
root->config_get (cfg_default_grids, default_grids);
@ -255,7 +255,7 @@ MainConfigPage3::setup (lay::PluginRoot *root)
}
void
MainConfigPage3::commit (lay::PluginRoot *root)
MainConfigPage3::commit (lay::Dispatcher *root)
{
root->config_set (cfg_default_grids, tl::to_string (mp_ui->grids_edit->text ()));
}
@ -277,7 +277,7 @@ MainConfigPage4::~MainConfigPage4 ()
}
void
MainConfigPage4::setup (lay::PluginRoot *root)
MainConfigPage4::setup (lay::Dispatcher *root)
{
bool flag = true;
root->config_get (cfg_edit_mode, flag);
@ -285,7 +285,7 @@ MainConfigPage4::setup (lay::PluginRoot *root)
}
void
MainConfigPage4::commit (lay::PluginRoot *root)
MainConfigPage4::commit (lay::Dispatcher *root)
{
root->config_set (cfg_edit_mode, mp_ui->edit_mode_cbx->isChecked ());
}
@ -307,7 +307,7 @@ MainConfigPage5::~MainConfigPage5 ()
}
void
MainConfigPage5::setup (lay::PluginRoot *root)
MainConfigPage5::setup (lay::Dispatcher *root)
{
int d;
d = 5;
@ -319,7 +319,7 @@ MainConfigPage5::setup (lay::PluginRoot *root)
}
void
MainConfigPage5::commit (lay::PluginRoot *root)
MainConfigPage5::commit (lay::Dispatcher *root)
{
root->config_set (cfg_micron_digits, mp_ui->micron_digits->value ());
root->config_set (cfg_dbu_digits, mp_ui->dbu_digits->value ());
@ -329,7 +329,7 @@ MainConfigPage5::commit (lay::PluginRoot *root)
// The "key bindings" config page
CustomizeMenuConfigPage::CustomizeMenuConfigPage (QWidget *parent)
: lay::ConfigPage (parent), m_enable_event (true)
: lay::ConfigPage (parent), m_enable_event (true), mp_dispatcher (0)
{
mp_ui = new Ui::CustomizeMenuConfigPage ();
mp_ui->setupUi (this);
@ -357,7 +357,7 @@ static void get_shortcuts (const lay::AbstractMenu &menu, const std::string &roo
std::vector<std::string> items = menu.items (root);
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
if (i->size () > 0) {
if (menu.is_valid (*i) && menu.action (*i).is_visible ()) {
if (menu.is_valid (*i) && menu.action (*i)->is_visible ()) {
if (menu.is_menu (*i)) {
// a menu must be listed (so it can be hidden), but does not have a shortcut
// but we don't include special menus
@ -366,7 +366,7 @@ static void get_shortcuts (const lay::AbstractMenu &menu, const std::string &roo
}
get_shortcuts (menu, *i, bindings, with_defaults);
} else if (! menu.is_separator (*i)) {
bindings.insert (std::make_pair (*i, with_defaults ? menu.action (*i).get_default_shortcut () : menu.action (*i).get_effective_shortcut ()));
bindings.insert (std::make_pair (*i, with_defaults ? menu.action (*i)->get_default_shortcut () : menu.action (*i)->get_effective_shortcut ()));
}
}
}
@ -402,11 +402,11 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
// get the current bindings
m_current_bindings.clear ();
get_shortcuts (*lay::MainWindow::instance ()->menu (), std::string (), m_current_bindings, false);
get_shortcuts (*mp_dispatcher->menu (), std::string (), m_current_bindings, false);
// get the default bindings
std::map<std::string, std::string> default_bindings;
get_shortcuts (*lay::MainWindow::instance ()->menu (), std::string (), default_bindings, true);
get_shortcuts (*mp_dispatcher->menu (), std::string (), default_bindings, true);
m_enable_event = false;
@ -416,8 +416,8 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
for (std::map<std::string, std::string>::iterator kb = m_current_bindings.begin (); kb != m_current_bindings.end (); ++kb) {
std::map<std::string, std::string>::iterator bb = b.find (kb->first);
if (bb != b.end ()) {
lay::Action a = lay::MainWindow::instance ()->menu ()->action (kb->first);
kb->second = a.get_effective_shortcut_for (bb->second);
lay::Action *a = mp_dispatcher->menu ()->action (kb->first);
kb->second = a->get_effective_shortcut_for (bb->second);
} else {
kb->second.clear ();
}
@ -470,11 +470,11 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
if (t->first == tl_menu) {
QTreeWidgetItem *item = new QTreeWidgetItem (top_level_item);
lay::Action action = lay::MainWindow::instance ()->menu ()->action (cb->first);
lay::Action *action = mp_dispatcher->menu ()->action (cb->first);
item->setData (0, Qt::ToolTipRole, tl::to_qstring (rem_path));
item->setData (0, Qt::DisplayRole, tl::to_qstring (rem_path));
item->setData (1, Qt::ToolTipRole, tl::to_qstring (action.get_title ()));
item->setData (1, Qt::DisplayRole, tl::to_qstring (action.get_title ()));
item->setData (1, Qt::ToolTipRole, tl::to_qstring (action->get_title ()));
item->setData (1, Qt::DisplayRole, tl::to_qstring (action->get_title ()));
item->setData (2, Qt::DisplayRole, tl::to_qstring (sc));
item->setData (2, Qt::ForegroundRole, palette ().color (is_default ? QPalette::Disabled : QPalette::Normal, QPalette::Text));
item->setData (0, Qt::UserRole, tl::to_qstring (path));
@ -482,8 +482,8 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
item->setCheckState (0, hidden ? Qt::Unchecked : Qt::Checked);
item->setHidden (false);
m_item_for_path[path] = item;
if (action.qaction ()) {
m_paths_for_action[action.qaction ()].push_back (path);
if (action->qaction ()) {
m_paths_for_action[action->qaction ()].push_back (path);
}
}
}
@ -502,21 +502,23 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
}
void
CustomizeMenuConfigPage::setup (lay::PluginRoot *root)
CustomizeMenuConfigPage::setup (lay::Dispatcher *dispatcher)
{
mp_dispatcher = dispatcher;
std::string packed_key_bindings;
root->config_get (cfg_key_bindings, packed_key_bindings);
dispatcher->config_get (cfg_key_bindings, packed_key_bindings);
std::vector<std::pair<std::string, std::string> > key_bindings = unpack_key_binding (packed_key_bindings);
std::string packed_menu_items_hidden;
root->config_get (cfg_menu_items_hidden, packed_menu_items_hidden);
dispatcher->config_get (cfg_menu_items_hidden, packed_menu_items_hidden);
std::vector<std::pair<std::string, bool> > menu_items_hidden = unpack_menu_items_hidden (packed_menu_items_hidden);
apply (key_bindings, menu_items_hidden);
}
void
CustomizeMenuConfigPage::commit (lay::PluginRoot *root)
CustomizeMenuConfigPage::commit (lay::Dispatcher *dispatcher)
{
current_changed (0, mp_ui->bindings_list->currentItem ());
@ -524,14 +526,14 @@ CustomizeMenuConfigPage::commit (lay::PluginRoot *root)
// but never reduce them.
std::string packed_key_bindings;
root->config_get (cfg_key_bindings, packed_key_bindings);
dispatcher->config_get (cfg_key_bindings, packed_key_bindings);
std::vector<std::pair<std::string, std::string> > key_bindings = unpack_key_binding (packed_key_bindings);
for (std::vector<std::pair<std::string, std::string> >::iterator kb = key_bindings.begin (); kb != key_bindings.end (); ++kb) {
std::map<std::string, std::string>::iterator cb = m_current_bindings.find (kb->first);
if (cb != m_current_bindings.end ()) {
lay::Action a = lay::MainWindow::instance ()->menu ()->action (kb->first);
if (cb->second != a.get_default_shortcut ()) {
lay::Action *a = dispatcher->menu ()->action (kb->first);
if (cb->second != a->get_default_shortcut ()) {
if (cb->second.empty ()) {
kb->second = lay::Action::no_shortcut ();
} else {
@ -549,10 +551,10 @@ CustomizeMenuConfigPage::commit (lay::PluginRoot *root)
}
packed_key_bindings = pack_key_binding (key_bindings);
root->config_set (cfg_key_bindings, packed_key_bindings);
dispatcher->config_set (cfg_key_bindings, packed_key_bindings);
std::string packed_hidden_flags;
root->config_get (cfg_menu_items_hidden, packed_hidden_flags);
dispatcher->config_get (cfg_menu_items_hidden, packed_hidden_flags);
std::vector<std::pair<std::string, bool> > hidden = unpack_menu_items_hidden (packed_hidden_flags);
for (std::vector<std::pair<std::string, bool> >::iterator hf = hidden.begin (); hf != hidden.end (); ++hf) {
@ -568,7 +570,7 @@ CustomizeMenuConfigPage::commit (lay::PluginRoot *root)
}
packed_hidden_flags = pack_menu_items_hidden (hidden);
root->config_set (cfg_menu_items_hidden, packed_hidden_flags);
dispatcher->config_set (cfg_menu_items_hidden, packed_hidden_flags);
}
void
@ -580,10 +582,10 @@ CustomizeMenuConfigPage::text_cleared ()
}
std::string path = tl::to_string (item->data (0, Qt::UserRole).toString ());
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
lay::Action *a = mp_dispatcher->menu ()->action (path);
// "clear" reverts to default
mp_ui->binding_le->setText (tl::to_qstring (a.get_default_shortcut ()));
mp_ui->binding_le->setText (tl::to_qstring (a->get_default_shortcut ()));
}
void
@ -634,8 +636,8 @@ CustomizeMenuConfigPage::update_list_item (QTreeWidgetItem *item)
bool is_default = false;
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
std::string def_shortcut = a.get_default_shortcut ();
lay::Action *a = mp_dispatcher->menu ()->action (path);
std::string def_shortcut = a->get_default_shortcut ();
is_default = (def_shortcut == shortcut);
@ -643,9 +645,9 @@ CustomizeMenuConfigPage::update_list_item (QTreeWidgetItem *item)
item->setData (2, Qt::ForegroundRole, palette ().color (is_default ? QPalette::Disabled : QPalette::Normal, QPalette::Text));
// Set the aliases too
const lay::AbstractMenu &menu = *lay::MainWindow::instance ()->menu ();
const lay::AbstractMenu &menu = *mp_dispatcher->menu ();
if (menu.is_valid (path)) {
QAction *qaction = menu.action (path).qaction ();
QAction *qaction = menu.action (path)->qaction ();
std::map<QAction *, std::vector<std::string> >::const_iterator a = m_paths_for_action.find (qaction);
if (a != m_paths_for_action.end ()) {
for (std::vector<std::string>::const_iterator p = a->second.begin (); p != a->second.end (); ++p) {
@ -688,7 +690,7 @@ CustomizeMenuConfigPage::current_changed (QTreeWidgetItem *current, QTreeWidgetI
if (current && !current->data (0, Qt::UserRole).isNull ()) {
std::string path = tl::to_string (current->data (0, Qt::UserRole).toString ());
if (lay::MainWindow::instance ()->menu ()->is_menu (path)) {
if (mp_dispatcher->menu ()->is_menu (path)) {
mp_ui->binding_le->setText (QString ());
#if QT_VERSION >= 0x40700
@ -700,9 +702,9 @@ CustomizeMenuConfigPage::current_changed (QTreeWidgetItem *current, QTreeWidgetI
std::string shortcut = m_current_bindings[path];
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
lay::Action *a = mp_dispatcher->menu ()->action (path);
std::string def_shortcut = a.get_default_shortcut ();
std::string def_shortcut = a->get_default_shortcut ();
mp_ui->binding_le->setText (tl::to_qstring (shortcut));
#if QT_VERSION >= 0x40700

View File

@ -59,8 +59,8 @@ public:
MainConfigPage (QWidget *parent);
~MainConfigPage ();
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::MainConfigPage *mp_ui;
@ -75,8 +75,8 @@ public:
MainConfigPage2 (QWidget *parent);
~MainConfigPage2 ();
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::MainConfigPage2 *mp_ui;
@ -91,8 +91,8 @@ public:
MainConfigPage3 (QWidget *parent);
~MainConfigPage3 ();
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::MainConfigPage3 *mp_ui;
@ -107,8 +107,8 @@ public:
MainConfigPage4 (QWidget *parent);
~MainConfigPage4 ();
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::MainConfigPage4 *mp_ui;
@ -123,8 +123,8 @@ public:
MainConfigPage5 (QWidget *parent);
~MainConfigPage5 ();
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::MainConfigPage5 *mp_ui;
@ -139,8 +139,8 @@ public:
MainConfigPage6 (QWidget *parent);
~MainConfigPage6 ();
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::MainConfigPage6 *mp_ui;
@ -155,8 +155,8 @@ public:
MainConfigPage7 (QWidget *parent);
~MainConfigPage7 ();
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::MainConfigPage7 *mp_ui;
@ -171,8 +171,8 @@ public:
CustomizeMenuConfigPage (QWidget *parent);
~CustomizeMenuConfigPage ();
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 slots:
void current_changed (QTreeWidgetItem *current, QTreeWidgetItem *previous);
@ -189,6 +189,7 @@ private:
std::map<std::string, QTreeWidgetItem *> m_item_for_path;
std::map<QAction *, std::vector<std::string> > m_paths_for_action;
bool m_enable_event;
lay::Dispatcher *mp_dispatcher;
void apply (const std::vector<std::pair<std::string, std::string> > &bindings, const std::vector<std::pair<std::string, bool> > &menu_items_hidden);
void update_list_item (QTreeWidgetItem *item);

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@
#include "dbManager.h"
#include "dbLoadLayoutOptions.h"
#include "layAbstractMenu.h"
#include "layAbstractMenuProvider.h"
#include "layDispatcher.h"
#include "layLayoutView.h"
#include "layPlugin.h"
#include "layProgress.h"
@ -118,8 +118,7 @@ private:
class LAY_PUBLIC MainWindow
: public QMainWindow,
public lay::Plugin,
public lay::AbstractMenuProvider
public lay::Dispatcher
{
Q_OBJECT
public:
@ -132,7 +131,7 @@ public:
/**
* @brief Constructor
*/
MainWindow (QApplication *app = 0, lay::Plugin *parent_plugin = 0, const char *name = "main_window");
MainWindow (QApplication *app = 0, lay::Plugin *parent_plugin = 0, const char *name = "main_window", bool undo_enabled = true);
/**
* @brief Destructor
@ -140,21 +139,13 @@ public:
~MainWindow ();
/**
* @brief Implementation of the AbstractMenuProvider interface
* @brief Implementation of the Dispatcher interface
*/
QWidget *menu_parent_widget ()
{
return this;
}
/**
* @brief Get the main menu abstraction object
*/
AbstractMenu *menu ()
{
return mp_menu;
}
/**
* @brief Shows the window
*
@ -407,12 +398,12 @@ public:
bool show_progress_bar (bool show);
/**
* @brief Implementation of the PluginRoot interface
* @brief Implementation of the Plugin interface
*/
bool configure (const std::string &name, const std::string &value);
/**
* @brief Implementation of the PluginRoot interface
* @brief Implementation of the Plugin interface
*/
void config_finalize ();
@ -537,35 +528,10 @@ public:
void menu_activated (const std::string &symbol);
/**
* @brief Get the action for a slot
* @brief Gets the available menu symbols
*/
lay::Action &action_for_slot (const char *slot);
static std::vector<std::string> menu_symbols ();
/**
* @brief Create a configuration action with the given title, parameter name and value
*
* The action will be owned by the main window but can be deleted to remove the action from the main window.
*/
lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue);
/**
* @brief Create a configuration action with the given parameter name and value
*
* The action will be owned by the main window but can be deleted to remove the action from the main window.
* This version is provided for applications, where the title is set later.
*/
lay::Action *create_config_action (const std::string &cname, const std::string &cvalue);
/**
* @brief Register a configuration action with the given name
*/
void register_config_action (const std::string &name, lay::ConfigureAction *action);
/**
* @brief Unregister a configuration action with the given name
*/
void unregister_config_action (const std::string &name, lay::ConfigureAction *action);
/**
* @brief Open a new layout in mode 'mode'
*
@ -664,174 +630,16 @@ public slots:
*/
void select_mode (int m);
/**
* @brief Called when one of the built-in modes (i.e. select, move) is selected
*/
void intrinsic_mode_triggered ();
void update_action_states ();
void cancel ();
void redraw ();
void exit ();
void close_current_view ();
void tab_close_requested (int);
void enable_all ();
void disable_all ();
void open_recent ();
void open_recent (size_t n);
void view_selected (int index);
void view_title_changed ();
// menu callbacks for main window
void cm_reset_window_state ();
void cm_select_all ();
void cm_unselect_all ();
void cm_undo ();
void cm_redo ();
void cm_delete ();
void cm_show_properties ();
void cm_copy ();
void cm_paste ();
void cm_paste_interactive ();
void cm_duplicate ();
void cm_duplicate_interactive ();
void cm_cut ();
void cm_zoom_fit_sel ();
void cm_zoom_fit ();
void cm_zoom_in ();
void cm_zoom_out ();
void cm_pan_up ();
void cm_pan_down ();
void cm_pan_left ();
void cm_pan_right ();
void cm_save_session ();
void cm_restore_session ();
void cm_setup ();
void cm_save_as ();
void cm_save_all ();
void cm_save ();
void cm_reload ();
void cm_close ();
void cm_close_all ();
void cm_clone ();
void cm_layout_props ();
void cm_layout_stats ();
void cm_inc_max_hier ();
void cm_dec_max_hier ();
void cm_max_hier ();
void cm_max_hier_0 ();
void cm_max_hier_1 ();
void cm_prev_display_state ();
void cm_next_display_state ();
void cm_cancel ();
void cm_redraw ();
void cm_screenshot ();
void cm_save_layer_props ();
void cm_load_layer_props ();
void cm_save_bookmarks ();
void cm_load_bookmarks ();
void cm_select_cell ();
void cm_select_current_cell ();
void cm_print ();
void cm_exit ();
void cm_view_log ();
void cm_bookmark_view ();
void cm_manage_bookmarks ();
void cm_goto_position ();
void cm_show_all_tips ();
void cm_help_about ();
void cm_help_about_qt ();
void cm_macro_editor ();
void cm_packages ();
void cm_technologies ();
void cm_open_too ();
void cm_open_new_view ();
void cm_open ();
void cm_pull_in ();
void cm_reader_options ();
void cm_writer_options ();
void cm_new_layout ();
void cm_new_panel ();
void cm_adjust_origin ();
void cm_new_cell ();
void cm_new_layer ();
void cm_clear_layer ();
void cm_delete_layer ();
void cm_edit_layer ();
void cm_copy_layer ();
void cm_lay_convert_to_static ();
void cm_lay_flip_x ();
void cm_lay_flip_y ();
void cm_lay_rot_cw ();
void cm_lay_rot_ccw ();
void cm_lay_free_rot ();
void cm_lay_scale ();
void cm_lay_move ();
void cm_sel_flip_x ();
void cm_sel_flip_y ();
void cm_sel_rot_cw ();
void cm_sel_rot_ccw ();
void cm_sel_free_rot ();
void cm_sel_scale ();
void cm_sel_move ();
void cm_sel_move_to ();
void cm_sel_move_interactive ();
void cm_show_assistant ();
// forwarded to the current view: layer list context menu
void cm_lv_new_tab ();
void cm_lv_remove_tab ();
void cm_lv_rename_tab ();
void cm_lv_make_valid ();
void cm_lv_make_invalid ();
void cm_lv_hide ();
void cm_lv_hide_all ();
void cm_lv_show ();
void cm_lv_show_all ();
void cm_lv_show_only ();
void cm_lv_rename ();
void cm_lv_select_all ();
void cm_lv_delete ();
void cm_lv_insert ();
void cm_lv_group ();
void cm_lv_ungroup ();
void cm_lv_source ();
void cm_lv_sort_by_name ();
void cm_lv_sort_by_ild ();
void cm_lv_sort_by_idl ();
void cm_lv_sort_by_ldi ();
void cm_lv_sort_by_dli ();
void cm_lv_regroup_by_index ();
void cm_lv_regroup_by_datatype ();
void cm_lv_regroup_by_layer ();
void cm_lv_regroup_flatten ();
void cm_lv_expand_all ();
void cm_lv_add_missing ();
void cm_lv_remove_unused ();
void cm_lv_copy ();
void cm_lv_cut ();
void cm_lv_paste ();
// forwarded to the current view: cell list context menu
void cm_cell_user_properties ();
void cm_cell_delete ();
void cm_cell_replace ();
void cm_cell_rename ();
void cm_cell_flatten ();
void cm_cell_convert_to_static ();
void cm_cell_copy ();
void cm_cell_cut ();
void cm_cell_paste ();
void cm_cell_select ();
void cm_open_current_cell ();
void cm_save_current_cell_as ();
void cm_cell_hide ();
void cm_cell_show ();
void cm_cell_show_all ();
// forwarded to the navigator
void cm_navigator_freeze ();
void cm_navigator_close ();
/**
* @brief shows the given URL as a non-modal help window
* Intended as a connection target for QLabel linkVisisted signals.
@ -865,12 +673,9 @@ protected:
void do_update_file_menu ();
private:
friend class PluginRootToMainWindow;
TextProgressDelegate m_text_progress;
// Main menu
AbstractMenu *mp_menu;
QTabBar *mp_tab_bar;
QToolBar *mp_tool_bar;
QDockWidget *mp_navigator_dock_widget;
@ -920,11 +725,8 @@ private:
double m_grid_micron;
std::vector<double> m_default_grids;
bool m_default_grids_updated;
std::vector<lay::Action *> m_default_grid_actions;
std::vector<std::pair<std::string, std::string> > m_key_bindings;
double m_new_cell_window_size;
bool m_new_layout_current_panel;
std::string m_new_cell_cell_name;
bool m_synchronized_views;
bool m_synchronous;
bool m_busy;
@ -935,10 +737,6 @@ private:
std::auto_ptr<QPrinter> mp_printer;
std::vector<QString> m_changed_files;
std::map<std::string, lay::Action> m_actions_for_slot;
std::map<std::string, std::vector<lay::ConfigureAction *> > m_configuration_actions;
tl::shared_collection<lay::ConfigureAction> m_ca_collection;
// the object manager (undo/redo mechanism and others)
db::Manager m_manager;
@ -949,8 +747,48 @@ private:
void closeEvent (QCloseEvent *event);
void resizeEvent (QResizeEvent *event);
void do_cm_paste (bool interactive);
void do_cm_duplicate (bool interactive);
void cm_navigator_freeze ();
void cm_navigator_close ();
void cm_view_log ();
void cm_print ();
void cm_exit ();
void cm_reset_window_state ();
void cm_undo ();
void cm_redo ();
void cm_goto_position ();
void cm_manage_bookmarks ();
void cm_bookmark_view ();
void cm_cancel ();
void cm_save_layer_props ();
void cm_load_layer_props ();
void cm_save_session ();
void cm_restore_session ();
void cm_save_bookmarks ();
void cm_load_bookmarks ();
void cm_screenshot ();
void cm_save_current_cell_as ();
void cm_save ();
void cm_save_as ();
void cm_save_all ();
void cm_setup ();
void cm_open_too ();
void cm_open_new_view ();
void cm_open ();
void cm_pull_in ();
void cm_reader_options ();
void cm_writer_options ();
void cm_new_panel ();
void cm_new_layout ();
void cm_clone ();
void cm_close_all ();
void cm_close ();
void cm_packages ();
void cm_technologies ();
void cm_macro_editor ();
void cm_show_assistant ();
void cm_show_all_tips ();
void cm_help_about ();
void cm_help_about_qt ();
void format_message ();
@ -982,26 +820,6 @@ private:
void apply_hidden (const std::vector<std::pair <std::string, bool> > &hidden);
};
class LAY_PUBLIC PluginRootToMainWindow
: public lay::PluginRoot
{
public:
PluginRootToMainWindow ();
void attach_to (lay::MainWindow *main_window);
virtual void plugin_registered (lay::PluginDeclaration *cls);
virtual void plugin_removed (lay::PluginDeclaration *cls);
virtual void select_mode (int mode);
virtual void menu_activated (const std::string &symbol);
private:
PluginRootToMainWindow (const PluginRootToMainWindow &);
PluginRootToMainWindow &operator= (const PluginRootToMainWindow &);
tl::weak_ptr<MainWindow> mp_main_window;
};
}
namespace tl {

View File

@ -503,32 +503,6 @@ Navigator::~Navigator ()
}
}
void
Navigator::init_menu (AbstractMenu &menu)
{
MenuLayoutEntry navigator_main_menu [] = {
MenuLayoutEntry ("navigator_show_images", tl::to_string (QObject::tr ("Show Images")), std::make_pair (cfg_navigator_show_images, "?")),
MenuLayoutEntry ("navigator_all_hier_levels", tl::to_string (QObject::tr ("Show All Hierarchy Levels")), std::make_pair (cfg_navigator_all_hier_levels, "?")),
MenuLayoutEntry::separator ("navigator_options_group"),
MenuLayoutEntry ("navigator_freeze", tl::to_string (QObject::tr ("Freeze")), SLOT (cm_navigator_freeze ())),
MenuLayoutEntry::last ()
};
MenuLayoutEntry navigator_menu [] = {
MenuLayoutEntry ("navigator_main_menu", tl::to_string (QObject::tr ("Options")), navigator_main_menu),
MenuLayoutEntry::last ()
};
MenuLayoutEntry navigator_detached_menu [] = {
MenuLayoutEntry ("@@navigator_menu", "", navigator_menu),
MenuLayoutEntry::last ()
};
menu.init (navigator_detached_menu);
menu.action (freeze_action_path).set_checkable (true);
}
void
Navigator::menu_changed ()
{
@ -567,11 +541,11 @@ Navigator::all_hier_levels (bool f)
void
Navigator::freeze_clicked ()
{
Action freeze_action = mp_main_window->menu ()->action (freeze_action_path);
Action *freeze_action = mp_main_window->menu ()->action (freeze_action_path);
m_frozen_list.erase (mp_source_view);
if (freeze_action.is_checked () && mp_source_view) {
if (freeze_action->is_checked () && mp_source_view) {
NavigatorFrozenViewInfo &info = m_frozen_list.insert (std::make_pair (mp_source_view, NavigatorFrozenViewInfo ())).first->second;
info.layer_properties = mp_source_view->get_properties ();
info.hierarchy_levels = mp_source_view->get_hier_levels ();
@ -598,8 +572,8 @@ Navigator::showEvent (QShowEvent *)
void
Navigator::closeEvent (QCloseEvent *)
{
lay::PluginRoot::instance ()->config_set (cfg_show_navigator, "false");
lay::PluginRoot::instance ()->config_end ();
mp_main_window->config_set (cfg_show_navigator, "false");
mp_main_window->config_end ();
}
void
@ -716,8 +690,8 @@ Navigator::attach_view (LayoutView *view)
all_views.erase (*v);
}
Action freeze_action = mp_main_window->menu ()->action (freeze_action_path);
freeze_action.set_checked (m_frozen_list.find (mp_source_view) != m_frozen_list.end ());
Action *freeze_action = mp_main_window->menu ()->action (freeze_action_path);
freeze_action->set_checked (m_frozen_list.find (mp_source_view) != m_frozen_list.end ());
// Hint: this must happen before update ()
mp_service->attach_view (mp_source_view);
@ -793,5 +767,33 @@ Navigator::update ()
mp_service->update_marker ();
}
// ------------------------------------------------------------
// Declaration of the "plugin" for the menu entries
class NavigatorPluginDeclaration
: public lay::PluginDeclaration
{
public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
std::string at;
at = ".end";
menu_entries.push_back (lay::submenu ("@@navigator_menu", at, std::string ()));
at = "@@navigator_menu.end";
menu_entries.push_back (lay::submenu ("navigator_main_menu", at, tl::to_string (QObject::tr ("Options"))));
at = "@@navigator_menu.navigator_main_menu.end";
menu_entries.push_back (lay::config_menu_item ("navigator_show_images", at, tl::to_string (QObject::tr ("Show Images")), cfg_navigator_show_images, "?"));
menu_entries.push_back (lay::config_menu_item ("navigator_all_hier_levels", at, tl::to_string (QObject::tr ("Show All Hierarchy Levels")), cfg_navigator_all_hier_levels, "?"));
menu_entries.push_back (lay::separator ("navigator_options_group", at));
menu_entries.push_back (lay::menu_item ("cm_navigator_freeze", "navigator_freeze", at, tl::to_string (QObject::tr ("Freeze"))));
menu_entries.back ().checkable = true;
}
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new NavigatorPluginDeclaration (), -1, "NavigatorPlugin");
}

View File

@ -84,8 +84,6 @@ public:
void all_hier_levels (bool f);
void show_images (bool f);
static void init_menu (AbstractMenu &menu);
protected:
virtual void closeEvent (QCloseEvent *event);
virtual void showEvent (QShowEvent *event);

View File

@ -43,14 +43,14 @@ SaltController::SaltController ()
}
void
SaltController::initialize (lay::PluginRoot *root)
SaltController::initialize (lay::Dispatcher *root)
{
mp_mw = lay::MainWindow::instance ();
mp_plugin_root = root;
}
void
SaltController::initialized (lay::PluginRoot * /*root*/)
SaltController::initialized (lay::Dispatcher * /*root*/)
{
if (! m_file_watcher) {
m_file_watcher = new tl::FileSystemWatcher (this);
@ -62,7 +62,7 @@ SaltController::initialized (lay::PluginRoot * /*root*/)
}
void
SaltController::uninitialize (lay::PluginRoot * /*root*/)
SaltController::uninitialize (lay::Dispatcher * /*root*/)
{
disconnect (&m_salt, SIGNAL (collections_changed ()), this, SIGNAL (salt_changed ()));
@ -103,7 +103,7 @@ SaltController::config_finalize()
}
bool
SaltController::can_exit (lay::PluginRoot * /*root*/) const
SaltController::can_exit (lay::Dispatcher * /*root*/) const
{
// .. nothing yet ..
return true;

View File

@ -69,17 +69,17 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialize (lay::PluginRoot *root);
virtual void initialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void initialized (lay::PluginRoot *root);
virtual void initialized (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
virtual void uninitialize (lay::PluginRoot *root);
virtual void uninitialize (lay::Dispatcher *root);
/**
* @brief Reimplementation of the PluginDeclaration interface
@ -104,7 +104,7 @@ public:
/**
* @brief Reimplementation of the PluginDeclaration interface
*/
bool can_exit (lay::PluginRoot *root) const;
bool can_exit (lay::Dispatcher *root) const;
/**
* @brief Reimplementation of the PluginDeclaration interface
@ -191,7 +191,7 @@ signals:
private:
lay::SaltManagerDialog *mp_salt_dialog;
lay::MainWindow *mp_mw;
lay::PluginRoot * mp_plugin_root;
lay::Dispatcher * mp_plugin_root;
std::string m_salt_mine_url;
lay::Salt m_salt;
tl::FileSystemWatcher *m_file_watcher;

View File

@ -22,6 +22,7 @@
#include "laySearchReplaceConfigPage.h"
#include "layDispatcher.h"
namespace lay
{
@ -76,7 +77,7 @@ SearchReplaceConfigPage::SearchReplaceConfigPage (QWidget *parent)
}
void
SearchReplaceConfigPage::setup (lay::PluginRoot *root)
SearchReplaceConfigPage::setup (lay::Dispatcher *root)
{
std::string value;
@ -106,7 +107,7 @@ SearchReplaceConfigPage::window_changed (int m)
}
void
SearchReplaceConfigPage::commit (lay::PluginRoot *root)
SearchReplaceConfigPage::commit (lay::Dispatcher *root)
{
double dim = 1.0;
tl::from_string (tl::to_string (le_window->text ()), dim);

View File

@ -55,8 +55,8 @@ class SearchReplaceConfigPage
public:
SearchReplaceConfigPage (QWidget *parent);
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 window_changed (int);

View File

@ -697,7 +697,7 @@ fill_ctx_cbx (QComboBox *cbx)
cbx->addItem (QObject::tr ("All cells"));
}
SearchReplaceDialog::SearchReplaceDialog (lay::PluginRoot *root, lay::LayoutView *view)
SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view)
: lay::Browser (root, view),
Ui::SearchReplaceDialog (),
mp_view (view),
@ -768,7 +768,7 @@ SearchReplaceDialog::~SearchReplaceDialog ()
}
static void
save_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config_root)
save_states (QStackedWidget *sw, const std::string &pfx, lay::Dispatcher *config_root)
{
for (int i = 0; i < sw->count (); ++i) {
SearchReplacePropertiesWidget *pw = dynamic_cast<SearchReplacePropertiesWidget *> (sw->widget (i));
@ -779,7 +779,7 @@ save_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config
}
static void
restore_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config_root)
restore_states (QStackedWidget *sw, const std::string &pfx, lay::Dispatcher *config_root)
{
for (int i = 0; i < sw->count (); ++i) {
SearchReplacePropertiesWidget *pw = dynamic_cast<SearchReplacePropertiesWidget *> (sw->widget (i));
@ -813,7 +813,7 @@ ctx_from_index (int index)
void
SearchReplaceDialog::restore_state ()
{
lay::PluginRoot *config_root = root ();
lay::Dispatcher *config_root = root ();
restore_states (find_properties, "sr-find", config_root);
restore_states (delete_properties, "sr-find", config_root);
@ -881,7 +881,7 @@ SearchReplaceDialog::restore_state ()
void
SearchReplaceDialog::save_state ()
{
lay::PluginRoot *config_root = root ();
lay::Dispatcher *config_root = root ();
config_root->config_set (cfg_sr_window_state, lay::save_dialog_state (this));
@ -1877,7 +1877,7 @@ SearchReplaceDialog::tab_index_changed (int index)
{
cancel ();
lay::PluginRoot *config_root = root ();
lay::Dispatcher *config_root = root ();
std::string v;

View File

@ -164,7 +164,7 @@ public:
std::string text;
};
SearchReplaceDialog (lay::PluginRoot *root, lay::LayoutView *view);
SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view);
~SearchReplaceDialog ();
private:

View File

@ -56,14 +56,14 @@ public:
lay::PluginDeclaration::get_menu_entries (menu_entries);
// separator:
menu_entries.push_back (lay::MenuEntry ("search_replace_sep", "edit_menu.utils_group+"));
menu_entries.push_back (lay::separator ("search_replace_sep", "edit_menu.utils_group+"));
// two entries - one for view mode and one for edit mode:
menu_entries.push_back (lay::MenuEntry ("search_replace::show", "search_replace_editor:edit:edit_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search and Replace"))));
menu_entries.push_back (lay::MenuEntry ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search"))));
menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_editor:edit:edit_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search and Replace"))));
menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new SearchReplaceDialog (root, view);
}

View File

@ -325,7 +325,7 @@ public:
setupUi (this);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_instance_cellname_op, v)) {
@ -336,7 +336,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_instance_cellname_op, tl::to_string (instance_cellname_op->currentText ()));
config_root->config_set (pfx + cfg_suffix_instance_cellname_value, tl::to_string (instance_cellname_value->text ()));
@ -386,7 +386,7 @@ public:
shape_layer->set_new_layer_enabled (false);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_shape_layer, v)) {
@ -406,7 +406,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_shape_layer, tl::to_string (shape_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_shape_area_op, tl::to_string (shape_area_op->currentText ()));
@ -454,7 +454,7 @@ public:
// .. nothing yet ..
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_polygon_layer, v)) {
@ -474,7 +474,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_polygon_layer, tl::to_string (shape_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_polygon_area_op, tl::to_string (shape_area_op->currentText ()));
@ -527,7 +527,7 @@ public:
box_layer->set_new_layer_enabled (false);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_box_layer, v)) {
@ -547,7 +547,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_box_layer, tl::to_string (box_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_box_width_op, tl::to_string (box_width_op->currentText ()));
@ -602,7 +602,7 @@ public:
path_layer->set_new_layer_enabled (false);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_path_layer, v)) {
@ -622,7 +622,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_path_layer, tl::to_string (path_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_path_width_op, tl::to_string (path_width_op->currentText ()));
@ -675,7 +675,7 @@ public:
text_layer->set_new_layer_enabled (false);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_text_layer, v)) {
@ -701,7 +701,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_text_layer, tl::to_string (text_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_text_string_op, tl::to_string (text_string_op->currentText ()));
@ -753,7 +753,7 @@ public:
setupUi (this);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_instance_cellname_value, v)) {
@ -761,7 +761,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_instance_cellname_value, tl::to_string (instance_cellname->text ()));
}
@ -795,7 +795,7 @@ public:
shape_layer->set_no_layer_available (true);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_shape_layer, v)) {
@ -803,7 +803,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_shape_layer, tl::to_string (shape_layer->currentText ()));
}
@ -833,7 +833,7 @@ public:
// .. nothing yet ..
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_polygon_layer, v)) {
@ -841,7 +841,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_polygon_layer, tl::to_string (shape_layer->currentText ()));
}
@ -875,7 +875,7 @@ public:
box_layer->set_no_layer_available (true);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_box_layer, v)) {
@ -889,7 +889,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_box_layer, tl::to_string (box_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_box_width_value, tl::to_string (box_width->text ()));
@ -927,7 +927,7 @@ public:
path_layer->set_no_layer_available (true);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_path_layer, v)) {
@ -938,7 +938,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_path_layer, tl::to_string (path_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_path_width_value, tl::to_string (path_width->text ()));
@ -974,7 +974,7 @@ public:
text_layer->set_no_layer_available (true);
}
void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const
void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
std::string v;
if (config_root->config_get (pfx + cfg_suffix_text_layer, v)) {
@ -991,7 +991,7 @@ public:
}
}
void save_state (const std::string &pfx, lay::PluginRoot *config_root) const
void save_state (const std::string &pfx, lay::Dispatcher *config_root) const
{
config_root->config_set (pfx + cfg_suffix_text_layer, tl::to_string (text_layer->currentText ()));
config_root->config_set (pfx + cfg_suffix_text_string_value, tl::to_string (text_string->text ()));

View File

@ -37,7 +37,7 @@ namespace db
namespace lay
{
class PluginRoot;
class Dispatcher;
/**
* @brief A base class for the search and replace properties widgets
@ -50,8 +50,8 @@ public:
: QWidget (parent)
{ }
virtual void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const = 0;
virtual void save_state (const std::string &pfx, lay::PluginRoot *config_root) const = 0;
virtual void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const = 0;
virtual void save_state (const std::string &pfx, lay::Dispatcher *config_root) const = 0;
};
/**

View File

@ -40,9 +40,9 @@ namespace lay
// -------------------------------------------------------------
SettingsForm::SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name)
SettingsForm::SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name)
: QDialog (parent), Ui::SettingsForm (),
mp_plugin_root (plugin_root), m_finalize_recursion (false)
mp_dispatcher (dispatcher), m_finalize_recursion (false)
{
setObjectName (QString::fromUtf8 (name));
@ -237,7 +237,7 @@ SettingsForm::setup ()
// setup the custom config pages
for (std::vector <lay::ConfigPage *>::iterator cp = m_config_pages.begin (); cp != m_config_pages.end (); ++cp) {
(*cp)->setup (mp_plugin_root);
(*cp)->setup (mp_dispatcher);
}
}
@ -246,14 +246,14 @@ SettingsForm::commit ()
{
// commit the custom config pages
for (std::vector <lay::ConfigPage *>::iterator cp = m_config_pages.begin (); cp != m_config_pages.end (); ++cp) {
(*cp)->commit (mp_plugin_root);
(*cp)->commit (mp_dispatcher);
}
m_finalize_recursion = true;
try {
// config_end will make the main window call setup on the settings form.
// the recursion sentinel takes care of that.
mp_plugin_root->config_end ();
mp_dispatcher->config_end ();
m_finalize_recursion = false;
} catch (...) {
m_finalize_recursion = false;

View File

@ -37,7 +37,7 @@
namespace lay
{
class PluginRoot;
class Dispatcher;
class ConfigPage;
class SettingsForm
@ -46,7 +46,7 @@ class SettingsForm
Q_OBJECT
public:
SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name);
SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name);
void setup ();
void commit ();
@ -58,7 +58,7 @@ public slots:
void item_changed (QTreeWidgetItem *, QTreeWidgetItem *);
private:
lay::PluginRoot *mp_plugin_root;
lay::Dispatcher *mp_dispatcher;
std::vector <lay::ConfigPage *> m_config_pages;
bool m_finalize_recursion;
};

View File

@ -50,7 +50,7 @@ std::string tech_string_from_name (const std::string &tn)
}
TechnologyController::TechnologyController ()
: PluginDeclaration (), mp_editor (0), mp_mw (0), mp_plugin_root (0), mp_active_technology (0)
: PluginDeclaration (), mp_editor (0), mp_mw (0), mp_dispatcher (0), mp_active_technology (0)
{
m_configure_enabled = true;
m_current_technology_updated = false;
@ -70,9 +70,9 @@ TechnologyController::instance ()
}
void
TechnologyController::initialize (lay::PluginRoot *root)
TechnologyController::initialize (lay::Dispatcher *dispatcher)
{
mp_plugin_root = root;
mp_dispatcher = dispatcher;
mp_mw = lay::MainWindow::instance ();
if (mp_mw) {
mp_editor = new lay::TechSetupDialog (mp_mw);
@ -81,9 +81,11 @@ TechnologyController::initialize (lay::PluginRoot *root)
}
void
TechnologyController::initialized (lay::PluginRoot * /*root*/)
TechnologyController::initialized (lay::Dispatcher *dispatcher)
{
update_menu ();
tl_assert (dispatcher == mp_dispatcher);
update_menu (mp_dispatcher);
connect_events ();
if (lay::SaltController::instance ()) {
@ -92,8 +94,10 @@ TechnologyController::initialized (lay::PluginRoot * /*root*/)
}
void
TechnologyController::uninitialize (lay::PluginRoot * /*root*/)
TechnologyController::uninitialize (lay::Dispatcher *dispatcher)
{
tl_assert (dispatcher == mp_dispatcher);
m_tech_actions.clear ();
tl::Object::detach_from_all_events ();
@ -113,7 +117,7 @@ void
TechnologyController::get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("technology_selector:apply_technology", "technology_selector:tech_selector_group", "@toolbar.end", tl::to_string (QObject::tr ("Technology<:techs.png>{Select technology (click to apply)}"))));
menu_entries.push_back (lay::menu_item ("technology_selector:apply_technology", "technology_selector:tech_selector_group", "@toolbar.end", tl::to_string (QObject::tr ("Technology<:techs.png>{Select technology (click to apply)}"))));
}
void
@ -193,7 +197,7 @@ TechnologyController::update_active_technology ()
#if 0
// Hint with this implementation, the current technology follows the current layout.
// Although that's a nice way to display the current technology, it's pretty confusing
lay::PluginRoot *pr = mp_plugin_root;
lay::Dispatcher *pr = mp_plugin_root;
if (pr) {
pr->config_set (cfg_initial_technology, active_tech);
}
@ -204,11 +208,11 @@ void
TechnologyController::technologies_changed ()
{
// update the configuration to reflect the persisted technologies
lay::PluginRoot *pr = mp_plugin_root;
if (pr) {
lay::Dispatcher *dispatcher = mp_dispatcher;
if (dispatcher) {
m_configure_enabled = false;
try {
pr->config_set (cfg_technologies, db::Technologies::instance ()->to_xml ());
dispatcher->config_set (cfg_technologies, db::Technologies::instance ()->to_xml ());
m_configure_enabled = true;
} catch (...) {
m_configure_enabled = true;
@ -216,7 +220,7 @@ TechnologyController::technologies_changed ()
}
}
update_menu ();
update_menu (dispatcher);
emit technologies_edited ();
}
@ -265,16 +269,16 @@ TechnologyController::configure (const std::string &name, const std::string &val
void
TechnologyController::config_finalize ()
{
if (m_current_technology_updated) {
update_current_technology ();
m_current_technology_updated = false;
}
if (m_technologies_configured) {
update_menu ();
update_menu (mp_dispatcher);
emit technologies_edited ();
m_technologies_configured = false;
}
if (m_current_technology_updated) {
update_current_technology (mp_dispatcher);
m_current_technology_updated = false;
}
}
bool
@ -296,19 +300,18 @@ TechnologyController::menu_activated (const std::string &symbol) const
}
void
TechnologyController::update_current_technology ()
TechnologyController::update_current_technology (lay::Dispatcher *dispatcher)
{
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
if (! pr) {
if (! dispatcher || ! dispatcher->has_ui ()) {
return;
}
std::string title = tech_string_from_name (m_current_technology);
std::vector<std::string> menu_entries = pr->menu ()->group ("tech_selector_group");
std::vector<std::string> menu_entries = dispatcher->menu ()->group ("tech_selector_group");
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
lay::Action action = pr->menu ()->action (*m);
action.set_title (title);
lay::Action *action = dispatcher->menu ()->action (*m);
action->set_title (title);
}
std::map<std::string, const db::Technology *> tech_by_name;
@ -316,17 +319,16 @@ TechnologyController::update_current_technology ()
tech_by_name.insert (std::make_pair (t->name (), t.operator-> ()));
}
int it = 0;
for (std::map<std::string, const db::Technology *>::const_iterator t = tech_by_name.begin (); t != tech_by_name.end (); ++t, ++it) {
m_tech_actions[it].set_checked (t->second->name () == m_current_technology);
size_t it = 0;
for (std::map<std::string, const db::Technology *>::const_iterator t = tech_by_name.begin (); t != tech_by_name.end () && it < m_tech_actions.size (); ++t, ++it) {
m_tech_actions[it]->set_checked (t->second->name () == m_current_technology);
}
}
void
TechnologyController::update_menu ()
TechnologyController::update_menu (lay::Dispatcher *dispatcher)
{
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
if (! pr) {
if (! dispatcher || ! dispatcher->has_ui ()) {
return;
}
@ -345,15 +347,15 @@ TechnologyController::update_menu ()
++ntech;
}
std::vector<std::string> tech_group = pr->menu ()->group ("tech_selector_group");
std::vector<std::string> tech_group = dispatcher->menu ()->group ("tech_selector_group");
for (std::vector<std::string>::const_iterator t = tech_group.begin (); t != tech_group.end (); ++t) {
lay::Action action = pr->menu ()->action (*t);
action.set_title (title);
action.set_enabled (ntech > 1);
std::vector<std::string> items = pr->menu ()->items (*t);
lay::Action *action = dispatcher->menu ()->action (*t);
action->set_title (title);
action->set_enabled (ntech > 1);
std::vector<std::string> items = dispatcher->menu ()->items (*t);
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
pr->menu ()->delete_item (*i);
dispatcher->menu ()->delete_item (*i);
}
}
@ -372,7 +374,7 @@ TechnologyController::update_menu ()
std::string tp = *tg;
if (! g->first.empty ()) {
std::string gn = "techgroup_" + tl::to_string (++ig);
pr->menu ()->insert_menu (*tg + ".end", gn, g->first);
dispatcher->menu ()->insert_menu (*tg + ".end", gn, g->first);
tp = *tg + "." + gn;
}
tp += ".end";
@ -382,11 +384,11 @@ TechnologyController::update_menu ()
std::string title = tech_string_from_name (t->first);
m_tech_actions.push_back (pr->create_config_action ("", cfg_initial_technology, t->first));
m_tech_actions.back ().set_title (title); // setting the title here avoids interpretation of '(...)' etc.
m_tech_actions.back ().set_checkable (true);
m_tech_actions.back ().set_checked (t->first == m_current_technology);
pr->menu ()->insert_item (tp, "technology_" + tl::to_string (it), m_tech_actions.back ());
m_tech_actions.push_back (new lay::ConfigureAction ("", cfg_initial_technology, t->first));
m_tech_actions.back ()->set_title (title); // setting the title here avoids interpretation of '(...)' etc.
m_tech_actions.back ()->set_checkable (true);
m_tech_actions.back ()->set_checked (t->first == m_current_technology);
dispatcher->menu ()->insert_item (tp, "technology_" + tl::to_string (it), m_tech_actions.back ());
}
@ -490,7 +492,7 @@ TechnologyController::show_editor ()
}
mp_plugin_root->config_set (cfg_tech_editor_window_state, lay::save_dialog_state (mp_editor));
mp_dispatcher->config_set (cfg_tech_editor_window_state, lay::save_dialog_state (mp_editor));
}
const std::string &

View File

@ -54,9 +54,9 @@ public:
*/
TechnologyController ();
void initialize (lay::PluginRoot *root);
void initialized (lay::PluginRoot *root);
void uninitialize (lay::PluginRoot *root);
void initialize (lay::Dispatcher *root);
void initialized (lay::Dispatcher *root);
void uninitialize (lay::Dispatcher *root);
void get_options (std::vector < std::pair<std::string, std::string> > &options) const;
void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const;
@ -125,14 +125,14 @@ private slots:
void sync_with_external_sources ();
private:
tl::stable_vector <lay::Action> m_tech_actions;
std::vector <lay::Action *> m_tech_actions;
std::string m_current_technology;
bool m_configure_enabled;
bool m_current_technology_updated;
bool m_technologies_configured;
lay::TechSetupDialog *mp_editor;
lay::MainWindow *mp_mw;
lay::PluginRoot *mp_plugin_root;
lay::Dispatcher *mp_dispatcher;
std::vector<std::string> m_paths;
std::vector<db::Technology> m_temp_tech;
db::Technology *mp_active_technology;
@ -144,8 +144,8 @@ private:
bool configure (const std::string &name, const std::string &value);
void config_finalize ();
bool menu_activated (const std::string &symbol) const;
void update_current_technology ();
void update_menu ();
void update_current_technology (Dispatcher *dispatcher);
void update_menu (lay::Dispatcher *dispatcher);
void replace_technologies (const db::Technologies &technologies);
};

View File

@ -402,19 +402,148 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutView *view, u
return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index));
}
static lay::LayoutView *new_view ()
static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options)
{
return new lay::LayoutView (0, false, 0);
lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options);
if (parent) {
// transfer ownership to the parent
lv->keep ();
}
return lv;
}
Class<lay::LayoutView> decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView",
gsi::constructor ("new", &new_view,
gsi::constructor ("new", &new_view, gsi::arg ("parent", (QWidget *) 0, "nil"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0),
"@brief Creates a standalone view\n"
"\n"
"This constructor is for special purposes only. To create a view in the context of a main window, "
"use \\MainWindow#create_view and related methods.\n"
"\n"
"@param parent The parent widget in which to embed the view\n"
"@param editable True to make the view editable\n"
"@param manager The \\Manager object to enable undo/redo\n"
"@param options A combination of the values in the LV_... constants\n"
"\n"
"This constructor has been introduced in version 0.25.\n"
"It has been enhanced with the arguments in version 0.27.\n"
) +
gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutView::LV_NoLayers,
"@brief With this option, no layers view will be provided (see \\layer_control_frame)\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutView::LV_NoHierarchyPanel,
"@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutView::LV_NoLibrariesView,
"@brief With this option, no library view will be provided (see \\libraries_frame)\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView,
"@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_Naked", (unsigned int) lay::LayoutView::LV_Naked,
"@brief With this option, no separate views will be provided\n"
"Use this value with the constructor's 'options' argument.\n"
"This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutView::LV_NoZoom,
"@brief With this option, zooming is disabled\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutView::LV_NoGrid,
"@brief With this option, the grid background is not shown\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutView::LV_NoMove,
"@brief With this option, move operations are not supported\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutView::LV_NoTracker,
"@brief With this option, mouse position tracking is not supported\n"
"Use this value with the constructor's 'options' argument.\n"
"This option is not useful currently as no mouse tracking support is provided.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutView::LV_NoSelection,
"@brief With this option, objects cannot be selected\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutView::LV_NoPlugins,
"@brief With this option, all plugins are disabled\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutView::LV_NoServices,
"@brief This option disables all services except the ones for pure viewing\n"
"Use this value with the constructor's 'options' argument.\n"
"With this option, all manipulation features are disabled, except zooming.\n"
"It is equivalent to \\LV_NoMove + \\LV_NoTracker + \\LV_NoSelection + \\LV_NoPlugins.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
#if defined(HAVE_QTBINDINGS)
gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame,
"@brief Gets the layer control side widget\n"
"A 'side widget' is a widget attached to the view. It does not have a parent, so you can "
"embed it into a different context. Please note that with embedding through 'setParent' it will be "
"destroyed when your parent widget gets destroyed. It will be lost then to the view.\n"
"\n"
"The side widget can be configured through the views configuration interface.\n"
"\n"
"This method has been introduced in version 0.27\n"
) +
gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame,
"@brief Gets the cell view (hierarchy view) side widget\n"
"For details about side widgets see \\layer_control_frame.\n"
"\n"
"This method has been introduced in version 0.27\n"
) +
gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame,
"@brief Gets the library view side widget\n"
"For details about side widgets see \\layer_control_frame.\n"
"\n"
"This method has been introduced in version 0.27\n"
) +
gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame,
"@brief Gets the bookmarks side widget\n"
"For details about side widgets see \\layer_control_frame.\n"
"\n"
"This method has been introduced in version 0.27\n"
) +
#endif
gsi::method ("call_menu", &lay::LayoutView::menu_activated,
"@brief Calls the menu item with the provided symbol.\n"
"To obtain all symbols, use get_menu_symbols.\n"
"\n"
"This method has been introduced in version 0.27."
) +
gsi::method ("menu_symbols", &lay::LayoutView::menu_symbols,
"@brief Gets all available menu symbols (see \\call_menu).\n"
"NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n"
"\n"
"This method has been introduced in version 0.27."
) +
gsi::method ("current", &lay::LayoutView::current,
"@brief Returns the current view\n"

View File

@ -25,6 +25,34 @@
#include "gsiSignals.h"
#include "layAbstractMenu.h"
namespace {
// The Action stub to allow reimplementation of the triggered method
class ActionStub
: public lay::Action
{
public:
virtual void triggered ()
{
if (triggered_cb.can_issue ()) {
triggered_cb.issue<lay::Action> (&lay::Action::triggered);
}
on_triggered_event ();
}
gsi::Callback triggered_cb;
tl::Event on_triggered_event;
};
}
namespace tl
{
template <> struct type_traits<ActionStub> : public type_traits<void> {
typedef tl::false_tag has_copy_constructor;
};
}
namespace gsi
{
@ -58,7 +86,14 @@ static std::map<std::string, bool> unpack_menu_items_hidden (const std::string &
return kb;
}
static lay::AbstractMenu *new_menu ()
{
return new lay::AbstractMenu (0);
}
Class<lay::AbstractMenu> decl_AbstractMenu ("lay", "AbstractMenu",
// for test purposes mainly:
constructor ("new", &new_menu, "@hide") +
method ("pack_key_binding", &pack_key_binding, gsi::arg ("path_to_keys"),
"@brief Serializes a key binding definition into a single string\n"
"The serialized format is used by the 'key-bindings' config key. "
@ -87,26 +122,26 @@ Class<lay::AbstractMenu> decl_AbstractMenu ("lay", "AbstractMenu",
"\n"
"This method has been introduced in version 0.26."
) +
method ("action", &lay::AbstractMenu::action, gsi::arg ("path"),
"@brief Get the reference to a Action object associated with the given path\n"
method ("action", (lay::Action *(lay::AbstractMenu::*) (const std::string &path)) &lay::AbstractMenu::action, gsi::arg ("path"),
"@brief Gets the reference to a Action object associated with the given path\n"
"\n"
"@param path The path to the item. This must be a valid path.\n"
"@return A reference to a Action object associated with this path\n"
"@param path The path to the item.\n"
"@return A reference to a Action object associated with this path or nil if the path is not valid\n"
) +
method ("items", &lay::AbstractMenu::items, gsi::arg ("path"),
"@brief Get the subitems for a given submenu\n"
"@brief Gets the subitems for a given submenu\n"
"\n"
"@param path The path to the submenu\n"
"@return A vector or path strings for the child items or an empty vector if the path is not valid or the item does not have children\n"
) +
method ("is_menu?", &lay::AbstractMenu::is_menu, gsi::arg ("path"),
"@brief Query if an item is a menu\n"
"@brief Returns true if the item is a menu\n"
"\n"
"@param path The path to the item\n"
"@return false if the path is not valid or is not a menu\n"
) +
method ("is_separator?", &lay::AbstractMenu::is_separator, gsi::arg ("path"),
"@brief Query if an item is a separator\n"
"@brief Returns true if the item is a separator\n"
"\n"
"@param path The path to the item\n"
"@return false if the path is not valid or is not a separator\n"
@ -114,13 +149,13 @@ Class<lay::AbstractMenu> decl_AbstractMenu ("lay", "AbstractMenu",
"This method has been introduced in version 0.19.\n"
) +
method ("is_valid?", &lay::AbstractMenu::is_valid, gsi::arg ("path"),
"@brief Query if a path is a valid one\n"
"@brief Returns true if the path is a valid one\n"
"\n"
"@param path The path to check\n"
"@return false if the path is not a valid path to an item\n"
) +
method ("insert_item", (void (lay::AbstractMenu::*) (const std::string &, const std::string &, const lay::Action &)) &lay::AbstractMenu::insert_item, gsi::arg ("path"), gsi::arg ("name"), gsi::arg ("action"),
"@brief Insert a new item before the one given by the path\n"
"@brief Inserts a new item before the one given by the path\n"
"\n"
"The Action object passed as the third parameter references the handler which both implements the "
"action to perform and the menu item's appearance such as title, icon and keyboard shortcut.\n"
@ -130,13 +165,13 @@ Class<lay::AbstractMenu> decl_AbstractMenu ("lay", "AbstractMenu",
"@param action The Action object to insert\n"
) +
method ("insert_separator", &lay::AbstractMenu::insert_separator, gsi::arg ("path"), gsi::arg ("name"),
"@brief Insert a new separator before the item given by the path\n"
"@brief Inserts a new separator before the item given by the path\n"
"\n"
"@param path The path to the item before which to insert the separator\n"
"@param name The name of the separator to insert \n"
) +
method ("insert_menu", (void (lay::AbstractMenu::*) (const std::string &, const std::string &, const std::string &)) &lay::AbstractMenu::insert_menu, gsi::arg ("path"), gsi::arg ("name"), gsi::arg ("title"),
"@brief Insert a new submenu before the item given by the path\n"
"@brief Inserts a new submenu before the item given by the path\n"
"\n"
"The title string optionally encodes the key shortcut and icon resource\n"
"in the form <text>[\"(\"<shortcut>\")\"][\"<\"<icon-resource>\">\"].\n"
@ -146,17 +181,17 @@ Class<lay::AbstractMenu> decl_AbstractMenu ("lay", "AbstractMenu",
"@param title The title of the submenu to insert\n"
) +
method ("delete_item", &lay::AbstractMenu::delete_item, gsi::arg ("path"),
"@brief Delete the item given by the path\n"
"@brief Deletes the item given by the path\n"
"\n"
"@param path The path to the item to delete\n"
) +
method ("group", &lay::AbstractMenu::group, gsi::arg ("group"),
"@brief Get the group members\n"
"@brief Gets the group members\n"
"\n"
"@param group The group name\n"
"@param A vector of all members (by path) of the group\n"
),
"@brief The abstract menu class\n"
"@brief An abstraction for the application menues\n"
"\n"
"The abstract menu is a class that stores a main menu and several popup menus\n"
"in a generic form such that they can be manipulated and converted into GUI objects.\n"
@ -275,17 +310,17 @@ Class<lay::Action> decl_ActionBase ("lay", "ActionBase",
"This method has been introduced in version 0.25.\n"
) +
method ("checkable=", &lay::Action::set_checkable, gsi::arg ("checkable"),
"@brief Make the item(s) checkable or not\n"
"@brief Makes the item(s) checkable or not\n"
"\n"
"@param checkable true to make the item checkable\n"
) +
method ("enabled=", &lay::Action::set_enabled, gsi::arg ("enabled"),
"@brief Enable or disable the action\n"
"@brief Enables or disables the action\n"
"\n"
"@param enabled true to enable the item\n"
) +
method ("visible=", &lay::Action::set_visible, gsi::arg ("visible"),
"@brief Show or hide\n"
"@brief Sets the item's visibility\n"
"\n"
"@param visible true to make the item visible\n"
) +
@ -296,29 +331,29 @@ Class<lay::Action> decl_ActionBase ("lay", "ActionBase",
"This attribute has been introduced in version 0.25\n"
) +
method ("checked=", &lay::Action::set_checked, gsi::arg ("checked"),
"@brief Check or uncheck\n"
"@brief Checks or unchecks the item\n"
"\n"
"@param checked true to make the item checked\n"
) +
method ("icon=", &lay::Action::set_icon, gsi::arg ("file"),
"@brief Set the icon to the given picture\n"
"@brief Sets the icon to the given image file\n"
"\n"
"@param file The image file to load for the icon\n"
"\n"
"Passing an empty string will reset the icon\n"
"Passing an empty string will reset the icon.\n"
) +
method ("icon_text=", &lay::Action::set_icon_text, gsi::arg ("icon_text"),
"@brief Set the icon's text \n"
"@brief Sets the icon's text\n"
"\n"
"If an icon text is set, this will be used for the text below the icon.\n"
"If no icon text is set, the normal text will be used for the icon.\n"
"Passing an empty string will reset the icon's text.\n"
) +
method ("icon_text", &lay::Action::get_icon_text,
"@brief Get the icon's text\n"
"@brief Gets the icon's text\n"
) +
method ("tool_tip=", &lay::Action::set_tool_tip, gsi::arg ("text"),
"@brief Set the tool tip text \n"
"@brief Sets the tool tip text\n"
"\n"
"The tool tip text is displayed in the tool tip window of the menu entry.\n"
"This is in particular useful for entries in the tool bar."
@ -326,34 +361,17 @@ Class<lay::Action> decl_ActionBase ("lay", "ActionBase",
"This method has been added in version 0.22.\n"
) +
method ("tool_tip", &lay::Action::get_tool_tip,
"@brief Get the tool tip text\n"
"@brief Gets the tool tip text.\n"
"\n"
"This method has been added in version 0.22.\n"
) +
method ("trigger", &lay::Action::trigger,
"@brief Trigger the action programmatically"
"@brief Triggers the action programmatically"
),
"@hide\n"
"@alias Action\n"
);
// The Action stub to allow reimplementation of the triggered method
class ActionStub
: public lay::Action
{
public:
virtual void triggered ()
{
if (triggered_cb.can_issue ()) {
triggered_cb.issue<lay::Action> (&lay::Action::triggered);
}
on_triggered_event ();
}
gsi::Callback triggered_cb;
tl::Event on_triggered_event;
};
Class<ActionStub> decl_Action (decl_ActionBase, "lay", "Action",
gsi::callback ("triggered", &ActionStub::triggered, &ActionStub::triggered_cb,
"@brief This method is called if the menu item is selected"

View File

@ -56,14 +56,14 @@ namespace gsi
// of the factory, this hack is a quick but dirty workaround.
static bool s_in_create_plugin = false;
static lay::LayoutView *sp_view = 0;
static lay::PluginRoot *sp_root = 0;
static lay::Dispatcher *sp_dispatcher = 0;
class PluginBase
: public lay::Plugin, public lay::ViewService
{
public:
PluginBase ()
: lay::Plugin (sp_root), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0)
: lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0)
{
if (! s_in_create_plugin) {
throw tl::Exception (tl::to_string (QObject::tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method")));
@ -334,7 +334,7 @@ public:
}
}
virtual void initialize (lay::PluginRoot *root)
virtual void initialize (lay::Dispatcher *root)
{
if (f_initialize.can_issue ()) {
f_initialize.issue<lay::PluginDeclaration> (&lay::PluginDeclaration::initialize, root);
@ -343,7 +343,7 @@ public:
}
}
virtual void uninitialize (lay::PluginRoot *root)
virtual void uninitialize (lay::Dispatcher *root)
{
if (f_uninitialize.can_issue ()) {
f_uninitialize.issue<lay::PluginDeclaration> (&lay::PluginDeclaration::uninitialize, root);
@ -352,7 +352,7 @@ public:
}
}
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const
{
if (f_create_plugin.can_issue ()) {
return create_plugin_gsi (manager, root, view);
@ -361,22 +361,22 @@ public:
}
}
virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const
virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const
{
// TODO: this is a hack. See notes above at s_in_create_plugin
s_in_create_plugin = true;
sp_view = view;
sp_root = root;
sp_dispatcher = root;
gsi::PluginBase *ret = 0;
try {
ret = f_create_plugin.issue<PluginFactoryBase, gsi::PluginBase *, db::Manager *, lay::PluginRoot *, lay::LayoutView *> (&PluginFactoryBase::create_plugin_gsi, manager, root, view);
ret = f_create_plugin.issue<PluginFactoryBase, gsi::PluginBase *, db::Manager *, lay::Dispatcher *, lay::LayoutView *> (&PluginFactoryBase::create_plugin_gsi, manager, root, view);
s_in_create_plugin = false;
sp_view = 0;
sp_root = 0;
sp_dispatcher = 0;
} catch (...) {
s_in_create_plugin = false;
sp_view = 0;
sp_root = 0;
sp_dispatcher = 0;
}
return ret;
@ -394,17 +394,36 @@ public:
void add_menu_entry1 (const std::string &menu_name, const std::string &insert_pos)
{
m_menu_entries.push_back (lay::MenuEntry (menu_name, insert_pos));
m_menu_entries.push_back (lay::separator (menu_name, insert_pos));
}
void add_menu_entry2 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title)
{
m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title));
m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title));
}
void add_menu_entry_copy (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &copy_from)
{
m_menu_entries.push_back (lay::menu_item_copy (symbol, menu_name, insert_pos, copy_from));
}
void add_submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title)
{
m_menu_entries.push_back (lay::submenu (menu_name, insert_pos, title));
}
void add_config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue)
{
m_menu_entries.push_back (lay::config_menu_item (menu_name, insert_pos, title, cname, cvalue));
}
void add_menu_entry3 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title, bool sub_menu)
{
m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title, sub_menu));
if (sub_menu) {
m_menu_entries.push_back (lay::submenu (symbol, menu_name, insert_pos, title));
} else {
m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title));
}
}
void add_option (const std::string &name, const std::string &default_value)
@ -491,21 +510,21 @@ Class<gsi::PluginFactoryBase> decl_PluginFactory ("lay", "PluginFactory",
"If this method was handling the menu event, it should return true. This indicates that the event "
"will not be propagated to other plugins hence avoiding duplicate calls.\n"
) +
callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, gsi::arg ("root"),
callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, gsi::arg ("dispatcher"),
"@brief Gets called when the plugin singleton is initialized, i.e. when the application has been started.\n"
"@param root The reference to the \\MainWindow object\n"
"@param dispatcher The reference to the \\MainWindow object\n"
) +
callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, gsi::arg ("root"),
callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, gsi::arg ("dispatcher"),
"@brief Gets called when the application shuts down and the plugin is unregistered\n"
"This event can be used to free resources allocated with this factory singleton.\n"
"@param root The reference to the \\MainWindow object\n"
"@param dispatcher The reference to the \\MainWindow object\n"
) +
factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, gsi::arg ("manager"), gsi::arg ("root"), gsi::arg ("view"),
factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, gsi::arg ("manager"), gsi::arg ("dispatcher"), gsi::arg ("view"),
"@brief Creates the plugin\n"
"This is the basic functionality that the factory must provide. This method must create a plugin of the "
"specific type.\n"
"@param manager The database manager object responsible for handling database transactions\n"
"@param root The reference to the \\MainWindow object\n"
"@param dispatcher The reference to the \\MainWindow object\n"
"@param view The \\LayoutView that is plugin is created for\n"
"@return The new \\Plugin implementation object\n"
) +
@ -527,10 +546,33 @@ Class<gsi::PluginFactoryBase> decl_PluginFactory ("lay", "PluginFactory",
"@param insert_pos The position where to create the entry\n"
"@param title The title string for the item. The title can contain a keyboard shortcut in round braces after the title text, i.e. \"My Menu Item(F12)\"\n"
) +
method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("sub_menu"),
method ("#add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("sub_menu"),
"@brief Specifies a menu item or sub-menu\n"
"Similar to the previous form of \"add_menu_entry\", but this version allows also to create sub-menus by setting the "
"last parameter to \"true\""
"last parameter to \"true\".\n"
"\n"
"With version 0.27 it's more convenient to use \\add_submenu."
) +
method ("add_menu_item_clone", &gsi::PluginFactoryBase::add_menu_entry_copy, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("copy_from"),
"@brief Specifies a menu item as a clone of another one\n"
"Using this method, a menu item can be made a clone of another entry (given as path by 'copy_from').\n"
"The new item will share the \\Action object with the original one, so manipulating the action will change both the original entry "
"and the new entry.\n"
"\n"
"This method has been introduced in version 0.27."
) +
method ("add_submenu", &gsi::PluginFactoryBase::add_submenu, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"),
"@brief Specifies a menu item or sub-menu\n"
"\n"
"This method has been introduced in version 0.27."
) +
method ("add_config_menu_item", &gsi::PluginFactoryBase::add_config_menu_item, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("cname"), gsi::arg ("cvalue"),
"@brief Adds a configuration menu item\n"
"\n"
"Menu items created this way will send a configuration request with 'cname' as the configuration parameter name "
"and 'cvalue' as the configuration parameter value.\n"
"\n"
"This method has been introduced in version 0.27."
) +
method ("add_option", &gsi::PluginFactoryBase::add_option, gsi::arg ("name"), gsi::arg ("default_value"),
"@brief Specifies configuration variables.\n"
@ -588,7 +630,7 @@ Class<gsi::PluginFactoryBase> decl_PluginFactory ("lay", "PluginFactory",
" end\n"
" \n"
" # Create a new plugin instance of the custom type\n"
" def create_plugin(manager, root, view)\n"
" def create_plugin(manager, dispatcher, view)\n"
" return PluginTest.new\n"
" end\n"
"\n"
@ -816,22 +858,22 @@ Class<gsi::ButtonStateNamespace> decl_ButtonState ("lay", "ButtonState",
);
static std::vector<std::string>
get_config_names (lay::PluginRoot *root)
get_config_names (lay::Dispatcher *dispatcher)
{
std::vector<std::string> names;
root->get_config_names (names);
dispatcher->get_config_names (names);
return names;
}
static lay::PluginRoot *config_root_instance ()
static lay::Dispatcher *dispatcher_instance ()
{
return lay::PluginRoot::instance ();
return lay::Dispatcher::instance ();
}
static tl::Variant get_config (lay::PluginRoot *root, const std::string &name)
static tl::Variant get_config (lay::Dispatcher *dispatcher, const std::string &name)
{
std::string value;
if (root->config_get (name, value)) {
if (dispatcher->config_get (name, value)) {
return tl::Variant (value);
} else {
return tl::Variant ();
@ -839,33 +881,33 @@ static tl::Variant get_config (lay::PluginRoot *root, const std::string &name)
}
/**
* @brief Exposes the PluginRoot interface
* @brief Exposes the Dispatcher interface
*
* This interface is intentionally not derived from Plugin. It is used currently to
* identify the plugin root node for configuration. The Plugin nature of this interface
* identify the dispatcher node for configuration. The Plugin nature of this interface
* is somewhat artificial and may be removed later.
*
* TODO: this is a duplicate of the respective methods in LayoutView and Application.
* This is intentional since we don't want to spend the only derivation path on this.
* Once there is a mixin concept, provide a path through that concept.
*/
Class<lay::PluginRoot> decl_PluginRoot ("lay", "PluginRoot",
method ("clear_config", &lay::PluginRoot::clear_config,
Class<lay::Dispatcher> decl_Dispatcher ("lay", "Dispatcher",
method ("clear_config", &lay::Dispatcher::clear_config,
"@brief Clears the configuration parameters\n"
) +
method ("instance", &config_root_instance,
"@brief Gets the singleton instance of the PluginRoot object\n"
method ("instance", &dispatcher_instance,
"@brief Gets the singleton instance of the Dispatcher object\n"
"\n"
"@return The instance\n"
) +
method ("write_config", &lay::PluginRoot::write_config, gsi::arg ("file_name"),
method ("write_config", &lay::Dispatcher::write_config, gsi::arg ("file_name"),
"@brief Writes configuration to a file\n"
"@return A value indicating whether the operation was successful\n"
"\n"
"If the configuration file cannot be written, false \n"
"is returned but no exception is thrown.\n"
) +
method ("read_config", &lay::PluginRoot::read_config, gsi::arg ("file_name"),
method ("read_config", &lay::Dispatcher::read_config, gsi::arg ("file_name"),
"@brief Reads the configuration from a file\n"
"@return A value indicating whether the operation was successful\n"
"\n"
@ -880,7 +922,7 @@ Class<lay::PluginRoot> decl_PluginRoot ("lay", "PluginRoot",
"\n"
"@return The value of the parameter or nil if there is no such parameter\n"
) +
method ("set_config", (void (lay::PluginRoot::*) (const std::string &, const std::string &)) &lay::PluginRoot::config_set, gsi::arg ("name"), gsi::arg ("value"),
method ("set_config", (void (lay::Dispatcher::*) (const std::string &, const std::string &)) &lay::Dispatcher::config_set, gsi::arg ("name"), gsi::arg ("value"),
"@brief Set a local configuration parameter with the given name to the given value\n"
"\n"
"@param name The name of the configuration parameter to set\n"
@ -900,14 +942,14 @@ Class<lay::PluginRoot> decl_PluginRoot ("lay", "PluginRoot",
"This method returns the names of all known configuration parameters. These names can be used to "
"get and set configuration parameter values.\n"
) +
method ("commit_config", &lay::PluginRoot::config_end,
method ("commit_config", &lay::Dispatcher::config_end,
"@brief Commits the configuration settings\n"
"\n"
"Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. "
"After a sequence of \\set_config calls, this method should be called to activate the "
"settings made by these calls.\n"
),
"@brief Root of the configuration space in the plugin context\n"
"@brief Root of the configuration space in the plugin context and menu dispatcher\n"
"\n"
"This class provides access to the root configuration space in the context "
"of plugin programming. You can use this class to obtain configuration parameters "
@ -915,12 +957,12 @@ Class<lay::PluginRoot> decl_PluginRoot ("lay", "PluginRoot",
"preferred way of plugin configuration is through \\Plugin#configure.\n"
"\n"
"Currently, the application object provides an identical entry point for configuration modification. "
"For example, \"Application::instance.set_config\" is identical to \"PluginRoot::instance.set_config\". "
"Hence there is little motivation for the PluginRoot class currently and "
"For example, \"Application::instance.set_config\" is identical to \"Dispatcher::instance.set_config\". "
"Hence there is little motivation for the Dispatcher class currently and "
"this interface may be modified or removed in the future."
"\n"
"\n"
"This class has been introduced in version 0.25.\n"
"This class has been introduced in version 0.25 as 'PluginRoot'.\n"
"It is renamed and enhanced as 'Dispatcher' in 0.27."
);
}

File diff suppressed because it is too large Load Diff

View File

@ -50,10 +50,9 @@ class QMenu;
namespace lay
{
class AbstractMenuProvider;
class Action;
class AbstractMenu;
class PluginRoot;
class Dispatcher;
/**
* @brief A utility function to convert the packed key binding in the cfg_key_bindings string to a vector
@ -76,115 +75,54 @@ LAYBASIC_PUBLIC std::vector<std::pair<std::string, bool> > unpack_menu_items_hid
LAYBASIC_PUBLIC std::string pack_menu_items_hidden (const std::vector<std::pair<std::string, bool> > &unpacked);
/**
* @brief A helper class that does reference counting for the QAction object
*/
class ActionHandle
: public QObject
{
Q_OBJECT
public:
ActionHandle (QWidget *parent);
ActionHandle (QAction *action, bool owned = true);
ActionHandle (QMenu *menu, bool owned = true);
~ActionHandle ();
void add_ref ();
void remove_ref ();
QAction *ptr () const;
QMenu *menu () const;
void set_visible (bool v);
void set_hidden (bool h);
bool is_visible () const;
bool is_hidden () const;
bool is_effective_visible () const;
void set_default_shortcut (const std::string &sc);
void set_shortcut (const std::string &sc);
std::string get_default_shortcut () const;
std::string get_shortcut() const;
QKeySequence get_key_sequence () const;
QKeySequence get_key_sequence_for (const std::string &sc) const;
protected slots:
void destroyed (QObject *obj);
private:
QMenu *mp_menu;
QAction *mp_action;
int m_ref_count;
bool m_owned;
bool m_visible;
bool m_hidden;
std::string m_default_shortcut;
QKeySequence m_default_key_sequence;
std::string m_shortcut;
QKeySequence m_key_sequence;
bool m_no_key_sequence;
// no copying
ActionHandle (const ActionHandle &);
ActionHandle &operator= (const ActionHandle &);
};
/**
* @brief A QAction proxy
* @brief The basic Action object
*
* This class is provided to be better suited to automation because it provides the corresponding interfaces
* and allows implementing the "trigger" event by reimplementation of the slot (after being connected).
* In addition, by acting as a proxy, it can act as a reference to a QAction object created by Qt itself (i.e.
* within a QMenu).
* To reimplement the "triggered" method, derive a class from Action and reimplement "triggered". Then
* pass a reference to this object to "insert_item" of AbstractMenu and store away the derived object.
* This object then will receive the triggered events, although the menu holds a pure Action object.
* This works since the basic object is the QAction to which both the derived object and the Action
* point to. A triggered event will be forwarded from this QAction to all referencing Action objects.
* An "action" is the target of a menu action. It allows reimplementing the "triggered" method
* to implement a specific action. The action encapsulates a QAction object.
*
* Use this object in "insert_item" of AbstractMenu.
*
* This object is typically owned by the AbstractMenu and cannot be copied or assigned.
*/
class LAYBASIC_PUBLIC Action
: public QObject
: public QObject,
public tl::Object,
public gsi::ObjectBase
{
Q_OBJECT
public:
/**
* @brief The default constructor
*
* This constructor creates an QAction object internally which is owned by the Action object.
* @brief The main constructor
*/
Action ();
Action ();
/**
* @brief The copy constructor
*
* This constructor creates an QAction object internally which is owned by the Action object.
* @brief Creates an action from the given QAction
* If "owned" is true, the QAction will become owned by the Action object.
*/
Action (const Action &action);
Action (QAction *action, bool owned = true);
/**
* @brief Create an action with the given title (icon, keyboard shortcut)
* @brief Creates an action from the given QMenu
* If "owned" is true, the QAction will become owned by the Action object.
*/
Action (QMenu *menu, bool owned = true);
/**
* @brief Creates an action with the given title (icon, keyboard shortcut)
*
* The title will optionally encode the shortcut and/or icon resource.
* The format of the title string is: <text>["("shortcut")"]["<"icon-resource">"]
*
* @param title The title string encoding icon and keyboard shortcut if applicable.
*/
Action (const std::string &title);
Action (const std::string &title);
/**
* @brief Creates a new free action
* This constructor wil create a new action with it's own QAction object
* under the given parent.
* @brief Destructor
*/
static Action create_free_action (QWidget *parent);
/**
* @brief Assignement
*/
Action &operator= (const Action &action);
/**
* @brief The destructor
*/
~Action ();
~Action ();
/**
* @brief Set the title
@ -309,7 +247,7 @@ public:
void set_separator (bool s);
/**
* @brief Set the tool tip text
* @brief Set the tool tip text
*
* @param text The text to display in the tool tip
*/
@ -325,7 +263,7 @@ public:
void set_icon (const std::string &filename);
/**
* @brief Set the icon's text
* @brief Set the icon's text
*
* If an icon text is set, this will be used for the text below the icon.
* If no icon text is set, the normal text will be used for the icon.
@ -333,7 +271,7 @@ public:
*/
void set_icon_text (const std::string &icon_text);
/**
/**
* @brief Set the action's QObject name (for testing for example)
*/
void set_object_name (const std::string &name);
@ -344,12 +282,12 @@ public:
void add_to_exclusive_group (lay::AbstractMenu *menu, const std::string &group_name);
/**
* @brief Get the tool tip text
* @brief Get the tool tip text
*/
std::string get_tool_tip () const;
/**
* @brief Get the icon's text
* @brief Get the icon's text
*/
std::string get_icon_text () const;
@ -376,72 +314,76 @@ public:
QMenu *menu () const;
/**
* @brief Compares two action objects
*
* Two action objects are equal when they refer to the same ActionHandle.
* @brief Gets the dispatcher object this action is connected to
*/
bool operator== (const Action &other) const
Dispatcher *dispatcher () const
{
return mp_handle == other.mp_handle;
return mp_dispatcher;
}
public slots:
void triggered_slot ();
protected slots:
void destroyed (QObject *obj);
void qaction_triggered ();
private:
friend class AbstractMenu;
friend struct AbstractMenuItem;
ActionHandle *mp_handle;
QMenu *mp_menu;
QAction *mp_action;
lay::Dispatcher *mp_dispatcher;
bool m_owned;
bool m_visible;
bool m_hidden;
std::string m_default_shortcut;
QKeySequence m_default_key_sequence;
std::string m_shortcut;
std::string m_symbol;
QKeySequence m_key_sequence;
bool m_no_key_sequence;
/**
* @brief The proxy constructor
*
* This constructor takes a QAction object that it will refer to.
* If the Action is copied, the copy will refer to the same QAction.
* The QAction object is deleted if the last Action referring to QAction is deleted.
*/
Action (ActionHandle *action);
void set_dispatcher (Dispatcher *dispatcher);
QKeySequence get_key_sequence () const;
QKeySequence get_key_sequence_for (const std::string &sc) const;
// no copying
Action (const Action &);
Action &operator= (const Action &);
};
/**
* @brief A specialisation for the Action to issue a "configure" request on "triggered"
*
* When this action is triggered, a "configure" request is issued to the PluginRoot instance
* When this action is triggered, a "configure" request is issued to the Dispatcher instance
* (which is the root of the configuration hierarchy). The name and value is given by the
* respective parameters passed to the constructor or set with the write accessors.
*/
class LAYBASIC_PUBLIC ConfigureAction
: public Action,
public tl::Object
: public Action
{
public:
enum type { setter_type = 0, boolean_type = 1, choice_type = 2 };
/**
* @brief The default constructor
*
* @param pr The reference to the plugin root object which receives the configure request
*/
ConfigureAction (lay::PluginRoot *pr);
ConfigureAction ();
/**
* @brief Create an configure action with the given name and value
*
* @param pr The reference to the plugin root object which receives the configure request
* @param cname The name of the configuration parameter to set
* @param cvalue The value to set "cname" to
*
* The value can be "?" in which case the configuration action describes
* a boolean parameter which is mapped to a checkable action.
*/
ConfigureAction (lay::PluginRoot *pr, const std::string &cname, const std::string &value);
ConfigureAction (const std::string &cname, const std::string &value);
/**
* @brief Create an configure action with the given title (icon, keyboard shortcut), name and value
*
* The format of the title string is: <text>["("shortcut")"]["<"icon-resource">"]
*
* @param pr The reference to the plugin root object which receives the configure request
* @param title The title string encoding icon and keyboard shortcut if applicable.
* @param cname The name of the configuration parameter to set
* @param cvalue The value to set "cname" to
@ -449,7 +391,7 @@ public:
* The value can be "?" in which case the configuration action describes
* a boolean parameter which is mapped to a checkable action.
*/
ConfigureAction (lay::PluginRoot *pr, const std::string &title, const std::string &cname, const std::string &value);
ConfigureAction (const std::string &title, const std::string &cname, const std::string &value);
/**
* @brief Destructor
@ -498,76 +440,20 @@ public:
protected:
virtual void triggered ();
void reg ();
void unreg ();
private:
ConfigureAction (const ConfigureAction &action);
ConfigureAction &operator= (const ConfigureAction &action);
lay::PluginRoot *m_pr;
std::string m_cname, m_cvalue;
type m_type;
};
/**
* @brief A menu layout entry for static initialisation
*
* These objects act as the "source" for creating the initial AbstractLayout setup.
*/
struct LAYBASIC_PUBLIC MenuLayoutEntry {
MenuLayoutEntry (const char *_name,
const std::string &_title,
const std::pair<std::string, std::string> &_kv_pair)
: name (_name), title (_title), slot (0), kv_pair (_kv_pair), submenu (0)
{ }
MenuLayoutEntry (const char *_name,
const std::string &_title,
const char *_slot,
const MenuLayoutEntry *_submenu = 0)
: name (_name), title (_title), slot (_slot), submenu (_submenu)
{ }
MenuLayoutEntry (const char *_name,
const std::string &_title,
const MenuLayoutEntry *_submenu = 0)
: name (_name), title (_title), slot (0), submenu (_submenu)
{ }
MenuLayoutEntry (const char *_name)
: name (_name), slot (0), submenu (0)
{ }
MenuLayoutEntry ()
: name (0), slot (0), submenu (0)
{ }
static MenuLayoutEntry separator (const char *name)
{
return MenuLayoutEntry (name);
}
static MenuLayoutEntry last ()
{
return MenuLayoutEntry ();
}
const char *name;
std::string title;
const char *slot;
std::pair<std::string, std::string> kv_pair;
const MenuLayoutEntry *submenu;
};
/**
* @brief One item in the abstract menu
*/
struct LAYBASIC_PUBLIC AbstractMenuItem
{
AbstractMenuItem ();
AbstractMenuItem (lay::Dispatcher *dispatcher);
// No copy constructor semantics because we don't need it (we use list's) and Action does not provide one.
AbstractMenuItem (const AbstractMenuItem &);
@ -575,7 +461,12 @@ struct LAYBASIC_PUBLIC AbstractMenuItem
/**
* @brief Internal method used to set up the item
*/
void setup_item (const std::string &pn, const std::string &n, const Action &a);
void setup_item (const std::string &pn, const std::string &n, Action *a);
Dispatcher *dispatcher () const
{
return mp_dispatcher;
}
const std::string &name () const
{
@ -587,18 +478,23 @@ struct LAYBASIC_PUBLIC AbstractMenuItem
return m_groups;
}
void set_action (const Action &a, bool copy_properties);
void set_action (Action *a, bool copy_properties);
void set_action_title (const std::string &t);
const Action &action () const
Action *action ()
{
return m_action;
return mp_action.get ();
}
QMenu *menu () const
const Action *action () const
{
return m_action.menu ();
return mp_action.get ();
}
QMenu *menu ()
{
return mp_action->menu ();
}
void set_has_submenu ();
@ -618,9 +514,10 @@ struct LAYBASIC_PUBLIC AbstractMenuItem
std::list <AbstractMenuItem> children;
private:
tl::shared_ptr<Action> mp_action;
Dispatcher *mp_dispatcher;
bool m_has_submenu;
bool m_remove_on_empty;
Action m_action;
std::string m_name;
std::string m_basename;
std::set<std::string> m_groups;
@ -636,11 +533,6 @@ private:
* Each item can be associated with a Action, which delivers a title, enabled/disable state etc.
* The Action is either provided when new entries are inserted or created upon initialisation.
*
* An abstract menu is initialised from a initialisation sequence given by a list of
* MenuLayoutEntry objects terminated with a MenuLayoutEntry::last() item.
* Each of these entries may provide a submenu. Beside for initialisation, these entries
* are not used further.
*
* The abstract menu class provides methods to manipulate the menu structure (the state of the
* menu items, their title and shortcut key is provided and manipulated through the Action object).
*
@ -684,18 +576,13 @@ public:
/**
* @brief Create the abstract menu object attached to the given main window
*/
AbstractMenu (AbstractMenuProvider *provider);
AbstractMenu (Dispatcher *dispatcher);
/**
* @brief Destroy the abstract menu object
*/
~AbstractMenu ();
/**
* @brief Initialise from a sequence of MenuLayoutEntry objects
*/
void init (const MenuLayoutEntry *layout);
/**
* @brief Rebuild the QMenu's and refill the QMenuBar object
*/
@ -729,7 +616,12 @@ public:
* @param path The path to the item. This must be a valid path.
* @return The action object
*/
Action action (const std::string &path) const;
Action *action (const std::string &path);
/**
* @brief Get the Action object for a given item (const version)
*/
const Action *action(const std::string &path) const;
/**
* @brief Get the subitems for a given submenu
@ -772,8 +664,10 @@ public:
* @param path The path to the item before which to insert the new item
* @param name The name of the item to insert
* @param action The action associated with the item
*
* NOTE: the abstract menu will take ownership of the Action object.
*/
void insert_item (const std::string &path, const std::string &name, const Action &action);
void insert_item (const std::string &path, const std::string &name, Action *action);
/**
* @brief Insert a new separator before the one item by the path
@ -793,7 +687,7 @@ public:
* @param name The name of the submenu to insert
* @param action The action associated with the submenu
*/
void insert_menu (const std::string &path, const std::string &name, const Action &action);
void insert_menu (const std::string &path, const std::string &name, Action *action);
/**
* @brief Insert a new submenu before the item given by the path
@ -824,7 +718,7 @@ public:
/**
* @brief Delete the items referring to the given action
*/
void delete_items (const Action &action);
void delete_items (Action *action);
/**
* @brief Get the group members
@ -834,6 +728,21 @@ public:
*/
std::vector<std::string> group (const std::string &name) const;
/**
* @brief Get the group members as Action objects
*
* @param group The group name
* @param A vector of all members (as actions) of the group
*/
std::vector<Action *> group_actions(const std::string &name);
/**
* @brief Get the configure actions for a given configuration name
*
* @param The configuration actions for this given configuration name
*/
std::vector<lay::ConfigureAction *> configure_actions (const std::string &name);
/**
* @brief Get the detached menu
*
@ -873,29 +782,21 @@ signals:
private:
friend class Action;
std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator> > find_item (const std::string &path);
std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator> > find_item (tl::Extractor &extr);
const AbstractMenuItem *find_item_exact (const std::string &path) const;
AbstractMenuItem *find_item_exact (const std::string &path);
void transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item);
void build (QMenu *menu, std::list<AbstractMenuItem> &items);
void build (QToolBar *tbar, std::list<AbstractMenuItem> &items);
void collect_group (std::vector<std::string> &grp, const std::string &name, const AbstractMenuItem &item) const;
void collect_configure_actions (std::vector<ConfigureAction *> &ca, AbstractMenuItem &item);
void emit_changed ();
/**
* @brief Create a action from a string
*
* The format of the string is: <text>["("shortcut")"]["<"icon-resource">"]
*
* @param s The title, key and icon resource string in the format given above
* @param parent The widget to which to attach the QAction object
* @return The ActionHandle object created
*/
static ActionHandle *create_action (const std::string &s);
AbstractMenuProvider *mp_provider;
Dispatcher *mp_dispatcher;
AbstractMenuItem m_root;
tl::stable_vector<QMenu> m_helper_menu_items;
std::map<std::string, QActionGroup *> m_action_groups;
std::map<std::string, std::vector<ConfigureAction *> > m_config_action_by_name;
bool m_config_actions_valid;
};
}
@ -907,6 +808,14 @@ namespace tl
typedef tl::false_tag has_default_constructor;
};
template <> struct type_traits<lay::AbstractMenuItem> : public type_traits<void> {
typedef tl::false_tag has_copy_constructor;
typedef tl::false_tag has_default_constructor;
};
template <> struct type_traits<lay::Action> : public type_traits<void> {
typedef tl::false_tag has_copy_constructor;
};
}
#endif

View File

@ -1,51 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layAbstractMenuProvider.h"
namespace lay
{
static AbstractMenuProvider *ms_instance = 0;
AbstractMenuProvider::AbstractMenuProvider ()
{
if (! ms_instance) {
ms_instance = this;
}
}
AbstractMenuProvider::~AbstractMenuProvider ()
{
if (ms_instance == this) {
ms_instance = 0;
}
}
AbstractMenuProvider *AbstractMenuProvider::instance ()
{
return ms_instance;
}
}

View File

@ -1,106 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layAbstractMenuProvider
#define HDR_layAbstractMenuProvider
#include "laybasicCommon.h"
#include <string>
class QWidget;
namespace lay
{
class AbstractMenu;
class Action;
class ConfigureAction;
/**
* @brief An interface for the supplier of the abstract menu object
*/
class LAYBASIC_PUBLIC AbstractMenuProvider
{
public:
/**
* @brief Constructor
*/
AbstractMenuProvider ();
/**
* @brief Destructor
*/
virtual ~AbstractMenuProvider ();
/**
* @brief Gets the AbstractMenu object
*/
virtual AbstractMenu *menu () = 0;
/**
* @brief Gets the parent widget
*/
virtual QWidget *menu_parent_widget () = 0;
/**
* @brief Get the action for a slot
*/
virtual lay::Action &action_for_slot (const char *slot) = 0;
/**
* @brief Create a configuration action with the given title, parameter name and value
*
* The action will be owned by the main window but can be deleted to remove the action from the main window.
*/
virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) = 0;
/**
* @brief Create a configuration action with the given parameter name and value
*
* The action will be owned by the main window but can be deleted to remove the action from the main window.
* This version is provided for applications, where the title is set later.
*/
virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue) = 0;
/**
* @brief Register a configuration action with the given name
*/
virtual void register_config_action (const std::string &name, lay::ConfigureAction *action) = 0;
/**
* @brief Unregister a configuration action with the given name
*/
virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action) = 0;
/**
* @brief Gets the singleton instance of the AbstractMenuProvider object
*/
static AbstractMenuProvider *instance ();
};
}
#endif

View File

@ -24,7 +24,6 @@
#include "layBookmarksView.h"
#include "layLayoutView.h"
#include "layAbstractMenu.h"
#include "layAbstractMenuProvider.h"
#include "laybasicConfig.h"
@ -134,26 +133,6 @@ BookmarksView::follow_selection (bool f)
m_follow_selection = f;
}
void
BookmarksView::init_menu (lay::AbstractMenu &menu)
{
MenuLayoutEntry context_menu [] = {
MenuLayoutEntry ("follow_selection", tl::to_string (QObject::tr ("Follow Selection")), std::make_pair (cfg_bookmarks_follow_selection, "?")),
MenuLayoutEntry::separator ("ops_group"),
MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())),
MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())),
MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())),
MenuLayoutEntry::last ()
};
MenuLayoutEntry main_menu [] = {
MenuLayoutEntry ("@bookmarks_context_menu", "", context_menu),
MenuLayoutEntry::last ()
};
menu.init (main_menu);
}
void
BookmarksView::set_background_color (QColor c)
{
@ -182,11 +161,9 @@ BookmarksView::refresh ()
void
BookmarksView::context_menu (const QPoint &p)
{
tl_assert (lay::AbstractMenuProvider::instance () != 0);
QListView *bm_list = dynamic_cast<QListView *> (sender ());
if (bm_list) {
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("bookmarks_context_menu");
QMenu *ctx_menu = mp_view->menu ()->detached_menu ("bookmarks_context_menu");
ctx_menu->exec (bm_list->mapToGlobal (p));
}
}
@ -207,5 +184,30 @@ BookmarksView::bookmark_triggered (const QModelIndex &index)
}
}
// ------------------------------------------------------------
// Declaration of the "plugin" for the menu entries
class BookmarksViewPluginDeclaration
: public lay::PluginDeclaration
{
public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
std::string at;
at = ".end";
menu_entries.push_back (lay::submenu ("@bookmarks_context_menu", at, std::string ()));
at = "@bookmarks_context_menu.end";
menu_entries.push_back (lay::config_menu_item ("follow_selection", at, tl::to_string (QObject::tr ("Follow Selection")), cfg_bookmarks_follow_selection, "?")),
menu_entries.push_back (lay::separator ("ops_group", at));
menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks"))));
menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks"))));
menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks"))));
}
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new BookmarksViewPluginDeclaration (), -7, "BookmarksViewPlugin");
}

View File

@ -59,8 +59,6 @@ public:
void refresh ();
static void init_menu (lay::AbstractMenu &menu);
public slots:
void bookmark_triggered (const QModelIndex &index);
void current_bookmark_changed (const QModelIndex &index);

View File

@ -76,10 +76,10 @@ public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances"))));
menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new BrowseInstancesForm (root, view);
}
@ -175,7 +175,7 @@ BrowseInstancesConfigPage::BrowseInstancesConfigPage (QWidget *parent)
}
void
BrowseInstancesConfigPage::setup (lay::PluginRoot *root)
BrowseInstancesConfigPage::setup (lay::Dispatcher *root)
{
std::string value;
@ -221,7 +221,7 @@ BrowseInstancesConfigPage::window_changed (int m)
}
void
BrowseInstancesConfigPage::commit (lay::PluginRoot *root)
BrowseInstancesConfigPage::commit (lay::Dispatcher *root)
{
double dim = 1.0;
tl::from_string (tl::to_string (le_window->text ()), dim);
@ -289,7 +289,7 @@ private:
// ------------------------------------------------------------
BrowseInstancesForm::BrowseInstancesForm (lay::PluginRoot *root, lay::LayoutView *vw)
BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *vw)
: lay::Browser (root, vw),
Ui::BrowseInstancesForm (),
m_cv_index (0),

View File

@ -46,8 +46,8 @@ class BrowseInstancesConfigPage
public:
BrowseInstancesConfigPage (QWidget *parent);
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 context_changed (int);
@ -64,7 +64,7 @@ public:
enum mode_type { ToCellView = 0, AnyTop, Parent };
enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize };
BrowseInstancesForm (lay::PluginRoot *root, lay::LayoutView *view);
BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view);
~BrowseInstancesForm ();
bool eventFilter (QObject *watched, QEvent *event);

View File

@ -76,11 +76,11 @@ public:
virtual void get_menu_entries (std::vector<lay::MenuEntry> &menu_entries) const
{
lay::PluginDeclaration::get_menu_entries (menu_entries);
menu_entries.push_back (lay::MenuEntry ("browser_group", "tools_menu.end"));
menu_entries.push_back (lay::MenuEntry ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes"))));
menu_entries.push_back (lay::separator ("browser_group", "tools_menu.end"));
menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const
{
return new BrowseShapesForm (root, view);
}
@ -177,7 +177,7 @@ BrowseShapesConfigPage::BrowseShapesConfigPage (QWidget *parent)
}
void
BrowseShapesConfigPage::setup (lay::PluginRoot *root)
BrowseShapesConfigPage::setup (lay::Dispatcher *root)
{
std::string value;
@ -228,7 +228,7 @@ BrowseShapesConfigPage::window_changed (int m)
}
void
BrowseShapesConfigPage::commit (lay::PluginRoot *root)
BrowseShapesConfigPage::commit (lay::Dispatcher *root)
{
double dim = 1.0;
tl::from_string (tl::to_string (le_window->text ()), dim);
@ -388,7 +388,7 @@ private:
// ------------------------------------------------------------
BrowseShapesForm::BrowseShapesForm (lay::PluginRoot *root, lay::LayoutView *vw)
BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *vw)
: lay::Browser (root, vw),
Ui::BrowseShapesForm (),
m_cv_index (-1),

View File

@ -45,8 +45,8 @@ class BrowseShapesConfigPage
public:
BrowseShapesConfigPage (QWidget *parent);
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 context_changed (int);
@ -63,7 +63,7 @@ public:
enum mode_type { ToCellView = 0, AnyTop, Local };
enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize };
BrowseShapesForm (lay::PluginRoot *root, lay::LayoutView *view);
BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *view);
~BrowseShapesForm ();
bool eventFilter (QObject *watched, QEvent *event);

View File

@ -32,9 +32,9 @@ namespace lay
{
#if QT_VERSION >= 0x050000
Browser::Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl)
Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl)
#else
Browser::Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name, Qt::WFlags fl)
Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl)
#endif
// TODO: clarify whether to keep the browsers as separate (potentially hidden) windows
: QDialog (0 /*view*/, fl),

View File

@ -36,7 +36,7 @@ namespace lay
{
class LayoutView;
class PluginRoot;
class Dispatcher;
class LAYBASIC_PUBLIC Browser
: public QDialog,
@ -47,9 +47,9 @@ public:
* @brief Constructor
*/
#if QT_VERSION >= 0x050000
Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/);
Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/);
#else
Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/);
Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/);
#endif
/**
@ -101,7 +101,7 @@ public:
/**
* @brief Returns the pointer to the root configuration object
*/
lay::PluginRoot *root ()
lay::Dispatcher *root ()
{
return mp_root;
}
@ -133,7 +133,7 @@ public:
private:
bool m_active;
lay::LayoutView *mp_view;
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
void closeEvent (QCloseEvent *);
void accept ();

View File

@ -76,12 +76,12 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co
mp_case_sensitive->setChecked (true);
mp_case_sensitive->setText (tr ("Case sensitive search"));
if (lay::PluginRoot::instance ()) {
if (lay::Dispatcher::instance ()) {
bool cs = true;
lay::PluginRoot::instance ()->config_get (cfg_cell_selection_search_case_sensitive, cs);
lay::Dispatcher::instance ()->config_get (cfg_cell_selection_search_case_sensitive, cs);
mp_case_sensitive->setChecked (cs);
bool ue = true;
lay::PluginRoot::instance ()->config_get (cfg_cell_selection_search_use_expressions, ue);
lay::Dispatcher::instance ()->config_get (cfg_cell_selection_search_use_expressions, ue);
mp_use_regular_expressions->setChecked (ue);
}
@ -285,9 +285,9 @@ CellSelectionForm::reject ()
void
CellSelectionForm::store_config ()
{
if (lay::PluginRoot::instance ()) {
lay::PluginRoot::instance ()->config_set (cfg_cell_selection_search_case_sensitive, mp_case_sensitive->isChecked ());
lay::PluginRoot::instance ()->config_set (cfg_cell_selection_search_use_expressions, mp_use_regular_expressions->isChecked ());
if (lay::Dispatcher::instance ()) {
lay::Dispatcher::instance ()->config_set (cfg_cell_selection_search_case_sensitive, mp_case_sensitive->isChecked ());
lay::Dispatcher::instance ()->config_set (cfg_cell_selection_search_use_expressions, mp_use_regular_expressions->isChecked ());
}
}

View File

@ -28,6 +28,7 @@
#include "ui_ConfigurationDialog.h"
#include "layConfigurationDialog.h"
#include "layPlugin.h"
#include "layDispatcher.h"
#include "tlLog.h"
@ -36,7 +37,7 @@ namespace lay
// -------------------------------------------------------------
ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, const std::string &plugin_name, const char *name)
ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, const std::string &plugin_name, const char *name)
: QDialog (parent),
mp_root (root)
{
@ -56,7 +57,7 @@ ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root
}
}
ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, lay::PluginDeclaration *decl, const char *name)
ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, lay::PluginDeclaration *decl, const char *name)
: QDialog (parent),
mp_root (root)
{

View File

@ -38,7 +38,7 @@ namespace Ui
namespace lay
{
class PluginRoot;
class Dispatcher;
class ConfigPage;
class PluginDeclaration;
@ -48,8 +48,8 @@ class LAYBASIC_PUBLIC ConfigurationDialog
Q_OBJECT
public:
ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, lay::PluginDeclaration *decl, const char *name = "");
ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, const std::string &plugin_name, const char *name = "");
ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, lay::PluginDeclaration *decl, const char *name = "");
ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, const std::string &plugin_name, const char *name = "");
~ConfigurationDialog ();
void commit ();
@ -58,7 +58,7 @@ public slots:
virtual void ok_clicked ();
private:
lay::PluginRoot *mp_root;
lay::Dispatcher *mp_root;
std::vector <lay::ConfigPage *> m_config_pages;
Ui::ConfigurationDialog *mp_ui;

View File

@ -0,0 +1,229 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layDispatcher.h"
#include "tlXMLParser.h"
#include "tlXMLWriter.h"
namespace lay
{
// ----------------------------------------------------------------
// Dispatcher implementation
static Dispatcher *ms_dispatcher_instance = 0;
Dispatcher::Dispatcher (Plugin *parent, bool standalone)
: Plugin (parent, standalone),
m_menu (this)
{
if (! parent && ! ms_dispatcher_instance) {
ms_dispatcher_instance = this;
}
}
Dispatcher::~Dispatcher ()
{
if (ms_dispatcher_instance == this) {
ms_dispatcher_instance = 0;
}
}
bool
Dispatcher::configure (const std::string &name, const std::string &value)
{
std::vector<lay::ConfigureAction *> ca = m_menu.configure_actions (name);
for (std::vector<lay::ConfigureAction *>::const_iterator a = ca.begin (); a != ca.end (); ++a) {
(*a)->configure (value);
}
return false;
}
// Writing and Reading of configuration
struct ConfigGetAdaptor
{
ConfigGetAdaptor (const std::string &name)
: mp_owner (0), m_done (false), m_name (name)
{
// .. nothing yet ..
}
std::string operator () () const
{
std::string s;
mp_owner->config_get (m_name, s);
return s;
}
bool at_end () const
{
return m_done;
}
void start (const lay::Dispatcher &owner)
{
mp_owner = &owner;
m_done = false;
}
void next ()
{
m_done = true;
}
private:
const lay::Dispatcher *mp_owner;
bool m_done;
std::string m_name;
};
struct ConfigGetNullAdaptor
{
ConfigGetNullAdaptor ()
{
// .. nothing yet ..
}
std::string operator () () const
{
return std::string ();
}
bool at_end () const
{
return true;
}
void start (const lay::Dispatcher & /*owner*/) { }
void next () { }
};
struct ConfigNamedSetAdaptor
{
ConfigNamedSetAdaptor ()
{
// .. nothing yet ..
}
void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader, const std::string &name) const
{
tl::XMLObjTag<std::string> tag;
w.config_set (name, *reader.back (tag));
}
};
struct ConfigSetAdaptor
{
ConfigSetAdaptor (const std::string &name)
: m_name (name)
{
// .. nothing yet ..
}
void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader) const
{
tl::XMLObjTag<std::string> tag;
w.config_set (m_name, *reader.back (tag));
}
private:
std::string m_name;
};
// the configuration file's XML structure is built dynamically
static tl::XMLStruct<lay::Dispatcher>
config_structure (const lay::Dispatcher *plugin)
{
tl::XMLElementList body;
std::string n_with_underscores;
std::vector <std::string> names;
plugin->get_config_names (names);
for (std::vector <std::string>::const_iterator n = names.begin (); n != names.end (); ++n) {
body.append (tl::XMLMember<std::string, lay::Dispatcher, ConfigGetAdaptor, ConfigSetAdaptor, tl::XMLStdConverter <std::string> > (
ConfigGetAdaptor (*n), ConfigSetAdaptor (*n), *n));
// for compatibility, provide an alternative with underscores (i.e. 0.20->0.21 because of default_grids)
n_with_underscores.clear ();
for (const char *c = n->c_str (); *c; ++c) {
n_with_underscores += (*c == '-' ? '_' : *c);
}
body.append (tl::XMLMember<std::string, lay::Dispatcher, ConfigGetNullAdaptor, ConfigSetAdaptor, tl::XMLStdConverter <std::string> > (
ConfigGetNullAdaptor (), ConfigSetAdaptor (*n), n_with_underscores));
}
// add a wildcard member to read all others unspecifically into the repository
body.append (tl::XMLWildcardMember<std::string, lay::Dispatcher, ConfigNamedSetAdaptor, tl::XMLStdConverter <std::string> > (ConfigNamedSetAdaptor ()));
return tl::XMLStruct<lay::Dispatcher> ("config", body);
}
bool
Dispatcher::write_config (const std::string &config_file)
{
try {
tl::OutputStream os (config_file, tl::OutputStream::OM_Plain);
config_structure (this).write (os, *this);
return true;
} catch (...) {
return false;
}
}
bool
Dispatcher::read_config (const std::string &config_file)
{
std::auto_ptr<tl::XMLFileSource> file;
try {
file.reset (new tl::XMLFileSource (config_file));
} catch (...) {
return false;
}
try {
config_structure (this).parse (*file, *this);
} catch (tl::Exception &ex) {
std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg ();
throw tl::Exception (msg);
}
config_end ();
return true;
}
Dispatcher *
Dispatcher::instance ()
{
return ms_dispatcher_instance;
}
}

View File

@ -0,0 +1,156 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layDispatcher
#define HDR_layDispatcher
#include "laybasicCommon.h"
#include "tlTypeTraits.h"
#include "tlObject.h"
#include "layPlugin.h"
#include <map>
#include <string>
#include <vector>
namespace lay
{
class AbstractMenu;
class Action;
class ConfigureAction;
/**
* @brief The central menu event and configuration dispatcher class
*
* This class acts as the top level dispatcher for plugin events and the menu configuration.
*
*/
class LAYBASIC_PUBLIC Dispatcher
: public Plugin
{
public:
/**
* @brief The constructor
*
* @param parent Usually 0, but a dispatcher may have parents. In this case, the dispatcher is not the actual dispatcher, but the real plugin chain's root is.
* @param standalone The standalone flag passed to the plugin constructor.
*/
Dispatcher (Plugin *parent, bool standalone = false);
/**
* @brief Destructor
*/
~Dispatcher ();
/**
* @brief Write configuration to a file
*
* If the configuration file cannot be written, false
* is returned but no exception is thrown.
*
* @return false, if an error occurred.
*/
bool write_config (const std::string &config_file);
/**
* @brief Read the configuration from a file
*
* This method siletly does nothing, if the config file does not
* exist. If it does and an error occurred, the error message is printed
* on stderr. In both cases, false is returned.
*
* @return false, if an error occurred.
*/
bool read_config (const std::string &config_file);
/**
* @brief The singleton instance of the plugin root
*/
static Dispatcher *instance ();
/**
* @brief Notifies the plugin root that a new plugin class has been registered
*
* This method is called when a plugin is loaded dynamically during runtime.
*/
virtual void plugin_registered (lay::PluginDeclaration * /*cls*/) { }
/**
* @brief Notifies the plugin root that a plugin class is about to be removed
*/
virtual void plugin_removed (lay::PluginDeclaration * /*cls*/) { }
/**
* @brief Selects the given mode
*
* The implementation is supposed to select the given mode on all related plugins.
*/
virtual void select_mode (int /*mode*/) { }
/**
* @brief Gets the parent widget
*/
virtual QWidget *menu_parent_widget () { return 0; }
/**
* @brief Returns true, if the dispatcher supplies a user interface
*/
virtual bool has_ui () { return menu_parent_widget () != 0; }
/**
* @brief Gets the AbstractMenu object
*
* This will deliver the actual menu - the one that is the root dispatcher's menu
*/
AbstractMenu *menu ()
{
return (dispatcher () == this) ? &m_menu : dispatcher ()->menu ();
}
protected:
// capture the configuration events so we can change the value of the configuration actions
virtual bool configure (const std::string &name, const std::string &value);
private:
Dispatcher (const Dispatcher &);
Dispatcher &operator= (const Dispatcher &);
lay::AbstractMenu m_menu;
};
}
namespace tl
{
// disable copy ctor for Dispatcher
template <> struct type_traits<lay::Dispatcher> : public type_traits<void> {
typedef tl::false_tag has_copy_constructor;
typedef tl::false_tag has_default_constructor;
};
}
#endif

View File

@ -52,7 +52,7 @@ struct CurrentStyleOp
EditLineStylesForm::EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles)
: QDialog (view), db::Object (0),
m_selected (-1), m_styles (styles), mp_view (view)
m_selected (-1), m_styles (styles), m_manager (true), mp_view (view)
{
m_selection_changed_enabled = false;

View File

@ -52,7 +52,7 @@ struct CurrentPatternOp
EditStipplesForm::EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern)
: QDialog (view), db::Object (0),
m_selected (-1), m_pattern (pattern), mp_view (view)
m_selected (-1), m_pattern (pattern), m_manager (true), mp_view (view)
{
m_selection_changed_enabled = false;

View File

@ -105,7 +105,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons
}
lay::Plugin *
GridNetPluginDeclaration::create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const
GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const
{
return new lay::GridNet (view);
}
@ -134,7 +134,7 @@ GridNetConfigPage::~GridNetConfigPage ()
}
void
GridNetConfigPage::setup (lay::PluginRoot *root)
GridNetConfigPage::setup (lay::Dispatcher *root)
{
std::string value;
@ -176,7 +176,7 @@ GridNetConfigPage::setup (lay::PluginRoot *root)
}
void
GridNetConfigPage::commit (lay::PluginRoot *root)
GridNetConfigPage::commit (lay::Dispatcher *root)
{
root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ());
root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ());

View File

@ -44,7 +44,7 @@ class GridNetPluginDeclaration
public:
virtual void get_options (std::vector < std::pair<std::string, std::string> > &options) const;
virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const;
virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const;
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const;
};
class GridNetConfigPage
@ -56,8 +56,8 @@ public:
GridNetConfigPage (QWidget *parent);
~GridNetConfigPage ();
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::GridNetConfigPage *mp_ui;

Some files were not shown because too many files have changed in this diff Show More