X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=ded693fcf6894aace0670d1b8a44ae95c3594fae;hb=d77e6639d89abdcbf327cc73d13bf955064b8524;hp=b6ba2aa7101640473a22f93e0e2022c20c4173a2;hpb=a4f48873f6c5861a7ddbad5a6bdbbfb924b8a7b9;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index b6ba2aa71..ded693fcf 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -268,7 +269,7 @@ void XGUI_Workshop::initMenu() aCommand = aGroup->addFeature(aUndoId, tr("Undo"), tr("Undo last command"), QIcon(":pictures/undo.png"), QKeySequence::Undo); aCommand->connectTo(this, SLOT(onUndo())); - QToolButton* aUndoButton = qobject_cast(aGroup->widget(aUndoId)); + AppElements_Button* aUndoButton = qobject_cast(aGroup->widget(aUndoId)); addHistoryMenu(aUndoButton, SIGNAL(updateUndoHistory(const QList&)), SLOT(onUndo(int))); @@ -277,7 +278,7 @@ void XGUI_Workshop::initMenu() aCommand = aGroup->addFeature(aRedoId, tr("Redo"), tr("Redo last command"), QIcon(":pictures/redo.png"), QKeySequence::Redo); aCommand->connectTo(this, SLOT(onRedo())); - QToolButton* aRedoButton = qobject_cast(aGroup->widget(aRedoId)); + AppElements_Button* aRedoButton = qobject_cast(aGroup->widget(aRedoId)); addHistoryMenu(aRedoButton, SIGNAL(updateRedoHistory(const QList&)), SLOT(onRedo(int))); @@ -722,8 +723,26 @@ void XGUI_Workshop::addFeature(const std::shared_ptr& the aFeatureInfo.shortcut = aHotKey; } // Create feature... - AppElements_Command* aCommand = aGroup->addFeature(aFeatureInfo, aDocKind); - aCommand->setNestedCommands(aNestedFeatures); + AppElements_Command* aCommand = aGroup->addFeature(aFeatureInfo, + aDocKind, + aNestedFeatures); + // Enrich created button with accept/abort buttons if necessary + AppElements_Button* aButton = aCommand->button(); + if (aButton->isColumnButton()) { + QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested()); + QList anActList; + if (aNestedActions.contains("accept")) { + QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, aButton); + connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(commitAllOperations())); + anActList << anAction; + } + if (aNestedActions.contains("abort")) { + QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, aButton); + connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(abortAllOperations())); + anActList << anAction; + } + aButton->setAdditionalButtons(anActList); + } myActionsMgr->addCommand(aCommand); myModule->actionCreated(aCommand); } @@ -1058,11 +1077,10 @@ void XGUI_Workshop::updateCommandStatus() // Enable all commands aCmd->setEnabled(true); } + aUndoCmd->setEnabled(myModule->canUndo()); aRedoCmd->setEnabled(myModule->canRedo()); - updateHistory(); - } else { foreach(QAction* aCmd, aCommands) { QString aId = aCmd->data().toString(); @@ -1081,28 +1099,12 @@ void XGUI_Workshop::updateCommandStatus() void XGUI_Workshop::updateHistory() { std::list aUndoList = ModelAPI_Session::get()->undoList(); - std::list::iterator it = aUndoList.begin(); - QList aUndoRes; - for ( ; it != aUndoList.end(); it++) { - QString anId = QString::fromStdString(*it); - QIcon aIcon; - if (myIcons.contains(anId)) - aIcon = QIcon(myIcons[anId]); - aUndoRes << ActionInfo(aIcon, anId); - } + QList aUndoRes = processHistoryList(aUndoList); emit updateUndoHistory(aUndoRes); std::list aRedoList = ModelAPI_Session::get()->redoList(); - it = aRedoList.begin(); - QList aRedoRes; - for ( ; it != aRedoList.end(); it++) { - QString anId = QString::fromStdString(*it); - QIcon aIcon; - if (myIcons.contains(anId)) - aIcon = QIcon(myIcons[anId]); - aRedoRes << ActionInfo(aIcon, anId); - } - emit updateRedoHistory(aUndoRes); + QList aRedoRes = processHistoryList(aRedoList); + emit updateRedoHistory(aRedoRes); } //****************************************************** @@ -1133,24 +1135,26 @@ void XGUI_Workshop::createDockWidgets() QDockWidget* aObjDock = createObjectBrowser(aDesktop); aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock); myPropertyPanel = new XGUI_PropertyPanel(aDesktop); + myPropertyPanel->setupActions(myActionsMgr); myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - - connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets())); - aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel); hidePropertyPanel(); ///tabifyDockWidget(aObjDock, myPropertyPanel); myPropertyPanel->installEventFilter(myOperationMgr); - QPushButton* aOkBtn = myPropertyPanel->findChild(PROP_PANEL_OK); - connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation())); - QPushButton* aCancelBtn = myPropertyPanel->findChild(PROP_PANEL_CANCEL); - connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation())); - connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr, - SLOT(onKeyReleased(QKeyEvent*))); - connect(myOperationMgr, SIGNAL(applyEnableChanged(bool)), myPropertyPanel, - SLOT(setAcceptEnabled(bool))); + QAction* aOkAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + connect(aOkAct, SIGNAL(triggered()), myOperationMgr, SLOT(onCommitOperation())); + QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); + connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); + connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets())); + connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), + myOperationMgr, SLOT(onKeyReleased(QKeyEvent*))); + connect(myOperationMgr, SIGNAL(validationStateChanged(bool)), + aOkAct, SLOT(setEnabled(bool))); + QAction* aAcceptAllAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll); + connect(myOperationMgr, SIGNAL(nestedStateChanged(bool)), + aAcceptAllAct, SLOT(setEnabled(bool))); } @@ -1324,7 +1328,15 @@ These features will be deleted also. Would you like to continue?")).arg(aNames), } SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->startOperation("DeleteObjects"); + QString aDescription = tr("Delete %1"); + QStringList aObjectNames; + foreach (ObjectPtr aObj, theList) { + if (!aObj->data().get()) + continue; + aObjectNames << QString::fromStdString(aObj->data()->name()); + } + aDescription = aDescription.arg(aObjectNames.join(", ")); + aMgr->startOperation(aDescription.toStdString()); std::set::const_iterator anIt = aRefFeatures.begin(), aLast = aRefFeatures.end(); for (; anIt != aLast; anIt++) { @@ -1352,6 +1364,7 @@ These features will be deleted also. Would you like to continue?")).arg(aNames), myDisplayer->updateViewer(); aMgr->finishOperation(); + updateCommandStatus(); } //************************************************************** @@ -1466,5 +1479,23 @@ void XGUI_Workshop::addHistoryMenu(QObject* theObject, const char* theSignal, co } connect(this, theSignal, aMenu, SLOT(setHistory(const QList&))); connect(aMenu, SIGNAL(actionSelected(int)), this, theSlot); +} +QList XGUI_Workshop::processHistoryList(const std::list& theList) const +{ + QList aResult; + std::list::const_iterator it = theList.cbegin(); + for (; it != theList.cend(); it++) { + QString anId = QString::fromStdString(*it); + bool isEditing = anId.endsWith(ModuleBase_Operation::EditSuffix()); + if (isEditing) { + anId.chop(ModuleBase_Operation::EditSuffix().size()); + } + ActionInfo anInfo = myActionsMgr->actionInfoById(anId); + if (isEditing) { + anInfo.text = anInfo.text.prepend("Modify "); + } + aResult << anInfo; + } + return aResult; }