forked from qt-creator/qt-creator
Core: Remove Menu
... and replace the only use by MenuBuilder. Change-Id: Iaf224bee4a07de6ed733b4c89f01c42d4103fcb7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -403,35 +403,6 @@ ActionSeparator::ActionSeparator(Id id)
|
|||||||
container->addSeparator();
|
container->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu
|
|
||||||
|
|
||||||
Menu::Menu() = default;
|
|
||||||
|
|
||||||
void Menu::setId(Id id)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!m_menu, return);
|
|
||||||
m_menu = ActionManager::createMenu(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::setTitle(const QString &title)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_menu, return);
|
|
||||||
m_menu->menu()->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::setContainer(Id containerId, Id groupId)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_menu, return);
|
|
||||||
ActionContainer *container = ActionManager::actionContainer(containerId);
|
|
||||||
container->addMenu(m_menu, groupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::addSeparator()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_menu, return);
|
|
||||||
m_menu->addSeparator();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MenuBuilder
|
// MenuBuilder
|
||||||
|
|
||||||
MenuBuilder::MenuBuilder(Id id)
|
MenuBuilder::MenuBuilder(Id id)
|
||||||
|
@@ -101,20 +101,6 @@ private:
|
|||||||
class ActionBuilderPrivate *d = nullptr;
|
class ActionBuilderPrivate *d = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT Menu
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Menu();
|
|
||||||
|
|
||||||
void setId(Utils::Id id);
|
|
||||||
void setTitle(const QString &title);
|
|
||||||
void setContainer(Utils::Id containerId, Utils::Id groupId = {});
|
|
||||||
void addSeparator();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ActionContainer *m_menu = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CORE_EXPORT MenuBuilder
|
class CORE_EXPORT MenuBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -334,9 +334,9 @@ BookmarkManager::BookmarkManager(QObject *parent)
|
|||||||
const Id bookmarkMenuId = "Bookmarks.Menu";
|
const Id bookmarkMenuId = "Bookmarks.Menu";
|
||||||
const Context editorManagerContext(Core::Constants::C_EDITORMANAGER);
|
const Context editorManagerContext(Core::Constants::C_EDITORMANAGER);
|
||||||
|
|
||||||
m_bookmarkMenu.setId(bookmarkMenuId);
|
MenuBuilder bookmarkMenu(bookmarkMenuId);
|
||||||
m_bookmarkMenu.setTitle(Tr::tr("&Bookmarks"));
|
bookmarkMenu.setTitle(Tr::tr("&Bookmarks"));
|
||||||
m_bookmarkMenu.setContainer(Core::Constants::M_TOOLS);
|
bookmarkMenu.addToContainer(Core::Constants::M_TOOLS);
|
||||||
|
|
||||||
connect(&m_editBookmarkAction, &QAction::triggered, this, [this] {
|
connect(&m_editBookmarkAction, &QAction::triggered, this, [this] {
|
||||||
editByFileAndLine(m_marginActionFileName, m_marginActionLineNumber);
|
editByFileAndLine(m_marginActionFileName, m_marginActionLineNumber);
|
||||||
@@ -378,7 +378,7 @@ BookmarkManager::BookmarkManager(QObject *parent)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_bookmarkMenu.addSeparator();
|
bookmarkMenu.addSeparator();
|
||||||
|
|
||||||
ActionBuilder prevAction(this, Constants::BOOKMARKS_PREV_ACTION);
|
ActionBuilder prevAction(this, Constants::BOOKMARKS_PREV_ACTION);
|
||||||
prevAction.setContext(editorManagerContext);
|
prevAction.setContext(editorManagerContext);
|
||||||
@@ -400,7 +400,7 @@ BookmarkManager::BookmarkManager(QObject *parent)
|
|||||||
nextAction.bindContextAction(&m_nextAction);
|
nextAction.bindContextAction(&m_nextAction);
|
||||||
nextAction.addOnTriggered(this, [this] { next(); });
|
nextAction.addOnTriggered(this, [this] { next(); });
|
||||||
|
|
||||||
m_bookmarkMenu.addSeparator();
|
bookmarkMenu.addSeparator();
|
||||||
|
|
||||||
ActionBuilder docPrevAction(this, "Bookmarks.PreviousDocument");
|
ActionBuilder docPrevAction(this, "Bookmarks.PreviousDocument");
|
||||||
docPrevAction.setContext(editorManagerContext);
|
docPrevAction.setContext(editorManagerContext);
|
||||||
|
@@ -97,7 +97,6 @@ private:
|
|||||||
|
|
||||||
QList<Bookmark *> m_bookmarksList;
|
QList<Bookmark *> m_bookmarksList;
|
||||||
QItemSelectionModel *m_selectionModel;
|
QItemSelectionModel *m_selectionModel;
|
||||||
Core::Menu m_bookmarkMenu;
|
|
||||||
|
|
||||||
QAction *m_toggleAction = nullptr;
|
QAction *m_toggleAction = nullptr;
|
||||||
QAction *m_editAction = nullptr;
|
QAction *m_editAction = nullptr;
|
||||||
|
Reference in New Issue
Block a user