Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix GUI: Add preferences dialog #799

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project/GNU/GUI/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mediainfo_gui_SOURCES = \
../../../Source/GUI/WxWidgets/GUI_Main_Sheet.cpp \
../../../Source/GUI/WxWidgets/GUI_Main_Text.cpp \
../../../Source/GUI/WxWidgets/GUI_Main_Tree.cpp \
../../../Source/GUI/WxWidgets/GUI_Preferences.cpp \
../../../Source/CLI/CommandLine_Parser.cpp \
../../../Source/CLI/Help.cpp \
../../../Source/Common/Core.cpp
Expand Down
98 changes: 2 additions & 96 deletions Source/GUI/WxWidgets/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

//---------------------------------------------------------------------------
#include "wx/wxprec.h"
#include "wx/preferences.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
Expand Down Expand Up @@ -78,6 +79,7 @@ GUI_Main::GUI_Main(int argc, MediaInfoNameSpace::Char** argv_ansi, const wxPoint

//GUI
View=NULL;
PreferencesEditor=NULL;
CenterOnScreen();

//Drag and Drop
Expand Down Expand Up @@ -232,102 +234,6 @@ GUI_Main::GUI_Main(int argc, MediaInfoNameSpace::Char** argv_ansi, const wxPoint
//---------------------------------------------------------------------------
GUI_Main::~GUI_Main()
{

//Save view state
wxConfig *config = new wxConfig(wxT("mediainfo-gui"));


wxConfigBase *pConfig = wxConfigBase::Get();
if ( pConfig == NULL )
{
return;
}

bool rememberView;
if ( !pConfig->Read(wxT("rememberView"), &rememberView))
{
rememberView=1;
pConfig->Write(wxT("/rememberView"), 1);
}

if (rememberView == 1)
{
enum Core::kind currentView = C->Kind_Get();

switch (currentView)
{
case 0:
pConfig->Write(wxT("/View"), wxT("Easy"));
break;
case 1:
pConfig->Write(wxT("/View"), wxT("Sheet"));
break;
case 2:
pConfig->Write(wxT("/View"), wxT("Tree"));
break;
case 3:
pConfig->Write(wxT("/View"), wxT("HTML"));
break;
case 4:
pConfig->Write(wxT("/View"), wxT("Text"));
break;
case 5:
pConfig->Write(wxT("/View"), wxT("XML"));
break;
case 6:
pConfig->Write(wxT("/View"), wxT("JSON"));
break;
case 7:
pConfig->Write(wxT("/View"), wxT("PBCore"));
break;
case 8:
pConfig->Write(wxT("/View"), wxT("PBCore2"));
break;
case 9:
pConfig->Write(wxT("/View"), wxT("reVTMD"));
break;
case 10:
pConfig->Write(wxT("/View"), wxT("MPEG7_Strict"));
break;
case 11:
pConfig->Write(wxT("/View"), wxT("MPEG7_Relaxed"));
break;
case 12:
pConfig->Write(wxT("/View"), wxT("MPEG7_Extended"));
break;
case 13:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_5"));
break;
case 14:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_6"));
break;
case 15:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_8_ps"));
break;
case 16:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_8_sp"));
break;
case 17:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_8_ps_json"));
break;
case 18:
pConfig->Write(wxT("/View"), wxT("EBUCore_1_8_sp_json"));
break;
case 19:
pConfig->Write(wxT("/View"), wxT("FIMS_1_1"));
break;
case 20:
pConfig->Write(wxT("/View"), wxT("FIMS_1_2"));
break;
case 21:
pConfig->Write(wxT("/View"), wxT("FIMS_1_3"));
break;
case 22:
pConfig->Write(wxT("/View"), wxT("NISO_Z39_87"));
break;
}
}

delete C; //C=NULL;
delete View; //View=NULL;
}
Expand Down
5 changes: 5 additions & 0 deletions Source/GUI/WxWidgets/GUI_Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

//---------------------------------------------------------------------------
#include "GUI/Common/GUI_Main_Common_Core.h"
#include "wx/preferences.h"
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -62,6 +63,7 @@ class GUI_Main : public wxFrame
wxMenu* Menu_File_Open;
wxMenuItem* Menu_File_Open_Files;
wxMenuItem* Menu_File_Open_Directory;
wxMenuItem* Menu_File_Preferences;
wxMenuItem* Menu_File_Quit;
wxMenu* Menu_View;
wxMenuItem* Menu_View_Easy;
Expand Down Expand Up @@ -105,6 +107,7 @@ class GUI_Main : public wxFrame
void Menu_Create();
void OnMenu_File_Open_Files (wxCommandEvent &event);
void OnMenu_File_Open_Directory (wxCommandEvent &event);
void OnMenu_File_Preferences (wxCommandEvent &event);
void OnMenu_File_Quit (wxCommandEvent &event);
void OnMenu_View_Easy (wxCommandEvent &event);
void OnMenu_View_Sheet (wxCommandEvent &event);
Expand Down Expand Up @@ -156,6 +159,8 @@ class GUI_Main : public wxFrame
//GUI
GUI_Main_Common_Core* View;

wxPreferencesEditor* PreferencesEditor;

//wxWidgets
DECLARE_EVENT_TABLE() //Any class wishing to process wxWindows events must use this macro
};
Expand Down
3 changes: 0 additions & 3 deletions Source/GUI/WxWidgets/GUI_Main_HTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ GUI_Main_HTML::GUI_Main_HTML(Core* Core_, wxWindow* parent)
: wxHtmlWindow(parent, -1, wxPoint(1, 1), wxSize(parent->GetClientSize().GetWidth()-1, parent->GetClientSize().GetHeight()-1)),
GUI_Main_Common_Core(Core_)
{
int Size[7]={ 7, 8, 10, 12, 16, 22, 30};
SetFonts(wxEmptyString, wxEmptyString, Size);

//Drag and Drop
#if wxUSE_DRAG_AND_DROP && defined(__WXMAC__)
SetDropTarget(new FileDrop(C));
Expand Down
17 changes: 17 additions & 0 deletions Source/GUI/WxWidgets/GUI_Main_Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "GUI/WxWidgets/GUI_Main_Tree.h"
#include "GUI/WxWidgets/GUI_Main_HTML.h"
#include "GUI/WxWidgets/GUI_Main_Text.h"
#include "GUI/WxWidgets/GUI_Preferences.h"
#include "Common/Core.h"
#include <wx/image.h>
//---------------------------------------------------------------------------
Expand All @@ -33,6 +34,7 @@ enum
ID_Menu_File_Open,
ID_Menu_File_Open_Files,
ID_Menu_File_Open_Directory,
ID_Menu_File_Preferences,
ID_Menu_File_Quit,
ID_Menu_View_Easy,
ID_Menu_View_Sheet,
Expand Down Expand Up @@ -73,6 +75,7 @@ BEGIN_EVENT_TABLE(GUI_Main, wxFrame)
//Menu
EVT_MENU(ID_Menu_File_Open_Files, GUI_Main::OnMenu_File_Open_Files)
EVT_MENU(ID_Menu_File_Open_Directory, GUI_Main::OnMenu_File_Open_Directory)
EVT_MENU(ID_Menu_File_Preferences, GUI_Main::OnMenu_File_Preferences)
EVT_MENU(wxID_EXIT, GUI_Main::OnMenu_File_Quit)
EVT_MENU(ID_Menu_View_Easy, GUI_Main::OnMenu_View_Easy)
EVT_MENU(ID_Menu_View_Sheet, GUI_Main::OnMenu_View_Sheet)
Expand Down Expand Up @@ -133,6 +136,7 @@ void GUI_Main::Menu_Create()
//File
Menu_File=new wxMenu;
Menu_File->Append(ID_Menu_File_Open, __T("Open"), Menu_File_Open);
Menu_File_Preferences =Menu_File->Append(ID_Menu_File_Preferences, __T("&Preferences"));
Menu_File->AppendSeparator();
Menu_File_Quit =Menu_File->Append(wxID_EXIT, __T("E&xit\tAlt-X"), __T("Quit this program"));

Expand Down Expand Up @@ -222,6 +226,19 @@ void GUI_Main::OnMenu_File_Open_Files(wxCommandEvent& WXUNUSED(event))
View->GUI_Refresh();
}


//---------------------------------------------------------------------------
void GUI_Main::OnMenu_File_Preferences(wxCommandEvent& WXUNUSED(event))
{
if (!PreferencesEditor)
{
PreferencesEditor=new wxPreferencesEditor(wxT("Preferences"));
PreferencesEditor->AddPage(new GUI_Preferences_Page_General(this));
}

PreferencesEditor->Show(this);
}

//---------------------------------------------------------------------------
void GUI_Main::OnMenu_File_Open_Directory(wxCommandEvent& WXUNUSED(event))
{
Expand Down
23 changes: 14 additions & 9 deletions Source/GUI/WxWidgets/GUI_Main_Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/config.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
Expand All @@ -26,15 +27,6 @@ GUI_Main_Text::GUI_Main_Text(Core* Core_, wxWindow* parent)
: wxTextCtrl(parent, -1, __T(""), wxPoint(0, 0), wxSize(parent->GetClientSize().GetWidth()-0, parent->GetClientSize().GetHeight()-0), wxTE_READONLY|wxTE_MULTILINE|wxTE_RICH|wxTE_RICH2),
GUI_Main_Common_Core(Core_)
{
wxFont Font;
Font.SetFamily(wxFONTFAMILY_MODERN);
wxTextAttr Attr;
Attr.SetFont(Font);
#if wxCHECK_VERSION(2, 9, 0)
Attr.SetFontSize(8);
#endif
SetDefaultStyle(Attr);

//Drag and Drop
#if wxUSE_DRAG_AND_DROP && defined(__WXMAC__)
SetDropTarget(new FileDrop(C));
Expand All @@ -56,6 +48,19 @@ GUI_Main_Text::~GUI_Main_Text()
//---------------------------------------------------------------------------
void GUI_Main_Text::GUI_Refresh()
{
wxConfigBase* Config=wxConfigBase::Get();
long TextSize=Config->ReadLong(wxT("/TextSize"), 0);
if (TextSize>(long)wxFONTSIZE_XX_LARGE)
TextSize=0;

wxFont Font;
Font.SetFamily(wxFONTFAMILY_MODERN);
Font.SetSymbolicSize((wxFontSymbolicSize)TextSize);

wxTextAttr Attr;
Attr.SetFont(Font);
SetDefaultStyle(Attr);

Clear();
WriteText(C->Inform_Get().c_str());
}
Expand Down
Loading
Loading