show warnings

This commit is contained in:
clowwindy
2014-03-01 16:51:52 +08:00
parent cfc4e58964
commit 9e5c6258d6
2 changed files with 28 additions and 3 deletions

View File

@@ -46,5 +46,6 @@
"Turn Shadowsocks On" = "打开 Shadowsocks";
"Turn Shadowsocks Off" = "关闭 Shadowsocks";
"Open Server Preferences..." = "打开服务器设定...";
"Please fill in the blanks." = "请填写以下内容。";
"Show Logs..." = "显示日志..";
"Quit" = "退出";

View File

@@ -77,10 +77,34 @@
}
}
- (BOOL)validateSettings {
if ([[_serverField stringValue] isEqualToString:@""]) {
return NO;
}
if ([_portField integerValue] == 0) {
return NO;
}
if ([[_methodBox stringValue] isEqualToString:@""]) {
return NO;
}
if ([[_passwordField stringValue] isEqualToString:@""]) {
return NO;
}
return YES;
}
- (IBAction)OK:(id)sender {
[self saveSettings];
[ShadowsocksRunner reloadConfig];
[self.window performClose:self];
if ([self validateSettings]) {
[self saveSettings];
[ShadowsocksRunner reloadConfig];
[self.window performClose:self];
} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:_L(OK)];
[alert setMessageText:_L(Please fill in the blanks.)];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:nil contextInfo:nil];
}
}
- (IBAction)cancel:(id)sender {