make sure the pop-up is closed when the main window is hidden

This commit is contained in:
dries.k
2022-08-28 16:06:46 +02:00
parent 28fef2c9de
commit 1b4fec83d4
2 changed files with 7 additions and 1 deletions

View File

@@ -313,10 +313,13 @@ class MainApplication(QtWidgets.QApplication):
def image_popup_callback(self, link: str, pos: QtCore.QPoint):
if (filename := self.cache.lookup(link)) or (filename := self.downloader.get_filename(link)): # TODO: preload links
self.image_popup = ImagePopup(filename, pos, link)
self.image_popup.show()
else:
# TODO
logger.warning(f"Image {link} is not in the cache")
def main_window_hidden_callback(self):
if image_popup := getattr(self, "image_popup", None):
image_popup.close()
def refresh_callback(self):
# Manual refresh -> also reset the image cache
@@ -372,6 +375,7 @@ class MainApplication(QtWidgets.QApplication):
)
self.main_window.delete_message.connect(self.delete_message_callback)
self.main_window.image_popup.connect(self.image_popup_callback)
self.main_window.hidden.connect(self.main_window_hidden_callback)
self.watchdog.closed.connect(lambda: self.listener_closed_callback(None, None))