2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02: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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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 "centralwidget.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "docsettingspage.h"
|
2010-07-23 16:36:08 +02:00
|
|
|
#include "externalhelpwindow.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#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"
|
|
|
|
|
#include "helpmode.h"
|
|
|
|
|
#include "helpviewer.h"
|
2010-11-16 14:15:23 +01:00
|
|
|
#include "localhelpmanager.h"
|
2010-03-30 17:44:28 +02:00
|
|
|
#include "openpagesmanager.h"
|
|
|
|
|
#include "openpagesmodel.h"
|
2014-05-02 16:54:28 +02:00
|
|
|
#include "qtwebkithelpviewer.h"
|
2010-07-16 11:15:54 +02:00
|
|
|
#include "remotehelpfilter.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "searchwidget.h"
|
2014-03-18 22:50:44 +02:00
|
|
|
#include "searchtaskhandler.h"
|
2014-05-02 16:54:28 +02:00
|
|
|
#include "textbrowserhelpviewer.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-14 13:15:01 +02:00
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER
|
|
|
|
|
#include "macwebkithelpviewer.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-09-02 14:04:12 +02:00
|
|
|
#include <bookmarkmanager.h>
|
|
|
|
|
#include <contentwindow.h>
|
|
|
|
|
#include <indexwindow.h>
|
|
|
|
|
|
2011-08-30 15:57:00 +02:00
|
|
|
#include <app/app_version.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>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.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>
|
2014-01-13 16:17:34 +01:00
|
|
|
#include <coreplugin/find/findplugin.h>
|
2009-06-23 16:57:03 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2014-06-04 13:41:32 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2009-07-17 15:04:14 +02:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QLibraryInfo>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QTranslator>
|
|
|
|
|
#include <qplugin.h>
|
|
|
|
|
#include <QRegExp>
|
2010-02-02 14:25:22 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDesktopServices>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QStackedLayout>
|
|
|
|
|
#include <QSplitter>
|
2010-02-02 14:25:22 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHelpEngine>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Help::Internal;
|
|
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char SB_INDEX[] = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Index");
|
|
|
|
|
const char SB_CONTENTS[] = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Contents");
|
|
|
|
|
const char SB_BOOKMARKS[] = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Bookmarks");
|
2010-05-31 12:37:21 +02:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char SB_OPENPAGES[] = "OpenPages";
|
2010-04-29 11:59:42 +02:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
#define IMAGEPATH ":/help/images/"
|
2013-03-14 12:18:15 +01:00
|
|
|
|
2011-09-02 17:15:18 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
button->setPopupMode(QToolButton::DelayedPopup);
|
|
|
|
|
return button;
|
2010-10-05 14:18:18 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 14:25:22 +01:00
|
|
|
HelpPlugin::HelpPlugin()
|
2010-03-23 18:11:43 +01:00
|
|
|
: m_mode(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_centralWidget(0),
|
2011-03-03 16:46:57 +01:00
|
|
|
m_rightPaneSideBarWidget(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
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),
|
2010-07-23 16:36:08 +02:00
|
|
|
m_firstModeChange(true),
|
2012-05-15 15:06:39 +02:00
|
|
|
m_helpManager(0),
|
|
|
|
|
m_openPagesManager(0),
|
2010-08-05 16:16:53 +02:00
|
|
|
m_oldMode(0),
|
|
|
|
|
m_connectWindow(true),
|
2010-08-25 11:40:44 +02:00
|
|
|
m_externalWindow(0),
|
|
|
|
|
m_backMenu(0),
|
2012-05-11 14:41:40 +02:00
|
|
|
m_nextMenu(0),
|
|
|
|
|
m_isSidebarVisible(true)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpPlugin::~HelpPlugin()
|
|
|
|
|
{
|
2012-05-15 15:06:39 +02:00
|
|
|
delete m_centralWidget;
|
|
|
|
|
delete m_openPagesManager;
|
2011-03-03 16:46:57 +01:00
|
|
|
delete m_rightPaneSideBarWidget;
|
2012-05-15 15:06:39 +02:00
|
|
|
|
|
|
|
|
delete m_helpManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
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)
|
2013-08-29 19:00:34 +02:00
|
|
|
Context globalcontext(Core::Constants::C_GLOBAL);
|
|
|
|
|
Context modecontext(Constants::C_MODE_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
const QString &locale = ICore::userInterfaceLanguage();
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
const QString &creatorTrPath = ICore::resourcePath()
|
2010-02-02 12:33:13 +01:00
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
2012-05-15 15:06:39 +02:00
|
|
|
m_helpManager = new LocalHelpManager(this);
|
|
|
|
|
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());
|
2014-03-18 22:50:44 +02:00
|
|
|
addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler);
|
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-07-23 16:36:08 +02:00
|
|
|
connect(m_generalSettingsPage, SIGNAL(contextHelpOptionChanged()), this,
|
|
|
|
|
SLOT(contextHelpOptionChanged()));
|
2010-09-21 17:00:41 +02:00
|
|
|
connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), this,
|
|
|
|
|
SLOT(updateCloseButton()));
|
2013-08-29 19:00:34 +02:00
|
|
|
connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
|
2010-04-28 15:04:39 +02:00
|
|
|
SLOT(handleHelpRequest(QUrl)));
|
2014-03-18 22:50:44 +02:00
|
|
|
connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this,
|
|
|
|
|
SLOT(switchToHelpMode(QUrl)));
|
2010-08-02 16:33:19 +02:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this,
|
|
|
|
|
SLOT(setupHelpEngineIfNeeded()));
|
2013-08-29 19:00:34 +02:00
|
|
|
connect(HelpManager::instance(), SIGNAL(documentationChanged()), this,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(setupHelpEngineIfNeeded()));
|
2013-08-29 19:00:34 +02:00
|
|
|
connect(HelpManager::instance(), SIGNAL(collectionFileChanged()), this,
|
2010-08-02 16:32:18 +02:00
|
|
|
SLOT(setupHelpEngineIfNeeded()));
|
2013-08-29 19:00:34 +02:00
|
|
|
connect(HelpManager::instance(), SIGNAL(setupFinished()), this,
|
2012-09-18 10:05:09 +02:00
|
|
|
SLOT(unregisterOldQtCreatorDocumentation()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
m_splitter = new MiniSplitter;
|
2010-03-23 18:11:43 +01:00
|
|
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
ActionManager::registerAction(action, "Help.Home", globalcontext);
|
2010-03-30 17:44:28 +02:00
|
|
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
Command *cmd = ActionManager::registerAction(action, "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
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
action = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"), this);
|
|
|
|
|
cmd = ActionManager::registerAction(action, "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);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.AddBookmark", modecontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-01-24 09:51:52 +01:00
|
|
|
// Add Contents, Index, and Context menu items
|
2010-08-04 15:34:25 +02:00
|
|
|
action = new QAction(QIcon::fromTheme(QLatin1String("help-contents")),
|
|
|
|
|
tr(SB_CONTENTS), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.Contents", globalcontext);
|
|
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
2010-04-15 14:50:17 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
|
|
|
|
|
|
2010-05-31 12:37:21 +02:00
|
|
|
action = new QAction(tr(SB_INDEX), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.Index", globalcontext);
|
|
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("Context Help"), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.Context", globalcontext);
|
|
|
|
|
ActionManager::actionContainer(Core::Constants::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
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
action = new QAction(tr("Technical Support"), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.TechSupport", globalcontext);
|
2014-01-24 09:51:52 +01:00
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT);
|
2010-11-11 16:49:17 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenSupportPage()));
|
|
|
|
|
|
2011-08-01 08:53:26 +02:00
|
|
|
action = new QAction(tr("Report Bug..."), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.ReportBug", globalcontext);
|
2014-01-24 09:51:52 +01:00
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT);
|
2011-07-26 18:38:27 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(slotReportBug()));
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
action = new QAction(this);
|
2013-08-29 19:00:34 +02:00
|
|
|
ActionManager::registerAction(action, Core::Constants::PRINT, modecontext);
|
2010-03-30 17:44:28 +02:00
|
|
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, Core::Constants::COPY, modecontext);
|
2010-03-30 17:44:28 +02:00
|
|
|
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
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
if (ActionContainer *advancedMenu = ActionManager::actionContainer(Core::Constants::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);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE, modecontext);
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE, modecontext);
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE, modecontext);
|
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
|
|
|
}
|
|
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
if (ActionContainer *windowMenu = ActionManager::actionContainer(Core::Constants::M_WINDOW)) {
|
2010-04-12 14:55:41 +02:00
|
|
|
// reuse EditorManager constants to avoid a second pair of menu actions
|
2013-08-29 19:00:34 +02:00
|
|
|
// Goto Previous In History Action
|
2013-12-06 14:31:42 +01:00
|
|
|
action = new QAction(this);
|
2013-08-29 19:00:34 +02:00
|
|
|
Command *ctrlTab = ActionManager::registerAction(action, Core::Constants::GOTOPREVINHISTORY,
|
|
|
|
|
modecontext);
|
2010-04-12 14:55:41 +02:00
|
|
|
windowMenu->addAction(ctrlTab, Core::Constants::G_WINDOW_NAVIGATE);
|
|
|
|
|
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(gotoPreviousPage()));
|
|
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
// Goto Next In History Action
|
2013-12-06 14:31:42 +01:00
|
|
|
action = new QAction(this);
|
2013-08-29 19:00:34 +02:00
|
|
|
Command *ctrlShiftTab = ActionManager::registerAction(action, Core::Constants::GOTONEXTINHISTORY,
|
|
|
|
|
modecontext);
|
2010-04-12 14:55:41 +02:00
|
|
|
windowMenu->addAction(ctrlShiftTab, Core::Constants::G_WINDOW_NAVIGATE);
|
|
|
|
|
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(gotoNextPage()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
|
|
|
|
agg->add(m_centralWidget);
|
|
|
|
|
agg->add(new HelpFindSupport(m_centralWidget));
|
2010-08-25 15:50:22 +02:00
|
|
|
|
|
|
|
|
QWidget *toolBarWidget = new QWidget;
|
|
|
|
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
|
|
|
|
|
toolBarLayout->setMargin(0);
|
|
|
|
|
toolBarLayout->setSpacing(0);
|
|
|
|
|
toolBarLayout->addWidget(m_externalHelpBar = createIconToolBar(true));
|
|
|
|
|
toolBarLayout->addWidget(m_internalHelpBar = createIconToolBar(false));
|
|
|
|
|
toolBarLayout->addWidget(createWidgetToolBar());
|
|
|
|
|
|
2010-07-26 11:15:03 +02:00
|
|
|
QWidget *mainWidget = new QWidget;
|
|
|
|
|
m_splitter->addWidget(mainWidget);
|
|
|
|
|
QVBoxLayout *mainWidgetLayout = new QVBoxLayout(mainWidget);
|
2010-03-23 18:11:43 +01:00
|
|
|
mainWidgetLayout->setMargin(0);
|
|
|
|
|
mainWidgetLayout->setSpacing(0);
|
2010-08-25 15:50:22 +02:00
|
|
|
mainWidgetLayout->addWidget(toolBarWidget);
|
2010-03-23 18:11:43 +01:00
|
|
|
mainWidgetLayout->addWidget(m_centralWidget);
|
|
|
|
|
|
2010-07-21 14:56:03 +02:00
|
|
|
if (QLayout *layout = m_centralWidget->layout()) {
|
|
|
|
|
layout->setSpacing(0);
|
2013-08-29 19:00:34 +02:00
|
|
|
FindToolBarPlaceHolder *fth = new FindToolBarPlaceHolder(m_centralWidget);
|
2011-03-03 16:46:57 +01:00
|
|
|
fth->setObjectName(QLatin1String("HelpFindToolBarPlaceHolder"));
|
2014-01-13 16:04:51 +01:00
|
|
|
mainWidgetLayout->addWidget(fth);
|
2010-07-21 14:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-23 17:54:38 +01:00
|
|
|
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
|
|
|
|
|
addAutoReleasedObject(helpIndexFilter);
|
|
|
|
|
connect(helpIndexFilter, SIGNAL(linkActivated(QUrl)), this,
|
|
|
|
|
SLOT(switchToHelpMode(QUrl)));
|
|
|
|
|
|
2010-07-16 11:15:54 +02:00
|
|
|
RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter();
|
|
|
|
|
addAutoReleasedObject(remoteHelpFilter);
|
|
|
|
|
connect(remoteHelpFilter, SIGNAL(linkActivated(QUrl)), this,
|
|
|
|
|
SLOT(switchToHelpMode(QUrl)));
|
|
|
|
|
|
2012-11-26 20:56:29 +02:00
|
|
|
QDesktopServices::setUrlHandler(QLatin1String("qthelp"), this, "handleHelpRequest");
|
2013-08-29 19:00:34 +02:00
|
|
|
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)),
|
|
|
|
|
this, SLOT(modeChanged(Core::IMode*,Core::IMode*)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2010-08-04 15:34:25 +02:00
|
|
|
m_externalWindow = new ExternalHelpWindow;
|
2010-12-06 14:12:38 +01:00
|
|
|
m_mode = new HelpMode;
|
2010-07-23 16:36:08 +02:00
|
|
|
if (contextHelpOption() == Help::Constants::ExternalHelpAlways) {
|
2010-12-06 14:12:38 +01:00
|
|
|
m_mode->setWidget(new QWidget);
|
2010-07-23 16:36:08 +02:00
|
|
|
m_mode->setEnabled(false);
|
2010-08-25 17:34:36 +02:00
|
|
|
m_externalHelpBar->setVisible(true);
|
2010-07-23 16:36:08 +02:00
|
|
|
m_externalWindow->setCentralWidget(m_splitter);
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(showExternalWindow()));
|
|
|
|
|
} else {
|
2010-12-06 14:12:38 +01:00
|
|
|
m_mode->setWidget(m_splitter);
|
2010-08-25 17:34:36 +02:00
|
|
|
m_internalHelpBar->setVisible(true);
|
2010-07-23 16:36:08 +02:00
|
|
|
}
|
|
|
|
|
addAutoReleasedObject(m_mode);
|
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-03-23 18:11:43 +01:00
|
|
|
QStringList filesToRegister;
|
|
|
|
|
// we might need to register creators inbuild help
|
2013-06-18 09:22:46 +02:00
|
|
|
filesToRegister.append(ICore::documentationPath() + QLatin1String("/qtcreator.qch"));
|
2013-08-29 19:00:34 +02:00
|
|
|
HelpManager::registerDocumentation(filesToRegister);
|
2009-07-27 13:55:30 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 13:36:47 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
2010-02-02 11:40:45 +01:00
|
|
|
{
|
2012-05-11 14:41:40 +02:00
|
|
|
if (m_sideBar) {
|
2013-08-29 19:00:34 +02:00
|
|
|
QSettings *settings = ICore::settings();
|
2012-05-11 14:41:40 +02:00
|
|
|
m_sideBar->saveSettings(settings, QLatin1String("HelpSideBar"));
|
|
|
|
|
// keep a boolean value to avoid to modify the sidebar class, at least some qml stuff
|
|
|
|
|
// depends on the always visible property of the sidebar...
|
|
|
|
|
settings->setValue(QLatin1String("HelpSideBar/") + QLatin1String("Visible"), m_isSidebarVisible);
|
|
|
|
|
}
|
2012-06-04 13:17:54 +02:00
|
|
|
|
|
|
|
|
if (m_externalWindow) {
|
|
|
|
|
delete m_externalWindow;
|
|
|
|
|
m_centralWidget = 0; // Running the external window will take down the central widget as well, cause
|
|
|
|
|
// calling m_externalWindow->setCentralWidget(m_centralWidget) will pass ownership to the window.
|
|
|
|
|
}
|
2010-07-23 16:36:08 +02:00
|
|
|
|
2010-07-13 13:36:47 +02:00
|
|
|
return SynchronousShutdown;
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-18 10:05:09 +02:00
|
|
|
void HelpPlugin::unregisterOldQtCreatorDocumentation()
|
|
|
|
|
{
|
2013-01-29 15:29:55 +01:00
|
|
|
const QString &nsInternal = QString::fromLatin1("org.qt-project.qtcreator.%1%2%3")
|
2012-09-18 10:05:09 +02:00
|
|
|
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
|
|
|
|
|
|
|
|
|
QStringList documentationToUnregister;
|
2013-08-29 19:00:34 +02:00
|
|
|
foreach (const QString &ns, HelpManager::registeredNamespaces()) {
|
2013-01-29 15:29:55 +01:00
|
|
|
if (ns.startsWith(QLatin1String("org.qt-project.qtcreator."))
|
2012-09-18 10:05:09 +02:00
|
|
|
&& ns != nsInternal) {
|
|
|
|
|
documentationToUnregister << ns;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!documentationToUnregister.isEmpty())
|
2013-08-29 19:00:34 +02:00
|
|
|
HelpManager::unregisterDocumentation(documentationToUnregister);
|
2012-09-18 10:05:09 +02: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
|
2013-08-29 19:00:34 +02:00
|
|
|
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));
|
2013-08-29 19:00:34 +02:00
|
|
|
m_indexItem = new SideBarItem(indexWindow, QLatin1String(SB_INDEX));
|
2010-03-30 17:44:28 +02:00
|
|
|
|
|
|
|
|
connect(indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(indexWindow, SIGNAL(linksActivated(QMap<QString,QUrl>,QString)),
|
|
|
|
|
m_centralWidget, SLOT(showTopicChooser(QMap<QString,QUrl>,QString)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
QMap<QString, Command*> shortcutMap;
|
2014-02-28 17:33:48 +01:00
|
|
|
QAction *action = new QAction(tr("Activate Index in Help mode"), m_splitter);
|
|
|
|
|
Command *cmd = ActionManager::registerAction(action, "Help.IndexShortcut", modecontext);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+I") : tr("Ctrl+Shift+I")));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), 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));
|
2013-08-29 19:00:34 +02:00
|
|
|
m_contentItem = new 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
|
|
|
|
2014-02-28 17:33:48 +01:00
|
|
|
action = new QAction(tr("Activate Contents in Help mode"), m_splitter);
|
|
|
|
|
cmd = ActionManager::registerAction(action, "Help.ContentsShortcut", modecontext);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+C") : tr("Ctrl+Shift+C")));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), 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
|
|
|
|
2014-06-12 18:01:43 +02:00
|
|
|
m_searchItem = new SearchSideBarItem;
|
|
|
|
|
connect(m_searchItem, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(setSourceFromSearch(QUrl)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2014-02-28 17:33:48 +01:00
|
|
|
action = new QAction(tr("Activate Search in Help mode"), m_splitter);
|
|
|
|
|
cmd = ActionManager::registerAction(action, "Help.SearchShortcut", modecontext);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+/") : tr("Ctrl+Shift+/")));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(activateSearch()));
|
2014-06-12 18:01:43 +02:00
|
|
|
shortcutMap.insert(m_searchItem->id(), 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));
|
2013-08-29 19:00:34 +02:00
|
|
|
m_bookmarkItem = new SideBarItem(bookmarkWidget, QLatin1String(SB_BOOKMARKS));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(bookmarkWidget, SIGNAL(linkActivated(QUrl)), m_centralWidget,
|
|
|
|
|
SLOT(setSource(QUrl)));
|
2012-04-03 15:05:03 +02:00
|
|
|
connect(bookmarkWidget, SIGNAL(createPage(QUrl,bool)), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(createPage(QUrl,bool)));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2014-02-28 17:33:48 +01:00
|
|
|
action = new QAction(tr("Activate Bookmarks in Help mode"), m_splitter);
|
|
|
|
|
cmd = ActionManager::registerAction(action, "Help.BookmarkShortcut", modecontext);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+B") : tr("Ctrl+Shift+B")));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), 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"));
|
2013-08-29 19:00:34 +02:00
|
|
|
m_openPagesItem = new SideBarItem(openPagesWidget, QLatin1String(SB_OPENPAGES));
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2014-02-28 17:33:48 +01:00
|
|
|
action = new QAction(tr("Activate Open Pages in Help mode"), m_splitter);
|
|
|
|
|
cmd = ActionManager::registerAction(action, "Help.PagesShortcut", modecontext);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+O") : tr("Ctrl+Shift+O")));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), 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
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
QList<SideBarItem*> itemList;
|
2010-03-30 17:44:28 +02:00
|
|
|
itemList << m_contentItem << m_indexItem << m_searchItem << m_bookmarkItem
|
|
|
|
|
<< m_openPagesItem;
|
2013-08-29 19:00:34 +02:00
|
|
|
m_sideBar = new SideBar(itemList, QList<SideBarItem*>()
|
2010-04-01 14:49:15 +02:00
|
|
|
<< m_contentItem << m_openPagesItem);
|
2012-05-11 14:41:40 +02:00
|
|
|
m_sideBar->setCloseWhenEmpty(true);
|
2010-03-23 18:11:43 +01:00
|
|
|
m_sideBar->setShortcutMap(shortcutMap);
|
2012-05-11 14:41:40 +02:00
|
|
|
connect(m_sideBar, SIGNAL(sideBarClosed()), this, SLOT(onSideBarVisibilityChanged()));
|
2010-03-23 18:11:43 +01:00
|
|
|
|
|
|
|
|
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);
|
2013-08-29 19:00:34 +02:00
|
|
|
m_sideBar->readSettings(ICore::settings(), QLatin1String("HelpSideBar"));
|
2010-08-17 14:45:45 +02:00
|
|
|
m_splitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
|
2012-05-11 14:41:40 +02:00
|
|
|
|
|
|
|
|
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
|
|
|
|
|
tr("Show Sidebar"), this);
|
|
|
|
|
m_toggleSideBarAction->setCheckable(true);
|
|
|
|
|
connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(showHideSidebar()));
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR, modecontext);
|
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);
|
2012-04-30 12:01:15 +02:00
|
|
|
QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
|
2010-06-11 13:11:37 +02:00
|
|
|
|
|
|
|
|
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
|
|
|
|
|
const QStringList &filters = engine->customFilters();
|
|
|
|
|
foreach (const QString &filter, filters) {
|
|
|
|
|
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
|
|
|
|
|
engine->removeCustomFilter(filter);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 14:30:39 +02:00
|
|
|
// we added a filter at some point, remove previously added filter
|
|
|
|
|
if (engine->customValue(Help::Constants::WeAddedFilterKey).toInt() == 1) {
|
|
|
|
|
const QString &filter =
|
|
|
|
|
engine->customValue(Help::Constants::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());
|
2010-07-20 14:30:39 +02:00
|
|
|
engine->setCustomValue(Help::Constants::WeAddedFilterKey, 1);
|
|
|
|
|
engine->setCustomValue(Help::Constants::PreviousFilterNameKey, filterName);
|
2010-06-11 13:11:37 +02:00
|
|
|
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
|
|
|
{
|
2011-03-03 16:46:57 +01:00
|
|
|
if (m_rightPaneSideBarWidget)
|
2010-03-16 15:21:06 +01:00
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
Utils::StyledBar *toolBar = new Utils::StyledBar();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
|
|
|
|
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode()));
|
2010-08-25 11:40:44 +02:00
|
|
|
QAction *back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
2010-10-05 14:18:18 +02:00
|
|
|
tr("Previous"), toolBar);
|
2010-03-23 18:11:43 +01:00
|
|
|
QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
|
2010-10-05 14:18:18 +02:00
|
|
|
tr("Next"), toolBar);
|
2012-02-17 14:00:45 +01:00
|
|
|
QAction *close = new QAction(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT)),
|
2010-10-05 14:18:18 +02:00
|
|
|
QLatin1String(""), toolBar);
|
|
|
|
|
connect(close, SIGNAL(triggered()), this, SLOT(slotHideRightPane()));
|
2010-08-25 11:40:44 +02:00
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
setupNavigationMenus(back, next, toolBar);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->setMargin(0);
|
2010-03-16 15:21:06 +01:00
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
layout->addWidget(toolButton(switchToHelp));
|
|
|
|
|
layout->addWidget(toolButton(back));
|
|
|
|
|
layout->addWidget(toolButton(next));
|
|
|
|
|
layout->addStretch();
|
|
|
|
|
layout->addWidget(toolButton(close));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-03-03 16:46:57 +01:00
|
|
|
m_rightPaneSideBarWidget = new QWidget;
|
2014-05-02 16:54:28 +02:00
|
|
|
m_helpViewerForSideBar = createHelpViewer(qreal(0.0));
|
|
|
|
|
m_helpViewerForSideBar->setOpenInNewWindowActionVisible(false);
|
2010-10-05 14:18:18 +02:00
|
|
|
|
2011-03-03 16:46:57 +01:00
|
|
|
QVBoxLayout *rightPaneLayout = new QVBoxLayout(m_rightPaneSideBarWidget);
|
2010-10-05 14:18:18 +02:00
|
|
|
rightPaneLayout->setMargin(0);
|
|
|
|
|
rightPaneLayout->setSpacing(0);
|
|
|
|
|
rightPaneLayout->addWidget(toolBar);
|
2010-03-16 15:21:06 +01:00
|
|
|
rightPaneLayout->addWidget(m_helpViewerForSideBar);
|
2013-08-29 19:00:34 +02:00
|
|
|
FindToolBarPlaceHolder *fth = new FindToolBarPlaceHolder(m_rightPaneSideBarWidget);
|
2011-03-03 16:46:57 +01:00
|
|
|
fth->setObjectName(QLatin1String("HelpRightPaneFindToolBarPlaceHolder"));
|
|
|
|
|
rightPaneLayout->addWidget(fth);
|
|
|
|
|
m_rightPaneSideBarWidget->setFocusProxy(m_helpViewerForSideBar);
|
2010-03-16 15:21:06 +01:00
|
|
|
|
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-11-16 14:16:48 +01:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
Context context(Constants::C_HELP_SIDEBAR);
|
|
|
|
|
IContext *icontext = new IContext(this);
|
2011-04-13 16:09:04 +02:00
|
|
|
icontext->setContext(context);
|
|
|
|
|
icontext->setWidget(m_helpViewerForSideBar);
|
2013-08-29 19:00:34 +02:00
|
|
|
ICore::addContextObject(icontext);
|
2010-03-16 15:21:06 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
QAction *copy = new QAction(this);
|
2013-08-29 19:00:34 +02:00
|
|
|
Command *cmd = ActionManager::registerAction(copy, Core::Constants::COPY, context);
|
2010-03-23 18:11:43 +01:00
|
|
|
copy->setText(cmd->action()->text());
|
|
|
|
|
copy->setIcon(cmd->action()->icon());
|
|
|
|
|
connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy()));
|
2010-10-05 14:18:18 +02:00
|
|
|
|
2010-08-25 11:40:44 +02:00
|
|
|
next->setEnabled(m_helpViewerForSideBar->isForwardAvailable());
|
2010-03-23 18:11:43 +01:00
|
|
|
connect(next, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(forward()));
|
2010-08-25 11:40:44 +02:00
|
|
|
connect(m_helpViewerForSideBar, SIGNAL(forwardAvailable(bool)), next,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
2010-10-05 14:18:18 +02:00
|
|
|
|
2010-08-25 11:40:44 +02:00
|
|
|
back->setEnabled(m_helpViewerForSideBar->isBackwardAvailable());
|
|
|
|
|
connect(back, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(backward()));
|
|
|
|
|
connect(m_helpViewerForSideBar, SIGNAL(backwardAvailable(bool)), back,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
2010-07-07 11:26:24 +02:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
if (ActionContainer *advancedMenu = ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
2010-11-16 14:16:48 +01:00
|
|
|
// reuse TextEditor constants to avoid a second pair of menu actions
|
|
|
|
|
QAction *action = new QAction(tr("Increase Font Size"), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE, context);
|
2010-11-16 14:16:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneUp()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("Decrease Font Size"), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE, context);
|
2010-11-16 14:16:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneDown()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("Reset Font Size"), this);
|
2013-08-29 19:00:34 +02:00
|
|
|
cmd = ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE, context);
|
2010-11-16 14:16:48 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(resetRightPaneScale()));
|
|
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 13:41:32 +02:00
|
|
|
connect(m_helpViewerForSideBar, SIGNAL(loadFinished()),
|
|
|
|
|
this, SLOT(highlightSearchTermsInContextHelp()));
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2010-11-16 14:16:48 +01:00
|
|
|
void HelpPlugin::scaleRightPaneUp()
|
|
|
|
|
{
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->scaleUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::scaleRightPaneDown()
|
|
|
|
|
{
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->scaleDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::resetRightPaneScale()
|
|
|
|
|
{
|
|
|
|
|
if (m_helpViewerForSideBar)
|
|
|
|
|
m_helpViewerForSideBar->resetScale();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 16:54:28 +02:00
|
|
|
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|
|
|
|
{
|
2014-05-14 13:15:01 +02:00
|
|
|
HelpViewer *viewer = 0;
|
|
|
|
|
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
|
|
|
|
|
if (backend.compare(QLatin1String("native"), Qt::CaseInsensitive) == 0) {
|
|
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER
|
|
|
|
|
viewer = new MacWebKitHelpViewer(zoom);
|
|
|
|
|
#endif
|
|
|
|
|
} else if (backend.compare(QLatin1String("textbrowser"), Qt::CaseInsensitive) == 0) {
|
|
|
|
|
viewer = new TextBrowserHelpViewer(zoom);
|
|
|
|
|
} else {
|
2014-05-02 16:54:28 +02:00
|
|
|
#ifndef QT_NO_WEBKIT
|
2014-05-14 13:15:01 +02:00
|
|
|
viewer = new QtWebKitHelpViewer(zoom);
|
2014-05-02 16:54:28 +02:00
|
|
|
#else
|
2014-05-14 13:15:01 +02:00
|
|
|
viewer = new TextBrowserHelpViewer(zoom);
|
2014-05-02 16:54:28 +02:00
|
|
|
#endif
|
2014-05-14 13:15:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// initialize font
|
|
|
|
|
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
|
|
|
|
if (fontSetting.isValid())
|
|
|
|
|
viewer->setViewerFont(fontSetting.value<QFont>());
|
|
|
|
|
return viewer;
|
2014-05-02 16:54:28 +02:00
|
|
|
}
|
|
|
|
|
|
2009-01-28 13:57:42 +01:00
|
|
|
void HelpPlugin::activateHelpMode()
|
|
|
|
|
{
|
2010-07-23 16:36:08 +02:00
|
|
|
if (contextHelpOption() != Help::Constants::ExternalHelpAlways)
|
2013-08-29 19:00:34 +02:00
|
|
|
ModeManager::activateMode(Id(Constants::ID_MODE_HELP));
|
2010-07-23 16:36:08 +02:00
|
|
|
else
|
|
|
|
|
showExternalWindow();
|
2009-01-28 13:57:42 +01:00
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::slotHideRightPane()
|
|
|
|
|
{
|
2013-08-29 19:00:34 +02:00
|
|
|
RightPaneWidget::instance()->setShown(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-04 15:34:25 +02:00
|
|
|
void HelpPlugin::showHideSidebar()
|
|
|
|
|
{
|
|
|
|
|
m_sideBar->setVisible(!m_sideBar->isVisible());
|
2012-05-11 14:41:40 +02:00
|
|
|
onSideBarVisibilityChanged();
|
2010-08-04 15:34:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-23 16:36:08 +02:00
|
|
|
void HelpPlugin::showExternalWindow()
|
|
|
|
|
{
|
2010-08-02 16:18:09 +02:00
|
|
|
bool firstTime = m_firstModeChange;
|
2010-08-25 16:18:52 +02:00
|
|
|
doSetupIfNeeded();
|
2010-07-23 16:36:08 +02:00
|
|
|
m_externalWindow->show();
|
2010-08-05 16:16:53 +02:00
|
|
|
connectExternalHelpWindow();
|
|
|
|
|
if (firstTime)
|
2013-08-29 19:00:34 +02:00
|
|
|
ICore::raiseWindow(ICore::mainWindow());
|
2013-04-15 12:53:34 +02:00
|
|
|
else
|
2013-08-29 19:00:34 +02:00
|
|
|
ICore::raiseWindow(m_externalWindow);
|
2010-07-23 16:36:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
void HelpPlugin::modeChanged(IMode *mode, IMode *old)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-21 14:54:02 +02:00
|
|
|
if (mode == m_mode) {
|
2010-07-23 16:36:08 +02:00
|
|
|
m_oldMode = old;
|
2010-03-23 18:11:43 +01:00
|
|
|
qApp->setOverrideCursor(Qt::WaitCursor);
|
2010-08-25 16:18:52 +02:00
|
|
|
doSetupIfNeeded();
|
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
|
|
|
{
|
2013-08-29 19:00:34 +02:00
|
|
|
const bool closeOnReturn = HelpManager::customValue(QLatin1String("ReturnOnClose"),
|
2010-09-21 17:00:41 +02:00
|
|
|
false).toBool();
|
|
|
|
|
m_closeButton->setEnabled((OpenPagesManager::instance().pageCount() > 1)
|
2014-05-19 18:33:58 +03:00
|
|
|
|| closeOnReturn);
|
2010-03-30 17:44:28 +02:00
|
|
|
}
|
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
|
|
|
|
2014-05-14 13:15:01 +02:00
|
|
|
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
|
|
|
|
QFont font = fontSetting.isValid() ? fontSetting.value<QFont>()
|
|
|
|
|
: m_helpViewerForSideBar->viewerFont();
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2014-05-14 13:15:01 +02:00
|
|
|
m_helpViewerForSideBar->setViewerFont(font);
|
2010-03-30 17:44:28 +02:00
|
|
|
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-07-23 16:36:08 +02:00
|
|
|
QStackedLayout * layoutForWidget(QWidget *parent, QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
QList<QStackedLayout*> list = parent->findChildren<QStackedLayout*>();
|
|
|
|
|
foreach (QStackedLayout *layout, list) {
|
|
|
|
|
const int index = layout->indexOf(widget);
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
return layout;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::contextHelpOptionChanged()
|
|
|
|
|
{
|
2010-08-25 16:18:52 +02:00
|
|
|
doSetupIfNeeded();
|
2010-07-23 16:36:08 +02:00
|
|
|
QWidget *modeWidget = m_mode->widget();
|
|
|
|
|
if (modeWidget == m_splitter
|
|
|
|
|
&& contextHelpOption() == Help::Constants::ExternalHelpAlways) {
|
|
|
|
|
if (QWidget *widget = m_splitter->parentWidget()) {
|
|
|
|
|
if (QStackedLayout *layout = layoutForWidget(widget, m_splitter)) {
|
|
|
|
|
const int index = layout->indexOf(m_splitter);
|
|
|
|
|
layout->removeWidget(m_splitter);
|
|
|
|
|
m_mode->setWidget(new QWidget);
|
|
|
|
|
layout->insertWidget(index, m_mode->widget());
|
|
|
|
|
m_externalWindow->setCentralWidget(m_splitter);
|
|
|
|
|
m_splitter->show();
|
|
|
|
|
|
|
|
|
|
slotHideRightPane();
|
|
|
|
|
m_mode->setEnabled(false);
|
2010-08-25 15:50:22 +02:00
|
|
|
m_externalHelpBar->setVisible(true);
|
|
|
|
|
m_internalHelpBar->setVisible(false);
|
2010-07-23 16:36:08 +02:00
|
|
|
m_externalWindow->show();
|
2010-08-05 16:16:53 +02:00
|
|
|
connectExternalHelpWindow();
|
|
|
|
|
|
2012-01-26 01:18:02 +01:00
|
|
|
if (m_oldMode && m_mode == ModeManager::currentMode())
|
|
|
|
|
ModeManager::activateMode(m_oldMode->id());
|
2010-07-23 16:36:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (modeWidget != m_splitter
|
|
|
|
|
&& contextHelpOption() != Help::Constants::ExternalHelpAlways) {
|
|
|
|
|
QStackedLayout *wLayout = layoutForWidget(modeWidget->parentWidget(),
|
|
|
|
|
modeWidget);
|
|
|
|
|
if (wLayout && m_splitter->parentWidget()->layout()) {
|
|
|
|
|
const int index = wLayout->indexOf(modeWidget);
|
|
|
|
|
QWidget *tmp = wLayout->widget(index);
|
|
|
|
|
wLayout->removeWidget(modeWidget);
|
|
|
|
|
delete tmp;
|
|
|
|
|
|
|
|
|
|
m_splitter->parentWidget()->layout()->removeWidget(m_splitter);
|
|
|
|
|
m_mode->setWidget(m_splitter);
|
|
|
|
|
wLayout->insertWidget(index, m_splitter);
|
|
|
|
|
|
|
|
|
|
m_mode->setEnabled(true);
|
|
|
|
|
m_externalWindow->close();
|
2010-08-04 15:34:25 +02:00
|
|
|
m_sideBar->setVisible(true);
|
2010-08-25 15:50:22 +02:00
|
|
|
m_internalHelpBar->setVisible(true);
|
|
|
|
|
m_externalHelpBar->setVisible(false);
|
2010-07-23 16:36:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
void HelpPlugin::setupHelpEngineIfNeeded()
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
m_helpManager->setEngineNeedsUpdate();
|
2013-08-29 19:00:34 +02:00
|
|
|
if (ModeManager::currentMode() == m_mode
|
2010-07-23 16:36:08 +02:00
|
|
|
|| contextHelpOption() == Help::Constants::ExternalHelpAlways)
|
2010-03-23 18:11:43 +01:00
|
|
|
m_helpManager->setupGuiHelpEngine();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-02 17:15:18 +02:00
|
|
|
HelpViewer *HelpPlugin::viewerForContextMode()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-01-26 01:18:02 +01:00
|
|
|
if (ModeManager::currentMode()->id() == Core::Constants::MODE_WELCOME)
|
|
|
|
|
ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
2010-10-27 17:44:41 +02:00
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
bool showSideBySide = false;
|
|
|
|
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
2010-07-23 12:44:22 +02:00
|
|
|
switch (contextHelpOption()) {
|
|
|
|
|
case Help::Constants::SideBySideIfPossible: {
|
2010-02-02 12:33:13 +01:00
|
|
|
// side by side if possible
|
2012-05-08 09:43:14 +02:00
|
|
|
if (IEditor *editor = EditorManager::currentEditor()) {
|
2010-02-02 12:33:13 +01:00
|
|
|
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
|
2010-07-23 12:44:22 +02:00
|
|
|
case Help::Constants::SideBySideAlways: {
|
2010-02-02 12:33:13 +01:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:47:31 +02:00
|
|
|
if (placeHolder && showSideBySide) {
|
2011-05-19 17:14:53 +02:00
|
|
|
createRightPaneContextViewer();
|
2011-03-03 16:46:57 +01:00
|
|
|
RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPaneWidget::instance()->setShown(true);
|
2010-10-12 16:53:00 +02:00
|
|
|
return m_helpViewerForSideBar;
|
2009-06-02 17:22:14 +02:00
|
|
|
}
|
2010-10-12 16:53:00 +02:00
|
|
|
|
|
|
|
|
activateHelpMode(); // should trigger an createPage...
|
|
|
|
|
HelpViewer *viewer = m_centralWidget->currentHelpViewer();
|
|
|
|
|
if (!viewer)
|
|
|
|
|
viewer = OpenPagesManager::instance().createPage();
|
2009-08-06 15:47:31 +02:00
|
|
|
return viewer;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 13:41:32 +02:00
|
|
|
static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
|
|
|
|
|
{
|
|
|
|
|
if (highlightId)
|
|
|
|
|
highlightId->clear();
|
|
|
|
|
if (links.isEmpty())
|
|
|
|
|
return QUrl();
|
2014-06-04 10:47:48 -04:00
|
|
|
QUrl source = links.constBegin().value();
|
2014-06-04 13:41:32 +02:00
|
|
|
// workaround to show the latest Qt version
|
|
|
|
|
int version = 0;
|
|
|
|
|
QRegExp exp(QLatin1String("(\\d+)"));
|
|
|
|
|
foreach (const QUrl &link, links) {
|
|
|
|
|
const QString &authority = link.authority();
|
|
|
|
|
if (authority.startsWith(QLatin1String("com.trolltech."))
|
|
|
|
|
|| authority.startsWith(QLatin1String("org.qt-project."))) {
|
|
|
|
|
if (exp.indexIn(authority) >= 0) {
|
|
|
|
|
const int tmpVersion = exp.cap(1).toInt();
|
|
|
|
|
if (tmpVersion > version) {
|
|
|
|
|
source = link;
|
|
|
|
|
version = tmpVersion;
|
|
|
|
|
if (highlightId)
|
|
|
|
|
*highlightId = source.fragment();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:47:31 +02:00
|
|
|
void HelpPlugin::activateContext()
|
|
|
|
|
{
|
2010-03-16 19:31:29 +01:00
|
|
|
createRightPaneContextViewer();
|
2010-03-16 15:21:06 +01:00
|
|
|
|
2011-09-02 17:15:18 +02:00
|
|
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
2014-05-30 14:26:59 +02:00
|
|
|
if (placeHolder && qApp->focusWidget()
|
|
|
|
|
&& qApp->focusWidget() == m_helpViewerForSideBar->focusWidget()) {
|
2009-08-06 15:47:31 +02:00
|
|
|
switchToHelpMode();
|
|
|
|
|
return;
|
2011-09-02 17:15:18 +02:00
|
|
|
}
|
2012-01-26 01:18:02 +01:00
|
|
|
if (ModeManager::currentMode() == m_mode)
|
2009-08-06 15:47:31 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Find out what to show
|
2010-07-08 16:51:36 +02:00
|
|
|
QMap<QString, QUrl> links;
|
2014-06-04 13:41:32 +02:00
|
|
|
QString idFromContext;
|
2012-01-24 15:36:40 +01:00
|
|
|
if (IContext *context = Core::ICore::currentContextObject()) {
|
2014-06-04 13:41:32 +02:00
|
|
|
idFromContext = context->contextHelpId();
|
|
|
|
|
links = HelpManager::linksForIdentifier(idFromContext);
|
2014-06-03 17:17:08 +02:00
|
|
|
// Maybe the id is already an URL
|
2014-06-04 13:41:32 +02:00
|
|
|
if (links.isEmpty() && LocalHelpManager::isValidUrl(idFromContext))
|
|
|
|
|
links.insert(idFromContext, idFromContext);
|
2009-08-06 15:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:33:13 +01:00
|
|
|
if (HelpViewer* viewer = viewerForContextMode()) {
|
2014-06-04 13:41:32 +02:00
|
|
|
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
|
|
|
|
if (!source.isValid()) {
|
2009-06-02 17:22:14 +02:00
|
|
|
// No link found or no context object
|
2011-01-11 16:10:22 +01:00
|
|
|
viewer->setSource(QUrl(Help::Constants::AboutBlank));
|
2009-06-02 17:22:14 +02:00
|
|
|
viewer->setHtml(tr("<html><head><title>No Documentation</title>"
|
|
|
|
|
"</head><body><br/><center><b>%1</b><br/>No documentation "
|
2014-06-04 13:41:32 +02:00
|
|
|
"available.</center></body></html>").arg(idFromContext));
|
2009-06-02 17:22:14 +02:00
|
|
|
} else {
|
2010-07-08 16:51:36 +02:00
|
|
|
const QUrl &oldSource = viewer->source();
|
|
|
|
|
if (source != oldSource) {
|
|
|
|
|
viewer->stop();
|
2014-06-04 13:41:32 +02:00
|
|
|
viewer->setSource(source); // triggers loadFinished which triggers id highlighting
|
2010-08-23 14:30:29 +02:00
|
|
|
} else {
|
2014-05-02 16:54:28 +02:00
|
|
|
viewer->scrollToAnchor(source.fragment());
|
2010-07-08 16:51:36 +02:00
|
|
|
}
|
2010-09-23 17:08:28 +02:00
|
|
|
viewer->setFocus();
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
Utils::StyledBar *HelpPlugin::createWidgetToolBar()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_filterComboBox = new QComboBox;
|
2010-10-05 14:18:18 +02:00
|
|
|
m_filterComboBox->setMinimumContentsLength(15);
|
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();
|
2012-02-17 14:00:45 +01:00
|
|
|
m_closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT)));
|
2010-09-17 11:08:52 +02:00
|
|
|
m_closeButton->setToolTip(tr("Close current page"));
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(m_closeButton, SIGNAL(clicked()), &OpenPagesManager::instance(),
|
|
|
|
|
SLOT(closeCurrentPage()));
|
|
|
|
|
connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this,
|
|
|
|
|
SLOT(updateCloseButton()));
|
2010-10-05 14:18:18 +02:00
|
|
|
|
|
|
|
|
Utils::StyledBar *toolBar = new Utils::StyledBar;
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->addWidget(OpenPagesManager::instance().openPagesComboBox(), 10);
|
|
|
|
|
layout->addSpacing(5);
|
|
|
|
|
layout->addWidget(new QLabel(tr("Filtered by:")));
|
|
|
|
|
layout->addWidget(m_filterComboBox);
|
|
|
|
|
layout->addStretch();
|
|
|
|
|
layout->addWidget(m_closeButton);
|
2010-08-25 15:50:22 +02:00
|
|
|
|
|
|
|
|
return toolBar;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
Utils::StyledBar *HelpPlugin::createIconToolBar(bool external)
|
2010-08-25 15:50:22 +02:00
|
|
|
{
|
2010-10-05 14:18:18 +02:00
|
|
|
Utils::StyledBar *toolBar = new Utils::StyledBar;
|
|
|
|
|
toolBar->setVisible(false);
|
2010-08-25 15:50:22 +02:00
|
|
|
|
|
|
|
|
QAction *home, *back, *next, *bookmark;
|
|
|
|
|
if (external) {
|
|
|
|
|
home = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")),
|
|
|
|
|
tr("Home"), toolBar);
|
|
|
|
|
connect(home, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
|
|
|
|
|
|
|
|
|
|
back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
|
|
|
|
tr("Previous Page"), toolBar);
|
|
|
|
|
back->setEnabled(m_centralWidget->isBackwardAvailable());
|
|
|
|
|
connect(back, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), back,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
|
|
next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
|
|
|
|
|
tr("Next Page"), toolBar);
|
|
|
|
|
next->setEnabled(m_centralWidget->isForwardAvailable());
|
|
|
|
|
connect(next, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
|
|
|
|
|
connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), next,
|
|
|
|
|
SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
|
|
bookmark = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
|
|
|
|
|
tr("Add Bookmark"), toolBar);
|
|
|
|
|
connect(bookmark, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
|
|
|
|
} else {
|
2013-09-03 11:42:35 +02:00
|
|
|
home = Core::ActionManager::command("Help.Home")->action();
|
|
|
|
|
back = Core::ActionManager::command("Help.Previous")->action();
|
|
|
|
|
next = Core::ActionManager::command("Help.Next")->action();
|
|
|
|
|
bookmark = Core::ActionManager::command("Help.AddBookmark")->action();
|
2010-08-25 15:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupNavigationMenus(back, next, toolBar);
|
|
|
|
|
|
2010-10-05 14:18:18 +02:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->addWidget(toolButton(home));
|
|
|
|
|
layout->addWidget(toolButton(back));
|
|
|
|
|
layout->addWidget(toolButton(next));
|
|
|
|
|
layout->addWidget(new Utils::StyledSeparator(toolBar));
|
|
|
|
|
layout->addWidget(toolButton(bookmark));
|
|
|
|
|
layout->addWidget(new Utils::StyledSeparator(toolBar));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-25 14:19:03 +02:00
|
|
|
return toolBar;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2014-06-04 13:41:32 +02:00
|
|
|
void HelpPlugin::highlightSearchTermsInContextHelp()
|
2010-07-08 16:51:36 +02:00
|
|
|
{
|
2014-06-04 13:41:32 +02:00
|
|
|
if (m_contextHelpHighlightId.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
HelpViewer* viewer = viewerForContextMode();
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->highlightId(m_contextHelpHighlightId);
|
|
|
|
|
m_contextHelpHighlightId.clear();
|
2010-07-08 16:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
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();
|
2013-08-29 19:00:34 +02:00
|
|
|
if (!HelpManager::findFile(url).isValid()) {
|
2013-01-29 15:29:55 +01:00
|
|
|
if (address.startsWith(QLatin1String("qthelp://org.qt-project."))
|
|
|
|
|
|| address.startsWith(QLatin1String("qthelp://com.nokia."))
|
2013-01-11 09:03:02 +01:00
|
|
|
|| address.startsWith(QLatin1String("qthelp://com.trolltech."))) {
|
2010-04-28 15:04:39 +02:00
|
|
|
// local help not installed, resort to external web help
|
2014-02-10 17:22:26 +01:00
|
|
|
QString urlPrefix = QLatin1String("http://qt-project.org/doc/");
|
2013-01-29 15:29:55 +01:00
|
|
|
if (url.authority() == QLatin1String("org.qt-project.qtcreator"))
|
2010-05-31 12:07:08 +02:00
|
|
|
urlPrefix.append(QString::fromLatin1("qtcreator"));
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2010-04-28 15:04:39 +02:00
|
|
|
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 {
|
2010-07-23 11:58:23 +02:00
|
|
|
switchToHelpMode(newUrl);
|
2009-05-11 16:42:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-25 11:40:44 +02:00
|
|
|
void HelpPlugin::slotAboutToShowBackMenu()
|
|
|
|
|
{
|
|
|
|
|
m_backMenu->clear();
|
2014-05-02 16:54:28 +02:00
|
|
|
if (HelpViewer *viewer = m_centralWidget->currentHelpViewer())
|
|
|
|
|
viewer->addBackHistoryItems(m_backMenu);
|
2010-08-25 11:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::slotAboutToShowNextMenu()
|
|
|
|
|
{
|
|
|
|
|
m_nextMenu->clear();
|
2014-05-02 16:54:28 +02:00
|
|
|
if (HelpViewer *viewer = m_centralWidget->currentHelpViewer())
|
|
|
|
|
viewer->addForwardHistoryItems(m_nextMenu);
|
2010-08-25 11:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
void HelpPlugin::slotOpenSupportPage()
|
|
|
|
|
{
|
2013-01-29 15:29:55 +01:00
|
|
|
switchToHelpMode(QUrl(QLatin1String("qthelp://org.qt-project.qtcreator/doc/technical-support.html")));
|
2010-11-11 16:49:17 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-26 18:38:27 +02:00
|
|
|
void HelpPlugin::slotReportBug()
|
|
|
|
|
{
|
2012-11-26 20:56:29 +02:00
|
|
|
QDesktopServices::openUrl(QUrl(QLatin1String("https://bugreports.qt-project.org")));
|
2011-07-26 18:38:27 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-11 14:41:40 +02:00
|
|
|
void HelpPlugin::onSideBarVisibilityChanged()
|
|
|
|
|
{
|
|
|
|
|
m_isSidebarVisible = m_sideBar->isVisible();
|
|
|
|
|
m_toggleSideBarAction->setToolTip(m_isSidebarVisible ? tr("Hide Sidebar") : tr("Show Sidebar"));
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-25 16:18:52 +02:00
|
|
|
void HelpPlugin::doSetupIfNeeded()
|
2010-07-23 12:44:22 +02:00
|
|
|
{
|
|
|
|
|
m_helpManager->setupGuiHelpEngine();
|
|
|
|
|
if (m_firstModeChange) {
|
|
|
|
|
qApp->processEvents();
|
|
|
|
|
setupUi();
|
|
|
|
|
resetFilter();
|
|
|
|
|
m_firstModeChange = false;
|
|
|
|
|
OpenPagesManager::instance().setupInitialPages();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HelpPlugin::contextHelpOption() const
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2012-11-26 20:56:29 +02:00
|
|
|
const QString key = QLatin1String(Help::Constants::ID_MODE_HELP) + QLatin1String("/ContextHelpOption");
|
2010-07-23 16:36:08 +02:00
|
|
|
if (settings->contains(key))
|
|
|
|
|
return settings->value(key, Help::Constants::SideBySideIfPossible).toInt();
|
|
|
|
|
|
2010-07-23 12:44:22 +02:00
|
|
|
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
|
|
|
|
return engine.customValue(QLatin1String("ContextHelpOption"),
|
|
|
|
|
Help::Constants::SideBySideIfPossible).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-04 15:34:25 +02:00
|
|
|
void HelpPlugin::connectExternalHelpWindow()
|
|
|
|
|
{
|
2010-08-05 16:16:53 +02:00
|
|
|
if (m_connectWindow) {
|
|
|
|
|
m_connectWindow = false;
|
|
|
|
|
connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
|
|
|
|
|
m_externalWindow, SLOT(close()));
|
|
|
|
|
connect(m_externalWindow, SIGNAL(activateIndex()), this,
|
|
|
|
|
SLOT(activateIndex()));
|
|
|
|
|
connect(m_externalWindow, SIGNAL(activateContents()), this,
|
|
|
|
|
SLOT(activateContents()));
|
|
|
|
|
connect(m_externalWindow, SIGNAL(activateSearch()), this,
|
|
|
|
|
SLOT(activateSearch()));
|
|
|
|
|
connect(m_externalWindow, SIGNAL(activateBookmarks()), this,
|
|
|
|
|
SLOT(activateBookmarks()));
|
|
|
|
|
connect(m_externalWindow, SIGNAL(activateOpenPages()), this,
|
|
|
|
|
SLOT(activateOpenPages()));
|
2010-08-06 14:40:44 +02:00
|
|
|
connect(m_externalWindow, SIGNAL(addBookmark()), this,
|
|
|
|
|
SLOT(addBookmark()));
|
2010-08-05 16:16:53 +02:00
|
|
|
connect(m_externalWindow, SIGNAL(showHideSidebar()), this,
|
|
|
|
|
SLOT(showHideSidebar()));
|
|
|
|
|
}
|
2010-08-04 15:34:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-25 11:40:44 +02:00
|
|
|
void HelpPlugin::setupNavigationMenus(QAction *back, QAction *next, QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
if (!m_backMenu) {
|
|
|
|
|
m_backMenu = new QMenu(parent);
|
|
|
|
|
connect(m_backMenu, SIGNAL(aboutToShow()), this,
|
|
|
|
|
SLOT(slotAboutToShowBackMenu()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_nextMenu) {
|
|
|
|
|
m_nextMenu = new QMenu(parent);
|
|
|
|
|
connect(m_nextMenu, SIGNAL(aboutToShow()), this,
|
|
|
|
|
SLOT(slotAboutToShowNextMenu()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
back->setMenu(m_backMenu);
|
|
|
|
|
next->setMenu(m_nextMenu);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_EXPORT_PLUGIN(HelpPlugin)
|