Adopts modern Objective-C syntax.
This commit is contained in:
parent
6341270696
commit
4e27b5ecfa
|
@ -10,3 +10,4 @@ Credits.rtf
|
||||||
# the executable we used to count the occurance of a string in a file
|
# the executable we used to count the occurance of a string in a file
|
||||||
# that can be built by make -C Source/Data/bin/C_Version
|
# that can be built by make -C Source/Data/bin/C_Version
|
||||||
# C_count.occ.exe
|
# C_count.occ.exe
|
||||||
|
.idea
|
||||||
|
|
|
@ -216,13 +216,7 @@ public:
|
||||||
BOOL learningEnabled = ![[NSUserDefaults standardUserDefaults] boolForKey:kDisableUserCandidateSelectionLearning];
|
BOOL learningEnabled = ![[NSUserDefaults standardUserDefaults] boolForKey:kDisableUserCandidateSelectionLearning];
|
||||||
|
|
||||||
NSMenuItem *learnMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""];
|
NSMenuItem *learnMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""];
|
||||||
if (learningEnabled) {
|
learnMenuItem.state = learningEnabled ? NSControlStateValueOn : NSControlStateValueOff;
|
||||||
[learnMenuItem setState:NSOnState];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[learnMenuItem setState:NSOffState];
|
|
||||||
}
|
|
||||||
|
|
||||||
[menu addItem:learnMenuItem];
|
[menu addItem:learnMenuItem];
|
||||||
|
|
||||||
if (learningEnabled) {
|
if (learningEnabled) {
|
||||||
|
@ -458,9 +452,8 @@ public:
|
||||||
|
|
||||||
// we must use NSAttributedString so that the cursor is visible --
|
// we must use NSAttributedString so that the cursor is visible --
|
||||||
// can't just use NSString
|
// can't just use NSString
|
||||||
NSDictionary *attrDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
NSDictionary *attrDict = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
|
||||||
[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
|
NSMarkedClauseSegmentAttributeName: @0};
|
||||||
[NSNumber numberWithInt:0], NSMarkedClauseSegmentAttributeName, nil];
|
|
||||||
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict];
|
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict];
|
||||||
|
|
||||||
// the selection range is where the cursor is, with the length being 0 and replacement range NSNotFound,
|
// the selection range is where the cursor is, with the length being 0 and replacement range NSNotFound,
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wgnu-statement-expression"
|
#pragma GCC diagnostic ignored "-Wgnu-statement-expression"
|
||||||
|
|
||||||
- (void)showWithTitle:(NSString *)title content:(NSString *)content confirmButtonTitle:(NSString *)confirmTitle cancelButtonTitle:(NSString *)cancelButtonTitle cancelAsDefault:(BOOL)cancelAsDefault delegate:(id<OVNonModalAlertWindowControllerDelegate>)delegate;
|
- (void)showWithTitle:(NSString *)title content:(NSString *)content confirmButtonTitle:(NSString *)confirmTitle cancelButtonTitle:(NSString *)cancelButtonTitle cancelAsDefault:(BOOL)cancelAsDefault delegate:(id <OVNonModalAlertWindowControllerDelegate>)delegate;
|
||||||
{
|
{
|
||||||
// cancel previous alert
|
// cancel previous alert
|
||||||
if ([[self window] isVisible]) {
|
if (self.window.visible) {
|
||||||
if ([_delegate respondsToSelector:@selector(nonModalAlertWindowControllerDidCancel:)]) {
|
if ([_delegate respondsToSelector:@selector(nonModalAlertWindowControllerDidCancel:)]) {
|
||||||
[_delegate nonModalAlertWindowControllerDidCancel:self];
|
[_delegate nonModalAlertWindowControllerDidCancel:self];
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@
|
||||||
|
|
||||||
_delegate = delegate;
|
_delegate = delegate;
|
||||||
|
|
||||||
NSRect oldFrame = [self.confirmButton frame];
|
NSRect oldFrame = self.confirmButton.frame;
|
||||||
[self.confirmButton setTitle:confirmTitle];
|
[self.confirmButton setTitle:confirmTitle];
|
||||||
[self.confirmButton sizeToFit];
|
[self.confirmButton sizeToFit];
|
||||||
|
|
||||||
NSRect newFrame = [self.confirmButton frame];
|
NSRect newFrame = self.confirmButton.frame;
|
||||||
|
|
||||||
newFrame.size.width = MAX(90.0, (newFrame.size.width + 10.0));
|
newFrame.size.width = MAX(90.0, (newFrame.size.width + 10.0));
|
||||||
newFrame.origin.x += (oldFrame.size.width - newFrame.size.width);
|
newFrame.origin.x += (oldFrame.size.width - newFrame.size.width);
|
||||||
|
@ -54,41 +54,41 @@
|
||||||
if (cancelButtonTitle) {
|
if (cancelButtonTitle) {
|
||||||
[self.cancelButton setTitle:cancelButtonTitle];
|
[self.cancelButton setTitle:cancelButtonTitle];
|
||||||
[self.cancelButton sizeToFit];
|
[self.cancelButton sizeToFit];
|
||||||
NSRect adjustedFrame = [self.cancelButton frame];
|
NSRect adjustedFrame = self.cancelButton.frame;
|
||||||
adjustedFrame.size.width = MAX(90.0, (adjustedFrame.size.width + 10.0));
|
adjustedFrame.size.width = MAX(90.0, (adjustedFrame.size.width + 10.0));
|
||||||
adjustedFrame.origin.x = newFrame.origin.x - adjustedFrame.size.width;
|
adjustedFrame.origin.x = newFrame.origin.x - adjustedFrame.size.width;
|
||||||
[self.cancelButton setFrame:adjustedFrame];
|
self.cancelButton.frame = adjustedFrame;
|
||||||
[self.cancelButton setHidden:NO];
|
self.cancelButton.hidden = NO;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self.cancelButton setHidden:YES];
|
self.cancelButton.hidden = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.cancelButton setNextKeyView:self.confirmButton];
|
self.cancelButton.nextKeyView = self.confirmButton;
|
||||||
[self.confirmButton setNextKeyView:self.cancelButton];
|
self.confirmButton.nextKeyView = self.cancelButton;
|
||||||
|
|
||||||
if (cancelButtonTitle) {
|
if (cancelButtonTitle) {
|
||||||
if (cancelAsDefault) {
|
if (cancelAsDefault) {
|
||||||
[[self window] setDefaultButtonCell:[self.cancelButton cell]];
|
[self.window setDefaultButtonCell:self.cancelButton.cell];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self.cancelButton setKeyEquivalent:@" "];
|
self.cancelButton.keyEquivalent = @" ";
|
||||||
[[self window] setDefaultButtonCell:[self.confirmButton cell]];
|
[self.window setDefaultButtonCell:self.confirmButton.cell];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[[self window] setDefaultButtonCell:[self.confirmButton cell]];
|
[[self window] setDefaultButtonCell:self.confirmButton.cell];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.titleTextField setStringValue:title];
|
self.titleTextField.stringValue = title;
|
||||||
|
|
||||||
oldFrame = [self.contentTextField frame];
|
oldFrame = [self.contentTextField frame];
|
||||||
[self.contentTextField setStringValue:content];
|
self.contentTextField.stringValue = content;
|
||||||
|
|
||||||
NSRect infiniteHeightFrame = oldFrame;
|
NSRect infiniteHeightFrame = oldFrame;
|
||||||
infiniteHeightFrame.size.width -= 4.0;
|
infiniteHeightFrame.size.width -= 4.0;
|
||||||
infiniteHeightFrame.size.height = 10240;
|
infiniteHeightFrame.size.height = 10240;
|
||||||
newFrame = [content boundingRectWithSize:infiniteHeightFrame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:[self.contentTextField font], NSFontAttributeName, nil]];
|
newFrame = [content boundingRectWithSize:infiniteHeightFrame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.contentTextField.font}];
|
||||||
newFrame.size.width = MAX(newFrame.size.width, oldFrame.size.width);
|
newFrame.size.width = MAX(newFrame.size.width, oldFrame.size.width);
|
||||||
newFrame.size.height += 4.0;
|
newFrame.size.height += 4.0;
|
||||||
newFrame.origin = oldFrame.origin;
|
newFrame.origin = oldFrame.origin;
|
||||||
|
@ -98,18 +98,19 @@
|
||||||
NSRect windowFrame = [[self window] frame];
|
NSRect windowFrame = [[self window] frame];
|
||||||
windowFrame.size.height += (newFrame.size.height - oldFrame.size.height);
|
windowFrame.size.height += (newFrame.size.height - oldFrame.size.height);
|
||||||
|
|
||||||
[[self window] setLevel:CGShieldingWindowLevel() + 1];
|
self.window.level = CGShieldingWindowLevel() + 1;
|
||||||
[[self window] setFrame:windowFrame display:YES];
|
[self.window setFrame:windowFrame display:YES];
|
||||||
[[self window] center];
|
[self.window center];
|
||||||
[[self window] makeKeyAndOrderFront:self];
|
[self.window makeKeyAndOrderFront:self];
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
- (IBAction)confirmButtonAction:(id)sender
|
- (IBAction)confirmButtonAction:(id)sender
|
||||||
{
|
{
|
||||||
[_delegate nonModalAlertWindowControllerDidConfirm:self];
|
[_delegate nonModalAlertWindowControllerDidConfirm:self];
|
||||||
[[self window] orderOut:self];
|
[self.window orderOut:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)cancelButtonAction:(id)sender
|
- (IBAction)cancelButtonAction:(id)sender
|
||||||
|
@ -124,8 +125,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
|
[self.window orderOut:self];
|
||||||
[[self window] orderOut:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -46,7 +46,7 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
||||||
NSMenuItem *usKeyboardLayoutItem = nil;
|
NSMenuItem *usKeyboardLayoutItem = nil;
|
||||||
NSMenuItem *chosenItem = nil;
|
NSMenuItem *chosenItem = nil;
|
||||||
|
|
||||||
[[self.basisKeyboardLayoutButton menu] removeAllItems];
|
[self.basisKeyboardLayoutButton.menu removeAllItems];
|
||||||
|
|
||||||
NSString *basisKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kBasisKeyboardLayoutPreferenceKey];
|
NSString *basisKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kBasisKeyboardLayoutPreferenceKey];
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
||||||
NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
|
NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
|
||||||
|
|
||||||
NSMenuItem *item = [[NSMenuItem alloc] init];
|
NSMenuItem *item = [[NSMenuItem alloc] init];
|
||||||
[item setTitle:localizedName];
|
item.title = localizedName;
|
||||||
[item setRepresentedObject:sourceID];
|
item.representedObject = sourceID;
|
||||||
|
|
||||||
if ([sourceID isEqualToString:@"com.apple.keylayout.US"]) {
|
if ([sourceID isEqualToString:@"com.apple.keylayout.US"]) {
|
||||||
usKeyboardLayoutItem = item;
|
usKeyboardLayoutItem = item;
|
||||||
|
@ -84,7 +84,7 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
||||||
chosenItem = item;
|
chosenItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[self.basisKeyboardLayoutButton menu] addItem:item];
|
[self.basisKeyboardLayoutButton.menu addItem:item];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.basisKeyboardLayoutButton selectItem:(chosenItem ? chosenItem : usKeyboardLayoutItem)];
|
[self.basisKeyboardLayoutButton selectItem:(chosenItem ? chosenItem : usKeyboardLayoutItem)];
|
||||||
|
|
Loading…
Reference in New Issue