mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-07 11:31:08 +02:00
WIP: refactoring - at least some local context menus for detached views
This commit is contained in:
@@ -182,11 +182,13 @@ BookmarksView::refresh ()
|
||||
void
|
||||
BookmarksView::context_menu (const QPoint &p)
|
||||
{
|
||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
||||
if (! mp_view->menu ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,12 +370,14 @@ HierarchyControlPanel::event (QEvent *e)
|
||||
void
|
||||
HierarchyControlPanel::context_menu (const QPoint &p)
|
||||
{
|
||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
||||
if (! mp_view->menu ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
||||
if (cell_list) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1686,9 +1686,11 @@ LayerControlPanel::cm_expand_all ()
|
||||
void
|
||||
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) {
|
||||
ctx_menu->exec (mp_tab_bar->mapToGlobal (p));
|
||||
}
|
||||
@@ -1697,9 +1699,11 @@ LayerControlPanel::tab_context_menu (const QPoint &p)
|
||||
void
|
||||
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) {
|
||||
ctx_menu->exec (mp_layer_list->mapToGlobal (p));
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "tlAssert.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layAbstractMenuProvider.h"
|
||||
#include "layViewOp.h"
|
||||
#include "layViewObject.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)
|
||||
: QFrame (parent),
|
||||
lay::Plugin (plugin_parent),
|
||||
m_menu (0),
|
||||
m_editable (editable),
|
||||
m_options (options),
|
||||
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)
|
||||
: QFrame (parent),
|
||||
lay::Plugin (root),
|
||||
m_menu (0),
|
||||
m_editable (editable),
|
||||
m_options (options),
|
||||
m_annotation_shapes (manager),
|
||||
@@ -348,6 +351,10 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
|
||||
{
|
||||
manager (mgr);
|
||||
|
||||
if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) {
|
||||
init_menu (m_menu);
|
||||
}
|
||||
|
||||
m_annotation_shapes.manager (mgr);
|
||||
|
||||
m_visibility_changed = false;
|
||||
@@ -6461,6 +6468,16 @@ LayoutView::intrinsic_mouse_modes (std::vector<std::string> *descriptions)
|
||||
return 2;
|
||||
}
|
||||
|
||||
AbstractMenu *
|
||||
LayoutView::menu ()
|
||||
{
|
||||
if (lay::AbstractMenuProvider::instance () && lay::AbstractMenuProvider::instance ()->menu ()) {
|
||||
return lay::AbstractMenuProvider::instance ()->menu ();
|
||||
} else {
|
||||
return &m_menu;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
LayoutView::default_mode ()
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QImage>
|
||||
|
||||
#include "layLayerProperties.h"
|
||||
#include "layAbstractMenu.h"
|
||||
#include "layAnnotationShapes.h"
|
||||
#include "layLayoutCanvas.h"
|
||||
#include "layColorPalette.h"
|
||||
@@ -1666,6 +1667,12 @@ public:
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -2750,6 +2757,8 @@ protected:
|
||||
void activate ();
|
||||
|
||||
private:
|
||||
lay::AbstractMenu m_menu;
|
||||
|
||||
bool m_editable;
|
||||
int m_disabled_edits;
|
||||
unsigned int m_options;
|
||||
|
||||
@@ -338,11 +338,13 @@ LibrariesView::event (QEvent *e)
|
||||
void
|
||||
LibrariesView::context_menu (const QPoint &p)
|
||||
{
|
||||
tl_assert (lay::AbstractMenuProvider::instance () != 0);
|
||||
if (! mp_view->menu ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeView *cell_list = dynamic_cast<QTreeView *> (sender ());
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user