Changeset View
Changeset View
Standalone View
Standalone View
src/util/urlhandler.cpp
Show All 22 Lines | 21 | public Q_SLOTS: | |||
---|---|---|---|---|---|
23 | { | 23 | { | ||
24 | QUrl u(url); | 24 | QUrl u(url); | ||
25 | if (u.path() == QLatin1Char('/')) { | 25 | if (u.path() == QLatin1Char('/')) { | ||
26 | u.setPath(QCoreApplication::applicationName()); | 26 | u.setPath(QCoreApplication::applicationName()); | ||
27 | } | 27 | } | ||
28 | 28 | | |||
29 | const QString helpcenter = QStandardPaths::findExecutable(QStringLiteral("khelpcenter")); | 29 | const QString helpcenter = QStandardPaths::findExecutable(QStringLiteral("khelpcenter")); | ||
30 | if (helpcenter.isEmpty()) { | 30 | if (helpcenter.isEmpty()) { | ||
31 | if (QCoreApplication::organizationDomain() == QLatin1String("kde.org")) { | | |||
32 | //if khelpcenter is not installed and it's a KDE application, use docs.kde.org | 31 | //if khelpcenter is not installed and it's a KDE application, use docs.kde.org | ||
32 | if (QCoreApplication::organizationDomain() == QLatin1String("kde.org")) { | ||||
33 | if (QCoreApplication::applicationName() == QLatin1String("systemsettings") | ||||
34 | && url.path().startsWith(QLatin1String("/kcontrol"))) { | ||||
35 | // special case for kcm modules | ||||
36 | // e.g. "help:/kcontrol/fonts/index.html" >>> "&application=kcontorl/fonts" | ||||
37 | const QUrl httpUrl(QStringLiteral("https://docs.kde.org/index.php?branch=stable5&language=") | ||||
38 | + QLocale().name() + QLatin1String("&application=") | ||||
39 | + url.path().remove(0, 1).remove(QLatin1String("/index.html"))); | ||||
40 | QDesktopServices::openUrl(httpUrl); | ||||
41 | } else { | ||||
33 | const QUrl httpUrl(QLatin1String("https://docs.kde.org/index.php?branch=stable5&language=")+QLocale().name()+QLatin1String("&application=") + | 42 | const QUrl httpUrl(QLatin1String("https://docs.kde.org/index.php?branch=stable5&language=")+QLocale().name()+QLatin1String("&application=") + | ||
34 | QCoreApplication::applicationName() + QStringLiteral("&path=") + url.path()); | 43 | QCoreApplication::applicationName() + QStringLiteral("&path=") + url.path()); | ||
35 | QDesktopServices::openUrl(httpUrl); | 44 | QDesktopServices::openUrl(httpUrl); | ||
36 | } else | 45 | } | ||
46 | } else { | ||||
37 | QDesktopServices::openUrl(u); | 47 | QDesktopServices::openUrl(u); | ||
48 | } | ||||
38 | } else { | 49 | } else { | ||
39 | QProcess::startDetached(helpcenter, QStringList(u.toString())); | 50 | QProcess::startDetached(helpcenter, QStringList(u.toString())); | ||
40 | } | 51 | } | ||
41 | } | 52 | } | ||
42 | }; | 53 | }; | ||
43 | 54 | | |||
44 | Q_GLOBAL_STATIC(UrlHandler, s_handler) | 55 | Q_GLOBAL_STATIC(UrlHandler, s_handler) | ||
45 | 56 | | |||
46 | static void initializeGlobalSettings() | 57 | static void initializeGlobalSettings() | ||
47 | { | 58 | { | ||
48 | QDesktopServices::setUrlHandler(QStringLiteral("help"), s_handler, "openHelp"); | 59 | QDesktopServices::setUrlHandler(QStringLiteral("help"), s_handler, "openHelp"); | ||
49 | } | 60 | } | ||
50 | 61 | | |||
51 | Q_COREAPP_STARTUP_FUNCTION(initializeGlobalSettings) | 62 | Q_COREAPP_STARTUP_FUNCTION(initializeGlobalSettings) | ||
52 | 63 | | |||
53 | #include "urlhandler.moc" | 64 | #include "urlhandler.moc" |