📄 simple_prefs.m
字号:
/****************************************************************************** simple_prefs.m: Simple Preferences for Mac OS X****************************************************************************** Copyright (C) 2008 the VideoLAN team* $Id$** Authors: Felix Paul Kühne <fkuehne at videolan dot org>** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.*****************************************************************************/#import "simple_prefs.h"#import "prefs.h"#import <vlc_keys.h>#import <vlc_interface.h>#import "misc.h"static NSString* VLCSPrefsToolbarIdentifier = @"Our Simple Preferences Toolbar Identifier";static NSString* VLCIntfSettingToolbarIdentifier = @"Intf Settings Item Identifier";static NSString* VLCAudioSettingToolbarIdentifier = @"Audio Settings Item Identifier";static NSString* VLCVideoSettingToolbarIdentifier = @"Video Settings Item Identifier";static NSString* VLCOSDSettingToolbarIdentifier = @"Subtitles Settings Item Identifier";static NSString* VLCInputSettingToolbarIdentifier = @"Input Settings Item Identifier";static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Identifier";@implementation VLCSimplePrefsstatic VLCSimplePrefs *_o_sharedInstance = nil;+ (VLCSimplePrefs *)sharedInstance{ return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];}- (id)init{ if (_o_sharedInstance) { [self dealloc]; } else { _o_sharedInstance = [super init]; p_intf = VLCIntf; } return _o_sharedInstance;}- (void)dealloc{ [o_currentlyShownCategoryView release]; [o_hotkeySettings release]; [o_hotkeyDescriptions release]; [o_hotkeysNonUseableKeys release]; [o_keyInTransition release]; [super dealloc];}- (NSString *)OSXKeyToString:(int)val{ NSMutableString *o_temp_str = [[[NSMutableString alloc] init] autorelease]; if( val & KEY_MODIFIER_CTRL ) [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]]; if( val & KEY_MODIFIER_ALT ) [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]]; if( val & KEY_MODIFIER_SHIFT ) [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]]; if( val & KEY_MODIFIER_COMMAND ) [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]]; const char *base = KeyToString( val & ~KEY_MODIFIER ); if( base ) [o_temp_str appendString: [NSString stringWithUTF8String: base]]; else o_temp_str = [NSMutableString stringWithString:_NS("Not Set")]; return o_temp_str;}- (void)awakeFromNib{ [self initStrings]; /* setup the toolbar */ NSToolbar * o_sprefs_toolbar = [[[NSToolbar alloc] initWithIdentifier: VLCSPrefsToolbarIdentifier] autorelease]; [o_sprefs_toolbar setAllowsUserCustomization: NO]; [o_sprefs_toolbar setAutosavesConfiguration: NO]; [o_sprefs_toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel]; [o_sprefs_toolbar setSizeMode: NSToolbarSizeModeRegular]; [o_sprefs_toolbar setDelegate: self]; [o_sprefs_win setToolbar: o_sprefs_toolbar]; /* setup useful stuff */ o_hotkeysNonUseableKeys = [[NSArray arrayWithObjects: [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'c'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'x'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'v'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'a'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|','], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'h'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'h'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'o'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'o'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'d'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'n'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'s'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'z'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'l'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'r'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'0'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'1'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'2'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'3'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'m'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'w'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'w'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'c'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'p'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'i'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'e'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'e'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'b'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'m'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_CTRL|'m'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'?'], [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'?'], nil] retain];}#define CreateToolbarItem( o_name, o_desc, o_img, sel ) \ o_toolbarItem = create_toolbar_item(o_itemIdent, o_name, o_desc, o_img, self, @selector(sel));static inline NSToolbarItem *create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_desc, NSString * o_img, id target, SEL selector ){ NSToolbarItem *o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease]; \ [o_toolbarItem setLabel: o_name]; [o_toolbarItem setPaletteLabel: o_desc]; [o_toolbarItem setToolTip: o_desc]; [o_toolbarItem setImage: [NSImage imageNamed: o_img]]; [o_toolbarItem setTarget: target]; [o_toolbarItem setAction: selector]; [o_toolbarItem setEnabled: YES]; [o_toolbarItem setAutovalidates: YES]; return o_toolbarItem;}- (NSToolbarItem *) toolbar: (NSToolbar *)o_sprefs_toolbar itemForItemIdentifier: (NSString *)o_itemIdent willBeInsertedIntoToolbar: (BOOL)b_willBeInserted{ NSToolbarItem *o_toolbarItem = nil; if( [o_itemIdent isEqual: VLCIntfSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Interface"), _NS("Interface Settings"), @"spref_cone_Interface_64", showInterfaceSettings ); } else if( [o_itemIdent isEqual: VLCAudioSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Audio"), _NS("General Audio Settings"), @"spref_cone_Audio_64", showAudioSettings ); } else if( [o_itemIdent isEqual: VLCVideoSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Video"), _NS("General Video Settings"), @"spref_cone_Video_64", showVideoSettings ); } else if( [o_itemIdent isEqual: VLCOSDSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Subtitles & OSD"), _NS("Subtitles & On Screen Display Settings"), @"spref_cone_Subtitles_64", showOSDSettings ); } else if( [o_itemIdent isEqual: VLCInputSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Input & Codecs"), _NS("Input & Codec settings"), @"spref_cone_Input_64", showInputSettings ); } else if( [o_itemIdent isEqual: VLCHotkeysSettingToolbarIdentifier] ) { CreateToolbarItem( _NS("Hotkeys"), _NS("Hotkeys settings"), @"spref_cone_Hotkeys_64", showHotkeySettings ); } return o_toolbarItem;}- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar{ return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier, VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];}- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar{ return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier, VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];}- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar{ return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier, VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, nil];}- (void)initStrings{ /* audio */ [o_audio_dolby_txt setStringValue: _NS("Force detection of Dolby Surround")]; [o_audio_effects_box setTitle: _NS("Effects")]; [o_audio_enable_ckb setTitle: _NS("Enable Audio")]; [o_audio_general_box setTitle: _NS("General Audio")]; [o_audio_headphone_ckb setTitle: _NS("Headphone surround effect")]; [o_audio_lang_txt setStringValue: _NS("Preferred Audio language")]; [o_audio_last_ckb setTitle: _NS("Enable Last.fm submissions")]; [o_audio_lastpwd_txt setStringValue: _NS("Password")]; [o_audio_lastuser_txt setStringValue: _NS("User name")]; [o_audio_norm_ckb setTitle: _NS("Volume normalizer")]; [o_audio_spdif_ckb setTitle: _NS("Use S/PDIF when available")]; [o_audio_visual_txt setStringValue: _NS("Visualization")]; [o_audio_vol_txt setStringValue: _NS("Default Volume")]; /* hotkeys */ [o_hotkeys_change_btn setTitle: _NS("Change")]; [o_hotkeys_change_win setTitle: _NS("Change Hotkey")]; [o_hotkeys_change_cancel_btn setTitle: _NS("Cancel")]; [o_hotkeys_change_ok_btn setTitle: _NS("OK")]; [o_hotkeys_clear_btn setTitle: _NS("Clear")]; [o_hotkeys_lbl setStringValue: _NS("Select an action to change the associated hotkey:")]; [[[o_hotkeys_listbox tableColumnWithIdentifier: @"action"] headerCell] setStringValue: _NS("Action")]; [[[o_hotkeys_listbox tableColumnWithIdentifier: @"shortcut"] headerCell] setStringValue: _NS("Shortcut")]; /* input */ [o_input_access_box setTitle: _NS("Access Filter")]; [o_input_avi_txt setStringValue: _NS("Repair AVI Files")]; [o_input_bandwidth_ckb setTitle: _NS("Bandwidth limiter")]; [o_input_cachelevel_txt setStringValue: _NS("Default Caching Level")]; [o_input_caching_box setTitle: _NS("Caching")]; [o_input_cachelevel_custom_txt setStringValue: _NS("Use the complete preferences to configure custom caching values for each access module.")]; [o_input_dump_ckb setTitle: _NS("Dump")]; [o_input_httpproxy_txt setStringValue: _NS("HTTP Proxy")]; [o_input_httpproxypwd_txt setStringValue: _NS("Password for HTTP Proxy")]; [o_input_mux_box setTitle: _NS("Codecs / Muxers")]; [o_input_net_box setTitle: _NS("Network")]; [o_input_postproc_txt setStringValue: _NS("Post-Processing Quality")]; [o_input_record_ckb setTitle: _NS("Record")]; [o_input_rtsp_ckb setTitle: _NS("Use RTP over RTSP (TCP)")]; [o_input_serverport_txt setStringValue: _NS("Default Server Port")]; [o_input_timeshift_ckb setTitle: _NS("Timeshift")]; /* interface */ [o_intf_art_txt setStringValue: _NS("Album art download policy")]; [o_intf_embedded_ckb setTitle: _NS("Add controls to the video window")]; [o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")]; [o_intf_lang_txt setStringValue: _NS("Language")]; [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")]; /* Subtitles and OSD */ [o_osd_encoding_txt setStringValue: _NS("Default Encoding")]; [o_osd_font_box setTitle: _NS("Display Settings")]; [o_osd_font_btn setTitle: _NS("Browse...")]; [o_osd_font_color_txt setStringValue: _NS("Font Color")]; [o_osd_font_size_txt setStringValue: _NS("Font Size")]; [o_osd_font_txt setStringValue: _NS("Font")]; [o_osd_lang_box setTitle: _NS("Subtitle Languages")]; [o_osd_lang_txt setStringValue: _NS("Preferred Subtitle Language")]; [o_osd_osd_box setTitle: _NS("On Screen Display")]; [o_osd_osd_ckb setTitle: _NS("Enable OSD")]; /* video */ [o_video_black_ckb setTitle: _NS("Black screens in Fullscreen mode")]; [o_video_device_txt setStringValue: _NS("Fullscreen Video Device")]; [o_video_display_box setTitle: _NS("Display")]; [o_video_enable_ckb setTitle: _NS("Enable Video")]; [o_video_fullscreen_ckb setTitle: _NS("Fullscreen")]; [o_video_onTop_ckb setTitle: _NS("Always on top")]; [o_video_output_txt setStringValue: _NS("Output module")]; [o_video_skipFrames_ckb setTitle: _NS("Skip frames")]; [o_video_snap_box setTitle: _NS("Video snapshots")]; [o_video_snap_folder_btn setTitle: _NS("Browse...")]; [o_video_snap_folder_txt setStringValue: _NS("Folder")]; [o_video_snap_format_txt setStringValue: _NS("Format")]; [o_video_snap_prefix_txt setStringValue: _NS("Prefix")]; [o_video_snap_seqnum_ckb setTitle: _NS("Sequential numbering")]; /* generic stuff */ [[o_sprefs_basicFull_matrix cellAtRow: 0 column: 0] setStringValue: _NS("Basic")]; [[o_sprefs_basicFull_matrix cellAtRow: 0 column: 1] setStringValue: _NS("All")]; [o_sprefs_cancel_btn setTitle: _NS("Cancel")]; [o_sprefs_reset_btn setTitle: _NS("Reset All")]; [o_sprefs_save_btn setTitle: _NS("Save")]; [o_sprefs_win setTitle: _NS("Preferences")];}- (void)setupButton: (NSPopUpButton *)object forStringList: (const char *)name{ module_config_t *p_item; [object removeAllItems]; p_item = config_FindConfig( VLC_OBJECT(p_intf), name ); /* serious problem, if no item found */ assert( p_item ); for( int i = 0; i < p_item->i_list; i++ ) { NSMenuItem *mi; if( p_item->ppsz_list_text != NULL ) mi = [[NSMenuItem alloc] initWithTitle: _NS( p_item->ppsz_list_text[i] ) action:NULL keyEquivalent: @""]; else if( p_item->ppsz_list[i] && p_item->ppsz_list[i] == "" ) { [[object menu] addItem: [NSMenuItem separatorItem]]; continue; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -