2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helpplugin.h"
|
2009-06-25 17:16:16 +02:00
|
|
|
|
|
|
|
|
#include "bookmarkmanager.h"
|
|
|
|
|
#include "centralwidget.h"
|
|
|
|
|
#include "contentwindow.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "docsettingspage.h"
|
|
|
|
|
#include "filtersettingspage.h"
|
2009-06-25 17:16:16 +02:00
|
|
|
#include "generalsettingspage.h"
|
2010-03-23 17:05:09 +01:00
|
|
|
#include "helpconstants.h"
|
2009-06-25 17:16:16 +02:00
|
|
|
#include "helpfindsupport.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helpindexfilter.h"
|
2010-02-02 14:25:22 +01:00
|
|
|
#include "helpmanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helpmode.h"
|
|
|
|
|
#include "helpviewer.h"
|
|
|
|
|
#include "indexwindow.h"
|
|
|
|
|
#include "searchwidget.h"
|
|
|
|
|
|
2009-01-13 13:39:31 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2009-07-21 11:10:02 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2009-07-21 11:10:02 +02:00
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2008-12-02 16:19:05 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/modemanager.h>
|
2010-03-02 10:53:46 +01:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2008-12-02 16:19:05 +01:00
|
|
|
#include <coreplugin/rightpane.h>
|
|
|
|
|
#include <coreplugin/sidebar.h>
|
2009-07-21 11:10:02 +02:00
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-06-23 16:57:03 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2009-07-17 15:04:14 +02:00
|
|
|
#include <utils/styledbar.h>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <welcome/welcomemode.h>
|
2009-07-17 15:04:14 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDir>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <QtCore/QFileInfo>
|
2010-03-02 10:53:46 +01:00
|
|
|
#include <QtCore/QFuture>
|
2009-04-20 16:41:06 +02:00
|
|
|
#include <QtCore/QLibraryInfo>
|
|
|
|
|
#include <QtCore/QTranslator>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <QtCore/qplugin.h>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QAction>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <QtGui/QComboBox>
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
#include <QtGui/QDesktopServices>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QShortcut>
|
|
|
|
|
#include <QtGui/QSplitter>
|
|
|
|
|
#include <QtGui/QToolBar>
|
2010-02-02 14:25:22 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtHelp/QHelpEngine>
|
2010-03-02 10:53:46 +01:00
|
|
|
#include <QtHelp/QHelpSearchEngine>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 14:25:22 +01:00
|
|
|
#if defined(QT_NO_WEBKIT)
|
|
|
|
|
# include <QtGui/QApplication>
|
2009-06-25 16:07:57 +02:00
|
|
|
#else
|
2010-02-02 14:25:22 +01:00
|
|
|
# include <QtWebKit/QWebSettings>
|
2009-04-22 18:17:50 +02:00
|
|
|
#endif
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Help;
|
|
|
|
|
using namespace Help::Internal;
|
|
|
|
|
|
2010-03-04 18:46:16 +01:00
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
|
# define DOCPATH "/../Resources/doc/"
|
|
|
|
|
#else
|
2010-03-11 12:16:08 +01:00
|
|
|
# define DOCPATH "/../share/doc/qtcreator/"
|
2010-03-04 18:46:16 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-02-02 14:25:22 +01:00
|
|
|
HelpPlugin::HelpPlugin()
|
|
|
|
|
: m_core(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_helpEngine(0),
|
|
|
|
|
m_contentWidget(0),
|
|
|
|
|
m_indexWidget(0),
|
|
|
|
|
m_centralWidget(0),
|
|
|
|
|
m_helpViewerForSideBar(0),
|
|
|
|
|
m_mode(0),
|
|
|
|
|
m_contentItem(0),
|
|
|
|
|
m_indexItem(0),
|
|
|
|
|
m_searchItem(0),
|
|
|
|
|
m_bookmarkItem(0),
|
2010-03-05 16:06:41 +01:00
|
|
|
m_progress(0),
|
|
|
|
|
isInitialised(false),
|
|
|
|
|
firstModeChange(true)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpPlugin::~HelpPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(error)
|
2009-01-20 11:52:04 +01:00
|
|
|
m_core = Core::ICore::instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<int> globalcontext;
|
|
|
|
|
globalcontext << Core::Constants::C_GLOBAL_ID;
|
|
|
|
|
QList<int> modecontext;
|
|
|
|
|
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
|
|
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
const QString &locale = qApp->property("qtc_locale").toString();
|
2009-04-20 16:41:06 +02:00
|
|
|
if (!locale.isEmpty()) {
|
|
|
|
|
QTranslator *qtr = new QTranslator(this);
|
2009-06-10 13:27:05 +02:00
|
|
|
QTranslator *qhelptr = new QTranslator(this);
|
2010-02-02 12:33:13 +01:00
|
|
|
const QString &creatorTrPath = Core::ICore::instance()->resourcePath()
|
|
|
|
|
+ QLatin1String("/translations");
|
2009-06-10 13:27:05 +02:00
|
|
|
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
|
|
|
const QString &trFile = QLatin1String("assistant_") + locale;
|
|
|
|
|
const QString &helpTrFile = QLatin1String("qt_help_") + locale;
|
|
|
|
|
if (qtr->load(trFile, qtTrPath) || qtr->load(trFile, creatorTrPath))
|
|
|
|
|
qApp->installTranslator(qtr);
|
|
|
|
|
if (qhelptr->load(helpTrFile, qtTrPath) || qhelptr->load(helpTrFile, creatorTrPath))
|
|
|
|
|
qApp->installTranslator(qhelptr);
|
2009-04-20 16:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
2009-04-22 18:17:50 +02:00
|
|
|
#ifndef QT_NO_WEBKIT
|
|
|
|
|
QWebSettings *webSettings = QWebSettings::globalSettings();
|
|
|
|
|
const QFont applicationFont = QApplication::font();
|
|
|
|
|
webSettings->setFontFamily(QWebSettings::StandardFont, applicationFont.family());
|
|
|
|
|
//webSettings->setFontSize(QWebSettings::DefaultFontSize, applicationFont.pointSize());
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
addAutoReleasedObject(helpManager = new HelpManager(this));
|
|
|
|
|
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
|
|
|
|
|
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
|
2009-06-25 17:16:16 +02:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
connect(m_docSettingsPage, SIGNAL(documentationChanged()),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_filterSettingsPage, SLOT(updateFilterPage()));
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_docSettingsPage, SIGNAL(dialogAccepted()), this,
|
|
|
|
|
SLOT(checkForHelpChanges()));
|
2010-03-16 15:48:09 +01:00
|
|
|
connect(helpManager, SIGNAL(registerDocumentation()), this,
|
|
|
|
|
SLOT(slotRegisterDocumentation()));
|
|
|
|
|
|
|
|
|
|
// force a block here to avoid the expensive indexing restart signal, etc...
|
|
|
|
|
m_helpEngine = new QHelpEngine("", this);
|
|
|
|
|
m_helpEngine->blockSignals(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
m_contentWidget = new ContentWindow(m_helpEngine);
|
|
|
|
|
m_contentWidget->setWindowTitle(tr("Contents"));
|
|
|
|
|
m_indexWidget = new IndexWindow(m_helpEngine);
|
|
|
|
|
m_indexWidget->setWindowTitle(tr("Index"));
|
|
|
|
|
m_searchWidget = new SearchWidget(m_helpEngine->searchEngine());
|
|
|
|
|
m_searchWidget->setWindowTitle(tr("Search"));
|
|
|
|
|
m_bookmarkManager = new BookmarkManager(m_helpEngine);
|
|
|
|
|
m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, 0, false);
|
|
|
|
|
m_bookmarkWidget->setWindowTitle(tr("Bookmarks"));
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-13 13:39:31 +01:00
|
|
|
Core::ActionManager *am = m_core->actionManager();
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::Command *cmd;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Add Home, Previous and Next actions (used in the toolbar)
|
2009-06-02 18:41:12 +02:00
|
|
|
QAction *homeAction =
|
|
|
|
|
new QAction(QIcon(QLatin1String(":/help/images/home.png")), tr("Home"),
|
|
|
|
|
this);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd = am->registerAction(homeAction, QLatin1String("Help.Home"), globalcontext);
|
|
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
QAction *previousAction =
|
|
|
|
|
new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
|
2009-07-17 18:08:59 +02:00
|
|
|
tr("Previous Page"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(previousAction, QLatin1String("Help.Previous"),
|
|
|
|
|
modecontext);
|
2009-06-02 12:56:16 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Back);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
QAction *nextAction =
|
2009-07-17 18:08:59 +02:00
|
|
|
new QAction(QIcon(QLatin1String(":/help/images/next.png")), tr("Next Page"),
|
2009-06-02 18:41:12 +02:00
|
|
|
this);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd = am->registerAction(nextAction, QLatin1String("Help.Next"), modecontext);
|
2009-06-02 12:56:16 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Forward);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
QAction *addBookmarkAction =
|
|
|
|
|
new QAction(QIcon(QLatin1String(":/help/images/bookmark.png")),
|
2008-12-02 12:01:29 +01:00
|
|
|
tr("Add Bookmark"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(addBookmarkAction, QLatin1String("Help.AddBookmark"),
|
|
|
|
|
modecontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_M));
|
|
|
|
|
|
|
|
|
|
// Add Index, Contents, and Context menu items and a separator to the Help menu
|
|
|
|
|
QAction *indexAction = new QAction(tr("Index"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(indexAction, QLatin1String("Help.Index"),
|
|
|
|
|
globalcontext);
|
|
|
|
|
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
|
|
|
|
|
Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *contentsAction = new QAction(tr("Contents"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(contentsAction, QLatin1String("Help.Contents"),
|
|
|
|
|
globalcontext);
|
|
|
|
|
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
|
|
|
|
|
Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *searchAction = new QAction(tr("Search"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(searchAction, QLatin1String("Help.Search"),
|
|
|
|
|
globalcontext);
|
|
|
|
|
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
|
|
|
|
|
Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *contextAction = new QAction(tr("Context Help"), this);
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerAction(contextAction, QLatin1String("Help.Context"),
|
|
|
|
|
globalcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
2009-06-02 18:41:12 +02:00
|
|
|
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
|
|
|
|
|
Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-03 20:45:49 +02:00
|
|
|
#ifndef Q_WS_MAC
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *sep = new QAction(this);
|
|
|
|
|
sep->setSeparator(true);
|
|
|
|
|
cmd = am->registerAction(sep, QLatin1String("Help.Separator"), globalcontext);
|
2009-06-02 18:41:12 +02:00
|
|
|
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd,
|
|
|
|
|
Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
2009-05-07 15:34:52 +02:00
|
|
|
m_centralWidget = new Help::Internal::CentralWidget(m_helpEngine);
|
2008-12-02 12:01:29 +01:00
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
|
|
|
|
agg->add(m_centralWidget);
|
|
|
|
|
agg->add(new HelpFindSupport(m_centralWidget));
|
|
|
|
|
QWidget *mainWidget = new QWidget;
|
|
|
|
|
QVBoxLayout *mainWidgetLayout = new QVBoxLayout(mainWidget);
|
|
|
|
|
mainWidgetLayout->setMargin(0);
|
|
|
|
|
mainWidgetLayout->setSpacing(0);
|
|
|
|
|
mainWidgetLayout->addWidget(createToolBar());
|
|
|
|
|
mainWidgetLayout->addWidget(m_centralWidget);
|
|
|
|
|
|
|
|
|
|
m_contentItem = new Core::SideBarItem(m_contentWidget);
|
|
|
|
|
m_indexItem = new Core::SideBarItem(m_indexWidget);
|
|
|
|
|
m_searchItem = new Core::SideBarItem(m_searchWidget);
|
|
|
|
|
m_bookmarkItem = new Core::SideBarItem(m_bookmarkWidget);
|
|
|
|
|
QList<Core::SideBarItem*> itemList;
|
|
|
|
|
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem;
|
|
|
|
|
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>() << m_indexItem);
|
|
|
|
|
|
|
|
|
|
QSplitter *splitter = new Core::MiniSplitter;
|
|
|
|
|
splitter->setOpaqueResize(false);
|
|
|
|
|
splitter->addWidget(m_sideBar);
|
|
|
|
|
splitter->addWidget(mainWidget);
|
|
|
|
|
splitter->setStretchFactor(0, 0);
|
|
|
|
|
splitter->setStretchFactor(1, 1);
|
|
|
|
|
splitter->setSizes(QList<int>() << 300 << 300);
|
|
|
|
|
|
|
|
|
|
m_mode = new HelpMode(splitter, m_centralWidget);
|
|
|
|
|
m_mode->setContext(QList<int>() << modecontext);
|
|
|
|
|
addAutoReleasedObject(m_mode);
|
|
|
|
|
|
|
|
|
|
QAction *printAction = new QAction(this);
|
|
|
|
|
am->registerAction(printAction, Core::Constants::PRINT, modecontext);
|
|
|
|
|
connect(printAction, SIGNAL(triggered()), m_centralWidget, SLOT(print()));
|
|
|
|
|
|
|
|
|
|
QAction *copyAction = new QAction(this);
|
|
|
|
|
cmd = am->registerAction(copyAction, Core::Constants::COPY, modecontext);
|
|
|
|
|
connect(copyAction, SIGNAL(triggered()), m_centralWidget, SLOT(copy()));
|
|
|
|
|
copyAction->setText(cmd->action()->text());
|
|
|
|
|
copyAction->setIcon(cmd->action()->icon());
|
|
|
|
|
|
2009-01-14 13:17:53 +01:00
|
|
|
QMap<QString, Core::Command*> shortcutMap;
|
2008-12-02 12:01:29 +01:00
|
|
|
QShortcut *shortcut = new QShortcut(splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.IndexShortcut"),
|
|
|
|
|
modecontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_I));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
|
|
|
|
|
shortcutMap.insert(m_indexWidget->windowTitle(), cmd);
|
|
|
|
|
|
|
|
|
|
shortcut = new QShortcut(splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"),
|
|
|
|
|
modecontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_T));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
|
|
|
|
|
shortcutMap.insert(m_contentWidget->windowTitle(), cmd);
|
|
|
|
|
|
|
|
|
|
shortcut = new QShortcut(splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Search in Help mode"));
|
2009-06-02 18:41:12 +02:00
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"),
|
|
|
|
|
modecontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_S));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
|
|
|
|
|
shortcutMap.insert(m_searchWidget->windowTitle(), cmd);
|
|
|
|
|
shortcutMap.insert(m_bookmarkWidget->windowTitle(), 0);
|
|
|
|
|
|
|
|
|
|
m_sideBar->setShortcutMap(shortcutMap);
|
|
|
|
|
|
|
|
|
|
connect(homeAction, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
|
|
|
|
|
connect(previousAction, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
|
|
|
|
|
connect(nextAction, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
|
|
|
|
|
connect(addBookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_contentWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(m_indexWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)),
|
|
|
|
|
m_centralWidget, SLOT(setSourceInNewTab(QUrl)));
|
|
|
|
|
connect(m_bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(const QUrl&)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)),
|
|
|
|
|
previousAction, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)),
|
|
|
|
|
nextAction, SLOT(setEnabled(bool)));
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this,
|
|
|
|
|
SLOT(addNewBookmark(QString, QString)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<QAction*> actionList;
|
|
|
|
|
actionList << previousAction
|
|
|
|
|
<< nextAction
|
|
|
|
|
<< homeAction
|
2009-06-03 20:45:49 +02:00
|
|
|
#ifndef Q_WS_MAC
|
2008-12-02 12:01:29 +01:00
|
|
|
<< sep
|
|
|
|
|
#endif
|
|
|
|
|
<< copyAction;
|
|
|
|
|
m_centralWidget->setGlobalActions(actionList);
|
|
|
|
|
|
|
|
|
|
connect(contextAction, SIGNAL(triggered()), this, SLOT(activateContext()));
|
|
|
|
|
connect(indexAction, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
|
|
|
|
connect(contentsAction, SIGNAL(triggered()), this, SLOT(activateContents()));
|
|
|
|
|
connect(searchAction, SIGNAL(triggered()), this, SLOT(activateSearch()));
|
|
|
|
|
|
|
|
|
|
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
|
|
|
|
this, SLOT(modeChanged(Core::IMode*)));
|
|
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_contentWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(m_indexWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(m_indexWidget, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
|
|
|
|
|
m_centralWidget, SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
previousAction->setEnabled(m_centralWidget->isBackwardAvailable());
|
|
|
|
|
nextAction->setEnabled(m_centralWidget->isForwardAvailable());
|
|
|
|
|
|
2009-08-06 15:47:31 +02:00
|
|
|
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
|
2009-05-12 19:46:40 +02:00
|
|
|
|
2009-06-23 16:57:03 +02:00
|
|
|
if (Core::ActionContainer *advancedMenu =
|
|
|
|
|
am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
|
|
|
|
// reuse TextEditor constants to avoid a second pair of menu actions
|
|
|
|
|
QAction *a = new QAction(tr("Increase Font Size"), this);
|
|
|
|
|
cmd = am->registerAction(a, TextEditor::Constants::INCREASE_FONT_SIZE,
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
|
|
|
|
|
connect(a, SIGNAL(triggered()), m_centralWidget, SLOT(zoomIn()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-11-19 11:23:52 +01:00
|
|
|
|
2009-06-23 16:57:03 +02:00
|
|
|
a = new QAction(tr("Decrease Font Size"), this);
|
|
|
|
|
cmd = am->registerAction(a, TextEditor::Constants::DECREASE_FONT_SIZE,
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
|
|
|
|
|
connect(a, SIGNAL(triggered()), m_centralWidget, SLOT(zoomOut()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-06-25 16:03:02 +02:00
|
|
|
|
|
|
|
|
a = new QAction(tr("Reset Font Size"), this);
|
2009-11-30 19:13:20 +01:00
|
|
|
cmd = am->registerAction(a, TextEditor::Constants::RESET_FONT_SIZE,
|
2009-06-25 16:03:02 +02:00
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+0")));
|
|
|
|
|
connect(a, SIGNAL(triggered()), m_centralWidget, SLOT(resetZoom()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-06-23 16:57:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-16 14:47:27 +01:00
|
|
|
generalSettingsPage = new GeneralSettingsPage(m_bookmarkManager);
|
|
|
|
|
addAutoReleasedObject(generalSettingsPage);
|
|
|
|
|
connect(generalSettingsPage, SIGNAL(fontChanged()), this, SLOT(fontChanged()));
|
|
|
|
|
connect(generalSettingsPage, SIGNAL(dialogAccepted()), this,
|
|
|
|
|
SLOT(checkForGeneralChanges()));
|
2010-03-23 17:54:38 +01:00
|
|
|
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
|
|
|
|
|
addAutoReleasedObject(helpIndexFilter);
|
|
|
|
|
connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this,
|
|
|
|
|
SLOT(switchToHelpMode(QUrl)));
|
|
|
|
|
connect(helpIndexFilter, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
|
|
|
|
|
this, SLOT(switchToHelpMode(QMap<QString, QUrl>, QString)));
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-27 13:55:30 +02:00
|
|
|
QHelpEngine* HelpPlugin::helpEngine() const
|
|
|
|
|
{
|
|
|
|
|
return m_helpEngine;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-02 11:40:45 +01:00
|
|
|
void HelpPlugin::setFilesToRegister(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
filesToRegister += files;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
void HelpPlugin::slotRegisterDocumentation()
|
2010-02-02 11:40:45 +01:00
|
|
|
{
|
2010-03-16 15:48:09 +01:00
|
|
|
if (isInitialised) {
|
|
|
|
|
if (registerDocumentation())
|
|
|
|
|
m_helpEngine->setupData();
|
|
|
|
|
}
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:28:31 +01:00
|
|
|
void HelpPlugin::resetFilter()
|
|
|
|
|
{
|
|
|
|
|
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
|
|
|
|
|
const QLatin1String previousFilterNameKey("UnfilteredFilterName");
|
|
|
|
|
if (m_helpEngine->customValue(weAddedFilterKey).toInt() == 1) {
|
|
|
|
|
// we added a filter at some point, remove previously added filter
|
|
|
|
|
const QString &previousFilter =
|
|
|
|
|
m_helpEngine->customValue(previousFilterNameKey).toString();
|
|
|
|
|
if (!previousFilter.isEmpty())
|
|
|
|
|
m_helpEngine->removeCustomFilter(previousFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// potentially remove a filter with new name
|
|
|
|
|
const QString filterName = tr("Unfiltered");
|
|
|
|
|
m_helpEngine->removeCustomFilter(filterName);
|
|
|
|
|
m_helpEngine->addCustomFilter(filterName, QStringList());
|
|
|
|
|
m_helpEngine->setCustomValue(weAddedFilterKey, 1);
|
|
|
|
|
m_helpEngine->setCustomValue(previousFilterNameKey, filterName);
|
|
|
|
|
m_helpEngine->setCurrentFilter(filterName);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
bool HelpPlugin::verifiyDocumentation()
|
2010-02-02 11:40:45 +01:00
|
|
|
{
|
2010-03-16 15:48:09 +01:00
|
|
|
QStringList nameSpacesToUnregister;
|
2010-03-04 18:46:16 +01:00
|
|
|
const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations();
|
|
|
|
|
foreach (const QString &nameSpace, registeredDocs) {
|
|
|
|
|
const QString &file = m_helpEngine->documentationFileName(nameSpace);
|
2010-03-16 15:48:09 +01:00
|
|
|
if (!QFileInfo(file).exists())
|
|
|
|
|
nameSpacesToUnregister.append(nameSpace);
|
2010-03-04 18:46:16 +01:00
|
|
|
}
|
2010-02-02 11:40:45 +01:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
if (!nameSpacesToUnregister.isEmpty())
|
|
|
|
|
return unregisterDocumentation(nameSpacesToUnregister);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool HelpPlugin::registerDocumentation()
|
|
|
|
|
{
|
|
|
|
|
bool needsSetup = false;
|
2010-03-04 18:46:16 +01:00
|
|
|
foreach (const QString &file, filesToRegister) {
|
|
|
|
|
const QString &nameSpace = m_helpEngine->namespaceName(file);
|
|
|
|
|
if (nameSpace.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
|
|
|
|
|
if (m_helpEngine->registerDocumentation(file)) {
|
|
|
|
|
needsSetup = true;
|
|
|
|
|
} else {
|
2010-03-16 15:48:09 +01:00
|
|
|
qWarning() << "Error registering namespace '" << nameSpace
|
|
|
|
|
<< "' from file '" << file << "':" << m_helpEngine->error();
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-04 18:46:16 +01:00
|
|
|
filesToRegister.clear();
|
2010-03-16 15:48:09 +01:00
|
|
|
return needsSetup;
|
|
|
|
|
}
|
2010-03-04 18:46:16 +01:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
bool HelpPlugin::unregisterDocumentation(const QStringList &nameSpaces)
|
|
|
|
|
{
|
|
|
|
|
bool needsSetup = false;
|
|
|
|
|
foreach (const QString &nameSpace, nameSpaces) {
|
|
|
|
|
const QString &file = m_helpEngine->documentationFileName(nameSpace);
|
|
|
|
|
if (m_helpEngine->unregisterDocumentation(nameSpace)) {
|
|
|
|
|
needsSetup = true;
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "Error unregistering namespace '" << nameSpace
|
|
|
|
|
<< "' from file '" << file << "': " << m_helpEngine->error();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-02 11:40:45 +01:00
|
|
|
return needsSetup;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 19:31:29 +01:00
|
|
|
void HelpPlugin::createRightPaneContextViewer()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-16 15:21:06 +01:00
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-16 15:21:06 +01:00
|
|
|
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), this);
|
|
|
|
|
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-16 15:21:06 +01:00
|
|
|
QAction *next = new QAction(QIcon(QLatin1String(":/help/images/next.png")),
|
|
|
|
|
tr("Next"), this);
|
|
|
|
|
connect(next, SIGNAL(triggered()), this, SLOT(rightPaneForward()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-16 15:21:06 +01:00
|
|
|
QAction *previous = new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
|
|
|
|
|
tr("Previous"), this);
|
|
|
|
|
connect(previous, SIGNAL(triggered()), this, SLOT(rightPaneBackward()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Dummy layout to align the close button to the right
|
|
|
|
|
QHBoxLayout *hboxLayout = new QHBoxLayout();
|
|
|
|
|
hboxLayout->setSpacing(0);
|
|
|
|
|
hboxLayout->setMargin(0);
|
2010-03-16 15:21:06 +01:00
|
|
|
|
|
|
|
|
// left side actions
|
|
|
|
|
QToolBar *rightPaneToolBar = new QToolBar();
|
|
|
|
|
rightPaneToolBar->addAction(switchToHelp);
|
|
|
|
|
rightPaneToolBar->addAction(previous);
|
|
|
|
|
rightPaneToolBar->addAction(next);
|
|
|
|
|
|
2009-07-17 15:04:14 +02:00
|
|
|
hboxLayout->addWidget(rightPaneToolBar);
|
2010-03-16 15:21:06 +01:00
|
|
|
hboxLayout->addStretch();
|
|
|
|
|
|
|
|
|
|
QToolButton *closeButton = new QToolButton();
|
|
|
|
|
closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(closeButton, SIGNAL(clicked()), this, SLOT(slotHideRightPane()));
|
|
|
|
|
|
2010-03-16 15:21:06 +01:00
|
|
|
// close button to the right
|
|
|
|
|
hboxLayout->addWidget(closeButton);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QVBoxLayout *rightPaneLayout = new QVBoxLayout;
|
|
|
|
|
rightPaneLayout->setMargin(0);
|
|
|
|
|
rightPaneLayout->setSpacing(0);
|
|
|
|
|
|
2010-03-16 15:21:06 +01:00
|
|
|
QWidget *rightPaneSideBar = new QWidget;
|
|
|
|
|
rightPaneSideBar->setLayout(rightPaneLayout);
|
|
|
|
|
addAutoReleasedObject(new Core::BaseRightPaneWidget(rightPaneSideBar));
|
|
|
|
|
|
|
|
|
|
Utils::StyledBar *rightPaneStyledBar = new Utils::StyledBar;
|
|
|
|
|
rightPaneStyledBar->setLayout(hboxLayout);
|
|
|
|
|
rightPaneLayout->addWidget(rightPaneStyledBar);
|
|
|
|
|
|
2010-03-23 16:56:59 +01:00
|
|
|
m_helpViewerForSideBar = new HelpViewer(0, rightPaneSideBar);
|
2010-03-16 15:21:06 +01:00
|
|
|
rightPaneLayout->addWidget(m_helpViewerForSideBar);
|
|
|
|
|
rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar));
|
|
|
|
|
rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar);
|
|
|
|
|
|
2009-03-17 17:47:14 +01:00
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
|
|
|
|
|
agg->add(m_helpViewerForSideBar);
|
|
|
|
|
agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar));
|
2010-03-16 15:21:06 +01:00
|
|
|
m_core->addContextObject(new Core::BaseContext(m_helpViewerForSideBar, QList<int>()
|
|
|
|
|
<< m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR), this));
|
|
|
|
|
|
2009-06-25 17:16:16 +02:00
|
|
|
#if defined(QT_NO_WEBKIT)
|
|
|
|
|
QFont font = m_helpViewerForSideBar->font();
|
|
|
|
|
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"),
|
|
|
|
|
font));
|
|
|
|
|
m_helpViewerForSideBar->setFont(font);
|
|
|
|
|
#endif
|
2009-06-02 16:30:56 +02:00
|
|
|
|
2009-03-13 12:10:28 +01:00
|
|
|
QAction *copyActionSideBar = new QAction(this);
|
|
|
|
|
Core::Command *cmd = m_core->actionManager()->registerAction(copyActionSideBar,
|
|
|
|
|
Core::Constants::COPY, QList<int>()
|
|
|
|
|
<< m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR));
|
|
|
|
|
connect(copyActionSideBar, SIGNAL(triggered()), this, SLOT(copyFromSideBar()));
|
|
|
|
|
copyActionSideBar->setText(cmd->action()->text());
|
|
|
|
|
copyActionSideBar->setIcon(cmd->action()->icon());
|
2010-03-16 15:21:06 +01:00
|
|
|
|
|
|
|
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
|
|
|
|
SLOT(updateSideBarSource(QUrl)));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
|
|
|
|
|
SLOT(updateSideBarSource()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-13 12:10:28 +01:00
|
|
|
void HelpPlugin::copyFromSideBar()
|
|
|
|
|
{
|
|
|
|
|
m_helpViewerForSideBar->copy();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void HelpPlugin::rightPaneBackward()
|
|
|
|
|
{
|
|
|
|
|
m_helpViewerForSideBar->backward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::rightPaneForward()
|
|
|
|
|
{
|
|
|
|
|
m_helpViewerForSideBar->forward();
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-28 13:57:42 +01:00
|
|
|
void HelpPlugin::activateHelpMode()
|
|
|
|
|
{
|
|
|
|
|
m_core->modeManager()->activateMode(QLatin1String(Constants::ID_MODE_HELP));
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void HelpPlugin::switchToHelpMode()
|
|
|
|
|
{
|
|
|
|
|
switchToHelpMode(m_helpViewerForSideBar->source());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::switchToHelpMode(const QUrl &source)
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_centralWidget->setSource(source);
|
|
|
|
|
m_centralWidget->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
void HelpPlugin::switchToHelpMode(const QMap<QString, QUrl> &urls,
|
|
|
|
|
const QString &keyword)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_centralWidget->showTopicChooser(urls, keyword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::slotHideRightPane()
|
|
|
|
|
{
|
|
|
|
|
Core::RightPaneWidget::instance()->setShown(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2010-01-04 14:36:29 +01:00
|
|
|
m_sideBar->readSettings(m_core->settings(), QLatin1String("HelpSideBar"));
|
2010-02-02 11:40:45 +01:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
m_helpEngine->setCollectionFile(HelpManager::collectionFilePath());
|
|
|
|
|
m_helpEngine->setAutoSaveFilter(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-01 12:43:56 +01:00
|
|
|
const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
|
2009-09-15 17:26:44 +02:00
|
|
|
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
2010-02-02 11:40:45 +01:00
|
|
|
|
|
|
|
|
bool assistantInternalDocRegistered = false;
|
2009-06-02 18:41:12 +02:00
|
|
|
const QStringList &docs = m_helpEngine->registeredDocumentations();
|
|
|
|
|
foreach (const QString &ns, docs) {
|
|
|
|
|
if (ns == docInternal) {
|
2008-12-02 12:01:29 +01:00
|
|
|
assistantInternalDocRegistered = true;
|
2010-02-01 12:43:56 +01:00
|
|
|
} else if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))) {
|
2010-02-02 11:40:45 +01:00
|
|
|
m_helpEngine->unregisterDocumentation(ns);
|
2009-09-15 18:41:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
2009-09-15 17:26:44 +02:00
|
|
|
|
2010-02-02 11:40:45 +01:00
|
|
|
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
|
|
|
|
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 11:40:45 +01:00
|
|
|
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
|
|
|
|
|
const QStringList &filters = m_helpEngine->customFilters();
|
|
|
|
|
foreach (const QString &filter, filters) {
|
|
|
|
|
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
|
|
|
|
|
m_helpEngine->removeCustomFilter(filter);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-04 18:46:16 +01:00
|
|
|
// Explicitly register qml.qch if located in creator directory. This is only
|
|
|
|
|
// needed for the creator-qml package, were we want to ship the documentation
|
|
|
|
|
// without a qt development version.
|
|
|
|
|
const QString &appPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
|
|
|
|
|
+ QLatin1String(DOCPATH "qml.qch"))));
|
|
|
|
|
|
|
|
|
|
// we might need to register creators inbuild help
|
|
|
|
|
if (!assistantInternalDocRegistered) {
|
|
|
|
|
filesToRegister.append(QDir::cleanPath(appPath
|
|
|
|
|
+ QLatin1String(DOCPATH "qtcreator.qch")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this comes from the installer
|
2010-02-02 11:40:45 +01:00
|
|
|
const QLatin1String key("AddedDocs");
|
|
|
|
|
const QString &addedDocs = m_helpEngine->customValue(key).toString();
|
2009-10-21 12:37:26 +02:00
|
|
|
if (!addedDocs.isEmpty()) {
|
2010-02-02 11:40:45 +01:00
|
|
|
m_helpEngine->removeCustomValue(key);
|
|
|
|
|
filesToRegister += addedDocs.split(QLatin1Char(';'));
|
2009-10-21 12:37:26 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
verifiyDocumentation();
|
|
|
|
|
registerDocumentation();
|
|
|
|
|
m_bookmarkManager->setupBookmarkModels();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-25 17:16:16 +02:00
|
|
|
#if !defined(QT_NO_WEBKIT)
|
|
|
|
|
QWebSettings* webSettings = QWebSettings::globalSettings();
|
|
|
|
|
QFont font(webSettings->fontFamily(QWebSettings::StandardFont),
|
|
|
|
|
webSettings->fontSize(QWebSettings::DefaultFontSize));
|
|
|
|
|
|
|
|
|
|
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"),
|
|
|
|
|
font));
|
2009-11-19 11:23:52 +01:00
|
|
|
|
2009-06-25 17:16:16 +02:00
|
|
|
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
|
|
|
|
|
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
|
|
|
|
|
#endif
|
2009-06-26 16:50:50 +02:00
|
|
|
|
2010-03-10 15:02:24 +01:00
|
|
|
const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
|
|
|
|
|
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
|
|
|
|
|
.arg(IDE_VERSION_RELEASE);
|
|
|
|
|
m_helpEngine->setCustomValue(QLatin1String("DefaultHomePage"), url);
|
2010-01-18 15:18:23 +01:00
|
|
|
|
|
|
|
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
|
|
|
|
SLOT(rebuildViewerComboBox()));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
|
|
|
|
|
SLOT(updateViewerComboBoxIndex(int)));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
|
|
|
|
|
SLOT(removeViewerFromComboBox(int)));
|
2010-02-02 11:40:45 +01:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
// explicit disconnect the full text search indexer, we connect and start
|
|
|
|
|
// it later once we really need it, e.g. the full text search is opened...
|
|
|
|
|
disconnect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(),
|
|
|
|
|
SLOT(indexDocumentation()));
|
|
|
|
|
|
|
|
|
|
connect(m_helpEngine, SIGNAL(setupFinished()), this,
|
|
|
|
|
SLOT(updateFilterComboBox()));
|
|
|
|
|
connect(m_helpEngine->searchEngine(), SIGNAL(indexingStarted()), this,
|
|
|
|
|
SLOT(indexingStarted()));
|
|
|
|
|
connect(m_helpEngine->searchEngine(), SIGNAL(indexingFinished()), this,
|
|
|
|
|
SLOT(indexingFinished()));
|
2010-03-04 18:46:16 +01:00
|
|
|
|
2010-03-16 15:48:09 +01:00
|
|
|
isInitialised = true; // helper for slotRegisterDocumentation()
|
|
|
|
|
m_helpEngine->blockSignals(false); // blocked in initialize()
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::shutdown()
|
|
|
|
|
{
|
2010-01-04 14:36:29 +01:00
|
|
|
m_sideBar->saveSettings(m_core->settings(), QLatin1String("HelpSideBar"));
|
2008-12-02 12:01:29 +01:00
|
|
|
m_bookmarkManager->saveBookmarks();
|
|
|
|
|
delete m_bookmarkManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::setIndexFilter(const QString &filter)
|
|
|
|
|
{
|
|
|
|
|
m_indexWidget->setSearchLineEditText(filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString HelpPlugin::indexFilter() const
|
|
|
|
|
{
|
|
|
|
|
return m_indexWidget->searchLineEditText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::modeChanged(Core::IMode *mode)
|
|
|
|
|
{
|
2010-03-05 16:06:41 +01:00
|
|
|
if (mode == m_mode && firstModeChange) {
|
|
|
|
|
firstModeChange = false;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
qApp->processEvents();
|
|
|
|
|
qApp->setOverrideCursor(Qt::WaitCursor);
|
2010-03-05 16:06:41 +01:00
|
|
|
|
2010-03-16 15:28:31 +01:00
|
|
|
resetFilter();
|
2010-03-16 15:48:09 +01:00
|
|
|
m_helpEngine->setupData();
|
2010-03-05 16:06:41 +01:00
|
|
|
connect(m_helpEngine, SIGNAL(setupFinished()), m_helpEngine->searchEngine(),
|
|
|
|
|
SLOT(indexDocumentation()));
|
|
|
|
|
QMetaObject::invokeMethod(m_helpEngine, "setupFinished", Qt::QueuedConnection);
|
2010-03-16 15:48:09 +01:00
|
|
|
|
|
|
|
|
m_centralWidget->setLastShownPages();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
qApp->restoreOverrideCursor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-02 16:30:56 +02:00
|
|
|
void HelpPlugin::updateSideBarSource()
|
|
|
|
|
{
|
|
|
|
|
const QUrl &url = m_centralWidget->currentSource();
|
|
|
|
|
if (url.isValid())
|
|
|
|
|
updateSideBarSource(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
|
|
|
|
{
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->setSource(newUrl);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-25 17:16:16 +02:00
|
|
|
void HelpPlugin::fontChanged()
|
|
|
|
|
{
|
|
|
|
|
#if defined(QT_NO_WEBKIT)
|
|
|
|
|
QFont font = qApp->font();
|
|
|
|
|
font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"),
|
|
|
|
|
font));
|
|
|
|
|
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->setFont(font);
|
|
|
|
|
|
|
|
|
|
if (m_centralWidget) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (HelpViewer* viewer = m_centralWidget->helpViewerAtIndex(i++)) {
|
|
|
|
|
if (viewer->font() != font)
|
|
|
|
|
viewer->setFont(font);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 15:18:23 +01:00
|
|
|
void HelpPlugin::rebuildViewerComboBox()
|
|
|
|
|
{
|
|
|
|
|
m_documentsCombo->clear();
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (HelpViewer *viewer = m_centralWidget->helpViewerAtIndex(i++))
|
|
|
|
|
m_documentsCombo->addItem(viewer->documentTitle());
|
|
|
|
|
|
|
|
|
|
int index = m_centralWidget->indexOf(m_centralWidget->currentHelpViewer());
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
m_documentsCombo->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::removeViewerFromComboBox(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
m_documentsCombo->removeItem(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateViewerComboBoxIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
m_documentsCombo->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-02 10:53:46 +01:00
|
|
|
void HelpPlugin::indexingStarted()
|
|
|
|
|
{
|
2010-03-05 16:06:41 +01:00
|
|
|
Q_ASSERT(!m_progress);
|
|
|
|
|
m_progress = new QFutureInterface<void>();
|
|
|
|
|
Core::ICore::instance()->progressManager() ->addTask(m_progress->future(),
|
2010-03-02 10:53:46 +01:00
|
|
|
tr("Indexing"), QLatin1String("Help.Indexer"));
|
2010-03-05 16:06:41 +01:00
|
|
|
m_progress->setProgressRange(0, 2);
|
|
|
|
|
m_progress->setProgressValueAndText(1, tr("Indexing Documentation..."));
|
|
|
|
|
m_progress->reportStarted();
|
2010-03-02 10:53:46 +01:00
|
|
|
|
2010-03-05 16:06:41 +01:00
|
|
|
m_watcher.setFuture(m_progress->future());
|
2010-03-02 10:53:46 +01:00
|
|
|
connect(&m_watcher, SIGNAL(canceled()), m_helpEngine->searchEngine(),
|
|
|
|
|
SLOT(cancelIndexing()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::indexingFinished()
|
|
|
|
|
{
|
2010-03-05 16:06:41 +01:00
|
|
|
m_progress->reportFinished();
|
|
|
|
|
|
|
|
|
|
delete m_progress;
|
|
|
|
|
m_progress = NULL;
|
2010-03-02 10:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:47:31 +02:00
|
|
|
HelpViewer* HelpPlugin::viewerForContextMode()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-02 12:33:13 +01:00
|
|
|
using namespace Core;
|
2009-07-14 13:20:26 +02:00
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
bool showSideBySide = false;
|
|
|
|
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
|
|
|
|
switch (m_helpEngine->customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
|
|
|
|
|
case 0: {
|
|
|
|
|
// side by side if possible
|
|
|
|
|
if (IEditor *editor = EditorManager::instance()->currentEditor()) {
|
|
|
|
|
if (!placeHolder || !placeHolder->isVisible()) {
|
2010-03-10 18:39:46 +01:00
|
|
|
if (!editor->widget())
|
|
|
|
|
break;
|
|
|
|
|
if (!editor->widget()->isVisible())
|
|
|
|
|
break;
|
|
|
|
|
if (editor->widget()->width() < 800)
|
2010-02-02 12:33:13 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2009-07-14 13:20:26 +02:00
|
|
|
}
|
2010-02-02 12:33:13 +01:00
|
|
|
} // fall through
|
|
|
|
|
case 1: {
|
|
|
|
|
// side by side
|
|
|
|
|
showSideBySide = true;
|
|
|
|
|
} break;
|
2010-03-04 18:46:16 +01:00
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
default: // help mode
|
|
|
|
|
break;
|
2009-07-14 13:20:26 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
HelpViewer *viewer = m_centralWidget->currentHelpViewer();
|
2009-08-06 15:47:31 +02:00
|
|
|
if (placeHolder && showSideBySide) {
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPaneWidget::instance()->setShown(true);
|
2010-03-16 19:31:29 +01:00
|
|
|
|
|
|
|
|
createRightPaneContextViewer();
|
2009-06-02 17:22:14 +02:00
|
|
|
viewer = m_helpViewerForSideBar;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2010-03-10 18:39:46 +01:00
|
|
|
activateHelpMode();
|
2010-03-16 19:31:29 +01:00
|
|
|
if (!viewer)
|
2010-03-16 15:21:06 +01:00
|
|
|
viewer = m_centralWidget->newEmptyTab();
|
2009-06-02 17:22:14 +02:00
|
|
|
}
|
2009-08-06 15:47:31 +02:00
|
|
|
return viewer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateContext()
|
|
|
|
|
{
|
2010-02-02 12:33:13 +01:00
|
|
|
using namespace Core;
|
2010-03-16 19:31:29 +01:00
|
|
|
createRightPaneContextViewer();
|
2010-03-16 15:21:06 +01:00
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPanePlaceHolder* placeHolder = RightPanePlaceHolder::current();
|
2009-08-06 15:47:31 +02:00
|
|
|
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
|
2010-02-02 12:33:13 +01:00
|
|
|
if (IContext *context = m_core->currentContextObject()) {
|
2009-08-06 15:47:31 +02:00
|
|
|
id = context->contextHelpId();
|
2010-03-16 15:21:06 +01:00
|
|
|
links = HelpManager::helpEngineCore().linksForIdentifier(id);
|
2009-08-06 15:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
if (HelpViewer* viewer = viewerForContextMode()) {
|
2009-06-02 17:22:14 +02:00
|
|
|
if (links.isEmpty()) {
|
|
|
|
|
// No link found or no context object
|
|
|
|
|
viewer->setHtml(tr("<html><head><title>No Documentation</title>"
|
|
|
|
|
"</head><body><br/><center><b>%1</b><br/>No documentation "
|
|
|
|
|
"available.</center></body></html>").arg(id));
|
2008-12-02 12:01:29 +01:00
|
|
|
viewer->setSource(QUrl());
|
2009-06-02 17:22:14 +02:00
|
|
|
} else {
|
2010-02-02 12:33:13 +01:00
|
|
|
const QUrl &source = *links.begin();
|
2009-06-02 17:22:14 +02:00
|
|
|
if (viewer->source() != source)
|
|
|
|
|
viewer->setSource(source);
|
|
|
|
|
viewer->setFocus();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-07-14 13:20:26 +02:00
|
|
|
if (viewer != m_helpViewerForSideBar)
|
|
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateIndex()
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_sideBar->activateItem(m_indexItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateContents()
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_sideBar->activateItem(m_contentItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateSearch()
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_sideBar->activateItem(m_searchItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QToolBar *HelpPlugin::createToolBar()
|
|
|
|
|
{
|
|
|
|
|
QToolBar *toolWidget = new QToolBar;
|
2009-01-13 13:39:31 +01:00
|
|
|
Core::ActionManager *am = m_core->actionManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
toolWidget->addAction(am->command(QLatin1String("Help.Home"))->action());
|
|
|
|
|
toolWidget->addAction(am->command(QLatin1String("Help.Previous"))->action());
|
|
|
|
|
toolWidget->addAction(am->command(QLatin1String("Help.Next"))->action());
|
|
|
|
|
toolWidget->addSeparator();
|
|
|
|
|
toolWidget->addAction(am->command(QLatin1String("Help.AddBookmark"))->action());
|
|
|
|
|
//int size = toolWidget->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
|
|
|
|
//toolWidget->setIconSize(QSize(size, size));
|
|
|
|
|
toolWidget->setMovable(false);
|
|
|
|
|
|
|
|
|
|
toolWidget->addSeparator();
|
|
|
|
|
|
|
|
|
|
QWidget *w = new QWidget;
|
2010-01-18 15:18:23 +01:00
|
|
|
toolWidget->addWidget(w);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout(w);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->addSpacing(10);
|
2010-01-18 15:18:23 +01:00
|
|
|
m_documentsCombo = new QComboBox;
|
|
|
|
|
m_documentsCombo->setMinimumContentsLength(40);
|
|
|
|
|
layout->addWidget(m_documentsCombo);
|
|
|
|
|
|
|
|
|
|
connect(m_documentsCombo, SIGNAL(activated(int)), m_centralWidget,
|
|
|
|
|
SLOT(activateTab(int)));
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
layout->addWidget(new QLabel(tr("Filtered by:")));
|
|
|
|
|
m_filterComboBox = new QComboBox;
|
|
|
|
|
m_filterComboBox->setMinimumContentsLength(20);
|
2010-01-18 15:18:23 +01:00
|
|
|
layout->addWidget(m_filterComboBox);
|
|
|
|
|
|
2009-06-02 18:41:12 +02:00
|
|
|
connect(m_filterComboBox, SIGNAL(activated(QString)), this,
|
|
|
|
|
SLOT(filterDocumentation(QString)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
return toolWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateFilterComboBox()
|
|
|
|
|
{
|
|
|
|
|
QString curFilter = m_filterComboBox->currentText();
|
|
|
|
|
if (curFilter.isEmpty())
|
|
|
|
|
curFilter = m_helpEngine->currentFilter();
|
|
|
|
|
m_filterComboBox->clear();
|
|
|
|
|
m_filterComboBox->addItems(m_helpEngine->customFilters());
|
|
|
|
|
int idx = m_filterComboBox->findText(curFilter);
|
|
|
|
|
if (idx < 0)
|
|
|
|
|
idx = 0;
|
|
|
|
|
m_filterComboBox->setCurrentIndex(idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::checkForHelpChanges()
|
|
|
|
|
{
|
2010-03-16 15:48:09 +01:00
|
|
|
bool changed = unregisterDocumentation(m_docSettingsPage->docsToUnregister());
|
|
|
|
|
filesToRegister += m_docSettingsPage->docsToRegister();
|
|
|
|
|
changed |= registerDocumentation();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (changed)
|
|
|
|
|
m_helpEngine->setupData();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 14:47:27 +01:00
|
|
|
void HelpPlugin::checkForGeneralChanges()
|
|
|
|
|
{
|
|
|
|
|
if (generalSettingsPage->applyChanges())
|
|
|
|
|
m_helpEngine->setupData();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void HelpPlugin::filterDocumentation(const QString &customFilter)
|
|
|
|
|
{
|
|
|
|
|
m_helpEngine->setCurrentFilter(customFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::addBookmark()
|
|
|
|
|
{
|
2009-06-04 13:12:20 +02:00
|
|
|
addNewBookmark(m_centralWidget->currentTitle(),
|
|
|
|
|
m_centralWidget->currentSource().toString());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
|
|
|
|
|
{
|
2009-06-04 13:12:20 +02:00
|
|
|
if (url.isEmpty() || url == QLatin1String("about:blank"))
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 18:24:13 +01:00
|
|
|
void HelpPlugin::handleHelpRequest(const QString &address)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-10 18:24:13 +01:00
|
|
|
if (m_helpEngine->findFile(address).isValid()) {
|
|
|
|
|
const QUrl url(address);
|
|
|
|
|
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
|
|
|
|
|
if (HelpViewer* viewer = viewerForContextMode())
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
} else {
|
|
|
|
|
activateHelpMode();
|
|
|
|
|
m_centralWidget->setSource(url);
|
|
|
|
|
}
|
2009-06-10 17:38:45 +02:00
|
|
|
} else {
|
|
|
|
|
// local help not installed, resort to external web help
|
|
|
|
|
QString urlPrefix;
|
2010-03-10 18:24:13 +01:00
|
|
|
if (address.startsWith(QLatin1String("qthelp://com.nokia.qtcreator"))) {
|
2010-02-02 12:33:13 +01:00
|
|
|
urlPrefix = QString::fromLatin1("http://doc.trolltech.com/qtcreator"
|
|
|
|
|
"-%1.%2/").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR);
|
2009-06-10 17:38:45 +02:00
|
|
|
} else {
|
|
|
|
|
urlPrefix = QLatin1String("http://doc.trolltech.com/latest/");
|
|
|
|
|
}
|
2010-03-10 18:24:13 +01:00
|
|
|
QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address
|
2010-02-08 11:07:18 +01:00
|
|
|
.lastIndexOf(QLatin1Char('/')) + 1)));
|
2009-05-11 16:42:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(HelpPlugin)
|