]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModuleBase/ModuleBase_WidgetChoice.cpp
Salome HOME
Issue #2206 Avoid the ability to cancel the current sketch when saving,
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.cpp
index ce664179fb40611472f9037f2c24d1cee49827a6..74e8b12aa335a3b3e39fa68fb910bdc9ca7f8086 100644 (file)
@@ -55,6 +55,8 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
   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")) {
@@ -97,7 +99,8 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
         myButtons->addButton(aBtn, aId++);
       }
     }
-    myButtons->button(0)->setChecked(true);
+    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);
@@ -115,6 +118,9 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
 
     myCombo->addItems(aList);
 
+    if (aHasDefaultValue && aDefaultVal < aList.size())
+      myCombo->setCurrentIndex(aDefaultVal);
+
     connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
   }
 }