mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Close only "child" window (e.g. Preview) inside Browser on Cmd+W (#3913)
Currently, if a user tries to close Preview which was opened inside Browse, the "parent" Browse window itself gets closed Co-authored-by: beyondcompute <beyondcompute@users.noreply.github.com>
This commit is contained in:
parent
62bad44eed
commit
2acdc8c30a
2 changed files with 14 additions and 1 deletions
|
@ -280,6 +280,19 @@ class Browser(QMainWindow):
|
|||
if note_type_id := self.get_active_note_type_id():
|
||||
add_cards.set_note_type(note_type_id)
|
||||
|
||||
# If in the Browser we open Preview and press Ctrl+W there,
|
||||
# both Preview and Browser windows get closed by Qt out of the box.
|
||||
# We circumvent that behavior by only closing the currently active window
|
||||
def _handle_close(self):
|
||||
active_window = QApplication.activeWindow()
|
||||
if active_window and active_window != self:
|
||||
if isinstance(active_window, QDialog):
|
||||
active_window.reject()
|
||||
else:
|
||||
active_window.close()
|
||||
else:
|
||||
self.close()
|
||||
|
||||
def setupMenus(self) -> None:
|
||||
# actions
|
||||
f = self.form
|
||||
|
|
|
@ -792,7 +792,7 @@
|
|||
<sender>actionClose</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<slot>_handle_close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
|
|
Loading…
Reference in a new issue