##// END OF EJS Templates
Disables 'plot' menu when variable data have not been loaded yet
Alexandre Leroux -
r404:40749dfba67d
parent child
Show More
@@ -25,11 +25,12 public:
25 25 void addAction(const QString &actionName, ActionFun actionFunction);
26 26
27 27 /**
28 * Adds a new menu to the current menu
28 * Adds a new menu to the current menu and returns it
29 29 * @param name the name of the menu
30 30 * @param icon the icon of the menu (can be null)
31 * @returns the created menu, nullptr if it couldn't be created
31 32 */
32 void addMenu(const QString &name, const QIcon &icon = {});
33 QMenu *addMenu(const QString &name, const QIcon &icon = {});
33 34
34 35 /// Adds a separator to the current menu. The separator is added only if the menu already
35 36 /// contains entries
@@ -21,7 +21,11 struct GenerateVariableMenuOperation::GenerateVariableMenuOperationPrivate {
21 21 void visitRootEnter()
22 22 {
23 23 // Creates the root menu
24 m_PlotMenuBuilder.addMenu(QObject::tr("Plot"), QIcon{":/icones/plot.png"});
24 if (auto plotMenu
25 = m_PlotMenuBuilder.addMenu(QObject::tr("Plot"), QIcon{":/icones/plot.png"})) {
26 plotMenu->setEnabled(m_Variable && m_Variable->dataSeries() != nullptr);
27 }
28
25 29 m_UnplotMenuBuilder.addMenu(QObject::tr("Unplot"), QIcon{":/icones/unplot.png"});
26 30 }
27 31
@@ -12,13 +12,16 MenuBuilder::MenuBuilder(QMenu *menu)
12 12 }
13 13 }
14 14
15 void MenuBuilder::addMenu(const QString &name, const QIcon &icon)
15 QMenu *MenuBuilder::addMenu(const QString &name, const QIcon &icon)
16 16 {
17 17 if (auto currMenu = currentMenu()) {
18 m_Menus.push(currMenu->addMenu(icon, name));
18 auto menu = currMenu->addMenu(icon, name);
19 m_Menus.push(menu);
20 return menu;
19 21 }
20 22 else {
21 23 qCCritical(LOG_MenuBuilder()) << QObject::tr("No current menu to attach the new menu");
24 return nullptr;
22 25 }
23 26 }
24 27
General Comments 0
You need to be logged in to leave comments. Login now