}
QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
- const bool isAddSeparator,
- bool isMenuAction, bool isToolAction)
+ const bool isAddSeparator)
{
return addFeature(theWBName,
theInfo.id,
theInfo.icon,
theInfo.shortcut,
theInfo.checkable,
- isAddSeparator, isMenuAction, isToolAction);
+ isAddSeparator);
}
//******************************************************
QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
const QString& theTitle, const QString& theTip,
const QIcon& theIcon, const QKeySequence& theKeys,
- bool isCheckable, const bool isAddSeparator,
- bool isMenuAction, bool isToolAction)
+ bool isCheckable, const bool isAddSeparator)
{
static QString aLastTool = "";
static int aNb = 0;
isCheckable);
aAction->setData(theId);
- if (isMenuAction) {
- int aWBMenu = createMenu(theWBName, -1, -1, 50/*10-Window, 1000 - Help*/);
- int aItemId = createMenu(aId, aWBMenu);
- if (isAddSeparator)
- createMenu(separator(), aWBMenu);
- }
- if (isToolAction) {
- int aWBTool = createTool(theWBName, theWBName);
- int aToolId = createTool(aId, aWBTool);
- if (isAddSeparator)
- createTool(separator(), aWBTool);
- }
+ int aWBMenu = createMenu(theWBName, -1, -1, 50/*10-Window, 1000 - Help*/);
+ int aItemId = createMenu(aId, aWBMenu);
+ if (isAddSeparator)
+ createMenu(separator(), aWBMenu);
+
+ int aWBTool = createTool(theWBName, theWBName);
+ int aToolId = createTool(aId, aWBTool);
+ if (isAddSeparator)
+ createTool(separator(), aWBTool);
+
return aAction;
}
QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
const ActionInfo& theInfo,
- const QList<QAction*>& theNestedActions,
- bool isMenuAction, bool isToolAction)
+ const QList<QAction*>& theNestedActions)
{
- int aId = myActionsList.size();
myActionsList.append(theInfo.id);
SUIT_Desktop* aDesk = application()->desktop();
SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
anAction->setShortcut(theInfo.shortcut);
anAction->setFont(theInfo.font);
- if (isMenuAction) {
- int aWBMenu = createMenu(theWBName, -1, -1, 50);
- int aItemId = createMenu(anAction, aWBMenu);
- }
- if (isToolAction) {
- int aWBTool = createTool(theWBName, theWBName);
- int aToolId = createTool(anAction, aWBTool);
- }
+ int aWBMenu = createMenu(theWBName, -1, -1, 50);
+ int aItemId = createMenu(anAction, aWBMenu);
+
+ int aWBTool = createTool(theWBName, theWBName);
+ int aToolId = createTool(anAction, aWBTool);
+
return anAction;
}
if (aCmd && myActionsList.contains(aCmd->data().toString()))
aActions.append(aCmd);
}
- return aActions;
-}
-//******************************************************
-QStringList SHAPERGUI::commandIdList() const
-{
- return myActionsList;
+ return aActions;
}
//******************************************************
return application()->desktop();
}
-//******************************************************
-QString SHAPERGUI::commandId(const QAction* theCmd) const
-{
- int aId = actionId(theCmd);
- if (aId < myActionsList.size())
- return myActionsList[aId];
- return QString();
-}
-
-//******************************************************
-QAction* SHAPERGUI::command(const QString& theId) const
-{
- int aId = myActionsList.indexOf(theId);
- if ((aId != -1) && (aId < myActionsList.size())) {
- return action(aId);
- }
- return 0;
-}
-
void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
const std::shared_ptr<Config_FeatureMessage>& theMessage)
{
virtual QAction* addFeature(const QString& theWBName, const QString& theId,
const QString& theTitle, const QString& theTip, const QIcon& theIcon,
const QKeySequence& theKeys = QKeySequence(),
- bool isCheckable = false, const bool isAddSeparator = false,
- bool isMenuAction = true, bool isToolAction = true);
+ bool isCheckable = false, const bool isAddSeparator = false);
//! Add feature (QAction) in the \a theWBName toolbar with given \a theInfo about action
virtual QAction* addFeature(const QString& theWBName,
- const ActionInfo& theInfo, const bool isAddSeparator,
- bool isMenuAction = true, bool isToolAction = true);
+ const ActionInfo& theInfo, const bool isAddSeparator);
/// Add a nested feature
/// \param theWBName a workbench name
/// \param theNestedActions a list of nested actions
virtual QAction* addFeatureOfNested(const QString& theWBName,
const ActionInfo& theInfo,
- const QList<QAction*>& theNestedActions,
- bool isMenuAction = true, bool isToolAction = true);
+ const QList<QAction*>& theNestedActions);
//! Returns true if the feature action is a nested action, in other words,
//! it is created by addNestedFeature().
virtual QMainWindow* desktop() const;
- virtual QString commandId(const QAction* theCmd) const;
-
- virtual QAction* command(const QString& theId) const;
-
- //! Stores XML information for the feature kind
+ //! Stores XML information for the feature kind
//! \param theFeatureId a feature kind
//! \param theMessage a container of the feature XML properties
virtual void setFeatureInfo(const QString& theFeatureId,
//! Returns list of defined actions (just by SHAPER module)
virtual QList<QAction*> commandList() const;
- //! Returns list of Ids of defined actions (just by SHAPER module)
- virtual QStringList commandIdList() const;
-
/// Redefinition of virtual function.
/// \param theClient name of pop-up client
/// \param theMenu popup menu instance
/// List of registered actions
QStringList myActionsList;
+ /// List of registered nested actions
+ QStringList myNestedActionsList;
+
/// Reference to workshop
XGUI_Workshop* myWorkshop;
#include <QFrame>
#include <QHBoxLayout>
#include <QToolButton>
+#include <QToolBar>
#include <QEvent>
SHAPERGUI_NestedButton::SHAPERGUI_NestedButton(QObject* theParent,
QWidget * SHAPERGUI_NestedButton::createWidget(QWidget * theParent)
{
+ // the action has widget only in tool bar, in menu bar, the default
+ // action presentation is shown
+ QToolBar* aToolBar = dynamic_cast<QToolBar*>(theParent);
+ if (!aToolBar)
+ return 0;
+
myButtonFrame = new QFrame(theParent);
QHBoxLayout* aBoxLay = new QHBoxLayout(myButtonFrame);
aBoxLay->setContentsMargins(2, 0, 0, 0);
void XGUI_ActionsMgr::updateCommandsStatus()
{
- setAllEnabled(true);
+ setAllEnabled();
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
if (aSelection->getSelected(ModuleBase_ISelection::Viewer).size() > 0)
updateOnViewSelection();
return aResult;
}
-void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+void XGUI_ActionsMgr::setAllEnabled()
{
foreach(QString eachAction, myActions.keys()) {
- setActionEnabled(eachAction, isEnabled);
+ if (myActions.contains(eachAction)) {
+ QAction* aAction = myActions[eachAction];
+ aAction->setEnabled(true);
+ }
}
}
//! Updates actions according to current selection in the viewer
void updateOnViewSelection();
- //! Sets all actions to isEnabled state.
- void setAllEnabled(bool isEnabled);
+ //! Sets all actions to enabled state.
+ void setAllEnabled();
//! Sets all nested actions to isEnabled state for the command with given ID.
//! If ID is empty - all nested actions will be affected.
aNestedActList << anAction;
}
anAction = aSalomeConnector->addFeatureOfNested(theWchName.c_str(), aFeatureInfo,
- aNestedActList, false, true);
- QAction* aMenuAction = aSalomeConnector->addFeature(theWchName.c_str(), aFeatureInfo,
- aUseSeparator, true, false);
- myWorkshop->module()->actionCreated(aMenuAction);
+ aNestedActList);
}
else {
//Issue #650: in the SALOME mode the tooltip should be same as text
//! \param isCheckable - is checkable or not
//! \param theKeys - hot keys
//! \param isAddSeparator boolean flag about adding separator after the action
- //! \param isMenuAction boolean flag about adding the action to application menu bar
- //! \param isToolAction boolean flag about adding the action to application tool bar
//! returns created action
virtual QAction* addFeature(const QString& theWBName, const QString& theId,
const QString& theTitle, const QString& theTip, const QIcon& theIcon,
- const QKeySequence& theKeys, bool isCheckable, const bool isAddSeparator,
- bool isMenuAction = true, bool isToolAction = true) = 0;
+ const QKeySequence& theKeys, bool isCheckable, const bool isAddSeparator) = 0;
//! Creates a feature (command) in SALOME desktop
//! \param theWBName - name of toolbar (workbench)
//! \param theInfo - information about action (icon, text, etc)
//! \param isAddSeparator boolean flag about adding separator after the action
- //! \param isMenuAction boolean flag about adding the action to application menu bar
- //! \param isToolAction boolean flag about adding the action to application tool bar
virtual QAction* addFeature(const QString& theWBName,
- const ActionInfo& theInfo, const bool isAddSeparator,
- bool isMenuAction = true, bool isToolAction = true) = 0;
+ const ActionInfo& theInfo, const bool isAddSeparator) = 0;
//! Creates a feature (command) in SALOME desktop
//! \param theWBName - name of toolbar (workbench)
//! \param theInfo - information about action (icon, text, etc)
//! \param theNestedActions a list of nested actions
- //! \param isMenuAction boolean flag about adding the action to application menu bar
- //! \param isToolAction boolean flag about adding the action to application tool bar
virtual QAction* addFeatureOfNested(const QString& theWBName,
const ActionInfo& theInfo,
- const QList<QAction*>& theNestedActions,
- bool isMenuAction = true, bool isToolAction = true) = 0;
+ const QList<QAction*>& theNestedActions) = 0;
//! Returns true if the feature action is a nested action, in other words,
//! it is created by addFeatureOfNested().
//! Returns desktop window of SALOME
virtual QMainWindow* desktop() const = 0;
- //! Returns command string Id by QAction instance
- virtual QString commandId(const QAction* theCmd) const = 0;
-
- //! Returns QAction instance by command string Id
- virtual QAction* command(const QString& theId) const = 0;
-
//! Returns list of defined actions (just by SHAPER module)
virtual QList<QAction*> commandList() const = 0;
- //! Returns list of Ids of defined actions (just by NewGeom module)
- virtual QStringList commandIdList() const = 0;
-
//! Stores XML information for the feature kind
//! \param theFeatureId a feature kind
//! \param theMessage a container of the feature XML properties