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
|
|
|
**************************************************************************/
|
2010-03-30 17:44:28 +02: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"
|
2010-03-30 17:44:28 +02:00
|
|
|
#include "openpagesmanager.h"
|
|
|
|
|
#include "openpagesmodel.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#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>
|
2010-06-11 13:11:37 +02:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2008-12-02 16:19:05 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/modemanager.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
|
|
|
|
#include <coreplugin/sidebar.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>
|
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/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-07-08 16:51:36 +02:00
|
|
|
#if !defined(QT_NO_WEBKIT)
|
|
|
|
|
#include <QtWebKit/QWebElement>
|
|
|
|
|
#include <QtWebKit/QWebElementCollection>
|
|
|
|
|
#include <QtWebKit/QWebFrame>
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
using namespace Core::Constants;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Help::Internal;
|
|
|
|
|
|
2010-05-31 12:37:21 +02:00
|
|
|
const char * const SB_INDEX = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Index");
|
|
|
|
|
const char * const SB_CONTENTS = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Contents");
|
|
|
|
|
const char * const SB_BOOKMARKS = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Bookmarks");
|
|
|
|
|
const char * const SB_SEARCH = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Search");
|
|
|
|
|
|
2010-04-29 11:59:42 +02:00
|
|
|
const char * const SB_OPENPAGES = "OpenPages";
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
#define IMAGEPATH ":/help/images/"
|
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()
|
2010-03-23 18:11:43 +01:00
|
|
|
: m_mode(0),
|
|
|
|
|
m_core(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_centralWidget(0),
|
|
|
|
|
m_helpViewerForSideBar(0),
|
|
|
|
|
m_contentItem(0),
|
|
|
|
|
m_indexItem(0),
|
|
|
|
|
m_searchItem(0),
|
|
|
|
|
m_bookmarkItem(0),
|
2010-03-23 18:11:43 +01:00
|
|
|
m_sideBar(0),
|
|
|
|
|
m_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();
|
2010-06-28 14:30:03 +02:00
|
|
|
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context modecontext(Constants::C_MODE_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
addAutoReleasedObject(m_helpManager = new LocalHelpManager(this));
|
2010-03-30 17:44:28 +02:00
|
|
|
addAutoReleasedObject(m_openPagesManager = new OpenPagesManager(this));
|
2010-03-16 15:48:09 +01:00
|
|
|
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
|
|
|
|
|
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
|
2010-03-23 18:11:43 +01:00
|
|
|
addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
|
2009-06-25 17:16:16 +02:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
|
|
|
|
|
SLOT(fontChanged()));
|
2010-06-11 13:11:37 +02:00
|
|
|
connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
|
2010-04-28 15:04:39 +02:00
|
|
|
SLOT(handleHelpRequest(QUrl)));
|
2010-06-11 13:11:37 +02:00
|
|
|
m_filterSettingsPage->setHelpManager(m_helpManager);
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this,
|
|
|
|
|
SLOT(setupHelpEngineIfNeeded()));
|
2010-06-11 13:11:37 +02:00
|
|
|
connect(Core::HelpManager::instance(), SIGNAL(documentationChanged()), this,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(setupHelpEngineIfNeeded()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
m_splitter = new Core::MiniSplitter;
|
|
|
|
|
m_centralWidget = new Help::Internal::CentralWidget();
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
|
|
|
|
SLOT(updateSideBarSource(QUrl)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Add Home, Previous and Next actions (used in the toolbar)
|
2010-03-30 17:44:28 +02:00
|
|
|
QAction *action = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")),
|
|
|
|
|
tr("Home"), this);
|
2010-03-23 18:11:43 +01:00
|
|
|
Core::ActionManager *am = m_core->actionManager();
|
2010-03-30 17:44:28 +02:00
|
|
|
Core::Command *cmd = am->registerAction(action, QLatin1String("Help.Home"),
|
|
|
|
|
globalcontext);
|
|
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
2009-07-17 18:08:59 +02:00
|
|
|
tr("Previous Page"), this);
|
2010-03-30 17:44:28 +02:00
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Previous"), modecontext);
|
2009-06-02 12:56:16 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Back);
|
2010-03-30 17:44:28 +02:00
|
|
|
action->setEnabled(m_centralWidget->isBackwardAvailable());
|
|
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), action,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"),
|
2009-06-02 18:41:12 +02:00
|
|
|
this);
|
2010-03-30 17:44:28 +02:00
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Next"), modecontext);
|
2009-06-02 12:56:16 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Forward);
|
2010-03-30 17:44:28 +02:00
|
|
|
action->setEnabled(m_centralWidget->isForwardAvailable());
|
|
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), action,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
|
2008-12-02 12:01:29 +01:00
|
|
|
tr("Add Bookmark"), this);
|
2010-03-30 17:44:28 +02:00
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.AddBookmark"),
|
2009-06-02 18:41:12 +02:00
|
|
|
modecontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_M));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-15 14:50:17 +02:00
|
|
|
// Add Contents, Index, and Context menu items and a separator to the Help menu
|
2010-05-31 12:37:21 +02:00
|
|
|
action = new QAction(QIcon::fromTheme(QLatin1String("help-contents")), tr(SB_CONTENTS), this);
|
2010-04-15 14:50:17 +02:00
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Contents"), globalcontext);
|
|
|
|
|
am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
|
|
|
|
|
|
2010-05-31 12:37:21 +02:00
|
|
|
action = new QAction(tr(SB_INDEX), this);
|
2010-03-30 17:44:28 +02:00
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Index"), globalcontext);
|
|
|
|
|
am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
|
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("Context Help"), this);
|
|
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Context"), globalcontext);
|
|
|
|
|
am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateContext()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-03 20:45:49 +02:00
|
|
|
#ifndef Q_WS_MAC
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(this);
|
|
|
|
|
action->setSeparator(true);
|
|
|
|
|
cmd = am->registerAction(action, QLatin1String("Help.Separator"), globalcontext);
|
|
|
|
|
am->actionContainer(M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(this);
|
|
|
|
|
am->registerAction(action, Core::Constants::PRINT, modecontext);
|
|
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(print()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(this);
|
|
|
|
|
cmd = am->registerAction(action, Core::Constants::COPY, modecontext);
|
|
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(copy()));
|
|
|
|
|
action->setText(cmd->action()->text());
|
|
|
|
|
action->setIcon(cmd->action()->icon());
|
2009-05-12 19:46:40 +02:00
|
|
|
|
2010-04-12 14:55:41 +02:00
|
|
|
if (Core::ActionContainer *advancedMenu = am->actionContainer(M_EDIT_ADVANCED)) {
|
2009-06-23 16:57:03 +02:00
|
|
|
// reuse TextEditor constants to avoid a second pair of menu actions
|
2010-04-12 14:55:41 +02:00
|
|
|
action = new QAction(tr("Increase Font Size"), this);
|
|
|
|
|
cmd = am->registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
2009-06-23 16:57:03 +02:00
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
|
2010-04-12 14:55:41 +02:00
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomIn()));
|
2009-06-23 16:57:03 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-11-19 11:23:52 +01:00
|
|
|
|
2010-04-12 14:55:41 +02:00
|
|
|
action = new QAction(tr("Decrease Font Size"), this);
|
|
|
|
|
cmd = am->registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
2009-06-23 16:57:03 +02:00
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
|
2010-04-12 14:55:41 +02:00
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomOut()));
|
2009-06-23 16:57:03 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-06-25 16:03:02 +02:00
|
|
|
|
2010-04-12 14:55:41 +02:00
|
|
|
action = new QAction(tr("Reset Font Size"), this);
|
|
|
|
|
cmd = am->registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
2009-06-25 16:03:02 +02:00
|
|
|
modecontext);
|
2010-04-22 17:11:37 +02:00
|
|
|
#ifndef Q_WS_MAC
|
2009-06-25 16:03:02 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+0")));
|
2010-04-22 17:11:37 +02:00
|
|
|
#endif
|
2010-04-12 14:55:41 +02:00
|
|
|
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(resetZoom()));
|
2009-06-25 16:03:02 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
2009-06-23 16:57:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 14:55:41 +02:00
|
|
|
if (Core::ActionContainer *windowMenu = am->actionContainer(M_WINDOW)) {
|
|
|
|
|
// reuse EditorManager constants to avoid a second pair of menu actions
|
|
|
|
|
action = new QAction(QApplication::tr("EditorManager",
|
|
|
|
|
"Next Open Document in History"), this);
|
|
|
|
|
Core::Command *ctrlTab = am->registerAction(action, GOTOPREVINHISTORY,
|
|
|
|
|
modecontext); // Goto Previous In History Action
|
|
|
|
|
windowMenu->addAction(ctrlTab, Core::Constants::G_WINDOW_NAVIGATE);
|
|
|
|
|
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(gotoPreviousPage()));
|
|
|
|
|
|
|
|
|
|
action = new QAction(QApplication::tr("EditorManager",
|
|
|
|
|
"Previous Open Document in History"), this);
|
|
|
|
|
Core::Command *ctrlShiftTab = am->registerAction(action, GOTONEXTINHISTORY,
|
|
|
|
|
modecontext); // Goto Next In History Action
|
|
|
|
|
windowMenu->addAction(ctrlShiftTab, Core::Constants::G_WINDOW_NAVIGATE);
|
|
|
|
|
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(gotoNextPage()));
|
|
|
|
|
|
|
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
|
ctrlTab->setDefaultKeySequence(QKeySequence(tr("Alt+Tab")));
|
|
|
|
|
ctrlShiftTab->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+Tab")));
|
|
|
|
|
#else
|
|
|
|
|
ctrlTab->setDefaultKeySequence(QKeySequence(tr("Ctrl+Tab")));
|
|
|
|
|
ctrlShiftTab->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Tab")));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
|
|
|
|
agg->add(m_centralWidget);
|
|
|
|
|
agg->add(new HelpFindSupport(m_centralWidget));
|
|
|
|
|
m_mainWidget = new QWidget;
|
2010-03-24 11:38:55 +01:00
|
|
|
m_splitter->addWidget(m_mainWidget);
|
2010-03-23 18:11:43 +01:00
|
|
|
QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_mainWidget);
|
|
|
|
|
mainWidgetLayout->setMargin(0);
|
|
|
|
|
mainWidgetLayout->setSpacing(0);
|
|
|
|
|
mainWidgetLayout->addWidget(createToolBar());
|
|
|
|
|
mainWidgetLayout->addWidget(m_centralWidget);
|
|
|
|
|
|
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)));
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
|
|
|
|
|
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
|
|
|
|
this, SLOT(modeChanged(Core::IMode*)));
|
|
|
|
|
|
|
|
|
|
addAutoReleasedObject(m_mode = new HelpMode(m_splitter, m_centralWidget));
|
2010-06-25 12:56:16 +02:00
|
|
|
m_mode->setContext(modecontext);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
void HelpPlugin::extensionsInitialized()
|
2009-07-27 13:55:30 +02:00
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
const QString &nsInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
|
2010-03-23 18:11:43 +01:00
|
|
|
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
|
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
Core::HelpManager *helpManager = Core::HelpManager::instance();
|
|
|
|
|
foreach (const QString &ns, helpManager->registeredNamespaces()) {
|
2010-03-23 18:11:43 +01:00
|
|
|
if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))
|
2010-06-11 13:11:37 +02:00
|
|
|
&& ns != nsInternal)
|
|
|
|
|
helpManager->unregisterDocumentation(QStringList() << ns);
|
2010-03-23 18:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList filesToRegister;
|
|
|
|
|
// 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
|
2010-06-11 13:11:37 +02:00
|
|
|
// without a qt development version. TODO: is this still really needed, remove
|
2010-03-23 18:11:43 +01:00
|
|
|
const QString &appPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
|
|
|
|
|
+ QLatin1String(DOCPATH "qml.qch"))));
|
|
|
|
|
|
|
|
|
|
// we might need to register creators inbuild help
|
|
|
|
|
filesToRegister.append(QDir::cleanPath(appPath
|
|
|
|
|
+ QLatin1String(DOCPATH "qtcreator.qch")));
|
2010-06-29 10:43:33 +02:00
|
|
|
helpManager->registerDocumentation(filesToRegister);
|
2009-07-27 13:55:30 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-28 16:59:03 +02:00
|
|
|
void HelpPlugin::aboutToShutdown()
|
2010-02-02 11:40:45 +01:00
|
|
|
{
|
2010-03-23 18:11:43 +01:00
|
|
|
if (m_sideBar)
|
|
|
|
|
m_sideBar->saveSettings(m_core->settings(), QLatin1String("HelpSideBar"));
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
void HelpPlugin::setupUi()
|
2010-02-02 11:40:45 +01:00
|
|
|
{
|
2010-03-23 18:11:43 +01:00
|
|
|
// side bar widgets and shortcuts
|
|
|
|
|
Core::ActionManager *am = m_core->actionManager();
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context modecontext(Constants::C_MODE_HELP);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
IndexWindow *indexWindow = new IndexWindow();
|
2010-05-31 12:37:21 +02:00
|
|
|
indexWindow->setWindowTitle(tr(SB_INDEX));
|
2010-04-29 11:59:42 +02:00
|
|
|
m_indexItem = new Core::SideBarItem(indexWindow, QLatin1String(SB_INDEX));
|
2010-03-30 17:44:28 +02:00
|
|
|
|
|
|
|
|
connect(indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
|
|
|
|
connect(indexWindow, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
|
|
|
|
|
m_centralWidget, SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
QMap<QString, Core::Command*> shortcutMap;
|
|
|
|
|
QShortcut *shortcut = new QShortcut(m_splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
|
2010-03-30 17:44:28 +02:00
|
|
|
Core::Command* cmd = am->registerShortcut(shortcut,
|
|
|
|
|
QLatin1String("Help.IndexShortcut"), modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
|
2010-03-23 18:11:43 +01:00
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
|
2010-04-29 11:59:42 +02:00
|
|
|
shortcutMap.insert(QLatin1String(SB_INDEX), cmd);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
ContentWindow *contentWindow = new ContentWindow();
|
2010-05-31 12:37:21 +02:00
|
|
|
contentWindow->setWindowTitle(tr(SB_CONTENTS));
|
2010-04-29 11:59:42 +02:00
|
|
|
m_contentItem = new Core::SideBarItem(contentWindow, QLatin1String(SB_CONTENTS));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
shortcut = new QShortcut(m_splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
|
2010-03-30 17:44:28 +02:00
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.ContentsShortcut"),
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
|
2010-03-23 18:11:43 +01:00
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
|
2010-04-29 11:59:42 +02:00
|
|
|
shortcutMap.insert(QLatin1String(SB_CONTENTS), cmd);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
SearchWidget *searchWidget = new SearchWidget();
|
2010-05-31 12:37:21 +02:00
|
|
|
searchWidget->setWindowTitle(tr(SB_SEARCH));
|
|
|
|
|
m_searchItem = new Core::SideBarItem(searchWidget, QLatin1String(SB_SEARCH));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(searchWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSourceFromSearch(QUrl)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2010-06-21 13:23:43 +02:00
|
|
|
shortcut = new QShortcut(m_splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Search in Help mode"));
|
|
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.SearchShortcut"),
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
|
2010-06-24 11:40:22 +02:00
|
|
|
shortcutMap.insert(QLatin1String(SB_SEARCH), cmd);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
|
2010-03-23 18:11:43 +01:00
|
|
|
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false);
|
2010-05-31 12:37:21 +02:00
|
|
|
bookmarkWidget->setWindowTitle(tr(SB_BOOKMARKS));
|
2010-04-29 11:59:42 +02:00
|
|
|
m_bookmarkItem = new Core::SideBarItem(bookmarkWidget, QLatin1String(SB_BOOKMARKS));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(bookmarkWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2010-06-21 13:23:43 +02:00
|
|
|
shortcut = new QShortcut(m_splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode"));
|
|
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.BookmarkShortcut"),
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks()));
|
2010-06-24 11:40:22 +02:00
|
|
|
shortcutMap.insert(QLatin1String(SB_BOOKMARKS), cmd);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
|
|
|
|
|
openPagesWidget->setWindowTitle(tr("Open Pages"));
|
2010-04-29 11:59:42 +02:00
|
|
|
m_openPagesItem = new Core::SideBarItem(openPagesWidget, QLatin1String(SB_OPENPAGES));
|
2010-03-30 17:44:28 +02:00
|
|
|
|
|
|
|
|
shortcut = new QShortcut(m_splitter);
|
|
|
|
|
shortcut->setWhatsThis(tr("Activate Open Pages in Help mode"));
|
|
|
|
|
cmd = am->registerShortcut(shortcut, QLatin1String("Help.PagesShortcut"),
|
|
|
|
|
modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
|
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateOpenPages()));
|
2010-04-29 11:59:42 +02:00
|
|
|
shortcutMap.insert(QLatin1String(SB_OPENPAGES), cmd);
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
QList<Core::SideBarItem*> itemList;
|
2010-03-30 17:44:28 +02:00
|
|
|
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem
|
|
|
|
|
<< m_openPagesItem;
|
|
|
|
|
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem*>()
|
2010-04-01 14:49:15 +02:00
|
|
|
<< m_contentItem << m_openPagesItem);
|
2010-03-23 18:11:43 +01:00
|
|
|
m_sideBar->setShortcutMap(shortcutMap);
|
|
|
|
|
|
|
|
|
|
m_splitter->setOpaqueResize(false);
|
2010-03-24 11:38:55 +01:00
|
|
|
m_splitter->insertWidget(0, m_sideBar);
|
2010-03-23 18:11:43 +01:00
|
|
|
m_splitter->setStretchFactor(0, 0);
|
|
|
|
|
m_splitter->setStretchFactor(1, 1);
|
|
|
|
|
m_splitter->setSizes(QList<int>() << 300 << 300);
|
|
|
|
|
m_sideBar->readSettings(m_core->settings(), QLatin1String("HelpSideBar"));
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:28:31 +01:00
|
|
|
void HelpPlugin::resetFilter()
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
|
|
|
|
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
|
|
|
|
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
|
|
|
|
|
|
|
|
|
|
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
|
|
|
|
|
const QStringList &filters = engine->customFilters();
|
|
|
|
|
foreach (const QString &filter, filters) {
|
|
|
|
|
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
|
|
|
|
|
engine->removeCustomFilter(filter);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 15:28:31 +01:00
|
|
|
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
|
|
|
|
|
const QLatin1String previousFilterNameKey("UnfilteredFilterName");
|
2010-06-11 13:11:37 +02:00
|
|
|
if (engine->customValue(weAddedFilterKey).toInt() == 1) {
|
2010-03-16 15:28:31 +01:00
|
|
|
// we added a filter at some point, remove previously added filter
|
2010-06-11 13:11:37 +02:00
|
|
|
const QString &filter = engine->customValue(previousFilterNameKey).toString();
|
2010-03-30 17:44:28 +02:00
|
|
|
if (!filter.isEmpty())
|
2010-06-11 13:11:37 +02:00
|
|
|
engine->removeCustomFilter(filter);
|
2010-03-16 15:28:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// potentially remove a filter with new name
|
|
|
|
|
const QString filterName = tr("Unfiltered");
|
2010-06-11 13:11:37 +02:00
|
|
|
engine->removeCustomFilter(filterName);
|
|
|
|
|
engine->addCustomFilter(filterName, QStringList());
|
|
|
|
|
engine->setCustomValue(weAddedFilterKey, 1);
|
|
|
|
|
engine->setCustomValue(previousFilterNameKey, filterName);
|
|
|
|
|
engine->setCurrentFilter(filterName);
|
|
|
|
|
|
|
|
|
|
updateFilterComboBox();
|
|
|
|
|
connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
|
2010-03-16 15:48:09 +01:00
|
|
|
}
|
|
|
|
|
|
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-23 18:11:43 +01:00
|
|
|
QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
|
2010-03-16 15:21:06 +01:00
|
|
|
tr("Next"), this);
|
2010-03-23 18:11:43 +01:00
|
|
|
QAction *previous = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
2010-03-16 15:21:06 +01:00
|
|
|
tr("Previous"), this);
|
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-30 17:44:28 +02:00
|
|
|
m_helpViewerForSideBar = new HelpViewer(qreal(0.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-06-25 17:37:59 +02:00
|
|
|
m_core->addContextObject(new Core::BaseContext(m_helpViewerForSideBar,
|
|
|
|
|
Core::Context(Constants::C_HELP_SIDEBAR), this));
|
2010-03-16 15:21:06 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
QAction *copy = new QAction(this);
|
|
|
|
|
Core::Command *cmd = m_core->actionManager()->registerAction(copy, Core::Constants::COPY,
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context(Constants::C_HELP_SIDEBAR));
|
2010-03-23 18:11:43 +01:00
|
|
|
copy->setText(cmd->action()->text());
|
|
|
|
|
copy->setIcon(cmd->action()->icon());
|
2009-03-13 12:10:28 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy()));
|
|
|
|
|
connect(next, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(forward()));
|
|
|
|
|
connect(previous, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(backward()));
|
2010-07-07 11:26:24 +02:00
|
|
|
|
|
|
|
|
// force setup, as we might have never switched to full help mode
|
|
|
|
|
// thus the help engine might still run without collection file setup
|
|
|
|
|
m_helpManager->setupGuiHelpEngine();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
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::modeChanged(Core::IMode *mode)
|
|
|
|
|
{
|
2010-03-23 18:11:43 +01:00
|
|
|
if (mode == m_mode && m_firstModeChange) {
|
|
|
|
|
m_firstModeChange = false;
|
2010-03-05 16:06:41 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
qApp->processEvents();
|
|
|
|
|
qApp->setOverrideCursor(Qt::WaitCursor);
|
2010-03-05 16:06:41 +01:00
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
m_helpManager->setupGuiHelpEngine();
|
2010-03-23 18:11:43 +01:00
|
|
|
setupUi();
|
2010-03-16 15:28:31 +01:00
|
|
|
resetFilter();
|
2010-03-30 17:44:28 +02:00
|
|
|
OpenPagesManager::instance().setupInitialPages();
|
2010-03-16 15:48:09 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
qApp->restoreOverrideCursor();
|
|
|
|
|
} else if (mode == m_mode && !m_firstModeChange) {
|
|
|
|
|
qApp->setOverrideCursor(Qt::WaitCursor);
|
|
|
|
|
m_helpManager->setupGuiHelpEngine();
|
2008-12-02 12:01:29 +01:00
|
|
|
qApp->restoreOverrideCursor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-02 16:30:56 +02:00
|
|
|
void HelpPlugin::updateSideBarSource()
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer *viewer = m_centralWidget->currentHelpViewer()) {
|
|
|
|
|
const QUrl &url = viewer->source();
|
|
|
|
|
if (url.isValid())
|
|
|
|
|
updateSideBarSource(url);
|
|
|
|
|
}
|
2009-06-02 16:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
|
|
|
|
{
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->setSource(newUrl);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void HelpPlugin::updateCloseButton()
|
2009-06-25 17:16:16 +02:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
m_closeButton->setEnabled(OpenPagesManager::instance().pageCount() > 1);
|
|
|
|
|
}
|
2009-06-25 17:16:16 +02:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void HelpPlugin::fontChanged()
|
|
|
|
|
{
|
|
|
|
|
if (!m_helpViewerForSideBar)
|
|
|
|
|
createRightPaneContextViewer();
|
2009-06-25 17:16:16 +02:00
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
const QHelpEngine &engine = LocalHelpManager::helpEngine();
|
2010-03-30 17:44:28 +02:00
|
|
|
QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
|
|
|
|
|
m_helpViewerForSideBar->viewerFont()));
|
|
|
|
|
|
|
|
|
|
m_helpViewerForSideBar->setFont(font);
|
|
|
|
|
const int count = OpenPagesManager::instance().pageCount();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
if (HelpViewer *viewer = CentralWidget::instance()->viewerAt(i))
|
|
|
|
|
viewer->setViewerFont(font);
|
2009-06-25 17:16:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
void HelpPlugin::setupHelpEngineIfNeeded()
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
m_helpManager->setEngineNeedsUpdate();
|
|
|
|
|
if (Core::ModeManager::instance()->currentMode() == m_mode)
|
2010-03-23 18:11:43 +01:00
|
|
|
m_helpManager->setupGuiHelpEngine();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2010-06-11 13:11:37 +02:00
|
|
|
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
2010-03-23 18:11:43 +01:00
|
|
|
switch (engine.customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
|
2010-02-02 12:33:13 +01:00
|
|
|
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-30 17:44:28 +02:00
|
|
|
viewer = OpenPagesManager::instance().createPage();
|
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;
|
|
|
|
|
|
|
|
|
|
// Find out what to show
|
2010-07-08 16:51:36 +02:00
|
|
|
QMap<QString, QUrl> links;
|
2010-02-02 12:33:13 +01:00
|
|
|
if (IContext *context = m_core->currentContextObject()) {
|
2010-07-08 16:51:36 +02:00
|
|
|
m_idFromContext = context->contextHelpId();
|
|
|
|
|
links = Core::HelpManager::instance()->linksForIdentifier(m_idFromContext);
|
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 "
|
2010-07-08 16:51:36 +02:00
|
|
|
"available.</center></body></html>").arg(m_idFromContext));
|
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();
|
2010-07-08 16:51:36 +02:00
|
|
|
const QUrl &oldSource = viewer->source();
|
|
|
|
|
if (source != oldSource) {
|
|
|
|
|
viewer->stop();
|
2009-06-02 17:22:14 +02:00
|
|
|
viewer->setSource(source);
|
2010-07-08 16:51:36 +02:00
|
|
|
}
|
2009-06-02 17:22:14 +02:00
|
|
|
viewer->setFocus();
|
2010-07-08 16:51:36 +02:00
|
|
|
connect(viewer, SIGNAL(loadFinished(bool)), this,
|
|
|
|
|
SLOT(highlightSearchTerms()));
|
|
|
|
|
|
|
|
|
|
if (source.toString().remove(source.fragment())
|
|
|
|
|
== oldSource.toString().remove(oldSource.fragment())) {
|
|
|
|
|
highlightSearchTerms();
|
|
|
|
|
}
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void HelpPlugin::activateOpenPages()
|
|
|
|
|
{
|
|
|
|
|
activateHelpMode();
|
|
|
|
|
m_sideBar->activateItem(m_openPagesItem);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-21 13:23:43 +02:00
|
|
|
void HelpPlugin::activateBookmarks()
|
|
|
|
|
{
|
|
|
|
|
activateHelpMode();
|
|
|
|
|
m_sideBar->activateItem(m_bookmarkItem);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
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());
|
|
|
|
|
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-03-30 17:44:28 +02:00
|
|
|
layout->addWidget(OpenPagesManager::instance().openPagesComboBox());
|
2010-01-18 15:18:23 +01:00
|
|
|
|
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)));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_filterComboBox, SIGNAL(currentIndexChanged(int)), this,
|
|
|
|
|
SLOT(updateSideBarSource()));
|
|
|
|
|
|
|
|
|
|
m_closeButton = new QToolButton();
|
|
|
|
|
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
|
|
|
|
|
m_closeButton->setToolTip(tr("Close current Page"));
|
|
|
|
|
connect(m_closeButton, SIGNAL(clicked()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(closeCurrentPage()));
|
|
|
|
|
connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this,
|
|
|
|
|
SLOT(updateCloseButton()));
|
|
|
|
|
layout->addStretch();
|
|
|
|
|
layout->addWidget(m_closeButton);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
return toolWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateFilterComboBox()
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
const QHelpEngine &engine = LocalHelpManager::helpEngine();
|
2008-12-02 12:01:29 +01:00
|
|
|
QString curFilter = m_filterComboBox->currentText();
|
|
|
|
|
if (curFilter.isEmpty())
|
2010-03-23 18:11:43 +01:00
|
|
|
curFilter = engine.currentFilter();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_filterComboBox->clear();
|
2010-03-23 18:11:43 +01:00
|
|
|
m_filterComboBox->addItems(engine.customFilters());
|
2008-12-02 12:01:29 +01:00
|
|
|
int idx = m_filterComboBox->findText(curFilter);
|
|
|
|
|
if (idx < 0)
|
|
|
|
|
idx = 0;
|
|
|
|
|
m_filterComboBox->setCurrentIndex(idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::filterDocumentation(const QString &customFilter)
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
LocalHelpManager::helpEngine().setCurrentFilter(customFilter);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::addBookmark()
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
HelpViewer *viewer = m_centralWidget->currentHelpViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
const QString &url = viewer->source().toString();
|
|
|
|
|
if (url.isEmpty() || url == Help::Constants::AboutBlank)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
|
2010-03-30 17:44:28 +02:00
|
|
|
manager->showBookmarkDialog(m_centralWidget, viewer->title(), url);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 16:51:36 +02:00
|
|
|
void HelpPlugin::highlightSearchTerms()
|
|
|
|
|
{
|
|
|
|
|
if (HelpViewer* viewer = viewerForContextMode()) {
|
|
|
|
|
disconnect(viewer, SIGNAL(loadFinished(bool)), this,
|
|
|
|
|
SLOT(highlightSearchTerms()));
|
|
|
|
|
|
|
|
|
|
#if !defined(QT_NO_WEBKIT)
|
|
|
|
|
const QString &attrValue = m_idFromContext.mid(m_idFromContext
|
|
|
|
|
.lastIndexOf(QChar(':')) + 1);
|
|
|
|
|
if (attrValue.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QWebElement &document = viewer->page()->mainFrame()->documentElement();
|
|
|
|
|
const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a"));
|
|
|
|
|
|
|
|
|
|
const QLatin1String property("background-color");
|
|
|
|
|
foreach (const QWebElement &element, collection) {
|
|
|
|
|
const QString &name = element.attribute(QLatin1String("name"));
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (m_oldAttrValue == name) {
|
|
|
|
|
QWebElement parent = element.parent();
|
|
|
|
|
parent.setStyleProperty(property, m_styleProperty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (attrValue == name) {
|
|
|
|
|
QWebElement parent = element.parent();
|
|
|
|
|
m_styleProperty = parent.styleProperty(property,
|
|
|
|
|
QWebElement::InlineStyle);
|
|
|
|
|
parent.setStyleProperty(property, QLatin1String("yellow"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_oldAttrValue = attrValue;
|
|
|
|
|
#endif
|
|
|
|
|
viewer->findText(m_idFromContext, 0, false, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-28 15:04:39 +02:00
|
|
|
void HelpPlugin::handleHelpRequest(const QUrl &url)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-04-28 15:04:39 +02:00
|
|
|
if (HelpViewer::launchWithExternalApp(url))
|
2010-03-30 17:44:28 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-06-14 14:31:34 +02:00
|
|
|
QString address = url.toString();
|
|
|
|
|
if (!Core::HelpManager::instance()->findFile(url).isValid()) {
|
2010-04-28 15:04:39 +02:00
|
|
|
if (address.startsWith(HelpViewer::NsNokia)
|
|
|
|
|
|| address.startsWith(HelpViewer::NsTrolltech)) {
|
|
|
|
|
// local help not installed, resort to external web help
|
|
|
|
|
QString urlPrefix = QLatin1String("http://doc.trolltech.com/");
|
|
|
|
|
if (url.authority() == QLatin1String("com.nokia.qtcreator")) {
|
2010-05-31 12:07:08 +02:00
|
|
|
urlPrefix.append(QString::fromLatin1("qtcreator"));
|
2010-04-28 15:04:39 +02:00
|
|
|
} else {
|
|
|
|
|
urlPrefix.append(QLatin1String("latest"));
|
|
|
|
|
}
|
|
|
|
|
address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')));
|
2009-06-10 17:38:45 +02:00
|
|
|
}
|
2010-06-14 14:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QUrl newUrl(address);
|
|
|
|
|
if (newUrl.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
|
|
|
|
|
if (HelpViewer* viewer = viewerForContextMode())
|
|
|
|
|
viewer->setSource(newUrl);
|
|
|
|
|
} else {
|
|
|
|
|
activateHelpMode();
|
|
|
|
|
m_centralWidget->setSource(newUrl);
|
2009-05-11 16:42:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(HelpPlugin)
|