Skip to content

Commit

Permalink
feat: add shortcut to toggle fullscreen selected window (closes #2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed May 9, 2023
1 parent c08dcd9 commit 7327917
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/logic/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Preferences {
"cancelShortcut": "",
"closeWindowShortcut": "W",
"minDeminWindowShortcut": "M",
"toggleFullscreenWindowShortcut": "F",
"quitAppShortcut": "Q",
"hideShowAppShortcut": "H",
"arrowKeysEnabled": "true",
Expand Down Expand Up @@ -115,6 +116,7 @@ class Preferences {
static var cancelShortcut: String { defaults.string("cancelShortcut") }
static var closeWindowShortcut: String { defaults.string("closeWindowShortcut") }
static var minDeminWindowShortcut: String { defaults.string("minDeminWindowShortcut") }
static var toggleFullscreenWindowShortcut: String { defaults.string("toggleFullscreenWindowShortcut") }
static var quitAppShortcut: String { defaults.string("quitAppShortcut") }
static var hideShowAppShortcut: String { defaults.string("hideShowAppShortcut") }
static var arrowKeysEnabled: Bool { defaults.bool("arrowKeysEnabled") }
Expand Down
4 changes: 4 additions & 0 deletions src/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class App: AppCenterApplication, NSApplicationDelegate {
Windows.focusedWindow()?.minDemin()
}

func toggleFullscreenSelectedWindow() {
Windows.focusedWindow()?.toggleFullscreen()
}

func quitSelectedApp() {
Windows.focusedWindow()?.application.quit()
}
Expand Down
4 changes: 3 additions & 1 deletion src/ui/preferences-window/tabs/ControlsTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ControlsTab {
"cancelShortcut": { App.app.hideUi() },
"closeWindowShortcut": { App.app.closeSelectedWindow() },
"minDeminWindowShortcut": { App.app.minDeminSelectedWindow() },
"toggleFullscreenWindowShortcut": { App.app.toggleFullscreenSelectedWindow() },
"quitAppShortcut": { App.app.quitSelectedApp() },
"hideShowAppShortcut": { App.app.hideShowSelectedApp() },
]
Expand All @@ -35,6 +36,7 @@ class ControlsTab {
let cancelShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Cancel and hide", comment: ""), "cancelShortcut", Preferences.cancelShortcut, labelPosition: .right)
let closeWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Close window", comment: ""), "closeWindowShortcut", Preferences.closeWindowShortcut, labelPosition: .right)
let minDeminWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Minimize/Deminimize window", comment: ""), "minDeminWindowShortcut", Preferences.minDeminWindowShortcut, labelPosition: .right)
let toggleFullscreenWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Fullscreen/Defullscreen window", comment: ""), "toggleFullscreenWindowShortcut", Preferences.toggleFullscreenWindowShortcut, labelPosition: .right)
let quitAppShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Quit app", comment: ""), "quitAppShortcut", Preferences.quitAppShortcut, labelPosition: .right)
let hideShowAppShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Hide/Show app", comment: ""), "hideShowAppShortcut", Preferences.hideShowAppShortcut, labelPosition: .right)
let enableArrows = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Arrow keys", comment: ""), "arrowKeysEnabled", extraAction: ControlsTab.arrowKeysEnabledCallback, labelPosition: .right)
Expand All @@ -45,7 +47,7 @@ class ControlsTab {
let selectWindowCheckboxes = StackView([StackView(enableArrows), StackView(enableMouse)], .vertical)
let miscCheckboxesExplanations = LabelAndControl.makeLabel(NSLocalizedString("Miscellaneous:", comment: ""))
let miscCheckboxes = StackView([StackView(enableCursorFollowFocus)], .vertical)
let shortcuts = StackView([focusWindowShortcut, previousWindowShortcut, cancelShortcut, closeWindowShortcut, minDeminWindowShortcut, quitAppShortcut, hideShowAppShortcut].map { (view: [NSView]) in StackView(view) }, .vertical)
let shortcuts = StackView([focusWindowShortcut, previousWindowShortcut, cancelShortcut, closeWindowShortcut, minDeminWindowShortcut, toggleFullscreenWindowShortcut, quitAppShortcut, hideShowAppShortcut].map { (view: [NSView]) in StackView(view) }, .vertical)
let orPress = LabelAndControl.makeLabel(NSLocalizedString("While open, press:", comment: ""), shouldFit: false)
let (holdShortcut, nextWindowShortcut, tab1View) = toShowSection(0)
let (holdShortcut2, nextWindowShortcut2, tab2View) = toShowSection(1)
Expand Down

0 comments on commit 7327917

Please sign in to comment.