From: nds Date: Thu, 17 Mar 2016 09:00:32 +0000 (+0300) Subject: Issue 1299 Angle presentation: "Cut"/"Fuse"/"Common" should not be shown in the PP... X-Git-Tag: V_2.3.0~379 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ec8afdf50f8400316e31bdad33fa9b337210833;p=modules%2Fshaper.git Issue 1299 Angle presentation: "Cut"/"Fuse"/"Common" should not be shown in the PP title. --- diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index 99d5ca699..e3b9b2dbb 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -7,6 +7,7 @@ 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" /> diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index 6c35d6627..f8b4ff516 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -33,6 +33,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")) { @@ -77,7 +80,6 @@ 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()) @@ -95,7 +97,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))); } } @@ -130,7 +131,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; @@ -158,9 +159,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); } diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.h b/src/ModuleBase/ModuleBase_WidgetChoice.h index 100f66f24..e5e7474c3 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.h +++ b/src/ModuleBase/ModuleBase_WidgetChoice.h @@ -54,8 +54,13 @@ Q_OBJECT /// \return a controls list virtual QList 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 @@ -75,6 +80,9 @@ private: /// The control QComboBox* myCombo; QButtonGroup* myButtons; + + // XML definition of titles + QStringList myButtonTitles; }; #endif diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3f2ef5ed8..d38ee8de6 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -683,7 +683,8 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th 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; } @@ -1241,22 +1242,20 @@ AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject, } //****************************************************** -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(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); } } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 2581d7bb2..cb7d86131 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -315,9 +315,11 @@ protected slots: /// 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 diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 8640c0635..5e1e924db 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -209,7 +209,7 @@