mirror of https://github.com/KLayout/klayout.git
WIP: refactoring - at least some local context menus for detached views
This commit is contained in:
parent
0f69c24e79
commit
22b3a5face
|
|
@ -150,10 +150,6 @@ PluginDeclaration::configure (const std::string &name, const std::string &value)
|
||||||
void
|
void
|
||||||
PluginDeclaration::config_finalize ()
|
PluginDeclaration::config_finalize ()
|
||||||
{
|
{
|
||||||
if (!lay::AbstractMenuProvider::instance ()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_templates_updated) {
|
if (m_templates_updated) {
|
||||||
|
|
||||||
update_menu ();
|
update_menu ();
|
||||||
|
|
@ -217,6 +213,9 @@ void
|
||||||
PluginDeclaration::update_current_template ()
|
PluginDeclaration::update_current_template ()
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||||
|
if (! mp || ! mp->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
|
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
|
||||||
|
|
||||||
|
|
@ -240,6 +239,9 @@ void
|
||||||
PluginDeclaration::update_menu ()
|
PluginDeclaration::update_menu ()
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||||
|
if (! mp || ! mp->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_current_template < 0 || m_current_template >= int (m_templates.size ())) {
|
if (m_current_template < 0 || m_current_template >= int (m_templates.size ())) {
|
||||||
m_current_template = 0;
|
m_current_template = 0;
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ public:
|
||||||
virtual void initialize (lay::PluginRoot *root)
|
virtual void initialize (lay::PluginRoot *root)
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||||
if (! mp) {
|
if (! mp || ! mp->menu ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,7 +312,7 @@ public:
|
||||||
void update_menu (combine_mode_type cm)
|
void update_menu (combine_mode_type cm)
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||||
if (! mp) {
|
if (! mp || ! mp->menu ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -375,7 +375,7 @@ public:
|
||||||
void initialized (lay::PluginRoot *root)
|
void initialized (lay::PluginRoot *root)
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||||
if (! mp) {
|
if (! mp || ! mp->menu ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ void
|
||||||
TechnologyController::update_current_technology ()
|
TechnologyController::update_current_technology ()
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
|
||||||
if (! pr) {
|
if (! pr || ! pr->menu ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ void
|
||||||
TechnologyController::update_menu ()
|
TechnologyController::update_menu ()
|
||||||
{
|
{
|
||||||
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
|
lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance ();
|
||||||
if (! pr) {
|
if (! pr || ! pr->menu ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,11 +182,13 @@ BookmarksView::refresh ()
|
||||||
void
|
void
|
||||||
BookmarksView::context_menu (const QPoint &p)
|
BookmarksView::context_menu (const QPoint &p)
|
||||||
{
|
{
|
||||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
if (! mp_view->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QListView *bm_list = dynamic_cast<QListView *> (sender ());
|
QListView *bm_list = dynamic_cast<QListView *> (sender ());
|
||||||
if (bm_list) {
|
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));
|
ctx_menu->exec (bm_list->mapToGlobal (p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,12 +370,14 @@ HierarchyControlPanel::event (QEvent *e)
|
||||||
void
|
void
|
||||||
HierarchyControlPanel::context_menu (const QPoint &p)
|
HierarchyControlPanel::context_menu (const QPoint &p)
|
||||||
{
|
{
|
||||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
if (! mp_view->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
||||||
if (cell_list) {
|
if (cell_list) {
|
||||||
set_active_celltree_from_sender ();
|
set_active_celltree_from_sender ();
|
||||||
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("hcp_context_menu");
|
QMenu *ctx_menu = mp_view->menu ()->detached_menu ("hcp_context_menu");
|
||||||
ctx_menu->exec (cell_list->mapToGlobal (p));
|
ctx_menu->exec (cell_list->mapToGlobal (p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1686,9 +1686,11 @@ LayerControlPanel::cm_expand_all ()
|
||||||
void
|
void
|
||||||
LayerControlPanel::tab_context_menu (const QPoint &p)
|
LayerControlPanel::tab_context_menu (const QPoint &p)
|
||||||
{
|
{
|
||||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
if (! mp_view->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lcp_tabs_context_menu");
|
QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lcp_tabs_context_menu");
|
||||||
if (ctx_menu) {
|
if (ctx_menu) {
|
||||||
ctx_menu->exec (mp_tab_bar->mapToGlobal (p));
|
ctx_menu->exec (mp_tab_bar->mapToGlobal (p));
|
||||||
}
|
}
|
||||||
|
|
@ -1697,9 +1699,11 @@ LayerControlPanel::tab_context_menu (const QPoint &p)
|
||||||
void
|
void
|
||||||
LayerControlPanel::context_menu (const QPoint &p)
|
LayerControlPanel::context_menu (const QPoint &p)
|
||||||
{
|
{
|
||||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
if (! mp_view->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lcp_context_menu");
|
QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lcp_context_menu");
|
||||||
if (ctx_menu) {
|
if (ctx_menu) {
|
||||||
ctx_menu->exec (mp_layer_list->mapToGlobal (p));
|
ctx_menu->exec (mp_layer_list->mapToGlobal (p));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include "tlAssert.h"
|
#include "tlAssert.h"
|
||||||
#include "tlExceptions.h"
|
#include "tlExceptions.h"
|
||||||
#include "layLayoutView.h"
|
#include "layLayoutView.h"
|
||||||
|
#include "layAbstractMenuProvider.h"
|
||||||
#include "layViewOp.h"
|
#include "layViewOp.h"
|
||||||
#include "layViewObject.h"
|
#include "layViewObject.h"
|
||||||
#include "layLayoutViewConfigPages.h"
|
#include "layLayoutViewConfigPages.h"
|
||||||
|
|
@ -255,6 +256,7 @@ static LayoutView *ms_current = 0;
|
||||||
LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options)
|
LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options)
|
||||||
: QFrame (parent),
|
: QFrame (parent),
|
||||||
lay::Plugin (plugin_parent),
|
lay::Plugin (plugin_parent),
|
||||||
|
m_menu (0),
|
||||||
m_editable (editable),
|
m_editable (editable),
|
||||||
m_options (options),
|
m_options (options),
|
||||||
m_annotation_shapes (manager),
|
m_annotation_shapes (manager),
|
||||||
|
|
@ -270,6 +272,7 @@ LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin
|
||||||
LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options)
|
LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options)
|
||||||
: QFrame (parent),
|
: QFrame (parent),
|
||||||
lay::Plugin (root),
|
lay::Plugin (root),
|
||||||
|
m_menu (0),
|
||||||
m_editable (editable),
|
m_editable (editable),
|
||||||
m_options (options),
|
m_options (options),
|
||||||
m_annotation_shapes (manager),
|
m_annotation_shapes (manager),
|
||||||
|
|
@ -348,6 +351,10 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
|
||||||
{
|
{
|
||||||
manager (mgr);
|
manager (mgr);
|
||||||
|
|
||||||
|
if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) {
|
||||||
|
init_menu (m_menu);
|
||||||
|
}
|
||||||
|
|
||||||
m_annotation_shapes.manager (mgr);
|
m_annotation_shapes.manager (mgr);
|
||||||
|
|
||||||
m_visibility_changed = false;
|
m_visibility_changed = false;
|
||||||
|
|
@ -6461,6 +6468,16 @@ LayoutView::intrinsic_mouse_modes (std::vector<std::string> *descriptions)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractMenu *
|
||||||
|
LayoutView::menu ()
|
||||||
|
{
|
||||||
|
if (lay::AbstractMenuProvider::instance () && lay::AbstractMenuProvider::instance ()->menu ()) {
|
||||||
|
return lay::AbstractMenuProvider::instance ()->menu ();
|
||||||
|
} else {
|
||||||
|
return &m_menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
LayoutView::default_mode ()
|
LayoutView::default_mode ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
|
||||||
#include "layLayerProperties.h"
|
#include "layLayerProperties.h"
|
||||||
|
#include "layAbstractMenu.h"
|
||||||
#include "layAnnotationShapes.h"
|
#include "layAnnotationShapes.h"
|
||||||
#include "layLayoutCanvas.h"
|
#include "layLayoutCanvas.h"
|
||||||
#include "layColorPalette.h"
|
#include "layColorPalette.h"
|
||||||
|
|
@ -1666,6 +1667,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu);
|
static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the menu abstraction object
|
||||||
|
* This is either the global abstract menu or a view-local one if the view is not embedded into a main window.
|
||||||
|
*/
|
||||||
|
AbstractMenu *menu ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Query the default mode
|
* @brief Query the default mode
|
||||||
*/
|
*/
|
||||||
|
|
@ -2750,6 +2757,8 @@ protected:
|
||||||
void activate ();
|
void activate ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
lay::AbstractMenu m_menu;
|
||||||
|
|
||||||
bool m_editable;
|
bool m_editable;
|
||||||
int m_disabled_edits;
|
int m_disabled_edits;
|
||||||
unsigned int m_options;
|
unsigned int m_options;
|
||||||
|
|
|
||||||
|
|
@ -338,11 +338,13 @@ LibrariesView::event (QEvent *e)
|
||||||
void
|
void
|
||||||
LibrariesView::context_menu (const QPoint &p)
|
LibrariesView::context_menu (const QPoint &p)
|
||||||
{
|
{
|
||||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
if (! mp_view->menu ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
||||||
if (cell_list) {
|
if (cell_list) {
|
||||||
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lib_context_menu");
|
QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lib_context_menu");
|
||||||
ctx_menu->exec (cell_list->mapToGlobal (p));
|
ctx_menu->exec (cell_list->mapToGlobal (p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue