mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Working Settings Shortcut
This commit is contained in:
parent
d1bfec5922
commit
88f5cb68d8
3 changed files with 62 additions and 90 deletions
|
|
@ -320,10 +320,9 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
.sensoryFeedback(.alignment, trigger: haptics)
|
.sensoryFeedback(.alignment, trigger: haptics)
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
SettingsLink(label: {
|
Button("Settings") {
|
||||||
Text("Settings")
|
SettingsWindowController.shared.showWindow()
|
||||||
})
|
}
|
||||||
.keyboardShortcut(KeyEquivalent(","), modifiers: .command)
|
|
||||||
// Button("Edit") { // Doesnt work....
|
// Button("Edit") { // Doesnt work....
|
||||||
// let dn = DynamicNotch(content: EditPanelView())
|
// let dn = DynamicNotch(content: EditPanelView())
|
||||||
// dn.toggle()
|
// dn.toggle()
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@ struct DynamicNotchApp: App {
|
||||||
.windowStyle(.hiddenTitleBar)
|
.windowStyle(.hiddenTitleBar)
|
||||||
.windowResizability(.contentSize)
|
.windowResizability(.contentSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var commands: some Commands {
|
||||||
|
CommandGroup(replacing: .appSettings) {
|
||||||
|
Button("Settings…") {
|
||||||
|
SettingsWindowController.shared.showWindow()
|
||||||
|
}
|
||||||
|
.keyboardShortcut(",", modifiers: .command)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
@ -404,6 +413,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
Defaults.publisher(.showDiskGraph, options: []).sink { [weak self] _ in
|
Defaults.publisher(.showDiskGraph, options: []).sink { [weak self] _ in
|
||||||
self?.debouncedUpdateWindowSize()
|
self?.debouncedUpdateWindowSize()
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
|
Defaults.publisher(.enableShortcuts, options: []).sink { change in
|
||||||
|
KeyboardShortcuts.isEnabled = change.newValue
|
||||||
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
// Observe minimalistic UI setting changes - trigger window resize
|
// Observe minimalistic UI setting changes - trigger window resize
|
||||||
Defaults.publisher(.enableMinimalisticUI, options: []).sink { [weak self] change in
|
Defaults.publisher(.enableMinimalisticUI, options: []).sink { [weak self] change in
|
||||||
|
|
@ -477,12 +490,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
self, selector: #selector(onScreenUnlocked(_:)),
|
self, selector: #selector(onScreenUnlocked(_:)),
|
||||||
name: NSNotification.Name(rawValue: "com.apple.screenIsUnlocked"), object: nil)
|
name: NSNotification.Name(rawValue: "com.apple.screenIsUnlocked"), object: nil)
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .toggleSneakPeek) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .toggleSneakPeek) { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
self.coordinator.toggleSneakPeek(
|
self.coordinator.toggleSneakPeek(
|
||||||
status: !self.coordinator.sneakPeek.show,
|
status: !self.coordinator.sneakPeek.show,
|
||||||
type: .music,
|
type: .music,
|
||||||
|
|
@ -490,14 +501,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .toggleNotchOpen) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .toggleNotchOpen) { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
let mouseLocation = NSEvent.mouseLocation
|
let mouseLocation = NSEvent.mouseLocation
|
||||||
|
|
||||||
var viewModel = self.vm
|
var viewModel = self.vm
|
||||||
|
|
||||||
if Defaults[.showOnAllDisplays] {
|
if Defaults[.showOnAllDisplays] {
|
||||||
|
|
@ -510,131 +519,91 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.closeNotchWorkItem?.cancel()
|
self.closeNotchWorkItem?.cancel()
|
||||||
self.closeNotchWorkItem = nil
|
self.closeNotchWorkItem = nil
|
||||||
|
|
||||||
switch viewModel.notchState {
|
switch viewModel.notchState {
|
||||||
case .closed:
|
case .closed:
|
||||||
viewModel.open()
|
viewModel.open()
|
||||||
|
|
||||||
let workItem = DispatchWorkItem { [weak viewModel] in
|
let workItem = DispatchWorkItem { [weak viewModel] in
|
||||||
viewModel?.close()
|
viewModel?.close()
|
||||||
}
|
}
|
||||||
self.closeNotchWorkItem = workItem
|
self.closeNotchWorkItem = workItem
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: workItem)
|
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: workItem)
|
||||||
case .open:
|
case .open:
|
||||||
viewModel.close()
|
viewModel.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .startDemoTimer) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .startDemoTimer) {
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
// Only start timer if the timer feature is enabled
|
|
||||||
guard Defaults[.enableTimerFeature] else { return }
|
guard Defaults[.enableTimerFeature] else { return }
|
||||||
|
|
||||||
// Start a 5-minute demo timer
|
|
||||||
TimerManager.shared.startDemoTimer(duration: 300)
|
TimerManager.shared.startDemoTimer(duration: 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .clipboardHistoryPanel) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .clipboardHistoryPanel) { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
// Only open clipboard if the feature is enabled
|
|
||||||
guard Defaults[.enableClipboardManager] else { return }
|
guard Defaults[.enableClipboardManager] else { return }
|
||||||
|
|
||||||
// Start clipboard monitoring if not already running
|
|
||||||
if !ClipboardManager.shared.isMonitoring {
|
if !ClipboardManager.shared.isMonitoring {
|
||||||
ClipboardManager.shared.startMonitoring()
|
ClipboardManager.shared.startMonitoring()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle keyboard shortcut based on display mode
|
|
||||||
switch Defaults[.clipboardDisplayMode] {
|
switch Defaults[.clipboardDisplayMode] {
|
||||||
case .panel:
|
case .panel:
|
||||||
ClipboardPanelManager.shared.toggleClipboardPanel()
|
ClipboardPanelManager.shared.toggleClipboardPanel()
|
||||||
case .popover:
|
case .popover:
|
||||||
// For popover mode, first ensure notch is open, then toggle popover
|
|
||||||
|
|
||||||
// If notch is closed, open it first
|
|
||||||
if self.vm.notchState == .closed {
|
if self.vm.notchState == .closed {
|
||||||
self.vm.open()
|
self.vm.open()
|
||||||
// Wait a moment for the notch to open, then show popover
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||||
NotificationCenter.default.post(name: NSNotification.Name("ToggleClipboardPopover"), object: nil)
|
NotificationCenter.default.post(name: NSNotification.Name("ToggleClipboardPopover"), object: nil)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Notch is already open, toggle popover immediately
|
|
||||||
NotificationCenter.default.post(name: NSNotification.Name("ToggleClipboardPopover"), object: nil)
|
NotificationCenter.default.post(name: NSNotification.Name("ToggleClipboardPopover"), object: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .colorPickerPanel) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .colorPickerPanel) {
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
// Only open color picker panel if the feature is enabled
|
|
||||||
guard Defaults[.enableColorPickerFeature] else { return }
|
guard Defaults[.enableColorPickerFeature] else { return }
|
||||||
|
|
||||||
// Toggle color picker panel
|
|
||||||
ColorPickerPanelManager.shared.toggleColorPickerPanel()
|
ColorPickerPanelManager.shared.toggleColorPickerPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .screenAssistantPanel) { [weak self] in
|
_ = KeyboardShortcuts.onKeyDown(for: .screenAssistantPanel) { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
// Only open screen assistant if the feature is enabled
|
|
||||||
guard Defaults[.enableScreenAssistant] else { return }
|
guard Defaults[.enableScreenAssistant] else { return }
|
||||||
|
|
||||||
// Handle keyboard shortcut based on display mode
|
|
||||||
switch Defaults[.screenAssistantDisplayMode] {
|
switch Defaults[.screenAssistantDisplayMode] {
|
||||||
case .panel:
|
case .panel:
|
||||||
ScreenAssistantPanelManager.shared.toggleScreenAssistantPanel()
|
ScreenAssistantPanelManager.shared.toggleScreenAssistantPanel()
|
||||||
case .popover:
|
case .popover:
|
||||||
// For popover mode, first ensure notch is open, then toggle popover
|
|
||||||
|
|
||||||
// If notch is closed, open it first
|
|
||||||
if self.vm.notchState == .closed {
|
if self.vm.notchState == .closed {
|
||||||
self.vm.open()
|
self.vm.open()
|
||||||
// Wait a moment for the notch to open, then show popover
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||||
NotificationCenter.default.post(name: NSNotification.Name("ToggleScreenAssistantPopover"), object: nil)
|
NotificationCenter.default.post(name: NSNotification.Name("ToggleScreenAssistantPopover"), object: nil)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Notch is already open, toggle popover immediately
|
|
||||||
NotificationCenter.default.post(name: NSNotification.Name("ToggleScreenAssistantPopover"), object: nil)
|
NotificationCenter.default.post(name: NSNotification.Name("ToggleScreenAssistantPopover"), object: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardShortcuts.onKeyDown(for: .statsPanel) { [weak self] in
|
KeyboardShortcuts.isEnabled = Defaults[.enableShortcuts]
|
||||||
guard let self = self else { return }
|
|
||||||
|
_ = KeyboardShortcuts.onKeyDown(for: .statsPanel) {
|
||||||
// Only execute if shortcuts are enabled
|
|
||||||
guard Defaults[.enableShortcuts] else { return }
|
guard Defaults[.enableShortcuts] else { return }
|
||||||
|
|
||||||
// Only open stats panel if both stats feature and panel are enabled
|
|
||||||
guard Defaults[.enableStatsFeature] && Defaults[.showStatsPanel] else { return }
|
guard Defaults[.enableStatsFeature] && Defaults[.showStatsPanel] else { return }
|
||||||
|
|
||||||
// Start stats monitoring if not already running
|
|
||||||
if !StatsManager.shared.isMonitoring {
|
if !StatsManager.shared.isMonitoring {
|
||||||
StatsManager.shared.startMonitoring()
|
StatsManager.shared.startMonitoring()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle stats panel
|
|
||||||
StatsPanelManager.shared.toggleStatsPanel()
|
StatsPanelManager.shared.toggleStatsPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10257,10 +10257,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Media output" : {
|
|
||||||
"comment" : "Accessibility label describing the control that opens the media output selector.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Media inactivity timeout" : {
|
"Media inactivity timeout" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -10361,6 +10357,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Media output" : {
|
||||||
|
"comment" : "Accessibility label describing the control that opens the media output selector.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Media playback live activity" : {
|
"Media playback live activity" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -11819,6 +11819,10 @@
|
||||||
"comment" : "A message displayed when there are no active network interfaces to display.",
|
"comment" : "A message displayed when there are no active network interfaces to display.",
|
||||||
"isCommentAutoGenerated" : true
|
"isCommentAutoGenerated" : true
|
||||||
},
|
},
|
||||||
|
"No audio outputs available" : {
|
||||||
|
"comment" : "Displayed when no audio output devices can be listed in the media output selector.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"No clipboard history" : {
|
"No clipboard history" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -13019,6 +13023,14 @@
|
||||||
},
|
},
|
||||||
"Opens the detailed system performance monitor panel. Default is Cmd+Shift+S. Only works when stats feature is enabled." : {
|
"Opens the detailed system performance monitor panel. Default is Cmd+Shift+S. Only works when stats feature is enabled." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Output devices" : {
|
||||||
|
"comment" : "Section title for the list of available audio output devices in the media output selector.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
|
"Output volume" : {
|
||||||
|
"comment" : "Label describing the system volume control inside the media output selector.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
},
|
},
|
||||||
"Panel mode shows clipboard in a floating window near the notch. Popover mode shows clipboard as a dropdown attached to the clipboard button." : {
|
"Panel mode shows clipboard in a floating window near the notch. Popover mode shows clipboard as a dropdown attached to the clipboard button." : {
|
||||||
|
|
||||||
|
|
@ -13755,18 +13767,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"No audio outputs available" : {
|
|
||||||
"comment" : "Displayed when no audio output devices can be listed in the media output selector.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Output devices" : {
|
|
||||||
"comment" : "Section title for the list of available audio output devices in the media output selector.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Output volume" : {
|
|
||||||
"comment" : "Label describing the system volume control inside the media output selector.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Reminders" : {
|
"Reminders" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -14495,6 +14495,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Settings…" : {
|
||||||
|
"comment" : "A command that shows the settings window.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Shelf" : {
|
"Shelf" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue