forked from qt-creator/qt-creator
Add previous and next buttons to bookmarks pane tool bar
Task-number: QTCREATORBUG-9859 Change-Id: I2555fc89cd893681ee17b272def053f1e42e9368 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QSpinBox>
|
||||
#include <QToolButton>
|
||||
|
||||
Q_DECLARE_METATYPE(Bookmarks::Internal::Bookmark*)
|
||||
|
||||
@@ -241,6 +242,20 @@ BookmarkView::~BookmarkView()
|
||||
ICore::removeContextObject(m_bookmarkContext);
|
||||
}
|
||||
|
||||
QList<QToolButton *> BookmarkView::createToolBarWidgets() const
|
||||
{
|
||||
Command *prevCmd = ActionManager::command(Constants::BOOKMARKS_PREV_ACTION);
|
||||
Command *nextCmd = ActionManager::command(Constants::BOOKMARKS_NEXT_ACTION);
|
||||
QTC_ASSERT(prevCmd && nextCmd, return {});
|
||||
auto prevButton = new QToolButton;
|
||||
prevButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
prevButton->setDefaultAction(prevCmd->action());
|
||||
auto nextButton = new QToolButton;
|
||||
nextButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
nextButton->setDefaultAction(nextCmd->action());
|
||||
return {prevButton, nextButton};
|
||||
}
|
||||
|
||||
void BookmarkView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu menu;
|
||||
@@ -804,7 +819,10 @@ BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm)
|
||||
|
||||
NavigationView BookmarkViewFactory::createWidget()
|
||||
{
|
||||
return NavigationView(new BookmarkView(m_manager));
|
||||
auto view = new BookmarkView(m_manager);
|
||||
auto navview = NavigationView(view);
|
||||
navview.dockToolBarWidgets = view->createToolBarWidgets();
|
||||
return navview;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -128,6 +128,8 @@ public:
|
||||
explicit BookmarkView(BookmarkManager *manager);
|
||||
~BookmarkView();
|
||||
|
||||
QList<QToolButton *> createToolBarWidgets() const;
|
||||
|
||||
public slots:
|
||||
void gotoBookmark(const QModelIndex &index);
|
||||
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
@@ -113,12 +114,16 @@ BookmarksPluginRunData::BookmarksPluginRunData()
|
||||
mbm->addSeparator();
|
||||
|
||||
// Previous
|
||||
m_prevAction.setIcon(Utils::Icons::PREV_TOOLBAR.icon());
|
||||
m_prevAction.setIconVisibleInMenu(false);
|
||||
cmd = ActionManager::registerAction(&m_prevAction, BOOKMARKS_PREV_ACTION, editorManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? BookmarksPlugin::tr("Meta+,")
|
||||
: BookmarksPlugin::tr("Ctrl+,")));
|
||||
mbm->addAction(cmd);
|
||||
|
||||
// Next
|
||||
m_nextAction.setIcon(Utils::Icons::NEXT_TOOLBAR.icon());
|
||||
m_nextAction.setIconVisibleInMenu(false);
|
||||
cmd = ActionManager::registerAction(&m_nextAction, BOOKMARKS_NEXT_ACTION, editorManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? BookmarksPlugin::tr("Meta+.")
|
||||
: BookmarksPlugin::tr("Ctrl+.")));
|
||||
|
Reference in New Issue
Block a user