From eb20968e3c311919e83836a8113d8a3570da2455 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Sat, 13 May 2023 17:57:39 +0300 Subject: [PATCH] ImageManager: Check if desktop icons are supported on current plaform Before creating icons, check if desktop links are supported by Rare on the current platform. Fixes Dummerle/Rare#262 --- rare/shared/image_manager.py | 7 ++++--- rare/utils/paths.py | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rare/shared/image_manager.py b/rare/shared/image_manager.py index 006da2b6..e958b0a1 100644 --- a/rare/shared/image_manager.py +++ b/rare/shared/image_manager.py @@ -34,7 +34,7 @@ from legendary.models.game import Game from rare.lgndr.core import LegendaryCore from rare.models.image import ImageSize from rare.models.signals import GlobalSignals -from rare.utils.paths import image_dir, resources_path, desktop_icon_suffix +from rare.utils.paths import image_dir, resources_path, desktop_icon_suffix, desktop_links_supported # from requests_futures.sessions import FuturesSession @@ -281,8 +281,9 @@ class ImageManager(QObject): painter.end() cover = cover.scaled(ImageSize.Image.size, Qt.KeepAspectRatio, Qt.SmoothTransformation) - icon = self.__convert_icon(cover) - icon.save(str(self.__img_desktop_icon(game.app_name)), format=desktop_icon_suffix().upper()) + if desktop_links_supported(): + icon = self.__convert_icon(cover) + icon.save(str(self.__img_desktop_icon(game.app_name)), format=desktop_icon_suffix().upper()) # this is not required if we ever want to re-apply the alpha channel # cover = cover.convertToFormat(QImage.Format_Indexed8) diff --git a/rare/utils/paths.py b/rare/utils/paths.py index 71a29867..58317a4d 100644 --- a/rare/utils/paths.py +++ b/rare/utils/paths.py @@ -83,6 +83,10 @@ __link_suffix = { "link": "desktop", "icon": "png", }, + # "Darwin": { + # "link": "", + # "icon": "icns", + # }, } def desktop_links_supported() -> bool: