Allow PopupMenu not to reactivate parent window.

This commit is contained in:
John Preston 2020-11-30 14:13:54 +03:00
parent 79ea651127
commit 3a05cdc11e
2 changed files with 7 additions and 1 deletions

View file

@ -538,7 +538,9 @@ PopupMenu::~PopupMenu() {
delete submenu;
}
if (const auto parent = parentWidget()) {
if (QApplication::focusWidget() != nullptr
const auto focused = QApplication::focusWidget();
if (_reactivateParent
&& focused != nullptr
&& Ui::InFocusChain(parent->window())) {
ActivateWindowDelayed(parent);
}

View file

@ -37,6 +37,9 @@ public:
void setDestroyedCallback(Fn<void()> callback) {
_destroyedCallback = std::move(callback);
}
void discardParentReActivate() {
_reactivateParent = false;
}
~PopupMenu();
@ -122,6 +125,7 @@ private:
bool _deleteOnHide = true;
bool _triggering = false;
bool _deleteLater = false;
bool _reactivateParent = true;
Fn<void()> _destroyedCallback;