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