1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "ModuleBase_WidgetLabel.h"
23 #include <Config_WidgetAPI.h>
24 #include <Config_Keywords.h>
25 #include <ModuleBase_IconFactory.h>
26 #include <ModuleBase_Tools.h>
28 #include <ModelAPI_AttributeString.h>
31 #include <QVBoxLayout>
34 ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
35 const Config_WidgetAPI* theData)
36 : ModuleBase_ModelWidget(theParent, theData)
38 QString aText = translate(theData->getProperty("title"));
39 QString aLabelIcon = QString::fromStdString(theData->getProperty("icon"));
40 myLabel = new QLabel(aText, theParent);
41 if (!aLabelIcon.isEmpty()) {
42 myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon));
43 myLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
45 myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
47 myLabel->setWordWrap(true);
48 myLabel->setIndent(5);
49 myLabel->setContentsMargins(0,0,0,4);
51 QVBoxLayout* aLayout = new QVBoxLayout(this);
52 ModuleBase_Tools::zeroMargins(aLayout);
53 aLayout->addWidget(myLabel);
56 std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET).c_str();
57 if (!aStyleSheet.empty())
58 myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str()));
61 ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
65 QList<QWidget*> ModuleBase_WidgetLabel::getControls() const
67 return QList<QWidget*>();
70 bool ModuleBase_WidgetLabel::restoreValueCustom()
72 DataPtr aData = myFeature->data();
73 AttributeStringPtr aStrAttr = aData->string(attributeID());
77 aMsg = aStrAttr->value();
79 QString aText = ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
80 myLabel->setText(aText);
85 bool ModuleBase_WidgetLabel::focusTo()