Commit 6afc0c3e authored by Eike Ziller's avatar Eike Ziller
Browse files

Help: Add method for showing URL in specific viewer



That centralizes all the focus setting, raising of windows, etc. This
was for example already done wrong when opening links in help mode and
external window.

Change-Id: I5036b5caa751d1f36dc442078624a31fb8f573ee
Reviewed-by: Jaroslaw Kobus's avatarJarek Kobus <jaroslaw.kobus@qt.io>
parent be3dbd4c
......@@ -362,7 +362,6 @@ HelpViewer *HelpPlugin::externalHelpViewer()
else
m_externalWindow->setGeometry(m_externalWindowState);
m_externalWindow->show();
m_externalWindow->setFocus();
return m_externalWindow->currentViewer();
}
......@@ -428,10 +427,7 @@ void HelpPlugin::activateHelpMode()
void HelpPlugin::showLinkInHelpMode(const QUrl &source)
{
activateHelpMode();
ICore::raiseWindow(m_mode->widget());
m_centralWidget->setSource(source);
m_centralWidget->setFocus();
showInHelpViewer(source, helpModeHelpViewer());
}
void HelpPlugin::showLinksInHelpMode(const QMap<QString, QUrl> &links, const QString &key)
......@@ -494,6 +490,15 @@ bool HelpPlugin::canShowHelpSideBySide()
return true;
}
HelpViewer *HelpPlugin::helpModeHelpViewer()
{
activateHelpMode(); // should trigger an createPage...
HelpViewer *viewer = m_instance->m_centralWidget->currentViewer();
if (!viewer)
viewer = OpenPagesManager::instance().createPage();
return viewer;
}
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location)
{
HelpManager::HelpViewerLocation actualLocation = location;
......@@ -513,11 +518,16 @@ HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocat
QTC_CHECK(actualLocation == HelpManager::HelpModeAlways);
activateHelpMode(); // should trigger an createPage...
HelpViewer *viewer = m_instance->m_centralWidget->currentViewer();
if (!viewer)
viewer = OpenPagesManager::instance().createPage();
return viewer;
return m_instance->helpModeHelpViewer();
}
void HelpPlugin::showInHelpViewer(const QUrl &url, HelpViewer *viewer)
{
QTC_ASSERT(viewer, return);
viewer->setFocus();
viewer->stop();
viewer->setSource(url);
ICore::raiseWindow(viewer);
}
HelpViewer *HelpPlugin::viewerForContextHelp()
......@@ -574,7 +584,7 @@ void HelpPlugin::showContextHelp()
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
if (!source.isValid()) {
// No link found or no context object
viewer->setSource(QUrl(Help::Constants::AboutBlank));
showInHelpViewer(QUrl(Help::Constants::AboutBlank), viewer);
viewer->setHtml(tr("<html><head><title>No Documentation</title>"
"</head><body><br/><center>"
"<font color=\"%1\"><b>%2</b></font><br/>"
......@@ -584,10 +594,7 @@ void HelpPlugin::showContextHelp()
.arg(contextHelpId)
.arg(creatorTheme()->color(Theme::TextColorNormal).name()));
} else {
viewer->setFocus();
viewer->stop();
viewer->setSource(source); // triggers loadFinished which triggers id highlighting
ICore::raiseWindow(viewer);
showInHelpViewer(source, viewer); // triggers loadFinished which triggers id highlighting
}
}
......@@ -635,9 +642,7 @@ void HelpPlugin::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocat
}
HelpViewer *viewer = viewerForHelpViewerLocation(location);
QTC_ASSERT(viewer, return);
viewer->setSource(url);
ICore::raiseWindow(viewer);
showInHelpViewer(url, viewer);
}
class DialogClosingOnEscape : public QDialog
......
......@@ -76,6 +76,7 @@ public:
ShutdownFlag aboutToShutdown();
static HelpViewer *viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location);
static void showInHelpViewer(const QUrl &url, HelpViewer *viewer);
static HelpViewer *createHelpViewer(qreal zoom);
......@@ -107,6 +108,7 @@ private:
HelpWidget *createHelpWidget(const Core::Context &context, HelpWidget::WidgetStyle style);
void createRightPaneContextViewer();
HelpViewer *externalHelpViewer();
HelpViewer *helpModeHelpViewer();
void doSetupIfNeeded();
......
......@@ -70,9 +70,7 @@ namespace Internal {
static void openUrlInWindow(const QUrl &url)
{
HelpViewer *viewer = HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::ExternalHelpAlways);
if (QTC_GUARD(viewer))
viewer->setSource(url);
Core::ICore::raiseWindow(viewer);
HelpPlugin::showInHelpViewer(url, viewer);
}
static bool isBookmarkable(const QUrl &url)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment