make sure the pop-up is closed when the main window is hidden
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
delete_message = QtCore.pyqtSignal(MessagesModelItem)
|
||||
application_selection_changed = QtCore.pyqtSignal(QtGui.QStandardItem)
|
||||
image_popup = QtCore.pyqtSignal(str, QtCore.QPoint)
|
||||
hidden = QtCore.pyqtSignal()
|
||||
|
||||
def __init__(
|
||||
self, application_model: ApplicationModel, messages_model: MessagesModel
|
||||
@@ -175,3 +176,4 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def closeEvent(self, e: QtGui.QCloseEvent) -> None:
|
||||
self.hide()
|
||||
self.hidden.emit()
|
||||
|
||||
Reference in New Issue
Block a user