Added warning in Integration settings when autotype is not available

This commit is contained in:
Michael Starke
2018-09-26 15:09:21 +02:00
parent 182f448535
commit bf68afb457
4 changed files with 204 additions and 122 deletions

View File

@@ -23,6 +23,7 @@
#import "MPIntegrationSettingsController.h"
#import "MPSettingsHelper.h"
#import "MPIconHelper.h"
#import "MPAutotypeDaemon.h"
#import "DDHotKeyCenter.h"
#import "DDHotKey+MacPassAdditions.h"
@@ -67,8 +68,9 @@
[self.matchTagsCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyAutotypeMatchTags] options:nil];
[self.sendCommandForControlCheckBox bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeySendCommandForControlKey] options:nil];
[self _showWarning:NO];
[self _showKeyCodeMissingKeyWarning:NO];
[self _updateAccessabilityWarning];
}
- (void)willShowTab {
@@ -92,14 +94,42 @@
- (void)controlTextDidChange:(NSNotification *)obj {
BOOL validHotKey = self.hotKeyTextField.hotKey.valid;
[self _showWarning:!validHotKey];
[self _showKeyCodeMissingKeyWarning:!validHotKey];
if(validHotKey) {
self.hotKey = self.hotKeyTextField.hotKey;
}
}
- (void)_showWarning:(BOOL)show {
- (void)_showKeyCodeMissingKeyWarning:(BOOL)show {
self.hotkeyWarningTextField.hidden = !show;
}
- (void)_updateAccessabilityWarning {
BOOL hasAutotypeSupport = MPAutotypeDaemon.defaultDaemon.autotypeSupported;
if(hasAutotypeSupport) {
[self.autotypeStackView setVisibilityPriority:NSStackViewVisibilityPriorityNotVisible forView:self.autotypeWarningTextField];
[self.autotypeStackView setVisibilityPriority:NSStackViewVisibilityPriorityNotVisible forView:self.openPreferencesButton];
}
else {
[self.autotypeStackView setVisibilityPriority:NSStackViewVisibilityPriorityMustHold forView:self.autotypeWarningTextField];
[self.autotypeStackView setVisibilityPriority:NSStackViewVisibilityPriorityMustHold forView:self.openPreferencesButton];
}
NSArray <NSControl *> *controls = @[ self.enableGlobalAutotypeCheckBox,
self.hotKeyTextField,
self.matchTitleCheckBox,
self.matchURLCheckBox,
self.matchHostCheckBox,
self.matchTagsCheckBox,
self.sendCommandForControlCheckBox ];
for(NSControl *control in controls) {
control.enabled = hasAutotypeSupport;
}
}
- (void)openAccessibiltyPreferences:(id)sender {
[NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"]];
}
@end