From 4e67028b78327c31eb28ec02fa4a96b5c41c55d7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 15 Feb 2022 19:50:33 -0500 Subject: [PATCH 01/10] Quick updates. --- Clocker/Overall App/Themer.swift | 6 +++++- Clocker/Preferences/General/PreferencesViewController.swift | 4 ++-- Clocker/Preferences/Menu Bar/StatusItemHandler.swift | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Clocker/Overall App/Themer.swift b/Clocker/Overall App/Themer.swift index e28bb1c..81e8def 100644 --- a/Clocker/Overall App/Themer.swift +++ b/Clocker/Overall App/Themer.swift @@ -191,7 +191,7 @@ extension Themer { } func preferenceImage() -> NSImage { - if let symbolImageForPreference = symbolImage(for: "gear") { + if let symbolImageForPreference = symbolImage(for: "plus") { return symbolImageForPreference } @@ -389,6 +389,10 @@ extension Themer { } func addImage() -> NSImage { + if let symbolImageForPreference = symbolImage(for: "plus") { + return symbolImageForPreference + } + if #available(macOS 10.14, *) { switch themeIndex { case .light, .solarizedLight: diff --git a/Clocker/Preferences/General/PreferencesViewController.swift b/Clocker/Preferences/General/PreferencesViewController.swift index e3a7137..4656fb5 100644 --- a/Clocker/Preferences/General/PreferencesViewController.swift +++ b/Clocker/Preferences/General/PreferencesViewController.swift @@ -172,8 +172,8 @@ class PreferencesViewController: ParentViewController { private func darkModeChanges() { if #available(macOS 10.14, *) { - addTimezoneButton.image = NSImage(named: .addDynamicIcon) - deleteButton.image = NSImage(named: NSImage.Name("Remove Dynamic"))! + addTimezoneButton.image = Themer.shared().addImage() + deleteButton.image = Themer.shared().removeImage() } } diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index e44f657..ca9dbf8 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -123,7 +123,7 @@ class StatusItemHandler: NSObject { self.menubarTimer?.invalidate() } - NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { notification in + NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { notification in self.setupStatusItem() } } From f65b1ea6c1a37551325fa246aab72acd3b8ddaa3 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 15 Feb 2022 20:07:14 -0500 Subject: [PATCH 02/10] Remove shared() --- .../AppFeedbackWindowController.swift | 11 ++-- Clocker/Preferences/OneWindowController.swift | 9 +--- Clocker/Preferences/Preferences.storyboard | 52 +++++++++---------- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift index a32b23a..ea12d94 100644 --- a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift +++ b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift @@ -309,8 +309,13 @@ extension AppFeedbackWindowController: NSWindowDelegate { } func bringPreferencesWindowToFront() { - let oneWindowController = OneWindowController.shared() - oneWindowController.window?.makeKeyAndOrderFront(self) - NSApp.activate(ignoringOtherApps: true) + let windows = NSApplication.shared.windows + let prefWindow = windows.first(where: { window in + return window.identifier == NSUserInterfaceItemIdentifier("Preferences") + }) + if let prefW = prefWindow { + prefW.makeKeyAndOrderFront(self) + NSApp.activate(ignoringOtherApps: true) + } } } diff --git a/Clocker/Preferences/OneWindowController.swift b/Clocker/Preferences/OneWindowController.swift index bed5c59..b778943 100644 --- a/Clocker/Preferences/OneWindowController.swift +++ b/Clocker/Preferences/OneWindowController.swift @@ -49,14 +49,7 @@ class OneWindowController: NSWindowController { private func setupWindow() { window?.titlebarAppearsTransparent = true window?.backgroundColor = Themer.shared().mainBackgroundColor() - } - - class func shared() -> OneWindowController { - if sharedWindow == nil { - let prefStoryboard = NSStoryboard(name: "Preferences", bundle: nil) - sharedWindow = prefStoryboard.instantiateInitialController() as? OneWindowController - } - return sharedWindow + window?.identifier = NSUserInterfaceItemIdentifier("Preferences") } func openPermissions() { diff --git a/Clocker/Preferences/Preferences.storyboard b/Clocker/Preferences/Preferences.storyboard index 3031c19..49a3e55 100644 --- a/Clocker/Preferences/Preferences.storyboard +++ b/Clocker/Preferences/Preferences.storyboard @@ -801,7 +801,7 @@ - + @@ -814,7 +814,7 @@ - + @@ -834,7 +834,7 @@ - + @@ -844,7 +844,7 @@ - + @@ -865,7 +865,7 @@ - + @@ -878,7 +878,7 @@ - + @@ -896,7 +896,7 @@ - + @@ -909,7 +909,7 @@ - + @@ -925,7 +925,7 @@ - + @@ -938,7 +938,7 @@ - + @@ -954,7 +954,7 @@ - + @@ -967,7 +967,7 @@ - + @@ -979,11 +979,11 @@ - + - + @@ -1512,7 +1512,7 @@ - + @@ -1569,13 +1569,13 @@ DQ - + - + - + @@ -1665,14 +1665,14 @@ DQ - + - + @@ -1860,14 +1860,14 @@ DQ