PrefUI // Only showing fart SFX toggle on April 1st.

This commit is contained in:
ShikiSuen 2023-02-06 20:25:37 +08:00
parent 3b836d3dff
commit 13a7076255
1 changed files with 35 additions and 33 deletions

View File

@ -168,42 +168,44 @@ struct VwrPrefPaneGeneral: View {
PrefMgr.shared.inlineDumpPinyinInLieuOfZhuyin = selInlineDumpPinyinInLieuOfZhuyin PrefMgr.shared.inlineDumpPinyinInLieuOfZhuyin = selInlineDumpPinyinInLieuOfZhuyin
} }
) )
Toggle( if Date.isTodayTheDate(from: 0401) {
LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"), Toggle(
isOn: $selEnableFartSuppressor.onChange { LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"),
let content = String( isOn: $selEnableFartSuppressor.onChange {
format: NSLocalizedString( let content = String(
"You are about to uncheck this fart suppressor. You are responsible for all consequences lead by letting people nearby hear the fart sound come from your computer. We strongly advise against unchecking this in any public circumstance that prohibits NSFW netas.", format: NSLocalizedString(
comment: "" "You are about to uncheck this fart suppressor. You are responsible for all consequences lead by letting people nearby hear the fart sound come from your computer. We strongly advise against unchecking this in any public circumstance that prohibits NSFW netas.",
)) comment: ""
let alert = NSAlert(error: NSLocalizedString("Warning", comment: "")) ))
alert.informativeText = content let alert = NSAlert(error: NSLocalizedString("Warning", comment: ""))
alert.addButton(withTitle: NSLocalizedString("Uncheck", comment: "")) alert.informativeText = content
if #available(macOS 11, *) { alert.addButton(withTitle: NSLocalizedString("Uncheck", comment: ""))
alert.buttons.forEach { button in if #available(macOS 11, *) {
button.hasDestructiveAction = true alert.buttons.forEach { button in
} button.hasDestructiveAction = true
}
alert.addButton(withTitle: NSLocalizedString("Leave it checked", comment: ""))
if let window = CtlPrefUI.shared.controller.window, !selEnableFartSuppressor {
PrefMgr.shared.shouldNotFartInLieuOfBeep = true
alert.beginSheetModal(for: window) { result in
switch result {
case .alertFirstButtonReturn:
PrefMgr.shared.shouldNotFartInLieuOfBeep = false
case .alertSecondButtonReturn:
PrefMgr.shared.shouldNotFartInLieuOfBeep = true
default: break
} }
selEnableFartSuppressor = PrefMgr.shared.shouldNotFartInLieuOfBeep
IMEApp.buzz()
} }
return alert.addButton(withTitle: NSLocalizedString("Leave it checked", comment: ""))
if let window = CtlPrefUI.shared.controller.window, !selEnableFartSuppressor {
PrefMgr.shared.shouldNotFartInLieuOfBeep = true
alert.beginSheetModal(for: window) { result in
switch result {
case .alertFirstButtonReturn:
PrefMgr.shared.shouldNotFartInLieuOfBeep = false
case .alertSecondButtonReturn:
PrefMgr.shared.shouldNotFartInLieuOfBeep = true
default: break
}
selEnableFartSuppressor = PrefMgr.shared.shouldNotFartInLieuOfBeep
IMEApp.buzz()
}
return
}
PrefMgr.shared.shouldNotFartInLieuOfBeep = selEnableFartSuppressor
IMEApp.buzz()
} }
PrefMgr.shared.shouldNotFartInLieuOfBeep = selEnableFartSuppressor )
IMEApp.buzz() }
}
)
} }
SSPreferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")).controlSize(.small) }) { SSPreferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")).controlSize(.small) }) {
Toggle( Toggle(