basic image pop-up on hover
This commit is contained in:
@@ -31,7 +31,7 @@ from .models import (
|
||||
MessagesModelItem,
|
||||
MessageItemDataRole,
|
||||
)
|
||||
from .widgets import MainWindow, SettingsDialog, Tray
|
||||
from .widgets import ImagePopup, MainWindow, SettingsDialog, Tray
|
||||
|
||||
|
||||
settings = Settings("gotify-tray")
|
||||
@@ -65,6 +65,7 @@ class MainApplication(QtWidgets.QApplication):
|
||||
settings.value("Server/client_token", type=str),
|
||||
)
|
||||
|
||||
self.cache = Cache()
|
||||
self.downloader = Downloader()
|
||||
|
||||
self.messages_model = MessagesModel()
|
||||
@@ -308,6 +309,14 @@ class MainApplication(QtWidgets.QApplication):
|
||||
return
|
||||
|
||||
self.messages_model.clear()
|
||||
|
||||
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 refresh_callback(self):
|
||||
# Manual refresh -> also reset the image cache
|
||||
@@ -362,6 +371,7 @@ class MainApplication(QtWidgets.QApplication):
|
||||
self.application_selection_changed_callback
|
||||
)
|
||||
self.main_window.delete_message.connect(self.delete_message_callback)
|
||||
self.main_window.image_popup.connect(self.image_popup_callback)
|
||||
|
||||
self.watchdog.closed.connect(lambda: self.listener_closed_callback(None, None))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user