mirror of
https://github.com/TermiT/Flycut.git
synced 2024-11-10 09:32:29 +08:00
Add OSX 10.13 and lower alert
This commit is contained in:
parent
3d4a1384f3
commit
052b76746e
1 changed files with 39 additions and 15 deletions
|
@ -116,6 +116,43 @@
|
||||||
[flycutOperator registerOrDeregisterICloudSync];
|
[flycutOperator registerOrDeregisterICloudSync];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showAccessibilityAlert {
|
||||||
|
BOOL suppressAlert = [[NSUserDefaults standardUserDefaults] boolForKey:@"suppressAccessibilityAlert"];
|
||||||
|
NSDictionary* options = @{(id) (kAXTrustedCheckOptionPrompt): @NO};
|
||||||
|
if (!suppressAlert && AXIsProcessTrustedWithOptions != NULL && !AXIsProcessTrustedWithOptions((CFDictionaryRef) (options))) {
|
||||||
|
NSAlert *alert = [NSAlert alertWithMessageText:@"Flycut" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"For correct functioning of the app please tick Flycut in Accessibility apps list"];
|
||||||
|
alert.showsSuppressionButton = YES;
|
||||||
|
[alert runModal];
|
||||||
|
if (alert.suppressionButton.state == NSOnState) {
|
||||||
|
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES]
|
||||||
|
forKey:@"suppressAccessibilityAlert"];
|
||||||
|
}
|
||||||
|
NSString *urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
|
||||||
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)showOldOSXAlert {
|
||||||
|
#ifdef SANDBOXING
|
||||||
|
NSOperatingSystemVersion ver = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||||
|
if (ver.majorVersion == 10 && ver.minorVersion <= 13) {
|
||||||
|
BOOL suppressAlert = [[NSUserDefaults standardUserDefaults] boolForKey:@"suppressOldOSXAlert"];
|
||||||
|
if (!suppressAlert) {
|
||||||
|
NSAlert *alert = [NSAlert alertWithMessageText:@"Flycut" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Unfortunatly due to some app sandbox security restrictions from Apple Flycut may not correctly function on MacOSX 10.13 or lower. You can download non sandboxed version here: https://github.com/TermiT/Flycut/releases"];
|
||||||
|
alert.showsSuppressionButton = YES;
|
||||||
|
[alert runModal];
|
||||||
|
if (alert.suppressionButton.state == NSOnState) {
|
||||||
|
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES]
|
||||||
|
forKey:@"suppressOldOSXAlert"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (void)awakeFromNib
|
- (void)awakeFromNib
|
||||||
{
|
{
|
||||||
[self buildAppearancesPreferencePanel];
|
[self buildAppearancesPreferencePanel];
|
||||||
|
@ -211,20 +248,8 @@
|
||||||
// Check if the app has Accessibility permission
|
// Check if the app has Accessibility permission
|
||||||
[NSApp activateIgnoringOtherApps: YES];
|
[NSApp activateIgnoringOtherApps: YES];
|
||||||
|
|
||||||
BOOL suppressAlert = [[NSUserDefaults standardUserDefaults] boolForKey:@"suppressAccessibilityAlert"];
|
[self showAccessibilityAlert];
|
||||||
NSDictionary* options = @{(id) (kAXTrustedCheckOptionPrompt): @NO};
|
[self showOldOSXAlert];
|
||||||
if (!suppressAlert && AXIsProcessTrustedWithOptions != NULL && !AXIsProcessTrustedWithOptions((CFDictionaryRef) (options))) {
|
|
||||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Flycut" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"For correct functioning of the app please tick Flycut in Accessibility apps list"];
|
|
||||||
alert.showsSuppressionButton = YES;
|
|
||||||
alert.delegate = self;
|
|
||||||
[alert runModal];
|
|
||||||
if (alert.suppressionButton.state == NSOnState) {
|
|
||||||
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES]
|
|
||||||
forKey:@"suppressAccessibilityAlert"];
|
|
||||||
}
|
|
||||||
NSString *urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
|
|
||||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)savePreferencesOnDict:(NSMutableDictionary *)saveDict
|
-(void)savePreferencesOnDict:(NSMutableDictionary *)saveDict
|
||||||
|
@ -664,7 +689,6 @@
|
||||||
-(IBAction)toggleLoadOnStartup:(id)sender {
|
-(IBAction)toggleLoadOnStartup:(id)sender {
|
||||||
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"loadOnStartup"] ) {
|
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"loadOnStartup"] ) {
|
||||||
#ifdef SANDBOXING
|
#ifdef SANDBOXING
|
||||||
|
|
||||||
SMLoginItemSetEnabled((__bridge CFStringRef)kFlycutHelperId, YES);
|
SMLoginItemSetEnabled((__bridge CFStringRef)kFlycutHelperId, YES);
|
||||||
#else
|
#else
|
||||||
[UKLoginItemRegistry addLoginItemWithPath:[[NSBundle mainBundle] bundlePath] hideIt:NO];
|
[UKLoginItemRegistry addLoginItemWithPath:[[NSBundle mainBundle] bundlePath] hideIt:NO];
|
||||||
|
|
Loading…
Reference in a new issue