Commit 2948651f authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Show tutorials in context help pane by default, but honor context help settings.

Reviewed-by: kh
parent 6ab034ba
......@@ -76,6 +76,7 @@
#include <QtGui/QToolBar>
#include <QtGui/QComboBox>
#include <QtGui/QDesktopServices>
#include <QtGui/QMessageBox>
#include <QtHelp/QHelpEngine>
#ifndef QT_NO_WEBKIT
......@@ -118,7 +119,7 @@ void HelpManager::registerDocumentation(const QStringList &fileNames)
void HelpManager::openHelpPage(const QString& url)
{
m_plugin->openHelpPage(url);
m_plugin->handleHelpRequest(url);
}
void HelpManager::openContextHelpPage(const QString& url)
......@@ -405,7 +406,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
createRightPaneSideBar();
QDesktopServices::setUrlHandler("qthelp", this, "openHelpPage");
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
if (Core::ActionContainer *advancedMenu =
am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
......@@ -674,12 +675,6 @@ void HelpPlugin::modeChanged(Core::IMode *mode)
}
}
void HelpPlugin::openContextHelpPage(const QString &url)
{
Core::RightPaneWidget::instance()->setShown(true);
m_helpViewerForSideBar->setSource(QUrl(url));
}
void HelpPlugin::updateSideBarSource()
{
const QUrl &url = m_centralWidget->currentSource();
......@@ -713,35 +708,9 @@ void HelpPlugin::fontChanged()
#endif
}
void HelpPlugin::activateContext()
HelpViewer* HelpPlugin::viewerForContextMode()
{
Core::RightPanePlaceHolder* placeHolder = Core::RightPanePlaceHolder::current();
if (placeHolder && Core::RightPaneWidget::instance()->hasFocus()) {
switchToHelpMode();
return;
} else if (m_core->modeManager()->currentMode() == m_mode)
return;
QString id;
QMap<QString, QUrl> links;
// Find out what to show
if (Core::IContext *context = m_core->currentContextObject()) {
if (!m_contextHelpEngine) {
m_contextHelpEngine =
new QHelpEngineCore(m_helpEngine->collectionFile(), this);
m_contextHelpEngine->setupData();
m_contextHelpEngine->setCurrentFilter(tr("Unfiltered"));
}
id = context->contextHelpId();
links = m_contextHelpEngine->linksForIdentifier(id);
}
HelpViewer *viewer = 0;
bool showSideBySide = false;
switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt())
......@@ -761,7 +730,8 @@ void HelpPlugin::activateContext()
break;
}
if (placeHolder && showSideBySide && !Core::RightPaneWidget::instance()->hasFocus()) {
Core::RightPanePlaceHolder* placeHolder = Core::RightPanePlaceHolder::current();
if (placeHolder && showSideBySide) {
Core::RightPaneWidget::instance()->setShown(true);
viewer = m_helpViewerForSideBar;
} else {
......@@ -770,6 +740,37 @@ void HelpPlugin::activateContext()
viewer = m_centralWidget->currentHelpViewer();
}
return viewer;
}
void HelpPlugin::activateContext()
{
Core::RightPanePlaceHolder* placeHolder = Core::RightPanePlaceHolder::current();
if (placeHolder && m_helpViewerForSideBar->hasFocus()) {
switchToHelpMode();
return;
} else if (m_core->modeManager()->currentMode() == m_mode)
return;
QString id;
QMap<QString, QUrl> links;
// Find out what to show
if (Core::IContext *context = m_core->currentContextObject()) {
if (!m_contextHelpEngine) {
m_contextHelpEngine =
new QHelpEngineCore(m_helpEngine->collectionFile(), this);
m_contextHelpEngine->setupData();
m_contextHelpEngine->setCurrentFilter(tr("Unfiltered"));
}
id = context->contextHelpId();
links = m_contextHelpEngine->linksForIdentifier(id);
}
QMessageBox::warning(0, "id", id);
HelpViewer* viewer = viewerForContextMode();
if (viewer) {
if (links.isEmpty()) {
// No link found or no context object
......@@ -876,9 +877,12 @@ void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url);
}
void HelpPlugin::openHelpPage(const QUrl& url)
void HelpPlugin::handleHelpRequest(const QUrl& url)
{
openHelpPage(url.toString());
if (url.queryItemValue("view") == QLatin1String("split"))
openContextHelpPage(url.toString());
else
openHelpPage(url.toString());
}
void HelpPlugin::openHelpPage(const QString& url)
......@@ -899,4 +903,13 @@ void HelpPlugin::openHelpPage(const QString& url)
}
}
void HelpPlugin::openContextHelpPage(const QString &url)
{
Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
if (modeManager->currentMode() == modeManager->mode(Core::Constants::MODE_WELCOME))
modeManager->activateMode(Core::Constants::MODE_EDIT);
HelpViewer* viewer = viewerForContextMode();
viewer->setSource(QUrl(url));
}
Q_EXPORT_PLUGIN(HelpPlugin)
......@@ -111,7 +111,7 @@ public:
void setIndexFilter(const QString &filter);
QString indexFilter() const;
void openHelpPage(const QUrl& url);
void handleHelpRequest(const QUrl& url);
void openHelpPage(const QString& url);
void openContextHelpPage(const QString &url);
......@@ -146,6 +146,7 @@ private:
QToolBar *createToolBar();
void createRightPaneSideBar();
void activateHelpMode();
HelpViewer* viewerForContextMode();
Core::ICore *m_core;
QHelpEngine *m_helpEngine;
......
......@@ -48,8 +48,6 @@
namespace Qt4ProjectManager {
namespace Internal {
// TODO: remove
GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::GettingStartedWelcomePageWidget)
......@@ -67,13 +65,13 @@ GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent
ui->tutorialTreeWidget->addItem(tr("<b>Qt Creator - A quick tour</b>"),
QString("qthelp://com.nokia.qtcreator.%1%2/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR));
ui->tutorialTreeWidget->addItem(tr("Creating an address book"),
QLatin1String("qthelp://com.nokia.qtcreator/doc/tutorials-addressbook-sdk.html"));
QLatin1String("qthelp://com.nokia.qtcreator/doc/tutorials-addressbook-sdk.html?view=split"));
ui->tutorialTreeWidget->addItem(tr("Understanding widgets"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/widgets-tutorial.html"));
QLatin1String("qthelp://com.trolltech.qt/qdoc/widgets-tutorial.html?view=split"));
ui->tutorialTreeWidget->addItem(tr("Building with qmake"),
QLatin1String("qthelp://com.trolltech.qmake/qdoc/qmake-tutorial.html"));
QLatin1String("qthelp://com.trolltech.qmake/qdoc/qmake-tutorial.html?view=split"));
ui->tutorialTreeWidget->addItem(tr("Writing test cases"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html"));
QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html?view=split"));
srand(QDateTime::currentDateTime().toTime_t());
QStringList tips = tipsOfTheDay();
......
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