Commit 46dfd21c authored by Eike Ziller's avatar Eike Ziller Committed by Eike Ziller

Help Window: Add Bookmarks view

Change-Id: I8b4db5b3208c4133466fe4e61f1dd1f18b432fea
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 85a6ea6c
......@@ -257,6 +257,7 @@ HelpWidget::~HelpWidget()
if (m_sideBar) {
m_sideBar->saveSettings(Core::ICore::settings(), QLatin1String(kSideBarSettingsKey));
Core::ActionManager::unregisterAction(m_indexAction, Constants::HELP_INDEX);
Core::ActionManager::unregisterAction(m_bookmarkAction, Constants::HELP_BOOKMARKS);
}
Core::ICore::removeContextObject(m_context);
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
......@@ -296,8 +297,21 @@ void HelpWidget::addSideBar()
: tr("Ctrl+Shift+I")));
shortcutMap.insert(QLatin1String(Constants::HELP_INDEX), cmd);
auto bookmarkWidget = new BookmarkWidget(&LocalHelpManager::bookmarkManager(), 0, false);
bookmarkWidget->setWindowTitle(tr(Constants::SB_BOOKMARKS));
bookmarkWidget->setOpenInNewPageActionVisible(false);
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());
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+B")
: tr("Ctrl+Shift+B")));
shortcutMap.insert(QLatin1String(Constants::HELP_BOOKMARKS), cmd);
QList<Core::SideBarItem *> itemList;
itemList << indexItem;
itemList << indexItem << bookmarkItem;
m_sideBar = new Core::SideBar(itemList, QList<Core::SideBarItem *>() << indexItem);
m_sideBar->setShortcutMap(shortcutMap);
m_sideBar->setCloseWhenEmpty(true);
......@@ -312,6 +326,9 @@ void HelpWidget::addSideBar()
connect(m_indexAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_INDEX));
});
connect(m_bookmarkAction, &QAction::triggered, m_sideBar, [this]() {
m_sideBar->activateItem(QLatin1String(Constants::HELP_BOOKMARKS));
});
}
HelpViewer *HelpWidget::currentViewer() const
......
......@@ -141,6 +141,7 @@ private:
Core::MiniSplitter *m_sideBarSplitter;
Core::SideBar *m_sideBar;
QAction *m_indexAction;
QAction *m_bookmarkAction;
};
} // Internal
......
......@@ -302,6 +302,7 @@ BookmarkWidget::BookmarkWidget(BookmarkManager *manager, QWidget *parent,
, addButton(0)
, removeButton(0)
, bookmarkManager(manager)
, m_isOpenInNewPageActionVisible(true)
{
setup(showButtons);
installEventFilter(this);
......@@ -311,6 +312,11 @@ BookmarkWidget::~BookmarkWidget()
{
}
void BookmarkWidget::setOpenInNewPageActionVisible(bool visible)
{
m_isOpenInNewPageActionVisible = visible;
}
void BookmarkWidget::removeClicked()
{
const QModelIndex& index = treeView->currentIndex();
......@@ -384,7 +390,8 @@ void BookmarkWidget::customContextMenuRequested(const QPoint &point)
renameItem = menu.addAction(tr("Rename Folder"));
} else {
showItem = menu.addAction(tr("Show Bookmark"));
showItemNewTab = menu.addAction(tr("Show Bookmark as New Page"));
if (m_isOpenInNewPageActionVisible)
showItemNewTab = menu.addAction(tr("Show Bookmark as New Page"));
if (searchField->text().isEmpty()) {
menu.addSeparator();
removeItem = menu.addAction(tr("Delete Bookmark"));
......
......@@ -113,6 +113,8 @@ public:
bool showButtons = true);
~BookmarkWidget();
void setOpenInNewPageActionVisible(bool visible);
signals:
void addBookmark();
void linkActivated(const QUrl &url);
......@@ -138,6 +140,7 @@ private:
QToolButton *removeButton;
BookmarkManager *bookmarkManager;
QSortFilterProxyModel* filterBookmarkModel;
bool m_isOpenInNewPageActionVisible;
};
class BookmarkModel : public QStandardItemModel
......
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