mirror of https://github.com/KLayout/klayout.git
WIP: some refinement
This commit is contained in:
parent
cdce2cb151
commit
4254221e6e
|
|
@ -92,8 +92,8 @@ struct EOPCompareOp
|
|||
}
|
||||
};
|
||||
|
||||
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root)
|
||||
: QFrame (parent), mp_root (root)
|
||||
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *dispatcher)
|
||||
: QFrame (parent), mp_dispatcher (dispatcher)
|
||||
{
|
||||
QVBoxLayout *ly1 = new QVBoxLayout (this);
|
||||
ly1->setMargin (0);
|
||||
|
|
@ -148,7 +148,7 @@ EditorOptionsPages::activate_page (edt::EditorOptionsPage *page)
|
|||
{
|
||||
try {
|
||||
if (page->active ()) {
|
||||
page->setup (mp_root);
|
||||
page->setup (mp_dispatcher);
|
||||
}
|
||||
} catch (...) {
|
||||
// catch any errors related to configuration file errors etc.
|
||||
|
|
@ -192,7 +192,7 @@ EditorOptionsPages::setup ()
|
|||
|
||||
for (std::vector <edt::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
(*p)->setup (mp_root);
|
||||
(*p)->setup (mp_dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,8 @@ EditorOptionsPages::do_apply ()
|
|||
{
|
||||
for (std::vector <edt::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
(*p)->apply (mp_root);
|
||||
// NOTE: we apply to the root dispatcher, so other dispatchers (views) get informed too.
|
||||
(*p)->apply (mp_dispatcher->dispatcher ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public slots:
|
|||
|
||||
private:
|
||||
std::vector <edt::EditorOptionsPage *> m_pages;
|
||||
lay::Dispatcher *mp_root;
|
||||
lay::Dispatcher *mp_dispatcher;
|
||||
QTabWidget *mp_pages;
|
||||
|
||||
void update (edt::EditorOptionsPage *page);
|
||||
|
|
|
|||
|
|
@ -2362,6 +2362,12 @@ private:
|
|||
db::cell_index_type m_topcell;
|
||||
};
|
||||
|
||||
void
|
||||
MainService::config_finalize ()
|
||||
{
|
||||
setup_pages (view ());
|
||||
}
|
||||
|
||||
void
|
||||
MainService::paste ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -199,6 +199,12 @@ public:
|
|||
*/
|
||||
virtual void paste ();
|
||||
|
||||
/**
|
||||
* @brief Implementation of "config_finalize"
|
||||
* This implementation will update the editor option page's parameters.
|
||||
*/
|
||||
virtual void config_finalize ();
|
||||
|
||||
private:
|
||||
// The layout view that this service is attached to
|
||||
lay::LayoutView *mp_view;
|
||||
|
|
|
|||
|
|
@ -377,12 +377,12 @@ show_editor_options_page (lay::LayoutView *view)
|
|||
}
|
||||
}
|
||||
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view->dispatcher ());
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
view->editor_options_frame ()->layout ()->addWidget (pages);
|
||||
}
|
||||
|
||||
void
|
||||
activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active)
|
||||
static
|
||||
edt::EditorOptionsPages *get_pages_widget (lay::LayoutView *view)
|
||||
{
|
||||
// TODO: is there a better way to find the editor options pages?
|
||||
edt::EditorOptionsPages *eo_pages = 0;
|
||||
|
|
@ -391,6 +391,13 @@ activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool
|
|||
eo_pages = dynamic_cast<edt::EditorOptionsPages *> (*c);
|
||||
}
|
||||
|
||||
return eo_pages;
|
||||
}
|
||||
|
||||
void
|
||||
activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active)
|
||||
{
|
||||
edt::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
if (!eo_pages) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -400,6 +407,19 @@ activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
setup_pages (lay::LayoutView *view)
|
||||
{
|
||||
edt::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
if (!eo_pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
(*op)->setup (view);
|
||||
}
|
||||
}
|
||||
|
||||
class PartialPluginDeclaration
|
||||
: public lay::PluginDeclaration
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ namespace edt
|
|||
* This will show or hide the editor properties pages for the respective service.
|
||||
*/
|
||||
void activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active);
|
||||
|
||||
/**
|
||||
* @brief Setup the editor option pages for the given view
|
||||
*/
|
||||
void setup_pages (lay::LayoutView *view);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue