Added RestoreAllDefaultSettings action in Edit menu

git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@72 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
matlabbe 2012-01-12 22:21:56 +00:00
parent f506c9e01f
commit a1c6ec7509
4 changed files with 46 additions and 0 deletions

View File

@ -78,6 +78,7 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects())); connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects()));
connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects())); connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects()));
connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec())); connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec()));
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
QTimer::singleShot(10, this, SLOT(startProcessing())); QTimer::singleShot(10, this, SLOT(startProcessing()));
} }

View File

@ -57,6 +57,43 @@ void ParametersToolBox::resetCurrentPage()
} }
} }
void ParametersToolBox::resetAllPages()
{
for(int i=0; i< this->count(); ++i)
{
const QObjectList & children = this->widget(i)->children();
for(int j=0; j<children.size();++j)
{
QString key = children.at(j)->objectName();
// ignore only the nextObjID setting, to avoid problem with saved objects
if(key.compare(Settings::kGeneral_nextObjID()) != 0)
{
QVariant value = Settings::getDefaultParameters().value(key, QVariant());
if(value.isValid())
{
if(qobject_cast<QComboBox*>(children.at(j)))
{
((QComboBox*)children.at(j))->setCurrentIndex(value.toString().split(':').first().toInt());
}
else if(qobject_cast<QSpinBox*>(children.at(j)))
{
((QSpinBox*)children.at(j))->setValue(value.toInt());
}
else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
{
((QDoubleSpinBox*)children.at(j))->setValue(value.toDouble());
}
else if(qobject_cast<QCheckBox*>(children.at(j)))
{
((QCheckBox*)children.at(j))->setChecked(value.toBool());
}
Settings::setParameter(key, value);
}
}
}
}
}
void ParametersToolBox::setupUi() void ParametersToolBox::setupUi()
{ {
QWidget * currentItem = 0; QWidget * currentItem = 0;

View File

@ -34,6 +34,7 @@ private slots:
void changeParameter(const QString & value); void changeParameter(const QString & value);
void changeParameter(const int & value); void changeParameter(const int & value);
void resetCurrentPage(); void resetCurrentPage();
void resetAllPages();
}; };
#endif /* PARAMETERSTOOLBOX_H_ */ #endif /* PARAMETERSTOOLBOX_H_ */

View File

@ -150,6 +150,8 @@
<addaction name="actionAdd_object"/> <addaction name="actionAdd_object"/>
<addaction name="actionStart_camera"/> <addaction name="actionStart_camera"/>
<addaction name="actionStop_camera"/> <addaction name="actionStop_camera"/>
<addaction name="separator"/>
<addaction name="actionRestore_all_default_settings"/>
</widget> </widget>
<widget class="QMenu" name="menuView"> <widget class="QMenu" name="menuView">
<property name="title"> <property name="title">
@ -467,6 +469,11 @@
<string>About...</string> <string>About...</string>
</property> </property>
</action> </action>
<action name="actionRestore_all_default_settings">
<property name="text">
<string>Restore all default settings</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>