31#include <wx/mimetype.h>
32#include <wx/filename.h>
34#include <wx/filedlg.h>
55 wxFileTypeInfo( wxT(
"text/html" ),
58 wxT(
"html document (from KiCad)" ),
60 wxT(
"html" ),wxNullPtr ),
62 wxFileTypeInfo( wxT(
"application/sch" ),
64 wxT(
"eeschema -p %s" ),
65 wxT(
"sch document (from KiCad)" ),
67 wxT(
"SCH" ), wxNullPtr ),
77 wxString fullfilename;
83 static const std::vector<wxString> url_header =
95 for(
const wxString& proc : url_header)
97 if( docname.StartsWith( proc ) )
100 wxLaunchDefaultBrowser( uri.BuildURI() );
112 if( wxIsAbsolutePath( docname ) || aPaths ==
nullptr )
113 fullfilename = docname;
117 else if( wxFileName::FileExists( docname ) )
118 fullfilename = docname;
120 fullfilename = aPaths->FindValidPath( docname );
125 extension = wxT(
".*" );
128 if( wxIsWild( fullfilename ) )
130 fullfilename = wxFileSelector(
_(
"Documentation File" ), wxPathOnly( fullfilename ),
131 fullfilename, extension, wxFileSelectorDefaultWildcardStr,
132 wxFD_OPEN, aParent );
134 if( fullfilename.IsEmpty() )
138 if( !wxFileExists( fullfilename ) )
140 msg.Printf(
_(
"Documentation file '%s' not found." ), docname );
145 wxFileName currentFileName( fullfilename );
148 fullfilename = currentFileName.GetAbsolutePath();
150 wxString file_ext = currentFileName.GetExt();
152 if( file_ext.Lower() == wxT(
"pdf" ) )
154 success =
OpenPDF( fullfilename );
159 wxFileType* filetype;
162 filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
168 filetype =
mimeDatabase->GetFileTypeFromExtension( file_ext );
175 wxFileType::MessageParameters params( fullfilename, type );
177 success = filetype->GetOpenCommand( &command, params );
181 success = wxExecute( command );
186 msg.Printf(
_(
"Unknown MIME type for documentation file '%s'" ), fullfilename );
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual void SetPdfBrowserName(const wxString &aFileName)
virtual void ReadPdfBrowserInfos()
Read the PDF browser choice from the common configuration.
bool m_use_system_pdf_browser
virtual const wxString & GetPdfBrowserName() const
virtual void WritePdfBrowserInfos()
Save the PDF browser choice to the common configuration.
Container for project specific data.
Look for files in a number of paths.
const wxString ResolveUriByEnvVars(const wxString &aUri, PROJECT *aProject)
Replace any environment and/or text variables in file-path uris (leaving network-path URIs alone).
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
static const wxFileTypeInfo EDAfallbacks[]
static wxMimeTypesManager * mimeDatabase
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths)
Open a document (file) with the suitable browser.
bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.
#define WIN_STRING_DIR_SEP
#define UNIX_STRING_DIR_SEP
bool use_system_pdf_viewer