Skip to content

Commit

Permalink
feat: allow per-shortcut release action preference (closes #573)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 4, 2020
1 parent f7571a3 commit ddecf91
Show file tree
Hide file tree
Showing 24 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion resources/l10n/ar.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "المظهر:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/de.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Thema:";

/*No comment provided by engineer.*/
"then release:" = "dann loslassen:";
"Then release:" = "Dann loslassen:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Diese Erlaubnis ist nötig um Fenster nach dem Drücken des Tastenkürzels anzuzeigen";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/en.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Theme:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/es.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/fi.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Teema:";

/*No comment provided by engineer.*/
"then release:" = "sitten päästä:";
"Then release:" = "Sitten päästä:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Tarvitaan ikkunoiden valitsemiseksi";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/fr.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Thème :";

/*No comment provided by engineer.*/
"then release:" = "puis relâcher :";
"Then release:" = "Puis relâcher :";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Cette permission est nécessaire pour afficher la fenêtre après le relâchement du raccourci clavier";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/hu.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Téma:";

/*No comment provided by engineer.*/
"then release:" = "majd engedje fel:";
"Then release:" = "Majd engedje fel:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Ez a jogosultság ahhoz szükséges hogy az ablak fókuszba kerüljön miután a parancsikont elengedte";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/id.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "lalu lepaskan:";
"Then release:" = "Lalu lepaskan:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Izin ini diperlukan untuk memfokuskan jendela setelah Anda melepaskan pintasan";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/it.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/ja.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "テーマ:";

/*No comment provided by engineer.*/
"then release:" = "離した時の動作:";
"Then release:" = "離した時の動作:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "こちらの許可は、ショートカットキーを離した後、ウィンドウにフォーカスするのに必要です。";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/ko.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "테마:";

/*No comment provided by engineer.*/
"then release:" = "그리고 놓으면:";
"Then release:" = "그리고 놓으면:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "이 권한은 단축키를 사용했을 때 원하는 윈도우로 이동할 수 있게 해줍니다";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/lb.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Theme:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/nl.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Thema:";

/*No comment provided by engineer.*/
"then release:" = "doe dan:";
"Then release:" = "Doe dan:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Deze permissie is nodig om vensters te focussen na het uitvoeren van de snelkoppeling";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/no.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = " slipp:";
"Then release:" = " slipp:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Denne tillatelsen er nødvendig for å kunne fokusere på vindu når du slipper hurtigtasten";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/pl.lproj/Localizable.strings
Expand Up @@ -304,7 +304,7 @@
"Theme:" = "Motyw:";

/*No comment provided by engineer.*/
"then release:" = "po czym wypuść:";
"Then release:" = "Po czym wypuść:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "To uprawnienie jest potrzebne, aby aktywować okna po zwolnieniu skrótu";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/pt-BR.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "Ao soltar:";
"Then release:" = "Ao soltar:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Esta permissão é necessária para focar a janela após acionar o atalho";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/pt.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "depois soltar:";
"Then release:" = "Depois soltar:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Esta permissão é necessária para dar foco em janelas após carregar nos atalhos";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/ru.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Тема:";

/*No comment provided by engineer.*/
"then release:" = "затем отпустить:";
"Then release:" = "Затем отпустить:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "Это разрешение нужно для фокусировки окна после отпускания комбинации клавиш";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/tr.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "Tema:";

/*No comment provided by engineer.*/
"then release:" = "then release:";
"Then release:" = "Then release:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "This permission is needed to focus windows after you release the shortcut";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/zh-CN.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "主题:";

/*No comment provided by engineer.*/
"then release:" = "然后松开:";
"Then release:" = "然后松开:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "需要此权限在释放快捷键后切换鼠标焦点";
Expand Down
2 changes: 1 addition & 1 deletion resources/l10n/zh-TW.lproj/Localizable.strings
Expand Up @@ -303,7 +303,7 @@
"Theme:" = "主題:";

/*No comment provided by engineer.*/
"then release:" = "然後放開:";
"Then release:" = "然後放開:";

/*No comment provided by engineer.*/
"This permission is needed to focus windows after you release the shortcut" = "需要取得此權限,才能在放開快速鍵後聚焦視窗";
Expand Down
3 changes: 2 additions & 1 deletion src/logic/Preferences.swift
Expand Up @@ -58,6 +58,7 @@ class Preferences {
"minCellsPerRow": defaultsDependingOnScreenRatio_["minCellsPerRow"]!,
"maxCellsPerRow": defaultsDependingOnScreenRatio_["maxCellsPerRow"]!,
"shortcutStyle": "0",
"shortcutStyle2": "0",
"hideAppBadges": "false",
"hideWindowlessApps": "false",
"hideThumbnails": "false",
Expand Down Expand Up @@ -116,7 +117,7 @@ class Preferences {
static var appsToShow: [AppsToShowPreference] { ["appsToShow", "appsToShow2"].map { defaults.macroPref($0, AppsToShowPreference.allCases) } }
static var spacesToShow: [SpacesToShowPreference] { ["spacesToShow", "spacesToShow2"].map { defaults.macroPref($0, SpacesToShowPreference.allCases) } }
static var screensToShow: [ScreensToShowPreference] { ["screensToShow", "screensToShow2"].map { defaults.macroPref($0, ScreensToShowPreference.allCases) } }
static var shortcutStyle: ShortcutStylePreference { defaults.macroPref("shortcutStyle", ShortcutStylePreference.allCases) }
static var shortcutStyle: [ShortcutStylePreference] { ["shortcutStyle", "shortcutStyle2"].map { defaults.macroPref($0, ShortcutStylePreference.allCases) } }
static var menubarIcon: MenubarIconPreference { defaults.macroPref("menubarIcon", MenubarIconPreference.allCases) }

// derived values
Expand Down
4 changes: 2 additions & 2 deletions src/logic/events/KeyboardEvents.swift
Expand Up @@ -118,7 +118,7 @@ fileprivate func handleHotModifier(_ modifiers: UInt32) -> Bool {
let otherKey = key == "holdShortcut" ? "holdShortcut2" : "holdShortcut"
KeyboardEvents.holdShortcutWasDown[key] = false
}
if Preferences.shortcutStyle == .focusOnRelease && handleHotAny(key, shortcutIndex) {
if Preferences.shortcutStyle[App.app.shortcutIndex] == .focusOnRelease && handleHotAny(key, shortcutIndex) {
return true
}
}
Expand Down Expand Up @@ -151,7 +151,7 @@ fileprivate func localShortcutThatMatches(_ event: NSEvent) -> String? {
if shortcutId.hasPrefix("holdShortcut") {
let postfix = App.app.shortcutIndex == 0 ? "" : "2"
if event.sr_keyEventType == .up && event.type == .flagsChanged && shortcut.keyCode == .none && event.modifierFlags.isDisjoint(with: shortcut.modifierFlags) &&
shortcutId == "holdShortcut" + postfix && App.app.appIsBeingUsed && Preferences.shortcutStyle == .focusOnRelease {
shortcutId == "holdShortcut" + postfix && App.app.appIsBeingUsed && Preferences.shortcutStyle[App.app.shortcutIndex] == .focusOnRelease {
return shortcutId
}
} else if event.sr_keyEventType == .down && (shortcut.keyCode == .none || event.keyCode == shortcut.carbonKeyCode) &&
Expand Down
4 changes: 2 additions & 2 deletions src/ui/preferences-window/tabs/ControlsTab.swift
Expand Up @@ -24,7 +24,6 @@ class ControlsTab {
]

static func initTab() -> NSView {
let shortcutStyle = LabelAndControl.makeLabelWithDropdown(NSLocalizedString("then release:", comment: ""), "shortcutStyle", ShortcutStylePreference.allCases)
let focusWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Focus selected window", comment: ""), "focusWindowShortcut", Preferences.focusWindowShortcut, labelPosition: .right)
let previousWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Select previous window", comment: ""), "previousWindowShortcut", Preferences.previousWindowShortcut, labelPosition: .right)
let cancelShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Cancel and hide", comment: ""), "cancelShortcut", Preferences.cancelShortcut, labelPosition: .right)
Expand All @@ -47,7 +46,6 @@ class ControlsTab {

let grid = GridView([
[tabView],
shortcutStyle,
[orPress, shortcuts],
[checkboxesExplanations, checkboxes],
])
Expand Down Expand Up @@ -81,12 +79,14 @@ class ControlsTab {
let showHiddenWindows = StackView(LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Hidden", comment: ""), "showHiddenWindows" + postfix, labelPosition: .right))
let showFullscreenWindows = StackView(LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Fullscreen", comment: ""), "showFullscreenWindows" + postfix, labelPosition: .right))
let nextWindowShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Select next window", comment: ""), "nextWindowShortcut" + postfix, Preferences.nextWindowShortcut[postfix == "" ? 0 : 1], labelPosition: .right)
let shortcutStyle = LabelAndControl.makeLabelWithDropdown(NSLocalizedString("Then release:", comment: ""), "shortcutStyle" + postfix, ShortcutStylePreference.allCases)
let toShowDropdowns = StackView([appsToShow, spacesToShow, screensToShow, showMinimizedWindows, showHiddenWindows, showFullscreenWindows], .vertical, false)
toShowDropdowns.spacing = TabView.padding
toShowDropdowns.fit()
let tab = GridView([
[toShowExplanations, toShowDropdowns],
[holdAndPress, StackView(nextWindowShortcut)],
shortcutStyle,
], TabView.padding)
tab.column(at: 0).xPlacement = .trailing
tab.fit()
Expand Down

0 comments on commit ddecf91

Please sign in to comment.