Merge bitcoin-core/gui#795: Keep focus on "Hide" while ModalOverlay is visible

992b1bbd5da95ee782515fb0f5674bb7a02684b2 qt: keep focus on "Hide" while ModalOverlay is visible (Jadi)

Pull request description:

  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

ACKs for top commit:
  pablomartin4btc:
    Concept & approach ACK 992b1bbd5da95ee782515fb0f5674bb7a02684b2
  hebasto:
    re-ACK 992b1bbd5da95ee782515fb0f5674bb7a02684b2

Tree-SHA512: f702a3fd51db4bc10780bccf76394e35a6b5fb45db72c9c23cd10d777106b08c61077d2d989003838921e76d2cb44f809399f31df76448e4305a6c2a71b5c6a3
This commit is contained in:
Hennadii Stepanov 2024-07-15 10:44:19 +01:00 committed by pasta
parent 69c04b2c48
commit 4e144be0dd
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

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