mirror of https://github.com/KLayout/klayout.git
Implementation of #343 (dockable bookmark window)
Here is the proposal: - There is a new panel similar to the layer list showing the bookmarks. It can be shown using View/Bookmarks. Initially this panel is hidden. - Double-clicking on an item in this bookmark list will navigate to the bookmark. - Context menu entries of this panel are: manage, load and save bookmarks (like in main menu) In addition, "bookmark this view" now proposes a bookmark name make of "B" and a unique number.
This commit is contained in:
parent
8a21d9718e
commit
d2d22eafb5
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "layBookmarksView.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layAbstractMenu.h"
|
||||
#include "layAbstractMenuProvider.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
@ -100,7 +102,9 @@ BookmarksView::BookmarksView (LayoutView *view, QWidget *parent, const char *nam
|
|||
layout->addWidget (mp_bookmarks);
|
||||
|
||||
mp_bookmarks->setModel (new BookmarkListModel (&view->bookmarks ()));
|
||||
mp_bookmarks->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
|
||||
connect (mp_bookmarks, SIGNAL (customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &)));
|
||||
connect (mp_bookmarks, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (bookmark_triggered (const QModelIndex &)));
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +113,24 @@ BookmarksView::~BookmarksView ()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksView::init_menu (lay::AbstractMenu &menu)
|
||||
{
|
||||
MenuLayoutEntry context_menu [] = {
|
||||
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)
|
||||
{
|
||||
|
|
@ -134,6 +156,18 @@ 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");
|
||||
ctx_menu->exec (bm_list->mapToGlobal (p));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksView::bookmark_triggered (const QModelIndex &index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace lay
|
|||
{
|
||||
|
||||
class LayoutView;
|
||||
class AbstractMenu;
|
||||
|
||||
/**
|
||||
* @brief A widget to display a bookmark list
|
||||
|
|
@ -53,10 +54,13 @@ public:
|
|||
|
||||
void refresh ();
|
||||
|
||||
static void init_menu (lay::AbstractMenu &menu);
|
||||
|
||||
public slots:
|
||||
void bookmark_triggered (const QModelIndex &index);
|
||||
void context_menu (const QPoint &p);
|
||||
|
||||
public:
|
||||
private:
|
||||
LayoutView *mp_view;
|
||||
QListView *mp_bookmarks;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -840,6 +840,7 @@ LayoutView::init_menu (lay::AbstractMenu &menu)
|
|||
lay::LayerControlPanel::init_menu (menu);
|
||||
lay::HierarchyControlPanel::init_menu (menu);
|
||||
lay::LibrariesView::init_menu (menu);
|
||||
lay::BookmarksView::init_menu (menu);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Reference in New Issue