1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetAction.cpp
4 // Created: 15 Apr 2016
5 // Author: Natalia Ermolaeva
7 #include <ModuleBase_WidgetAction.h>
8 #include <ModuleBase_Tools.h>
10 #include <Config_WidgetAPI.h>
13 #include <QHBoxLayout>
14 #include <QToolButton>
16 ModuleBase_WidgetAction::ModuleBase_WidgetAction(QWidget* theParent,
17 const Config_WidgetAPI* theData)
18 : ModuleBase_ModelWidget(theParent, theData)
20 QHBoxLayout* aControlLay = new QHBoxLayout(this);
21 ModuleBase_Tools::adjustMargins(aControlLay);
23 myActionID = attributeID();
26 QString aText = QString::fromStdString(theData->widgetLabel());
27 QString aToolTip = ModuleBase_Tools::wrapToolTipByWords(
28 QString::fromStdString(theData->widgetTooltip()), myButton);
30 myButton = new QToolButton(this);
31 myButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
32 aControlLay->addWidget(myButton);
34 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
35 if (!aLabelIcon.isEmpty())
36 myButton->setIcon(QPixmap(aLabelIcon));
38 myButton->setText(aText);
39 myButton->setToolTip(aToolTip);
41 connect(myButton, SIGNAL(clicked(bool)), this, SLOT(onActionClicked()));
44 ModuleBase_WidgetAction::~ModuleBase_WidgetAction()
48 QList<QWidget*> ModuleBase_WidgetAction::getControls() const
50 QList<QWidget*> aList;
51 aList.append(myButton);
55 bool ModuleBase_WidgetAction::storeValueCustom()
60 bool ModuleBase_WidgetAction::restoreValueCustom()
65 void ModuleBase_WidgetAction::onActionClicked()
67 if (myFeature->customAction(myActionID))
68 updateObject(myFeature);