From: nds Date: Tue, 24 May 2016 07:56:22 +0000 (+0300) Subject: Issue #1015: The validate icon must be greyed and inactive instead of red and active X-Git-Tag: V_2.3.1~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56d964e85b8ac63b2c4fb36426fa150d52afa998;p=modules%2Fshaper.git Issue #1015: The validate icon must be greyed and inactive instead of red and active Actions contain information for Status bar --- diff --git a/src/ModuleBase/ModuleBase_ActionInfo.cpp b/src/ModuleBase/ModuleBase_ActionInfo.cpp index 7966f3461..b9540f26d 100644 --- a/src/ModuleBase/ModuleBase_ActionInfo.cpp +++ b/src/ModuleBase/ModuleBase_ActionInfo.cpp @@ -78,7 +78,7 @@ QAction* ModuleBase_ActionInfo::makeAction(QObject* theParent) aResult->setVisible(visible); aResult->setIconText(iconText); aResult->setToolTip(toolTip); - // aResult->setStatusTip(statusTip); + aResult->setStatusTip(toolTip); // aResult->setWhatsThis(whatsThis); aResult->setShortcut(shortcut); aResult->setFont(font); diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 70c4ae827..ec8d04906 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -103,6 +103,10 @@ Q_OBJECT //! \param theValues a list of presentations virtual void setSelected(const QList>& theValues) = 0; + //! Shows the message in the status bar + //! \param theMessage a message + virtual void setStatusBarMessage(const QString& theMessage) = 0; + /// Update of commands status virtual void updateCommandStatus() = 0; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index a3a62f4e2..822640eac 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -227,6 +228,21 @@ void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue) theSpin->blockSignals(isBlocked); } +QAction* createAction(const QIcon& theIcon, const QString& theText, + QObject* theParent, const QObject* theReceiver, + const char* theMember, const QString& theToolTip, + const QString& theStatusTip) +{ + QAction* anAction = new QAction(theIcon, theText, theParent); + anAction->setToolTip(theToolTip.isEmpty() ? theText : theToolTip); + anAction->setStatusTip(!theStatusTip.isEmpty() ? theStatusTip : + (!theToolTip.isEmpty() ? theToolTip : theText)); + if (theReceiver) + QObject::connect(anAction, SIGNAL(triggered(bool)), theReceiver, theMember); + + return anAction; +} + QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { QString aFeatureStr = "feature"; diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index d053d279b..b50ec66a1 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -19,6 +19,7 @@ #include +#include #include #include @@ -26,6 +27,7 @@ class QWidget; class QLayout; class QDoubleSpinBox; +class QAction; class ModuleBase_ParamIntSpinBox; class ModuleBase_ParamSpinBox; class ModuleBase_IWorkshop; @@ -118,6 +120,20 @@ MODULEBASE_EXPORT void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int the /// \param theText a new value MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText); +/// Creates an action filled with the parameters +/// \param theIcon an action icon +/// \param theText an icon text +/// \param theParent an action object +/// \param theReceiver an object to process action triggered signal +/// \param theMember a slot to process the action triggered signal +/// \param theToolTip an action tool tip information, if empty the text is used +/// \param theStatusTip an action status tip information, if empty the text is used +MODULEBASE_EXPORT QAction* createAction(const QIcon& theIcon, const QString& theText, + QObject* theParent, const QObject* theReceiver = 0, + const char* theMember = "", + const QString& theToolTip = QString(), + const QString& theStatusTip = QString()); + /// Converts the object to the feature or a result and generate information string /// \param theObj an object /// \param isUseAttributesInfo a flag whether the attribute values information is used diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index a651aa185..f4f4be128 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -143,15 +143,15 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen //this->setLayout(aMainLay); connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged())); - myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this); + myCopyAction = ModuleBase_Tools::createAction(QIcon(":pictures/copy.png"), tr("Copy"), this, + this, SLOT(onCopyItem())); myCopyAction->setShortcut(QKeySequence::Copy); myCopyAction->setEnabled(false); - connect(myCopyAction, SIGNAL(triggered(bool)), SLOT(onCopyItem())); myListControl->addAction(myCopyAction); - myDeleteAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this); + myDeleteAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"), this, + this, SLOT(onDeleteItem())); myDeleteAction->setEnabled(false); - connect(myDeleteAction, SIGNAL(triggered(bool)), SLOT(onDeleteItem())); myListControl->addAction(myDeleteAction); myListControl->setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 96dbb9cbc..4dea8c2f1 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -72,21 +73,21 @@ void PartSet_MenuMgr::createActions() { QAction* aAction; - aAction = new QAction(tr("Auxiliary"), this); + aAction = ModuleBase_Tools::createAction(QIcon(), tr("Auxiliary"), this); aAction->setCheckable(true); addAction("AUXILIARY_CMD", aAction); - aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePart(bool))); + aAction = ModuleBase_Tools::createAction(QIcon(":icons/activate.png"), tr("Activate"), this, + this, SLOT(onActivatePart(bool))); myActions["ACTIVATE_PART_CMD"] = aAction; // Activate PartSet - aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePartSet(bool))); + aAction = ModuleBase_Tools::createAction(QIcon(":icons/activate.png"), tr("Activate"), this, + this, SLOT(onActivatePartSet(bool))); myActions["ACTIVATE_PARTSET_CMD"] = aAction; - aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool))); + aAction = ModuleBase_Tools::createAction(QIcon(":icons/edit.png"), tr("Edit..."), this, + this, SLOT(onEdit(bool))); myActions["EDIT_CMD"] = aAction; } diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index f1d5e49b1..4af899ee9 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -229,27 +230,27 @@ QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QOb switch (theId) { case Accept: case AcceptAll: { - aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent); - aResult->setToolTip("Apply"); + aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_ok.png"), + "", /*empty to show error*/, theParent); } break; case Abort: case AbortAll: { - aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent); - aResult->setToolTip("Cancel"); + aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_cancel.png"), "Cancel", + theParent); if (theId == Abort) { aResult->setShortcut(QKeySequence(Qt::Key_Escape)); } } break; case Help: { - aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent); - aResult->setToolTip("Help"); + aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_help.png"), "Help", + theParent); } break; case Preview: { - aResult = new QAction("See preview", theParent); - aResult->setToolTip("Compute preview"); + aResult = ModuleBase_Tools::createAction(QIcon(), tr("See preview"), theParent, 0, 0, "Compute preview"); + aResult->setStatusTip(aResult->toolTip()); } break; default: diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index c9505229a..72a3bc975 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -54,7 +54,6 @@ XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorksh XGUI_ErrorMgr::~XGUI_ErrorMgr() { - } void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) @@ -64,8 +63,6 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) ModuleBase_OperationFeature* aFOperation = dynamic_cast (workshop()->operationMgr()->currentOperation()); if (aFOperation && aFOperation->feature() == theFeature) { - QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); - ModuleBase_ModelWidget* anActiveWidget = activeWidget(); bool isApplyEnabledByActiveWidget = false; if (anActiveWidget) @@ -80,8 +77,9 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) if (anError.isEmpty()) anError = aWidgetError; } - updateActionState(anOkAction, anError); + updateAcceptActionState(anError); updateToolTip(anActiveWidget, aWidgetError); + myWorkshop->setStatusBarMessage(anError); #ifdef DEBUG_ERROR_STATE QString anInfo = ModuleBase_Tools::objectInfo(theFeature); @@ -124,12 +122,15 @@ bool XGUI_ErrorMgr::isApplyEnabled() const return isEnabled; } -void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theError) +void XGUI_ErrorMgr::updateAcceptActionState(const QString& theError) { + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); + QAction* anAcceptAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + bool anEnabled = theError.isEmpty(); - theAction->setEnabled(anEnabled); - theAction->setToolTip(anEnabled ? myAcceptToolTip : theError); + anAcceptAction->setEnabled(anEnabled); + anAcceptAction->setToolTip(anEnabled ? myAcceptToolTip : theError); // some operations have no property panel, so it is important to check that it is not null if (myPropertyPanel) { // update controls error information diff --git a/src/XGUI/XGUI_ErrorMgr.h b/src/XGUI/XGUI_ErrorMgr.h index 23012267b..4b1ca159c 100644 --- a/src/XGUI/XGUI_ErrorMgr.h +++ b/src/XGUI/XGUI_ErrorMgr.h @@ -52,11 +52,11 @@ protected slots: virtual void onWidgetChanged(); private: - /// It disables the action if the error message is not empty + /// It disables the propety panel Accept action if the error message is not empty /// The message is set to the header tool tip. /// \param theAction an action to be changed /// \param theError an error state - void updateActionState(QAction* theAction, const QString& theError); + void updateAcceptActionState(const QString& theError); /// It updates the tool tip of the widget controls according to the widget error /// \param theWidget a widget diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 614428a48..326117bab 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -118,6 +118,19 @@ void XGUI_ModuleConnector::setSelected(const QList& the } } +#include +#include +void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage) +{ +#ifdef HAVE_SALOME + //return myWorkshop->salomeConnector()->featureInfo(theId); +#else + QMainWindow* aDesktop = desktop(); + aDesktop->statusBar()->showMessage(theMessage); + +#endif +} + bool XGUI_ModuleConnector::canStartOperation(QString theId) { return myWorkshop->operationMgr()->canStartOperation(theId); diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 6fc335412..0afbe49ac 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -81,6 +81,10 @@ Q_OBJECT //! If the list is empty then selection will be cleared virtual void setSelected(const QList>& theValues); + //! Shows the message in the status bar + //! \param theMessage a message + virtual void setStatusBarMessage(const QString& theMessage); + /// Update of commands status virtual void updateCommandStatus();