##// END OF EJS Templates
Merge branch 'feature/ThreadFix' of...
Merge branch 'feature/ThreadFix' of https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/SCIQLOP-Initialisation into feature/ThreadFix Conflicts: core/src/Variable/Variable.cpp core/src/Variable/VariableCacheController.cpp core/src/Variable/VariableController.cpp gui/src/Visualization/VisualizationGraphHelper.cpp plugins/mockplugin/src/CosinusProvider.cpp

File last commit:

r322:e195db267c87
r369:65d06a34f5f1 merge
Show More
MenuBuilder.cpp
55 lines | 1.4 KiB | text/x-c | CppLexer
Alexandre Leroux
Moves MenuBuilder in a new class
r222 #include "Visualization/operations/MenuBuilder.h"
Q_LOGGING_CATEGORY(LOG_MenuBuilder, "MenuBuilder")
MenuBuilder::MenuBuilder(QMenu *menu)
{
if (menu) {
m_Menus.push(menu);
}
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No parent menu has been defined");
}
}
Alexandre Leroux
Adds icon for 'Plot' menu
r322 void MenuBuilder::addMenu(const QString &name, const QIcon &icon)
Alexandre Leroux
Moves MenuBuilder in a new class
r222 {
if (auto currMenu = currentMenu()) {
Alexandre Leroux
Adds icon for 'Plot' menu
r322 m_Menus.push(currMenu->addMenu(icon, name));
Alexandre Leroux
Moves MenuBuilder in a new class
r222 }
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No current menu to attach the new menu");
}
}
void MenuBuilder::addSeparator()
{
if (auto currMenu = currentMenu()) {
if (!currMenu->isEmpty()) {
currMenu->addSeparator();
}
}
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No current menu to attach the separator");
}
}
void MenuBuilder::closeMenu()
{
if (!m_Menus.isEmpty()) {
if (auto closedMenu = m_Menus.pop()) {
// Purge menu : if the closed menu has no entries, we remove it from its parent (the
// current menu)
if (auto currMenu = currentMenu()) {
if (closedMenu->isEmpty()) {
currMenu->removeAction(closedMenu->menuAction());
}
}
}
}
}
QMenu *MenuBuilder::currentMenu() const
{
return !m_Menus.isEmpty() ? m_Menus.top() : nullptr;
}