+ foreach(QString aType, QString(aTypes.c_str()).split(' ')) {
+ aList.append(translate(aType.toStdString()));
+ }
+ if (aTypes.empty()) {
+ myStringListAttribute = theData->getProperty("string_list_attribute");
+ if (!myStringListAttribute.empty())
+ aList.clear();
+ }
+ if (theData->getBooleanAttribute("use_in_title", false))
+ myButtonTitles = aList;
+
+ bool aHasDefaultValue;
+ int aDefaultVal = QString::fromStdString(getDefaultValue()).toInt(&aHasDefaultValue);
+ // Widget type can be combobox or radiobuttons
+ std::string aWgtType = theData->getProperty("widget_type");
+ if ((aWgtType.length() > 0) && (aWgtType == "radiobuttons")) {
+ myButtons = new QButtonGroup(this);
+ QGroupBox* aGroupBox = new QGroupBox(aLabelText, this);
+ aLayout->addWidget(aGroupBox);
+
+
+ QLayout* aBtnLayout = 0;
+ std::string aWgtDir = theData->getProperty("buttons_dir");
+ if (aWgtDir == "horizontal")
+ aBtnLayout = new QHBoxLayout(aGroupBox);
+ else
+ aBtnLayout = new QVBoxLayout(aGroupBox);
+ ModuleBase_Tools::adjustMargins(aBtnLayout);
+
+ std::string aIcons = theData->getProperty("icons_list");
+ QStringList aIconList = QString(aIcons.c_str()).split(' ');
+ if (aIconList.length() == aList.length()) {
+ int aId = 0;
+ foreach(QString aBtnTxt, aList) {
+ QToolButton* aBtn = new QToolButton(aGroupBox);
+ aBtn->setFocusPolicy(Qt::StrongFocus);
+ aBtn->setCheckable(true);
+ aBtn->setToolTip(aBtnTxt);
+
+ QPixmap aIcon = ModuleBase_IconFactory::loadPixmap(aIconList.at(aId));
+ aBtn->setIcon(aIcon);
+ aBtn->setIconSize(aIcon.size());
+
+ aBtnLayout->addWidget(aBtn);
+ myButtons->addButton(aBtn, aId++);
+ }
+
+ } else {
+ int aId = 0;
+ foreach(QString aBtnTxt, aList) {
+ QRadioButton* aBtn = new QRadioButton(aBtnTxt, aGroupBox);
+ aBtnLayout->addWidget(aBtn);
+ myButtons->addButton(aBtn, aId++);
+ }
+ }
+ int aCheckedId = aHasDefaultValue ? aDefaultVal : 0;
+ myButtons->button(aDefaultVal)->setChecked(true);
+ connect(myButtons, SIGNAL(buttonClicked(int)), this, SLOT(onCurrentIndexChanged(int)));
+ } else {
+ myLabel = new QLabel(aLabelText, this);
+ if (!aLabelIcon.isEmpty())
+ myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon));
+ aLayout->addWidget(myLabel);
+
+ std::string aToolstr = theData->widgetTooltip();
+ if (!aToolstr.empty()) {
+ myLabel->setToolTip(QString::fromStdString(aToolstr));
+ }
+
+ myCombo = new QComboBox(this);
+ aLayout->addWidget(myCombo, 1);
+
+ myCombo->addItems(aList);
+
+ if (aHasDefaultValue && aDefaultVal < aList.size())
+ myCombo->setCurrentIndex(aDefaultVal);
+
+ connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
+ }