7 #include "fwGuiQt/layoutManager/MenuLayoutManager.hpp" 9 #include "fwGuiQt/ActionCallback.hpp" 10 #include "fwGuiQt/container/QtMenuContainer.hpp" 11 #include "fwGuiQt/container/QtMenuItemContainer.hpp" 13 #include <fwGui/registry/macros.hpp> 15 #include <boost/assign/list_of.hpp> 16 #include <boost/lambda/lambda.hpp> 19 #include <QActionGroup> 25 ::fwGui::layoutManager::IMenuLayoutManager::REGISTRY_KEY );
29 namespace layoutManager
40 MenuLayoutManager::~MenuLayoutManager()
50 m_parent = ::fwGuiQt::container::QtMenuContainer::dynamicCast(parent);
51 SLM_ASSERT(
"dynamicCast fwMenu to QtMenuContainer failed", m_parent);
53 QMenu* menu = m_parent->getQtMenu();
55 QActionGroup* actionGroup = 0;
56 unsigned int menuItemIndex = 0;
59 ::fwGuiQt::container::QtMenuItemContainer::sptr menuItem = ::fwGuiQt::container::QtMenuItemContainer::New();
61 QAction* action = menu->addAction( QString::fromStdString(actionInfo.m_name) );
63 action->setSeparator(actionInfo.m_isSeparator);
65 if (!actionInfo.m_icon.empty())
67 QIcon icon(QString::fromStdString(actionInfo.m_icon.string()));
68 action->setIcon(icon);
70 if (actionInfo.m_type == ::fwGui::layoutManager::IMenuLayoutManager::QUIT)
72 action->setMenuRole(QAction::QuitRole);
74 else if (actionInfo.m_type == ::fwGui::layoutManager::IMenuLayoutManager::ABOUT)
76 action->setMenuRole(QAction::AboutRole);
80 action->setMenuRole(QAction::NoRole);
83 action->setCheckable(actionInfo.m_isCheckable || actionInfo.m_isRadio);
85 if (actionInfo.m_isRadio)
89 actionGroup =
new QActionGroup(menu);
91 actionGroup->addAction(action);
95 if( !actionInfo.m_shortcut.empty() )
97 action->setShortcut(QKeySequence(QString::fromStdString(actionInfo.m_shortcut)));
100 if (actionInfo.m_isMenu)
102 ::fwGuiQt::container::QtMenuContainer::sptr menu = ::fwGuiQt::container::QtMenuContainer::New();
103 QMenu* qtMenu =
new QMenu();
104 menu->setQtMenu(qtMenu);
105 action->setMenu(qtMenu);
109 menuItem->setQtMenuItem(action);
111 if(!actionInfo.m_isSeparator && !actionInfo.m_isMenu )
115 ::fwGui::IMenuItemCallback::sptr callback =
m_callbacks.at(menuItemIndex);
117 ::fwGuiQt::ActionCallback::sptr qtCallback = ::fwGuiQt::ActionCallback::dynamicCast(callback);
118 SLM_ASSERT(
"dynamicCast IMenuItemCallback to ActionCallback failed", qtCallback);
120 QObject::connect( action, SIGNAL(triggered(
bool)), qtCallback.get(), SLOT(executeQt(
bool)));
121 QObject::connect( action, SIGNAL(toggled(
bool)), qtCallback.get(), SLOT(checkQt(
bool)));
144 ::fwGuiQt::container::QtMenuItemContainer::sptr menuItemContainer =
145 ::fwGuiQt::container::QtMenuItemContainer::dynamicCast(fwMenuItem);
146 QAction* action = menuItemContainer->getQtMenuItem();
147 action->setVisible(isVisible);
154 ::fwGuiQt::container::QtMenuItemContainer::sptr menuItemContainer =
155 ::fwGuiQt::container::QtMenuItemContainer::dynamicCast(fwMenuItem);
156 QAction* action = menuItemContainer->getQtMenuItem();
157 action->setEnabled(isEnabled);
164 ::fwGuiQt::container::QtMenuItemContainer::sptr menuItemContainer =
165 ::fwGuiQt::container::QtMenuItemContainer::dynamicCast(fwMenuItem);
166 QAction* action = menuItemContainer->getQtMenuItem();
167 action->setChecked(isChecked);
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
The namespace fwGui contains the base interface for IHM services.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...