1 /***************************************************************************
2   qgshelp.h
3   --------------------------------------
4   Date                 : December 2016
5   Copyright            : (C) 2016 by Alexander Bruy
6   Email                : alexander dot bruy at gmail dot com
7  ***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #ifndef QGSHELP_H
17 #define QGSHELP_H
18 
19 #include <QtCore>
20 
21 #include "qgis_gui.h"
22 
23 /**
24  * \ingroup gui
25  * \class QgsHelp
26  * \brief Helper class for showing help topic URI for the given key.
27  *
28  * Help can be stored online, on the local directory or on the intranet
29  * server. Location of the QGIS help can be configured in QGIS options.
30  * Multiple locations are supported, they will be used in order of
31  * preference, from top to bottom.
32  *
33  * URI construction takes in account following information:
34  *
35  * - QGIS version
36  * - language of the QGIS UI
37  *
38  * If no help found, default error page with information how to setup
39  * help system will be shown.
40  *
41  * \since QGIS 3.0
42  */
43 class GUI_EXPORT QgsHelp
44 {
45   public:
46 
47     /**
48      * Opens help topic for the given help key using default system
49      * web browser. If help topic not found, builtin error page shown.
50      * \param key key which identified help topic
51      * \since QGIS 3.0
52      */
53     static void openHelp( const QString &key );
54 
55     /**
56      * Returns URI of the help topic for the given key. If help topic
57      * not found, URI of the builtin error page returned.
58      * \param key key which identified help topic
59      * \since QGIS 3.0
60      */
61     static QUrl helpUrl( const QString &key );
62 
63   private:
64 
65     /**
66      * Check if given URL accessible by issuing HTTP HEAD request.
67      * Returns TRUE if URL accessible, FALSE otherwise.
68      * \param url URL to check
69      * \since QGIS 3.0
70      */
71     static bool urlExists( const QString &url );
72 };
73 
74 #endif // QGSHELP_H
75