Salome HOME
#1109 Sketch entities preview red lines stayed in the viewer after Sketch is applyed.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetErrorLabel.cpp
index 2f8260c91fdb6bb197dae24cc9d807766f6a92db..2291bf1a0f9228b4ec7305c65f592543d0601fe4 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_AttributeString.h>
 
 #include <QLabel>
+#include <QEvent>
 
 ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent,
                                                const Config_WidgetAPI* theData,
@@ -18,6 +19,9 @@ ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent,
     : ModuleBase_WidgetLabel(theParent, theData, theParentId)
 {
   myDefaultStyle = myLabel->styleSheet();
+  myLabel->setContentsMargins(0,0,0,4);
+  myLabel->setWordWrap(true);
+  myLabel->installEventFilter(this);
 }
 
 ModuleBase_WidgetErrorLabel::~ModuleBase_WidgetErrorLabel()
@@ -37,7 +41,25 @@ bool ModuleBase_WidgetErrorLabel::restoreValueCustom()
     myLabel->setStyleSheet(myDefaultStyle);
   } else {
     myLabel->setText(aMsg.c_str());
-    myLabel->setStyleSheet("QLabel { background-color : red; color : white; }");
+    //myLabel->setStyleSheet("QLabel { color : red; font : italic }");
+    myLabel->setStyleSheet("QLabel { color : red; font : bold }");
+    //myLabel->setStyleSheet("QLabel { border: 1px solid red; }");
   }
   return true;
 }
+
+
+bool ModuleBase_WidgetErrorLabel::focusTo() 
+{ 
+  restoreValue();
+  return false; 
+}
+
+bool ModuleBase_WidgetErrorLabel::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+  if (theObj == myLabel) {
+    if (theEvent->type() == QEvent::Show)
+      restoreValue();
+  }
+  return ModuleBase_WidgetLabel::eventFilter(theObj, theEvent);
+}