From 6a102ca055de0f18183497c955f3afa13b31ff6b Mon Sep 17 00:00:00 2001 From: Kai Azim <68963405+MrKai77@users.noreply.github.com> Date: Sun, 17 Sep 2023 14:54:13 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20`refreshCurrentAppIcon()`=20i?= =?UTF-8?q?nside=20`setAppIcon()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Loop/LoopApp.swift | 2 +- Loop/Managers/IconManager.swift | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Loop/LoopApp.swift b/Loop/LoopApp.swift index 2e455157..d51c10df 100644 --- a/Loop/LoopApp.swift +++ b/Loop/LoopApp.swift @@ -95,7 +95,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Check & ask for accessibility access PermissionsManager.Accessibility.requestAccess() - iconManager.restoreCurrentAppIcon() + iconManager.refreshCurrentAppIcon() if Defaults[.windowSnapping] { SnappingManager.shared.addObservers() diff --git a/Loop/Managers/IconManager.swift b/Loop/Managers/IconManager.swift index 8a949f75..0598b857 100644 --- a/Loop/Managers/IconManager.swift +++ b/Loop/Managers/IconManager.swift @@ -52,20 +52,18 @@ class IconManager { } func setAppIcon(to icon: Icon) { - NSWorkspace.shared.setIcon(NSImage(named: icon.name), forFile: Bundle.main.bundlePath, options: []) - NSApp.applicationIconImage = NSImage(named: icon.name) + Defaults[.currentIcon] = icon.name + self.refreshCurrentAppIcon() let alert = NSAlert() alert.messageText = "\(Bundle.main.appName)" alert.informativeText = "Current icon is now \(nameWithoutPrefix(name: icon.name))!" alert.icon = NSImage(named: icon.name) alert.runModal() - - Defaults[.currentIcon] = icon.name } // This function is run at startup to set the current icon to the user's set icon. - func restoreCurrentAppIcon() { + func refreshCurrentAppIcon() { NSWorkspace.shared.setIcon(NSImage(named: Defaults[.currentIcon]), forFile: Bundle.main.bundlePath, options: []) NSApp.applicationIconImage = NSImage(named: Defaults[.currentIcon]) }