Skip to content

Commit

Permalink
Add captions display options
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <gervais.maxime@gmail.com>
  • Loading branch information
g-maxime committed Jun 26, 2024
1 parent c45073d commit e6f37e5
Show file tree
Hide file tree
Showing 53 changed files with 497 additions and 46 deletions.
12 changes: 12 additions & 0 deletions Source/GUI/Cocoa/English.lproj/Preferences.strings
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@

/* Class = "NSButtonCell"; title = "subscribe"; ObjectID = "qvF-It-rlQ"; */
"qvF-It-rlQ.title" = "subscribe";

/* Class = "NSTextFieldCell"; title = "Handling of 608/708 streams:"; ObjectID = "FSN-9S-Ykj"; */
"FSN-9S-Ykj.title" = "Handling of 608/708 streams:";

/* Class = "NSMenuItem"; title = "When content or a command is detected"; ObjectID = "I2h-Au-EAa"; */
"I2h-Au-EAa.title" = "When content or a command is detected";

/* Class = "NSMenuItem"; title = "When content is detected"; ObjectID = "8Ua-A2-6V9"; */
"8Ua-A2-6V9.title" = "When content is detected";

/* Class = "NSMenuItem"; title = "Even when no content or command is detected"; ObjectID = "sik-bk-btb"; */
"sik-bk-btb.title" = "Even when no content or command is detected";
107 changes: 75 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"];
[mediaList 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
26 changes: 26 additions & 0 deletions Source/GUI/Cocoa/PreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ - (void)windowDidLoad
}
}

//DisplayCaptions
[[[displayCaptionsCombo menu] itemWithTag:1] setRepresentedObject:@"Command"];
[[[displayCaptionsCombo menu] itemWithTag:2] setRepresentedObject:@"Content"];
[[[displayCaptionsCombo menu] itemWithTag:3] setRepresentedObject:@"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 @@ -202,6 +217,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
4 changes: 4 additions & 0 deletions Source/GUI/Cocoa/_i18n/stringsdb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ Preferences.strings/54.title=txt/LanguageChanges//Changes take effect after appl
Preferences.strings/eaf-m0-xtv.title=txt/PremiumFeature//Premium MediaInfo feature
Preferences.strings/mz3-nf-7kH.title=txt/DefaultView//Default view:
Preferences.strings/qvF-It-rlQ.title=csv/Subscribe//subscribe
Preferences.strings/FSN-9S-Ykj.title=csv/DisplayCaptions//Handling of 608/708 streams:
Preferences.strings/I2h-Au-EAa.title=csv/DisplayCaptions_Command//When content or a command is detected
Preferences.strings/8Ua-A2-6V9.title=csv/DisplayCaptions_Content//When content is detected
Preferences.strings/sik-bk-btb.title=csv/DisplayCaptions_Stream//Even when no content or command is detected
ProgressDialog.strings/F0z-JX-Cv5.title=skip/F0z-JX-Cv5.title//Window
ProgressDialog.strings/ojc-pE-bUU.title=csv/Cancel//Cancel
ServicesMenu.strings/Analyze with MediaInfo=txt/AnalyzeServicesMenu//Analyze with MediaInfo
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("Command");
else if (Advanced_DisplayCaptions_Sel->ItemIndex==1)
Prefs->Config(__T("DisplayCaptions"))=__T("Content");
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=1;
else if (Prefs->Config(__T("DisplayCaptions"))==__T("Stream"))
Advanced_DisplayCaptions_Sel->ItemIndex=2;
else // Command (default)
Advanced_DisplayCaptions_Sel->ItemIndex=0;
}

//---------------------------------------------------------------------------
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("DisplayCaptions")).c_str();
Advanced_DisplayCaptions_Sel->Items->Clear();
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("DisplayCaptions_Command")).c_str());
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("DisplayCaptions_Content")).c_str());
Advanced_DisplayCaptions_Sel->Items->Add(Prefs->Translate(__T("DisplayCaptions_Stream")).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 Advanced_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 = 285
Height = 22
Style = csDropDownList
DropDownCount = 10
TabOrder = 1
OnChange = Advanced_DisplayCaptions_SelChange
Items.Strings = (
'When content or a command is detected'
'When content 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
27 changes: 27 additions & 0 deletions Source/GUI/WxWidgets/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ GUI_Main::GUI_Main(int argc, MediaInfoNameSpace::Char** argv_ansi, const wxPoint
OnMenu_View_Easy(*EventTemp);
}

wxString displayCaptionsOption = pConfig->Read(wxT("/DisplayCaptions"), wxT("Command"));
if (displayCaptionsOption==wxT("Command"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Command"));
else if (displayCaptionsOption==wxT("Content"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Content"));
else if (displayCaptionsOption==wxT("Stream"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Stream"));

delete EventTemp; //This is done to be GCC-compatible...
Menu_Debug_Demux_None->Check(); //Default to no Debug Demux
Expand Down Expand Up @@ -248,3 +255,23 @@ void GUI_Main::OnSize(wxSizeEvent& WXUNUSED(event))
if (View && IsShown())
View->GUI_Resize();
}

//***************************************************************************
// Helpers
//***************************************************************************

//---------------------------------------------------------------------------
void GUI_Main::View_Refresh()
{
wxConfigBase *pConfig = wxConfigBase::Get();

wxString displayCaptionsOption = pConfig->Read(wxT("/DisplayCaptions"), wxT("Command"));
if (displayCaptionsOption==wxT("Command"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Command"));
else if (displayCaptionsOption==wxT("Content"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Content"));
else if (displayCaptionsOption==wxT("Stream"))
C->MI->Option(__T("File_DisplayCaptions"), __T("Stream"));

View->GUI_Refresh();
}
2 changes: 1 addition & 1 deletion Source/GUI/WxWidgets/GUI_Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class GUI_Main : public wxFrame
void ToolBar_Create();

//Helpers
void View_Refresh() {View->GUI_Refresh();}
void View_Refresh();

private:
//Non-GUI Elements
Expand Down
1 change: 1 addition & 0 deletions Source/GUI/WxWidgets/GUI_Main_Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void GUI_Main::OnMenu_File_Preferences(wxCommandEvent& WXUNUSED(event))
{
PreferencesEditor=new wxPreferencesEditor(wxT("Preferences"));
PreferencesEditor->AddPage(new GUI_Preferences_Page_General(this));
PreferencesEditor->AddPage(new GUI_Preferences_Page_Advanced(this));
}

PreferencesEditor->Show(this);
Expand Down
96 changes: 95 additions & 1 deletion Source/GUI/WxWidgets/GUI_Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,85 @@ void GUI_Preference_Panel_General::ChangeTextSize(wxCommandEvent&)
UpdateSettingsIfNecessary();
}

//***************************************************************************
// GUI_Preference_Panel_Advanced
//***************************************************************************

//---------------------------------------------------------------------------
GUI_Preference_Panel_Advanced::GUI_Preference_Panel_Advanced(wxWindow* Parent, GUI_Main* Main) : wxPanel(Parent), Main(Main)
{
// Init
wxSizer* Sizer=new wxBoxSizer(wxVERTICAL);

// Captions display option
DisplayCaptionsLabel=new wxStaticText(this, wxID_ANY, wxT("Handling of 608/708 streams:"));
wxString DisplayCaptionsOptions[]=
{
wxT("When content or a command is detected"),
wxT("When content is detected"),
wxT("Even when no content or command is detected")
};
DisplayCaptionsComboBox=new wxComboBox(this, wxID_ANY, wxT("Select an option"), wxDefaultPosition,
wxDefaultSize, WXSIZEOF(DisplayCaptionsOptions), DisplayCaptionsOptions, wxCB_READONLY);
DisplayCaptionsComboBox->Bind(wxEVT_COMBOBOX, &GUI_Preference_Panel_Advanced::ChangeCaptionsDisplayOption, this);


Sizer->Add(DisplayCaptionsLabel, 0, wxALL | wxALIGN_LEFT, 20);
Sizer->Add(DisplayCaptionsComboBox, 0, wxALL | wxEXPAND, 20);
SetSizerAndFit(Sizer);
}

//---------------------------------------------------------------------------
bool GUI_Preference_Panel_Advanced::TransferDataToWindow()
{
wxConfigBase* Config=wxConfigBase::Get();

wxString View=Config->Read(wxT("/DisplayCaptions"), wxT("Command"));
if (View==wxT("Command"))
DisplayCaptionsComboBox->SetSelection(0);
else if (View==wxT("Content"))
DisplayCaptionsComboBox->SetSelection(1);
else if (View==wxT("Stream"))
DisplayCaptionsComboBox->SetSelection(2);
else
DisplayCaptionsComboBox->SetSelection(0);

return true;
}

//---------------------------------------------------------------------------
bool GUI_Preference_Panel_Advanced::TransferDataFromWindow()
{
wxConfigBase* Config=wxConfigBase::Get();
if (Config==NULL)
return false;

switch (DisplayCaptionsComboBox->GetSelection())
{
case 0: Config->Write(wxT("/DisplayCaptions"), wxT("Command")); break;
case 1: Config->Write(wxT("/DisplayCaptions"), wxT("Content")); break;
case 2: Config->Write(wxT("/DisplayCaptions"), wxT("Stream")); break;
default: Config->Write(wxT("/DisplayCaptions"), wxT("Command")); break;
}

Main->View_Refresh();

return true;
}

//---------------------------------------------------------------------------
void GUI_Preference_Panel_Advanced::UpdateSettingsIfNecessary()
{
if (wxPreferencesEditor::ShouldApplyChangesImmediately())
TransferDataFromWindow();
}

//---------------------------------------------------------------------------
void GUI_Preference_Panel_Advanced::ChangeCaptionsDisplayOption(wxCommandEvent&)
{
UpdateSettingsIfNecessary();
}

//***************************************************************************
// GUI_Preferences_Page_General
//***************************************************************************
Expand All @@ -208,4 +287,19 @@ GUI_Preferences_Page_General::GUI_Preferences_Page_General(GUI_Main* Main) : wxS
wxWindow* GUI_Preferences_Page_General::CreateWindow(wxWindow* Parent)
{
return new GUI_Preference_Panel_General(Parent, Main);
}
}

//***************************************************************************
// GUI_Preferences_Page_Advanced
//***************************************************************************

//---------------------------------------------------------------------------
GUI_Preferences_Page_Advanced::GUI_Preferences_Page_Advanced(GUI_Main* Main) : wxStockPreferencesPage(Kind_Advanced), Main(Main)
{
}

//---------------------------------------------------------------------------
wxWindow* GUI_Preferences_Page_Advanced::CreateWindow(wxWindow* Parent)
{
return new GUI_Preference_Panel_Advanced(Parent, Main);
}
35 changes: 35 additions & 0 deletions Source/GUI/WxWidgets/GUI_Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ class GUI_Preference_Panel_General : public wxPanel
wxComboBox* SizesComboBox;
};

//***************************************************************************
// GUI_Preference_Panel_Advanced
//***************************************************************************

class GUI_Preference_Panel_Advanced : public wxPanel
{
public:
GUI_Preference_Panel_Advanced(wxWindow* Parent, GUI_Main* Main);
virtual bool TransferDataToWindow() override;
virtual bool TransferDataFromWindow() override;

private:
void UpdateSettingsIfNecessary();
void ChangeCaptionsDisplayOption(wxCommandEvent&);

GUI_Main* Main;
wxStaticText* DisplayCaptionsLabel;
wxComboBox* DisplayCaptionsComboBox;
};


//***************************************************************************
// GUI_Preferences_Page_General
//***************************************************************************
Expand All @@ -65,4 +86,18 @@ class GUI_Preferences_Page_General : public wxStockPreferencesPage
GUI_Main* Main;
};

//***************************************************************************
// GUI_Preferences_Page_Advanced
//***************************************************************************

class GUI_Preferences_Page_Advanced : public wxStockPreferencesPage
{
public:
GUI_Preferences_Page_Advanced(GUI_Main* Main);
virtual wxWindow *CreateWindow(wxWindow* Parent) override;

private:
GUI_Main* Main;
};

#endif
Loading

0 comments on commit e6f37e5

Please sign in to comment.