mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
ShortcutWidget: override shortcuts in the way they are meant to be (#10075)
I would say "by the books" but the documentation was not really clear. Problems with the logic of the previous implementation were exposed in Qt 5.6 by commit <https://codereview.qt-project.org/125142>. <http://mid.gmane.org/20160510070413.wzjpk4w4turnx6pr@cotopaxi> Note that ShortcutOverride events are used elsewhere in the code where they may need to be corrected in the same way.
This commit is contained in:
parent
0f3dbc472f
commit
a645d7f4e5
@ -45,7 +45,6 @@ namespace frontend {
|
||||
ShortcutWidget::ShortcutWidget(QWidget * parent)
|
||||
: QLabel(parent), keysequence_()
|
||||
{
|
||||
QApplication::instance()->installEventFilter(this);
|
||||
has_cursor_ = false;
|
||||
setFrameShape(QFrame::Panel);
|
||||
setFrameShadow(QFrame::Raised);
|
||||
@ -62,24 +61,6 @@ void ShortcutWidget::reset()
|
||||
}
|
||||
|
||||
|
||||
bool ShortcutWidget::eventFilter(QObject * obj, QEvent * e)
|
||||
{
|
||||
if (!has_cursor_)
|
||||
return false;
|
||||
|
||||
switch (e->type()) {
|
||||
// swallow these if we have focus and they come from elsewhere
|
||||
case QEvent::Shortcut:
|
||||
case QEvent::ShortcutOverride:
|
||||
if (obj != this)
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
KeySequence const ShortcutWidget::getKeySequence() const
|
||||
{
|
||||
return keysequence_;
|
||||
@ -124,13 +105,17 @@ bool ShortcutWidget::event(QEvent * e)
|
||||
setFrameShadow(QFrame::Sunken);
|
||||
break;
|
||||
case QEvent::ShortcutOverride:
|
||||
// accepting the ShortcutOverride event lets us override shortcuts
|
||||
// and capture them as keypress events instead
|
||||
e->accept();
|
||||
return true;
|
||||
case QEvent::KeyPress:
|
||||
keyPressEvent(static_cast<QKeyEvent *>(e));
|
||||
return true;
|
||||
case QEvent::KeyRelease:
|
||||
case QEvent::Shortcut:
|
||||
case QEvent::KeyPress:
|
||||
return true;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QLabel::event(e);
|
||||
@ -141,7 +126,7 @@ void ShortcutWidget::appendToSequence(QKeyEvent * e)
|
||||
{
|
||||
KeySymbol sym;
|
||||
setKeySymbol(&sym, e);
|
||||
|
||||
|
||||
if (sym.isOK()) {
|
||||
KeyModifier mod = lyx::q_key_state(e->modifiers());
|
||||
keysequence_.addkey(sym, mod, lyx::NoModifier);
|
||||
|
@ -31,7 +31,6 @@ class ShortcutWidget : public QLabel {
|
||||
public:
|
||||
ShortcutWidget(QWidget * parent);
|
||||
void reset();
|
||||
bool eventFilter(QObject*, QEvent* e );
|
||||
KeySequence const getKeySequence() const;
|
||||
void setKeySequence(lyx::KeySequence const & s);
|
||||
void removeFromSequence();
|
||||
|
Loading…
Reference in New Issue
Block a user