Shows help in browser, or possibly in own dialog.
| 231 | |
| 232 | // Shows help in browser, or possibly in own dialog. |
| 233 | void HelpSystem::ShowHelp(wxWindow *parent, |
| 234 | const FilePath &localFileName, |
| 235 | const URLString &remoteURL, |
| 236 | bool bModal, |
| 237 | bool alwaysDefaultBrowser) |
| 238 | { |
| 239 | wxASSERT(parent); // to justify safenew |
| 240 | wxString HelpMode = wxT("Local"); //this probably always gets overwritten to FromInternet |
| 241 | //TODO: remove code which handles local manual |
| 242 | |
| 243 | gPrefs->Read(wxT("/GUI/Help"), &HelpMode, {"FromInternet"} ); |
| 244 | |
| 245 | { |
| 246 | // these next lines are for legacy cfg files (pre 2.0) where we had different modes |
| 247 | if( (HelpMode == wxT("Standard")) || (HelpMode == wxT("InBrowser")) ) |
| 248 | { |
| 249 | HelpMode = GUIManualLocation.Default().Internal(); |
| 250 | GUIManualLocation.Write(HelpMode); |
| 251 | gPrefs->Flush(); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // Anchors (URLs with a '#' in them) are not supported by many OSs for local file names |
| 256 | // See, for example, https://groups.google.com/forum/#!topic/wx-users/pC0uOZJalRQ |
| 257 | // Problems have been reported on Win, Mac and some versions of Linux. |
| 258 | // So we set HelpMode to use the internet if an anchor is found. |
| 259 | if (localFileName.Find('#', true) != wxNOT_FOUND) |
| 260 | HelpMode = wxT("FromInternet"); |
| 261 | // Until a solution is found for this, the next few lines are irrelevant. |
| 262 | |
| 263 | // Obtain the local file system file name, without the anchor if present. |
| 264 | wxString localfile; |
| 265 | if (localFileName.Find('#', true) != wxNOT_FOUND) |
| 266 | localfile = localFileName.BeforeLast('#'); |
| 267 | else |
| 268 | localfile = localFileName; |
| 269 | |
| 270 | if( (HelpMode == wxT("FromInternet")) && !remoteURL.empty() ) |
| 271 | { |
| 272 | // Always go to remote URL. Use External browser. |
| 273 | OpenInDefaultBrowser( remoteURL ); |
| 274 | } |
| 275 | else if( localfile.empty() || !wxFileExists( localfile )) |
| 276 | { |
| 277 | if (remoteURL.empty()) |
| 278 | { |
| 279 | // If you give an empty remote URL, you should have already ensured |
| 280 | // that the file exists! |
| 281 | wxASSERT(!remoteURL.empty()); |
| 282 | // I can't find it'. |
| 283 | // Use Built-in browser to suggest you use the remote url. |
| 284 | wxString Text = HelpText(wxT("remotehelp")); |
| 285 | Text.Replace(wxT("*URL*"), remoteURL.GET()); |
| 286 | // Always make the 'help on the internet' dialog modal. |
| 287 | // Fixes Bug 1411. |
| 288 | ShowHtmlText(parent, XO("Help on the Internet"), Text, false, true); |
| 289 | } |
| 290 | else |
nothing calls this directly
no test coverage detected