Skip to content

Commit

Permalink
Windows GUI: Add DisplayCaptions option
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed Jun 26, 2024
1 parent 9050096 commit 4e6c8c0
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 33 deletions.
94 changes: 62 additions & 32 deletions Source/GUI/Cocoa/English.lproj/Preferences.xib

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Source/GUI/Cocoa/MyWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,12 @@ -(void)processFiles:(NSArray *)URLs {
if(!mediaList)
mediaList = [[oMediaInfoList alloc] init]; //dont care about release

if ([[NSUserDefaults standardUserDefaults] stringForKey:@"displayCaptions"]!=nil)
{
NSString *value = [[NSUserDefaults standardUserDefaults] stringForKey:@"displayCaptions"];
[oMediaInfoList setOption:@"File_DisplayCaptions" withValue:value];
}

NSInteger oldCount = [mediaList count];

if([URLs count]==1 && [[NSFileManager defaultManager] fileExistsAtPath:[URLs[0] path]]) {
Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/Cocoa/PreferencesWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
IBOutlet NSButton *graphAdmShowTrackUIDs;
IBOutlet NSButton *graphAdmShowChannelFormats;
IBOutlet NSButton *subscribeButton;

IBOutlet NSPopUpButton *displayCaptionsCombo;
NSMutableArray *observers;
}

Expand Down
34 changes: 34 additions & 0 deletions Source/GUI/Cocoa/PreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ - (void)windowDidLoad
}
}

//DisplayCaptions
[self addCaptionsOptionToComboWithTitle:@"When content is detected" andValue:@"Content"];
[self addCaptionsOptionToComboWithTitle:@"When content or a command is detected" andValue:@"Command"];
[self addCaptionsOptionToComboWithTitle:@"Even when no content or command is detected" andValue:@"Stream"];

NSString *savedCaptionsOption = [[NSUserDefaults standardUserDefaults] objectForKey:@"displayCaptions"];
if(savedCaptionsOption == nil)
savedCaptionsOption = @"Command";

for(NSMenuItem *i in [[displayCaptionsCombo menu] itemArray]) {
if([[i representedObject] isEqualToString:savedCaptionsOption]) {
[displayCaptionsCombo selectItem:i];
break;
}
}

// Graph options
BOOL savedGraphAdmShowTrackUIDs = [[NSUserDefaults standardUserDefaults] boolForKey:@"graphAdmShowTrackUIDs"];
[graphAdmShowTrackUIDs setState:savedGraphAdmShowTrackUIDs?NSControlStateValueOn:NSControlStateValueOff];
Expand Down Expand Up @@ -175,6 +191,13 @@ - (void)addLanguageToComboWithTitle:(NSString*)title andValue:(NSString*)value {
[item release];
}

- (void)addCaptionsOptionToComboWithTitle:(NSString*)title andValue:(NSString*)value {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
[item setRepresentedObject:value];
[[displayCaptionsCombo menu] addItem:item];
[item release];
}

- (IBAction)languageChanged:(id)sender {

NSMenuItem *obj = [langsCombo selectedItem];
Expand Down Expand Up @@ -202,6 +225,17 @@ - (IBAction)viewChanged:(id)sender {

[[NSUserDefaults standardUserDefaults] setObject:value forKey:@"defaultView"];
}

- (IBAction)captionsOptionChanged:(id)sender {
NSMenuItem *obj = [displayCaptionsCombo selectedItem];
NSString *value = [obj representedObject];

if (!value)
value = @"Command";

[[NSUserDefaults standardUserDefaults] setObject:value forKey:@"displayCaptions"];
}

- (IBAction)subscribeClicked:(id)sender {
if (@available(macOS 10.9, *)) {
[[SubscribeWindowController controller] show];
Expand Down
3 changes: 3 additions & 0 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ void __fastcall TMainF::Refresh(TTabSheet *Page)
if (!Prefs->Config(__T("EnableFfmpeg")).empty())
I->Option_Static(__T("Enable_Ffmpeg"), Prefs->Config(__T("EnableFfmpeg")));

if (!Prefs->Config(__T("DisplayCaptions")).empty())
I->Option(__T("File_DisplayCaptions"), Prefs->Config(__T("DisplayCaptions")));

//Easy
if (Page==Page_Easy)
{
Expand Down
24 changes: 24 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,17 @@ void __fastcall TPreferencesF::Advanced_EnableFfmpegClick(TObject *Sender)
}
}

//---------------------------------------------------------------------------
void __fastcall TPreferencesF::Advanced_DisplayCaptions_SelChange(TObject *Sender)
{
if (Advanced_DisplayCaptions_Sel->ItemIndex==0)
Prefs->Config(__T("DisplayCaptions"))=__T("Content");
else if (Advanced_DisplayCaptions_Sel->ItemIndex==1)
Prefs->Config(__T("DisplayCaptions"))=__T("Command");
else if (Advanced_DisplayCaptions_Sel->ItemIndex==2)
Prefs->Config(__T("DisplayCaptions"))=__T("Stream");
}

//---------------------------------------------------------------------------
void __fastcall TPreferencesF::Language_NewClick(TObject *Sender)
{
Expand Down Expand Up @@ -621,6 +632,14 @@ void __fastcall TPreferencesF::Setup_AdvancedShow(TObject *Sender)
Advanced_InformVersion->Checked=Prefs->Config(__T("InformVersion")).To_int32s();
Advanced_InformTimestamp->Checked=Prefs->Config(__T("InformTimestamp")).To_int32s();
Advanced_EnableFfmpeg->Checked=Prefs->Config(__T("EnableFfmpeg")).To_int32s();

//Display captions
if (Prefs->Config(__T("DisplayCaptions"))==__T("Content"))
Advanced_DisplayCaptions_Sel->ItemIndex=0;
else if (Prefs->Config(__T("DisplayCaptions"))==__T("Stream"))
Advanced_DisplayCaptions_Sel->ItemIndex=2;
else // Command (default)
Advanced_DisplayCaptions_Sel->ItemIndex=1;
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -736,6 +755,11 @@ void __fastcall TPreferencesF::GUI_Configure()
Advanced_InformVersion->Caption=Prefs->Translate(__T("Add version to text output")).c_str();
Advanced_InformTimestamp->Caption=Prefs->Translate(__T("Add creation date to text output")).c_str();
Advanced_EnableFfmpeg->Caption=Prefs->Translate(__T("Enable FFmpeg plugin")).c_str();
Advanced_DisplayCaptions_Caption->Caption=Prefs->Translate(__T("Handling of 608/708 streams:")).c_str();
Advanced_DisplayCaptions_Sel->Items->Clear();
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("When content is detected")).c_str());
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("When content or a command is detected")).c_str());
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("Even when no content or command is detected")).c_str());
//-Language
Language_Caption->Caption=Prefs->Translate(__T("Choose language")).c_str();
Language_Edit->Caption=(Prefs->Translate(__T("Edit"))+__T("...")).c_str();
Expand Down
21 changes: 21 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,27 @@ object PreferencesF: TPreferencesF
TabOrder = 4
OnClick = Advanced_EnableFfmpegClick
end
object LanguAdvanced_DisplayCaptions_Caption: TLabel
Left = 0
Top = 131
Width = 200
Height = 14
Caption = 'Handling of 608/708 streams:'
end
object Advanced_DisplayCaptions_Sel: TComboBox
Left = 200
Top = 127
Width = 290
Height = 22
Style = csDropDownList
DropDownCount = 10
TabOrder = 1
OnChange = Advanced_DisplayCaptions_SelChange
Items.Strings = (
'When content is detected'
'When content or a command is detected'
'Even when no content or command is detected')
end
end
object Customize_Language: TTabSheet
Caption = 'Language'
Expand Down
3 changes: 3 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class TPreferencesF : public TForm
TCheckBox *Advanced_InformVersion;
TCheckBox *Advanced_InformTimestamp;
TCheckBox *Advanced_EnableFfmpeg;
TLabel *Advanced_DisplayCaptions_Caption;
TComboBox *Advanced_DisplayCaptions_Sel;
TTabSheet *Customize_Language;
TLabel *Language_Caption;
TButton *Language_New;
Expand Down Expand Up @@ -93,6 +95,7 @@ class TPreferencesF : public TForm
void __fastcall Advanced_InformVersionClick(TObject *Sender);
void __fastcall Advanced_InformTimestampClick(TObject *Sender);
void __fastcall Advanced_EnableFfmpegClick(TObject *Sender);
void __fastcall Advanced_DisplayCaptions_SelChange(TObject *Sender);
void __fastcall Graph_Adm_ShowTrackUIDsClick(TObject *Sender);
void __fastcall Graph_Adm_ShowChannelFormatsClick(TObject *Sender);
void __fastcall Setup_GeneralShow(TObject *Sender);
Expand Down
4 changes: 4 additions & 0 deletions Source/Resource/Plugin/Language/en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ EPG_Positions;EPG positions (internal)
EpisodeTitleNumber;Episode Title Number
Error_File;Error while reading file
Error_File_Write;Error while writing file
Even when no content or command is detected;Even when no content or command is detected
Events_MinDuration;Minimum duration per event
Events_PaintOn;Count of PaintOn events
Events_PopOn;Count of PopOn events
Expand Down Expand Up @@ -695,6 +696,7 @@ Group;Group
Grouping;Grouping
GroupPreset;Group preset
h; h
Handling of 608/708 streams:;Handling of 608/708 streams:
HDR_Format;HDR format
Header file;Create a header file
Height;Height
Expand Down Expand Up @@ -1352,6 +1354,8 @@ WebSite_Text_More;Go to the web site (%Url%) to find this text codec
WebSite_Url;http://MediaArea.net/MediaInfo
WebSite_Video;Go to the web site of this video codec
WebSite_Video_More;Go to the web site (%Url%) to find this video codec
When content is detected;When content is detected
When content or a command is detected;When content or a command is detected
Width;Width
Width_CleanAperture;Clean aperture width
Width_Original;Original width
Expand Down

0 comments on commit 4e6c8c0

Please sign in to comment.