35 #include <wx/mimetype.h> 36 #include <wx/tokenzr.h> 37 #include <wx/filename.h> 39 #include <wx/filedlg.h> 60 wxFileTypeInfo( wxT(
"text/html" ),
63 wxT(
"html document (from KiCad)" ),
65 wxT(
"html" ),wxNullPtr ),
67 wxFileTypeInfo( wxT(
"application/sch" ),
69 wxT(
"eeschema -p %s" ),
70 wxT(
"sch document (from KiCad)" ),
72 wxT(
"SCH" ), wxNullPtr ),
83 wxString fullfilename;
89 SEARCH_STACK* aPaths = aProject ? aProject->SchSearchS() :
nullptr;
93 static const std::vector<wxString> url_header =
105 for(
const wxString& proc : url_header)
107 if( docname.StartsWith( proc ) )
109 wxURI uri( docname );
110 wxLaunchDefaultBrowser( uri.BuildURI() );
123 if( wxIsAbsolutePath( docname ) || aPaths ==
NULL )
124 fullfilename = docname;
129 else if( wxFileName::FileExists( docname ) )
130 fullfilename = docname;
134 wxString mask( wxT(
"*" ) ), extension;
138 extension = wxT(
".*" );
141 if( wxIsWild( fullfilename ) )
144 wxPathOnly( fullfilename ),
152 if( fullfilename.IsEmpty() )
156 if( !wxFileExists( fullfilename ) )
158 msg.Printf(
_(
"Doc File \"%s\" not found" ), docname );
163 wxFileName currentFileName( fullfilename );
165 wxString file_ext = currentFileName.GetExt();
167 if( file_ext.Lower() == wxT(
"pdf" ) )
169 success =
OpenPDF( fullfilename );
174 wxFileType* filetype;
177 filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
183 filetype =
mimeDatabase->GetFileTypeFromExtension( file_ext );
190 wxFileType::MessageParameters params( fullfilename, type );
192 success = filetype->GetOpenCommand( &command, params );
201 msg.Printf(
_(
"Unknown MIME type for doc file \"%s\"" ), fullfilename );
virtual COMMON_SETTINGS * GetCommonSettings() const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject)
Open a document (file) with the suitable browser.
wxString FindValidPath(const wxString &aFileName) const
int ProcessExecute(const wxString &aCommandLine, int aFlags, wxProcess *callback)
Run a command in a child process.
#define WIN_STRING_DIR_SEP
Container for project specific data.
This file is part of the common library TODO brief description.
This file is part of the common library.
#define UNIX_STRING_DIR_SEP
Look for files in a number of paths.
virtual void WritePdfBrowserInfos()
Save the PDF browser choice to the common configuration.
static wxMimeTypesManager * mimeDatabase
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
static const wxFileTypeInfo EDAfallbacks[]
virtual void SetPdfBrowserName(const wxString &aFileName)
bool use_system_pdf_viewer
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
const wxString ResolveUriByEnvVars(const wxString &aUri, PROJECT *aProject)
Replace any environment and/or text variables in file-path uris (leaving network-path URIs alone).
virtual const wxString & GetPdfBrowserName() const
virtual void ReadPdfBrowserInfos()
Read the PDF browser choice from the common configuration.
bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.