mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 16:50:39 +00:00
branch: Fix bug #5414: Show context menu accelerators when the context menu is shown after pressing the keyboard context menu key.
This should have been done by qt, but we can override qt by adapting the style on the windows platform. see r37678. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@37686 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8fd648afa9
commit
e2e87c6756
@ -652,7 +652,11 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
|
||||
QAbstractScrollArea::contextMenuEvent(e);
|
||||
return;
|
||||
}
|
||||
QMenu * menu = guiApp->menus().menu(toqstr(name), *lyx_view_);
|
||||
|
||||
// always show mnemonics when the keyboard is used to show the context menu
|
||||
// FIXME: This should be fixed in Qt itself
|
||||
bool const keyboard = (e->reason() == QContextMenuEvent::Keyboard);
|
||||
QMenu * menu = guiApp->menus().menu(toqstr(name), *lyx_view_, keyboard);
|
||||
if (!menu) {
|
||||
QAbstractScrollArea::contextMenuEvent(e);
|
||||
return;
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QMenuBar>
|
||||
#include <QProxyStyle>
|
||||
#include <QString>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@ -1223,13 +1224,35 @@ void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
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)
|
||||
{
|
||||
#ifdef Q_WS_WIN
|
||||
if (keyboard)
|
||||
setStyle(new AlwaysMnemonicStyle);
|
||||
#else
|
||||
(void) keyboard;
|
||||
#endif
|
||||
|
||||
d->top_level_menu = top_level? new MenuDefinition : 0;
|
||||
d->view = gv;
|
||||
d->name = name;
|
||||
@ -1680,7 +1703,7 @@ void Menus::updateMenu(Menu * qmenu)
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -1689,7 +1712,7 @@ Menu * Menus::menu(QString const & name, GuiView & view)
|
||||
return 0;
|
||||
}
|
||||
|
||||
menu = new Menu(&view, name, true);
|
||||
menu = new Menu(&view, name, true, keyboard);
|
||||
d->name_map_[&view][name] = menu;
|
||||
return menu;
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ class Menu : public QMenu
|
||||
Q_OBJECT
|
||||
public:
|
||||
///
|
||||
Menu(GuiView * gv, QString const & name, bool top_level);
|
||||
Menu(GuiView * gv, QString const & name, bool top_level,
|
||||
bool keyboard = false);
|
||||
|
||||
///
|
||||
~Menu();
|
||||
@ -70,7 +71,7 @@ public:
|
||||
void fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial = false);
|
||||
|
||||
/// \return a top-level submenu given its name.
|
||||
Menu * menu(QString const & name, GuiView & view);
|
||||
Menu * menu(QString const & name, GuiView & view, bool keyboard = false);
|
||||
|
||||
///
|
||||
void read(Lexer &);
|
||||
|
@ -32,6 +32,9 @@ What's new
|
||||
- Fix a crash when loading a document with instant previewed math that
|
||||
could not succesfully be previewed (bug 7263).
|
||||
|
||||
- Show mnemonics in context menus that are requested by the keyboard
|
||||
key (only Windows; bug 5414).
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user