forked from qt-creator/qt-creator
Help: Unify showing a specific help url
Makes code paths easier to follow. Change-Id: I6056862c15dbbaa8c63f0633ba70a178cfa910f6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -124,7 +124,6 @@ public:
|
|||||||
void activateContents();
|
void activateContents();
|
||||||
|
|
||||||
void saveExternalWindowSettings();
|
void saveExternalWindowSettings();
|
||||||
void showLinkInHelpMode(const QUrl &source);
|
|
||||||
void showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key);
|
void showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key);
|
||||||
void slotHideRightPane();
|
void slotHideRightPane();
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ public:
|
|||||||
void setupHelpEngineIfNeeded();
|
void setupHelpEngineIfNeeded();
|
||||||
|
|
||||||
void highlightSearchTermsInContextHelp();
|
void highlightSearchTermsInContextHelp();
|
||||||
void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
HelpViewer *showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
||||||
|
|
||||||
void slotSystemInformation();
|
void slotSystemInformation();
|
||||||
|
|
||||||
@@ -287,7 +286,8 @@ HelpPluginPrivate::HelpPluginPrivate()
|
|||||||
cmd = ActionManager::registerAction(action, "Help.TechSupport");
|
cmd = ActionManager::registerAction(action, "Help.TechSupport");
|
||||||
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT);
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT);
|
||||||
connect(action, &QAction::triggered, this, [this] {
|
connect(action, &QAction::triggered, this, [this] {
|
||||||
showLinkInHelpMode(QUrl("qthelp://org.qt-project.qtcreator/doc/technical-support.html"));
|
showHelpUrl(QUrl("qthelp://org.qt-project.qtcreator/doc/technical-support.html"),
|
||||||
|
Core::HelpManager::HelpModeAlways);
|
||||||
});
|
});
|
||||||
|
|
||||||
action = new QAction(HelpPlugin::tr("Report Bug..."), this);
|
action = new QAction(HelpPlugin::tr("Report Bug..."), this);
|
||||||
@@ -410,10 +410,10 @@ HelpWidget *HelpPluginPrivate::createHelpWidget(const Context &context, HelpWidg
|
|||||||
|
|
||||||
connect(widget->currentViewer(), &HelpViewer::loadFinished,
|
connect(widget->currentViewer(), &HelpViewer::loadFinished,
|
||||||
this, &HelpPluginPrivate::highlightSearchTermsInContextHelp);
|
this, &HelpPluginPrivate::highlightSearchTermsInContextHelp);
|
||||||
connect(widget, &HelpWidget::openHelpMode,
|
connect(widget, &HelpWidget::openHelpMode, this, [this](const QUrl &url) {
|
||||||
this, &HelpPluginPrivate::showLinkInHelpMode);
|
showHelpUrl(url, Core::HelpManager::HelpModeAlways);
|
||||||
connect(widget, &HelpWidget::closeButtonClicked,
|
});
|
||||||
this, &HelpPluginPrivate::slotHideRightPane);
|
connect(widget, &HelpWidget::closeButtonClicked, this, &HelpPluginPrivate::slotHideRightPane);
|
||||||
connect(widget, &HelpWidget::aboutToClose,
|
connect(widget, &HelpWidget::aboutToClose,
|
||||||
this, &HelpPluginPrivate::saveExternalWindowSettings);
|
this, &HelpPluginPrivate::saveExternalWindowSettings);
|
||||||
|
|
||||||
@@ -507,11 +507,6 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPluginPrivate::showLinkInHelpMode(const QUrl &source)
|
|
||||||
{
|
|
||||||
showInHelpViewer(source, helpModeHelpViewer());
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPluginPrivate::showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key)
|
void HelpPluginPrivate::showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key)
|
||||||
{
|
{
|
||||||
if (links.size() < 1)
|
if (links.size() < 1)
|
||||||
@@ -670,11 +665,6 @@ void HelpPluginPrivate::requestContextHelp()
|
|||||||
|
|
||||||
void HelpPluginPrivate::showContextHelp(const QString &contextHelpId)
|
void HelpPluginPrivate::showContextHelp(const QString &contextHelpId)
|
||||||
{
|
{
|
||||||
// get the viewer after getting the help id,
|
|
||||||
// because a new window might be opened and therefore focus be moved
|
|
||||||
HelpViewer *viewer = viewerForContextHelp();
|
|
||||||
QTC_ASSERT(viewer, return);
|
|
||||||
|
|
||||||
QMap<QString, QUrl> links = Core::HelpManager::linksForIdentifier(contextHelpId);
|
QMap<QString, QUrl> links = Core::HelpManager::linksForIdentifier(contextHelpId);
|
||||||
// Maybe the id is already an URL
|
// Maybe the id is already an URL
|
||||||
if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId))
|
if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId))
|
||||||
@@ -683,19 +673,22 @@ void HelpPluginPrivate::showContextHelp(const QString &contextHelpId)
|
|||||||
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
||||||
if (!source.isValid()) {
|
if (!source.isValid()) {
|
||||||
// No link found or no context object
|
// No link found or no context object
|
||||||
showInHelpViewer(QUrl(Help::Constants::AboutBlank), viewer);
|
HelpViewer *viewer = showHelpUrl(QUrl(Help::Constants::AboutBlank),
|
||||||
viewer->setHtml(QString("<html><head><title>%1</title>"
|
LocalHelpManager::contextHelpOption());
|
||||||
"</head><body bgcolor=\"%2\"><br/><center>"
|
if (viewer) {
|
||||||
"<font color=\"%3\"><b>%4</b></font><br/>"
|
viewer->setHtml(QString("<html><head><title>%1</title>"
|
||||||
"<font color=\"%3\">%5</font>"
|
"</head><body bgcolor=\"%2\"><br/><center>"
|
||||||
"</center></body></html>")
|
"<font color=\"%3\"><b>%4</b></font><br/>"
|
||||||
.arg(HelpPlugin::tr("No Documentation"))
|
"<font color=\"%3\">%5</font>"
|
||||||
.arg(creatorTheme()->color(Theme::BackgroundColorNormal).name())
|
"</center></body></html>")
|
||||||
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
.arg(HelpPlugin::tr("No Documentation"))
|
||||||
.arg(contextHelpId)
|
.arg(creatorTheme()->color(Theme::BackgroundColorNormal).name())
|
||||||
.arg(HelpPlugin::tr("No documentation available.")));
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
||||||
|
.arg(contextHelpId)
|
||||||
|
.arg(HelpPlugin::tr("No documentation available.")));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showInHelpViewer(source, viewer); // triggers loadFinished which triggers id highlighting
|
showHelpUrl(source, LocalHelpManager::contextHelpOption()); // triggers loadFinished which triggers id highlighting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,7 +714,7 @@ void HelpPluginPrivate::highlightSearchTermsInContextHelp()
|
|||||||
m_contextHelpHighlightId.clear();
|
m_contextHelpHighlightId.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
HelpViewer *HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
||||||
{
|
{
|
||||||
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
|
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
|
||||||
if (url.host() == qtcreatorUnversionedID) {
|
if (url.host() == qtcreatorUnversionedID) {
|
||||||
@@ -729,12 +722,12 @@ void HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpView
|
|||||||
QUrl versioned = url;
|
QUrl versioned = url;
|
||||||
versioned.setHost(qtcreatorUnversionedID + "."
|
versioned.setHost(qtcreatorUnversionedID + "."
|
||||||
+ QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.'));
|
+ QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.'));
|
||||||
showHelpUrl(versioned, location);
|
|
||||||
return;
|
return showHelpUrl(versioned, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HelpViewer::launchWithExternalApp(url))
|
if (HelpViewer::launchWithExternalApp(url))
|
||||||
return;
|
return nullptr;
|
||||||
|
|
||||||
if (!HelpManager::findFile(url).isValid()) {
|
if (!HelpManager::findFile(url).isValid()) {
|
||||||
const QString address = url.toString();
|
const QString address = url.toString();
|
||||||
@@ -748,12 +741,13 @@ void HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpView
|
|||||||
else
|
else
|
||||||
urlPrefix.append("qt-5");
|
urlPrefix.append("qt-5");
|
||||||
QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')))));
|
QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')))));
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpViewer *viewer = viewerForHelpViewerLocation(location);
|
HelpViewer *viewer = viewerForHelpViewerLocation(location);
|
||||||
showInHelpViewer(url, viewer);
|
showInHelpViewer(url, viewer);
|
||||||
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DialogClosingOnEscape : public QDialog
|
class DialogClosingOnEscape : public QDialog
|
||||||
|
Reference in New Issue
Block a user