mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Merge 0ecf708421 into dac26ce671
This commit is contained in:
commit
6a3e89a694
2 changed files with 24 additions and 0 deletions
|
|
@ -254,6 +254,7 @@ nav1s <nav1s@proton.me>
|
|||
Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
||||
Eltaurus <https://github.com/Eltaurus-Lt>
|
||||
jariji
|
||||
Junia Mannervik <junia.mannervik@gmail.com>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,29 @@ def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None:
|
|||
showText(out.server_message, parent=mw)
|
||||
if out.required == out.NO_CHANGES:
|
||||
tooltip(parent=mw, msg=tr.sync_collection_complete())
|
||||
|
||||
# Monitor window focus and close tooltip if window loses focus
|
||||
def check_focus() -> None:
|
||||
from aqt.utils import closeTooltip
|
||||
|
||||
# Close tooltip if window loses focus, becomes invisible, or is minimized
|
||||
if (
|
||||
not mw.isActiveWindow()
|
||||
or not mw.isVisible()
|
||||
or (mw.windowState() & Qt.WindowState.WindowMinimized)
|
||||
):
|
||||
closeTooltip()
|
||||
focus_timer.stop()
|
||||
|
||||
focus_timer = QTimer(mw)
|
||||
qconnect(focus_timer.timeout, check_focus)
|
||||
focus_timer.start(100) # Check every 100ms
|
||||
|
||||
# Stop monitoring after tooltip's natural expiry time
|
||||
def stop_monitoring() -> None:
|
||||
focus_timer.stop()
|
||||
|
||||
QTimer.singleShot(3000, stop_monitoring)
|
||||
# all done; track media progress
|
||||
mw.media_syncer.start_monitoring()
|
||||
return on_done()
|
||||
|
|
|
|||
Loading…
Reference in a new issue