mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Smarter menu length calculation
It is possible I have missed some shortcut conflicts, so please report if you find any.
This commit is contained in:
parent
8850b68792
commit
f3a4602c4c
@ -234,10 +234,10 @@ Menuset
|
|||||||
Menu "context-note"
|
Menu "context-note"
|
||||||
Item "LyX Note|N" "inset-modify note Note Note"
|
Item "LyX Note|N" "inset-modify note Note Note"
|
||||||
Item "Comment|m" "inset-modify note Note Comment"
|
Item "Comment|m" "inset-modify note Note Comment"
|
||||||
Item "Greyed Out|G" "inset-modify note Note Greyedout"
|
Item "Greyed Out|y" "inset-modify note Note Greyedout"
|
||||||
Separator
|
Separator
|
||||||
Item "Open All Notes|A" "inset-forall Note inset-toggle open"
|
Item "Open All Notes|A" "inset-forall Note inset-toggle open"
|
||||||
Item "Close All Notes|l" "inset-forall Note inset-toggle close"
|
Item "Close All Notes|o" "inset-forall Note inset-toggle close"
|
||||||
End
|
End
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -383,7 +383,7 @@ Menuset
|
|||||||
Item "Jump Back to Saved Bookmark|B" "bookmark-goto 0"
|
Item "Jump Back to Saved Bookmark|B" "bookmark-goto 0"
|
||||||
OptItem "Forward Search|F" "forward-search"
|
OptItem "Forward Search|F" "forward-search"
|
||||||
Separator
|
Separator
|
||||||
Item "Move Paragraph Up|o" "paragraph-move-up"
|
Item "Move Paragraph Up|h" "paragraph-move-up"
|
||||||
Item "Move Paragraph Down|v" "paragraph-move-down"
|
Item "Move Paragraph Down|v" "paragraph-move-down"
|
||||||
Separator
|
Separator
|
||||||
EnvironmentSeparatorsContext
|
EnvironmentSeparatorsContext
|
||||||
|
@ -117,7 +117,7 @@ Menuset
|
|||||||
Item "Find & Replace (Quick)...|F" "dialog-show findreplace"
|
Item "Find & Replace (Quick)...|F" "dialog-show findreplace"
|
||||||
Item "Find & Replace (Advanced)..." "dialog-show findreplaceadv"
|
Item "Find & Replace (Advanced)..." "dialog-show findreplaceadv"
|
||||||
Separator
|
Separator
|
||||||
Item "Move Paragraph Up|o" "paragraph-move-up"
|
Item "Move Paragraph Up|h" "paragraph-move-up"
|
||||||
Item "Move Paragraph Down|v" "paragraph-move-down"
|
Item "Move Paragraph Down|v" "paragraph-move-down"
|
||||||
Separator
|
Separator
|
||||||
Item "Paragraph Settings...|P" "layout-paragraph"
|
Item "Paragraph Settings...|P" "layout-paragraph"
|
||||||
@ -545,7 +545,7 @@ Menuset
|
|||||||
Menu "insert_note"
|
Menu "insert_note"
|
||||||
Item "LyX Note|N" "note-insert Note"
|
Item "LyX Note|N" "note-insert Note"
|
||||||
Item "Comment|C" "note-insert Comment"
|
Item "Comment|C" "note-insert Comment"
|
||||||
Item "Greyed Out|G" "note-insert Greyedout"
|
Item "Greyed Out|y" "note-insert Greyedout"
|
||||||
End
|
End
|
||||||
|
|
||||||
Menu "insert_branches"
|
Menu "insert_branches"
|
||||||
|
@ -342,6 +342,8 @@ public:
|
|||||||
const;
|
const;
|
||||||
///
|
///
|
||||||
bool hasFunc(FuncRequest const &) const;
|
bool hasFunc(FuncRequest const &) const;
|
||||||
|
/// The real size of the menu considering hidden entries
|
||||||
|
int realSize() const;
|
||||||
/// Add the menu item unconditionally
|
/// Add the menu item unconditionally
|
||||||
void add(MenuItem const & item) { items_.push_back(item); }
|
void add(MenuItem const & item) { items_.push_back(item); }
|
||||||
/// Checks the associated FuncRequest status before adding the
|
/// Checks the associated FuncRequest status before adding the
|
||||||
@ -727,6 +729,23 @@ bool MenuDefinition::hasFunc(FuncRequest const & func) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int MenuDefinition::realSize() const
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
for (auto const & it : *this) {
|
||||||
|
if (it.kind() == MenuItem::Submenu)
|
||||||
|
++res;
|
||||||
|
else if (it.kind() == MenuItem::Command) {
|
||||||
|
FuncStatus status = lyx::getStatus(*it.func());
|
||||||
|
// count only items that are actually displayed
|
||||||
|
if (!status.unknown() && (status.enabled() || !it.optional()))
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MenuDefinition::catSub(docstring const & name)
|
void MenuDefinition::catSub(docstring const & name)
|
||||||
{
|
{
|
||||||
add(MenuItem(MenuItem::Submenu,
|
add(MenuItem(MenuItem::Submenu,
|
||||||
@ -867,13 +886,13 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
|
|||||||
if (i > 0)
|
if (i > 0)
|
||||||
add(MenuItem(MenuItem::Separator));
|
add(MenuItem(MenuItem::Separator));
|
||||||
docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
|
docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
|
||||||
add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|n"),
|
add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|r"),
|
||||||
FuncRequest(LFUN_SPELLING_ADD, arg)));
|
FuncRequest(LFUN_SPELLING_ADD, arg)));
|
||||||
add(MenuItem(MenuItem::Command, qt_("Ignore this occurrence|g"),
|
add(MenuItem(MenuItem::Command, qt_("Ignore this occurrence|g"),
|
||||||
FuncRequest(LFUN_FONT_NO_SPELLCHECK, arg)));
|
FuncRequest(LFUN_FONT_NO_SPELLCHECK, arg)));
|
||||||
add(MenuItem(MenuItem::Command, qt_("Ignore all for this session|I"),
|
add(MenuItem(MenuItem::Command, qt_("Ignore all for this session|l"),
|
||||||
FuncRequest(LFUN_SPELLING_IGNORE, arg)));
|
FuncRequest(LFUN_SPELLING_IGNORE, arg)));
|
||||||
add(MenuItem(MenuItem::Command, qt_("Ignore all in this document|d"),
|
add(MenuItem(MenuItem::Command, qt_("Ignore all in this document|u"),
|
||||||
FuncRequest(LFUN_SPELLING_ADD_LOCAL, arg)));
|
FuncRequest(LFUN_SPELLING_ADD_LOCAL, arg)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -918,7 +937,7 @@ void MenuDefinition::expandLanguageSelector(Buffer const * buf)
|
|||||||
buf->masterBuffer()->getLanguages();
|
buf->masterBuffer()->getLanguages();
|
||||||
|
|
||||||
if (languages_buffer.size() < 2) {
|
if (languages_buffer.size() < 2) {
|
||||||
add(MenuItem(MenuItem::Command, qt_("Switch Language...|L"),
|
add(MenuItem(MenuItem::Command, qt_("Switch Language...|w"),
|
||||||
FuncRequest(LFUN_DIALOG_SHOW, "character")));
|
FuncRequest(LFUN_DIALOG_SHOW, "character")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2707,6 +2726,9 @@ void Menus::updateMenu(Menu * qmenu)
|
|||||||
|
|
||||||
docstring identifier = qstring_to_ucs4(qmenu->d->name);
|
docstring identifier = qstring_to_ucs4(qmenu->d->name);
|
||||||
MenuDefinition fromLyxMenu(qmenu->d->name);
|
MenuDefinition fromLyxMenu(qmenu->d->name);
|
||||||
|
BufferView * bv = 0;
|
||||||
|
if (qmenu->d->view)
|
||||||
|
bv = qmenu->d->view->currentBufferView();
|
||||||
while (!identifier.empty()) {
|
while (!identifier.empty()) {
|
||||||
docstring menu_name;
|
docstring menu_name;
|
||||||
identifier = split(identifier, menu_name, ';');
|
identifier = split(identifier, menu_name, ';');
|
||||||
@ -2718,10 +2740,14 @@ void Menus::updateMenu(Menu * qmenu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
|
MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
|
||||||
//FIXME: 50 is a wild guess. We should take into account here
|
// We take into account here the expansion of menu items,
|
||||||
//the expansion of menu items, disabled optional items etc.
|
// disabled optional items etc.
|
||||||
|
MenuDefinition to_menu;
|
||||||
|
d->expand(fromLyxMenu, to_menu, bv);
|
||||||
|
MenuDefinition to_cat_menu;
|
||||||
|
d->expand(cat_menu, to_cat_menu, bv);
|
||||||
bool const in_sub_menu = !fromLyxMenu.empty()
|
bool const in_sub_menu = !fromLyxMenu.empty()
|
||||||
&& fromLyxMenu.size() + cat_menu.size() > 50 ;
|
&& to_menu.realSize() + to_cat_menu.realSize() > 50;
|
||||||
if (in_sub_menu)
|
if (in_sub_menu)
|
||||||
fromLyxMenu.catSub(menu_name);
|
fromLyxMenu.catSub(menu_name);
|
||||||
else
|
else
|
||||||
@ -2734,9 +2760,6 @@ void Menus::updateMenu(Menu * qmenu)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferView * bv = 0;
|
|
||||||
if (qmenu->d->view)
|
|
||||||
bv = qmenu->d->view->currentBufferView();
|
|
||||||
d->expand(fromLyxMenu, *qmenu->d->top_level_menu, bv);
|
d->expand(fromLyxMenu, *qmenu->d->top_level_menu, bv);
|
||||||
qmenu->d->populate(qmenu, *qmenu->d->top_level_menu);
|
qmenu->d->populate(qmenu, *qmenu->d->top_level_menu);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user