From: vsv Date: Tue, 8 Sep 2015 10:01:54 +0000 (+0300) Subject: Create error label X-Git-Tag: V_1.4.0_beta4~81^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3f35df4cfef8b71de83a283b400193f35ee2277;p=modules%2Fshaper.git Create error label --- diff --git a/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp b/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp index 2f8260c91..2291bf1a0 100644 --- a/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp +++ b/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp @@ -11,6 +11,7 @@ #include #include +#include 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); +} diff --git a/src/ModuleBase/ModuleBase_WidgetErrorLabel.h b/src/ModuleBase/ModuleBase_WidgetErrorLabel.h index 882fe13dd..f17350901 100644 --- a/src/ModuleBase/ModuleBase_WidgetErrorLabel.h +++ b/src/ModuleBase/ModuleBase_WidgetErrorLabel.h @@ -25,12 +25,17 @@ Q_OBJECT /// \param theData the widget configuation. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute ModuleBase_WidgetErrorLabel(QWidget* theParent, const Config_WidgetAPI* theData, - const std::string& theParentId); + const std::string & theParentId); virtual ~ModuleBase_WidgetErrorLabel(); virtual bool restoreValueCustom(); + virtual bool focusTo(); + +protected: + bool eventFilter(QObject* theObj, QEvent* theEvent); + private: QString myDefaultStyle; };