Salome HOME
#1150 Tab buttons problems
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index d33467c7e883cacdbf53e1a68fb6b07c31a90518..6cbbe1c80c3361ba65c7009a2b57c7ac62f63f77 100755 (executable)
@@ -5,6 +5,8 @@
 // Author:      Vitaly Smetannikov
 
 #include "ModuleBase_Tools.h"
+
+#include <ModuleBase_ParamIntSpinBox.h>
 #include <ModuleBase_ParamSpinBox.h>
 
 #include <ModelAPI_Attribute.h>
@@ -29,6 +31,8 @@
 #include <QPainter>
 #include <QBitmap>
 #include <QDoubleSpinBox>
+#include <QGraphicsDropShadowEffect>
+#include <QColor>
 
 #include <sstream>
 
@@ -91,6 +95,23 @@ void setFocus(QWidget* theWidget, const QString& theInfo)
 #endif
 }
 
+void setShadowEffect(QWidget* theWidget, const bool isSetEffect)
+{
+  if (isSetEffect) {
+    QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
+    aGlowEffect->setOffset(.0);
+    aGlowEffect->setBlurRadius(10.0);
+    aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
+    theWidget->setGraphicsEffect(aGlowEffect);
+  }
+  else {
+    QGraphicsEffect* anEffect = theWidget->graphicsEffect();
+    if(anEffect)
+    anEffect->deleteLater();
+    theWidget->setGraphicsEffect(NULL);
+  }
+}
+
 QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
 {
   QImage anIcon(theIcon);
@@ -171,6 +192,26 @@ void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
   theSpin->blockSignals(isBlocked);
 }
 
+void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText)
+{
+  // In order to avoid extra text setting because it will
+  // reset cursor position in control
+  if (theSpin->text() == theText)
+    return;
+  bool isBlocked = theSpin->blockSignals(true);
+  theSpin->setText(theText);
+  theSpin->blockSignals(isBlocked);
+}
+
+void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue)
+{
+  if (theSpin->value() == theValue)
+    return;
+  bool isBlocked = theSpin->blockSignals(true);
+  theSpin->setValue(theValue);
+  theSpin->blockSignals(isBlocked);
+}
+
 QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
 {
   QString aFeatureStr = "feature";