31#include <wx/mimetype.h>
32#include <wx/filename.h>
34#include <wx/filedlg.h>
41 wxFileTypeInfo( wxT(
"text/html" ),
44 wxT(
"html document (from KiCad)" ),
46 wxT(
"html" ),wxNullPtr ),
48 wxFileTypeInfo( wxT(
"application/sch" ),
50 wxT(
"eeschema -p %s" ),
51 wxT(
"sch document (from KiCad)" ),
53 wxT(
"SCH" ), wxNullPtr ),
63 wxString fullfilename;
69 static const std::vector<wxString> url_header =
81 for(
const wxString& proc : url_header)
83 if( docname.StartsWith( proc ) )
86 wxLaunchDefaultBrowser( uri.BuildURI() );
98 if( wxIsAbsolutePath( docname ) || aPaths ==
nullptr )
99 fullfilename = docname;
103 else if( wxFileName::FileExists( docname ) )
104 fullfilename = docname;
106 fullfilename = aPaths->FindValidPath( docname );
111 extension = wxT(
".*" );
114 if( wxIsWild( fullfilename ) )
116 fullfilename = wxFileSelector(
_(
"Documentation File" ), wxPathOnly( fullfilename ),
117 fullfilename, extension, wxFileSelectorDefaultWildcardStr,
118 wxFD_OPEN, aParent );
120 if( fullfilename.IsEmpty() )
124 if( !wxFileExists( fullfilename ) )
126 msg.Printf(
_(
"Documentation file '%s' not found." ), docname );
131 wxFileName currentFileName( fullfilename );
134 fullfilename = currentFileName.GetAbsolutePath();
136 wxString file_ext = currentFileName.GetExt();
138 if( file_ext.Lower() == wxT(
"pdf" ) )
140 success =
OpenPDF( fullfilename );
145 wxFileType* filetype;
148 filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
154 filetype =
mimeDatabase->GetFileTypeFromExtension( file_ext );
161 wxFileType::MessageParameters params( fullfilename, type );
163 success = filetype->GetOpenCommand( &command, params );
167 success = wxExecute( command );
172 msg.Printf(
_(
"Unknown MIME type for documentation file '%s'" ), fullfilename );
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