mirror of
https://github.com/ankitects/anki.git
synced 2026-01-09 03:53:55 -05:00
Updated the code to only monitor focus if the window was active when the tooltip was created
This commit is contained in:
parent
eb42e901d7
commit
c3239453a4
2 changed files with 11 additions and 10 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0b7c530233390d73b706f012bbe7489539925c7d
|
Subproject commit dad4e2736a2b53dcdb52d79b5703dd464c05d666
|
||||||
|
|
@ -1103,16 +1103,16 @@ def tooltip(
|
||||||
lab.move(aw.mapToGlobal(QPoint(0 + x_offset, aw.height() - y_offset)))
|
lab.move(aw.mapToGlobal(QPoint(0 + x_offset, aw.height() - y_offset)))
|
||||||
lab.show()
|
lab.show()
|
||||||
window = aw.window() if hasattr(aw, "window") else aw
|
window = aw.window() if hasattr(aw, "window") else aw
|
||||||
if window is None:
|
|
||||||
window = aw
|
was_active = window.isActiveWindow() if window else False
|
||||||
|
|
||||||
def close_if_parent_inactive() -> None:
|
def close_if_parent_inactive() -> None:
|
||||||
if not _tooltipLabel or window is None:
|
if not _tooltipLabel or window is None:
|
||||||
return
|
return
|
||||||
if (
|
if (
|
||||||
not window.isActiveWindow()
|
not window.isVisible()
|
||||||
or not window.isVisible()
|
|
||||||
or (window.windowState() & Qt.WindowState.WindowMinimized)
|
or (window.windowState() & Qt.WindowState.WindowMinimized)
|
||||||
|
or (was_active and not window.isActiveWindow())
|
||||||
):
|
):
|
||||||
closeTooltip()
|
closeTooltip()
|
||||||
|
|
||||||
|
|
@ -1124,11 +1124,12 @@ def tooltip(
|
||||||
pass
|
pass
|
||||||
_tooltipFocusTimer = None
|
_tooltipFocusTimer = None
|
||||||
|
|
||||||
focus_timer = QTimer(lab)
|
if was_active:
|
||||||
focus_timer.setInterval(100)
|
focus_timer = QTimer(lab)
|
||||||
qconnect(focus_timer.timeout, close_if_parent_inactive)
|
focus_timer.setInterval(100)
|
||||||
focus_timer.start()
|
qconnect(focus_timer.timeout, close_if_parent_inactive)
|
||||||
_tooltipFocusTimer = focus_timer
|
focus_timer.start()
|
||||||
|
_tooltipFocusTimer = focus_timer
|
||||||
_tooltipTimer = aqt.mw.progress.timer(
|
_tooltipTimer = aqt.mw.progress.timer(
|
||||||
period, closeTooltip, False, requiresCollection=False, parent=aw
|
period, closeTooltip, False, requiresCollection=False, parent=aw
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue