TrayIcon: Generic notifications
* Add a notification when starting a download too
This commit is contained in:
parent
7aa64b385e
commit
4e6008a8f7
|
@ -194,7 +194,7 @@ class DownloadsTab(QWidget):
|
|||
if item.expired:
|
||||
self.__refresh_download(item)
|
||||
return
|
||||
dl_thread = DlThread(item, self.rcore.get_game(item.options.app_name), self.core, self.args.debug)
|
||||
dl_thread = DlThread(item, rgame, self.core, self.args.debug)
|
||||
dl_thread.result.connect(self.__on_download_result)
|
||||
dl_thread.progress.connect(self.__on_download_progress)
|
||||
dl_thread.finished.connect(dl_thread.deleteLater)
|
||||
|
@ -206,6 +206,11 @@ class DownloadsTab(QWidget):
|
|||
RareCore.instance().image_manager().get_pixmap(rgame.app_name, True)
|
||||
)
|
||||
|
||||
self.signals.application.notify.emit(
|
||||
self.tr("Downloads"),
|
||||
self.tr("Starting: \"{}\" is now downloading.").format(rgame.app_title)
|
||||
)
|
||||
|
||||
@pyqtSlot(UIUpdate, object)
|
||||
def __on_download_progress(self, ui_update: UIUpdate, dl_size: int):
|
||||
self.download_widget.ui.progress_bar.setValue(int(ui_update.progress))
|
||||
|
@ -231,16 +236,19 @@ class DownloadsTab(QWidget):
|
|||
if result.shortcut and desktop_links_supported():
|
||||
if not create_desktop_link(
|
||||
app_name=result.options.app_name,
|
||||
app_title=result.shortcut_title,
|
||||
link_name=result.shortcut_name,
|
||||
app_title=result.app_title,
|
||||
link_name=result.folder_name,
|
||||
link_type="desktop",
|
||||
):
|
||||
# maybe add it to download summary, to show in finished downloads
|
||||
logger.error(f"Failed to create desktop link on {platform.system()}")
|
||||
else:
|
||||
logger.info(f"Created desktop link {result.shortcut_name} for {result.options.app_name}")
|
||||
logger.info(f"Created desktop link {result.folder_name} for {result.app_title}")
|
||||
|
||||
self.signals.application.notify.emit(result.options.app_name)
|
||||
self.signals.application.notify.emit(
|
||||
self.tr("Downloads"),
|
||||
self.tr("Finished: \"{}\" is now playable.").format(result.app_title),
|
||||
)
|
||||
|
||||
if self.updates_group.contains(result.options.app_name):
|
||||
self.updates_group.set_widget_enabled(result.options.app_name, True)
|
||||
|
|
|
@ -34,8 +34,8 @@ class DlResultModel:
|
|||
sync_saves: bool = False
|
||||
tip_url: str = ""
|
||||
shortcut: bool = False
|
||||
shortcut_name: str = ""
|
||||
shortcut_title: str = ""
|
||||
folder_name: str = ""
|
||||
app_title: str = ""
|
||||
|
||||
|
||||
class DlThread(QThread):
|
||||
|
@ -151,10 +151,9 @@ class DlThread(QThread):
|
|||
self.item.download.repair_file,
|
||||
)
|
||||
|
||||
if not self.item.options.update and self.item.options.create_shortcut:
|
||||
result.shortcut = True
|
||||
result.shortcut_name = self.rgame.folder_name
|
||||
result.shortcut_title = self.rgame.app_title
|
||||
result.shortcut = not self.item.options.update and self.item.options.create_shortcut
|
||||
result.folder_name = self.rgame.folder_name
|
||||
result.app_title = self.rgame.app_title
|
||||
|
||||
self.__finish(result)
|
||||
|
||||
|
|
|
@ -59,17 +59,10 @@ class TrayIcon(QSystemTrayIcon):
|
|||
last_played.sort(key=lambda g: g.metadata.last_played, reverse=True)
|
||||
return last_played[0:5]
|
||||
|
||||
@pyqtSlot(str)
|
||||
def notify(self, app_name: str):
|
||||
@pyqtSlot(str, str)
|
||||
def notify(self, title: str, body: str):
|
||||
if self.settings.value("notification", True, bool):
|
||||
self.showMessage(
|
||||
self.tr("Download finished"),
|
||||
self.tr("Download finished. {} is playable now").format(
|
||||
self.rcore.get_game(app_name).app_title
|
||||
),
|
||||
self.Information,
|
||||
4000,
|
||||
)
|
||||
self.showMessage(f"{QApplication.applicationName()} - {title}", body, QSystemTrayIcon.Information, 4000)
|
||||
|
||||
@pyqtSlot()
|
||||
def update_actions(self):
|
||||
|
|
|
@ -11,8 +11,8 @@ class GlobalSignals:
|
|||
class ApplicationSignals(QObject):
|
||||
# int: exit code
|
||||
quit = pyqtSignal(int)
|
||||
# str: app_title
|
||||
notify = pyqtSignal(str)
|
||||
# str: title, str: body
|
||||
notify = pyqtSignal(str, str)
|
||||
# none
|
||||
prefix_updated = pyqtSignal()
|
||||
# none
|
||||
|
|
Loading…
Reference in a new issue