2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
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"
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
#include "helpicons.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helpindexfilter.h"
|
2018-08-31 16:00:32 +02:00
|
|
|
#include "helpmanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#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"
|
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
|
2016-03-04 20:29:38 +03:00
|
|
|
#ifdef QTC_WEBENGINE_HELPVIEWER
|
|
|
|
|
#include "webenginehelpviewer.h"
|
|
|
|
|
#endif
|
2014-05-14 13:15:01 +02:00
|
|
|
|
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>
|
2019-01-25 15:04:50 +01:00
|
|
|
#include <coreplugin/helpitem.h>
|
2009-07-21 11:10:02 +02:00
|
|
|
#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>
|
2016-03-04 20:29:38 +03:00
|
|
|
#include <utils/algorithm.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
|
|
|
|
2016-08-31 15:39:52 +02:00
|
|
|
#include <QClipboard>
|
|
|
|
|
#include <QDialog>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QLibraryInfo>
|
2016-08-31 15:39:52 +02:00
|
|
|
#include <QPlainTextEdit>
|
2012-02-15 10:42:41 +01:00
|
|
|
#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>
|
|
|
|
|
|
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
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
namespace Help {
|
|
|
|
|
namespace Internal {
|
2016-09-09 15:37:01 +02:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
class HelpPluginPrivate : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2018-02-02 17:29:15 +01:00
|
|
|
public:
|
|
|
|
|
HelpPluginPrivate();
|
|
|
|
|
|
|
|
|
|
void modeChanged(Core::Id mode, Core::Id old);
|
|
|
|
|
|
|
|
|
|
void requestContextHelp();
|
2019-01-25 15:04:50 +01:00
|
|
|
void showContextHelp(const HelpItem &contextHelp);
|
2018-02-02 17:29:15 +01:00
|
|
|
void activateIndex();
|
|
|
|
|
void activateContents();
|
|
|
|
|
|
|
|
|
|
void saveExternalWindowSettings();
|
|
|
|
|
void showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key);
|
|
|
|
|
void slotHideRightPane();
|
|
|
|
|
|
|
|
|
|
void updateSideBarSource(const QUrl &newUrl);
|
|
|
|
|
|
|
|
|
|
void setupHelpEngineIfNeeded();
|
|
|
|
|
|
2019-01-22 15:25:27 +01:00
|
|
|
HelpViewer *showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
2018-02-02 17:29:15 +01:00
|
|
|
|
|
|
|
|
void slotSystemInformation();
|
|
|
|
|
|
|
|
|
|
void resetFilter();
|
|
|
|
|
static void activateHelpMode() { ModeManager::activateMode(Constants::ID_MODE_HELP); }
|
|
|
|
|
static bool canShowHelpSideBySide();
|
|
|
|
|
|
|
|
|
|
HelpViewer *viewerForContextHelp();
|
|
|
|
|
HelpWidget *createHelpWidget(const Core::Context &context, HelpWidget::WidgetStyle style);
|
|
|
|
|
void createRightPaneContextViewer();
|
|
|
|
|
HelpViewer *externalHelpViewer();
|
|
|
|
|
HelpViewer *helpModeHelpViewer();
|
|
|
|
|
HelpWidget *helpWidgetForWindow(QWidget *window);
|
2018-08-31 16:00:32 +02:00
|
|
|
HelpViewer *viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location);
|
2018-02-02 17:29:15 +01:00
|
|
|
|
|
|
|
|
void showInHelpViewer(const QUrl &url, HelpViewer *viewer);
|
|
|
|
|
void doSetupIfNeeded();
|
|
|
|
|
|
|
|
|
|
HelpMode m_mode;
|
|
|
|
|
CentralWidget *m_centralWidget = nullptr;
|
|
|
|
|
HelpWidget *m_rightPaneSideBarWidget = nullptr;
|
|
|
|
|
|
|
|
|
|
DocSettingsPage m_docSettingsPage;
|
|
|
|
|
FilterSettingsPage m_filterSettingsPage;
|
|
|
|
|
SearchTaskHandler m_searchTaskHandler;
|
|
|
|
|
GeneralSettingsPage m_generalSettingsPage;
|
|
|
|
|
|
|
|
|
|
bool m_setupNeeded = true;
|
2018-08-31 16:00:32 +02:00
|
|
|
LocalHelpManager m_localHelpManager;
|
2018-02-02 17:29:15 +01:00
|
|
|
OpenPagesManager m_openPagesManager;
|
|
|
|
|
|
|
|
|
|
QPointer<HelpWidget> m_externalWindow;
|
|
|
|
|
QRect m_externalWindowState;
|
|
|
|
|
|
|
|
|
|
HelpIndexFilter helpIndexFilter;
|
|
|
|
|
RemoteHelpFilter remoteHelpFilter;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static HelpPluginPrivate *dd = nullptr;
|
2018-08-31 16:00:32 +02:00
|
|
|
static HelpManager *m_helpManager = nullptr;
|
|
|
|
|
|
|
|
|
|
HelpPlugin::HelpPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_helpManager = new HelpManager;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
HelpPlugin::~HelpPlugin()
|
|
|
|
|
{
|
2018-02-02 17:29:15 +01:00
|
|
|
delete dd;
|
|
|
|
|
dd = nullptr;
|
2018-08-31 16:00:32 +02:00
|
|
|
delete m_helpManager;
|
|
|
|
|
m_helpManager = nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-22 14:53:45 +01:00
|
|
|
void HelpPlugin::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
|
|
|
|
{
|
|
|
|
|
dd->showHelpUrl(url, location);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
2018-02-02 17:29:15 +01:00
|
|
|
dd = new HelpPluginPrivate;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpPluginPrivate::HelpPluginPrivate()
|
|
|
|
|
{
|
|
|
|
|
Context modecontext(Help::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()) {
|
2018-11-11 10:08:29 +01:00
|
|
|
auto qtr = new QTranslator(this);
|
|
|
|
|
auto qhelptr = new QTranslator(this);
|
2016-07-20 10:11:35 +02:00
|
|
|
const QString &creatorTrPath = ICore::resourcePath() + "/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))
|
2017-04-24 17:01:10 +02:00
|
|
|
QCoreApplication::installTranslator(qtr);
|
2009-06-10 13:27:05 +02:00
|
|
|
if (qhelptr->load(helpTrFile, qtTrPath) || qhelptr->load(helpTrFile, creatorTrPath))
|
2017-04-24 17:01:10 +02:00
|
|
|
QCoreApplication::installTranslator(qhelptr);
|
2009-04-20 16:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-24 13:54:33 +02:00
|
|
|
m_centralWidget = new CentralWidget(Context("Help.CentralHelpWidget"));
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(m_centralWidget, &HelpWidget::sourceChanged,
|
|
|
|
|
this, &HelpPluginPrivate::updateSideBarSource);
|
2014-09-25 16:29:56 +02:00
|
|
|
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);
|
2016-06-28 23:07:19 +03:00
|
|
|
connect(HelpManager::instance(), &HelpManager::helpRequested,
|
2019-01-22 14:53:45 +01:00
|
|
|
this, &HelpPluginPrivate::showHelpUrl);
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(&m_searchTaskHandler, &SearchTaskHandler::search,
|
|
|
|
|
this, &QDesktopServices::openUrl);
|
2016-06-28 23:07:19 +03:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(&m_filterSettingsPage, &FilterSettingsPage::filtersChanged,
|
|
|
|
|
this, &HelpPluginPrivate::setupHelpEngineIfNeeded);
|
2018-08-31 16:00:32 +02:00
|
|
|
connect(Core::HelpManager::Signals::instance(),
|
|
|
|
|
&Core::HelpManager::Signals::documentationChanged,
|
|
|
|
|
this,
|
|
|
|
|
&HelpPluginPrivate::setupHelpEngineIfNeeded);
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(HelpManager::instance(), &HelpManager::collectionFileChanged,
|
|
|
|
|
this, &HelpPluginPrivate::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
|
2016-07-20 10:11:35 +02:00
|
|
|
action = new QAction(QIcon::fromTheme("help-contents"),
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpPlugin::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);
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(action, &QAction::triggered, this, &HelpPluginPrivate::activateContents);
|
2010-04-15 14:50:17 +02:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
action = new QAction(HelpPlugin::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);
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(action, &QAction::triggered, this, &HelpPluginPrivate::activateIndex);
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
action = new QAction(HelpPlugin::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));
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
cmd->setTouchBarIcon(Icons::MACOS_TOUCHBAR_HELP.icon());
|
2013-08-29 19:00:34 +02:00
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
Add macOS touch bar support
Introduce a generic Utils::TouchBar that implements a touch bar for
macOS based on QAction. Touch bars can be nested, and one is set to be
the application's top level touch bar.
Also add an ActionContainer for the touch bar. That allows us to manage
the layout of the touch bar the same way we do with menus.
Since the touch bar is an input device with very limited space, a
command in the touch bar needs to be specifically styled for the touch
bar by setting either touchBarText or touchBarIcon (or both).
Touch bars can be nested by nesting the ActionContainers. A nested touch
bar ActionContainer needs to specify an icon and/or text to show in the
touch bar button that opens that sub-bar.
Commands are only shown in the touch bar if they are valid within the
current context.
Implementation-wise we cannot use the standard NSPopoverTouchBarItem for
nesting touch bar levels. We cannot hide items in the touch bar, because
hidden items still take up space in the touch bar. So we need to rebuild
the touch bar regularly. Since the items we show are very dynamic, every
time the items in the toplevel bar change because of a context change,
any opened sub-level touch bar closes. That is why we maintain a stack of
touch bar levels ourselves, replacing the main touch bar with the current
level, and managing opening and closing the levels manually.
This patch adds buttons for Help, Bookmarks, Header/Source, Follow
(Symbol), Decl/Def, and a sub-bar for the debugger actions.
Fixes: QTCREATORBUG-21263
Change-Id: Ib63e610f21a993f1d324fe23c83a7f2224f434ac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
2018-10-05 13:52:57 +02:00
|
|
|
ActionManager::actionContainer(Core::Constants::TOUCH_BAR)
|
|
|
|
|
->addAction(cmd, Core::Constants::G_TOUCHBAR_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(action, &QAction::triggered, this, &HelpPluginPrivate::requestContextHelp);
|
2018-03-22 09:52:49 +01:00
|
|
|
ActionContainer *textEditorContextMenu = ActionManager::actionContainer(
|
|
|
|
|
TextEditor::Constants::M_STANDARDCONTEXTMENU);
|
|
|
|
|
if (textEditorContextMenu) {
|
|
|
|
|
textEditorContextMenu->insertGroup(TextEditor::Constants::G_BOM,
|
|
|
|
|
Core::Constants::G_HELP);
|
|
|
|
|
textEditorContextMenu->addSeparator(Core::Constants::G_HELP);
|
|
|
|
|
textEditorContextMenu->addAction(cmd, Core::Constants::G_HELP);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-10-19 14:08:14 +02:00
|
|
|
action = new QAction(HelpPlugin::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);
|
2017-07-12 14:33:18 +02:00
|
|
|
connect(action, &QAction::triggered, this, [this] {
|
2019-01-22 15:25:27 +01:00
|
|
|
showHelpUrl(QUrl("qthelp://org.qt-project.qtcreator/doc/technical-support.html"),
|
|
|
|
|
Core::HelpManager::HelpModeAlways);
|
2017-07-12 14:33:18 +02:00
|
|
|
});
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
action = new QAction(HelpPlugin::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);
|
2017-07-12 14:33:18 +02:00
|
|
|
connect(action, &QAction::triggered, this, [] {
|
|
|
|
|
QDesktopServices::openUrl(QUrl("https://bugreports.qt.io"));
|
|
|
|
|
});
|
2011-07-26 18:38:27 +02:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
action = new QAction(HelpPlugin::tr("System Information..."), this);
|
2016-08-31 15:39:52 +02:00
|
|
|
cmd = ActionManager::registerAction(action, "Help.SystemInformation");
|
|
|
|
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT);
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(action, &QAction::triggered, this, &HelpPluginPrivate::slotSystemInformation);
|
2016-08-31 15:39:52 +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);
|
2016-06-28 23:07:19 +03:00
|
|
|
connect(action, &QAction::triggered, &OpenPagesManager::instance(),
|
|
|
|
|
&OpenPagesManager::gotoPreviousPage);
|
2010-04-12 14:55:41 +02:00
|
|
|
|
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);
|
2016-06-28 23:07:19 +03:00
|
|
|
connect(action, &QAction::triggered, &OpenPagesManager::instance(),
|
|
|
|
|
&OpenPagesManager::gotoNextPage);
|
2010-04-12 14:55:41 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(&helpIndexFilter, &HelpIndexFilter::linksActivated,
|
|
|
|
|
this, &HelpPluginPrivate::showLinksInCurrentViewer);
|
2010-03-23 17:54:38 +01:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
connect(&remoteHelpFilter, &RemoteHelpFilter::linkActivated,
|
|
|
|
|
this, &QDesktopServices::openUrl);
|
2010-07-16 11:15:54 +02:00
|
|
|
|
2019-01-30 12:13:35 +01:00
|
|
|
QDesktopServices::setUrlHandler("qthelp", HelpManager::instance(), "showHelpUrl");
|
2016-04-12 14:47:15 +02:00
|
|
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
2018-02-02 17:29:15 +01:00
|
|
|
this, &HelpPluginPrivate::modeChanged);
|
2010-03-23 18:11:43 +01:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
m_mode.setWidget(m_centralWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
2018-09-19 14:39:46 +02:00
|
|
|
filesToRegister.append(Core::HelpManager::documentationPath() + "/qtcreator.qch");
|
2018-08-31 16:00:32 +02:00
|
|
|
Core::HelpManager::registerDocumentation(filesToRegister);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool HelpPlugin::delayedInitialize()
|
|
|
|
|
{
|
|
|
|
|
HelpManager::setupHelpManager();
|
|
|
|
|
return true;
|
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
|
|
|
{
|
2018-02-02 17:29:15 +01:00
|
|
|
delete dd->m_externalWindow.data();
|
|
|
|
|
|
|
|
|
|
delete dd->m_centralWidget;
|
|
|
|
|
dd->m_centralWidget = nullptr;
|
|
|
|
|
|
|
|
|
|
delete dd->m_rightPaneSideBarWidget;
|
|
|
|
|
dd->m_rightPaneSideBarWidget = nullptr;
|
|
|
|
|
|
2010-07-13 13:36:47 +02:00
|
|
|
return SynchronousShutdown;
|
2010-02-02 11:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::resetFilter()
|
2010-03-16 15:28:31 +01:00
|
|
|
{
|
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);
|
2016-07-20 10:11:35 +02:00
|
|
|
QRegExp filterRegExp("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
|
2018-02-02 17:29:15 +01:00
|
|
|
const QString filterName = HelpPlugin::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
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::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();
|
2016-07-20 10:11:35 +02:00
|
|
|
settings->setValue(kExternalWindowStateKey, qVariantFromValue(m_externalWindowState));
|
2014-06-18 17:42:01 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpWidget *HelpPluginPrivate::createHelpWidget(const Context &context, HelpWidget::WidgetStyle style)
|
2014-06-18 17:42:01 +02:00
|
|
|
{
|
2018-11-11 10:08:29 +01:00
|
|
|
auto widget = new HelpWidget(context, style);
|
2010-11-16 14:16:48 +01:00
|
|
|
|
2019-01-22 15:25:27 +01:00
|
|
|
connect(widget, &HelpWidget::openHelpMode, this, [this](const QUrl &url) {
|
|
|
|
|
showHelpUrl(url, Core::HelpManager::HelpModeAlways);
|
|
|
|
|
});
|
|
|
|
|
connect(widget, &HelpWidget::closeButtonClicked, this, &HelpPluginPrivate::slotHideRightPane);
|
2016-06-28 23:07:19 +03:00
|
|
|
connect(widget, &HelpWidget::aboutToClose,
|
2018-02-02 17:29:15 +01:00
|
|
|
this, &HelpPluginPrivate::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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::createRightPaneContextViewer()
|
2014-06-18 17:42:01 +02:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpViewer *HelpPluginPrivate::externalHelpViewer()
|
2014-06-18 17:42:01 +02:00
|
|
|
{
|
|
|
|
|
if (m_externalWindow)
|
|
|
|
|
return m_externalWindow->currentViewer();
|
2014-10-01 17:52:57 +02:00
|
|
|
doSetupIfNeeded();
|
Avoid double deletion of HelpWidget when quitting application via Dock
HelpWidgets that are created to be shown in an external window, had
two different places where they were deleted:
1) When the widget was closed (due to Qt::WA_DeleteOnClose)
2) In HelpPlugin::aboutToShutdown via manual delete call
In certain circumstances (when the WebEngine backend was used)
this caused a double delete. Specifically, after opening an external
help window, and closing the MainWindow, the application did not quit
due to QTBUG-62596.
Now if the help window were left open, and the application was quit
via the macOS Dock, this caused a crash.
When the application quits, it calls the HelpPlugin::aboutToShutdown,
which deletes the HelpWidget. This in turn destroys the WebEngine
view, which destroys the underlying QQuickWidget, which destroys
a QQuickRenderControl, which calls
QQuickRenderControlPrivate::windowDestroyed, which handles all
posted QEvent::DeferredDelete events, which in turn triggers the
deletion of the same HelpWidget due to the
Qt::WA_DeleteOnClose attribute.
The solution is to remove the Qt::WA_DeleteOnClose attribute, and only
delete the external HelpWidget on shutdown, and not on CloseEvent.
Task-number: QTBUG-63945
Task-number: QTCREATORBUG-19582
Change-Id: I5b73ff7fe52e7e1259a8aa98c97c9dbedd5e3c20
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-17 16:15:12 +01:00
|
|
|
// Deletion for this widget is taken care of in HelpPlugin::aboutToShutdown().
|
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();
|
2016-07-20 10:11:35 +02:00
|
|
|
m_externalWindowState = settings->value(kExternalWindowStateKey).toRect();
|
2014-06-18 17:42:01 +02:00
|
|
|
}
|
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();
|
|
|
|
|
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
|
2018-11-11 10:08:29 +01:00
|
|
|
using ViewerFactory = std::function<HelpViewer *()>;
|
|
|
|
|
using ViewerFactoryItem = QPair<QByteArray, ViewerFactory>; // id -> factory
|
2016-03-04 20:29:38 +03:00
|
|
|
QVector<ViewerFactoryItem> factories;
|
|
|
|
|
#ifdef QTC_WEBENGINE_HELPVIEWER
|
|
|
|
|
factories.append(qMakePair(QByteArray("qtwebengine"), []() { return new WebEngineHelpViewer(); }));
|
|
|
|
|
#endif
|
|
|
|
|
factories.append(qMakePair(QByteArray("textbrowser"), []() { return new TextBrowserHelpViewer(); }));
|
|
|
|
|
|
2014-05-14 13:15:01 +02:00
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER
|
2016-03-04 20:29:38 +03:00
|
|
|
// default setting
|
|
|
|
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
|
|
|
|
|
factories.prepend(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
|
|
|
|
|
#else
|
|
|
|
|
factories.append(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
|
2014-05-14 13:15:01 +02:00
|
|
|
#endif
|
2014-05-02 16:54:28 +02:00
|
|
|
#endif
|
2014-12-18 12:21:53 +01:00
|
|
|
|
2016-03-04 20:29:38 +03:00
|
|
|
HelpViewer *viewer = nullptr;
|
2015-05-07 12:10:18 +02:00
|
|
|
|
2014-12-18 12:21:53 +01:00
|
|
|
// check requested backend
|
2016-03-04 20:29:38 +03:00
|
|
|
const QByteArray backend = qgetenv("QTC_HELPVIEWER_BACKEND");
|
2014-12-18 12:21:53 +01:00
|
|
|
if (!backend.isEmpty()) {
|
2016-03-04 20:29:38 +03:00
|
|
|
const int pos = Utils::indexOf(factories, [backend](const ViewerFactoryItem &item) {
|
|
|
|
|
return backend == item.first;
|
|
|
|
|
});
|
|
|
|
|
if (pos == -1) {
|
|
|
|
|
qWarning("Help viewer backend \"%s\" not found, using default.", backend.constData());
|
2015-05-07 12:10:18 +02:00
|
|
|
} else {
|
2016-03-04 20:29:38 +03:00
|
|
|
viewer = factories.at(pos).second();
|
2015-05-07 12:10:18 +02:00
|
|
|
}
|
2014-05-14 13:15:01 +02:00
|
|
|
}
|
2016-03-04 20:29:38 +03:00
|
|
|
|
|
|
|
|
if (!viewer)
|
|
|
|
|
viewer = factories.first().second();
|
|
|
|
|
QTC_ASSERT(viewer, return nullptr);
|
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
|
2018-11-11 10:08:29 +01:00
|
|
|
auto agg = new Aggregation::Aggregate;
|
2014-06-17 16:46:48 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key)
|
2014-10-23 14:49:57 +02:00
|
|
|
{
|
2017-07-20 07:41:05 +02:00
|
|
|
if (links.size() < 1)
|
|
|
|
|
return;
|
|
|
|
|
HelpWidget *widget = helpWidgetForWindow(QApplication::activeWindow());
|
|
|
|
|
widget->showLinks(links, key);
|
2014-10-23 14:49:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::slotHideRightPane()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-08-29 19:00:34 +02:00
|
|
|
RightPaneWidget::instance()->setShown(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::modeChanged(Core::Id mode, Core::Id old)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-06-18 17:42:01 +02:00
|
|
|
Q_UNUSED(old)
|
2018-02-02 17:29:15 +01:00
|
|
|
if (mode == m_mode.id()) {
|
2017-04-24 17:01:10 +02:00
|
|
|
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
2010-08-25 16:18:52 +02:00
|
|
|
doSetupIfNeeded();
|
2017-04-24 17:01:10 +02:00
|
|
|
QGuiApplication::restoreOverrideCursor();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::updateSideBarSource(const QUrl &newUrl)
|
2009-06-02 16:30:56 +02:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::setupHelpEngineIfNeeded()
|
2010-03-23 18:11:43 +01:00
|
|
|
{
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setEngineNeedsUpdate();
|
2018-07-10 15:49:50 +02:00
|
|
|
if (ModeManager::currentModeId() == m_mode.id()
|
2018-08-31 16:00:32 +02:00
|
|
|
|| LocalHelpManager::contextHelpOption() == Core::HelpManager::ExternalHelpAlways)
|
2014-12-12 11:21:14 +01:00
|
|
|
LocalHelpManager::setupGuiHelpEngine();
|
2010-03-23 18:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
bool HelpPluginPrivate::canShowHelpSideBySide()
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpViewer *HelpPluginPrivate::helpModeHelpViewer()
|
2017-07-11 17:05:40 +02:00
|
|
|
{
|
|
|
|
|
activateHelpMode(); // should trigger an createPage...
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpViewer *viewer = m_centralWidget->currentViewer();
|
2017-07-11 17:05:40 +02:00
|
|
|
if (!viewer)
|
|
|
|
|
viewer = OpenPagesManager::instance().createPage();
|
|
|
|
|
return viewer;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpWidget *HelpPluginPrivate::helpWidgetForWindow(QWidget *window)
|
2017-07-20 07:41:05 +02:00
|
|
|
{
|
|
|
|
|
if (m_externalWindow && m_externalWindow->window() == window->window())
|
|
|
|
|
return m_externalWindow;
|
|
|
|
|
activateHelpMode();
|
|
|
|
|
return m_centralWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(
|
|
|
|
|
Core::HelpManager::HelpViewerLocation location)
|
2014-06-20 17:24:18 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
Core::HelpManager::HelpViewerLocation actualLocation = location;
|
|
|
|
|
if (location == Core::HelpManager::SideBySideIfPossible)
|
|
|
|
|
actualLocation = canShowHelpSideBySide() ? Core::HelpManager::SideBySideAlways
|
|
|
|
|
: Core::HelpManager::HelpModeAlways;
|
2014-06-20 17:24:18 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
if (actualLocation == Core::HelpManager::ExternalHelpAlways)
|
2018-02-02 17:29:15 +01:00
|
|
|
return externalHelpViewer();
|
2009-07-14 13:20:26 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
if (actualLocation == Core::HelpManager::SideBySideAlways) {
|
2018-02-02 17:29:15 +01:00
|
|
|
createRightPaneContextViewer();
|
|
|
|
|
RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
|
2010-02-02 12:33:13 +01:00
|
|
|
RightPaneWidget::instance()->setShown(true);
|
2018-02-02 17:29:15 +01:00
|
|
|
return m_rightPaneSideBarWidget->currentViewer();
|
2009-06-02 17:22:14 +02:00
|
|
|
}
|
2010-10-12 16:53:00 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
QTC_CHECK(actualLocation == Core::HelpManager::HelpModeAlways);
|
2014-06-20 17:24:18 +02:00
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
return helpModeHelpViewer();
|
2017-07-11 17:05:40 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::showInHelpViewer(const QUrl &url, HelpViewer *viewer)
|
2017-07-11 17:05:40 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->setFocus();
|
|
|
|
|
viewer->stop();
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
ICore::raiseWindow(viewer);
|
Avoid double deletion of HelpWidget when quitting application via Dock
HelpWidgets that are created to be shown in an external window, had
two different places where they were deleted:
1) When the widget was closed (due to Qt::WA_DeleteOnClose)
2) In HelpPlugin::aboutToShutdown via manual delete call
In certain circumstances (when the WebEngine backend was used)
this caused a double delete. Specifically, after opening an external
help window, and closing the MainWindow, the application did not quit
due to QTBUG-62596.
Now if the help window were left open, and the application was quit
via the macOS Dock, this caused a crash.
When the application quits, it calls the HelpPlugin::aboutToShutdown,
which deletes the HelpWidget. This in turn destroys the WebEngine
view, which destroys the underlying QQuickWidget, which destroys
a QQuickRenderControl, which calls
QQuickRenderControlPrivate::windowDestroyed, which handles all
posted QEvent::DeferredDelete events, which in turn triggers the
deletion of the same HelpWidget due to the
Qt::WA_DeleteOnClose attribute.
The solution is to remove the Qt::WA_DeleteOnClose attribute, and only
delete the external HelpWidget on shutdown, and not on CloseEvent.
Task-number: QTBUG-63945
Task-number: QTCREATORBUG-19582
Change-Id: I5b73ff7fe52e7e1259a8aa98c97c9dbedd5e3c20
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-17 16:15:12 +01:00
|
|
|
// Show the parent top-level-widget in case it was closed previously.
|
|
|
|
|
viewer->window()->show();
|
2009-08-06 15:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
HelpViewer *HelpPluginPrivate::viewerForContextHelp()
|
2014-06-20 17:24:18 +02:00
|
|
|
{
|
2015-04-02 16:49:04 +02:00
|
|
|
return viewerForHelpViewerLocation(LocalHelpManager::contextHelpOption());
|
2014-06-20 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-23 16:27:29 +01:00
|
|
|
static QUrl findBestLink(const QMap<QString, QUrl> &links)
|
2014-06-04 13:41:32 +02:00
|
|
|
{
|
|
|
|
|
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;
|
2016-07-20 10:11:35 +02:00
|
|
|
QRegExp exp("(\\d+)");
|
2014-06-04 13:41:32 +02:00
|
|
|
foreach (const QUrl &link, links) {
|
|
|
|
|
const QString &authority = link.authority();
|
2016-07-20 10:11:35 +02:00
|
|
|
if (authority.startsWith("com.trolltech.")
|
|
|
|
|
|| authority.startsWith("org.qt-project.")) {
|
2014-06-04 13:41:32 +02:00
|
|
|
if (exp.indexIn(authority) >= 0) {
|
|
|
|
|
const int tmpVersion = exp.cap(1).toInt();
|
|
|
|
|
if (tmpVersion > version) {
|
|
|
|
|
source = link;
|
|
|
|
|
version = tmpVersion;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::requestContextHelp()
|
2009-08-06 15:47:31 +02:00
|
|
|
{
|
|
|
|
|
// Find out what to show
|
2019-01-29 11:43:43 +01:00
|
|
|
const QVariant tipHelpValue = Utils::ToolTip::contextHelp();
|
|
|
|
|
const HelpItem tipHelp = tipHelpValue.canConvert<HelpItem>()
|
|
|
|
|
? tipHelpValue.value<HelpItem>()
|
|
|
|
|
: HelpItem(tipHelpValue.toString());
|
2015-08-07 17:21:38 +02:00
|
|
|
IContext *context = ICore::currentContextObject();
|
2019-01-29 11:43:43 +01:00
|
|
|
if (!tipHelp.isValid() && context)
|
2019-01-25 15:04:50 +01:00
|
|
|
context->contextHelp([this](const HelpItem &item) { showContextHelp(item); });
|
2018-01-17 16:06:13 +01:00
|
|
|
else
|
2019-01-29 11:43:43 +01:00
|
|
|
showContextHelp(tipHelp);
|
2018-01-17 16:06:13 +01:00
|
|
|
}
|
2015-08-07 17:21:38 +02:00
|
|
|
|
2019-01-25 15:04:50 +01:00
|
|
|
void HelpPluginPrivate::showContextHelp(const HelpItem &contextHelp)
|
2018-01-17 16:06:13 +01:00
|
|
|
{
|
2019-01-28 12:46:30 +01:00
|
|
|
const QMap<QString, QUrl> &links = contextHelp.links();
|
2015-08-07 17:21:38 +02:00
|
|
|
|
2019-01-28 12:46:30 +01:00
|
|
|
const QUrl source = findBestLink(links);
|
2015-08-07 17:21:38 +02:00
|
|
|
if (!source.isValid()) {
|
|
|
|
|
// No link found or no context object
|
2019-01-22 15:25:27 +01:00
|
|
|
HelpViewer *viewer = showHelpUrl(QUrl(Help::Constants::AboutBlank),
|
|
|
|
|
LocalHelpManager::contextHelpOption());
|
|
|
|
|
if (viewer) {
|
|
|
|
|
viewer->setHtml(QString("<html><head><title>%1</title>"
|
|
|
|
|
"</head><body bgcolor=\"%2\"><br/><center>"
|
|
|
|
|
"<font color=\"%3\"><b>%4</b></font><br/>"
|
|
|
|
|
"<font color=\"%3\">%5</font>"
|
|
|
|
|
"</center></body></html>")
|
|
|
|
|
.arg(HelpPlugin::tr("No Documentation"))
|
|
|
|
|
.arg(creatorTheme()->color(Theme::BackgroundColorNormal).name())
|
|
|
|
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
2019-01-25 15:04:50 +01:00
|
|
|
.arg(contextHelp.helpId())
|
2019-01-22 15:25:27 +01:00
|
|
|
.arg(HelpPlugin::tr("No documentation available.")));
|
|
|
|
|
}
|
2015-08-07 17:21:38 +02:00
|
|
|
} else {
|
2019-01-23 16:27:29 +01:00
|
|
|
showHelpUrl(source, LocalHelpManager::contextHelpOption());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::activateIndex()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2016-07-20 10:11:35 +02:00
|
|
|
m_centralWidget->activateSideBarItem(Constants::HELP_INDEX);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::activateContents()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-28 13:57:42 +01:00
|
|
|
activateHelpMode();
|
2016-07-20 10:11:35 +02:00
|
|
|
m_centralWidget->activateSideBarItem(Constants::HELP_CONTENTS);
|
2010-06-21 13:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-22 15:25:27 +01:00
|
|
|
HelpViewer *HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-09-11 12:33:35 +02:00
|
|
|
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
|
|
|
|
|
if (url.host() == qtcreatorUnversionedID) {
|
|
|
|
|
// QtHelp doesn't know about versions, add the version number and use that
|
|
|
|
|
QUrl versioned = url;
|
|
|
|
|
versioned.setHost(qtcreatorUnversionedID + "."
|
|
|
|
|
+ QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.'));
|
2019-01-22 15:25:27 +01:00
|
|
|
|
|
|
|
|
return showHelpUrl(versioned, location);
|
2017-09-11 12:33:35 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-28 15:04:39 +02:00
|
|
|
if (HelpViewer::launchWithExternalApp(url))
|
2019-01-22 15:25:27 +01:00
|
|
|
return nullptr;
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2013-08-29 19:00:34 +02:00
|
|
|
if (!HelpManager::findFile(url).isValid()) {
|
2016-09-06 11:38:19 +02:00
|
|
|
const QString address = url.toString();
|
2016-07-20 10:11:35 +02:00
|
|
|
if (address.startsWith("qthelp://org.qt-project.")
|
2016-09-06 11:38:19 +02:00
|
|
|
|| address.startsWith("qthelp://com.nokia.")
|
|
|
|
|
|| address.startsWith("qthelp://com.trolltech.")) {
|
|
|
|
|
// local help not installed, resort to external web help
|
|
|
|
|
QString urlPrefix = "http://doc.qt.io/";
|
2017-09-11 12:33:35 +02:00
|
|
|
if (url.authority().startsWith(qtcreatorUnversionedID))
|
2016-09-06 11:38:19 +02:00
|
|
|
urlPrefix.append(QString::fromLatin1("qtcreator"));
|
|
|
|
|
else
|
|
|
|
|
urlPrefix.append("qt-5");
|
|
|
|
|
QDesktopServices::openUrl(QUrl(urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')))));
|
2019-01-22 15:25:27 +01:00
|
|
|
return nullptr;
|
2009-06-10 17:38:45 +02:00
|
|
|
}
|
2010-06-14 14:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-20 17:24:18 +02:00
|
|
|
HelpViewer *viewer = viewerForHelpViewerLocation(location);
|
2017-07-11 17:05:40 +02:00
|
|
|
showInHelpViewer(url, viewer);
|
2019-01-22 15:25:27 +01:00
|
|
|
return viewer;
|
2009-05-11 16:42:51 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-08-31 15:39:52 +02:00
|
|
|
class DialogClosingOnEscape : public QDialog
|
|
|
|
|
{
|
|
|
|
|
public:
|
2018-04-19 10:47:13 +02:00
|
|
|
DialogClosingOnEscape(QWidget *parent = nullptr) : QDialog(parent) {}
|
2018-11-11 10:08:29 +01:00
|
|
|
bool event(QEvent *event) override
|
2016-08-31 15:39:52 +02:00
|
|
|
{
|
|
|
|
|
if (event->type() == QEvent::ShortcutOverride) {
|
2018-11-11 10:08:29 +01:00
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
2016-08-31 15:39:52 +02:00
|
|
|
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
|
|
|
|
|
ke->accept();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QDialog::event(event);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::slotSystemInformation()
|
2016-08-31 15:39:52 +02:00
|
|
|
{
|
|
|
|
|
auto dialog = new DialogClosingOnEscape(ICore::dialogParent());
|
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
dialog->setModal(true);
|
2018-02-02 17:29:15 +01:00
|
|
|
dialog->setWindowTitle(HelpPlugin::tr("System Information"));
|
2016-08-31 15:39:52 +02:00
|
|
|
auto layout = new QVBoxLayout;
|
|
|
|
|
dialog->setLayout(layout);
|
2018-02-02 17:29:15 +01:00
|
|
|
auto intro = new QLabel(HelpPlugin::tr("Use the following to provide more detailed information about your system to bug reports:"));
|
2016-08-31 15:39:52 +02:00
|
|
|
intro->setWordWrap(true);
|
|
|
|
|
layout->addWidget(intro);
|
|
|
|
|
const QString text = "{noformat}\n" + ICore::systemInformation() + "\n{noformat}";
|
|
|
|
|
auto info = new QPlainTextEdit;
|
2016-09-28 10:57:21 +02:00
|
|
|
QFont font = info->font();
|
|
|
|
|
font.setFamily("Courier");
|
|
|
|
|
font.setStyleHint(QFont::TypeWriter);
|
|
|
|
|
info->setFont(font);
|
2016-08-31 15:39:52 +02:00
|
|
|
info->setPlainText(text);
|
|
|
|
|
layout->addWidget(info);
|
|
|
|
|
auto buttonBox = new QDialogButtonBox;
|
|
|
|
|
buttonBox->addButton(QDialogButtonBox::Cancel);
|
2018-02-02 17:29:15 +01:00
|
|
|
buttonBox->addButton(HelpPlugin::tr("Copy to Clipboard"), QDialogButtonBox::AcceptRole);
|
2016-08-31 15:39:52 +02:00
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
|
|
|
|
|
layout->addWidget(buttonBox);
|
|
|
|
|
connect(dialog, &QDialog::accepted, info, [info]() {
|
|
|
|
|
if (QApplication::clipboard())
|
|
|
|
|
QApplication::clipboard()->setText(info->toPlainText());
|
|
|
|
|
});
|
|
|
|
|
connect(dialog, &QDialog::rejected, dialog, [dialog]{ dialog->close(); });
|
|
|
|
|
dialog->resize(700, 400);
|
|
|
|
|
ICore::registerWindow(dialog, Context("Help.SystemInformation"));
|
|
|
|
|
dialog->show();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 17:29:15 +01:00
|
|
|
void HelpPluginPrivate::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
|
|
|
}
|
|
|
|
|
}
|
2018-02-02 17:29:15 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Help
|