Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -41,16 +41,11 @@ HelpManager::HelpManager(HelpPlugin* plugin) ...@@ -41,16 +41,11 @@ HelpManager::HelpManager(HelpPlugin* plugin)
{ {
} }
void HelpManager::openHelpPage(const QString& url) void HelpManager::handleHelpRequest(const QString &url)
{ {
m_plugin->handleHelpRequest(url); m_plugin->handleHelpRequest(url);
} }
void HelpManager::openContextHelpPage(const QString& url)
{
m_plugin->openContextHelpPage(url);
}
void HelpManager::registerDocumentation(const QStringList &fileNames) void HelpManager::registerDocumentation(const QStringList &fileNames)
{ {
if (m_plugin) { if (m_plugin) {
......
...@@ -47,12 +47,11 @@ class HELP_EXPORT HelpManager : public QObject ...@@ -47,12 +47,11 @@ class HELP_EXPORT HelpManager : public QObject
public: public:
HelpManager(Internal::HelpPlugin*); HelpManager(Internal::HelpPlugin*);
void openHelpPage(const QString& url); void handleHelpRequest(const QString &url);
void openContextHelpPage(const QString &url);
void registerDocumentation(const QStringList &fileNames); void registerDocumentation(const QStringList &fileNames);
signals: signals:
void helpPluginUpdateDocumentation(); void registerDocumentation();
private: private:
Internal::HelpPlugin *m_plugin; Internal::HelpPlugin *m_plugin;
......
...@@ -998,43 +998,35 @@ void HelpPlugin::addNewBookmark(const QString &title, const QString &url) ...@@ -998,43 +998,35 @@ void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, 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")) if (m_helpEngine->findFile(address).isValid()) {
openContextHelpPage(url.toString()); const QUrl url(address);
else if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
openHelpPage(url.toString()); using namespace Core::Constants;
}
void HelpPlugin::openHelpPage(const QString& url) Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
{ if (modeManager->currentMode() == modeManager->mode(MODE_WELCOME))
if (m_helpEngine->findFile(url).isValid()) { modeManager->activateMode(MODE_EDIT);
activateHelpMode();
m_centralWidget->setSource(url); if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(url);
} else {
activateHelpMode();
m_centralWidget->setSource(url);
}
} else { } else {
// local help not installed, resort to external web help // local help not installed, resort to external web help
QString urlPrefix; 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" urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator"
"-%1.%2/").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR); "-%1.%2/").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR);
} else { } else {
urlPrefix = QLatin1String("http://doc.trolltech.com/latest/"); urlPrefix = QLatin1String("http://doc.trolltech.com/latest/");
} }
QDesktopServices::openUrl(QUrl(urlPrefix + url.mid(url QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address
.lastIndexOf(QLatin1Char('/')) + 1))); .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) Q_EXPORT_PLUGIN(HelpPlugin)
...@@ -91,16 +91,13 @@ public: ...@@ -91,16 +91,13 @@ public:
void setIndexFilter(const QString &filter); void setIndexFilter(const QString &filter);
QString indexFilter() const; QString indexFilter() const;
void openHelpPage(const QString& url);
void openContextHelpPage(const QString &url);
QHelpEngine* helpEngine() const; QHelpEngine* helpEngine() const;
void setFilesToRegister(const QStringList &files); void setFilesToRegister(const QStringList &files);
public slots: public slots:
void pluginUpdateDocumentation(); void pluginUpdateDocumentation();
void handleHelpRequest(const QUrl &url); void handleHelpRequest(const QString &url);
private slots: private slots:
void modeChanged(Core::IMode *mode); void modeChanged(Core::IMode *mode);
......
...@@ -265,14 +265,14 @@ void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url) ...@@ -265,14 +265,14 @@ void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url)
Help::HelpManager *helpManager Help::HelpManager *helpManager
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>(); = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager); Q_ASSERT(helpManager);
helpManager->openHelpPage(url); helpManager->handleHelpRequest(url);
} }
void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url) void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url)
{ {
Help::HelpManager *helpManager Help::HelpManager *helpManager
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>(); = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager); Q_ASSERT(helpManager);
helpManager->openContextHelpPage(url); helpManager->handleHelpRequest(url);
} }
void GettingStartedWelcomePageWidget::slotNextTip() void GettingStartedWelcomePageWidget::slotNextTip()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment