From ad32d33aa19eec20e33d3ae18f86f88a277ce49b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 21 Sep 2017 20:46:16 +0200 Subject: [PATCH] Ref T157, add context for help calls and call dispatcher --- .../share/shared/bootstrap/bootstrap.json | 2 +- src/blackcore/data/globalsetup.cpp | 25 +++++++++++-------- src/blackcore/data/globalsetup.h | 5 +--- .../components/configurationwizard.cpp | 5 +++- src/blackgui/guiapplication.cpp | 10 ++++++-- src/blackgui/guiapplication.h | 5 +++- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/resources/share/shared/bootstrap/bootstrap.json b/resources/share/shared/bootstrap/bootstrap.json index be41b9e32..0260d8325 100644 --- a/resources/share/shared/bootstrap/bootstrap.json +++ b/resources/share/shared/bootstrap/bootstrap.json @@ -19,7 +19,7 @@ }, "onlineHelpUrls": { "containerbase": [{ - "url": "http://help.swift-project.org" + "url": "https://datastore.swift-project.org/page/swifthelpdispatcher.html" }] }, "mapUrls": { diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index a5af5d5f4..51c77a7bc 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -100,15 +100,23 @@ namespace BlackCore return getDbRootDirectoryUrl().withAppendedPath("/page/index.php"); } - CUrl CGlobalSetup::getHelpPageUrl() const + CUrl CGlobalSetup::getHelpPageUrl(const QString &context) const { const CUrlList urls(this->m_onlineHelpUrls); - CUrl url = urls.getRandomWorkingUrl(); - if (sApp) + + // we display in the standard browser, so the user will realize if the URL + // does not work + CUrl url = (urls.size() < 2) ? urls.frontOrDefault() : urls.getRandomUrl(); + if (url.isEmpty()) { return url; } + + // context string something like "application.moreSpecific.evenMoreSpecific" + QString c = "client"; + if (QCoreApplication::instance()) { - const QString a = sApp->getApplicationNameVersionBetaDev(); - url.appendQuery("swift", a); + c = QCoreApplication::instance()->applicationName(); } + if (!context.isEmpty()) { c += "." + context; } + url.appendQuery("context", c); return url; } @@ -208,11 +216,6 @@ namespace BlackCore return m_newsUrls; } - const CUrlList &CGlobalSetup::getOnlineHelpUrls() const - { - return m_onlineHelpUrls; - } - const CUrlList &CGlobalSetup::getSwiftMapUrls() const { return m_mapUrls; @@ -255,7 +258,7 @@ namespace BlackCore % getSwiftLatestNewsUrls().toQString(i18n) % separator % "Help URLs: " - % getOnlineHelpUrls().toQString(i18n) + % m_onlineHelpUrls.toQString(i18n) % separator % "swift map URLs: " % getSwiftMapUrls().toQString(i18n) diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index 64ddf7e91..8d12833d2 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -153,12 +153,9 @@ namespace BlackCore //! Locations of swift DB news const BlackMisc::Network::CUrlList &getSwiftLatestNewsUrls() const; - //! Online help URLs - const BlackMisc::Network::CUrlList &getOnlineHelpUrls() const; - //! Help page URL //! \remark working URL evaluated at runtime, based on getOnlineHelpUrls - BlackMisc::Network::CUrl getHelpPageUrl() const; + BlackMisc::Network::CUrl getHelpPageUrl(const QString &context = {}) const; //! swift map URLs const BlackMisc::Network::CUrlList &getSwiftMapUrls() const; diff --git a/src/blackgui/components/configurationwizard.cpp b/src/blackgui/components/configurationwizard.cpp index c804a2a28..1c70f0e50 100644 --- a/src/blackgui/components/configurationwizard.cpp +++ b/src/blackgui/components/configurationwizard.cpp @@ -46,7 +46,10 @@ namespace BlackGui connect(this, &QWizard::accepted, this, &CConfigurationWizard::ended); Q_ASSERT_X(sGui, Q_FUNC_INFO, "missing sGui"); - connect(this, &QWizard::helpRequested, sGui, &CGuiApplication::showHelp); + connect(this, &QWizard::helpRequested, sGui, [ = ] + { + sGui->showHelp(this); + }); } CConfigurationWizard::~CConfigurationWizard() diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 53253b591..4541c5d1d 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -556,10 +556,10 @@ namespace BlackGui Q_UNUSED(c); } - void CGuiApplication::showHelp() + void CGuiApplication::showHelp(const QString &context) const { const CGlobalSetup gs = this->getGlobalSetup(); - const CUrl helpPage = gs.getHelpPageUrl(); + const CUrl helpPage = gs.getHelpPageUrl(context); if (helpPage.isEmpty()) { CLogMessage(this).warning("No help page"); @@ -568,6 +568,12 @@ namespace BlackGui QDesktopServices::openUrl(helpPage); } + void CGuiApplication::showHelp(const QObject *qObject) const + { + if (!qObject || qObject->objectName().isEmpty()) { return this->showHelp(); } + return this->showHelp(qObject->objectName()); + } + const CStyleSheetUtility &CGuiApplication::getStyleSheetUtility() const { return this->m_styleSheetUtility; diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index 9811bc78a..2fca4242e 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -143,7 +143,10 @@ namespace BlackGui void addMenuHelp(QMenu &menu); //! Show help page (online help) - void showHelp(); + void showHelp(const QString &context = {}) const; + + //! Show help page (online help), use QObject::objectName as 2nd level context + void showHelp(const QObject *qObject) const; //! Style sheet handling const CStyleSheetUtility &getStyleSheetUtility() const;