Salome HOME
Issue #2063 crash during trim: it was corrected with #2065 issue, TestTrimLine02...
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetAction.cpp
index f63455d18824431da9640463496ae2211e7239f9..a5ddbbe9660e1a88905316cee155c71e50a7d362 100755 (executable)
@@ -6,6 +6,7 @@
 
 #include <ModuleBase_WidgetAction.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_IconFactory.h>
 
 #include <Config_WidgetAPI.h>
 
 #include <QHBoxLayout>
 #include <QToolButton>
 
+#define DEFAULT_TOOL_TIP_WIDTH 300
+
 ModuleBase_WidgetAction::ModuleBase_WidgetAction(QWidget* theParent,
                                                  const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+: ModuleBase_ModelWidget(theParent, theData),
+  myActionID(attributeID())
 {
+  setAttributeID(""); // To prevent errors. Action not stored as attribtue in feature.
   QHBoxLayout* aControlLay = new QHBoxLayout(this);
   ModuleBase_Tools::adjustMargins(aControlLay);
 
-  myActionID = attributeID();
-  setAttributeID("");
-
-  QString aText = QString::fromStdString(theData->widgetLabel());
-  QString aToolTip = ModuleBase_Tools::wrapToolTipByWords(
-                        QString::fromStdString(theData->widgetTooltip()), myButton);
-
   myButton = new QToolButton(this);
+  QString aText = translate(theData->widgetLabel());
+  QString aToolTip = ModuleBase_Tools::wrapTextByWords(translate(theData->widgetTooltip()),
+                                                       myButton,
+                                                       DEFAULT_TOOL_TIP_WIDTH);
+
   myButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   aControlLay->addWidget(myButton);
 
   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
   if (!aLabelIcon.isEmpty())
-    myButton->setIcon(QPixmap(aLabelIcon));
+    myButton->setIcon(ModuleBase_IconFactory::loadPixmap(aLabelIcon));
   else
     myButton->setText(aText);
   myButton->setToolTip(aToolTip);
@@ -45,6 +48,11 @@ ModuleBase_WidgetAction::~ModuleBase_WidgetAction()
 {
 }
 
+bool ModuleBase_WidgetAction::focusTo()
+{
+  return false;
+}
+
 QList<QWidget*> ModuleBase_WidgetAction::getControls() const
 {
   QList<QWidget*> aList;