diff --git a/src/util/urlhandler.cpp b/src/util/urlhandler.cpp --- a/src/util/urlhandler.cpp +++ b/src/util/urlhandler.cpp @@ -21,34 +21,38 @@ public Q_SLOTS: void openHelp(const QUrl &url) { + const QString appName = QCoreApplication::applicationName(); + QUrl u(url); if (u.path() == QLatin1Char('/')) { - u.setPath(QCoreApplication::applicationName()); + u.setPath(appName); } const QString helpcenter = QStandardPaths::findExecutable(QStringLiteral("khelpcenter")); - if (helpcenter.isEmpty()) { - //if khelpcenter is not installed and it's a KDE application, use docs.kde.org - if (QCoreApplication::organizationDomain() == QLatin1String("kde.org")) { - if (QCoreApplication::applicationName() == QLatin1String("systemsettings") - && url.path().startsWith(QLatin1String("/kcontrol"))) { - // special case for kcm modules - // e.g. "help:/kcontrol/fonts/index.html" >>> "&application=kcontorl/fonts" - const QUrl httpUrl(QStringLiteral("https://docs.kde.org/index.php?branch=stable5&language=") - + QLocale().name() + QLatin1String("&application=") - + url.path().remove(0, 1).remove(QLatin1String("/index.html"))); - QDesktopServices::openUrl(httpUrl); - } else { - const QUrl httpUrl(QLatin1String("https://docs.kde.org/index.php?branch=stable5&language=")+QLocale().name()+QLatin1String("&application=") + - QCoreApplication::applicationName() + QStringLiteral("&path=") + url.path()); - QDesktopServices::openUrl(httpUrl); - } - } else { - QDesktopServices::openUrl(u); - } - } else { + if (!helpcenter.isEmpty()) { // use khelpcenter if it is available QProcess::startDetached(helpcenter, QStringList(u.toString())); + return; + } + + //if khelpcenter is not available and it's a KDE application, use docs.kde.org + if (QCoreApplication::organizationDomain() == QLatin1String("kde.org")) { + QString path = url.path(); + QString docPath; + if (appName == QLatin1String("systemsettings") && path.startsWith(QLatin1String("/kcontrol"))) { + // special case for kcm modules + // e.g. "help:/kcontrol/fonts/index.html" >>> "&application=kcontorl/fonts" + docPath = path.remove(0, 1).remove(QLatin1String("/index.html")); + } else { //e.g. "help:/okular", "help:/systemsettings" + docPath = appName + QStringLiteral("&path=") + path; + } + const QUrl httpUrl(QLatin1String("https://docs.kde.org/index.php?branch=stable5&language=") + + QLocale().name() + QLatin1String("&application=") + docPath); + QDesktopServices::openUrl(httpUrl); + return; } + + // not a KDE application + QDesktopServices::openUrl(u); } };