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
|
||||
# that can be built by make -C Source/Data/bin/C_Version
|
||||
# C_count.occ.exe
|
||||
.idea
|
||||
|
|
|
@ -216,13 +216,7 @@ public:
|
|||
BOOL learningEnabled = ![[NSUserDefaults standardUserDefaults] boolForKey:kDisableUserCandidateSelectionLearning];
|
||||
|
||||
NSMenuItem *learnMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""];
|
||||
if (learningEnabled) {
|
||||
[learnMenuItem setState:NSOnState];
|
||||
}
|
||||
else {
|
||||
[learnMenuItem setState:NSOffState];
|
||||
}
|
||||
|
||||
learnMenuItem.state = learningEnabled ? NSControlStateValueOn : NSControlStateValueOff;
|
||||
[menu addItem:learnMenuItem];
|
||||
|
||||
if (learningEnabled) {
|
||||
|
@ -458,9 +452,8 @@ public:
|
|||
|
||||
// we must use NSAttributedString so that the cursor is visible --
|
||||
// can't just use NSString
|
||||
NSDictionary *attrDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
|
||||
[NSNumber numberWithInt:0], NSMarkedClauseSegmentAttributeName, nil];
|
||||
NSDictionary *attrDict = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
|
||||
NSMarkedClauseSegmentAttributeName: @0};
|
||||
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,
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#pragma GCC diagnostic push
|
||||
#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
|
||||
if ([[self window] isVisible]) {
|
||||
if (self.window.visible) {
|
||||
if ([_delegate respondsToSelector:@selector(nonModalAlertWindowControllerDidCancel:)]) {
|
||||
[_delegate nonModalAlertWindowControllerDidCancel:self];
|
||||
}
|
||||
|
@ -41,11 +41,11 @@
|
|||
|
||||
_delegate = delegate;
|
||||
|
||||
NSRect oldFrame = [self.confirmButton frame];
|
||||
NSRect oldFrame = self.confirmButton.frame;
|
||||
[self.confirmButton setTitle:confirmTitle];
|
||||
[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.origin.x += (oldFrame.size.width - newFrame.size.width);
|
||||
|
@ -54,41 +54,41 @@
|
|||
if (cancelButtonTitle) {
|
||||
[self.cancelButton setTitle:cancelButtonTitle];
|
||||
[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.origin.x = newFrame.origin.x - adjustedFrame.size.width;
|
||||
[self.cancelButton setFrame:adjustedFrame];
|
||||
[self.cancelButton setHidden:NO];
|
||||
self.cancelButton.frame = adjustedFrame;
|
||||
self.cancelButton.hidden = NO;
|
||||
}
|
||||
else {
|
||||
[self.cancelButton setHidden:YES];
|
||||
self.cancelButton.hidden = YES;
|
||||
}
|
||||
|
||||
[self.cancelButton setNextKeyView:self.confirmButton];
|
||||
[self.confirmButton setNextKeyView:self.cancelButton];
|
||||
self.cancelButton.nextKeyView = self.confirmButton;
|
||||
self.confirmButton.nextKeyView = self.cancelButton;
|
||||
|
||||
if (cancelButtonTitle) {
|
||||
if (cancelAsDefault) {
|
||||
[[self window] setDefaultButtonCell:[self.cancelButton cell]];
|
||||
[self.window setDefaultButtonCell:self.cancelButton.cell];
|
||||
}
|
||||
else {
|
||||
[self.cancelButton setKeyEquivalent:@" "];
|
||||
[[self window] setDefaultButtonCell:[self.confirmButton cell]];
|
||||
self.cancelButton.keyEquivalent = @" ";
|
||||
[self.window setDefaultButtonCell:self.confirmButton.cell];
|
||||
}
|
||||
}
|
||||
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];
|
||||
[self.contentTextField setStringValue:content];
|
||||
self.contentTextField.stringValue = content;
|
||||
|
||||
NSRect infiniteHeightFrame = oldFrame;
|
||||
infiniteHeightFrame.size.width -= 4.0;
|
||||
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.height += 4.0;
|
||||
newFrame.origin = oldFrame.origin;
|
||||
|
@ -98,18 +98,19 @@
|
|||
NSRect windowFrame = [[self window] frame];
|
||||
windowFrame.size.height += (newFrame.size.height - oldFrame.size.height);
|
||||
|
||||
[[self window] setLevel:CGShieldingWindowLevel() + 1];
|
||||
[[self window] setFrame:windowFrame display:YES];
|
||||
[[self window] center];
|
||||
[[self window] makeKeyAndOrderFront:self];
|
||||
self.window.level = CGShieldingWindowLevel() + 1;
|
||||
[self.window setFrame:windowFrame display:YES];
|
||||
[self.window center];
|
||||
[self.window makeKeyAndOrderFront:self];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
- (IBAction)confirmButtonAction:(id)sender
|
||||
{
|
||||
[_delegate nonModalAlertWindowControllerDidConfirm:self];
|
||||
[[self window] orderOut:self];
|
||||
[self.window orderOut:self];
|
||||
}
|
||||
|
||||
- (IBAction)cancelButtonAction:(id)sender
|
||||
|
@ -124,8 +125,7 @@
|
|||
}
|
||||
|
||||
_delegate = nil;
|
||||
|
||||
[[self window] orderOut:self];
|
||||
[self.window orderOut:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -46,7 +46,7 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
|||
NSMenuItem *usKeyboardLayoutItem = nil;
|
||||
NSMenuItem *chosenItem = nil;
|
||||
|
||||
[[self.basisKeyboardLayoutButton menu] removeAllItems];
|
||||
[self.basisKeyboardLayoutButton.menu removeAllItems];
|
||||
|
||||
NSString *basisKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kBasisKeyboardLayoutPreferenceKey];
|
||||
|
||||
|
@ -72,8 +72,8 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
|||
NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
|
||||
|
||||
NSMenuItem *item = [[NSMenuItem alloc] init];
|
||||
[item setTitle:localizedName];
|
||||
[item setRepresentedObject:sourceID];
|
||||
item.title = localizedName;
|
||||
item.representedObject = sourceID;
|
||||
|
||||
if ([sourceID isEqualToString:@"com.apple.keylayout.US"]) {
|
||||
usKeyboardLayoutItem = item;
|
||||
|
@ -84,7 +84,7 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
|||
chosenItem = item;
|
||||
}
|
||||
|
||||
[[self.basisKeyboardLayoutButton menu] addItem:item];
|
||||
[self.basisKeyboardLayoutButton.menu addItem:item];
|
||||
}
|
||||
|
||||
[self.basisKeyboardLayoutButton selectItem:(chosenItem ? chosenItem : usKeyboardLayoutItem)];
|
||||
|
|
Loading…
Reference in New Issue