X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ActionsMgr.cpp;h=33f1826a792e99d7bcb183d94f35cddb37e78f2d;hb=b25922145a97fccf8d2613d0ef52a283d3ce0987;hp=851e3fef0adff9e5feb81c9e2eb35d4f5c9b7f49;hpb=3efd29f07fa128246690fd24a3439048b5e95878;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 851e3fef0..33f1826a7 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -142,9 +142,6 @@ void XGUI_ActionsMgr::updateOnViewSelection() foreach(QString aId, nestedCommands(aFeatureId)) { std::list aValidators; std::list > anArguments; - if (!anArguments.empty()) { - std::list firstArg = anArguments.front(); - } aFactory->validators(aId.toStdString(), aValidators, anArguments); std::list::iterator aValidator = aValidators.begin(); std::list >::iterator aValidatorArgs = anArguments.begin(); @@ -161,18 +158,28 @@ void XGUI_ActionsMgr::updateOnViewSelection() } } -QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence) +QKeySequence XGUI_ActionsMgr::registerShortcut(const QKeySequence& theKeySequence) { if (theKeySequence.isEmpty()) { return QKeySequence(); } - QKeySequence aResult(theKeySequence); - if (myShortcuts.contains(aResult)) { - QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence); + if (myShortcuts.contains(theKeySequence)) { + QString aMessage = tr("Shortcut %1 is already defined. Ignore."); + aMessage = aMessage.arg(theKeySequence.toString()); Events_Error::send(aMessage.toStdString()); return QKeySequence(); } - myShortcuts.append(aResult); + myShortcuts.append(theKeySequence); + return theKeySequence; +} + +QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence) +{ + if (theKeySequence.isEmpty()) { + return QKeySequence(); + } + QKeySequence aResult(theKeySequence); + registerShortcut(aResult); return aResult; } @@ -203,6 +210,51 @@ void XGUI_ActionsMgr::processEvent(const std::shared_ptr& theMes } } +QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QObject* theParent) +{ + QAction* aResult = NULL; + if (myOperationActions.contains(theId)) { + aResult = myOperationActions.value(theId); + if (theParent && aResult->parent() != theParent) { + aResult->setParent(theParent); + } + } else { + switch (theId) { + case Accept: + case AcceptAll: + aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent); + break; + case Abort: + case AbortAll: { + aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent); + if(theId == Abort) { + aResult->setShortcut(QKeySequence(Qt::Key_Escape)); + } + } + break; + case Help: + aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent); + break; + default: + break; + } + myOperationActions.insert(theId, aResult); + } + return aResult; +} + +ActionInfo XGUI_ActionsMgr::actionInfoById(const QString& theId) +{ + ActionInfo aResult; + if(myActions.contains(theId)) { + aResult.initFrom(myActions.value(theId)); + } else { + aResult.id = theId; + aResult.text = theId; + } + return aResult; +} + void XGUI_ActionsMgr::setAllEnabled(bool isEnabled) { foreach(QString eachAction, myActions.keys())