label="Operation type"
tooltip="Type of boolean operation"
string_list="Cut Fuse Common"
+ use_in_title="true"
icons_list=":icons/bool_cut.png :icons/bool_fuse.png :icons/bool_common.png"
default="0"
/>
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")) {
}
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())
myCombo->addItems(aList);
connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
- connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(itemSelected(int)));
}
}
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;
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);
}
/// \return a controls list
virtual QList<QWidget*> getControls() const;
+ /// Returns text value for the property panel title
+ /// \param theIndex a button index
+ /// \return the title value
+ QString getPropertyPanelTitle(int theIndex);
+
signals:
- void itemSelected(int);
+ void itemSelected(ModuleBase_ModelWidget* theWidget, int theIndex);
protected:
/// Saves the internal parameters to the given feature
/// The control
QComboBox* myCombo;
QButtonGroup* myButtons;
+
+ // XML definition of titles
+ QStringList myButtonTitles;
};
#endif
aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
} else if (theType == "module_choice") {
aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi);
- connect(aWgt, SIGNAL(itemSelected(int)), SLOT(onBooleanOperationChange(int)));
+ connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
+ this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
}
return aWgt;
}
}
//******************************************************
-void PartSet_Module::onBooleanOperationChange(int theOperation)
+void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
+ int theIndex)
{
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
- if (!aOperation)
+ PartSet_WidgetChoice* aChoiceWidget = dynamic_cast<PartSet_WidgetChoice*>(theWidget);
+ if (!aChoiceWidget)
return;
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- switch (theOperation) {
- case 0:
- aPanel->setWindowTitle(tr("Cut"));
- break;
- case 1:
- aPanel->setWindowTitle(tr("Fuse"));
- break;
- case 2:
- aPanel->setWindowTitle(tr("Common"));
- break;
+
+ QString aChoiceTitle = aChoiceWidget->getPropertyPanelTitle(theIndex);
+ if (!aChoiceTitle.isEmpty()) {
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (!aOperation)
+ return;
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ aPanel->setWindowTitle(aChoiceTitle);
}
}
/// A slot called on view window creation
void onViewCreated(ModuleBase_IViewWindow*);
- /// A slot to change property panel title on change of boolean operation type
- /// \param theOperation the operation type
- void onBooleanOperationChange(int theOperation);
+ /// A slot to change property panel title by choice type change if the title information
+ /// exists in the XML definition of this control attribute
+ /// \param theWidget a sender
+ /// \param theIndex the current choice index
+ void onChoiceChanged(ModuleBase_ModelWidget* theWidget, int theIndex);
protected:
/// Register validators for this module
<module_choice id="AngleType"
widget_type="radiobuttons"
buttons_dir="horizontal"
- label="Operation type"
+ label="Angle type"
tooltip="Type of angle"
string_list="Direct Supplementary Backward"
icons_list=":icons/angle_direct.png :icons/angle_supplementary.png :icons/angle_backward.png"