2014-06-17 18:14:37 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-06-17 18:14:37 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2014-06-17 18:14:37 +02: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.
|
2014-06-17 18:14:37 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "helpwidget.h"
|
|
|
|
|
|
2014-09-24 12:29:23 +02:00
|
|
|
#include "bookmarkmanager.h"
|
2014-10-10 11:01:21 +02:00
|
|
|
#include "contentwindow.h"
|
2014-06-18 17:42:01 +02:00
|
|
|
#include "helpconstants.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "helpicons.h"
|
2014-06-17 18:14:37 +02:00
|
|
|
#include "helpplugin.h"
|
|
|
|
|
#include "helpviewer.h"
|
2014-10-01 17:52:57 +02:00
|
|
|
#include "indexwindow.h"
|
2014-09-24 12:29:23 +02:00
|
|
|
#include "localhelpmanager.h"
|
2014-09-25 16:29:56 +02:00
|
|
|
#include "openpagesmanager.h"
|
2014-10-13 13:31:49 +02:00
|
|
|
#include "searchwidget.h"
|
2014-10-01 17:52:57 +02:00
|
|
|
#include "topicchooser.h"
|
2014-06-17 18:14:37 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2015-11-23 16:41:54 +01:00
|
|
|
#include <coreplugin/coreicons.h>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
2014-10-01 17:52:57 +02:00
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/sidebar.h>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2014-06-18 17:42:01 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
|
2015-04-23 23:57:48 +03:00
|
|
|
#include <QCoreApplication>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <QHBoxLayout>
|
2014-09-25 16:29:56 +02:00
|
|
|
#include <QHelpEngine>
|
|
|
|
|
#include <QHelpSearchEngine>
|
|
|
|
|
#include <QHelpSearchQuery>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <QMenu>
|
2014-09-25 16:29:56 +02:00
|
|
|
#include <QPrinter>
|
|
|
|
|
#include <QPrintDialog>
|
|
|
|
|
#include <QStackedWidget>
|
2014-06-17 18:14:37 +02:00
|
|
|
#include <QToolButton>
|
|
|
|
|
|
2014-10-13 19:40:39 +02:00
|
|
|
static const char kWindowSideBarSettingsKey[] = "Help/WindowSideBar";
|
|
|
|
|
static const char kModeSideBarSettingsKey[] = "Help/ModeSideBar";
|
2014-06-17 18:14:37 +02:00
|
|
|
|
|
|
|
|
namespace Help {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
2014-09-25 16:29:56 +02:00
|
|
|
m_style(style),
|
2014-10-01 17:52:57 +02:00
|
|
|
m_toggleSideBarAction(0),
|
2014-09-25 16:29:56 +02:00
|
|
|
m_switchToHelp(0),
|
|
|
|
|
m_filterComboBox(0),
|
|
|
|
|
m_closeAction(0),
|
2014-06-18 17:42:01 +02:00
|
|
|
m_scaleUp(0),
|
|
|
|
|
m_scaleDown(0),
|
2014-06-23 12:30:54 +02:00
|
|
|
m_resetScale(0),
|
2014-10-01 17:52:57 +02:00
|
|
|
m_printer(0),
|
|
|
|
|
m_sideBar(0),
|
2014-10-13 19:40:39 +02:00
|
|
|
m_contentsAction(0),
|
|
|
|
|
m_indexAction(0),
|
|
|
|
|
m_bookmarkAction(0),
|
|
|
|
|
m_searchAction(0),
|
|
|
|
|
m_openPagesAction(0)
|
2014-06-17 18:14:37 +02:00
|
|
|
{
|
2014-10-01 17:52:57 +02:00
|
|
|
m_viewerStack = new QStackedWidget;
|
|
|
|
|
|
|
|
|
|
auto hLayout = new QHBoxLayout(this);
|
|
|
|
|
hLayout->setMargin(0);
|
|
|
|
|
hLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_sideBarSplitter = new Core::MiniSplitter(this);
|
|
|
|
|
m_sideBarSplitter->setOpaqueResize(false);
|
|
|
|
|
hLayout->addWidget(m_sideBarSplitter);
|
|
|
|
|
|
2014-06-17 18:14:37 +02:00
|
|
|
Utils::StyledBar *toolBar = new Utils::StyledBar();
|
2014-09-23 19:16:17 +02:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->setMargin(0);
|
2014-10-01 17:52:57 +02:00
|
|
|
|
|
|
|
|
auto rightSide = new QWidget(this);
|
|
|
|
|
m_sideBarSplitter->insertWidget(1, rightSide);
|
|
|
|
|
QVBoxLayout *vLayout = new QVBoxLayout(rightSide);
|
|
|
|
|
vLayout->setMargin(0);
|
|
|
|
|
vLayout->setSpacing(0);
|
|
|
|
|
vLayout->addWidget(toolBar);
|
|
|
|
|
vLayout->addWidget(m_viewerStack);
|
|
|
|
|
Core::FindToolBarPlaceHolder *fth = new Core::FindToolBarPlaceHolder(this);
|
|
|
|
|
vLayout->addWidget(fth);
|
|
|
|
|
|
|
|
|
|
setFocusProxy(m_viewerStack);
|
|
|
|
|
|
|
|
|
|
m_context = new Core::IContext(this);
|
|
|
|
|
m_context->setContext(context);
|
|
|
|
|
m_context->setWidget(m_sideBarSplitter);
|
|
|
|
|
Core::ICore::addContextObject(m_context);
|
|
|
|
|
|
2014-09-23 19:16:17 +02:00
|
|
|
Core::Command *cmd;
|
2014-10-01 17:52:57 +02:00
|
|
|
QToolButton *button;
|
|
|
|
|
|
|
|
|
|
if (style == ExternalWindow) {
|
|
|
|
|
static int windowId = 0;
|
|
|
|
|
Core::ICore::registerWindow(this,
|
|
|
|
|
Core::Context(Core::Id("Help.Window.").withSuffix(++windowId)));
|
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
|
2014-10-13 19:40:39 +02:00
|
|
|
}
|
|
|
|
|
if (style != SideBarWidget) {
|
2016-04-20 16:12:42 +02:00
|
|
|
m_toggleSideBarAction = new QAction(Core::Icons::TOGGLE_SIDEBAR_TOOLBAR.icon(),
|
2015-04-23 23:57:48 +03:00
|
|
|
QCoreApplication::translate("Core", Core::Constants::TR_SHOW_SIDEBAR),
|
|
|
|
|
toolBar);
|
2014-10-01 17:52:57 +02:00
|
|
|
m_toggleSideBarAction->setCheckable(true);
|
|
|
|
|
m_toggleSideBarAction->setChecked(false);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_toggleSideBarAction,
|
|
|
|
|
Core::Constants::TOGGLE_SIDEBAR, context);
|
|
|
|
|
connect(m_toggleSideBarAction, &QAction::toggled, m_toggleSideBarAction,
|
|
|
|
|
[this](bool checked) {
|
2015-04-23 23:57:48 +03:00
|
|
|
m_toggleSideBarAction->setText(
|
|
|
|
|
QCoreApplication::translate("Core",
|
|
|
|
|
checked ? Core::Constants::TR_HIDE_SIDEBAR
|
|
|
|
|
: Core::Constants::TR_SHOW_SIDEBAR));
|
2014-10-01 17:52:57 +02:00
|
|
|
});
|
|
|
|
|
addSideBar();
|
2014-10-13 19:40:39 +02:00
|
|
|
m_toggleSideBarAction->setChecked(m_sideBar->isVisibleTo(this));
|
2014-10-01 17:52:57 +02:00
|
|
|
connect(m_toggleSideBarAction, &QAction::triggered, m_sideBar, &Core::SideBar::setVisible);
|
|
|
|
|
connect(m_sideBar, &Core::SideBar::sideBarClosed, m_toggleSideBarAction, [this]() {
|
|
|
|
|
m_toggleSideBarAction->setChecked(false);
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-10-13 19:40:39 +02:00
|
|
|
if (style == ExternalWindow)
|
|
|
|
|
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_toggleSideBarAction, cmd));
|
2014-06-17 18:14:37 +02:00
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
if (style != ModeWidget) {
|
|
|
|
|
m_switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_switchToHelp, Constants::CONTEXT_HELP, context);
|
2015-09-21 16:19:04 +02:00
|
|
|
connect(m_switchToHelp, &QAction::triggered, this, &HelpWidget::helpModeButtonClicked);
|
2014-10-01 17:52:57 +02:00
|
|
|
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_switchToHelp, cmd));
|
2014-09-25 16:29:56 +02:00
|
|
|
}
|
2014-06-17 18:14:37 +02:00
|
|
|
|
2016-04-15 10:54:50 +02:00
|
|
|
m_homeAction = new QAction(Icons::HOME_TOOLBAR.icon(), tr("Home"), this);
|
2014-09-24 12:29:23 +02:00
|
|
|
cmd = Core::ActionManager::registerAction(m_homeAction, Constants::HELP_HOME, context);
|
|
|
|
|
connect(m_homeAction, &QAction::triggered, this, &HelpWidget::goHome);
|
2014-10-01 17:52:57 +02:00
|
|
|
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_homeAction, cmd));
|
2014-09-24 12:29:23 +02:00
|
|
|
|
2016-04-20 16:12:42 +02:00
|
|
|
m_backAction = new QAction(Core::Icons::PREV_TOOLBAR.icon(), tr("Back"), toolBar);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_backAction, &QAction::triggered, this, &HelpWidget::backward);
|
2014-06-17 18:14:37 +02:00
|
|
|
m_backMenu = new QMenu(toolBar);
|
2015-09-21 16:19:04 +02:00
|
|
|
connect(m_backMenu, &QMenu::aboutToShow, this, &HelpWidget::updateBackMenu);
|
2014-09-23 19:16:17 +02:00
|
|
|
m_backAction->setMenu(m_backMenu);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_backAction, Constants::HELP_PREVIOUS, context);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Back);
|
2014-10-01 17:52:57 +02:00
|
|
|
button = Core::Command::toolButtonWithAppendedShortcut(m_backAction, cmd);
|
|
|
|
|
button->setPopupMode(QToolButton::DelayedPopup);
|
|
|
|
|
layout->addWidget(button);
|
2014-09-23 19:16:17 +02:00
|
|
|
|
2016-04-20 16:12:42 +02:00
|
|
|
m_forwardAction = new QAction(Core::Icons::NEXT_TOOLBAR.icon(), tr("Forward"), toolBar);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_forwardAction, &QAction::triggered, this, &HelpWidget::forward);
|
2014-06-17 18:14:37 +02:00
|
|
|
m_forwardMenu = new QMenu(toolBar);
|
2015-09-21 16:19:04 +02:00
|
|
|
connect(m_forwardMenu, &QMenu::aboutToShow, this, &HelpWidget::updateForwardMenu);
|
2014-09-23 19:16:17 +02:00
|
|
|
m_forwardAction->setMenu(m_forwardMenu);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_forwardAction, Constants::HELP_NEXT, context);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Forward);
|
2014-10-01 17:52:57 +02:00
|
|
|
button = Core::Command::toolButtonWithAppendedShortcut(m_forwardAction, cmd);
|
|
|
|
|
button->setPopupMode(QToolButton::DelayedPopup);
|
|
|
|
|
layout->addWidget(button);
|
2014-06-17 18:14:37 +02:00
|
|
|
|
2016-04-15 10:54:50 +02:00
|
|
|
m_addBookmarkAction = new QAction(Icons::BOOKMARK_TOOLBAR.icon(), tr("Add Bookmark"), this);
|
2014-10-09 16:03:27 +02:00
|
|
|
cmd = Core::ActionManager::registerAction(m_addBookmarkAction, Constants::HELP_ADDBOOKMARK, context);
|
2014-09-24 12:29:23 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
|
|
|
|
|
connect(m_addBookmarkAction, &QAction::triggered, this, &HelpWidget::addBookmark);
|
|
|
|
|
layout->addWidget(new Utils::StyledSeparator(toolBar));
|
2014-10-01 17:52:57 +02:00
|
|
|
layout->addWidget(Core::Command::toolButtonWithAppendedShortcut(m_addBookmarkAction, cmd));
|
2014-09-24 12:29:23 +02:00
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
if (style == ModeWidget) {
|
|
|
|
|
layout->addWidget(new Utils::StyledSeparator(toolBar));
|
|
|
|
|
layout->addWidget(OpenPagesManager::instance().openPagesComboBox(), 10);
|
2014-10-01 17:52:57 +02:00
|
|
|
} else {
|
|
|
|
|
layout->addWidget(new QLabel(), 10);
|
|
|
|
|
}
|
|
|
|
|
if (style != SideBarWidget) {
|
2014-09-25 16:29:56 +02:00
|
|
|
m_filterComboBox = new QComboBox;
|
|
|
|
|
m_filterComboBox->setMinimumContentsLength(15);
|
|
|
|
|
m_filterComboBox->setModel(LocalHelpManager::filterModel());
|
2014-10-01 17:52:57 +02:00
|
|
|
m_filterComboBox->setCurrentIndex(LocalHelpManager::filterIndex());
|
2014-09-25 16:29:56 +02:00
|
|
|
layout->addWidget(m_filterComboBox);
|
|
|
|
|
connect(m_filterComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
|
|
|
|
LocalHelpManager::instance(), &LocalHelpManager::setFilterIndex);
|
|
|
|
|
connect(LocalHelpManager::instance(), &LocalHelpManager::filterIndexChanged,
|
|
|
|
|
m_filterComboBox, &QComboBox::setCurrentIndex);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-17 18:14:37 +02:00
|
|
|
layout->addStretch();
|
|
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
m_printAction = new QAction(this);
|
|
|
|
|
Core::ActionManager::registerAction(m_printAction, Core::Constants::PRINT, context);
|
|
|
|
|
connect(m_printAction, &QAction::triggered, this, [this]() { print(currentViewer()); });
|
2014-06-17 18:14:37 +02:00
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
m_copy = new QAction(this);
|
2014-09-10 12:18:28 +02:00
|
|
|
Core::ActionManager::registerAction(m_copy, Core::Constants::COPY, context);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_copy, &QAction::triggered, this, &HelpWidget::copy);
|
2014-06-18 17:42:01 +02:00
|
|
|
|
|
|
|
|
Core::ActionContainer *advancedMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED);
|
2016-04-15 15:21:26 +02:00
|
|
|
if (QTC_GUARD(advancedMenu)) {
|
2014-06-17 18:14:37 +02:00
|
|
|
// reuse TextEditor constants to avoid a second pair of menu actions
|
2014-06-18 17:42:01 +02:00
|
|
|
m_scaleUp = new QAction(tr("Increase Font Size"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_scaleUp, TextEditor::Constants::INCREASE_FONT_SIZE,
|
2014-06-17 18:14:37 +02:00
|
|
|
context);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_scaleUp, &QAction::triggered, this, &HelpWidget::scaleUp);
|
2014-06-17 18:14:37 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
m_scaleDown = new QAction(tr("Decrease Font Size"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_scaleDown, TextEditor::Constants::DECREASE_FONT_SIZE,
|
2014-06-17 18:14:37 +02:00
|
|
|
context);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_scaleDown, &QAction::triggered, this, &HelpWidget::scaleDown);
|
2014-06-17 18:14:37 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
m_resetScale = new QAction(tr("Reset Font Size"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_resetScale, TextEditor::Constants::RESET_FONT_SIZE,
|
2014-06-17 18:14:37 +02:00
|
|
|
context);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_resetScale, &QAction::triggered, this, &HelpWidget::resetScale);
|
2014-06-17 18:14:37 +02:00
|
|
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
|
|
|
}
|
2014-06-18 17:42:01 +02:00
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
if (style != ExternalWindow) {
|
2015-11-30 18:12:49 +01:00
|
|
|
m_closeAction = new QAction(Core::Icons::CLOSE_TOOLBAR.icon(), QString(), toolBar);
|
2014-09-25 16:29:56 +02:00
|
|
|
connect(m_closeAction, SIGNAL(triggered()), this, SIGNAL(closeButtonClicked()));
|
2014-10-01 17:52:57 +02:00
|
|
|
button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(m_closeAction);
|
|
|
|
|
layout->addWidget(button);
|
2014-09-25 16:29:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (style != ModeWidget) {
|
|
|
|
|
HelpViewer *viewer = HelpPlugin::createHelpViewer(qreal(0.0));
|
|
|
|
|
addViewer(viewer);
|
|
|
|
|
setCurrentViewer(viewer);
|
2014-06-18 17:42:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpWidget::~HelpWidget()
|
|
|
|
|
{
|
2014-10-01 17:52:57 +02:00
|
|
|
if (m_sideBar) {
|
2014-10-13 19:40:39 +02:00
|
|
|
m_sideBar->saveSettings(Core::ICore::settings(), sideBarSettingsKey());
|
2014-10-10 11:01:21 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_contentsAction, Constants::HELP_CONTENTS);
|
2014-10-01 17:52:57 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_indexAction, Constants::HELP_INDEX);
|
2014-10-09 16:42:12 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_bookmarkAction, Constants::HELP_BOOKMARKS);
|
2014-10-13 13:31:49 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_searchAction, Constants::HELP_SEARCH);
|
2014-10-13 19:40:39 +02:00
|
|
|
if (m_openPagesAction)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_openPagesAction, Constants::HELP_OPENPAGES);
|
2014-10-01 17:52:57 +02:00
|
|
|
}
|
2014-07-24 14:48:36 +02:00
|
|
|
Core::ICore::removeContextObject(m_context);
|
2014-06-18 17:42:01 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
|
2014-10-08 15:22:14 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_printAction, Core::Constants::PRINT);
|
2014-10-01 17:52:57 +02:00
|
|
|
if (m_toggleSideBarAction)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR);
|
2014-09-25 16:29:56 +02:00
|
|
|
if (m_switchToHelp)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_switchToHelp, Constants::CONTEXT_HELP);
|
2014-09-24 12:29:23 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_homeAction, Constants::HELP_HOME);
|
2014-09-23 19:16:17 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_forwardAction, Constants::HELP_NEXT);
|
|
|
|
|
Core::ActionManager::unregisterAction(m_backAction, Constants::HELP_PREVIOUS);
|
2014-10-09 16:03:27 +02:00
|
|
|
Core::ActionManager::unregisterAction(m_addBookmarkAction, Constants::HELP_ADDBOOKMARK);
|
2014-06-18 17:42:01 +02:00
|
|
|
if (m_scaleUp)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_scaleUp, TextEditor::Constants::INCREASE_FONT_SIZE);
|
|
|
|
|
if (m_scaleDown)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_scaleDown, TextEditor::Constants::DECREASE_FONT_SIZE);
|
|
|
|
|
if (m_resetScale)
|
|
|
|
|
Core::ActionManager::unregisterAction(m_resetScale, TextEditor::Constants::RESET_FONT_SIZE);
|
2014-06-17 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
void HelpWidget::addSideBar()
|
|
|
|
|
{
|
|
|
|
|
QMap<QString, Core::Command *> shortcutMap;
|
|
|
|
|
Core::Command *cmd;
|
2014-10-13 19:40:39 +02:00
|
|
|
bool supportsNewPages = (m_style == ModeWidget);
|
2014-10-01 17:52:57 +02:00
|
|
|
|
2014-10-10 11:01:21 +02:00
|
|
|
auto contentWindow = new ContentWindow;
|
|
|
|
|
auto contentItem = new Core::SideBarItem(contentWindow, QLatin1String(Constants::HELP_CONTENTS));
|
2014-10-13 19:40:39 +02:00
|
|
|
contentWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
2015-04-21 14:48:04 +02:00
|
|
|
contentWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_CONTENTS));
|
2014-10-10 11:01:21 +02:00
|
|
|
connect(contentWindow, &ContentWindow::linkActivated,
|
|
|
|
|
this, &HelpWidget::open);
|
2014-10-13 19:40:39 +02:00
|
|
|
m_contentsAction = new QAction(tr(Constants::SB_CONTENTS), this);
|
2014-10-10 11:01:21 +02:00
|
|
|
cmd = Core::ActionManager::registerAction(m_contentsAction, Constants::HELP_CONTENTS, m_context->context());
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+C")
|
|
|
|
|
: tr("Ctrl+Shift+C")));
|
|
|
|
|
shortcutMap.insert(QLatin1String(Constants::HELP_CONTENTS), cmd);
|
|
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
auto indexWindow = new IndexWindow();
|
2014-10-09 16:03:27 +02:00
|
|
|
auto indexItem = new Core::SideBarItem(indexWindow, QLatin1String(Constants::HELP_INDEX));
|
2014-10-13 19:40:39 +02:00
|
|
|
indexWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
2015-04-21 14:48:04 +02:00
|
|
|
indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX));
|
2014-10-01 17:52:57 +02:00
|
|
|
connect(indexWindow, &IndexWindow::linkActivated,
|
|
|
|
|
this, &HelpWidget::open);
|
|
|
|
|
connect(indexWindow, &IndexWindow::linksActivated,
|
|
|
|
|
this, &HelpWidget::showTopicChooser);
|
2014-10-13 19:40:39 +02:00
|
|
|
m_indexAction = new QAction(tr(Constants::SB_INDEX), this);
|
2014-10-01 17:52:57 +02:00
|
|
|
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
|
|
|
|
|
: tr("Ctrl+Shift+I")));
|
2014-10-09 16:03:27 +02:00
|
|
|
shortcutMap.insert(QLatin1String(Constants::HELP_INDEX), cmd);
|
2014-10-01 17:52:57 +02:00
|
|
|
|
2014-10-09 17:07:35 +02:00
|
|
|
auto bookmarkWidget = new BookmarkWidget(&LocalHelpManager::bookmarkManager());
|
2015-04-21 14:48:04 +02:00
|
|
|
bookmarkWidget->setWindowTitle(HelpPlugin::tr(Constants::SB_BOOKMARKS));
|
2014-10-13 19:40:39 +02:00
|
|
|
bookmarkWidget->setOpenInNewPageActionVisible(supportsNewPages);
|
2014-10-09 16:42:12 +02:00
|
|
|
auto bookmarkItem = new Core::SideBarItem(bookmarkWidget,
|
|
|
|
|
QLatin1String(Constants::HELP_BOOKMARKS));
|
|
|
|
|
connect(bookmarkWidget, &BookmarkWidget::linkActivated, this, &HelpWidget::setSource);
|
|
|
|
|
m_bookmarkAction = new QAction(tr("Activate Help Bookmarks View"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_bookmarkAction, Constants::HELP_BOOKMARKS,
|
|
|
|
|
m_context->context());
|
2015-03-12 12:32:00 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Alt+Meta+M")
|
2014-10-09 16:42:12 +02:00
|
|
|
: tr("Ctrl+Shift+B")));
|
|
|
|
|
shortcutMap.insert(QLatin1String(Constants::HELP_BOOKMARKS), cmd);
|
|
|
|
|
|
2014-10-13 13:31:49 +02:00
|
|
|
auto searchItem = new SearchSideBarItem;
|
|
|
|
|
connect(searchItem, &SearchSideBarItem::linkActivated, this, &HelpWidget::openFromSearch);
|
|
|
|
|
m_searchAction = new QAction(tr("Activate Help Search View"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_searchAction, Constants::HELP_SEARCH,
|
|
|
|
|
m_context->context());
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+/")
|
|
|
|
|
: tr("Ctrl+Shift+/")));
|
|
|
|
|
shortcutMap.insert(QLatin1String(Constants::HELP_SEARCH), cmd);
|
|
|
|
|
|
2014-10-13 19:40:39 +02:00
|
|
|
Core::SideBarItem *openPagesItem = 0;
|
|
|
|
|
if (m_style == ModeWidget) {
|
|
|
|
|
QWidget *openPagesWidget = OpenPagesManager::instance().openPagesWidget();
|
2015-04-21 14:48:04 +02:00
|
|
|
openPagesWidget->setWindowTitle(HelpPlugin::tr(Constants::SB_OPENPAGES));
|
2014-10-13 19:40:39 +02:00
|
|
|
openPagesItem = new Core::SideBarItem(openPagesWidget,
|
|
|
|
|
QLatin1String(Constants::HELP_OPENPAGES));
|
|
|
|
|
m_openPagesAction = new QAction(tr("Activate Open Help Pages View"), this);
|
|
|
|
|
cmd = Core::ActionManager::registerAction(m_openPagesAction, Constants::HELP_OPENPAGES,
|
|
|
|
|
m_context->context());
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+O")
|
|
|
|
|
: tr("Ctrl+Shift+O")));
|
|
|
|
|
shortcutMap.insert(QLatin1String(Constants::HELP_OPENPAGES), cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
QList<Core::SideBarItem *> itemList;
|
2014-10-13 13:31:49 +02:00
|
|
|
itemList << contentItem << indexItem << bookmarkItem << searchItem;
|
2014-10-13 19:40:39 +02:00
|
|
|
if (openPagesItem)
|
|
|
|
|
itemList << openPagesItem;
|
2014-10-10 11:01:21 +02:00
|
|
|
m_sideBar = new Core::SideBar(itemList,
|
2014-10-13 19:40:39 +02:00
|
|
|
QList<Core::SideBarItem *>() << contentItem
|
|
|
|
|
<< (openPagesItem ? openPagesItem : indexItem));
|
2014-10-01 17:52:57 +02:00
|
|
|
m_sideBar->setShortcutMap(shortcutMap);
|
|
|
|
|
m_sideBar->setCloseWhenEmpty(true);
|
|
|
|
|
m_sideBarSplitter->insertWidget(0, m_sideBar);
|
|
|
|
|
m_sideBarSplitter->setStretchFactor(0, 0);
|
|
|
|
|
m_sideBarSplitter->setStretchFactor(1, 1);
|
2014-10-17 16:29:56 +02:00
|
|
|
if (m_style != ModeWidget)
|
|
|
|
|
m_sideBar->setVisible(false);
|
2014-10-10 11:01:21 +02:00
|
|
|
m_sideBar->resize(250, size().height());
|
2014-10-13 19:40:39 +02:00
|
|
|
m_sideBar->readSettings(Core::ICore::settings(), sideBarSettingsKey());
|
2014-10-01 17:52:57 +02:00
|
|
|
m_sideBarSplitter->setSizes(QList<int>() << m_sideBar->size().width() << 300);
|
|
|
|
|
|
2014-10-13 12:42:20 +02:00
|
|
|
connect(m_contentsAction, &QAction::triggered, m_sideBar, [this]() {
|
|
|
|
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_CONTENTS));
|
|
|
|
|
});
|
2014-10-09 16:03:27 +02:00
|
|
|
connect(m_indexAction, &QAction::triggered, m_sideBar, [this]() {
|
|
|
|
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
|
2014-10-01 17:52:57 +02:00
|
|
|
});
|
2014-10-09 16:42:12 +02:00
|
|
|
connect(m_bookmarkAction, &QAction::triggered, m_sideBar, [this]() {
|
|
|
|
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_BOOKMARKS));
|
|
|
|
|
});
|
2014-10-13 13:31:49 +02:00
|
|
|
connect(m_searchAction, &QAction::triggered, m_sideBar, [this]() {
|
|
|
|
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_SEARCH));
|
|
|
|
|
});
|
2014-10-13 19:40:39 +02:00
|
|
|
if (m_openPagesAction) {
|
|
|
|
|
connect(m_openPagesAction, &QAction::triggered, m_sideBar, [this]() {
|
|
|
|
|
m_sideBar->activateItem(QLatin1String(Constants::HELP_OPENPAGES));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString HelpWidget::sideBarSettingsKey() const
|
|
|
|
|
{
|
|
|
|
|
switch (m_style) {
|
|
|
|
|
case ModeWidget:
|
|
|
|
|
return QLatin1String(kModeSideBarSettingsKey);
|
|
|
|
|
case ExternalWindow:
|
|
|
|
|
return QLatin1String(kWindowSideBarSettingsKey);
|
|
|
|
|
case SideBarWidget:
|
|
|
|
|
QTC_CHECK(false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
2014-10-01 17:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-17 18:14:37 +02:00
|
|
|
HelpViewer *HelpWidget::currentViewer() const
|
|
|
|
|
{
|
2014-09-25 16:29:56 +02:00
|
|
|
return qobject_cast<HelpViewer *>(m_viewerStack->currentWidget());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::setCurrentViewer(HelpViewer *viewer)
|
|
|
|
|
{
|
|
|
|
|
m_viewerStack->setCurrentWidget(viewer);
|
|
|
|
|
m_backAction->setEnabled(viewer->isBackwardAvailable());
|
|
|
|
|
m_forwardAction->setEnabled(viewer->isForwardAvailable());
|
|
|
|
|
if (m_style == ExternalWindow)
|
|
|
|
|
updateWindowTitle();
|
|
|
|
|
emit sourceChanged(viewer->source());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HelpWidget::currentIndex() const
|
|
|
|
|
{
|
|
|
|
|
return m_viewerStack->currentIndex();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-31 14:20:03 +01:00
|
|
|
void HelpWidget::addViewer(HelpViewer *viewer)
|
2014-09-25 16:29:56 +02:00
|
|
|
{
|
|
|
|
|
m_viewerStack->addWidget(viewer);
|
|
|
|
|
viewer->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
if (m_style == SideBarWidget || m_style == ExternalWindow)
|
|
|
|
|
viewer->setOpenInNewPageActionVisible(false);
|
|
|
|
|
connect(viewer, &HelpViewer::sourceChanged, this, [viewer, this](const QUrl &url) {
|
|
|
|
|
if (currentViewer() == viewer)
|
|
|
|
|
emit sourceChanged(url);
|
|
|
|
|
});
|
|
|
|
|
connect(viewer, &HelpViewer::forwardAvailable, this, [viewer, this](bool available) {
|
|
|
|
|
if (currentViewer() == viewer)
|
|
|
|
|
m_forwardAction->setEnabled(available);
|
|
|
|
|
});
|
|
|
|
|
connect(viewer, &HelpViewer::backwardAvailable, this, [viewer, this](bool available) {
|
|
|
|
|
if (currentViewer() == viewer)
|
|
|
|
|
m_backAction->setEnabled(available);
|
|
|
|
|
});
|
|
|
|
|
connect(viewer, &HelpViewer::printRequested, this, [viewer, this]() {
|
|
|
|
|
print(viewer);
|
|
|
|
|
});
|
|
|
|
|
if (m_style == ExternalWindow)
|
2015-09-21 16:19:04 +02:00
|
|
|
connect(viewer, &HelpViewer::titleChanged, this, &HelpWidget::updateWindowTitle);
|
2014-09-25 16:29:56 +02:00
|
|
|
|
2014-10-31 14:20:03 +01:00
|
|
|
connect(viewer, &HelpViewer::loadFinished, this, &HelpWidget::highlightSearchTerms);
|
2014-09-25 16:29:56 +02:00
|
|
|
|
|
|
|
|
updateCloseButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::removeViewerAt(int index)
|
|
|
|
|
{
|
|
|
|
|
QWidget *viewerWidget = m_viewerStack->widget(index);
|
|
|
|
|
QTC_ASSERT(viewerWidget, return);
|
|
|
|
|
m_viewerStack->removeWidget(viewerWidget);
|
|
|
|
|
// do not delete, that is done in the model
|
|
|
|
|
// delete viewerWidget;
|
|
|
|
|
if (m_viewerStack->currentWidget())
|
|
|
|
|
setCurrentViewer(qobject_cast<HelpViewer *>(m_viewerStack->currentWidget()));
|
|
|
|
|
updateCloseButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HelpWidget::viewerCount() const
|
|
|
|
|
{
|
|
|
|
|
return m_viewerStack->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelpViewer *HelpWidget::viewerAt(int index) const
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<HelpViewer *>(m_viewerStack->widget(index));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:52:57 +02:00
|
|
|
void HelpWidget::open(const QUrl &url, bool newPage)
|
|
|
|
|
{
|
|
|
|
|
if (newPage)
|
|
|
|
|
OpenPagesManager::instance().createPage(url);
|
|
|
|
|
else
|
|
|
|
|
setSource(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::showTopicChooser(const QMap<QString, QUrl> &links,
|
|
|
|
|
const QString &keyword, bool newPage)
|
|
|
|
|
{
|
|
|
|
|
TopicChooser tc(this, keyword, links);
|
|
|
|
|
if (tc.exec() == QDialog::Accepted)
|
|
|
|
|
open(tc.link(), newPage);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 19:40:39 +02:00
|
|
|
void HelpWidget::activateSideBarItem(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_sideBar, return);
|
|
|
|
|
m_sideBar->activateItem(id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
void HelpWidget::setSource(const QUrl &url)
|
|
|
|
|
{
|
|
|
|
|
HelpViewer* viewer = currentViewer();
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
viewer->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-31 14:20:03 +01:00
|
|
|
void HelpWidget::openFromSearch(const QUrl &url, const QStringList &searchTerms, bool newPage)
|
2014-09-25 16:29:56 +02:00
|
|
|
{
|
2014-10-31 14:20:03 +01:00
|
|
|
m_searchTerms = searchTerms;
|
2014-10-10 15:32:46 +02:00
|
|
|
if (newPage)
|
2014-10-31 14:20:03 +01:00
|
|
|
OpenPagesManager::instance().createPage(url);
|
2014-10-10 15:32:46 +02:00
|
|
|
else {
|
|
|
|
|
HelpViewer* viewer = currentViewer();
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
viewer->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
}
|
2014-06-17 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
void HelpWidget::closeEvent(QCloseEvent *)
|
|
|
|
|
{
|
|
|
|
|
emit aboutToClose();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-17 18:14:37 +02:00
|
|
|
void HelpWidget::updateBackMenu()
|
|
|
|
|
{
|
|
|
|
|
m_backMenu->clear();
|
2014-09-25 16:29:56 +02:00
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->addBackHistoryItems(m_backMenu);
|
2014-06-17 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::updateForwardMenu()
|
|
|
|
|
{
|
|
|
|
|
m_forwardMenu->clear();
|
2014-09-25 16:29:56 +02:00
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->addForwardHistoryItems(m_forwardMenu);
|
2014-06-17 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-18 17:42:01 +02:00
|
|
|
void HelpWidget::updateWindowTitle()
|
|
|
|
|
{
|
2014-09-25 16:29:56 +02:00
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
const QString pageTitle = currentViewer()->title();
|
2014-06-18 17:42:01 +02:00
|
|
|
if (pageTitle.isEmpty())
|
|
|
|
|
setWindowTitle(tr("Help"));
|
|
|
|
|
else
|
|
|
|
|
setWindowTitle(tr("Help - %1").arg(pageTitle));
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 12:30:54 +02:00
|
|
|
void HelpWidget::helpModeButtonClicked()
|
2014-06-17 18:14:37 +02:00
|
|
|
{
|
2014-09-25 16:29:56 +02:00
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
emit openHelpMode(currentViewer()->source());
|
2014-06-23 12:30:54 +02:00
|
|
|
if (m_style == ExternalWindow)
|
|
|
|
|
close();
|
2014-06-17 18:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
void HelpWidget::updateCloseButton()
|
|
|
|
|
{
|
|
|
|
|
if (m_style == ModeWidget) {
|
2015-04-02 16:49:04 +02:00
|
|
|
const bool closeOnReturn = LocalHelpManager::returnOnClose();
|
2014-09-25 16:29:56 +02:00
|
|
|
m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-24 12:29:23 +02:00
|
|
|
void HelpWidget::goHome()
|
|
|
|
|
{
|
|
|
|
|
if (HelpViewer *viewer = currentViewer())
|
|
|
|
|
viewer->home();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::addBookmark()
|
|
|
|
|
{
|
|
|
|
|
HelpViewer *viewer = currentViewer();
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
|
|
|
|
|
const QString &url = viewer->source().toString();
|
|
|
|
|
if (url.isEmpty() || url == Help::Constants::AboutBlank)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
|
|
|
|
|
manager->showBookmarkDialog(this, viewer->title(), url);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 16:29:56 +02:00
|
|
|
void HelpWidget::copy()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->copy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::forward()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->forward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::backward()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->backward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::scaleUp()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->scaleUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::scaleDown()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->scaleDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::resetScale()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentViewer(), return);
|
|
|
|
|
currentViewer()->resetScale();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::print(HelpViewer *viewer)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
if (!m_printer)
|
|
|
|
|
m_printer = new QPrinter(QPrinter::HighResolution);
|
|
|
|
|
QPrintDialog dlg(m_printer, this);
|
|
|
|
|
dlg.setWindowTitle(tr("Print Documentation"));
|
|
|
|
|
if (!viewer->selectedText().isEmpty())
|
|
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
|
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
|
|
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
|
|
|
|
|
|
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
|
|
|
|
viewer->print(m_printer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelpWidget::highlightSearchTerms()
|
|
|
|
|
{
|
2014-10-31 14:20:03 +01:00
|
|
|
if (m_searchTerms.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
HelpViewer *viewer = qobject_cast<HelpViewer *>(sender());
|
|
|
|
|
QTC_ASSERT(viewer, return);
|
|
|
|
|
foreach (const QString& term, m_searchTerms)
|
|
|
|
|
viewer->findText(term, 0, false, true);
|
|
|
|
|
m_searchTerms.clear();
|
2014-09-25 16:29:56 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-17 18:14:37 +02:00
|
|
|
} // Internal
|
|
|
|
|
} // Help
|