kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #18295
[PATCH] Add online documenation URL to the menu
Hi devs,
I created a patch which opens the *online documentation* page in the
web-browser, only when the local help file could not be found.
This way the user *don't *get the pop-up message: 'PDF could not be found'.
Instead they can read the latest successfully build documentation online
:).
*Off-topic:*
> It would be nice if online documentation becomes the default.
> This way the users always read the latest version of the documentation.
>
See attachment for the patch.
Thanks in advance!
Kind regards,
Melroy van den Berg
=== modified file 'AUTHORS.txt'
--- AUTHORS.txt 2014-10-22 10:24:16 +0000
+++ AUTHORS.txt 2015-05-17 19:01:41 +0000
@@ -1,5 +1,5 @@
-* Copyright (C) 1992-2014 Jean-Pierre Charras
-* Copyright (C) 1992-2014 Kicad Developers Team
+* Copyright (C) 1992-2015 Jean-Pierre Charras
+* Copyright (C) 1992-2015 Kicad Developers Team
* under GNU General Public License (see copyright.txt)
== Main Authors
@@ -31,6 +31,7 @@
Nick Østergaard <oe.nick[at]gmail.com>
Andrew Zonenberg <azonenberg[at]drawersteak.com>
Cirilo Bernardo <cirilo_bernardo[at]yahoo.com>
+Melroy van den Berg <webmaster1989[at]gmail.com>
See also CHANGELOG.txt for contributors.
@@ -38,6 +39,7 @@
Jean-Pierre Charras <jean-pierre.charras[at]gipsa-lab.inpg.fr>
Igor Plyatov <plyatov[at]gmail.com>
Fabrizio Tappero <fabrizio-dot-tappero[at]gmail-dot-com>
+Melroy van den Berg <webmaster1989[at]gmail.com>
== Translators
Czech (CZ) Martin Kratoška <martin[at]ok1rr-dot-com>
=== modified file 'common/basicframe.cpp'
--- common/basicframe.cpp 2015-05-11 16:25:33 +0000
+++ common/basicframe.cpp 2015-05-17 22:11:36 +0000
@@ -33,6 +33,7 @@
#include <wx/clipbrd.h>
#include <wx/statline.h>
#include <wx/platinfo.h>
+#include <wx/hashmap.h>
#include <build_version.h>
#include <fctsys.h>
@@ -61,7 +62,41 @@
/// Configuration file entry for wxAuiManger perspective.
static const wxChar entryPerspective[] = wxT( "Perspective" );
-
+/// Documentation location URL
+static const wxString documentationURL = wxT("http://ci.kicad-pcb.org/job/any-kicad-doc-head/lastSuccessfulBuild/"\
+ "artifact/src/%s");
+/// Define Getting Started online URI
+static const wxString gettingStartedURI = wxT("Getting_Started_in_KiCad/Getting_Started_in_KiCad.html");
+
+/// Define KiCad online URI
+static const wxString kiCadURI = wxT("KiCad/KiCad.html");
+
+/// Define Eeschema online URI
+static const wxString eeschemaURI = wxT("Eeschema/Eeschema.html");
+
+/// Define Pcbnew online URI
+static const wxString pcbnewURI = wxT("Pcbnew/Pcbnew.html");
+
+/// Define GerbView online URI
+static const wxString gerbviewURI = wxT("GerbView/GerbView.html");
+
+/// Define Pl Editor online URI
+static const wxString plEditorURI = wxT("Pl_Editor/Pl_Editor.html");
+
+/// Define CvPcb Editor online URI
+static const wxString cvPcbURI = wxT("CvPcb/CvPcb.html");
+
+/// Enum holding all the possible values
+enum HelpValue { helpKiCad,
+ helpEeschema,
+ helpPcbnew,
+ helpGerbView,
+ helpPlEditor,
+ helpCvPcb};
+
+/// Map to associate the strings with the enum values
+WX_DECLARE_STRING_HASH_MAP( int, HelpHashMap);
+HelpHashMap helpHashMap;
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
@@ -92,6 +127,14 @@
m_FramePos.x = m_FramePos.y = 0;
+ // Init Hash map
+ helpHashMap["kicad"] = helpKiCad;
+ helpHashMap["eeschema"] = helpEeschema;
+ helpHashMap["pcbnew"] = helpPcbnew;
+ helpHashMap["gerbview"] = helpGerbView;
+ helpHashMap["pl_editor"] = helpPlEditor;
+ helpHashMap["cvpcb"] = helpCvPcb;
+
Connect( ID_HELP_COPY_VERSION_STRING,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( EDA_BASE_FRAME::CopyVersionInfoToClipboard ) );
@@ -388,7 +431,8 @@
void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
{
- const SEARCH_STACK& search = sys_search();
+ const SEARCH_STACK& search = sys_search();
+ wxString helpURL;
/* We have to get document for beginners,
* or the full specific doc
@@ -396,6 +440,7 @@
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
+
if( event.GetId() == wxID_INDEX )
{
// List of possible names for Getting Started in KiCad
@@ -417,32 +462,71 @@
if( !helpFile )
{
- wxString msg = wxString::Format( _(
- "Html or pdf help file \n'%s'\n or\n'%s' could not be found." ), names[0], names[1] );
- wxMessageBox( msg );
+ // If help file (html / pdf) could not be found,
+ // open the online Getting started documenation URL
+ helpURL = wxString::Format( _(documentationURL),
+ GetChars( gettingStartedURI )
+ );
}
else
{
GetAssociatedDocument( this, helpFile );
}
-
- return;
- }
-
- wxString base_name = help_name();
- wxString helpFile = SearchHelpFileFullPath( search, base_name );
-
- if( !helpFile )
- {
- wxString msg = wxString::Format( _(
- "Help file '%s' could not be found." ),
- GetChars( base_name )
- );
- wxMessageBox( msg );
}
else
{
- GetAssociatedDocument( this, helpFile );
+ wxString base_name = help_name();
+ wxString helpFile = SearchHelpFileFullPath( search, base_name );
+
+ if( !helpFile )
+ {
+ wxString uri;
+ // Switch on the enum value
+ switch(helpHashMap[base_name]) {
+ case helpKiCad:
+ uri = kiCadURI;
+ break;
+ case helpEeschema:
+ uri = eeschemaURI;
+ break;
+ case helpPcbnew:
+ uri = pcbnewURI;
+ break;
+ case helpGerbView:
+ uri = gerbviewURI;
+ break;
+ case helpPlEditor:
+ uri = plEditorURI;
+ break;
+ case helpCvPcb:
+ uri = cvPcbURI;
+ break;
+ default:
+ wxString msg = wxString::Format( _(
+ "Help file/URLs for '%s' could not be found." ),
+ GetChars( base_name )
+ );
+ wxMessageBox( msg );
+ break;
+ }
+
+ if(!uri.IsEmpty())
+ {
+ helpURL = wxString::Format( _(documentationURL),
+ GetChars( uri )
+ );
+ }
+ }
+ else
+ {
+ GetAssociatedDocument( this, helpFile );
+ }
+ }
+
+ if(!helpURL.IsEmpty())
+ {
+ // Open website
+ GetAssociatedDocument( this, helpURL );
}
}
Follow ups