summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/help/helpconstants.h2
-rw-r--r--src/plugins/help/helpplugin.cpp4
-rw-r--r--src/plugins/help/helpwidget.cpp37
-rw-r--r--src/plugins/help/helpwidget.h4
4 files changed, 45 insertions, 2 deletions
diff --git a/src/plugins/help/helpconstants.h b/src/plugins/help/helpconstants.h
index 0b0ce15fea..15343c1c70 100644
--- a/src/plugins/help/helpconstants.h
+++ b/src/plugins/help/helpconstants.h
@@ -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
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 52daa1f1a1..b7a8c007bf 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -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));
diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp
index 1ecd0c5f53..53b2bebbcc 100644
--- a/src/plugins/help/helpwidget.cpp
+++ b/src/plugins/help/helpwidget.cpp
@@ -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
diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h
index eec9989734..12788746f7 100644
--- a/src/plugins/help/helpwidget.h
+++ b/src/plugins/help/helpwidget.h
@@ -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;