X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetChoice.cpp;h=5797e7cc8de201b0882d34a9a37610fe44bdf8cd;hb=d0e479afb535cd9d6542d53302428a5c8e99485f;hp=d837c4f38b10efcf2ef81d38730bbaa74ec291db;hpb=502928b6299e5e83a663d6d3ba9d7d7ace247cb0;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index d837c4f38..5797e7cc8 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -5,7 +5,8 @@ // Author: Vitaly Smetannikov #include "ModuleBase_WidgetChoice.h" -#include +#include "ModuleBase_Tools.h" +#include "ModuleBase_IconFactory.h" #include #include @@ -22,9 +23,8 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) - : ModuleBase_ModelWidget(theParent, theData, theParentId), myCombo(0), myButtons(0) + const Config_WidgetAPI* theData) +: ModuleBase_ModelWidget(theParent, theData), myCombo(0), myButtons(0) { QHBoxLayout* aLayout = new QHBoxLayout(this); ModuleBase_Tools::adjustMargins(aLayout); @@ -34,6 +34,9 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, std::string aTypes = theData->getProperty("string_list"); QStringList aList = QString(aTypes.c_str()).split(' '); + if (theData->getBooleanAttribute("use_in_title", false)) + myButtonTitles = QString(aTypes.c_str()).split(" "); + // Widget type can be combobox or radiobuttons std::string aWgtType = theData->getProperty("widget_type"); if ((aWgtType.length() > 0) && (aWgtType == "radiobuttons")) { @@ -60,7 +63,7 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, aBtn->setCheckable(true); aBtn->setToolTip(aBtnTxt); - QPixmap aIcon(aIconList.at(aId)); + QPixmap aIcon = ModuleBase_IconFactory::loadPixmap(aIconList.at(aId)); aBtn->setIcon(aIcon); aBtn->setIconSize(aIcon.size()); @@ -78,11 +81,10 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, } myButtons->button(0)->setChecked(true); connect(myButtons, SIGNAL(buttonClicked(int)), this, SLOT(onCurrentIndexChanged(int))); - connect(myButtons, SIGNAL(buttonClicked(int)), this, SIGNAL(itemSelected(int))); } else { myLabel = new QLabel(aLabelText, this); if (!aLabelIcon.isEmpty()) - myLabel->setPixmap(QPixmap(aLabelIcon)); + myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon)); aLayout->addWidget(myLabel); std::string aToolstr = theData->widgetTooltip(); @@ -96,7 +98,6 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, myCombo->addItems(aList); connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); - connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(itemSelected(int))); } } @@ -104,7 +105,7 @@ ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice() { } -bool ModuleBase_WidgetChoice::storeValueCustom() const +bool ModuleBase_WidgetChoice::storeValueCustom() { DataPtr aData = myFeature->data(); std::shared_ptr aIntAttr = aData->integer(attributeID()); @@ -131,7 +132,7 @@ bool ModuleBase_WidgetChoice::restoreValueCustom() bool isBlocked = myButtons->blockSignals(true); myButtons->button(aIntAttr->value())->setChecked(true); myButtons->blockSignals(isBlocked); - emit itemSelected(aIntAttr->value()); + emit itemSelected(this, aIntAttr->value()); } } return true; @@ -159,9 +160,19 @@ QList ModuleBase_WidgetChoice::getControls() const return aControls; } +QString ModuleBase_WidgetChoice::getPropertyPanelTitle(int theIndex) +{ + QString aTitle; + if (myButtonTitles.length() > theIndex) + aTitle = tr(myButtonTitles[theIndex].toStdString().c_str()); + return aTitle; +} + void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex) { emit valuesChanged(); // Don't transfer focus // emit focusOutWidget(this); + + emit itemSelected(this, theIndex); }