mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 17:17:47 +08:00
Updated default config path on Windows
This commit is contained in:
@@ -1247,7 +1247,12 @@ void readINIImpl(const CSimpleIniA & ini, const std::string & configFilePath, Pa
|
||||
{
|
||||
if(RTABMAP_VERSION_COMPARE(<, std::atoi(version[0].c_str()), std::atoi(version[1].c_str()), std::atoi(version[2].c_str())))
|
||||
{
|
||||
if(configFilePath.find(".rtabmap") != std::string::npos)
|
||||
// Detect the user's private config - matches both the legacy
|
||||
// ~/.rtabmap/rtabmap.ini and the Windows %LOCALAPPDATA%/rtabmap/rtabmap.ini
|
||||
// (".rtabmap/rtabmap.ini" also contains "rtabmap/rtabmap.ini"): downgrade-on-save is fine there.
|
||||
// Accept both forward and backward slashes (native Windows paths).
|
||||
if(configFilePath.find("rtabmap/rtabmap.ini") != std::string::npos ||
|
||||
configFilePath.find("rtabmap\\rtabmap.ini") != std::string::npos)
|
||||
{
|
||||
UWARN("Version in the config file \"%s\" is more recent (\"%s\") than "
|
||||
"current RTAB-Map version used (\"%s\"). The config file will be downgraded "
|
||||
|
||||
@@ -39,6 +39,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QThread>
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
#include <rtabmap/utilite/UDirectory.h>
|
||||
@@ -583,12 +586,33 @@ QString DatabaseViewer::getIniFilePath() const
|
||||
{
|
||||
return iniFilePath_;
|
||||
}
|
||||
#ifdef WIN32
|
||||
// Windows: store settings in the standard per-user config location (%LOCALAPPDATA%\rtabmap)
|
||||
// instead of a Unix-style dotfile in the home root. A fixed "rtabmap" folder (not the app name)
|
||||
// is used so the main GUI and DatabaseViewer share the same rtabmap.ini. Other platforms keep
|
||||
// ~/.rtabmap for consistency.
|
||||
QString privatePath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/rtabmap";
|
||||
#else
|
||||
QString privatePath = QDir::homePath() + "/.rtabmap";
|
||||
#endif
|
||||
if(!QDir(privatePath).exists())
|
||||
{
|
||||
QDir::home().mkdir(".rtabmap");
|
||||
QDir().mkpath(privatePath);
|
||||
}
|
||||
return privatePath + "/rtabmap.ini";
|
||||
QString iniPath = privatePath + "/rtabmap.ini";
|
||||
#ifdef WIN32
|
||||
// One-time migration: if there's no ini at the new location but the legacy ~/.rtabmap/rtabmap.ini
|
||||
// exists, copy it over so users keep their existing settings.
|
||||
if(!QFile::exists(iniPath))
|
||||
{
|
||||
QString legacyIni = QDir::homePath() + "/.rtabmap/rtabmap.ini";
|
||||
if(QFile::exists(legacyIni))
|
||||
{
|
||||
QFile::copy(legacyIni, iniPath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return iniPath;
|
||||
}
|
||||
|
||||
void DatabaseViewer::readSettings()
|
||||
|
||||
@@ -39,6 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QUrl>
|
||||
|
||||
@@ -2579,12 +2581,33 @@ QString PreferencesDialog::getWorkingDirectory() const
|
||||
|
||||
QString PreferencesDialog::getIniFilePath() const
|
||||
{
|
||||
#ifdef WIN32
|
||||
// Windows: store settings in the standard per-user config location (%LOCALAPPDATA%\rtabmap)
|
||||
// instead of a Unix-style dotfile in the home root. A fixed "rtabmap" folder (not the app name)
|
||||
// is used so the main GUI and DatabaseViewer share the same rtabmap.ini. Other platforms keep
|
||||
// ~/.rtabmap for consistency.
|
||||
QString privatePath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/rtabmap";
|
||||
#else
|
||||
QString privatePath = QDir::homePath() + "/.rtabmap";
|
||||
#endif
|
||||
if(!QDir(privatePath).exists())
|
||||
{
|
||||
QDir::home().mkdir(".rtabmap");
|
||||
QDir().mkpath(privatePath);
|
||||
}
|
||||
return privatePath + "/rtabmap.ini";
|
||||
QString iniPath = privatePath + "/rtabmap.ini";
|
||||
#ifdef WIN32
|
||||
// One-time migration: if there's no ini at the new location but the legacy ~/.rtabmap/rtabmap.ini
|
||||
// exists, copy it over so users keep their existing settings.
|
||||
if(!QFile::exists(iniPath))
|
||||
{
|
||||
QString legacyIni = QDir::homePath() + "/.rtabmap/rtabmap.ini";
|
||||
if(QFile::exists(legacyIni))
|
||||
{
|
||||
QFile::copy(legacyIni, iniPath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return iniPath;
|
||||
}
|
||||
|
||||
QString PreferencesDialog::getTmpIniFilePath() const
|
||||
|
||||
Reference in New Issue
Block a user