Commit 85ac9651 authored by Eike Ziller's avatar Eike Ziller

External Help: Add home and bookmark buttons

Change-Id: Ia2442dfa435e964820ec6a721071fce4d4a04061
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 3f546f7b
......@@ -60,8 +60,10 @@ const char C_HELP_SIDEBAR[] = "Help Sidebar";
const char C_HELP_EXTERNAL[] = "Help.ExternalWindow";
const char CONTEXT_HELP[] = "Help.Context";
const char HELP_HOME[] = "Help.Home";
const char HELP_PREVIOUS[] = "Help.Previous";
const char HELP_NEXT[] = "Help.Next";
const char HELP_BOOKMARK[] = "Help.AddBookmark";
} // Constants
} // Help
......
......@@ -206,7 +206,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
// Add Home, Previous and Next actions (used in the toolbar)
QAction *action = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")),
tr("Home"), this);
cmd = ActionManager::registerAction(action, "Help.Home", globalcontext);
cmd = ActionManager::registerAction(action, Constants::HELP_HOME, globalcontext);
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
helpButtonLayout->addWidget(toolButton(cmd, action));
......@@ -234,7 +234,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
action = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
tr("Add Bookmark"), this);
cmd = ActionManager::registerAction(action, "Help.AddBookmark", modecontext);
cmd = ActionManager::registerAction(action, Constants::HELP_BOOKMARK, modecontext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
connect(action, SIGNAL(triggered()), this, SLOT(addBookmark()));
helpButtonLayout->addWidget(toolButton(cmd, action));
......
......@@ -29,9 +29,11 @@
#include "helpwidget.h"
#include "bookmarkmanager.h"
#include "helpconstants.h"
#include "helpplugin.h"
#include "helpviewer.h"
#include "localhelpmanager.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -81,6 +83,12 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
connect(m_switchToHelp, SIGNAL(triggered()), this, SLOT(helpModeButtonClicked()));
layout->addWidget(toolButton(m_switchToHelp, cmd));
m_homeAction = new QAction(QIcon(QLatin1String(":/help/images/home.png")),
tr("Home"), this);
cmd = Core::ActionManager::registerAction(m_homeAction, Constants::HELP_HOME, context);
connect(m_homeAction, &QAction::triggered, this, &HelpWidget::goHome);
layout->addWidget(toolButton(m_homeAction, cmd));
m_backAction = new QAction(QIcon(QLatin1String(":/help/images/previous.png")),
tr("Back"), toolBar);
m_backMenu = new QMenu(toolBar);
......@@ -99,6 +107,14 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
cmd->setDefaultKeySequence(QKeySequence::Forward);
layout->addWidget(toolButton(m_forwardAction, cmd));
m_addBookmarkAction = new QAction(QIcon(QLatin1String(":/help/images/bookmark.png")),
tr("Add Bookmark"), this);
cmd = Core::ActionManager::registerAction(m_addBookmarkAction, Constants::HELP_BOOKMARK, context);
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));
layout->addWidget(toolButton(m_addBookmarkAction, cmd));
layout->addStretch();
m_viewer = HelpPlugin::createHelpViewer(qreal(0.0));
......@@ -178,8 +194,10 @@ HelpWidget::~HelpWidget()
Core::ICore::removeContextObject(m_context);
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
Core::ActionManager::unregisterAction(m_switchToHelp, Constants::CONTEXT_HELP);
Core::ActionManager::unregisterAction(m_homeAction, Constants::HELP_HOME);
Core::ActionManager::unregisterAction(m_forwardAction, Constants::HELP_NEXT);
Core::ActionManager::unregisterAction(m_backAction, Constants::HELP_PREVIOUS);
Core::ActionManager::unregisterAction(m_addBookmarkAction, Constants::HELP_BOOKMARK);
if (m_scaleUp)
Core::ActionManager::unregisterAction(m_scaleUp, TextEditor::Constants::INCREASE_FONT_SIZE);
if (m_scaleDown)
......@@ -226,5 +244,24 @@ void HelpWidget::helpModeButtonClicked()
close();
}
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);
}
} // Internal
} // Help
......@@ -72,14 +72,18 @@ private slots:
void updateForwardMenu();
void updateWindowTitle();
void helpModeButtonClicked();
void goHome();
void addBookmark();
private:
Core::IContext *m_context;
QAction *m_switchToHelp;
QAction *m_homeAction;
QMenu *m_backMenu;
QMenu *m_forwardMenu;
QAction *m_backAction;
QAction *m_forwardAction;
QAction *m_addBookmarkAction;
QAction *m_scaleUp;
QAction *m_scaleDown;
QAction *m_resetScale;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment