2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company 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
|
|
|
|
2015-04-02 10:25:46 +02:00
|
|
|
#include "bookmarkmanager.h"
|
2009-06-25 17:16:16 +02:00
|
|
|
#include "centralwidget.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"
|
|
|
|
|
#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>
|
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>
|
Implement theming for QtCreator
Adds a 'Theme' tab to the environment settings and a '-theme' command
line option.
A theme is a combination of colors, gradients, flags and style
information.
There are two themes:
- 'default': preserves the current default look
- 'dark': uses a more flat for many widgets, dark color theme
for everything
This does not use a stylesheet (too limited), but rather sets
the palette via C++ and modifies drawing behavior.
Overall, the look is more flat (removed some gradients and bevels).
Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE
Desktop (Oxygen base style).
For a screenshot, see
https://gist.github.com/thorbenk/5ab06bea726de0aa7473
Changes:
- Introduce class Theme, defining the interface how to access theme
specific settings. The class reads a .creatortheme file (INI file, via
QSettings)
- Define named colors in the [Palette] section
(see dark.creatortheme for example usage)
- Use either named colors of AARRGGBB (hex) in the [Colors]
section
- A file ending with .creatortheme may be supplied
to the '-theme' command line option
- A global Theme instance can be accessed via creatorTheme()
- Query colors, gradients, icons and flags from the theme
were possible (TODO: use this in more places...)
- There are very many color roles. It seems better to me
to describe the role clearly, and then to consolidate later
in the actual theme by assigning the same color.
For example, one can set the text color of the output pane button
individualy.
- Many elements are also drawn differently.
For the dark theme, I wanted to have a flatter look.
- Introduce Theme::WidgetStyle enum, for now {Original, Flat}.
- The theme specifies which kind of widget style it wants.
- The drawing code queries the theme's style flag and
switches between the original, gradient based look and
the new, flat look.
- Create some custom icons which look better on dark background
(wip, currently folder/file icons)
- Let ManhattanStyle draw some elements for non-panelwidgets, too
(open/close arrows in QTreeView, custom folder/file icons)
- For the welcomescreen, pass the WelcomeTheme class.
WelcomeTheme exposes theme colors as Q_PROPERTY accessible from
.qml
- Themes can be modified via the 'Themes' tab in the environment
settings.
TODO:
* Unify image handling
* Avoid style name references
* Fix gradients
Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
|
|
|
#include <utils/theme/theme.h>
|
2015-08-07 17:21:38 +02:00
|
|
|
#include <utils/tooltip/tooltip.h>
|
2009-07-17 15:04:14 +02:00
|
|
|
|
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
|
|
|
|
2014-12-18 12:21:53 +01:00
|
|
|
#include <functional>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Help::Internal;
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
|
2015-08-07 17:21:38 +02:00
|
|
|
static const char kToolTipHelpContext[] = "Help.ToolTip";
|
2014-06-18 17:42:01 +02:00
|
|
|
|
2011-09-02 17:15:18 +02:00
|
|
|
using namespace Core;
|
Implement theming for QtCreator
Adds a 'Theme' tab to the environment settings and a '-theme' command
line option.
A theme is a combination of colors, gradients, flags and style
information.
There are two themes:
- 'default': preserves the current default look
- 'dark': uses a more flat for many widgets, dark color theme
for everything
This does not use a stylesheet (too limited), but rather sets
the palette via C++ and modifies drawing behavior.
Overall, the look is more flat (removed some gradients and bevels).
Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE
Desktop (Oxygen base style).
For a screenshot, see
https://gist.github.com/thorbenk/5ab06bea726de0aa7473
Changes:
- Introduce class Theme, defining the interface how to access theme
specific settings. The class reads a .creatortheme file (INI file, via
QSettings)
- Define named colors in the [Palette] section
(see dark.creatortheme for example usage)
- Use either named colors of AARRGGBB (hex) in the [Colors]
section
- A file ending with .creatortheme may be supplied
to the '-theme' command line option
- A global Theme instance can be accessed via creatorTheme()
- Query colors, gradients, icons and flags from the theme
were possible (TODO: use this in more places...)
- There are very many color roles. It seems better to me
to describe the role clearly, and then to consolidate later
in the actual theme by assigning the same color.
For example, one can set the text color of the output pane button
individualy.
- Many elements are also drawn differently.
For the dark theme, I wanted to have a flatter look.
- Introduce Theme::WidgetStyle enum, for now {Original, Flat}.
- The theme specifies which kind of widget style it wants.
- The drawing code queries the theme's style flag and
switches between the original, gradient based look and
the new, flat look.
- Create some custom icons which look better on dark background
(wip, currently folder/file icons)
- Let ManhattanStyle draw some elements for non-panelwidgets, too
(open/close arrows in QTreeView, custom folder/file icons)
- For the welcomescreen, pass the WelcomeTheme class.
WelcomeTheme exposes theme colors as Q_PROPERTY accessible from
.qml
- Themes can be modified via the 'Themes' tab in the environment
settings.
TODO:
* Unify image handling
* Avoid style name references
* Fix gradients
Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
|
|
|
using namespace Utils;
|
2011-09-02 17:15: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),
|
2014-10-01 17:52:57 +02:00
|
|
|
m_setupNeeded(true),
|
2012-05-15 15:06:39 +02:00
|
|
|
m_helpManager(0),
|
2014-10-08 15:35:59 +02:00
|
|
|
m_openPagesManager(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpPlugin::~HelpPlugin()
|
|
|
|
|
{
|
2012-05-15 15:06:39 +02:00
|
|
|
delete m_openPagesManager;
|
|
|
|
|
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 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());
|
2015-04-02 16:49:04 +02:00
|
|
|
addAutoReleasedObject(new GeneralSettingsPage());
|
2014-03-18 22:50:44 +02:00
|
|
|
addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler);
|
2009-06-25 17:16:16 +02:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
m_centralWidget = new CentralWidget(modecontext);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
|
|
|
|
SLOT(updateSideBarSource(QUrl)));
|
|
|
|
|
connect(m_centralWidget, &CentralWidget::closeButtonClicked,
|
|
|
|
|
&OpenPagesManager::instance(), &OpenPagesManager::closeCurrentPage);
|
|
|
|
|
|
2015-04-02 16:49:04 +02:00
|
|
|
connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged,
|
|
|
|
|
m_centralWidget, &CentralWidget::updateCloseButton);
|
2014-06-20 17:24:18 +02:00
|
|
|
connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl,Core::HelpManager::HelpViewerLocation)),
|
|
|
|
|
this, SLOT(handleHelpRequest(QUrl,Core::HelpManager::HelpViewerLocation)));
|
2014-03-18 22:50:44 +02:00
|
|
|
connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this,
|
2014-10-23 14:49:57 +02:00
|
|
|
SLOT(showLinkInHelpMode(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()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-08-07 17:21:38 +02:00
|
|
|
connect(ToolTip::instance(), &ToolTip::shown, ICore::instance(), []() {
|
|
|
|
|
ICore::addAdditionalContext(Context(kToolTipHelpContext), ICore::ContextPriority::High);
|
|
|
|
|
});
|
|
|
|
|
connect(ToolTip::instance(), &ToolTip::hidden,ICore::instance(), []() {
|
|
|
|
|
ICore::removeAdditionalContext(Context(kToolTipHelpContext));
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-23 19:11:05 +02:00
|
|
|
Command *cmd;
|
2014-09-25 16:29:56 +02:00
|
|
|
QAction *action;
|
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")),
|
2014-10-01 17:52:57 +02:00
|
|
|
tr(Constants::SB_CONTENTS), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.ContentsMenu");
|
2013-08-29 19:00:34 +02:00
|
|
|
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()));
|
|
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
action = new QAction(tr(Constants::SB_INDEX), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.IndexMenu");
|
2013-08-29 19:00:34 +02:00
|
|
|
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);
|
2015-08-07 17:21:38 +02:00
|
|
|
cmd = ActionManager::registerAction(action, Help::Constants::CONTEXT_HELP,
|
|
|
|
|
Context(kToolTipHelpContext, Core::Constants::C_GLOBAL));
|
2013-08-29 19:00:34 +02:00
|
|
|
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));
|
2014-07-01 09:50:10 +02:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(showContextHelp()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
action = new QAction(tr("Technical Support"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.TechSupport");
|
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);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.ReportBug");
|
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()));
|
|
|
|
|
|
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()));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 14:49:57 +02:00
|
|
|
auto helpIndexFilter = new HelpIndexFilter();
|
2010-03-23 17:54:38 +01:00
|
|
|
addAutoReleasedObject(helpIndexFilter);
|
2014-10-23 14:49:57 +02:00
|
|
|
connect(helpIndexFilter, &HelpIndexFilter::linkActivated,
|
|
|
|
|
this, &HelpPlugin::showLinkInHelpMode);
|
|
|
|
|
connect(helpIndexFilter, &HelpIndexFilter::linksActivated,
|
|
|
|
|
this, &HelpPlugin::showLinksInHelpMode);
|
2010-03-23 17:54:38 +01:00
|
|
|
|
2010-07-16 11:15:54 +02:00
|
|
|
RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter();
|
|
|
|
|
addAutoReleasedObject(remoteHelpFilter);
|
|
|
|
|
connect(remoteHelpFilter, SIGNAL(linkActivated(QUrl)), this,
|
2014-10-23 14:49:57 +02:00
|
|
|
SLOT(showLinkInHelpMode(QUrl)));
|
2010-07-16 11:15:54 +02:00
|
|
|
|
2015-05-18 11:44:22 +02:00
|
|
|
QDesktopServices::setUrlHandler(QLatin1String("qthelp"), HelpManager::instance(), "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-12-06 14:12:38 +01:00
|
|
|
m_mode = new HelpMode;
|
2014-10-13 19:40:39 +02:00
|
|
|
m_mode->setWidget(m_centralWidget);
|
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
|
|
|
{
|
2014-10-13 19:40:39 +02:00
|
|
|
if (m_externalWindow)
|
|
|
|
|
delete m_externalWindow.data();
|
|
|
|
|
if (m_centralWidget)
|
|
|
|
|
delete m_centralWidget;
|
|
|
|
|
if (m_rightPaneSideBarWidget)
|
|
|
|
|
delete m_rightPaneSideBarWidget;
|
2010-07-13 13:36:47 +02:00
|
|
|
return SynchronousShutdown;
|
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);
|
|
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
LocalHelpManager::updateFilterModel();
|
|
|
|
|
connect(engine, &QHelpEngineCore::setupFinished,
|
|
|
|
|
LocalHelpManager::instance(), &LocalHelpManager::updateFilterModel);
|
2010-03-16 15:48:09 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
void HelpPlugin::saveExternalWindowSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-06-18 17:42:01 +02:00
|
|
|
if (!m_externalWindow)
|
2010-03-16 15:21:06 +01:00
|
|
|
return;
|
2014-06-18 17:42:01 +02:00
|
|
|
m_externalWindowState = m_externalWindow->geometry();
|
2015-02-03 23:56:02 +02:00
|
|
|
QSettings *settings = ICore::settings();
|
2014-06-18 17:42:01 +02:00
|
|
|
settings->setValue(QLatin1String(kExternalWindowStateKey),
|
|
|
|
|
qVariantFromValue(m_externalWindowState));
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
HelpWidget *HelpPlugin::createHelpWidget(const Context &context, HelpWidget::WidgetStyle style)
|
|
|
|
|
{
|
|
|
|
|
HelpWidget *widget = new HelpWidget(context, style);
|
2010-11-16 14:16:48 +01:00
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
connect(widget->currentViewer(), SIGNAL(loadFinished()),
|
2014-06-04 13:41:32 +02:00
|
|
|
this, SLOT(highlightSearchTermsInContextHelp()));
|
2014-06-18 17:42:01 +02:00
|
|
|
connect(widget, SIGNAL(openHelpMode(QUrl)),
|
2014-10-23 14:49:57 +02:00
|
|
|
this, SLOT(showLinkInHelpMode(QUrl)));
|
2014-06-18 17:42:01 +02:00
|
|
|
connect(widget, SIGNAL(closeButtonClicked()),
|
2014-06-17 18:14:37 +02:00
|
|
|
this, SLOT(slotHideRightPane()));
|
2014-06-18 17:42:01 +02:00
|
|
|
connect(widget, SIGNAL(aboutToClose()),
|
|
|
|
|
this, SLOT(saveExternalWindowSettings()));
|
2014-06-04 13:41:32 +02:00
|
|
|
|
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
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setupGuiHelpEngine();
|
2014-06-18 17:42:01 +02:00
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::createRightPaneContextViewer()
|
|
|
|
|
{
|
|
|
|
|
if (m_rightPaneSideBarWidget)
|
|
|
|
|
return;
|
2015-02-03 23:56:02 +02:00
|
|
|
m_rightPaneSideBarWidget = createHelpWidget(Context(Constants::C_HELP_SIDEBAR),
|
2014-06-18 17:42:01 +02:00
|
|
|
HelpWidget::SideBarWidget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpViewer *HelpPlugin::externalHelpViewer()
|
|
|
|
|
{
|
|
|
|
|
if (m_externalWindow)
|
|
|
|
|
return m_externalWindow->currentViewer();
|
2014-10-01 17:52:57 +02:00
|
|
|
doSetupIfNeeded();
|
2015-02-03 23:56:02 +02:00
|
|
|
m_externalWindow = createHelpWidget(Context(Constants::C_HELP_EXTERNAL),
|
2014-06-18 17:42:01 +02:00
|
|
|
HelpWidget::ExternalWindow);
|
|
|
|
|
if (m_externalWindowState.isNull()) {
|
2015-02-03 23:56:02 +02:00
|
|
|
QSettings *settings = ICore::settings();
|
2014-06-18 17:42:01 +02:00
|
|
|
m_externalWindowState = settings->value(QLatin1String(kExternalWindowStateKey)).toRect();
|
|
|
|
|
}
|
2014-10-17 16:29:56 +02:00
|
|
|
if (m_externalWindowState.isNull())
|
|
|
|
|
m_externalWindow->resize(650, 700);
|
|
|
|
|
else
|
2014-06-18 17:42:01 +02:00
|
|
|
m_externalWindow->setGeometry(m_externalWindowState);
|
|
|
|
|
m_externalWindow->show();
|
2014-07-09 17:06:28 +02:00
|
|
|
m_externalWindow->setFocus();
|
2014-06-18 17:42:01 +02:00
|
|
|
return m_externalWindow->currentViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-02 16:54:28 +02:00
|
|
|
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|
|
|
|
{
|
2014-12-18 12:21:53 +01:00
|
|
|
// check for backends
|
|
|
|
|
typedef std::function<HelpViewer *()> ViewerFactory;
|
|
|
|
|
QHash<QString, ViewerFactory> factories; // id -> factory
|
2014-05-14 13:15:01 +02:00
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER
|
2014-12-18 12:21:53 +01:00
|
|
|
factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
|
2014-05-14 13:15:01 +02:00
|
|
|
#endif
|
2014-05-02 16:54:28 +02:00
|
|
|
#ifndef QT_NO_WEBKIT
|
2014-12-18 12:21:53 +01:00
|
|
|
factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
|
2014-05-02 16:54:28 +02:00
|
|
|
#endif
|
2014-12-18 12:21:53 +01:00
|
|
|
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
|
|
|
|
|
|
|
|
|
|
ViewerFactory factory;
|
2015-05-07 12:10:18 +02:00
|
|
|
// TODO: Visual Studio < 2013 has a bug in std::function's operator bool, which in this case
|
|
|
|
|
// leads to succeeding boolean checks on factory which should not succeed.
|
|
|
|
|
// So we may not check against "if (!factory)"
|
|
|
|
|
bool factoryFound = false;
|
|
|
|
|
|
2014-12-18 12:21:53 +01:00
|
|
|
// check requested backend
|
|
|
|
|
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
|
|
|
|
|
if (!backend.isEmpty()) {
|
2015-05-07 12:10:18 +02:00
|
|
|
if (!factories.contains(backend)) {
|
2014-12-18 12:21:53 +01:00
|
|
|
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
|
2015-05-07 12:10:18 +02:00
|
|
|
} else {
|
|
|
|
|
factory = factories.value(backend);
|
|
|
|
|
factoryFound = true;
|
|
|
|
|
}
|
2014-05-14 13:15:01 +02:00
|
|
|
}
|
2014-12-18 12:21:53 +01:00
|
|
|
// default setting
|
|
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
|
2015-05-07 12:10:18 +02:00
|
|
|
if (!factoryFound && factories.contains(QLatin1String("native"))) {
|
2014-12-18 12:21:53 +01:00
|
|
|
factory = factories.value(QLatin1String("native"));
|
2015-05-07 12:10:18 +02:00
|
|
|
factoryFound = true;
|
|
|
|
|
}
|
2014-12-18 12:21:53 +01:00
|
|
|
#endif
|
2015-05-07 12:10:18 +02:00
|
|
|
if (!factoryFound && factories.contains(QLatin1String("qtwebkit"))) {
|
2014-12-18 12:21:53 +01:00
|
|
|
factory = factories.value(QLatin1String("qtwebkit"));
|
2015-05-07 12:10:18 +02:00
|
|
|
factoryFound = true;
|
|
|
|
|
}
|
|
|
|
|
if (!factoryFound && factories.contains(QLatin1String("textbrowser"))) {
|
2014-12-18 12:21:53 +01:00
|
|
|
factory = factories.value(QLatin1String("textbrowser"));
|
2015-05-07 12:10:18 +02:00
|
|
|
factoryFound = true;
|
|
|
|
|
}
|
|
|
|
|
QTC_ASSERT(factoryFound, return 0);
|
2014-12-18 12:21:53 +01:00
|
|
|
HelpViewer *viewer = factory();
|
2014-05-14 13:15:01 +02:00
|
|
|
|
|
|
|
|
// initialize font
|
2015-04-02 16:49:04 +02:00
|
|
|
viewer->setViewerFont(LocalHelpManager::fallbackFont());
|
|
|
|
|
connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
|
|
|
|
|
viewer, &HelpViewer::setViewerFont);
|
2014-06-17 16:46:48 +02:00
|
|
|
|
2014-12-18 11:36:49 +01:00
|
|
|
// initialize zoom
|
|
|
|
|
viewer->setScale(zoom);
|
|
|
|
|
|
2014-06-17 16:46:48 +02:00
|
|
|
// add find support
|
|
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
|
|
|
|
|
agg->add(viewer);
|
|
|
|
|
agg->add(new HelpViewerFindSupport(viewer));
|
|
|
|
|
|
2014-05-14 13:15:01 +02:00
|
|
|
return viewer;
|
2014-05-02 16:54:28 +02:00
|
|
|
}
|
|
|
|
|
|
2009-01-28 13:57:42 +01:00
|
|
|
void HelpPlugin::activateHelpMode()
|
|
|
|
|
{
|
2014-06-18 17:42:01 +02:00
|
|
|
ModeManager::activateMode(Id(Constants::ID_MODE_HELP));
|
2009-01-28 13:57:42 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-23 14:49:57 +02:00
|
|
|
void HelpPlugin::showLinkInHelpMode(const QUrl &source)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2015-02-03 23:56:02 +02:00
|
|
|
ICore::raiseWindow(m_mode->widget());
|
2008-12-02 12:01:29 +01:00
|
|
|
m_centralWidget->setSource(source);
|
|
|
|
|
m_centralWidget->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 14:49:57 +02:00
|
|
|
void HelpPlugin::showLinksInHelpMode(const QMap<QString, QUrl> &links, const QString &key)
|
|
|
|
|
{
|
|
|
|
|
activateHelpMode();
|
2015-02-03 23:56:02 +02:00
|
|
|
ICore::raiseWindow(m_mode->widget());
|
2014-10-23 14:49:57 +02:00
|
|
|
m_centralWidget->showTopicChooser(links, key);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void HelpPlugin::slotHideRightPane()
|
|
|
|
|
{
|
2013-08-29 19:00:34 +02:00
|
|
|
RightPaneWidget::instance()->setShown(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
void HelpPlugin::modeChanged(IMode *mode, IMode *old)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-06-18 17:42:01 +02:00
|
|
|
Q_UNUSED(old)
|
2010-07-21 14:54:02 +02:00
|
|
|
if (mode == m_mode) {
|
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()
|
|
|
|
|
{
|
2014-09-25 16:29:56 +02:00
|
|
|
if (HelpViewer *viewer = m_centralWidget->currentViewer()) {
|
2010-03-30 17:44:28 +02:00
|
|
|
const QUrl &url = viewer->source();
|
|
|
|
|
if (url.isValid())
|
|
|
|
|
updateSideBarSource(url);
|
|
|
|
|
}
|
2009-06-02 16:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
|
|
|
|
{
|
2014-10-20 17:22:46 +02:00
|
|
|
if (m_rightPaneSideBarWidget) {
|
|
|
|
|
// This is called when setSource on the central widget is called.
|
|
|
|
|
// Avoid nested setSource calls (even of different help viewers) by scheduling the
|
|
|
|
|
// sidebar viewer update on the event loop (QTCREATORBUG-12742)
|
|
|
|
|
QMetaObject::invokeMethod(m_rightPaneSideBarWidget->currentViewer(), "setSource",
|
|
|
|
|
Qt::QueuedConnection, Q_ARG(QUrl, newUrl));
|
|
|
|
|
}
|
2009-06-02 16:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
void HelpPlugin::setupHelpEngineIfNeeded()
|
|
|
|
|
{
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setEngineNeedsUpdate();
|
2013-08-29 19:00:34 +02:00
|
|
|
if (ModeManager::currentMode() == m_mode
|
2015-04-02 16:49:04 +02:00
|
|
|
|| LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setupGuiHelpEngine();
|
2010-03-23 18:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-20 17:24:18 +02:00
|
|
|
bool HelpPlugin::canShowHelpSideBySide() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
2014-06-20 17:24:18 +02:00
|
|
|
if (!placeHolder)
|
|
|
|
|
return false;
|
|
|
|
|
if (placeHolder->isVisible())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
IEditor *editor = EditorManager::currentEditor();
|
|
|
|
|
if (!editor)
|
|
|
|
|
return true;
|
|
|
|
|
QTC_ASSERT(editor->widget(), return true);
|
|
|
|
|
if (!editor->widget()->isVisible())
|
|
|
|
|
return true;
|
|
|
|
|
if (editor->widget()->width() < 800)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location)
|
2014-06-20 17:24:18 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
HelpManager::HelpViewerLocation actualLocation = location;
|
|
|
|
|
if (location == HelpManager::SideBySideIfPossible)
|
|
|
|
|
actualLocation = canShowHelpSideBySide() ? HelpManager::SideBySideAlways
|
|
|
|
|
: HelpManager::HelpModeAlways;
|
2014-06-20 17:24:18 +02:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
if (actualLocation == HelpManager::ExternalHelpAlways)
|
2014-06-20 17:24:18 +02:00
|
|
|
return externalHelpViewer();
|
2009-07-14 13:20:26 +02:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
if (actualLocation == HelpManager::SideBySideAlways) {
|
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);
|
2014-06-17 18:14:37 +02:00
|
|
|
return m_rightPaneSideBarWidget->currentViewer();
|
2009-06-02 17:22:14 +02:00
|
|
|
}
|
2010-10-12 16:53:00 +02:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
QTC_CHECK(actualLocation == HelpManager::HelpModeAlways);
|
2014-06-20 17:24:18 +02:00
|
|
|
|
2010-10-12 16:53:00 +02:00
|
|
|
activateHelpMode(); // should trigger an createPage...
|
2014-09-25 16:29:56 +02:00
|
|
|
HelpViewer *viewer = m_centralWidget->currentViewer();
|
2010-10-12 16:53:00 +02:00
|
|
|
if (!viewer)
|
|
|
|
|
viewer = OpenPagesManager::instance().createPage();
|
2009-08-06 15:47:31 +02:00
|
|
|
return viewer;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-20 17:24:18 +02:00
|
|
|
HelpViewer *HelpPlugin::viewerForContextHelp()
|
|
|
|
|
{
|
2015-04-02 16:49:04 +02:00
|
|
|
return viewerForHelpViewerLocation(LocalHelpManager::contextHelpOption());
|
2014-06-20 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 09:50:10 +02:00
|
|
|
void HelpPlugin::showContextHelp()
|
2009-08-06 15:47:31 +02:00
|
|
|
{
|
|
|
|
|
// Find out what to show
|
2015-08-07 17:21:38 +02:00
|
|
|
QString contextHelpId = Utils::ToolTip::contextHelpId();
|
|
|
|
|
IContext *context = ICore::currentContextObject();
|
|
|
|
|
if (contextHelpId.isEmpty() && context)
|
|
|
|
|
contextHelpId = context->contextHelpId();
|
|
|
|
|
|
|
|
|
|
// get the viewer after getting the help id,
|
|
|
|
|
// because a new window might be opened and therefore focus be moved
|
|
|
|
|
HelpViewer *viewer = viewerForContextHelp();
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
|
|
|
|
|
QMap<QString, QUrl> links = HelpManager::linksForIdentifier(contextHelpId);
|
|
|
|
|
// Maybe the id is already an URL
|
|
|
|
|
if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId))
|
|
|
|
|
links.insert(contextHelpId, contextHelpId);
|
|
|
|
|
|
|
|
|
|
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
|
|
|
|
if (!source.isValid()) {
|
|
|
|
|
// No link found or no context object
|
|
|
|
|
viewer->setSource(QUrl(Help::Constants::AboutBlank));
|
|
|
|
|
viewer->setHtml(tr("<html><head><title>No Documentation</title>"
|
|
|
|
|
"</head><body><br/><center>"
|
|
|
|
|
"<font color=\"%1\"><b>%2</b></font><br/>"
|
|
|
|
|
"<font color=\"%3\">No documentation available.</font>"
|
|
|
|
|
"</center></body></html>")
|
|
|
|
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
|
|
|
|
.arg(contextHelpId)
|
|
|
|
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name()));
|
|
|
|
|
} else {
|
|
|
|
|
const QUrl &oldSource = viewer->source();
|
|
|
|
|
if (source != oldSource) {
|
|
|
|
|
viewer->stop();
|
|
|
|
|
viewer->setSource(source); // triggers loadFinished which triggers id highlighting
|
2009-06-02 17:22:14 +02:00
|
|
|
} else {
|
2015-08-07 17:21:38 +02:00
|
|
|
viewer->scrollToAnchor(source.fragment());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2015-08-07 17:21:38 +02:00
|
|
|
viewer->setFocus();
|
|
|
|
|
ICore::raiseWindow(viewer);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateIndex()
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2014-10-13 19:40:39 +02:00
|
|
|
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_INDEX));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpPlugin::activateContents()
|
|
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2014-10-13 19:40:39 +02:00
|
|
|
m_centralWidget->activateSideBarItem(QLatin1String(Constants::HELP_CONTENTS));
|
2010-06-21 13:23:43 +02: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;
|
2014-06-20 17:24:18 +02:00
|
|
|
HelpViewer *viewer = viewerForContextHelp();
|
2014-06-04 13:41:32 +02:00
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->highlightId(m_contextHelpHighlightId);
|
|
|
|
|
m_contextHelpHighlightId.clear();
|
2010-07-08 16:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
void HelpPlugin::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocation location)
|
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
|
2015-02-18 10:20:03 +01:00
|
|
|
QString urlPrefix = QLatin1String("http://doc.qt.io/");
|
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);
|
2014-06-20 17:24:18 +02:00
|
|
|
HelpViewer *viewer = viewerForHelpViewerLocation(location);
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->setSource(newUrl);
|
2015-02-03 23:56:02 +02:00
|
|
|
ICore::raiseWindow(viewer);
|
2009-05-11 16:42:51 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
void HelpPlugin::slotOpenSupportPage()
|
|
|
|
|
{
|
2014-10-23 14:49:57 +02:00
|
|
|
showLinkInHelpMode(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()
|
|
|
|
|
{
|
2014-12-15 09:31:53 +01:00
|
|
|
QDesktopServices::openUrl(QUrl(QLatin1String("https://bugreports.qt.io")));
|
2011-07-26 18:38:27 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-25 16:18:52 +02:00
|
|
|
void HelpPlugin::doSetupIfNeeded()
|
2010-07-23 12:44:22 +02:00
|
|
|
{
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setupGuiHelpEngine();
|
2014-10-01 17:52:57 +02:00
|
|
|
if (m_setupNeeded) {
|
2010-07-23 12:44:22 +02:00
|
|
|
resetFilter();
|
2014-10-01 17:52:57 +02:00
|
|
|
m_setupNeeded = false;
|
2010-07-23 12:44:22 +02:00
|
|
|
OpenPagesManager::instance().setupInitialPages();
|
2015-04-02 10:25:46 +02:00
|
|
|
LocalHelpManager::bookmarkManager().setupBookmarkModels();
|
2010-07-23 12:44:22 +02:00
|
|
|
}
|
|
|
|
|
}
|