]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1015: The validate icon must be greyed and inactive instead of red and active
authornds <nds@opencascade.com>
Tue, 24 May 2016 07:56:22 +0000 (10:56 +0300)
committernds <nds@opencascade.com>
Tue, 24 May 2016 07:56:50 +0000 (10:56 +0300)
Actions contain information for Status bar

src/ModuleBase/ModuleBase_ActionInfo.cpp
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_MenuMgr.cpp
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ErrorMgr.cpp
src/XGUI/XGUI_ErrorMgr.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h

index 7966f3461b86b5ee28f88a46406507dbf4e35b3a..b9540f26dfd27cc7a5dc7d5e0f82541bd4504e8b 100644 (file)
@@ -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);
index 70c4ae8276dade8d1447f7928b3d3a30e7b02d8d..ec8d04906ea780fab13d6a487f92f3cff3784e9a 100644 (file)
@@ -103,6 +103,10 @@ Q_OBJECT
   //! \param theValues a list of presentations
   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& 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;
 
index a3a62f4e264a3df4d75f0b8b14028803c37cd453..822640eac33ff7484bc693686c92d47e9bfdae5c 100755 (executable)
@@ -47,6 +47,7 @@
 #include <QColor>
 #include <QApplication>
 #include <QMessageBox>
+#include <QAction>
 
 #include <sstream>
 #include <string>
@@ -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";
index d053d279b6b39cb62692c9cba48e2426ab30fed0..b50ec66a1116581d3bef2dfe9b229f183da16085 100755 (executable)
@@ -19,6 +19,7 @@
 
 #include <Quantity_Color.hxx>
 
+#include <QIcon>
 #include <QPixmap>
 
 #include <map>
@@ -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
index a651aa185eb0372540bf230277e7dcec2a3bd44f..f4f4be12857a5012b21303e22be856d915062ca6 100755 (executable)
@@ -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);
index 96dbb9cbcdcc5dfd99b9b00d0cd705010a0494c2..4dea8c2f1b32dbd1cf85a85e4ae93ace0bd37e39 100644 (file)
@@ -25,6 +25,7 @@
 #include <ModuleBase_OperationAction.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
@@ -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;
 }
 
index f1d5e49b15ddf7ab4de2dfc415746b13f76e4823..4af899ee97fc4aff3c5b0b229e2af86d2ef7bf7e 100644 (file)
@@ -20,6 +20,7 @@
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_Tools.h>
 
 
 #include <QAction>
@@ -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:
index c9505229abbb00a4eeccf1a6556a3865185d4c22..72a3bc97526c2dbcd5952be8bc2386a43a09c6bf 100644 (file)
@@ -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<ModuleBase_OperationFeature*>
                                       (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
index 23012267b30a52f781cadcbc07c71b12d27f05b5..4b1ca159c984953d247cde182dda7cd4fc32faa1 100644 (file)
@@ -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
index 614428a4851a54d4762a3e231d92a6a728d35ec8..326117bab4f249d6c5c7c04ad19c9837959d643a 100644 (file)
@@ -118,6 +118,19 @@ void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& the
   }    
 }
 
+#include <QMainWindow>
+#include <QStatusBar>
+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);
index 6fc335412048cec2f0445f3057b1f509607bc8d9..0afbe49ac09544e65716e0f9dfb52b1f45599629 100644 (file)
@@ -81,6 +81,10 @@ Q_OBJECT
   //! If the list is empty then selection will be cleared
   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& 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();