enable = false;
break;
+ // FIXME optimally this should be in Text::getStatus. In such a case the flags
+ // are not passed when using context menu. This way it works.
+ case LFUN_SET_GRAPHICS_GROUP: {
+ if (!view())
+ break;
+ InsetGraphics * ins = InsetGraphics::getCurrentGraphicsInset(view()->cursor());
+ if (!ins)
+ break;
+ if (!cmd.argument().empty())
+ flag.setOnOff(to_utf8(cmd.argument()) == ins->getParams().groupId);
+ enable = true;
+ break;
+ }
+
case LFUN_TOOLBAR_TOGGLE:
case LFUN_INSET_APPLY:
case LFUN_BUFFER_WRITE:
void expandToolbars();
void expandBranches(Buffer const * buf);
void expandCiteStyles(BufferView const *);
- void expandGraphicsGroups(Buffer const * buf);
+ void expandGraphicsGroups(BufferView const *);
///
ItemList items_;
///
}
-void MenuDefinition::expandGraphicsGroups(Buffer const * buf)
+void MenuDefinition::expandGraphicsGroups(BufferView const * bv)
{
+ if (!bv)
+ return;
+ Cursor const & cur = bv->cursor();
+ Buffer const & buf = bv->buffer();
set<string> grp;
- InsetGraphics::getGraphicsGroups(*buf, grp);
+ InsetGraphics::getGraphicsGroups(buf, grp);
set<string>::const_iterator it = grp.begin();
set<string>::const_iterator end = grp.end();
- if (grp.empty()) return;
+ if (grp.empty())
+ return;
+ InsetGraphics * ins = InsetGraphics::getCurrentGraphicsInset(cur);
+ if (!ins)
+ return;
add(MenuItem(MenuItem::Separator));
- add(MenuItem(MenuItem::Command, qt_("Clear group"), FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
+ if (!ins->getParams().groupId.empty())
+ add(MenuItem(MenuItem::Command, qt_("Clear group"), FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
for (; it != end; it++) {
- add(MenuItem(MenuItem::Command, toqstr(*it), FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*it),
+ FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
}
}
break;
case MenuItem::GraphicsGroups:
- tomenu.expandGraphicsGroups(buf);
+ tomenu.expandGraphicsGroups(bv);
break;
case MenuItem::Submenu: {