Refactors the keyboard layout enum.
This commit is contained in:
parent
83354f7c48
commit
d11daacbd2
|
@ -228,29 +228,28 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
|||
[_composingBuffer setString:@""];
|
||||
|
||||
// checks and populates the default settings
|
||||
NSInteger keyboardLayout = Preferences.keyboardLayout;
|
||||
switch (keyboardLayout) {
|
||||
case 0:
|
||||
switch (Preferences.keyboardLayout) {
|
||||
case KeyboardLayoutStandard:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
||||
break;
|
||||
case 1:
|
||||
case KeyboardLayoutEten:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETenLayout());
|
||||
break;
|
||||
case 2:
|
||||
case KeyboardLayoutHsu:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HsuLayout());
|
||||
break;
|
||||
case 3:
|
||||
case KeyboardLayoutEten26:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETen26Layout());
|
||||
break;
|
||||
case 4:
|
||||
case KeyboardLayoutHanyuPinyin:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HanyuPinyinLayout());
|
||||
break;
|
||||
case 5:
|
||||
case KeyboardLayoutIBM:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::IBMLayout());
|
||||
break;
|
||||
default:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
||||
Preferences.keyboardLayout = 0;
|
||||
Preferences.keyboardLayout = KeyboardLayoutStandard;
|
||||
}
|
||||
|
||||
[(AppDelegate *)[NSApp delegate] checkForUpdate];
|
||||
|
|
|
@ -173,30 +173,42 @@ struct ComposingKeys {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
@objc enum KeyboardLayout: Int {
|
||||
case standard
|
||||
case eten
|
||||
case eten26
|
||||
case hsu
|
||||
case hanyuPinyin
|
||||
case IBM
|
||||
|
||||
var name: String {
|
||||
switch (self) {
|
||||
case .standard:
|
||||
return "Standard"
|
||||
case .eten:
|
||||
return "ETen"
|
||||
case .eten26:
|
||||
return "ETen26"
|
||||
case .hsu:
|
||||
return "Hsu"
|
||||
case .hanyuPinyin:
|
||||
return "HanyuPinyin"
|
||||
case .IBM:
|
||||
return "IBM"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
class Preferences: NSObject {
|
||||
@UserDefault(key: kKeyboardLayoutPreferenceKey, defaultValue: 0)
|
||||
@objc static var keyboardLayout: Int
|
||||
@UserDefault(key: kKeyboardLayoutPreferenceKey, defaultValue: KeyboardLayout.standard)
|
||||
@objc static var keyboardLayout: KeyboardLayout
|
||||
|
||||
@objc static var keyboardLayoutName: String {
|
||||
switch self.keyboardLayout {
|
||||
case 0:
|
||||
return "Standard"
|
||||
case 1:
|
||||
return "ETen"
|
||||
case 2:
|
||||
return "ETen26"
|
||||
case 3:
|
||||
return "Hsu"
|
||||
case 4:
|
||||
return "HanyuPinyin"
|
||||
case 5:
|
||||
return "IBM"
|
||||
default:
|
||||
return "Standard"
|
||||
}
|
||||
self.keyboardLayout.name
|
||||
}
|
||||
|
||||
@UserDefault(key: kBasisKeyboardLayoutPreferenceKey, defaultValue: "com.apple.keylayout.US")
|
||||
|
|
Loading…
Reference in New Issue