qt: keep focus on "Hide" while ModalOverlay is visible

During the initial sync, the Tab moves the focus to the widgets
of the main window, even when the ModalOverlay is visible. This
creates some weird rectangular *selections on the screen*.

This PR fixes this by keeping the focus on the "Hide" button while
the ModalOverlay is visible.

Fixes #783
This commit is contained in:
Jadi 2024-02-14 17:26:19 +03:30
parent baed5edeb6
commit 992b1bbd5d

View file

@ -23,6 +23,7 @@ ModalOverlay::ModalOverlay(bool enable_wallet, QWidget* parent)
parent->installEventFilter(this);
raise();
}
ui->closeButton->installEventFilter(this);
blockProcessTime.clear();
setVisible(false);
@ -58,6 +59,11 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
raise();
}
}
if (obj == ui->closeButton && ev->type() == QEvent::FocusOut && layerIsVisible) {
ui->closeButton->setFocus(Qt::OtherFocusReason);
}
return QWidget::eventFilter(obj, ev);
}
@ -185,6 +191,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
m_animation.setEndValue(QPoint(0, hide ? height() : 0));
m_animation.start(QAbstractAnimation::KeepWhenStopped);
layerIsVisible = !hide;
if (layerIsVisible) {
ui->closeButton->setFocus(Qt::OtherFocusReason);
}
}
void ModalOverlay::closeClicked()