diff options
author | dynaflash <[email protected]> | 2007-07-30 20:56:44 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-07-30 20:56:44 +0000 |
commit | cae08384433649c989276968854bee9045b619ee (patch) | |
tree | b5c65504f8f27efac7339b5a6e5f7008cd959a84 | |
parent | 8ae06e486523b4d062f2548a5080338a73d19aaa (diff) |
MacGui: Default Presets Initial Implementation
- Allows user to set a given preset as a default which will be used upon launch. As well, if user has not specified a preset as the default, HB will use the "HB - Normal" Built-in Preset at launch.
- Added the "Make Default" button at the bottom of the Presets Drawer.
- Default Preset is shown in Bold in the Presets Drawer
- Added a Select Default Preset command to the "Presets" Menu in the Menu Bar.
-- Note: the buttons and other display stuff is not set in stone, once again, initial function over form on intitial implementation.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@764 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/Controller.h | 13 | ||||
-rw-r--r-- | macosx/Controller.mm | 119 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 3 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/info.nib | 5 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/keyedobjects.nib | bin | 125838 -> 126589 bytes |
5 files changed, 130 insertions, 10 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 685e37ecd..24a2011c4 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -185,7 +185,7 @@ IBOutlet NSTextField * fX264optCabacLabel; IBOutlet NSButton * fX264optCabacSwitch; - /* User Preset variables here fPresetNewDesc*/ + /* User Preset variables here */ IBOutlet NSDrawer * fPresetDrawer; IBOutlet NSTextField * fPresetNewName; @@ -201,17 +201,22 @@ NSMutableArray * UserPresetssortedArray; NSMutableDictionary * chosenPreset; int curUserPresetChosenNum; - + + int presetHbDefault; // this is 1 in "Default" preset key + int presetUserDefault;// this is 2 in "Default" preset key IBOutlet NSPanel * fAddPresetPanel; IBOutlet NSTableView * tableView; IBOutlet NSButton * fPresetsAdd; IBOutlet NSButton * fPresetsDelete; + IBOutlet NSButton * fPresetMakeDefault; + hb_handle_t * fHandle; hb_title_t * fTitle; /* integer to set to determine the previous state of encode 0==idle, 1==encoding, 2==cancelled*/ int fEncodeState; int currentScanCount; + int currentSuccessfulScanCount; NSString * currentSource; HBOutputPanelController *outputPanel; @@ -304,7 +309,8 @@ - (NSDictionary *)CreateiPhonePreset; - (IBAction) RevertPictureSizeToMax:(id)sender; - +- (IBAction)SetDefaultPreset:(id)sender; +- (IBAction)SelectDefaultPreset:(id)sender; - (void) savePreset; - (IBAction)AddFactoryPresets:(id)sender; - (IBAction)DeleteFactoryPresets:(id)sender; @@ -312,6 +318,7 @@ - (void)AddPreset; - (IBAction)InsertPreset:(id)sender; - (IBAction)DeletePreset:(id)sender; +- (IBAction)GetDefaultPresets:(id)sender; - (IBAction)tableViewSelected:(id)sender; // NSTableDataSource methods - (int)numberOfRowsInTableView:(NSTableView *)aTableView; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index fa0f94230..b48dd7a90 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -134,7 +134,6 @@ static NSString* ChooseSourceIdentifier = @"Choose Source Item Identifie [self TranslateStrings]; currentScanCount = 0; -//[self registrationDictionaryForGrowl]; /* Init User Presets .plist */ /* We declare the default NSFileManager into fileManager */ NSFileManager * fileManager = [NSFileManager defaultManager]; @@ -180,6 +179,9 @@ static NSString* ChooseSourceIdentifier = @"Choose Source Item Identifie UserPresets = [[NSMutableArray alloc] init]; [self AddFactoryPresets:NULL]; } + + + /* Show/Dont Show Presets drawer upon launch based on user preference DefaultPresetsDrawerShow*/ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0) @@ -282,8 +284,16 @@ static NSString* ChooseSourceIdentifier = @"Choose Source Item Identifie /* We disable the Turbo 1st pass checkbox since we are not x264 */ [fVidTurboPassCheck setEnabled: NO]; [fVidTurboPassCheck setState: NSOffState]; + + + /* lets get our default prefs here */ + [self GetDefaultPresets: NULL]; + /* lets initialize the current successful scancount here to 0 */ + currentSuccessfulScanCount = 0; + } + // ============================================================ // NSToolbar Related Methods // ============================================================ @@ -888,6 +898,11 @@ list = hb_get_titles( fHandle ); } else { + /* We increment the successful scancount here by one, + which we use at the end of this function to tell the gui + if this is the first successful scan since launch and whether + or not we should set all settings to the defaults */ + currentSuccessfulScanCount++; [fSrcTitlePopUp removeAllItems]; for( int i = 0; i < hb_list_count( list ); i++ ) @@ -991,6 +1006,13 @@ list = hb_get_titles( fHandle ); /* we record the current source name here in case the next scan is unsuccessful, then we can replace the scan progress with the old name if necessary */ sourceDisplayName = [NSString stringWithFormat:[fSrcDVD2Field stringValue]]; + + + /* if its the initial successful scan after awakeFromNib */ + if (currentSuccessfulScanCount == 1) + { + [self SelectDefaultPreset: NULL]; + } } } @@ -2418,6 +2440,7 @@ the user is using "Custom" settings by determining the sender*/ { /* Deselect the currently selected Preset if there is one*/ [tableView deselectRow:[tableView selectedRow]]; + [fPresetMakeDefault setEnabled: NO]; /* Change UI to show "Custom" settings are being used */ [fPresetSelectedDisplay setStringValue: @"Custom"]; @@ -3937,7 +3960,7 @@ the user is using "Custom" settings by determining the sender*/ /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/ [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"]; /*Set whether or not this is default, at creation set to 0*/ - [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"]; /*Get the whether or not to apply pic settings in the AddPresetPanel*/ [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"]; /* Get the New Preset Description from the field in the AddPresetPanel */ @@ -4503,6 +4526,70 @@ the user is using "Custom" settings by determining the sender*/ [self savePreset]; } } + +- (IBAction)GetDefaultPresets:(id)sender +{ + int i = 0; + NSEnumerator *enumerator = [UserPresets objectEnumerator]; + id tempObject; + while (tempObject = [enumerator nextObject]) + { + NSDictionary *thisPresetDict = tempObject; + if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default + { + presetHbDefault = i; + } + if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default + { + presetUserDefault = i; + } + i++; + } +} + +- (IBAction)SetDefaultPreset:(id)sender +{ + int i = 0; + NSEnumerator *enumerator = [UserPresets objectEnumerator]; + id tempObject; + /* First make sure the old user specified default preset is removed */ + while (tempObject = [enumerator nextObject]) + { + /* make sure we are not removing the default HB preset */ + if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default + { + [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"]; + } + i++; + } + /* Second, go ahead and set the appropriate user specfied preset */ + /* we get the chosen preset from the UserPresets array */ + if ([[[UserPresets objectAtIndex:[tableView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default + { + [[UserPresets objectAtIndex:[tableView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"]; + } + + + /* We save all of the preset data here */ + [self savePreset]; + /* We Reload the New Table data for presets */ + [tableView reloadData]; +} + +- (IBAction)SelectDefaultPreset:(id)sender +{ + if (presetUserDefault) + { + [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO]; + [self tableViewSelected:NULL]; + } + else if (presetHbDefault) // we use the built in default presetHbDefault + { + [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO]; + [self tableViewSelected:NULL]; + } +} + - (IBAction)tableViewSelected:(id)sender { /* Since we cannot disable the presets tableView in terms of clickability @@ -4512,10 +4599,18 @@ the user is using "Custom" settings by determining the sender*/ { /* we get the chosen preset from the UserPresets array */ - chosenPreset = [UserPresets objectAtIndex:[sender selectedRow]]; + chosenPreset = [UserPresets objectAtIndex:[tableView selectedRow]]; curUserPresetChosenNum = [sender selectedRow]; /* we set the preset display field in main window here */ [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]]; + if ([[chosenPreset objectForKey:@"Default"] intValue] == 1) + { + [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@ (Default)",[chosenPreset valueForKey:@"PresetName"]]]; + } + else + { + [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]]; + } /* File Format */ [fDstFormatPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileFormat"]]]; [self FormatPopUpChanged: NULL]; @@ -4622,7 +4717,7 @@ the user is using "Custom" settings by determining the sender*/ } - +[fPresetMakeDefault setEnabled: YES]; } } @@ -4642,8 +4737,10 @@ show the built in presets in a blue font. */ forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { NSDictionary *userPresetDict = [UserPresets objectAtIndex:rowIndex]; + NSFont *txtFont; NSColor *fontColor; NSColor *shadowColor; + txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]; /* First, we check to see if its a selected row, if so, we use white since its highlighted in blue */ if ([[aTableView selectedRowIndexes] containsIndex:rowIndex] && ([tableView editedRow] != rowIndex)) { @@ -4665,7 +4762,19 @@ show the built in presets in a blue font. */ } shadowColor = nil; } + /* We check to see if this is the HB default, if so, color it appropriately */ + if (!presetUserDefault && presetHbDefault && rowIndex == presetHbDefault) + { + txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]]; + } + /* We check to see if this is the User Specified default, if so, color it appropriately */ + if (presetUserDefault && rowIndex == presetUserDefault) + { + txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]]; + } + [aCell setTextColor:fontColor]; + [aCell setFont:txtFont]; /* this shadow stuff (like mail app) for some reason looks crappy, commented out temporarily in case we want to resurrect it */ /* @@ -4738,6 +4847,8 @@ id theRecord, theValue; - (void)savePreset { [UserPresets writeToFile:UserPresetsFile atomically:YES]; + /* We get the default preset in case it changed */ + [self GetDefaultPresets: NULL]; } diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index f7a627c78..de7c2c62e 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -29,6 +29,8 @@ QualitySliderChanged = id; RevertPictureSizeToMax = id; Rip = id; + SelectDefaultPreset = id; + SetDefaultPreset = id; SetEnabledStateOfAudioMixdownControls = id; ShowAddPresetPanel = id; ShowNewScan = id; @@ -104,6 +106,7 @@ fPictureController = PictureController; fPicturePanel = NSPanel; fPresetDrawer = NSDrawer; + fPresetMakeDefault = NSButton; fPresetNewDesc = NSTextField; fPresetNewName = NSTextField; fPresetNewPicSettingsPopUp = NSPopUpButton; diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib index c3dd297fa..56fe64055 100644 --- a/macosx/English.lproj/MainMenu.nib/info.nib +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>61 34 630 601 0 0 1440 878 </string> + <string>44 271 630 601 0 0 1440 878 </string> <key>IBEditorPositions</key> <dict> <key>1843</key> @@ -26,8 +26,7 @@ <key>IBOpenObjects</key> <array> <integer>29</integer> - <integer>21</integer> - <integer>1162</integer> + <integer>1843</integer> </array> <key>IBSystem Version</key> <string>8R2218</string> diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib Binary files differindex 6dd2c8c57..a1e228f74 100644 --- a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib +++ b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib |