From a50a83590446adf03256d773405dd8baceaed4e5 Mon Sep 17 00:00:00 2001 From: Nikhil Bolar Date: Thu, 16 Mar 2023 22:49:26 -0400 Subject: [PATCH] Potential v2.6 with global search hotkey implemented --- .../xcschemes/xcschememanagement.plist | 2 +- .../xcdebugger/Breakpoints_v2.xcbkptlist | 2 +- PlayStatus/AppDelegate.swift | 41 +++++++----- PlayStatus/Base.lproj/Main.storyboard | 64 ++++++++++++++----- PlayStatus/MusicVC.swift | 1 + PlayStatus/Preferences/AboutVC.swift | 2 +- PlayStatus/Preferences/HotKeysVC.swift | 4 ++ PlayStatus/SearchVC.swift | 1 + .../xcschemes/xcschememanagement.plist | 6 +- 9 files changed, 86 insertions(+), 37 deletions(-) diff --git a/PlayStatus.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist b/PlayStatus.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist index 46776b5..1ecb6df 100644 --- a/PlayStatus.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/PlayStatus.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ PlayStatus.xcscheme_^#shared#^_ orderHint - 1 + 4 diff --git a/PlayStatus.xcworkspace/xcuserdata/nikhilbolar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/PlayStatus.xcworkspace/xcuserdata/nikhilbolar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 95af1a2..d50b004 100644 --- a/PlayStatus.xcworkspace/xcuserdata/nikhilbolar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/PlayStatus.xcworkspace/xcuserdata/nikhilbolar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -1,6 +1,6 @@ diff --git a/PlayStatus/AppDelegate.swift b/PlayStatus/AppDelegate.swift index 60f1ade..a5cb482 100644 --- a/PlayStatus/AppDelegate.swift +++ b/PlayStatus/AppDelegate.swift @@ -181,6 +181,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, CAAnimationDelegate { KeyboardShortcuts.onKeyDown(for: .prevTrack) { [self] in previousTrackMenuItem(self) + + } + KeyboardShortcuts.onKeyDown(for: .globalSearch) { [self] in + + togglePopover(self) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { [self] in + if musicController?.window?.isVisible == true{ + searchMenuItem(self) + } + } + } KeyboardShortcuts.onKeyDown(for: .playerVolUp) { [] in NSAppleScript.go(code: NSAppleScript.increasePlayerVol(), completionHandler: {_,_,_ in}) @@ -224,21 +235,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, CAAnimationDelegate { @objc func togglePopover(_ sender: Any?) { let event = NSApp.currentEvent! - if event.type == NSEvent.EventType.leftMouseUp - { - if musicController?.window?.isVisible == true - { - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "close"), object: nil) - musicController?.close() - }else{ - if UserDefaults.standard.bool(forKey: "scrollable") == false { - displayPopUp(status: newStatusItem) - }else{ - displayPopUp(status: statusItem) - } - } - - }else if event.type == NSEvent.EventType.rightMouseUp{ + if event.type == NSEvent.EventType.rightMouseUp{ var appVersion: String? { return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String @@ -263,6 +260,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, CAAnimationDelegate { } + }else + { + if musicController?.window?.isVisible == true + { + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "close"), object: nil) + musicController?.close() + }else{ + if UserDefaults.standard.bool(forKey: "scrollable") == false { + displayPopUp(status: newStatusItem) + }else{ + displayPopUp(status: statusItem) + } + } + } } diff --git a/PlayStatus/Base.lproj/Main.storyboard b/PlayStatus/Base.lproj/Main.storyboard index 101d141..dd78687 100644 --- a/PlayStatus/Base.lproj/Main.storyboard +++ b/PlayStatus/Base.lproj/Main.storyboard @@ -773,7 +773,8 @@ - + + @@ -844,7 +845,7 @@ - + @@ -996,7 +997,7 @@ - + @@ -1444,11 +1445,11 @@ - + - + @@ -1456,7 +1457,7 @@ - + @@ -1468,10 +1469,10 @@ - + - + @@ -1499,7 +1500,7 @@ - + @@ -1527,7 +1528,7 @@ - + @@ -1555,7 +1556,7 @@ - + @@ -1584,7 +1585,7 @@ - + @@ -1612,7 +1613,7 @@ - + @@ -1640,7 +1641,7 @@ - + @@ -1667,6 +1668,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1676,6 +1705,7 @@ + @@ -1685,10 +1715,11 @@ + - + @@ -1706,6 +1737,7 @@ + @@ -1717,7 +1749,7 @@ - + diff --git a/PlayStatus/MusicVC.swift b/PlayStatus/MusicVC.swift index cd6e023..172c68b 100644 --- a/PlayStatus/MusicVC.swift +++ b/PlayStatus/MusicVC.swift @@ -137,6 +137,7 @@ class MusicVC: NSViewController { } @objc func close(){ + if searchView?.window?.isVisible == true { searchView?.resignFirstResponder() diff --git a/PlayStatus/Preferences/AboutVC.swift b/PlayStatus/Preferences/AboutVC.swift index 1f8d4fa..e1657c3 100644 --- a/PlayStatus/Preferences/AboutVC.swift +++ b/PlayStatus/Preferences/AboutVC.swift @@ -25,7 +25,7 @@ class AboutVC: NSViewController { descriptionField.stringValue = """ MIT License - Copyright (c) 2022 Nikhil Bolar + Copyright (c) 2019 - 2023 Nikhil Bolar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PlayStatus/Preferences/HotKeysVC.swift b/PlayStatus/Preferences/HotKeysVC.swift index 37d98f3..d99de48 100644 --- a/PlayStatus/Preferences/HotKeysVC.swift +++ b/PlayStatus/Preferences/HotKeysVC.swift @@ -18,6 +18,7 @@ class HotKeysVC: NSViewController { @IBOutlet weak var playerVolDownView: NSView! @IBOutlet weak var systemVolUpView: NSView! @IBOutlet weak var systemVolDownView: NSView! + @IBOutlet weak var globalSearchView: NSView! private let playPausehotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .playPause) private let nextTrackhotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .nextTrack) private let prevTrackhotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .prevTrack) @@ -25,6 +26,7 @@ class HotKeysVC: NSViewController { private let playerVolDownhotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .playerVolDown) private let systemVolUphotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .systemVolUp) private let systemVolDownhotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .systemVolDown) + private let globalSearchhotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .globalSearch) override func viewDidLoad() { super.viewDidLoad() @@ -37,6 +39,7 @@ class HotKeysVC: NSViewController { playerVolDownView.addSubview(playerVolDownhotkeyRecorder) systemVolUpView.addSubview(systemVolUphotkeyRecorder) systemVolDownView.addSubview(systemVolDownhotkeyRecorder) + globalSearchView.addSubview(globalSearchhotkeyRecorder) } @@ -55,4 +58,5 @@ extension KeyboardShortcuts.Name{ static let playerVolDown = Self("playerVolDown") static let systemVolUp = Self("systemVolUp") static let systemVolDown = Self("systemVolDown") + static let globalSearch = Self("globalSearch") } diff --git a/PlayStatus/SearchVC.swift b/PlayStatus/SearchVC.swift index ccdb087..6628412 100644 --- a/PlayStatus/SearchVC.swift +++ b/PlayStatus/SearchVC.swift @@ -9,6 +9,7 @@ import Cocoa class SearchVC: NSViewController { + static let shared = SearchVC() var itunesMusicName: String! var segmentedButtonValue: Int = 0 diff --git a/Pods/Pods.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist index 4349566..f0c8894 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Pods/Pods.xcodeproj/xcuserdata/nikhilbolar.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ CircularProgressMac.xcscheme_^#shared#^_ orderHint - 2 + 3 KeyboardShortcuts.xcscheme_^#shared#^_ @@ -22,12 +22,12 @@ LoginServiceKit.xcscheme_^#shared#^_ orderHint - 3 + 1 Pods-PlayStatus.xcscheme_^#shared#^_ orderHint - 4 + 2 SwiftyJSON.xcscheme_^#shared#^_