#include <QList>
#include <QMenuBar>
#include <QString>
+#if QT_VERSION >= 0x040600
+#include <QProxyStyle>
+#endif
#include "support/shared_ptr.h"
const_iterator end() const { return items_.end(); }
///
void cat(MenuDefinition const & other);
+ ///
+ void catSub(docstring const & name);
// search for func in this menu iteratively, and put menu
// names in a stack.
}
+void MenuDefinition::catSub(docstring const & name)
+{
+ add(MenuItem(MenuItem::Submenu,
+ qt_("More...|M"), toqstr(name), QString(), false));
+}
+
void MenuDefinition::cat(MenuDefinition const & other)
{
const_iterator et = other.end();
{
if (!bv)
return;
+ Cursor const & cur = bv->cursor();
+ if (!cur.inTexted())
+ return;
WordLangTuple wl;
docstring_list suggestions;
- Cursor const & cur = bv->cursor();
Paragraph const & par = cur.paragraph();
pos_type from = cur.pos();
pos_type to = from;
continue;
}
case MenuItem::ExportFormats:
- if (!(*fit)->documentFormat())
+ if (!(*fit)->inExportMenu())
continue;
break;
default:
}
}
+#if defined(Q_WS_WIN) && (QT_VERSION >= 0x040600)
+class AlwaysMnemonicStyle : public QProxyStyle {
+public:
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 1;
+ return QProxyStyle::styleHint(hint, opt, widget, returnData);
+ }
+};
+#endif
+
/////////////////////////////////////////////////////////////////////
// Menu implementation
/////////////////////////////////////////////////////////////////////
-Menu::Menu(GuiView * gv, QString const & name, bool top_level)
+Menu::Menu(GuiView * gv, QString const & name, bool top_level, bool keyboard)
: QMenu(gv), d(new Menu::Impl)
{
+#if defined(Q_WS_WIN) && (QT_VERSION >= 0x040600)
+ if (keyboard)
+ setStyle(new AlwaysMnemonicStyle);
+#else
+ (void) keyboard;
+#endif
d->top_level_menu = top_level? new MenuDefinition : 0;
d->view = gv;
d->name = name;
setTitle(name);
if (d->top_level_menu)
- connect(this, SIGNAL(aboutToShow()), this, SLOT(updateView()));
+ connect(this, SIGNAL(aboutToShow()), this, SLOT(updateView()));
}
continue;
}
- fromLyxMenu.cat(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
+ //the expansion of menu items, disabled optional items etc.
+ bool const in_sub_menu = fromLyxMenu.size() > 0
+ && fromLyxMenu.size() + cat_menu.size() > 50 ;
+ if (in_sub_menu)
+ fromLyxMenu.catSub(menu_name);
+ else
+ fromLyxMenu.cat(cat_menu);
fromLyxMenu.add(MenuItem(MenuItem::Separator));
}
}
-Menu * Menus::menu(QString const & name, GuiView & view)
+Menu * Menus::menu(QString const & name, GuiView & view, bool keyboard)
{
LYXERR(Debug::GUI, "Context menu requested: " << name);
Menu * menu = d->name_map_[&view].value(name, 0);
return 0;
}
- menu = new Menu(&view, name, true);
+ menu = new Menu(&view, name, true, keyboard);
d->name_map_[&view][name] = menu;
return menu;
}