Commit 4e7bbbda authored by kh1's avatar kh1
Browse files

Fix broken behavior for welcome page links if no docs are installed.

In case of split mode we did not check if the actual requested doc
exists and thus did fail to open the browser if it could not be found.

Reviewed-by: Daniel Molkentin
parent 51c0913a
......@@ -41,16 +41,11 @@ HelpManager::HelpManager(HelpPlugin* plugin)
{
}
void HelpManager::openHelpPage(const QString& url)
void HelpManager::handleHelpRequest(const QString &url)
{
m_plugin->handleHelpRequest(url);
}
void HelpManager::openContextHelpPage(const QString& url)
{
m_plugin->openContextHelpPage(url);
}
void HelpManager::registerDocumentation(const QStringList &fileNames)
{
if (m_plugin) {
......
......@@ -47,12 +47,11 @@ class HELP_EXPORT HelpManager : public QObject
public:
HelpManager(Internal::HelpPlugin*);
void openHelpPage(const QString& url);
void openContextHelpPage(const QString &url);
void handleHelpRequest(const QString &url);
void registerDocumentation(const QStringList &fileNames);
signals:
void helpPluginUpdateDocumentation();
void registerDocumentation();
private:
Internal::HelpPlugin *m_plugin;
......
......@@ -998,43 +998,35 @@ void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url);
}
void HelpPlugin::handleHelpRequest(const QUrl& url)
void HelpPlugin::handleHelpRequest(const QString &address)
{
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split"))
openContextHelpPage(url.toString());
else
openHelpPage(url.toString());
}
if (m_helpEngine->findFile(address).isValid()) {
const QUrl url(address);
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
using namespace Core::Constants;
void HelpPlugin::openHelpPage(const QString& url)
{
if (m_helpEngine->findFile(url).isValid()) {
activateHelpMode();
m_centralWidget->setSource(url);
Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
if (modeManager->currentMode() == modeManager->mode(MODE_WELCOME))
modeManager->activateMode(MODE_EDIT);
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(url);
} else {
activateHelpMode();
m_centralWidget->setSource(url);
}
} else {
// local help not installed, resort to external web help
QString urlPrefix;
if (url.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) {
if (address.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) {
urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator"
"-%1.%2/").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR);
} else {
urlPrefix = QLatin1String("http://doc.trolltech.com/latest/");
}
QDesktopServices::openUrl(QUrl(urlPrefix + url.mid(url
QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address
.lastIndexOf(QLatin1Char('/')) + 1)));
}
}
void HelpPlugin::openContextHelpPage(const QString &url)
{
using namespace Core::Constants;
Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
if (modeManager->currentMode() == modeManager->mode(MODE_WELCOME))
modeManager->activateMode(MODE_EDIT);
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(QUrl(url));
}
Q_EXPORT_PLUGIN(HelpPlugin)
......@@ -91,16 +91,13 @@ public:
void setIndexFilter(const QString &filter);
QString indexFilter() const;
void openHelpPage(const QString& url);
void openContextHelpPage(const QString &url);
QHelpEngine* helpEngine() const;
void setFilesToRegister(const QStringList &files);
public slots:
void pluginUpdateDocumentation();
void handleHelpRequest(const QUrl &url);
void handleHelpRequest(const QString &url);
private slots:
void modeChanged(Core::IMode *mode);
......
......@@ -265,14 +265,14 @@ void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url)
Help::HelpManager *helpManager
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager);
helpManager->openHelpPage(url);
helpManager->handleHelpRequest(url);
}
void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url)
{
Help::HelpManager *helpManager
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager);
helpManager->openContextHelpPage(url);
helpManager->handleHelpRequest(url);
}
void GettingStartedWelcomePageWidget::slotNextTip()
......
Supports Markdown
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