mirror of https://github.com/KLayout/klayout.git
WIP: further refactoring.
This commit is contained in:
parent
64a09e07f9
commit
85789a386b
|
|
@ -1296,7 +1296,6 @@ ApplicationBase::special_app_flag (const std::string &name)
|
|||
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
|
||||
|
|
@ -1317,9 +1316,6 @@ GuiApplication::~GuiApplication ()
|
|||
}
|
||||
|
||||
shutdown ();
|
||||
|
||||
delete mp_plugin_root;
|
||||
mp_plugin_root = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1475,17 +1471,15 @@ GuiApplication::start_recording ()
|
|||
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::DispatcherToMainWindow ();
|
||||
mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window", is_undo_enabled ());
|
||||
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 ()));
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ namespace lay
|
|||
{
|
||||
|
||||
class MainWindow;
|
||||
class DispatcherToMainWindow;
|
||||
class Dispatcher;
|
||||
class ProgressReporter;
|
||||
class ProgressBar;
|
||||
|
|
@ -445,7 +444,6 @@ protected:
|
|||
|
||||
private:
|
||||
MainWindow *mp_mw;
|
||||
DispatcherToMainWindow *mp_plugin_root;
|
||||
gtf::Recorder *mp_recorder;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4072,61 +4072,6 @@ MainWindow::plugin_removed (lay::PluginDeclaration *cls)
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Implementation of the DispatcherToMainWindow bride
|
||||
|
||||
DispatcherToMainWindow::DispatcherToMainWindow ()
|
||||
: lay::Dispatcher (0, false),
|
||||
mp_main_window (0)
|
||||
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
DispatcherToMainWindow::attach_to (lay::MainWindow *main_window)
|
||||
{
|
||||
mp_main_window = main_window;
|
||||
}
|
||||
|
||||
void
|
||||
DispatcherToMainWindow::plugin_registered (lay::PluginDeclaration *cls)
|
||||
{
|
||||
if (mp_main_window.get ()) {
|
||||
mp_main_window->plugin_registered (cls);
|
||||
}
|
||||
|
||||
// re-establish the configuration
|
||||
config_setup ();
|
||||
}
|
||||
|
||||
void
|
||||
DispatcherToMainWindow::plugin_removed (lay::PluginDeclaration *cls)
|
||||
{
|
||||
if (mp_main_window.get ()) {
|
||||
mp_main_window->plugin_removed (cls);
|
||||
}
|
||||
|
||||
// re-establish the configuration
|
||||
config_setup ();
|
||||
}
|
||||
|
||||
void
|
||||
DispatcherToMainWindow::select_mode (int mode)
|
||||
{
|
||||
if (mp_main_window.get ()) {
|
||||
mp_main_window->select_mode (mode);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DispatcherToMainWindow::menu_activated (const std::string &symbol)
|
||||
{
|
||||
if (mp_main_window.get ()) {
|
||||
mp_main_window->menu_activated (symbol);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Implementation of the "help about" dialog
|
||||
|
||||
|
|
|
|||
|
|
@ -675,8 +675,6 @@ protected:
|
|||
void do_update_file_menu ();
|
||||
|
||||
private:
|
||||
friend class DispatcherToMainWindow;
|
||||
|
||||
TextProgressDelegate m_text_progress;
|
||||
|
||||
// Main menu
|
||||
|
|
@ -825,26 +823,6 @@ private:
|
|||
void apply_hidden (const std::vector<std::pair <std::string, bool> > &hidden);
|
||||
};
|
||||
|
||||
class LAY_PUBLIC DispatcherToMainWindow
|
||||
: public lay::Dispatcher
|
||||
{
|
||||
public:
|
||||
DispatcherToMainWindow ();
|
||||
|
||||
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:
|
||||
DispatcherToMainWindow (const DispatcherToMainWindow &);
|
||||
DispatcherToMainWindow &operator= (const DispatcherToMainWindow &);
|
||||
|
||||
tl::weak_ptr<MainWindow> mp_main_window;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ ActionHandle::ActionHandle (QMenu *menu, bool owned)
|
|||
sp_actionHandles->insert (this);
|
||||
|
||||
// catch the destroyed signal to tell if the QAction object is deleted.
|
||||
connect (mp_action, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
|
||||
connect (mp_menu, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
|
||||
}
|
||||
|
||||
ActionHandle::~ActionHandle ()
|
||||
|
|
@ -453,9 +453,15 @@ ActionHandle::menu () const
|
|||
}
|
||||
|
||||
void
|
||||
ActionHandle::destroyed (QObject * /*obj*/)
|
||||
ActionHandle::destroyed (QObject *obj)
|
||||
{
|
||||
mp_action = 0;
|
||||
if (obj == mp_action) {
|
||||
mp_action = 0;
|
||||
}
|
||||
if (obj == mp_menu) {
|
||||
mp_menu = 0;
|
||||
mp_action = 0;
|
||||
}
|
||||
m_owned = false;
|
||||
}
|
||||
|
||||
|
|
@ -1088,7 +1094,7 @@ AbstractMenu::build_detached (const std::string &name, QFrame *mbar)
|
|||
menu_button->setText (tl::to_qstring (c->action ().get_title ()));
|
||||
|
||||
if (c->menu () == 0) {
|
||||
QMenu *menu = new QMenu ();
|
||||
QMenu *menu = new QMenu (mp_dispatcher->menu_parent_widget ());
|
||||
menu_button->setMenu (menu);
|
||||
c->set_action (Action (new ActionHandle (menu)), true);
|
||||
} else {
|
||||
|
|
@ -1146,7 +1152,7 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar)
|
|||
} else if (c->name ().find ("@") == 0) {
|
||||
|
||||
if (c->menu () == 0) {
|
||||
QMenu *menu = new QMenu (tl::to_qstring (c->action ().get_title ()));
|
||||
QMenu *menu = new QMenu (tl::to_qstring (c->action ().get_title ()), mp_dispatcher->menu_parent_widget ());
|
||||
// HINT: it is necessary to add the menu action to a widget below the main window.
|
||||
// Otherwise, the keyboard shortcuts do not work for menu items inside such a
|
||||
// popup menu. It seems not to have a negative effect to add the menu to the
|
||||
|
|
@ -1163,7 +1169,7 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar)
|
|||
} else if (mbar) {
|
||||
|
||||
if (c->menu () == 0) {
|
||||
QMenu *menu = new QMenu ();
|
||||
QMenu *menu = new QMenu (mp_dispatcher->menu_parent_widget ());
|
||||
menu->setTitle (tl::to_qstring (c->action ().get_title ()));
|
||||
mbar->addMenu (menu);
|
||||
c->set_action (Action (new ActionHandle (menu)), true);
|
||||
|
|
@ -1225,7 +1231,7 @@ AbstractMenu::build (QMenu *m, std::list<AbstractMenuItem> &items)
|
|||
if (! c->menu ()) {
|
||||
// HINT: the action acts as a container for the title. Unfortunately, we cannot create a
|
||||
// menu with a given action. The action is provided by addMenu instead.
|
||||
QMenu *menu = new QMenu ();
|
||||
QMenu *menu = new QMenu (mp_dispatcher->menu_parent_widget ());
|
||||
menu->setTitle (tl::to_qstring (c->action ().get_title ()));
|
||||
m->addMenu (menu);
|
||||
c->set_action (Action (new ActionHandle (menu)), true);
|
||||
|
|
|
|||
|
|
@ -1181,7 +1181,7 @@ public:
|
|||
std::string at = "@hcp_context_menu.sorting.end";
|
||||
menu_entries.push_back (lay::config_menu_item ("by_name", at, tl::to_string (QObject::tr ("By Name")), cfg_cell_list_sorting, "?by-name"));
|
||||
menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Small To Large")), cfg_cell_list_sorting, "?by-area"));
|
||||
menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Large To Small")), cfg_cell_list_sorting, "?by-area-reverse"));
|
||||
menu_entries.push_back (lay::config_menu_item ("by_area_reverse", at, tl::to_string (QObject::tr ("By Area - Large To Small")), cfg_cell_list_sorting, "?by-area-reverse"));
|
||||
}
|
||||
|
||||
menu_entries.push_back (lay::separator ("operations_group", at));
|
||||
|
|
|
|||
|
|
@ -7979,7 +7979,8 @@ public:
|
|||
menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (QObject::tr ("Move Interactive"))));
|
||||
|
||||
at = "edit_menu.end";
|
||||
menu_entries.push_back (lay::separator ("edit_select_individual_group", at));
|
||||
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)"))));
|
||||
|
||||
menu_entries.push_back (lay::separator ("basic_group", at));
|
||||
menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layout"))));
|
||||
|
|
@ -8034,17 +8035,12 @@ public:
|
|||
menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (QObject::tr ("Move To"))));
|
||||
}
|
||||
|
||||
menu_entries.push_back (lay::separator ("edit_select_individual_group", at));
|
||||
|
||||
menu_entries.push_back (lay::separator ("utils_group", at));
|
||||
menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Utilities"))));
|
||||
|
||||
menu_entries.push_back (lay::separator ("edit_select_individual_group", at));
|
||||
|
||||
menu_entries.push_back (lay::separator ("misc_group", at));
|
||||
menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (QObject::tr ("Delete(Del)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (QObject::tr ("Properties(Q)"))));
|
||||
menu_entries.push_back (lay::separator ("edit_select_individual_group", at));
|
||||
|
||||
menu_entries.push_back (lay::separator ("cpc_group", at));
|
||||
menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (QObject::tr ("Copy(Ctrl+C)"))));
|
||||
|
|
|
|||
Loading…
Reference in New Issue