30#include <QDesktopServices>
32#include <QNetworkProxy>
33#include <QNetworkProxyFactory>
34#include <QRegularExpression>
48 const QStringList paths = settings.
value( u
"help/helpSearchPath"_s ).toStringList();
49 if ( paths.isEmpty() )
58 QString helpPath, fullPath;
59 bool helpFound =
false;
61 const auto constPaths = paths;
62 for (
const QString &path : constPaths )
64 if ( path.endsWith(
"\\"_L1 ) || path.endsWith(
'/'_L1 ) )
66 fullPath = path.left( path.size() - 1 );
73 const auto constVariableNames = scope->variableNames();
74 for (
const QString &var : constVariableNames )
76 const QRegularExpression rx( u
"(<!\\$\\$)*(\\$%1)"_s.arg( var ) );
77 fullPath.replace( rx, scope->variable( var ).toString() );
79 const thread_local QRegularExpression pathRx( u
"(\\$\\$)"_s );
80 fullPath.replace( pathRx, u
"$"_s );
82 helpPath = u
"%1/%2"_s.arg( fullPath, key );
86 if ( helpPath.startsWith(
"http"_L1 ) )
88 if ( !QgsHelp::urlExists( helpPath ) )
96 const QString filePath = helpPath.mid( 0, helpPath.lastIndexOf(
'#'_L1 ) );
97 if ( !QFileInfo::exists( filePath ) )
101 helpUrl = QUrl::fromLocalFile( filePath );
102 const int pos = helpPath.lastIndexOf(
'#'_L1 );
105 helpUrl.setFragment( helpPath.mid( helpPath.lastIndexOf(
'#'_L1 ) + 1, -1 ) );
113 return helpFound ?
helpUrl : helpNotFound;
116bool QgsHelp::urlExists(
const QString &url )
121 QNetworkRequest req(
helpUrl );
@ Info
Information message.
static QString pkgDataPath()
Returns the common root path of all application data directories.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
ErrorCode head(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr)
Performs a "head" operation on the specified request.
@ NoError
No error was encountered.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
static QUrl helpUrl(const QString &key)
Returns URI of the help topic for the given key.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
#define QgsSetRequestInitiatorClass(request, _class)