Skip to content

Commit

Permalink
Potential v2.6 with global search hotkey implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolar committed Jun 3, 2023
1 parent 8d555cd commit a50a835
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>PlayStatus.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>4</integer>
</dict>
</dict>
</dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "41F9DCE0-0C4A-4B16-8EA3-8DF1D0C111F2"
uuid = "436510D1-6AA8-42D1-9B20-D9F70270A645"
type = "0"
version = "2.0">
</Bucket>
41 changes: 26 additions & 15 deletions PlayStatus/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
}

}

}
Expand Down
64 changes: 48 additions & 16 deletions PlayStatus/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions PlayStatus/MusicVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class MusicVC: NSViewController {
}

@objc func close(){

if searchView?.window?.isVisible == true
{
searchView?.resignFirstResponder()
Expand Down
2 changes: 1 addition & 1 deletion PlayStatus/Preferences/AboutVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions PlayStatus/Preferences/HotKeysVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ 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)
private let playerVolUphotkeyRecorder = KeyboardShortcuts.RecorderCocoa(for: .playerVolUp)
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()
Expand All @@ -37,6 +39,7 @@ class HotKeysVC: NSViewController {
playerVolDownView.addSubview(playerVolDownhotkeyRecorder)
systemVolUpView.addSubview(systemVolUphotkeyRecorder)
systemVolDownView.addSubview(systemVolDownhotkeyRecorder)
globalSearchView.addSubview(globalSearchhotkeyRecorder)

}

Expand All @@ -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")
}
1 change: 1 addition & 0 deletions PlayStatus/SearchVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Cocoa

class SearchVC: NSViewController {
static let shared = SearchVC()
var itunesMusicName: String!
var segmentedButtonValue: Int = 0

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a50a835

Please sign in to comment.