diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift index 98f9593a..b4261cdc 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift @@ -19,7 +19,7 @@ public protocol PrefMgrProtocol { var keyboardParser: Int { get set } var basicKeyboardLayout: String { get set } var alphanumericalKeyboardLayout: String { get set } - var showPageButtonsInCandidateWindow: Bool { get set } + var showNotificationsWhenTogglingCapsLock: Bool { get set } var candidateListTextSize: Double { get set } var shouldAutoReloadUserDataFiles: Bool { get set } var useRearCursorMode: Bool { get set } diff --git a/Packages/vChewing_Shared/Sources/Shared/Shared.swift b/Packages/vChewing_Shared/Sources/Shared/Shared.swift index 2d1e0204..785ae131 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Shared.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Shared.swift @@ -21,7 +21,7 @@ public enum UserDef: String, CaseIterable { case kKeyboardParser = "KeyboardParser" case kBasicKeyboardLayout = "BasicKeyboardLayout" case kAlphanumericalKeyboardLayout = "AlphanumericalKeyboardLayout" - case kShowPageButtonsInCandidateWindow = "ShowPageButtonsInCandidateWindow" + case kShowNotificationsWhenTogglingCapsLock = "ShowNotificationsWhenTogglingCapsLock" case kCandidateListTextSize = "CandidateListTextSize" case kAppleLanguages = "AppleLanguages" case kShouldAutoReloadUserDataFiles = "ShouldAutoReloadUserDataFiles" diff --git a/Source/Modules/PrefMgr_Core.swift b/Source/Modules/PrefMgr_Core.swift index e279d741..00fd83a9 100644 --- a/Source/Modules/PrefMgr_Core.swift +++ b/Source/Modules/PrefMgr_Core.swift @@ -53,8 +53,8 @@ public class PrefMgr: PrefMgrProtocol { ) public var alphanumericalKeyboardLayout: String - @AppProperty(key: UserDef.kShowPageButtonsInCandidateWindow.rawValue, defaultValue: true) - public var showPageButtonsInCandidateWindow: Bool + @AppProperty(key: UserDef.kShowNotificationsWhenTogglingCapsLock.rawValue, defaultValue: true) + public var showNotificationsWhenTogglingCapsLock: Bool @AppProperty(key: UserDef.kCandidateListTextSize.rawValue, defaultValue: 18) public var candidateListTextSize: Double { diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 27be3928..16262948 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -47,7 +47,7 @@ class SessionCtl: IMKInputController { // MARK: - - /// 當前 CapsLock 按鍵是否被摁下。 + /// 當前 Caps Lock 按鍵是否被摁下。 var isCapsLocked: Bool { NSEvent.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock) } /// 當前這個 SessionCtl 副本是否處於英數輸入模式。 @@ -68,7 +68,7 @@ class SessionCtl: IMKInputController { } /// Shift 按鍵事件分析器的副本。 - /// - Remark: 警告:該工具必須為 Struct 且全專案只能有一個唯一初期化副本。否則會在動 CapsLock 的時候誤以為是在摁 Shift。 + /// - Remark: 警告:該工具必須為 Struct 且全專案只能有一個唯一初期化副本。否則會在動 Caps Lock 的時候誤以為是在摁 Shift。 static var theShiftKeyDetector = ShiftKeyUpChecker(useLShift: PrefMgr.shared.togglingAlphanumericalModeWithLShift) /// `handle(event:)` 會利用這個參數判定某次 Shift 按鍵是否用來切換中英文輸入。 @@ -170,7 +170,7 @@ extension SessionCtl { keyHandler.ensureKeyboardParser() if isASCIIMode, !isCapsLocked, PrefMgr.shared.disableShiftTogglingAlphanumericalMode { isASCIIMode = false } - if isCapsLocked { isASCIIMode = isCapsLocked } // 同步 CapsLock 狀態。 + if isCapsLocked { isASCIIMode = isCapsLocked } // 同步 Caps Lock 狀態。 /// 必須加上下述條件,否則會在每次切換至輸入法本體的視窗(比如偏好設定視窗)時會卡死。 /// 這是很多 macOS 副廠輸入法的常見失誤之處。 diff --git a/Source/Modules/SessionCtl_HandleEvent.swift b/Source/Modules/SessionCtl_HandleEvent.swift index 801c7242..73caac25 100644 --- a/Source/Modules/SessionCtl_HandleEvent.swift +++ b/Source/Modules/SessionCtl_HandleEvent.swift @@ -39,11 +39,13 @@ extension SessionCtl { if event.type == .flagsChanged, event.keyCode == KeyCode.kCapsLock.rawValue { let isCapsLockTurnedOn = event.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock) let status = NSLocalizedString("NotificationSwitchASCII", comment: "") - Notifier.notify( - message: isCapsLockTurnedOn - ? "Caps Lock" + NSLocalizedString("Alphanumerical Input Mode", comment: "") + "\n" + status - : NSLocalizedString("Chinese Input Mode", comment: "") + "\n" + status - ) + if PrefMgr.shared.showNotificationsWhenTogglingCapsLock { + Notifier.notify( + message: isCapsLockTurnedOn + ? "Caps Lock" + NSLocalizedString("Alphanumerical Input Mode", comment: "") + "\n" + status + : NSLocalizedString("Chinese Input Mode", comment: "") + "\n" + status + ) + } isASCIIMode = isCapsLockTurnedOn } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift index 29c281ea..2afb228c 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift @@ -47,6 +47,8 @@ struct suiPrefPaneExperience: View { forKey: UserDef.kTrimUnfinishedReadingsOnCommit.rawValue) @State private var selAlwaysShowTooltipTextsHorizontally = UserDefaults.standard.bool( forKey: UserDef.kAlwaysShowTooltipTextsHorizontally.rawValue) + @State private var selShowNotificationsWhenTogglingCapsLock = UserDefaults.standard.bool( + forKey: UserDef.kShowNotificationsWhenTogglingCapsLock.rawValue) private let contentMaxHeight: Double = 440 private let contentWidth: Double = { @@ -195,6 +197,14 @@ struct suiPrefPaneExperience: View { } ).disabled(PrefMgr.shared.disableShiftTogglingAlphanumericalMode == true) } + Preferences.Section(title: "Caps Lock:") { + Toggle( + LocalizedStringKey("Show notifications when toggling Caps Lock"), + isOn: $selShowNotificationsWhenTogglingCapsLock.onChange { + PrefMgr.shared.showNotificationsWhenTogglingCapsLock = selShowNotificationsWhenTogglingCapsLock + } + ) + } Preferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")) }) { Toggle( LocalizedStringKey("Enable Space key for calling candidate window"), diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 808e721c..78778ced 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -208,7 +208,7 @@ "Shift+BackSpace:" = "Shift+BackSpace:"; "Shift+Letter:" = "Shift+Letter:"; "Show Hanyu-Pinyin in the inline composition buffer" = "Show Hanyu-Pinyin in the inline composition buffer"; -"Show page buttons in candidate window" = "Show page buttons in candidate window"; +"Show notifications when toggling Caps Lock" = "Show notifications when toggling Caps Lock"; "Simplified Chinese" = "Simplified Chinese"; "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work." = "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work."; "Space to +cycle candidates, Shift+Space to +cycle pages" = "Space to +cycle candidates, Shift+Space to +cycle pages"; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 808e721c..78778ced 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -208,7 +208,7 @@ "Shift+BackSpace:" = "Shift+BackSpace:"; "Shift+Letter:" = "Shift+Letter:"; "Show Hanyu-Pinyin in the inline composition buffer" = "Show Hanyu-Pinyin in the inline composition buffer"; -"Show page buttons in candidate window" = "Show page buttons in candidate window"; +"Show notifications when toggling Caps Lock" = "Show notifications when toggling Caps Lock"; "Simplified Chinese" = "Simplified Chinese"; "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work." = "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work."; "Space to +cycle candidates, Shift+Space to +cycle pages" = "Space to +cycle candidates, Shift+Space to +cycle pages"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 2e18414b..aad16d7c 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -208,7 +208,7 @@ "Shift+BackSpace:" = "Shift+BackSpace:"; "Shift+Letter:" = "Shift+文字キー:"; "Show Hanyu-Pinyin in the inline composition buffer" = "弁音合併入力(入力緩衝列で音読みを漢語弁音に)"; -"Show page buttons in candidate window" = "入力候補陳列の側にページボタンを表示"; +"Show notifications when toggling Caps Lock" = "Caps Lock で切り替えの時に吹出通知メッセージを"; "Simplified Chinese" = "簡体中国語"; "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work." = "いくつかのアプリ(例えば MS Edge や Google Chrome などのような Chromium 系ブラウザー)には「Shift キーの入力イベントを複数化してしまう」という支障があり、そしてアプリそれぞれの開発元に修復される可能性はほぼゼロだと言える。威注音入力アプリは対策用の特殊措置を普段に起用している。ご自分の必要によって設定してください。"; "Space to +cycle candidates, Shift+Space to +cycle pages" = "Shift+Space で次のページ、Space で次の候補文字を"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 23a94622..dd386d41 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -208,7 +208,7 @@ "Shift+BackSpace:" = "Shift+退格键:"; "Shift+Letter:" = "Shift+字母键:"; "Show Hanyu-Pinyin in the inline composition buffer" = "拼音并击(组字区内显示汉语拼音)"; -"Show page buttons in candidate window" = "在选字窗内显示翻页按钮"; +"Show notifications when toggling Caps Lock" = "以 Caps Lock 切换输入法/中英模式时显示通知"; "Simplified Chinese" = "简体中文"; "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work." = "某些应用(比如像是 MS Edge 或者 Chrome 这样的 Chromium 核心的浏览器)可能会使输入的 Shift 按键讯号被重复输入,且其有关研发方很可能不打算修复这些产品缺陷。威注音针对这些应用预设启用了相容措施。请在此根据您的需求自订。"; "Space to +cycle candidates, Shift+Space to +cycle pages" = "Shift+空格键 换下一页,空格键 换选下一个候选字"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index a7e73c72..79553cd3 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -208,7 +208,7 @@ "Shift+BackSpace:" = "Shift+退格鍵:"; "Shift+Letter:" = "Shift+字母鍵:"; "Show Hanyu-Pinyin in the inline composition buffer" = "拼音並擊(組字區內顯示漢語拼音)"; -"Show page buttons in candidate window" = "在選字窗內顯示翻頁按鈕"; +"Show notifications when toggling Caps Lock" = "以 Caps Lock 切換輸入法/中英模式時顯示通知"; "Simplified Chinese" = "簡體中文"; "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. Here you can customize how the accommodation should work." = "某些應用(比如像是 MS Edge 或者 Chrome 這樣的 Chromium 核心的瀏覽器)可能會使輸入的 Shift 按鍵訊號被重複輸入,且其有關研發方很可能不打算修復這些產品缺陷。威注音針對這些應用預設啟用了相容措施。請在此根據您的需求自訂。"; "Space to +cycle candidates, Shift+Space to +cycle pages" = "Shift+空格鍵 換下一頁,空格鍵 換選下一個候選字"; diff --git a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index 9ef193a4..496e6a54 100644 --- a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -1,6 +1,7 @@ + @@ -36,14 +37,14 @@ - + - + - + @@ -266,10 +267,10 @@ - + - + @@ -319,7 +320,7 @@ - + @@ -365,10 +366,10 @@ - + + @@ -457,6 +475,7 @@ + @@ -467,6 +486,7 @@ + @@ -496,7 +516,7 @@ - + @@ -511,7 +531,6 @@ - @@ -635,7 +654,7 @@ - + @@ -649,7 +668,7 @@ - + @@ -659,7 +678,7 @@ - + @@ -692,25 +711,7 @@ - - - + diff --git a/Source/WindowNIBs/en.lproj/frmPrefWindow.strings b/Source/WindowNIBs/en.lproj/frmPrefWindow.strings index 1f6473fd..d96c6c46 100644 --- a/Source/WindowNIBs/en.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/en.lproj/frmPrefWindow.strings @@ -90,7 +90,7 @@ "RUG-ls-KyA.title" = "Push the cursor in front of the phrase after selection"; "rVQ-Hx-cGi.title" = "Japanese"; "s7u-Fm-dVg.title" = "Cycling Pages"; -"shc-Nu-UsM.title" = "Show page buttons in candidate list"; +"shc-Nu-UsM.title" = "Show notifications when toggling Caps Lock"; "tglDevZoneIMKCandidate.title" = "Use IMK Candidate Window instead of Tadokoro (will reboot the IME)"; "tglTrimUnfinishedReadingsOnCommit.title" = "Trim unfinished readings on commit"; "TXr-FF-ehw.title" = "Traditional Chinese"; diff --git a/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings b/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings index 02c9a2cf..9ed31a9a 100644 --- a/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings @@ -90,7 +90,7 @@ "RUG-ls-KyA.title" = "候補選択の直後、すぐカーソルを単語の向こうに推す"; "rVQ-Hx-cGi.title" = "和語"; "s7u-Fm-dVg.title" = "ページ"; -"shc-Nu-UsM.title" = "ページボタンを表示"; +"shc-Nu-UsM.title" = "Caps Lock で切り替えの時に吹出通知メッセージを"; "tglDevZoneIMKCandidate.title" = "IMK 候補陳列ウィンドウを起用(入力アプリは自動的に再起動)"; "tglTrimUnfinishedReadingsOnCommit.title" = "送り出す緩衝列内容から未完成な音読みを除く"; "TXr-FF-ehw.title" = "繁体中国語"; diff --git a/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings b/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings index a55ad56f..4600a74d 100644 --- a/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings @@ -90,7 +90,7 @@ "RUG-ls-KyA.title" = "在选字后将光标置于该字词的前方"; "rVQ-Hx-cGi.title" = "和语"; "s7u-Fm-dVg.title" = "轮替页面"; -"shc-Nu-UsM.title" = "在选字窗内显示翻页按钮"; +"shc-Nu-UsM.title" = "以 Caps Lock 切换输入法/中英模式时显示通知"; "tglDevZoneIMKCandidate.title" = "启用与 macOS 内建输入法相同的 IMK 选字窗(会自动重启输入法)"; "tglTrimUnfinishedReadingsOnCommit.title" = "在递交时清理未完成拼写的读音"; "TXr-FF-ehw.title" = "繁体中文"; diff --git a/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings b/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings index dc9f7a90..debf9684 100644 --- a/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings @@ -90,7 +90,7 @@ "RUG-ls-KyA.title" = "在選字後將游標置於該字詞的前方"; "rVQ-Hx-cGi.title" = "和語"; "s7u-Fm-dVg.title" = "輪替頁面"; -"shc-Nu-UsM.title" = "在選字窗內顯示翻頁按鈕"; +"shc-Nu-UsM.title" = "以 Caps Lock 切換輸入法/中英模式時顯示通知"; "tglDevZoneIMKCandidate.title" = "啟用與 macOS 內建輸入法相同的 IMK 選字窗(會自動重啟輸入法)"; "tglTrimUnfinishedReadingsOnCommit.title" = "在遞交時清理未完成拼寫的讀音"; "TXr-FF-ehw.title" = "繁體中文";