Skip to content

Commit

Permalink
Add hotkey to enable the Ice Bar
Browse files Browse the repository at this point in the history
Closes #381
  • Loading branch information
jordanbaird committed Sep 29, 2024
1 parent 99afb9f commit 9818919
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
24 changes: 16 additions & 8 deletions Ice/Hotkeys/HotkeyAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
//

enum HotkeyAction: String, Codable, CaseIterable {
// Menu Bar Sections
case toggleHiddenSection = "ToggleHiddenSection"
case toggleAlwaysHiddenSection = "ToggleAlwaysHiddenSection"
case toggleApplicationMenus = "ToggleApplicationMenus"
case showSectionDividers = "ShowSectionDividers"

// Menu Bar Items
case searchMenuBarItems = "SearchMenuBarItems"

// Other
case enableIceBar = "EnableIceBar"
case showSectionDividers = "ShowSectionDividers"
case toggleApplicationMenus = "ToggleApplicationMenus"

@MainActor
func perform(appState: AppState) async {
switch self {
Expand All @@ -18,7 +24,7 @@ enum HotkeyAction: String, Codable, CaseIterable {
return
}
section.toggle()
// prevent the section from automatically rehiding after mouse movement
// Prevent the section from automatically rehiding after mouse movement.
if !section.isHidden {
appState.preventShowOnHover()
}
Expand All @@ -27,16 +33,18 @@ enum HotkeyAction: String, Codable, CaseIterable {
return
}
section.toggle()
// prevent the section from automatically rehiding after mouse movement
// Prevent the section from automatically rehiding after mouse movement.
if !section.isHidden {
appState.preventShowOnHover()
}
case .toggleApplicationMenus:
appState.menuBarManager.toggleApplicationMenus()
case .showSectionDividers:
appState.settingsManager.advancedSettingsManager.showSectionDividers.toggle()
case .searchMenuBarItems:
await appState.menuBarManager.searchPanel.toggle()
case .enableIceBar:
appState.settingsManager.generalSettingsManager.useIceBar.toggle()
case .showSectionDividers:
appState.settingsManager.advancedSettingsManager.showSectionDividers.toggle()
case .toggleApplicationMenus:
appState.menuBarManager.toggleApplicationMenus()
}
}
}
13 changes: 8 additions & 5 deletions Ice/Settings/SettingsPanes/HotkeysSettingsPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ struct HotkeysSettingsPane: View {
hotkeyRecorder(forAction: .searchMenuBarItems)
}
IceSection("Other") {
hotkeyRecorder(forAction: .toggleApplicationMenus)
hotkeyRecorder(forAction: .enableIceBar)
hotkeyRecorder(forAction: .showSectionDividers)
hotkeyRecorder(forAction: .toggleApplicationMenus)
}
}
}
Expand All @@ -37,12 +38,14 @@ struct HotkeysSettingsPane: View {
Text("Toggle the hidden section")
case .toggleAlwaysHiddenSection:
Text("Toggle the always-hidden section")
case .toggleApplicationMenus:
Text("Toggle application menus")
case .showSectionDividers:
Text("Show section dividers")
case .searchMenuBarItems:
Text("Search menu bar items")
case .enableIceBar:
Text("Enable the Ice Bar")
case .showSectionDividers:
Text("Show section dividers")
case .toggleApplicationMenus:
Text("Toggle application menus")
}
}
}
Expand Down

0 comments on commit 9818919

Please sign in to comment.