📄 simple_prefs.m
字号:
- (void)showSettingsForCategory: (id)o_new_category_view{ NSRect o_win_rect, o_view_rect, o_old_view_rect; o_win_rect = [o_sprefs_win frame]; o_view_rect = [o_new_category_view frame]; if( o_currentlyShownCategoryView != nil ) { /* restore our window's height, if we've shown another category previously */ o_old_view_rect = [o_currentlyShownCategoryView frame]; o_win_rect.size.height = o_win_rect.size.height - o_old_view_rect.size.height; o_win_rect.origin.y = ( o_win_rect.origin.y + o_old_view_rect.size.height ) - o_view_rect.size.height; /* remove our previous category view */ [o_currentlyShownCategoryView removeFromSuperviewWithoutNeedingDisplay]; } o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height; [o_sprefs_win displayIfNeeded]; [o_sprefs_win setFrame: o_win_rect display:YES animate: YES]; [o_new_category_view setFrame: NSMakeRect( 0, [o_sprefs_controls_box frame].size.height, o_view_rect.size.width, o_view_rect.size.height )]; [o_new_category_view setNeedsDisplay: YES]; [o_new_category_view setAutoresizesSubviews: YES]; [[o_sprefs_win contentView] addSubview: o_new_category_view]; /* keep our current category for further reference */ [o_currentlyShownCategoryView release]; o_currentlyShownCategoryView = o_new_category_view; [o_currentlyShownCategoryView retain];}- (IBAction)interfaceSettingChanged:(id)sender{ b_intfSettingChanged = YES;}- (void)showInterfaceSettings{ [self showSettingsForCategory: o_intf_view];}- (IBAction)audioSettingChanged:(id)sender{ if( sender == o_audio_vol_sld ) [o_audio_vol_fld setIntValue: [o_audio_vol_sld intValue]]; if( sender == o_audio_vol_fld ) [o_audio_vol_sld setIntValue: [o_audio_vol_fld intValue]]; if( sender == o_audio_last_ckb ) { if( [o_audio_last_ckb state] == NSOnState ) { [o_audio_lastpwd_sfld setEnabled: YES]; [o_audio_lastuser_fld setEnabled: YES]; } else { [o_audio_lastpwd_sfld setEnabled: NO]; [o_audio_lastuser_fld setEnabled: NO]; } } b_audioSettingChanged = YES;}- (void)showAudioSettings{ [self showSettingsForCategory: o_audio_view];}- (IBAction)videoSettingChanged:(id)sender{ if( sender == o_video_snap_folder_btn ) { o_selectFolderPanel = [[NSOpenPanel alloc] init]; [o_selectFolderPanel setCanChooseDirectories: YES]; [o_selectFolderPanel setCanChooseFiles: NO]; [o_selectFolderPanel setResolvesAliases: YES]; [o_selectFolderPanel setAllowsMultipleSelection: NO]; [o_selectFolderPanel setMessage: _NS("Choose the folder to save your video snapshots to.")]; [o_selectFolderPanel setCanCreateDirectories: YES]; [o_selectFolderPanel setPrompt: _NS("Choose")]; [o_selectFolderPanel beginSheetForDirectory: nil file: nil modalForWindow: o_sprefs_win modalDelegate: self didEndSelector: @selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo: o_video_snap_folder_btn]; } else b_videoSettingChanged = YES;}- (void)savePanelDidEnd:(NSOpenPanel * )panel returnCode: (int)returnCode contextInfo: (void *)contextInfo{ if( returnCode == NSOKButton ) { if( contextInfo == o_video_snap_folder_btn ) { [o_video_snap_folder_fld setStringValue: [o_selectFolderPanel filename]]; b_videoSettingChanged = YES; } else if( contextInfo == o_osd_font_btn ) { [o_osd_font_fld setStringValue: [o_selectFolderPanel filename]]; b_osdSettingChanged = YES; } } [o_selectFolderPanel release];}- (void)showVideoSettings{ [self showSettingsForCategory: o_video_view];}- (IBAction)osdSettingChanged:(id)sender{ if( sender == o_osd_font_btn ) { o_selectFolderPanel = [[NSOpenPanel alloc] init]; [o_selectFolderPanel setCanChooseDirectories: NO]; [o_selectFolderPanel setCanChooseFiles: YES]; [o_selectFolderPanel setResolvesAliases: YES]; [o_selectFolderPanel setAllowsMultipleSelection: NO]; [o_selectFolderPanel setMessage: _NS("Choose the font to display your Subtitles with.")]; [o_selectFolderPanel setCanCreateDirectories: NO]; [o_selectFolderPanel setPrompt: _NS("Choose")]; [o_selectFolderPanel setAllowedFileTypes: [NSArray arrayWithObjects: @"dfont", @"ttf", @"otf", @"FFIL", nil]]; [o_selectFolderPanel beginSheetForDirectory: @"/System/Library/Fonts/" file: nil modalForWindow: o_sprefs_win modalDelegate: self didEndSelector: @selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo: o_osd_font_btn]; } else b_osdSettingChanged = YES;}- (void)showOSDSettings{ [self showSettingsForCategory: o_osd_view];}- (IBAction)inputSettingChanged:(id)sender{ if( sender == o_input_cachelevel_pop ) { if( [[[o_input_cachelevel_pop selectedItem] title] isEqualToString: _NS("Custom")] ) [o_input_cachelevel_custom_txt setHidden: NO]; else [o_input_cachelevel_custom_txt setHidden: YES]; } b_inputSettingChanged = YES;}- (void)showInputSettings{ [self showSettingsForCategory: o_input_view];}- (IBAction)hotkeySettingChanged:(id)sender{ if( sender == o_hotkeys_change_btn || sender == o_hotkeys_listbox ) { [o_hotkeys_change_lbl setStringValue: [NSString stringWithFormat: _NS("Press new keys for\n\"%@\""), [o_hotkeyDescriptions objectAtIndex: [o_hotkeys_listbox selectedRow]]]]; [o_hotkeys_change_keys_lbl setStringValue: [self OSXKeyToString:[[o_hotkeySettings objectAtIndex: [o_hotkeys_listbox selectedRow]] intValue]]]; [o_hotkeys_change_taken_lbl setStringValue: @""]; [o_hotkeys_change_win setInitialFirstResponder: [o_hotkeys_change_win contentView]]; [o_hotkeys_change_win makeFirstResponder: [o_hotkeys_change_win contentView]]; [NSApp runModalForWindow: o_hotkeys_change_win]; } else if( sender == o_hotkeys_change_cancel_btn ) { [NSApp stopModal]; [o_hotkeys_change_win close]; } else if( sender == o_hotkeys_change_ok_btn ) { int i_returnValue; if(! o_keyInTransition ) { [NSApp stopModal]; [o_hotkeys_change_win close]; msg_Err( p_intf, "internal error prevented the hotkey switch" ); return; } b_hotkeyChanged = YES; i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition]; if( i_returnValue != NSNotFound ) [o_hotkeySettings replaceObjectAtIndex: i_returnValue withObject: [[NSNumber numberWithInt: 0] retain]]; [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [o_keyInTransition retain]]; [NSApp stopModal]; [o_hotkeys_change_win close]; [o_hotkeys_listbox reloadData]; } else if( sender == o_hotkeys_clear_btn ) { [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [NSNumber numberWithInt: 0]]; [o_hotkeys_listbox reloadData]; b_hotkeyChanged = YES; }}- (void)showHotkeySettings{ [self showSettingsForCategory: o_hotkeys_view];}- (int)numberOfRowsInTableView:(NSTableView *)aTableView{ return [o_hotkeySettings count];}- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex{ if( [[aTableColumn identifier] isEqualToString: @"action"] ) return [o_hotkeyDescriptions objectAtIndex: rowIndex]; else if( [[aTableColumn identifier] isEqualToString: @"shortcut"] ) return [self OSXKeyToString: [[o_hotkeySettings objectAtIndex: rowIndex] intValue]]; else { msg_Err( p_intf, "unknown TableColumn identifier (%s)!", [[aTableColumn identifier] UTF8String] ); return NULL; }}- (BOOL)changeHotkeyTo: (int)i_theNewKey{ int i_returnValue; i_returnValue = [o_hotkeysNonUseableKeys indexOfObject: [NSNumber numberWithInt: i_theNewKey]]; if( i_returnValue != NSNotFound || i_theNewKey == 0 ) { [o_hotkeys_change_keys_lbl setStringValue: _NS("Invalid combination")]; [o_hotkeys_change_taken_lbl setStringValue: _NS("Regrettably, these keys cannot be assigned as hotkey shortcuts.")]; [o_hotkeys_change_ok_btn setEnabled: NO]; return NO; } else { NSString *o_temp; if( o_keyInTransition ) [o_keyInTransition release]; o_keyInTransition = [[NSNumber numberWithInt: i_theNewKey] retain]; o_temp = [self OSXKeyToString: i_theNewKey]; [o_hotkeys_change_keys_lbl setStringValue: o_temp]; i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition]; if( i_returnValue != NSNotFound ) [o_hotkeys_change_taken_lbl setStringValue: [NSString stringWithFormat: _NS("This combination is already taken by \"%@\"."), [o_hotkeyDescriptions objectAtIndex: i_returnValue]]]; else [o_hotkeys_change_taken_lbl setStringValue: @""]; [o_hotkeys_change_ok_btn setEnabled: YES]; return YES; }} @end/******************** * hotkeys settings * ********************/@implementation VLCHotkeyChangeWindow- (BOOL)acceptsFirstResponder{ return YES;}- (BOOL)becomeFirstResponder{ return YES;}- (BOOL)resignFirstResponder{ /* We need to stay the first responder or we'll miss the user's input */ return NO;}- (BOOL)performKeyEquivalent:(NSEvent *)o_theEvent{ unichar key; int i_key = 0; if( [o_theEvent modifierFlags] & NSControlKeyMask ) i_key |= KEY_MODIFIER_CTRL; if( [o_theEvent modifierFlags] & NSAlternateKeyMask ) i_key |= KEY_MODIFIER_ALT; if( [o_theEvent modifierFlags] & NSShiftKeyMask ) i_key |= KEY_MODIFIER_SHIFT; if( [o_theEvent modifierFlags] & NSCommandKeyMask ) i_key |= KEY_MODIFIER_COMMAND; key = [[[o_theEvent charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0]; if( key ) { i_key |= CocoaKeyToVLC( key ); return [[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: i_key]; } return FALSE;}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -