| | |
| | | } |
| | | |
| | | final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { |
| | | static private(set) weak var shared: AppDelegate? |
| | | |
| | | private static let showDockIconKey = "showDockIcon" |
| | | private static let statusItemAutosaveName = AppIdentity.statusItemAutosaveName |
| | | private static let statusItemButtonIdentifier = NSUserInterfaceItemIdentifier("TagLauncherStatusItemButton") |
| | |
| | | private var quickSearchHotkeyRef: EventHotKeyRef? |
| | | private var overlaySpaceHotkeyRef: EventHotKeyRef? |
| | | private var hotkeyEventHandlerInstalled = false |
| | | private var configuredHotkeysSuspendedForRecording = false |
| | | private var isQuickSearchOpen = false |
| | | private var quickSearchShouldHideOverlayOnClose = false |
| | | private var quickSearchOnlyOverlaySession = false |
| | |
| | | private var overlayOpenedByQuickSearchOnly = false |
| | | private var didFinishLaunching = false |
| | | private var pendingShowOverlayInvocation = false |
| | | |
| | | override init() { |
| | | super.init() |
| | | Self.shared = self |
| | | } |
| | | |
| | | private lazy var overlayController = OverlayWindowController( |
| | | dependencies: OverlayWindowController.Dependencies( |
| | |
| | | // MARK: - Global Hotkeys |
| | | |
| | | private func registerConfiguredHotkeys() { |
| | | guard !configuredHotkeysSuspendedForRecording else { return } |
| | | installHotkeyEventHandlerIfNeeded() |
| | | registerEffectiveHotkey(.main) |
| | | registerEffectiveHotkey(.quickSearch) |
| | | } |
| | | |
| | | func suspendConfiguredHotkeysForRecording() { |
| | | guard !configuredHotkeysSuspendedForRecording else { return } |
| | | configuredHotkeysSuspendedForRecording = true |
| | | unregisterHotkey(for: .main) |
| | | unregisterHotkey(for: .quickSearch) |
| | | } |
| | | |
| | | func resumeConfiguredHotkeysAfterRecording() { |
| | | guard configuredHotkeysSuspendedForRecording else { return } |
| | | configuredHotkeysSuspendedForRecording = false |
| | | registerConfiguredHotkeys() |
| | | } |
| | | |
| | | private func registerEffectiveHotkey(_ kind: LauncherHotkeyKind) { |
| | |
| | | ) { [weak self] event in |
| | | guard let self, self.isQuickSearchOpen else { return event } |
| | | if event.window === self.overlayWindow { |
| | | NotificationCenter.default.post( |
| | | name: .tagLauncherQuickSearchDismissRequested, |
| | | object: nil, |
| | | userInfo: ["source": QuickSearchDismissSource.mouse] |
| | | ) |
| | | return nil |
| | | return event |
| | | } |
| | | return event |
| | | } |
| | |
| | | } |
| | | |
| | | @objc private func openProStatusFromStatusMenu(_ sender: NSMenuItem) { |
| | | openPreferences(targetTab: SettingsTabTarget.about) |
| | | openPreferences(targetTab: SettingsTabTarget.pro) |
| | | } |
| | | |
| | | private func openPreferences(targetTab: String?) { |