Commit 03ea65ee authored by Eugene Popov's avatar Eugene Popov 🇺🇦
Browse files

[ZoomComboBox] Don't switch to Browse mode by pressing Esc while the popup is visible

If the Esc key pressed while the popup is visible, handle this as a normal key press instead of a shortcut action. This will prevent from switching to Browse mode instead of closing the popup.
parent df6bdad0
......@@ -296,13 +296,30 @@ void Gwenview::ZoomComboBox::showPopup()
QComboBox::showPopup();
}
bool ZoomComboBox::eventFilter(QObject * /* watched */, QEvent *event)
bool ZoomComboBox::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::Hide) {
Q_D(ZoomComboBox);
changeZoomTo(d->lastSelectedIndex);
if (watched == view()) {
switch (event->type()) {
case QEvent::Hide: {
Q_D(ZoomComboBox);
changeZoomTo(d->lastSelectedIndex);
break;
}
case QEvent::ShortcutOverride: {
if (view()->isVisibleTo(this)) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape) {
event->accept();
}
}
break;
}
default:
break;
}
}
return false;
return QComboBox::eventFilter(watched, event);
}
void ZoomComboBox::focusOutEvent(QFocusEvent *)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment