3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup
8 * \author Lars Gullik Bjønnes
9 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
12 * \author Martin Vermeer
14 * Full author contact details are available in file CREDITS.
22 #include "GuiApplication.h"
24 #include "GuiWorkArea.h"
25 #include "qt_helpers.h"
27 #include "BiblioInfo.h"
28 #include "BranchList.h"
30 #include "BufferList.h"
31 #include "BufferParams.h"
32 #include "BufferView.h"
33 #include "Converter.h"
34 #include "CutAndPaste.h"
36 #include "FloatList.h"
38 #include "FuncRequest.h"
39 #include "FuncStatus.h"
40 #include "IndicesList.h"
45 #include "LyXAction.h"
49 #include "Paragraph.h"
50 #include "ParagraphParameters.h"
51 #include "ParIterator.h"
53 #include "SpellChecker.h"
54 #include "TextClass.h"
56 #include "TocBackend.h"
58 #include "WordLangTuple.h"
60 #include "insets/Inset.h"
61 #include "insets/InsetCitation.h"
62 #include "insets/InsetGraphics.h"
63 #include "insets/InsetQuotes.h"
65 #include "support/lassert.h"
66 #include "support/convert.h"
67 #include "support/debug.h"
68 #include "support/docstring_list.h"
69 #include "support/filetools.h"
70 #include "support/gettext.h"
71 #include "support/lstrings.h"
78 #if QT_VERSION >= 0x040600
79 #include <QProxyStyle>
87 using namespace lyx::support;
95 // MacOSX specific stuff is at the end.
102 /// The type of elements that can be in a menu
110 /** This type of item explains why something is unavailable. If this
111 menuitem is in a submenu, the submenu is enabled to make sure the
112 user sees the information. */
114 /** This type of item merely shows that there might be a list or
115 something alike at this position, but the list is still empty.
116 If this item is in a submenu, the submenu will not always be
119 /** This is the list of last opened file,
120 typically for the File menu. */
122 /** This is the list of opened Documents,
123 typically for the Documents menu. */
125 /** This is the bookmarks */
129 /** This is a list of viewable formats
130 typically for the File->View menu. */
132 /** This is a list of updatable formats
133 typically for the File->Update menu. */
135 /** This is a list of exportable formats
136 typically for the File->Export menu. */
138 /** This is a list of importable formats
139 typically for the File->Import menu. */
141 /** This is the list of elements available
142 * for insertion into document. */
144 /** This is the list of user-configurable
145 insets to insert into document */
147 /** This is the list of XML elements to
148 insert into the document */
150 /** This is the list of floats that we can
151 insert a list for. */
153 /** This is the list of floats that we can
156 /** This is the list of selections that can
161 /** Available branches in document */
163 /** Available indices in document */
165 /** Context menu for indices in document */
167 /** Available index lists in document */
169 /** Context menu for available indices lists in document */
171 /** Available citation styles for a given citation */
173 /** Available graphics groups */
175 /// Words suggested by the spellchecker.
177 /** Used Languages */
179 /** This is the list of arguments available
180 for insertion into the current layout. */
182 /** This is the list of arguments available
183 in the InsetArgument context menu. */
185 /** This is the list of captions available
186 in the current layout. */
188 /** This is the list of captions available
189 in the InsetCaption context menu. */
191 /** Commands to separate environments. */
192 EnvironmentSeparators,
193 /** This is the list of quotation marks available */
197 explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
200 QString const & label,
201 QString const & submenu = QString(),
202 QString const & tooltip = QString(),
203 bool optional = false)
204 : kind_(kind), label_(label), func_(make_shared<FuncRequest>()),
205 submenuname_(submenu), tooltip_(tooltip), optional_(optional)
207 LATTEST(kind == Submenu || kind == Help || kind == Info);
211 QString const & label,
212 FuncRequest const & func,
213 QString const & tooltip = QString(),
214 bool optional = false,
215 FuncRequest::Origin origin = FuncRequest::MENU)
216 : kind_(kind), label_(label), func_(make_shared<FuncRequest>(func)),
217 tooltip_(tooltip), optional_(optional)
219 func_->setOrigin(origin);
222 /// The label of a given menuitem
223 QString label() const
225 int const index = label_.lastIndexOf('|');
226 return index == -1 ? label_ : label_.left(index);
229 /// The keyboard shortcut (usually underlined in the entry)
230 QString shortcut() const
232 int const index = label_.lastIndexOf('|');
233 return index == -1 ? QString() : label_.mid(index + 1);
235 /// The complete label, with label and shortcut separated by a '|'
236 QString fulllabel() const { return label_; }
237 /// The kind of entry
238 Kind kind() const { return kind_; }
239 /// the action (if relevant)
240 shared_ptr<FuncRequest const> func() const { return func_; }
242 QString const & tooltip() const { return tooltip_; }
243 /// returns true if the entry should be omitted when disabled
244 bool optional() const { return optional_; }
245 /// returns the status of the lfun associated with this entry
246 FuncStatus const & status() const { return status_; }
247 /// returns the status of the lfun associated with this entry
248 FuncStatus & status() { return status_; }
249 /// returns the status of the lfun associated with this entry
250 void status(FuncStatus const & status) { status_ = status; }
252 ///returns the binding associated to this action.
253 QString binding() const
255 if (kind_ != Command)
257 // Get the keys bound to this action, but keep only the
259 KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(*func_);
260 if (!bindings.empty())
261 return toqstr(bindings.begin()->print(KeySequence::ForGui));
263 LYXERR(Debug::KBMAP, "No binding for "
264 << lyxaction.getActionName(func_->action())
265 << '(' << func_->argument() << ')');
269 /// the description of the submenu (if relevant)
270 QString const & submenuname() const { return submenuname_; }
271 /// set the description of the submenu
272 void submenuname(QString const & name) { submenuname_ = name; }
274 bool hasSubmenu() const { return !submenu_.isEmpty(); }
276 MenuDefinition const & submenu() const { return submenu_.at(0); }
277 MenuDefinition & submenu() { return submenu_[0]; }
279 void setSubmenu(MenuDefinition const & menu)
282 submenu_.append(menu);
291 shared_ptr<FuncRequest> func_;// non-null
293 QString submenuname_;
300 /// contains 0 or 1 item.
301 QList<MenuDefinition> submenu_;
305 class MenuDefinition {
308 typedef std::vector<MenuItem> ItemList;
310 typedef ItemList::const_iterator const_iterator;
312 explicit MenuDefinition(QString const & name = QString()) : name_(name) {}
317 QString const & name() const { return name_; }
319 bool empty() const { return items_.empty(); }
320 /// Clear the menu content.
321 void clear() { items_.clear(); }
323 size_t size() const { return items_.size(); }
325 const_iterator begin() const { return items_.begin(); }
327 const_iterator end() const { return items_.end(); }
329 void cat(MenuDefinition const & other);
331 void catSub(docstring const & name);
333 // search for func in this menu iteratively, and put menu
335 bool searchMenu(FuncRequest const & func, docstring_list & names)
338 bool hasFunc(FuncRequest const &) const;
339 /// Add the menu item unconditionally
340 void add(MenuItem const & item) { items_.push_back(item); }
341 /// Checks the associated FuncRequest status before adding the
343 void addWithStatusCheck(MenuItem const &);
344 // Check whether the menu shortcuts are unique
345 void checkShortcuts() const;
347 void expandLastfiles();
348 void expandDocuments();
349 void expandBookmarks();
350 void expandFormats(MenuItem::Kind const kind, Buffer const * buf);
351 void expandFloatListInsert(Buffer const * buf);
352 void expandFloatInsert(Buffer const * buf);
353 void expandFlexInsert(Buffer const * buf, InsetLayout::InsetLyXType type);
354 void expandToc2(Toc const & toc_list, size_t from, size_t to, int depth, string toc_type);
355 void expandToc(Buffer const * buf);
356 void expandPasteRecent(Buffer const * buf);
357 void expandToolbars();
358 void expandBranches(Buffer const * buf);
359 void expandIndices(Buffer const * buf, bool listof = false);
360 void expandIndicesContext(Buffer const * buf, bool listof = false);
361 void expandCiteStyles(BufferView const *);
362 void expandGraphicsGroups(BufferView const *);
363 void expandSpellingSuggestions(BufferView const *);
364 void expandLanguageSelector(Buffer const * buf);
365 void expandArguments(BufferView const *, bool switcharg = false);
366 void expandCaptions(Buffer const * buf, bool switchcap = false);
367 void expandEnvironmentSeparators(BufferView const *);
368 void expandQuotes(BufferView const *);
376 /// Helper for std::find_if
380 MenuNamesEqual(QString const & name) : name_(name) {}
381 bool operator()(MenuDefinition const & menu) const { return menu.name() == name_; }
388 typedef std::vector<MenuDefinition> MenuList;
390 typedef MenuList::const_iterator const_iterator;
392 typedef MenuList::iterator iterator;
394 /////////////////////////////////////////////////////////////////////
395 // MenuDefinition implementation
396 /////////////////////////////////////////////////////////////////////
398 void MenuDefinition::addWithStatusCheck(MenuItem const & i)
402 case MenuItem::Command: {
403 FuncStatus status = lyx::getStatus(*i.func());
404 if (status.unknown() || (!status.enabled() && i.optional()))
407 items_.back().status(status);
411 case MenuItem::Submenu: {
412 bool enabled = false;
413 if (i.hasSubmenu()) {
414 for (const_iterator cit = i.submenu().begin();
415 cit != i.submenu().end(); ++cit) {
416 // Only these kind of items affect the status of the submenu
417 if ((cit->kind() == MenuItem::Command
418 || cit->kind() == MenuItem::Submenu
419 || cit->kind() == MenuItem::Help)
420 && cit->status().enabled()) {
426 if (enabled || !i.optional()) {
428 items_.back().status().setEnabled(enabled);
433 case MenuItem::Separator:
434 if (!items_.empty() && items_.back().kind() != MenuItem::Separator)
444 void MenuDefinition::read(Lexer & lex)
461 md_indiceslistscontext,
475 md_spellingsuggestions,
485 LexerKeyword menutags[] = {
486 { "arguments", md_arguments },
487 { "bookmarks", md_bookmarks },
488 { "branches", md_branches },
489 { "captions", md_captions },
490 { "charstyles", md_charstyles },
491 { "citestyles", md_citestyles },
492 { "custom", md_custom },
493 { "documents", md_documents },
494 { "elements", md_elements },
495 { "end", md_endmenu },
496 { "environmentseparators", md_env_separators },
497 { "exportformats", md_exportformats },
498 { "floatinsert", md_floatinsert },
499 { "floatlistinsert", md_floatlistinsert },
500 { "graphicsgroups", md_graphicsgroups },
501 { "importformats", md_importformats },
502 { "indices", md_indices },
503 { "indicescontext", md_indicescontext },
504 { "indiceslists", md_indiceslists },
505 { "indiceslistscontext", md_indiceslistscontext },
507 { "languageselector", md_languageselector },
508 { "lastfiles", md_lastfiles },
509 { "optitem", md_optitem },
510 { "optsubmenu", md_optsubmenu },
511 { "pasterecent", md_pasterecent },
512 { "separator", md_separator },
513 { "spellingsuggestions", md_spellingsuggestions },
514 { "submenu", md_submenu },
515 { "switcharguments", md_switcharguments },
516 { "switchcaptions", md_switchcaptions },
517 { "switchquotes", md_switchquotes },
519 { "toolbars", md_toolbars },
520 { "updateformats", md_updateformats },
521 { "viewformats", md_viewformats }
524 lex.pushTable(menutags);
525 lex.setContext("MenuDefinition::read: ");
528 while (lex.isOK() && md_type != md_endmenu) {
529 switch (md_type = lex.lex()) {
533 docstring const name = translateIfPossible(lex.getDocString());
535 string const command = lex.getString();
536 FuncRequest func = lyxaction.lookupFunc(command);
537 FuncRequest::Origin origin = FuncRequest::MENU;
538 if (name_.startsWith("context-toc-"))
539 origin = FuncRequest::TOC;
540 bool const optional = (md_type == md_optitem);
541 add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin));
546 add(MenuItem(MenuItem::Separator));
550 add(MenuItem(MenuItem::Lastfiles));
554 add(MenuItem(MenuItem::CharStyles));
558 add(MenuItem(MenuItem::Custom));
562 add(MenuItem(MenuItem::Elements));
566 add(MenuItem(MenuItem::Documents));
570 add(MenuItem(MenuItem::Bookmarks));
574 add(MenuItem(MenuItem::Toc));
578 add(MenuItem(MenuItem::ViewFormats));
581 case md_updateformats:
582 add(MenuItem(MenuItem::UpdateFormats));
585 case md_exportformats:
586 add(MenuItem(MenuItem::ExportFormats));
589 case md_importformats:
590 add(MenuItem(MenuItem::ImportFormats));
593 case md_floatlistinsert:
594 add(MenuItem(MenuItem::FloatListInsert));
598 add(MenuItem(MenuItem::FloatInsert));
602 add(MenuItem(MenuItem::PasteRecent));
606 add(MenuItem(MenuItem::Toolbars));
610 add(MenuItem(MenuItem::Branches));
614 add(MenuItem(MenuItem::CiteStyles));
617 case md_graphicsgroups:
618 add(MenuItem(MenuItem::GraphicsGroups));
621 case md_spellingsuggestions:
622 add(MenuItem(MenuItem::SpellingSuggestions));
625 case md_languageselector:
626 add(MenuItem(MenuItem::LanguageSelector));
630 add(MenuItem(MenuItem::Indices));
633 case md_indicescontext:
634 add(MenuItem(MenuItem::IndicesContext));
637 case md_indiceslists:
638 add(MenuItem(MenuItem::IndicesLists));
641 case md_indiceslistscontext:
642 add(MenuItem(MenuItem::IndicesListsContext));
646 add(MenuItem(MenuItem::Arguments));
649 case md_switcharguments:
650 add(MenuItem(MenuItem::SwitchArguments));
654 add(MenuItem(MenuItem::Captions));
657 case md_switchcaptions:
658 add(MenuItem(MenuItem::SwitchCaptions));
661 case md_env_separators:
662 add(MenuItem(MenuItem::EnvironmentSeparators));
665 case md_switchquotes:
666 add(MenuItem(MenuItem::SwitchQuotes));
672 docstring const mlabel = translateIfPossible(lex.getDocString());
674 docstring const mname = lex.getDocString();
675 bool const optional = (md_type == md_optsubmenu);
676 add(MenuItem(MenuItem::Submenu,
677 toqstr(mlabel), toqstr(mname), QString(), optional));
685 lex.printError("Unknown menu tag");
693 bool MenuDefinition::hasFunc(FuncRequest const & func) const
695 for (const_iterator it = begin(), et = end(); it != et; ++it)
696 if (*it->func() == func)
702 void MenuDefinition::catSub(docstring const & name)
704 add(MenuItem(MenuItem::Submenu,
705 qt_("More...|M"), toqstr(name), QString(), false));
708 void MenuDefinition::cat(MenuDefinition const & other)
710 const_iterator et = other.end();
711 for (const_iterator it = other.begin(); it != et; ++it)
716 void MenuDefinition::checkShortcuts() const
718 // This is a quadratic algorithm, but we do not care because
719 // menus are short enough
720 for (const_iterator it1 = begin(); it1 != end(); ++it1) {
721 QString shortcut = it1->shortcut();
722 if (shortcut.isEmpty())
724 if (!it1->label().contains(shortcut))
725 LYXERR0("Menu warning: menu entry \""
727 << "\" does not contain shortcut `"
728 << shortcut << "'.");
729 for (const_iterator it2 = begin(); it2 != it1 ; ++it2) {
730 if (!it2->shortcut().compare(shortcut, Qt::CaseInsensitive)) {
731 LYXERR0("Menu warning: menu entries "
732 << '"' << it1->fulllabel()
733 << "\" and \"" << it2->fulllabel()
734 << "\" share the same shortcut.");
741 bool MenuDefinition::searchMenu(FuncRequest const & func, docstring_list & names) const
743 const_iterator m = begin();
744 const_iterator m_end = end();
745 for (; m != m_end; ++m) {
746 if (m->kind() == MenuItem::Command && *m->func() == func) {
747 names.push_back(qstring_to_ucs4(m->label()));
750 if (m->kind() == MenuItem::Submenu) {
751 names.push_back(qstring_to_ucs4(m->label()));
752 if (!m->hasSubmenu()) {
753 LYXERR(Debug::GUI, "Warning: non existing sub menu label="
754 << m->label() << " name=" << m->submenuname());
758 if (m->submenu().searchMenu(func, names))
767 QString limitStringLength(docstring const & str)
769 size_t const max_item_length = 45;
770 docstring ret = str.substr(0, max_item_length + 1);
771 support::truncateWithEllipsis(ret, max_item_length);
776 void MenuDefinition::expandGraphicsGroups(BufferView const * bv)
781 graphics::getGraphicsGroups(bv->buffer(), grp);
785 set<string>::const_iterator it = grp.begin();
786 set<string>::const_iterator end = grp.end();
787 add(MenuItem(MenuItem::Command, qt_("No Group"),
788 FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
789 for (; it != end; ++it) {
790 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*it) + '|',
791 FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
796 void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
800 Cursor const & cur = bv->cursor();
804 docstring_list suggestions;
805 Paragraph const & par = cur.paragraph();
806 pos_type from = cur.pos();
808 SpellChecker::Result res = par.spellCheck(from, to, wl, suggestions, true, true);
810 case SpellChecker::UNKNOWN_WORD:
811 if (lyxrc.spellcheck_continuously) {
812 LYXERR(Debug::GUI, "Misspelled Word! Suggested Words = ");
813 docstring const & selection = cur.selectionAsString(false);
814 if (!cur.selection() || selection == wl.word()) {
816 size_t m = 10; // first submenu index
817 MenuItem item(MenuItem::Submenu, qt_("More Spelling Suggestions"));
818 item.setSubmenu(MenuDefinition(qt_("More Spelling Suggestions")));
819 for (; i != suggestions.size(); ++i) {
820 docstring const & suggestion = suggestions[i];
821 LYXERR(Debug::GUI, suggestion);
822 MenuItem w(MenuItem::Command, toqstr(suggestion),
823 FuncRequest(LFUN_WORD_REPLACE,
824 replace2string(suggestion, selection,
825 true, // case sensitive
829 false))); // find next
833 item.submenu().add(w);
838 add(MenuItem(MenuItem::Separator));
839 docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
840 add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|n"),
841 FuncRequest(LFUN_SPELLING_ADD, arg)));
842 add(MenuItem(MenuItem::Command, qt_("Ignore all|I"),
843 FuncRequest(LFUN_SPELLING_IGNORE, arg)));
847 case SpellChecker::LEARNED_WORD: {
848 LYXERR(Debug::GUI, "Learned Word.");
849 docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
850 add(MenuItem(MenuItem::Command, qt_("Remove from personal dictionary|r"),
851 FuncRequest(LFUN_SPELLING_REMOVE, arg)));
854 case SpellChecker::NO_DICTIONARY:
855 LYXERR(Debug::GUI, "No dictionary for language " + from_ascii(wl.lang()->lang()));
857 case SpellChecker::WORD_OK:
858 case SpellChecker::COMPOUND_WORD:
859 case SpellChecker::ROOT_FOUND:
860 case SpellChecker::IGNORED_WORD:
865 struct sortLanguageByName {
866 bool operator()(const Language * a, const Language * b) const {
867 return qt_(a->display()).localeAwareCompare(qt_(b->display())) < 0;
871 void MenuDefinition::expandLanguageSelector(Buffer const * buf)
876 std::set<Language const *> languages_buffer =
877 buf->masterBuffer()->getLanguages();
879 if (languages_buffer.size() < 2)
882 std::set<Language const *, sortLanguageByName> languages;
884 std::set<Language const *>::const_iterator const beg =
885 languages_buffer.begin();
886 for (std::set<Language const *>::const_iterator cit = beg;
887 cit != languages_buffer.end(); ++cit) {
888 languages.insert(*cit);
891 MenuItem item(MenuItem::Submenu, qt_("Language|L"));
892 item.setSubmenu(MenuDefinition(qt_("Language")));
893 QString morelangs = qt_("More Languages ...|M");
894 QStringList accelerators;
895 if (morelangs.contains('|'))
896 accelerators.append(morelangs.section('|', -1));
897 std::set<Language const *, sortLanguageByName>::const_iterator const begin = languages.begin();
898 for (std::set<Language const *, sortLanguageByName>::const_iterator cit = begin;
899 cit != languages.end(); ++cit) {
900 QString label = qt_((*cit)->display());
901 // try to add an accelerator
902 bool success = false;
903 // try capitals first
904 for (int i = 0; i < label.size(); ++i) {
905 QChar const ch = label[i];
908 if (!accelerators.contains(ch, Qt::CaseInsensitive)) {
909 label = label + toqstr("|") + ch;
910 accelerators.append(ch);
915 // if all capitals are taken, try the rest
917 for (int i = 0; i < label.size(); ++i) {
918 if (label[i].isSpace())
920 QString const ch = QString(label[i]);
921 if (!accelerators.contains(ch, Qt::CaseInsensitive)) {
922 label = label + toqstr("|") + ch;
923 accelerators.append(ch);
928 MenuItem w(MenuItem::Command, label,
929 FuncRequest(LFUN_LANGUAGE, (*cit)->lang() + " set"));
930 item.submenu().addWithStatusCheck(w);
932 item.submenu().add(MenuItem(MenuItem::Separator));
933 item.submenu().add(MenuItem(MenuItem::Command, morelangs,
934 FuncRequest(LFUN_DIALOG_SHOW, "character")));
939 void MenuDefinition::expandLastfiles()
941 LastFilesSection::LastFiles const & lf = theSession().lastFiles().lastFiles();
942 LastFilesSection::LastFiles::const_iterator lfit = lf.begin();
946 for (; lfit != lf.end() && ii <= lyxrc.num_lastfiles; ++lfit, ++ii) {
947 string const file = lfit->absFileName();
948 QString const short_path = toqstr(makeDisplayPath(file, 30));
949 QString const long_path = toqstr(makeDisplayPath(file));
952 label = QString("%1. %2|%3").arg(ii).arg(short_path).arg(ii);
954 label = QString("%1. %2").arg(ii).arg(short_path);
955 add(MenuItem(MenuItem::Command, label,
956 FuncRequest(LFUN_FILE_OPEN, file), long_path));
961 void MenuDefinition::expandDocuments()
963 MenuItem item(MenuItem::Submenu, qt_("Hidden|H"));
964 item.setSubmenu(MenuDefinition(qt_("Hidden|H")));
966 Buffer * first = theBufferList().first();
968 add(MenuItem(MenuItem::Info, qt_("<No Documents Open>")));
974 if (!guiApp->currentView())
976 GuiWorkArea * wa = guiApp->currentView()->workArea(i);
979 Buffer const & b = wa->bufferView().buffer();
980 QString label = toqstr(b.fileName().displayName(20));
984 label = QString::number(i) + ". " + label + '|' + QString::number(i);
985 add(MenuItem(MenuItem::Command, label,
986 FuncRequest(LFUN_BUFFER_SWITCH, b.absFileName())));
993 // We cannot use a for loop as the buffer list cycles.
995 if (!(guiApp->currentView()
996 && guiApp->currentView()->workArea(*b))) {
997 QString label = toqstr(b->fileName().displayName(20));
1001 label = QString::number(i) + ". " + label + '|' + QString::number(i);
1002 item.submenu().add(MenuItem(MenuItem::Command, label,
1003 FuncRequest(LFUN_BUFFER_SWITCH, b->absFileName())));
1006 b = theBufferList().next(b);
1007 } while (b != first);
1009 if (!item.submenu().empty())
1014 void MenuDefinition::expandBookmarks()
1016 lyx::BookmarksSection const & bm = theSession().bookmarks();
1019 for (size_t i = 1; i <= bm.size(); ++i) {
1020 if (bm.isValid(i)) {
1021 string const file = bm.bookmark(i).filename.absFileName();
1022 QString const label = QString("%1. %2|%3").arg(i)
1023 .arg(toqstr(makeDisplayPath(file, 20))).arg(i);
1024 add(MenuItem(MenuItem::Command, label,
1025 FuncRequest(LFUN_BOOKMARK_GOTO, convert<docstring>(i))));
1030 add(MenuItem(MenuItem::Info, qt_("<No Bookmarks Saved Yet>")));
1034 void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf)
1036 if (!buf && kind != MenuItem::ImportFormats)
1040 FuncCode action = LFUN_NOACTION;
1043 case MenuItem::ImportFormats:
1044 formats = theConverters().importableFormats();
1045 action = LFUN_BUFFER_IMPORT;
1047 case MenuItem::ViewFormats:
1048 formats = buf->params().exportableFormats(true);
1049 action = LFUN_BUFFER_VIEW;
1051 case MenuItem::UpdateFormats:
1052 formats = buf->params().exportableFormats(true);
1053 action = LFUN_BUFFER_UPDATE;
1055 case MenuItem::ExportFormats:
1056 formats = buf->params().exportableFormats(false);
1057 action = LFUN_BUFFER_EXPORT;
1064 bool const view_update = (kind == MenuItem::ViewFormats
1065 || kind == MenuItem::UpdateFormats);
1069 smenue = (kind == MenuItem::ViewFormats
1070 ? qt_("View (Other Formats)|F")
1071 : qt_("Update (Other Formats)|p"));
1072 MenuItem item(MenuItem::Submenu, smenue);
1073 item.setSubmenu(MenuDefinition(smenue));
1075 for (Format const * f : formats) {
1079 docstring lab = f->prettyname();
1080 docstring const scut = from_utf8(f->shortcut());
1081 docstring const tmplab = lab;
1084 lab += char_type('|') + scut;
1085 docstring const lab_i18n = translateIfPossible(lab);
1086 docstring const shortcut = split(lab_i18n, lab, '|');
1088 bool const untranslated = (lab == lab_i18n);
1089 docstring label = untranslated ? translateIfPossible(tmplab) : lab;
1092 case MenuItem::ImportFormats:
1093 label += from_ascii("...");
1095 case MenuItem::ViewFormats:
1096 case MenuItem::UpdateFormats:
1097 if (f->name() == buf->params().getDefaultOutputFormat()) {
1098 docstring lbl = (kind == MenuItem::ViewFormats
1099 ? bformat(_("View [%1$s]|V"), label)
1100 : bformat(_("Update [%1$s]|U"), label));
1101 add(MenuItem(MenuItem::Command, toqstr(lbl), FuncRequest(action)));
1105 case MenuItem::ExportFormats:
1106 if (!f->inExportMenu())
1110 // we already asserted earlier in this case
1114 if (!shortcut.empty())
1115 label += '|' + shortcut;
1118 // note that at this point, we know that buf is not null
1120 item.submenu().addWithStatusCheck(MenuItem(MenuItem::Command,
1121 toqstr(label), FuncRequest(action, f->name())));
1124 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1125 FuncRequest(action, f->name())));
1127 add(MenuItem(MenuItem::Command, toqstr(label),
1128 FuncRequest(action, f->name())));
1136 void MenuDefinition::expandFloatListInsert(Buffer const * buf)
1141 FloatList const & floats = buf->params().documentClass().floats();
1142 FloatList::const_iterator cit = floats.begin();
1143 FloatList::const_iterator end = floats.end();
1145 for (; cit != end; ++cit) {
1146 if (!cit->second.usesFloatPkg()) {
1147 // Different floats could declare the same ListCommand. We only
1148 // want it on the list once, though.
1149 string const & list_cmd = cit->second.listCommand();
1150 if (list_cmd.empty())
1151 // we do not know how to generate such a list
1153 // This form of insert returns an iterator pointing to the newly
1154 // inserted element OR the existing element with that value, and
1155 // a bool indicating whether we inserted a new element. So we can
1156 // see if one is there and insert it if not all at once.
1157 pair<set<string>::iterator, bool> ret = seen.insert(list_cmd);
1161 string const & list_name = cit->second.listName();
1162 addWithStatusCheck(MenuItem(MenuItem::Command, qt_(list_name),
1163 FuncRequest(LFUN_FLOAT_LIST_INSERT, cit->second.floattype())));
1168 void MenuDefinition::expandFloatInsert(Buffer const * buf)
1173 FloatList const & floats = buf->params().documentClass().floats();
1174 FloatList::const_iterator cit = floats.begin();
1175 FloatList::const_iterator end = floats.end();
1176 for (; cit != end; ++cit) {
1178 QString const label = qt_(cit->second.name());
1179 addWithStatusCheck(MenuItem(MenuItem::Command, label,
1180 FuncRequest(LFUN_FLOAT_INSERT,
1181 cit->second.floattype())));
1186 void MenuDefinition::expandFlexInsert(
1187 Buffer const * buf, InsetLayout::InsetLyXType type)
1192 TextClass::InsetLayouts const & insetLayouts =
1193 buf->params().documentClass().insetLayouts();
1194 TextClass::InsetLayouts::const_iterator cit = insetLayouts.begin();
1195 TextClass::InsetLayouts::const_iterator end = insetLayouts.end();
1196 for (; cit != end; ++cit) {
1197 if (cit->second.lyxtype() == type) {
1198 if (!cit->second.obsoleted_by().empty())
1200 docstring label = cit->first;
1201 // we remove the "Flex:" prefix, if it is present
1202 if (prefixIs(label, from_ascii("Flex:")))
1203 label = label.substr(5);
1204 addWithStatusCheck(MenuItem(MenuItem::Command,
1205 toqstr(translateIfPossible(label)),
1206 FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
1209 // FIXME This is a little clunky.
1210 if (items_.empty() && type == InsetLayout::CUSTOM && !buf->isReadonly())
1211 add(MenuItem(MenuItem::Help, qt_("No Custom Insets Defined!")));
1215 // Threshold before we stop displaying sub-items alongside items
1216 // (for display purposes). Ideally this should fit on a screen.
1217 size_t const max_number_of_items = 30;
1218 // Size limit for the menu. This is for performance purposes,
1219 // because qt already displays a scrollable menu when necessary.
1220 // Ideally this should be the menu size from which scrollable
1221 // menus become unpractical.
1222 size_t const menu_size_limit = 80;
1224 void MenuDefinition::expandToc2(Toc const & toc_list,
1225 size_t from, size_t to, int depth,
1228 int shortcut_count = 0;
1230 // check whether depth is smaller than the smallest depth in toc.
1231 int min_depth = 1000;
1232 for (size_t i = from; i < to; ++i)
1233 min_depth = min(min_depth, toc_list[i].depth());
1234 if (min_depth > depth)
1237 if (to - from <= max_number_of_items) {
1238 for (size_t i = from; i < to; ++i) {
1239 QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
1240 label += limitStringLength(toc_list[i].asString());
1241 if (toc_list[i].depth() == depth) {
1243 if (shortcut_count < 9) {
1244 if (label.contains(QString::number(shortcut_count + 1)))
1245 label += QString::number(++shortcut_count);
1248 add(MenuItem(MenuItem::Command, label,
1249 FuncRequest(toc_list[i].action())));
1250 // separator after the menu heading
1251 if (toc_list[i].depth() < depth)
1252 add(MenuItem(MenuItem::Separator));
1258 size_t new_pos = pos + 1;
1259 while (new_pos < to && toc_list[new_pos].depth() > depth)
1262 QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
1263 label += limitStringLength(toc_list[pos].asString());
1264 if (toc_list[pos].depth() == depth) {
1266 if (shortcut_count < 9) {
1267 if (label.contains(QString::number(shortcut_count + 1)))
1268 label += QString::number(++shortcut_count);
1271 if (size >= menu_size_limit) {
1272 FuncRequest f(LFUN_DIALOG_SHOW, "toc " + toc_type);
1273 add(MenuItem(MenuItem::Command, "...", f));
1276 if (new_pos == pos + 1) {
1277 add(MenuItem(MenuItem::Command,
1278 label, FuncRequest(toc_list[pos].action())));
1281 sub.expandToc2(toc_list, pos, new_pos, depth + 1, toc_type);
1282 MenuItem item(MenuItem::Submenu, label);
1283 item.setSubmenu(sub);
1293 void MenuDefinition::expandToc(Buffer const * buf)
1295 // To make things very cleanly, we would have to pass buf to
1296 // all MenuItem constructors and to expandToc2. However, we
1297 // know that all the entries in a TOC will be have status_ ==
1298 // OK, so we avoid this unnecessary overhead (JMarc)
1300 add(MenuItem(MenuItem::Info, qt_("(No Document Open)")));
1303 // Add an entry for the master doc if this is a child doc
1304 Buffer const * const master = buf->masterBuffer();
1305 if (buf != master) {
1306 ParIterator const pit = par_iterator_begin(master->inset());
1307 string const arg = convert<string>(pit->id());
1308 FuncRequest f(LFUN_PARAGRAPH_GOTO, arg);
1309 add(MenuItem(MenuItem::Command, qt_("Master Document"), f));
1312 MenuDefinition other_lists;
1313 FloatList const & floatlist = buf->params().documentClass().floats();
1314 TocList const & toc_list = buf->tocBackend().tocs();
1315 TocList::const_iterator cit = toc_list.begin();
1316 TocList::const_iterator end = toc_list.end();
1317 for (; cit != end; ++cit) {
1318 // Handle table of contents later
1319 if (cit->first == "tableofcontents" || cit->second->empty())
1321 MenuDefinition submenu;
1322 // "Open outliner..." entry
1323 FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
1324 submenu.add(MenuItem(MenuItem::Command, qt_("Open Outliner..."), f));
1325 submenu.add(MenuItem(MenuItem::Separator));
1327 submenu.expandToc2(*cit->second, 0, cit->second->size(), 0, cit->first);
1328 MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
1329 item.setSubmenu(submenu);
1330 // deserves to be in the main menu?
1331 if (floatlist.typeExist(cit->first) || cit->first == "child")
1334 other_lists.add(item);
1336 if (!other_lists.empty()) {
1337 MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
1338 item.setSubmenu(other_lists);
1341 // Handle normal TOC
1342 add(MenuItem(MenuItem::Separator));
1343 cit = toc_list.find("tableofcontents");
1345 LYXERR(Debug::GUI, "No table of contents.");
1347 if (!cit->second->empty())
1348 expandToc2(*cit->second, 0, cit->second->size(), 0,
1351 add(MenuItem(MenuItem::Info, qt_("(Empty Table of Contents)")));
1356 void MenuDefinition::expandPasteRecent(Buffer const * buf)
1358 docstring_list const sel = cap::availableSelections(buf);
1360 docstring_list::const_iterator cit = sel.begin();
1361 docstring_list::const_iterator end = sel.end();
1363 for (unsigned int index = 0; cit != end; ++cit, ++index) {
1364 add(MenuItem(MenuItem::Command, toqstr(*cit) + '|',
1365 FuncRequest(LFUN_PASTE, convert<string>(index))));
1370 void MenuDefinition::expandToolbars()
1372 MenuDefinition other_lists;
1373 // extracts the toolbars from the backend
1374 Toolbars::Infos::const_iterator cit = guiApp->toolbars().begin();
1375 Toolbars::Infos::const_iterator end = guiApp->toolbars().end();
1376 for (; cit != end; ++cit) {
1377 MenuItem const item(MenuItem::Command, toqstr(cit->gui_name),
1378 FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name));
1379 if (guiApp->toolbars().isMainToolbar(cit->name))
1382 other_lists.add(item);
1385 if (!other_lists.empty()) {
1386 MenuItem item(MenuItem::Submenu, qt_("Other Toolbars"));
1387 item.setSubmenu(other_lists);
1393 void MenuDefinition::expandBranches(Buffer const * buf)
1395 if (!buf || buf->isReadonly())
1398 BufferParams const & master_params = buf->masterBuffer()->params();
1399 BufferParams const & params = buf->params();
1400 if (params.branchlist().empty() && master_params.branchlist().empty() ) {
1401 add(MenuItem(MenuItem::Help, qt_("No Branches Set for Document!")));
1405 BranchList::const_iterator cit = master_params.branchlist().begin();
1406 BranchList::const_iterator end = master_params.branchlist().end();
1408 for (int ii = 1; cit != end; ++cit, ++ii) {
1409 docstring label = cit->branch();
1411 label = convert<docstring>(ii) + ". " + label
1412 + char_type('|') + convert<docstring>(ii);
1414 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1415 FuncRequest(LFUN_BRANCH_INSERT,
1419 if (buf == buf->masterBuffer())
1422 MenuDefinition child_branches;
1424 BranchList::const_iterator ccit = params.branchlist().begin();
1425 BranchList::const_iterator cend = params.branchlist().end();
1427 for (int ii = 1; ccit != cend; ++ccit, ++ii) {
1428 docstring label = ccit->branch();
1430 label = convert<docstring>(ii) + ". " + label
1431 + char_type('|') + convert<docstring>(ii);
1433 label += char_type('|');
1434 child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
1436 FuncRequest(LFUN_BRANCH_INSERT,
1440 if (!child_branches.empty()) {
1441 MenuItem item(MenuItem::Submenu, qt_("Child Document"));
1442 item.setSubmenu(child_branches);
1448 void MenuDefinition::expandIndices(Buffer const * buf, bool listof)
1453 BufferParams const & params = buf->masterBuffer()->params();
1454 if (!params.use_indices) {
1456 addWithStatusCheck(MenuItem(MenuItem::Command,
1457 qt_("Index List|I"),
1458 FuncRequest(LFUN_INDEX_PRINT,
1459 from_ascii("idx"))));
1461 addWithStatusCheck(MenuItem(MenuItem::Command,
1462 qt_("Index Entry|d"),
1463 FuncRequest(LFUN_INDEX_INSERT,
1464 from_ascii("idx"))));
1468 if (params.indiceslist().empty())
1471 IndicesList::const_iterator cit = params.indiceslist().begin();
1472 IndicesList::const_iterator end = params.indiceslist().end();
1474 for (int ii = 1; cit != end; ++cit, ++ii) {
1476 docstring const label =
1477 bformat(_("Index: %1$s"), cit->index());
1478 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1479 FuncRequest(LFUN_INDEX_PRINT, cit->shortcut())));
1481 docstring const label =
1482 bformat(_("Index Entry (%1$s)"), cit->index());
1483 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1484 FuncRequest(LFUN_INDEX_INSERT, cit->shortcut())));
1490 void MenuDefinition::expandIndicesContext(Buffer const * buf, bool listof)
1495 BufferParams const & params = buf->masterBuffer()->params();
1496 if (!params.use_indices || params.indiceslist().empty())
1499 IndicesList::const_iterator cit = params.indiceslist().begin();
1500 IndicesList::const_iterator end = params.indiceslist().end();
1502 for (int ii = 1; cit != end; ++cit, ++ii) {
1504 InsetCommandParams p(INDEX_PRINT_CODE);
1505 p["type"] = cit->shortcut();
1506 string const data = InsetCommand::params2string(p);
1507 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cit->index()),
1508 FuncRequest(LFUN_INSET_MODIFY, data)));
1510 docstring const label =
1511 bformat(_("Index Entry (%1$s)"), cit->index());
1512 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1513 FuncRequest(LFUN_INSET_MODIFY,
1514 from_ascii("changetype ") + cit->shortcut())));
1520 void MenuDefinition::expandCiteStyles(BufferView const * bv)
1525 Inset const * inset = bv->cursor().nextInset();
1526 if (!inset || inset->lyxCode() != CITE_CODE) {
1527 add(MenuItem(MenuItem::Command,
1528 qt_("No Citation in Scope!"),
1529 FuncRequest(LFUN_NOACTION)));
1532 InsetCommand const * citinset =
1533 static_cast<InsetCommand const *>(inset);
1535 Buffer const * buf = &bv->buffer();
1536 string const cmd = citinset->params().getCmdName();
1538 docstring const & key = citinset->getParam("key");
1540 add(MenuItem(MenuItem::Command,
1541 qt_("No citations selected!"),
1542 FuncRequest(LFUN_NOACTION)));
1546 docstring const & before = citinset->getParam("before");
1547 docstring const & after = citinset->getParam("after");
1549 size_t const n = cmd.size();
1550 bool const force = cmd[0] == 'C';
1551 bool const full = cmd[n] == '*';
1553 vector<docstring> const keys = getVectorFromString(key);
1555 vector<CitationStyle> const citeStyleList = buf->params().citeStyles();
1556 static const size_t max_length = 40;
1557 vector<docstring> citeStrings =
1558 buf->masterBibInfo().getCiteStrings(keys, citeStyleList, bv->buffer(),
1559 before, after, from_utf8("dialog"), max_length);
1561 vector<docstring>::const_iterator cit = citeStrings.begin();
1562 vector<docstring>::const_iterator end = citeStrings.end();
1564 for (int ii = 1; cit != end; ++cit, ++ii) {
1565 docstring label = *cit;
1566 CitationStyle cs = citeStyleList[ii - 1];
1567 cs.forceUpperCase &= force;
1568 cs.fullAuthorList &= full;
1569 addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
1570 FuncRequest(LFUN_INSET_MODIFY,
1571 "changetype " + from_utf8(citationStyleToString(cs)))));
1576 void MenuDefinition::expandArguments(BufferView const * bv, bool switcharg)
1581 if (!bv->cursor().inTexted())
1584 Inset const * inset = &bv->cursor().inset();
1585 Layout::LaTeXArgMap args = bv->cursor().paragraph().layout().args();
1586 if (inset && args.empty())
1587 args = inset->getLayout().args();
1588 if (args.empty() || (switcharg && args.size() == 1))
1590 Layout::LaTeXArgMap::const_iterator lait = args.begin();
1591 Layout::LaTeXArgMap::const_iterator const laend = args.end();
1592 for (; lait != laend; ++lait) {
1593 Layout::latexarg arg = (*lait).second;
1594 docstring str = arg.menustring.empty()? arg.labelstring : arg.menustring;
1595 QString item = toqstr(translateIfPossible(str));
1597 add(MenuItem(MenuItem::Command, item,
1598 FuncRequest(LFUN_INSET_MODIFY,
1599 from_ascii("changetype ")
1600 + from_ascii((*lait).first))));
1602 add(MenuItem(MenuItem::Command, item,
1603 FuncRequest(LFUN_ARGUMENT_INSERT,
1604 from_ascii((*lait).first))));
1609 void MenuDefinition::expandCaptions(Buffer const * buf, bool switchcap)
1614 DocumentClass const & dc = buf->params().documentClass();
1615 vector< pair<docstring, FuncRequest> > caps;
1616 for (pair<docstring, InsetLayout> const & il : dc.insetLayouts()) {
1618 docstring const type = split(il.first, instype, ':');
1619 if (instype == "Caption") {
1620 // skip forbidden caption types
1621 FuncRequest const cmd = switchcap
1622 ? FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype ") + type)
1623 : FuncRequest(LFUN_CAPTION_INSERT, type);
1624 if (getStatus(cmd).enabled())
1625 caps.push_back(make_pair(type, cmd));
1629 if (caps.empty() || (switchcap && caps.size() == 1))
1631 if (caps.size() == 1) {
1632 add(MenuItem(MenuItem::Command, qt_("Caption"), caps.front().second));
1636 MenuDefinition captions;
1637 for (pair<docstring, FuncRequest> const & cap : caps) {
1638 docstring const type = cap.first;
1639 docstring const trtype = translateIfPossible(type);
1640 docstring const cmitem = bformat(_("Caption (%1$s)"), trtype);
1642 add(MenuItem(MenuItem::Command, toqstr(cmitem), cap.second));
1644 captions.add(MenuItem(MenuItem::Command, toqstr(trtype), cap.second));
1646 if (!captions.empty()) {
1647 MenuItem item(MenuItem::Submenu, qt_("Caption"));
1648 item.setSubmenu(captions);
1654 void MenuDefinition::expandQuotes(BufferView const * bv)
1659 if (!bv->cursor().inTexted())
1662 Inset const * inset = bv->cursor().nextInset();
1663 if (!inset || inset->lyxCode() != QUOTE_CODE) {
1664 add(MenuItem(MenuItem::Command,
1665 qt_("No Quote in Scope!"),
1666 FuncRequest(LFUN_NOACTION)));
1669 InsetQuotes const * qinset =
1670 static_cast<InsetQuotes const *>(inset);
1672 map<string, docstring> styles = quoteparams.getTypes();
1673 string const qtype = qinset->getType();
1675 map<string, docstring>::const_iterator qq = styles.begin();
1676 map<string, docstring>::const_iterator end = styles.end();
1693 InsetQuotesParams::QuoteStyle globalqs =
1694 bv->buffer().masterBuffer()->params().quotes_style;
1695 FuncRequest cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xld"));
1696 docstring desc = bformat(_("%1$stext (dynamic)"),
1697 docstring(1, quoteparams.getQuoteChar(globalqs,
1698 InsetQuotesParams::PrimaryQuotes,
1699 InsetQuotesParams::OpeningQuote)));
1700 if (prefixIs(qtype, "x"))
1701 add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1703 xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1704 cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xls"));
1705 desc = bformat(_("%1$stext (dynamic)"),
1706 docstring(1, quoteparams.getQuoteChar(globalqs,
1707 InsetQuotesParams::SecondaryQuotes,
1708 InsetQuotesParams::OpeningQuote)));
1709 if (prefixIs(qtype, "x"))
1710 add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1712 xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1713 cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xrd"));
1714 desc = bformat(_("text%1$s (dynamic)"),
1715 docstring(1, quoteparams.getQuoteChar(globalqs,
1716 InsetQuotesParams::PrimaryQuotes,
1717 InsetQuotesParams::ClosingQuote)));
1718 if (prefixIs(qtype, "x"))
1719 add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1721 xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1722 cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xrs"));
1723 desc = bformat(_("text%1$s (dynamic)"),
1724 docstring(1, quoteparams.getQuoteChar(globalqs,
1725 InsetQuotesParams::SecondaryQuotes,
1726 InsetQuotesParams::ClosingQuote)));
1727 if (prefixIs(qtype, "x"))
1728 add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1730 xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1732 for (; qq != end; ++qq) {
1733 docstring const style = from_ascii(qq->first);
1734 cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype ") + style);
1735 desc = contains(style, 'l') ?
1736 bformat(_("%1$stext"), qq->second) : bformat(_("text%1$s"), qq->second);
1737 if (prefixIs(style, qtype[0]))
1738 add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1739 else if (prefixIs(style, 'e') && !prefixIs(qtype, "e"))
1740 eqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1741 else if (prefixIs(style, 's') && !prefixIs(qtype, "s"))
1742 sqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1743 else if (prefixIs(style, 'g') && !prefixIs(qtype, "g"))
1744 gqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1745 else if (prefixIs(style, 'p') && !prefixIs(qtype, "p"))
1746 pqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1747 else if (prefixIs(style, 'c') && !prefixIs(qtype, "c"))
1748 cqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1749 else if (prefixIs(style, 'a') && !prefixIs(qtype, "a"))
1750 aqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1751 else if (prefixIs(style, 'q') && !prefixIs(qtype, "q"))
1752 qqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1753 else if (prefixIs(style, 'b') && !prefixIs(qtype, "b"))
1754 bqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1755 else if (prefixIs(style, 'w') && !prefixIs(qtype, "w"))
1756 wqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1757 else if (prefixIs(style, 'f') && !prefixIs(qtype, "f"))
1758 fqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1759 else if (prefixIs(style, 'i') && !prefixIs(qtype, "i"))
1760 iqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1761 else if (prefixIs(style, 'r') && !prefixIs(qtype, "r"))
1762 rqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1763 else if (prefixIs(style, 'j') && !prefixIs(qtype, "j"))
1764 jqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1765 else if (prefixIs(style, 'k') && !prefixIs(qtype, "k"))
1766 kqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
1770 MenuItem item(MenuItem::Submenu, qt_("Dynamic Quotation Marks"));
1771 item.setSubmenu(xqs);
1775 MenuItem item(MenuItem::Submenu,
1776 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::EnglishQuotes)));
1777 item.setSubmenu(eqs);
1781 MenuItem item(MenuItem::Submenu,
1782 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwedishQuotes)));
1783 item.setSubmenu(sqs);
1787 MenuItem item(MenuItem::Submenu,
1788 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::GermanQuotes)));
1789 item.setSubmenu(gqs);
1793 MenuItem item(MenuItem::Submenu,
1794 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::PolishQuotes)));
1795 item.setSubmenu(pqs);
1799 MenuItem item(MenuItem::Submenu,
1800 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwissQuotes)));
1801 item.setSubmenu(cqs);
1805 MenuItem item(MenuItem::Submenu,
1806 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::DanishQuotes)));
1807 item.setSubmenu(aqs);
1811 MenuItem item(MenuItem::Submenu,
1812 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::PlainQuotes)));
1813 item.setSubmenu(qqs);
1817 MenuItem item(MenuItem::Submenu,
1818 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::BritishQuotes)));
1819 item.setSubmenu(bqs);
1823 MenuItem item(MenuItem::Submenu,
1824 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwedishGQuotes)));
1825 item.setSubmenu(wqs);
1829 MenuItem item(MenuItem::Submenu,
1830 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::FrenchQuotes)));
1831 item.setSubmenu(fqs);
1835 MenuItem item(MenuItem::Submenu,
1836 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::FrenchINQuotes)));
1837 item.setSubmenu(iqs);
1841 MenuItem item(MenuItem::Submenu,
1842 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::RussianQuotes)));
1843 item.setSubmenu(rqs);
1847 MenuItem item(MenuItem::Submenu,
1848 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::CJKQuotes)));
1849 item.setSubmenu(jqs);
1853 MenuItem item(MenuItem::Submenu,
1854 toqstr(quoteparams.getGuiLabel(InsetQuotesParams::CJKAngleQuotes)));
1855 item.setSubmenu(kqs);
1861 void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv)
1865 Text const * text = bv->cursor().text();
1866 // no paragraphs and no separators exist in math
1870 pit_type pit = bv->cursor().selBegin().pit();
1871 Paragraph const & par = text->getPar(pit);
1872 docstring const curlayout = par.layout().name();
1873 docstring outerlayout;
1874 depth_type current_depth = par.params().depth();
1875 // check if we have an environment in our nesting hierarchy
1876 Paragraph cpar = par;
1878 if (pit == 0 || cpar.params().depth() == 0)
1881 cpar = text->getPar(pit);
1882 if (cpar.params().depth() < current_depth
1883 && cpar.layout().isEnvironment()) {
1884 outerlayout = cpar.layout().name();
1885 current_depth = cpar.params().depth();
1888 if (par.layout().isEnvironment()) {
1889 docstring const label =
1890 bformat(_("Start New Environment (%1$s)"),
1891 translateIfPossible(curlayout));
1892 add(MenuItem(MenuItem::Command, toqstr(label),
1893 FuncRequest(LFUN_ENVIRONMENT_SPLIT)));
1895 if (!outerlayout.empty()) {
1896 docstring const label =
1897 bformat(_("Start New Parent Environment (%1$s)"),
1898 translateIfPossible(outerlayout));
1899 add(MenuItem(MenuItem::Command, toqstr(label),
1900 FuncRequest(LFUN_ENVIRONMENT_SPLIT,
1901 from_ascii("outer"))));
1908 /////////////////////////////////////////////////////////////////////
1909 // Menu::Impl definition and implementation
1910 /////////////////////////////////////////////////////////////////////
1914 /// populates the menu or one of its submenu
1915 /// This is used as a recursive function
1916 void populate(QMenu * qMenu, MenuDefinition const & menu);
1918 /// Only needed for top level menus.
1919 MenuDefinition * top_level_menu;
1922 /// the name of this menu
1928 /// Get a MenuDefinition item label from the menu backend
1929 static QString label(MenuItem const & mi)
1931 QString label = mi.label();
1932 label.replace("&", "&&");
1934 QString shortcut = mi.shortcut();
1935 if (!shortcut.isEmpty()) {
1936 int pos = label.indexOf(shortcut);
1938 //label.insert(pos, 1, char_type('&'));
1939 label.replace(pos, 0, "&");
1942 QString const binding = mi.binding();
1943 if (!binding.isEmpty())
1944 label += '\t' + binding;
1949 void Menu::Impl::populate(QMenu * qMenu, MenuDefinition const & menu)
1951 LYXERR(Debug::GUI, "populating menu " << menu.name());
1953 LYXERR(Debug::GUI, "\tERROR: empty menu " << menu.name());
1956 LYXERR(Debug::GUI, " ***** menu entries " << menu.size());
1957 for (MenuItem const & m : menu)
1959 case MenuItem::Separator:
1960 qMenu->addSeparator();
1962 case MenuItem::Submenu: {
1963 QMenu * subMenu = qMenu->addMenu(label(m));
1964 populate(subMenu, m.submenu());
1965 subMenu->setEnabled(!subMenu->isEmpty());
1968 case MenuItem::Command:
1970 // FIXME: A previous comment assured that MenuItem::Command was the
1971 // only possible case in practice, but this is wrong. It would be
1972 // good to document which cases are actually treated here.
1973 qMenu->addAction(new Action(m.func(), QIcon(), label(m),
1974 m.tooltip(), qMenu));
1979 #if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && (QT_VERSION >= 0x040600)
1980 class AlwaysMnemonicStyle : public QProxyStyle {
1982 int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
1983 QStyleHintReturn *returnData = 0) const
1985 if (hint == QStyle::SH_UnderlineShortcut)
1987 return QProxyStyle::styleHint(hint, opt, widget, returnData);
1992 /////////////////////////////////////////////////////////////////////
1993 // Menu implementation
1994 /////////////////////////////////////////////////////////////////////
1996 Menu::Menu(GuiView * gv, QString const & name, bool top_level, bool keyboard)
1997 : QMenu(gv), d(new Menu::Impl)
1999 #if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && (QT_VERSION >= 0x040600)
2001 setStyle(new AlwaysMnemonicStyle);
2005 d->top_level_menu = top_level? new MenuDefinition : 0;
2009 if (d->top_level_menu)
2010 connect(this, SIGNAL(aboutToShow()), this, SLOT(updateView()));
2016 delete d->top_level_menu;
2021 void Menu::updateView()
2023 guiApp->menus().updateMenu(this);
2029 QList<QAction *> items = actions();
2030 for (int i = 0; i != items.size(); ++i) {
2031 // QAction::menu() returns 0 if there's no submenu.
2032 delete items.at(i)->menu();
2038 /////////////////////////////////////////////////////////////////////
2039 // Menus::Impl definition and implementation
2040 /////////////////////////////////////////////////////////////////////
2042 struct Menus::Impl {
2044 bool hasMenu(QString const &) const;
2046 MenuDefinition & getMenu(QString const &);
2048 MenuDefinition const & getMenu(QString const &) const;
2050 /// Expands some special entries of the menu
2051 /** The entries with the following kind are expanded to a
2052 sequence of Command MenuItems: Lastfiles, Documents,
2053 ViewFormats, ExportFormats, UpdateFormats, Branches,
2054 Indices, Arguments, SwitchArguments, Captions, SwitchCaptions,
2055 EnvironmentSeparators
2057 void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
2058 BufferView const *) const;
2060 /// Initialize specific MACOS X menubar
2061 void macxMenuBarInit(QMenuBar * qmb);
2063 /// Mac special menu.
2064 /** This defines a menu whose entries list the FuncRequests
2065 that will be removed by expand() in other menus. This is
2066 used by the Qt/Mac code.
2068 NOTE: Qt does not remove the menu items when clearing a QMenuBar,
2069 such that the items will keep accessing the FuncRequests in
2070 the MenuDefinition. While Menus::Impl might be recreated,
2071 we keep mac_special_menu_ in memory by making it static.
2073 static MenuDefinition mac_special_menu_;
2078 MenuDefinition menubar_;
2080 typedef QMap<GuiView *, QHash<QString, Menu*> > NameMap;
2082 /// name to menu for \c menu() method.
2087 MenuDefinition Menus::Impl::mac_special_menu_;
2091 Here is what the Qt documentation says about how a menubar is chosen:
2093 1) If the window has a QMenuBar then it is used. 2) If the window
2094 is a modal then its menubar is used. If no menubar is specified
2095 then a default menubar is used (as documented below) 3) If the
2096 window has no parent then the default menubar is used (as
2099 The above 3 steps are applied all the way up the parent window
2100 chain until one of the above are satisifed. If all else fails a
2101 default menubar will be created, the default menubar on Qt/Mac is
2102 an empty menubar, however you can create a different default
2103 menubar by creating a parentless QMenuBar, the first one created
2104 will thus be designated the default menubar, and will be used
2105 whenever a default menubar is needed.
2107 Thus, for Qt/Mac, we add the menus to a free standing menubar, so
2108 that this menubar will be used also when one of LyX' dialogs has
2111 void Menus::Impl::macxMenuBarInit(QMenuBar * qmb)
2113 /* Since Qt 4.2, the qt/mac menu code has special code for
2114 specifying the role of a menu entry. However, it does not
2115 work very well with our scheme of creating menus on demand,
2116 and therefore we need to put these entries in a special
2117 invisible menu. (JMarc)
2120 /* The entries of our special mac menu. If we add support for
2121 * special entries in Menus, we could imagine something
2123 * SpecialItem About " "About LyX" "dialog-show aboutlyx"
2124 * and therefore avoid hardcoding. I am not sure it is worth
2125 * the hassle, though. (JMarc)
2127 struct MacMenuEntry {
2131 QAction::MenuRole role;
2134 static const MacMenuEntry entries[] = {
2135 {LFUN_DIALOG_SHOW, "aboutlyx", "About LyX",
2136 QAction::AboutRole},
2137 {LFUN_DIALOG_SHOW, "prefs", "Preferences",
2138 QAction::PreferencesRole},
2139 #if !(defined(QT_MAC_USE_COCOA) || (QT_VERSION >= 0x050000))
2140 /* This doesn't work with Cocoa. */
2141 {LFUN_RECONFIGURE, "", "Reconfigure",
2142 QAction::ApplicationSpecificRole},
2144 {LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole}
2146 const size_t num_entries = sizeof(entries) / sizeof(entries[0]);
2147 const bool first_call = mac_special_menu_.empty();
2149 LYXERR(Debug::GUI, "Creating Mac OS X special menu bar");
2150 // the special menu for Menus. Fill it up only once.
2152 for (size_t i = 0 ; i < num_entries ; ++i) {
2153 FuncRequest const func(entries[i].action,
2154 from_utf8(entries[i].arg));
2155 mac_special_menu_.add(MenuItem(MenuItem::Command,
2156 entries[i].label, func));
2160 // add the entries to a QMenu that will eventually be empty
2161 // and therefore invisible.
2162 QMenu * qMenu = qmb->addMenu("special");
2164 for (MenuItem const & m : mac_special_menu_) {
2165 Action * action = new Action(m.func(), QIcon(), m.label(),
2167 action->setMenuRole(entries[i].role);
2168 qMenu->addAction(action);
2174 void Menus::Impl::expand(MenuDefinition const & frommenu,
2175 MenuDefinition & tomenu, BufferView const * bv) const
2177 if (!tomenu.empty())
2180 for (MenuDefinition::const_iterator cit = frommenu.begin();
2181 cit != frommenu.end() ; ++cit) {
2182 Buffer const * buf = bv ? &bv->buffer() : 0;
2183 switch (cit->kind()) {
2184 case MenuItem::Lastfiles:
2185 tomenu.expandLastfiles();
2188 case MenuItem::Documents:
2189 tomenu.expandDocuments();
2192 case MenuItem::Bookmarks:
2193 tomenu.expandBookmarks();
2196 case MenuItem::ImportFormats:
2197 case MenuItem::ViewFormats:
2198 case MenuItem::UpdateFormats:
2199 case MenuItem::ExportFormats:
2200 tomenu.expandFormats(cit->kind(), buf);
2203 case MenuItem::CharStyles:
2204 tomenu.expandFlexInsert(buf, InsetLayout::CHARSTYLE);
2207 case MenuItem::Custom:
2208 tomenu.expandFlexInsert(buf, InsetLayout::CUSTOM);
2211 case MenuItem::Elements:
2212 tomenu.expandFlexInsert(buf, InsetLayout::ELEMENT);
2215 case MenuItem::FloatListInsert:
2216 tomenu.expandFloatListInsert(buf);
2219 case MenuItem::FloatInsert:
2220 tomenu.expandFloatInsert(buf);
2223 case MenuItem::PasteRecent:
2224 tomenu.expandPasteRecent(buf);
2227 case MenuItem::Toolbars:
2228 tomenu.expandToolbars();
2231 case MenuItem::Branches:
2232 tomenu.expandBranches(buf);
2235 case MenuItem::Indices:
2236 tomenu.expandIndices(buf);
2239 case MenuItem::IndicesContext:
2240 tomenu.expandIndicesContext(buf);
2243 case MenuItem::IndicesLists:
2244 tomenu.expandIndices(buf, true);
2247 case MenuItem::IndicesListsContext:
2248 tomenu.expandIndicesContext(buf, true);
2251 case MenuItem::CiteStyles:
2252 tomenu.expandCiteStyles(bv);
2256 tomenu.expandToc(buf);
2259 case MenuItem::GraphicsGroups:
2260 tomenu.expandGraphicsGroups(bv);
2263 case MenuItem::SpellingSuggestions:
2264 tomenu.expandSpellingSuggestions(bv);
2267 case MenuItem::LanguageSelector:
2268 tomenu.expandLanguageSelector(buf);
2271 case MenuItem::Arguments:
2272 tomenu.expandArguments(bv, false);
2275 case MenuItem::SwitchArguments:
2276 tomenu.expandArguments(bv, true);
2279 case MenuItem::Captions:
2280 tomenu.expandCaptions(buf, false);
2283 case MenuItem::SwitchCaptions:
2284 tomenu.expandCaptions(buf, true);
2287 case MenuItem::EnvironmentSeparators:
2288 tomenu.expandEnvironmentSeparators(bv);
2291 case MenuItem::SwitchQuotes:
2292 tomenu.expandQuotes(bv);
2295 case MenuItem::Submenu: {
2296 MenuItem item(*cit);
2297 item.setSubmenu(MenuDefinition(cit->submenuname()));
2298 expand(getMenu(cit->submenuname()), item.submenu(), bv);
2299 tomenu.addWithStatusCheck(item);
2303 case MenuItem::Info:
2304 case MenuItem::Help:
2305 case MenuItem::Separator:
2306 tomenu.addWithStatusCheck(*cit);
2309 case MenuItem::Command:
2310 if (!mac_special_menu_.hasFunc(*cit->func()))
2311 tomenu.addWithStatusCheck(*cit);
2315 // we do not want the menu to end with a separator
2316 if (!tomenu.empty() && tomenu.items_.back().kind() == MenuItem::Separator)
2317 tomenu.items_.pop_back();
2319 // Check whether the shortcuts are unique
2320 tomenu.checkShortcuts();
2324 bool Menus::Impl::hasMenu(QString const & name) const
2326 return find_if(menulist_.begin(), menulist_.end(),
2327 MenuNamesEqual(name)) != menulist_.end();
2331 MenuDefinition const & Menus::Impl::getMenu(QString const & name) const
2333 const_iterator cit = find_if(menulist_.begin(), menulist_.end(),
2334 MenuNamesEqual(name));
2335 if (cit == menulist_.end()) {
2336 LYXERR0("No submenu named " << name);
2337 LASSERT(false, { static const MenuDefinition m; return m; });
2343 MenuDefinition & Menus::Impl::getMenu(QString const & name)
2345 iterator it = find_if(menulist_.begin(), menulist_.end(),
2346 MenuNamesEqual(name));
2347 if (it == menulist_.end()) {
2348 LYXERR0("No submenu named " << name);
2349 LASSERT(false, { static MenuDefinition m; return m; });
2355 /////////////////////////////////////////////////////////////////////
2359 /////////////////////////////////////////////////////////////////////
2361 Menus::Menus() : d(new Impl) {}
2377 void Menus::read(Lexer & lex)
2385 LexerKeyword menutags[] = {
2386 { "end", md_endmenuset },
2387 { "menu", md_menu },
2388 { "menubar", md_menubar }
2391 // consistency check
2392 if (compare_ascii_no_case(lex.getString(), "menuset"))
2393 LYXERR0("Menus::read: ERROR wrong token: `" << lex.getString() << '\'');
2395 lex.pushTable(menutags);
2396 lex.setContext("Menus::read");
2400 while (lex.isOK() && !quit) {
2401 switch (lex.lex()) {
2403 d->menubar_.read(lex);
2407 QString const name = toqstr(lex.getDocString());
2408 if (d->hasMenu(name))
2409 d->getMenu(name).read(lex);
2411 MenuDefinition menu(name);
2413 d->menulist_.push_back(menu);
2421 lex.printError("Unknown menu tag");
2429 bool Menus::searchMenu(FuncRequest const & func,
2430 docstring_list & names) const
2432 MenuDefinition menu;
2433 d->expand(d->menubar_, menu, 0);
2434 return menu.searchMenu(func, names);
2438 void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial)
2442 // setup special mac specific menu items, but only do this
2443 // the first time a QMenuBar is created. Otherwise Qt will
2444 // create duplicate items in the application menu. It seems
2445 // that Qt does not remove them when the QMenubar is cleared.
2446 d->macxMenuBarInit(qmb);
2449 // Clear all menubar contents before filling it.
2451 #if (QT_VERSION >= 0x050000 && defined(Q_OS_MAC))
2452 d->macxMenuBarInit(qmb);
2456 LYXERR(Debug::GUI, "populating menu bar" << d->menubar_.name());
2458 if (d->menubar_.empty()) {
2459 LYXERR(Debug::GUI, "\tERROR: empty menu bar"
2460 << d->menubar_.name());
2463 LYXERR(Debug::GUI, "menu bar entries " << d->menubar_.size());
2465 MenuDefinition menu;
2466 BufferView * bv = 0;
2468 bv = view->currentBufferView();
2469 d->expand(d->menubar_, menu, bv);
2471 MenuDefinition::const_iterator m = menu.begin();
2472 MenuDefinition::const_iterator end = menu.end();
2474 for (; m != end; ++m) {
2476 if (m->kind() != MenuItem::Submenu) {
2477 LYXERR(Debug::GUI, "\tERROR: not a submenu " << m->label());
2481 LYXERR(Debug::GUI, "menu bar item " << m->label()
2482 << " is a submenu named " << m->submenuname());
2484 QString name = m->submenuname();
2485 if (!d->hasMenu(name)) {
2486 LYXERR(Debug::GUI, "\tERROR: " << name
2487 << " submenu has no menu!");
2491 Menu * menu = new Menu(view, m->submenuname(), true);
2492 menu->setTitle(label(*m));
2494 #if defined(Q_OS_MAC) && (defined(QT_MAC_USE_COCOA) || (QT_VERSION >= 0x050000))
2495 // On Mac OS with QT/cocoa, the menu is not displayed if there is no action
2496 // so we create a temporary one here
2497 QAction * action = new QAction(menu);
2498 menu->addAction(action);
2503 d->name_map_[view][name] = menu;
2508 void Menus::updateMenu(Menu * qmenu)
2510 LYXERR(Debug::GUI, "Triggered menu: " << qmenu->d->name);
2513 if (qmenu->d->name.isEmpty())
2516 docstring identifier = qstring_to_ucs4(qmenu->d->name);
2517 MenuDefinition fromLyxMenu(qmenu->d->name);
2518 while (!identifier.empty()) {
2519 docstring menu_name;
2520 identifier = split(identifier, menu_name, ';');
2522 if (!d->hasMenu(toqstr(menu_name))) {
2523 LYXERR(Debug::GUI, "\tWARNING: non existing menu: "
2528 MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
2529 //FIXME: 50 is a wild guess. We should take into account here
2530 //the expansion of menu items, disabled optional items etc.
2531 bool const in_sub_menu = !fromLyxMenu.empty()
2532 && fromLyxMenu.size() + cat_menu.size() > 50 ;
2534 fromLyxMenu.catSub(menu_name);
2536 fromLyxMenu.cat(cat_menu);
2537 fromLyxMenu.add(MenuItem(MenuItem::Separator));
2540 if (fromLyxMenu.empty()) {
2541 qmenu->addAction(qt_("No Action Defined!"));
2545 BufferView * bv = 0;
2547 bv = qmenu->d->view->currentBufferView();
2548 d->expand(fromLyxMenu, *qmenu->d->top_level_menu, bv);
2549 qmenu->d->populate(qmenu, *qmenu->d->top_level_menu);
2553 Menu * Menus::menu(QString const & name, GuiView & view, bool keyboard)
2555 LYXERR(Debug::GUI, "Context menu requested: " << name);
2556 Menu * menu = d->name_map_[&view].value(name, 0);
2557 if (!menu && !name.startsWith("context-")) {
2558 LYXERR0("requested context menu not found: " << name);
2562 menu = new Menu(&view, name, true, keyboard);
2563 d->name_map_[&view][name] = menu;
2567 } // namespace frontend
2570 #include "moc_Menus.cpp"