PreferencesDialog: added virtual getDefaultWorkingDirectory() for convenience (can be changed in inherited class)

This commit is contained in:
matlabbe
2017-10-25 10:56:43 +02:00
parent 7a2ddd3905
commit de5f3657ab
2 changed files with 12 additions and 7 deletions
@@ -116,6 +116,7 @@ public:
virtual QString getTmpIniFilePath() const; virtual QString getTmpIniFilePath() const;
void init(); void init();
void setCurrentPanelToSource(); void setCurrentPanelToSource();
virtual QString getDefaultWorkingDirectory() const;
// save stuff // save stuff
void saveSettings(); void saveSettings();
+11 -7
View File
@@ -1602,7 +1602,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
{ {
if(key.compare(Parameters::kRtabmapWorkingDirectory().c_str()) == 0) if(key.compare(Parameters::kRtabmapWorkingDirectory().c_str()) == 0)
{ {
this->setParameter(key, Parameters::createDefaultWorkingDirectory()); this->setParameter(key, getDefaultWorkingDirectory().toStdString());
} }
else else
{ {
@@ -1984,6 +1984,11 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
} }
QString PreferencesDialog::getDefaultWorkingDirectory() const
{
return Parameters::createDefaultWorkingDirectory().c_str();
}
bool PreferencesDialog::readCoreSettings(const QString & filePath) bool PreferencesDialog::readCoreSettings(const QString & filePath)
{ {
QString path = getIniFilePath(); QString path = getIniFilePath();
@@ -2008,7 +2013,7 @@ bool PreferencesDialog::readCoreSettings(const QString & filePath)
if(iter->first.compare(Parameters::kRtabmapWorkingDirectory()) == 0) if(iter->first.compare(Parameters::kRtabmapWorkingDirectory()) == 0)
{ {
// The directory should exist if not the default one // The directory should exist if not the default one
if(!QDir(value.c_str()).exists() && value.compare(Parameters::createDefaultWorkingDirectory().c_str()) != 0) if(!QDir(value.c_str()).exists() && value.compare(getDefaultWorkingDirectory().toStdString()) != 0)
{ {
if(QDir(this->getWorkingDirectory().toStdString().c_str()).exists()) if(QDir(this->getWorkingDirectory().toStdString().c_str()).exists())
{ {
@@ -2019,7 +2024,7 @@ bool PreferencesDialog::readCoreSettings(const QString & filePath)
} }
else else
{ {
std::string defaultWorkingDir = Parameters::createDefaultWorkingDirectory(); std::string defaultWorkingDir = getDefaultWorkingDirectory().toStdString();
UWARN("Reading config: Not existing working directory \"%s\". Using default one (\"%s\").", UWARN("Reading config: Not existing working directory \"%s\". Using default one (\"%s\").",
value.c_str(), value.c_str(),
defaultWorkingDir.c_str()); defaultWorkingDir.c_str());
@@ -2040,11 +2045,10 @@ bool PreferencesDialog::readCoreSettings(const QString & filePath)
tr("RTAB-Map needs a working directory to put the database.\n\n" tr("RTAB-Map needs a working directory to put the database.\n\n"
"By default, the directory \"%1\" is used.\n\n" "By default, the directory \"%1\" is used.\n\n"
"The working directory can be changed any time in the " "The working directory can be changed any time in the "
"preferences menu.").arg( "preferences menu.").arg(getDefaultWorkingDirectory()));
Parameters::createDefaultWorkingDirectory().c_str()));
} }
this->setParameter(Parameters::kRtabmapWorkingDirectory(), Parameters::createDefaultWorkingDirectory()); this->setParameter(Parameters::kRtabmapWorkingDirectory(), getDefaultWorkingDirectory().toStdString());
UDEBUG("key.toStdString()=%s", Parameters::createDefaultWorkingDirectory().c_str()); UDEBUG("key.toStdString()=%s", getDefaultWorkingDirectory().toStdString().c_str());
} }
return true; return true;