#include <QLayout>
#include <QApplication>
#include <QDialogButtonBox>
+#include <QPushButton>
const QString XGUI_Preferences::VIEWER_SECTION = "Viewer";
const QString XGUI_Preferences::MENU_SECTION = "Menu";
return false;
}
-void XGUI_Preferences::updateCustomProps()
+void XGUI_Preferences::updateConfigByResources()
{
Config_Properties aProps = Config_PropManager::getProperties();
Config_Properties::iterator aIt;
Config_Prop* aProp = (*aIt);
QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()),
QString(aProp->name().c_str()));
- if (!aVal.isNull())
+ if (!aVal.isEmpty()) {
aProp->setValue(aVal.toStdString());
+ }
+ }
+}
+
+void XGUI_Preferences::updateResourcesByConfig()
+{
+ Config_Properties aProps = Config_PropManager::getProperties();
+ Config_Properties::iterator aIt;
+ for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
+ Config_Prop* aProp = (*aIt);
+ myResourceMgr->setValue(QString(aProp->section().c_str()), QString(aProp->name().c_str()),
+ QString(aProp->value().c_str()));
+ }
+}
+
+void XGUI_Preferences::resetConfig()
+{
+ Config_Properties aProps = Config_PropManager::getProperties();
+ Config_Properties::iterator aIt;
+ for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
+ Config_Prop* aProp = (*aIt);
+ aProp->setValue(aProp->defaultValue());
}
}
QStringList aParams = myResourceMgr->parameters(aSection);
foreach (QString aParam, aParams)
{
- Config_PropManager::registerProp(aSection.toStdString(), aParam.toStdString(), "",
- Config_Prop::Disabled,
- myResourceMgr->stringValue(aSection, aParam).toStdString());
+ Config_Prop* aProp = Config_PropManager::registerProp(aSection.toStdString(),
+ aParam.toStdString(), "", Config_Prop::Disabled);
+ aProp->setValue(myResourceMgr->stringValue(aSection, aParam).toStdString());
}
}
}
setFocusProxy(myPreferences);
myPreferences->setFrameStyle(QFrame::Box | QFrame::Sunken);
- QDialogButtonBox* aBtnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+ QDialogButtonBox* aBtnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel |
+ QDialogButtonBox::Reset,
Qt::Horizontal, this);
+ QPushButton* aDefaultButton = aBtnBox->button(QDialogButtonBox::Reset);
+ aDefaultButton->setText(tr("Default"));
+ connect(aDefaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));
+
main->addWidget(aBtnBox);
connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
myIsChanged = true;
// Save custom properties
- XGUI_Preferences::updateCustomProps();
+ XGUI_Preferences::updateConfigByResources();
QDialog::accept();
}
theModified = myPreferences->modified();
}
+void XGUI_PreferencesDlg::onDefault()
+{
+ // reset main resources
+#ifdef WIN32
+ QtxResourceMgr::WorkingMode aPrev =
+ myPreferences->resourceMgr()->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
+ myPreferences->retrieve();
+ myPreferences->resourceMgr()->setWorkingMode(aPrev);
+#endif
+ // reset plugin's resources
+ XGUI_Preferences::resetConfig();
+ XGUI_Preferences::updateResourcesByConfig();
+
+ myPreferences->retrieve();
+}
+
//**********************************************************
//**********************************************************
//**********************************************************