Salome HOME
Issue #1852 In the Sketcher, replace all disabled real inputs by labels
[modules/shaper.git] / src / ModuleBase / ModuleBase_LabelValue.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_IWorkshop.cpp
4 // Created:     30 Nov 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #include <ModuleBase_LabelValue.h>
8 #include <ModuleBase_IconFactory.h>
9
10 #include <QHBoxLayout>
11 #include <QLabel>
12
13 ModuleBase_LabelValue::ModuleBase_LabelValue(QWidget* theParent, const QString& theText,
14                                              const QString& theToolTip, const QString& theIcon)
15 : QWidget(theParent)
16 {
17   QHBoxLayout* aLayout = new QHBoxLayout(this);
18   aLayout->setContentsMargins(2, 0, 0, 0);
19   aLayout->setSpacing(0);
20
21   myLabel = new QLabel(QString("%1 : ").arg(theText), this);
22   if (!theIcon.isEmpty()) {
23     myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(theIcon));
24     aLayout->setSpacing(4);
25   }
26   myLabel->setToolTip(!theToolTip.isEmpty() ? theToolTip : theText);
27   aLayout->addWidget(myLabel);
28
29   myLabelValue = new QLabel("", this);
30   aLayout->addWidget(myLabelValue, 1);
31
32   aLayout->addStretch(1);
33 }
34
35 ModuleBase_LabelValue::~ModuleBase_LabelValue()
36 {
37 }
38
39 void ModuleBase_LabelValue::setValue(const double theValue)
40 {
41   myValue = theValue;
42   myLabelValue->setText(QString::number(theValue));
43   myLabelValue->setToolTip(QString::number(theValue));
44 }