forked from qt-creator/qt-creator
Help: Create separate help widget class
That contains the tool bar together with a help viewer, which can also be used for an external help window, and later be extended to also replace the extra "central widget". Change-Id: I73fac4c135b985cbe47062b90783f156b5062005 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
This commit is contained in:
@@ -38,7 +38,8 @@ HEADERS += \
|
|||||||
externalhelpwindow.h \
|
externalhelpwindow.h \
|
||||||
searchtaskhandler.h \
|
searchtaskhandler.h \
|
||||||
qtwebkithelpviewer.h \
|
qtwebkithelpviewer.h \
|
||||||
textbrowserhelpviewer.h
|
textbrowserhelpviewer.h \
|
||||||
|
helpwidget.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
centralwidget.cpp \
|
centralwidget.cpp \
|
||||||
@@ -61,7 +62,8 @@ SOURCES += \
|
|||||||
externalhelpwindow.cpp \
|
externalhelpwindow.cpp \
|
||||||
searchtaskhandler.cpp \
|
searchtaskhandler.cpp \
|
||||||
qtwebkithelpviewer.cpp \
|
qtwebkithelpviewer.cpp \
|
||||||
textbrowserhelpviewer.cpp
|
textbrowserhelpviewer.cpp \
|
||||||
|
helpwidget.cpp
|
||||||
|
|
||||||
FORMS += docsettingspage.ui \
|
FORMS += docsettingspage.ui \
|
||||||
filtersettingspage.ui \
|
filtersettingspage.ui \
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ QtcPlugin {
|
|||||||
"helpmode.cpp", "helpmode.h",
|
"helpmode.cpp", "helpmode.h",
|
||||||
"helpplugin.cpp", "helpplugin.h",
|
"helpplugin.cpp", "helpplugin.h",
|
||||||
"helpviewer.cpp", "helpviewer.h",
|
"helpviewer.cpp", "helpviewer.h",
|
||||||
|
"helpwidget.cpp", "helpwidget.h",
|
||||||
"localhelpmanager.cpp", "localhelpmanager.h",
|
"localhelpmanager.cpp", "localhelpmanager.h",
|
||||||
"openpagesmanager.cpp", "openpagesmanager.h",
|
"openpagesmanager.cpp", "openpagesmanager.h",
|
||||||
"openpagesmodel.cpp", "openpagesmodel.h",
|
"openpagesmodel.cpp", "openpagesmodel.h",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "helpindexfilter.h"
|
#include "helpindexfilter.h"
|
||||||
#include "helpmode.h"
|
#include "helpmode.h"
|
||||||
#include "helpviewer.h"
|
#include "helpviewer.h"
|
||||||
|
#include "helpwidget.h"
|
||||||
#include "localhelpmanager.h"
|
#include "localhelpmanager.h"
|
||||||
#include "openpagesmanager.h"
|
#include "openpagesmanager.h"
|
||||||
#include "openpagesmodel.h"
|
#include "openpagesmodel.h"
|
||||||
@@ -119,7 +120,6 @@ HelpPlugin::HelpPlugin()
|
|||||||
: m_mode(0),
|
: m_mode(0),
|
||||||
m_centralWidget(0),
|
m_centralWidget(0),
|
||||||
m_rightPaneSideBarWidget(0),
|
m_rightPaneSideBarWidget(0),
|
||||||
m_helpViewerForSideBar(0),
|
|
||||||
m_contentItem(0),
|
m_contentItem(0),
|
||||||
m_indexItem(0),
|
m_indexItem(0),
|
||||||
m_searchItem(0),
|
m_searchItem(0),
|
||||||
@@ -529,110 +529,20 @@ void HelpPlugin::createRightPaneContextViewer()
|
|||||||
if (m_rightPaneSideBarWidget)
|
if (m_rightPaneSideBarWidget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Utils::StyledBar *toolBar = new Utils::StyledBar();
|
m_rightPaneSideBarWidget = new HelpWidget(Core::Context(Constants::C_HELP_SIDEBAR));
|
||||||
|
|
||||||
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
connect(m_rightPaneSideBarWidget->currentViewer(), SIGNAL(loadFinished()),
|
||||||
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode()));
|
|
||||||
QAction *back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
|
||||||
tr("Previous"), toolBar);
|
|
||||||
QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
|
|
||||||
tr("Next"), toolBar);
|
|
||||||
QAction *close = new QAction(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT)),
|
|
||||||
QLatin1String(""), toolBar);
|
|
||||||
connect(close, SIGNAL(triggered()), this, SLOT(slotHideRightPane()));
|
|
||||||
|
|
||||||
setupNavigationMenus(back, next, toolBar);
|
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setMargin(0);
|
|
||||||
|
|
||||||
layout->addWidget(toolButton(switchToHelp));
|
|
||||||
layout->addWidget(toolButton(back));
|
|
||||||
layout->addWidget(toolButton(next));
|
|
||||||
layout->addStretch();
|
|
||||||
layout->addWidget(toolButton(close));
|
|
||||||
|
|
||||||
m_rightPaneSideBarWidget = new QWidget;
|
|
||||||
m_helpViewerForSideBar = createHelpViewer(qreal(0.0));
|
|
||||||
m_helpViewerForSideBar->setOpenInNewWindowActionVisible(false);
|
|
||||||
|
|
||||||
QVBoxLayout *rightPaneLayout = new QVBoxLayout(m_rightPaneSideBarWidget);
|
|
||||||
rightPaneLayout->setMargin(0);
|
|
||||||
rightPaneLayout->setSpacing(0);
|
|
||||||
rightPaneLayout->addWidget(toolBar);
|
|
||||||
rightPaneLayout->addWidget(m_helpViewerForSideBar);
|
|
||||||
FindToolBarPlaceHolder *fth = new FindToolBarPlaceHolder(m_rightPaneSideBarWidget);
|
|
||||||
fth->setObjectName(QLatin1String("HelpRightPaneFindToolBarPlaceHolder"));
|
|
||||||
rightPaneLayout->addWidget(fth);
|
|
||||||
m_rightPaneSideBarWidget->setFocusProxy(m_helpViewerForSideBar);
|
|
||||||
|
|
||||||
Context context(Constants::C_HELP_SIDEBAR);
|
|
||||||
IContext *icontext = new IContext(this);
|
|
||||||
icontext->setContext(context);
|
|
||||||
icontext->setWidget(m_helpViewerForSideBar);
|
|
||||||
ICore::addContextObject(icontext);
|
|
||||||
|
|
||||||
QAction *copy = new QAction(this);
|
|
||||||
Command *cmd = ActionManager::registerAction(copy, Core::Constants::COPY, context);
|
|
||||||
copy->setText(cmd->action()->text());
|
|
||||||
copy->setIcon(cmd->action()->icon());
|
|
||||||
connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy()));
|
|
||||||
|
|
||||||
next->setEnabled(m_helpViewerForSideBar->isForwardAvailable());
|
|
||||||
connect(next, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(forward()));
|
|
||||||
connect(m_helpViewerForSideBar, SIGNAL(forwardAvailable(bool)), next,
|
|
||||||
SLOT(setEnabled(bool)));
|
|
||||||
|
|
||||||
back->setEnabled(m_helpViewerForSideBar->isBackwardAvailable());
|
|
||||||
connect(back, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(backward()));
|
|
||||||
connect(m_helpViewerForSideBar, SIGNAL(backwardAvailable(bool)), back,
|
|
||||||
SLOT(setEnabled(bool)));
|
|
||||||
|
|
||||||
if (ActionContainer *advancedMenu = ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
|
||||||
// reuse TextEditor constants to avoid a second pair of menu actions
|
|
||||||
QAction *action = new QAction(tr("Increase Font Size"), this);
|
|
||||||
cmd = ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE, context);
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneUp()));
|
|
||||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
||||||
|
|
||||||
action = new QAction(tr("Decrease Font Size"), this);
|
|
||||||
cmd = ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE, context);
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneDown()));
|
|
||||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
||||||
|
|
||||||
action = new QAction(tr("Reset Font Size"), this);
|
|
||||||
cmd = ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE, context);
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(resetRightPaneScale()));
|
|
||||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(m_helpViewerForSideBar, SIGNAL(loadFinished()),
|
|
||||||
this, SLOT(highlightSearchTermsInContextHelp()));
|
this, SLOT(highlightSearchTermsInContextHelp()));
|
||||||
|
connect(m_rightPaneSideBarWidget, SIGNAL(openHelpMode(QUrl)),
|
||||||
|
this, SLOT(switchToHelpMode(QUrl)));
|
||||||
|
connect(m_rightPaneSideBarWidget, SIGNAL(close()),
|
||||||
|
this, SLOT(slotHideRightPane()));
|
||||||
|
|
||||||
// force setup, as we might have never switched to full help mode
|
// force setup, as we might have never switched to full help mode
|
||||||
// thus the help engine might still run without collection file setup
|
// thus the help engine might still run without collection file setup
|
||||||
m_helpManager->setupGuiHelpEngine();
|
m_helpManager->setupGuiHelpEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::scaleRightPaneUp()
|
|
||||||
{
|
|
||||||
if (m_helpViewerForSideBar)
|
|
||||||
m_helpViewerForSideBar->scaleUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::scaleRightPaneDown()
|
|
||||||
{
|
|
||||||
if (m_helpViewerForSideBar)
|
|
||||||
m_helpViewerForSideBar->scaleDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::resetRightPaneScale()
|
|
||||||
{
|
|
||||||
if (m_helpViewerForSideBar)
|
|
||||||
m_helpViewerForSideBar->resetScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
||||||
{
|
{
|
||||||
HelpViewer *viewer = 0;
|
HelpViewer *viewer = 0;
|
||||||
@@ -672,11 +582,6 @@ void HelpPlugin::activateHelpMode()
|
|||||||
showExternalWindow();
|
showExternalWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::switchToHelpMode()
|
|
||||||
{
|
|
||||||
switchToHelpMode(m_helpViewerForSideBar->source());
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::switchToHelpMode(const QUrl &source)
|
void HelpPlugin::switchToHelpMode(const QUrl &source)
|
||||||
{
|
{
|
||||||
activateHelpMode();
|
activateHelpMode();
|
||||||
@@ -728,8 +633,8 @@ void HelpPlugin::updateSideBarSource()
|
|||||||
|
|
||||||
void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
||||||
{
|
{
|
||||||
if (m_helpViewerForSideBar)
|
if (m_rightPaneSideBarWidget)
|
||||||
m_helpViewerForSideBar->setSource(newUrl);
|
m_rightPaneSideBarWidget->currentViewer()->setSource(newUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::updateCloseButton()
|
void HelpPlugin::updateCloseButton()
|
||||||
@@ -742,14 +647,14 @@ void HelpPlugin::updateCloseButton()
|
|||||||
|
|
||||||
void HelpPlugin::fontChanged()
|
void HelpPlugin::fontChanged()
|
||||||
{
|
{
|
||||||
if (!m_helpViewerForSideBar)
|
if (!m_rightPaneSideBarWidget)
|
||||||
createRightPaneContextViewer();
|
createRightPaneContextViewer();
|
||||||
|
|
||||||
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
||||||
QFont font = fontSetting.isValid() ? fontSetting.value<QFont>()
|
QFont font = fontSetting.isValid() ? fontSetting.value<QFont>()
|
||||||
: m_helpViewerForSideBar->viewerFont();
|
: m_rightPaneSideBarWidget->currentViewer()->viewerFont();
|
||||||
|
|
||||||
m_helpViewerForSideBar->setViewerFont(font);
|
m_rightPaneSideBarWidget->currentViewer()->setViewerFont(font);
|
||||||
const int count = OpenPagesManager::instance().pageCount();
|
const int count = OpenPagesManager::instance().pageCount();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
if (HelpViewer *viewer = CentralWidget::instance()->viewerAt(i))
|
if (HelpViewer *viewer = CentralWidget::instance()->viewerAt(i))
|
||||||
@@ -859,7 +764,7 @@ HelpViewer *HelpPlugin::viewerForContextMode()
|
|||||||
createRightPaneContextViewer();
|
createRightPaneContextViewer();
|
||||||
RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
|
RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
|
||||||
RightPaneWidget::instance()->setShown(true);
|
RightPaneWidget::instance()->setShown(true);
|
||||||
return m_helpViewerForSideBar;
|
return m_rightPaneSideBarWidget->currentViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
activateHelpMode(); // should trigger an createPage...
|
activateHelpMode(); // should trigger an createPage...
|
||||||
@@ -903,8 +808,8 @@ void HelpPlugin::activateContext()
|
|||||||
|
|
||||||
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
|
||||||
if (placeHolder && qApp->focusWidget()
|
if (placeHolder && qApp->focusWidget()
|
||||||
&& qApp->focusWidget() == m_helpViewerForSideBar->focusWidget()) {
|
&& qApp->focusWidget() == m_rightPaneSideBarWidget->currentViewer()->focusWidget()) {
|
||||||
switchToHelpMode();
|
switchToHelpMode(m_rightPaneSideBarWidget->currentViewer()->source());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ModeManager::currentMode() == m_mode)
|
if (ModeManager::currentMode() == m_mode)
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class ExternalHelpWindow;
|
|||||||
class FilterSettingsPage;
|
class FilterSettingsPage;
|
||||||
class GeneralSettingsPage;
|
class GeneralSettingsPage;
|
||||||
class HelpMode;
|
class HelpMode;
|
||||||
|
class HelpWidget;
|
||||||
class HelpViewer;
|
class HelpViewer;
|
||||||
class LocalHelpManager;
|
class LocalHelpManager;
|
||||||
class OpenPagesManager;
|
class OpenPagesManager;
|
||||||
@@ -97,7 +98,6 @@ private slots:
|
|||||||
void updateFilterComboBox();
|
void updateFilterComboBox();
|
||||||
void filterDocumentation(const QString &customFilter);
|
void filterDocumentation(const QString &customFilter);
|
||||||
|
|
||||||
void switchToHelpMode();
|
|
||||||
void switchToHelpMode(const QUrl &source);
|
void switchToHelpMode(const QUrl &source);
|
||||||
void slotHideRightPane();
|
void slotHideRightPane();
|
||||||
void showHideSidebar();
|
void showHideSidebar();
|
||||||
@@ -121,10 +121,6 @@ private slots:
|
|||||||
|
|
||||||
void onSideBarVisibilityChanged();
|
void onSideBarVisibilityChanged();
|
||||||
|
|
||||||
void scaleRightPaneUp();
|
|
||||||
void scaleRightPaneDown();
|
|
||||||
void resetRightPaneScale();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void resetFilter();
|
void resetFilter();
|
||||||
@@ -142,8 +138,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
HelpMode *m_mode;
|
HelpMode *m_mode;
|
||||||
CentralWidget *m_centralWidget;
|
CentralWidget *m_centralWidget;
|
||||||
QWidget *m_rightPaneSideBarWidget;
|
HelpWidget *m_rightPaneSideBarWidget;
|
||||||
HelpViewer *m_helpViewerForSideBar;
|
|
||||||
|
|
||||||
Core::SideBarItem *m_contentItem;
|
Core::SideBarItem *m_contentItem;
|
||||||
Core::SideBarItem *m_indexItem;
|
Core::SideBarItem *m_indexItem;
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ public:
|
|||||||
virtual QFont viewerFont() const = 0;
|
virtual QFont viewerFont() const = 0;
|
||||||
virtual void setViewerFont(const QFont &font) = 0;
|
virtual void setViewerFont(const QFont &font) = 0;
|
||||||
|
|
||||||
virtual void scaleUp() = 0;
|
|
||||||
virtual void scaleDown() = 0;
|
|
||||||
virtual void resetScale() = 0;
|
|
||||||
|
|
||||||
virtual qreal scale() const = 0;
|
virtual qreal scale() const = 0;
|
||||||
|
|
||||||
virtual QString title() const = 0;
|
virtual QString title() const = 0;
|
||||||
@@ -88,6 +84,9 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void home();
|
void home();
|
||||||
|
|
||||||
|
virtual void scaleUp() = 0;
|
||||||
|
virtual void scaleDown() = 0;
|
||||||
|
virtual void resetScale() = 0;
|
||||||
virtual void copy() = 0;
|
virtual void copy() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual void forward() = 0;
|
virtual void forward() = 0;
|
||||||
|
|||||||
168
src/plugins/help/helpwidget.cpp
Normal file
168
src/plugins/help/helpwidget.cpp
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "helpwidget.h"
|
||||||
|
|
||||||
|
#include "helpplugin.h"
|
||||||
|
#include "helpviewer.h"
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/findplaceholder.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
static QToolButton *toolButton(QAction *action)
|
||||||
|
{
|
||||||
|
QToolButton *button = new QToolButton;
|
||||||
|
button->setDefaultAction(action);
|
||||||
|
button->setPopupMode(QToolButton::DelayedPopup);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Help {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
HelpWidget::HelpWidget(const Core::Context &context, QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
Utils::StyledBar *toolBar = new Utils::StyledBar();
|
||||||
|
|
||||||
|
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
|
||||||
|
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(emitOpenHelpMode()));
|
||||||
|
|
||||||
|
QAction *back = new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
|
||||||
|
tr("Back"), toolBar);
|
||||||
|
m_backMenu = new QMenu(toolBar);
|
||||||
|
connect(m_backMenu, SIGNAL(aboutToShow()), this, SLOT(updateBackMenu()));
|
||||||
|
back->setMenu(m_backMenu);
|
||||||
|
QAction *forward = new QAction(QIcon(QLatin1String(":/help/images/next.png")),
|
||||||
|
tr("Forward"), toolBar);
|
||||||
|
m_forwardMenu = new QMenu(toolBar);
|
||||||
|
connect(m_forwardMenu, SIGNAL(aboutToShow()), this, SLOT(updateForwardMenu()));
|
||||||
|
forward->setMenu(m_forwardMenu);
|
||||||
|
|
||||||
|
QAction *close = new QAction(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT)),
|
||||||
|
QString(), toolBar);
|
||||||
|
connect(close, SIGNAL(triggered()), this, SIGNAL(close()));
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout(toolBar);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
layout->setMargin(0);
|
||||||
|
|
||||||
|
layout->addWidget(toolButton(switchToHelp));
|
||||||
|
layout->addWidget(toolButton(back));
|
||||||
|
layout->addWidget(toolButton(forward));
|
||||||
|
layout->addStretch();
|
||||||
|
layout->addWidget(toolButton(close));
|
||||||
|
|
||||||
|
m_viewer = HelpPlugin::createHelpViewer(qreal(0.0));
|
||||||
|
m_viewer->setOpenInNewWindowActionVisible(false);
|
||||||
|
|
||||||
|
QVBoxLayout *vLayout = new QVBoxLayout(this);
|
||||||
|
vLayout->setMargin(0);
|
||||||
|
vLayout->setSpacing(0);
|
||||||
|
vLayout->addWidget(toolBar);
|
||||||
|
vLayout->addWidget(m_viewer);
|
||||||
|
Core::FindToolBarPlaceHolder *fth = new Core::FindToolBarPlaceHolder(this);
|
||||||
|
vLayout->addWidget(fth);
|
||||||
|
|
||||||
|
setFocusProxy(m_viewer);
|
||||||
|
|
||||||
|
Core::IContext *icontext = new Core::IContext(this);
|
||||||
|
icontext->setContext(context);
|
||||||
|
icontext->setWidget(m_viewer);
|
||||||
|
Core::ICore::addContextObject(icontext);
|
||||||
|
|
||||||
|
QAction *copy = new QAction(this);
|
||||||
|
Core::Command *cmd = Core::ActionManager::registerAction(copy, Core::Constants::COPY, context);
|
||||||
|
connect(copy, SIGNAL(triggered()), m_viewer, SLOT(copy()));
|
||||||
|
|
||||||
|
back->setEnabled(m_viewer->isBackwardAvailable());
|
||||||
|
connect(back, SIGNAL(triggered()), m_viewer, SLOT(backward()));
|
||||||
|
connect(m_viewer, SIGNAL(backwardAvailable(bool)), back,
|
||||||
|
SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
|
forward->setEnabled(m_viewer->isForwardAvailable());
|
||||||
|
connect(forward, SIGNAL(triggered()), m_viewer, SLOT(forward()));
|
||||||
|
connect(m_viewer, SIGNAL(forwardAvailable(bool)), forward,
|
||||||
|
SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
|
if (Core::ActionContainer *advancedMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
||||||
|
// reuse TextEditor constants to avoid a second pair of menu actions
|
||||||
|
QAction *action = new QAction(tr("Increase Font Size"), this);
|
||||||
|
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
||||||
|
context);
|
||||||
|
connect(action, SIGNAL(triggered()), m_viewer, SLOT(scaleUp()));
|
||||||
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||||
|
|
||||||
|
action = new QAction(tr("Decrease Font Size"), this);
|
||||||
|
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
||||||
|
context);
|
||||||
|
connect(action, SIGNAL(triggered()), m_viewer, SLOT(scaleDown()));
|
||||||
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||||
|
|
||||||
|
action = new QAction(tr("Reset Font Size"), this);
|
||||||
|
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
||||||
|
context);
|
||||||
|
connect(action, SIGNAL(triggered()), m_viewer, SLOT(resetScale()));
|
||||||
|
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HelpViewer *HelpWidget::currentViewer() const
|
||||||
|
{
|
||||||
|
return m_viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWidget::updateBackMenu()
|
||||||
|
{
|
||||||
|
m_backMenu->clear();
|
||||||
|
m_viewer->addBackHistoryItems(m_backMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWidget::updateForwardMenu()
|
||||||
|
{
|
||||||
|
m_forwardMenu->clear();
|
||||||
|
m_viewer->addForwardHistoryItems(m_forwardMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpWidget::emitOpenHelpMode()
|
||||||
|
{
|
||||||
|
emit openHelpMode(m_viewer->source());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Help
|
||||||
74
src/plugins/help/helpwidget.h
Normal file
74
src/plugins/help/helpwidget.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef HELPWIDGET_H
|
||||||
|
#define HELPWIDGET_H
|
||||||
|
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QMenu;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Help {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class HelpViewer;
|
||||||
|
|
||||||
|
class HelpWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit HelpWidget(const Core::Context &context, QWidget *parent = 0);
|
||||||
|
|
||||||
|
HelpViewer *currentViewer() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openHelpMode(const QUrl &url);
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateBackMenu();
|
||||||
|
void updateForwardMenu();
|
||||||
|
void emitOpenHelpMode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMenu *m_backMenu;
|
||||||
|
QMenu *m_forwardMenu;
|
||||||
|
|
||||||
|
HelpViewer *m_viewer;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Help
|
||||||
|
|
||||||
|
#endif // HELPWIDGET_H
|
||||||
@@ -87,10 +87,6 @@ public:
|
|||||||
QFont viewerFont() const;
|
QFont viewerFont() const;
|
||||||
void setViewerFont(const QFont &font);
|
void setViewerFont(const QFont &font);
|
||||||
|
|
||||||
void scaleUp();
|
|
||||||
void scaleDown();
|
|
||||||
void resetScale();
|
|
||||||
|
|
||||||
qreal scale() const;
|
qreal scale() const;
|
||||||
|
|
||||||
QString title() const;
|
QString title() const;
|
||||||
@@ -115,6 +111,9 @@ public:
|
|||||||
MacWebKitHelpWidget *widget() const { return m_widget; }
|
MacWebKitHelpWidget *widget() const { return m_widget; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void scaleUp();
|
||||||
|
void scaleDown();
|
||||||
|
void resetScale();
|
||||||
void copy();
|
void copy();
|
||||||
void stop();
|
void stop();
|
||||||
void forward();
|
void forward();
|
||||||
|
|||||||
@@ -53,9 +53,6 @@ public:
|
|||||||
QFont viewerFont() const;
|
QFont viewerFont() const;
|
||||||
void setViewerFont(const QFont &font);
|
void setViewerFont(const QFont &font);
|
||||||
|
|
||||||
void scaleUp();
|
|
||||||
void scaleDown();
|
|
||||||
void resetScale();
|
|
||||||
qreal scale() const;
|
qreal scale() const;
|
||||||
|
|
||||||
QString title() const;
|
QString title() const;
|
||||||
@@ -80,6 +77,9 @@ public:
|
|||||||
HelpPage *page() const;
|
HelpPage *page() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void scaleUp();
|
||||||
|
void scaleDown();
|
||||||
|
void resetScale();
|
||||||
void copy();
|
void copy();
|
||||||
void stop();
|
void stop();
|
||||||
void forward();
|
void forward();
|
||||||
|
|||||||
@@ -52,10 +52,6 @@ public:
|
|||||||
QFont viewerFont() const;
|
QFont viewerFont() const;
|
||||||
void setViewerFont(const QFont &font);
|
void setViewerFont(const QFont &font);
|
||||||
|
|
||||||
void scaleUp();
|
|
||||||
void scaleDown();
|
|
||||||
|
|
||||||
void resetScale();
|
|
||||||
qreal scale() const;
|
qreal scale() const;
|
||||||
|
|
||||||
QString title() const;
|
QString title() const;
|
||||||
@@ -77,6 +73,9 @@ public:
|
|||||||
bool incremental, bool fromSearch, bool *wrapped = 0);
|
bool incremental, bool fromSearch, bool *wrapped = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void scaleUp();
|
||||||
|
void scaleDown();
|
||||||
|
void resetScale();
|
||||||
void copy();
|
void copy();
|
||||||
void stop();
|
void stop();
|
||||||
void forward();
|
void forward();
|
||||||
|
|||||||
Reference in New Issue
Block a user