Handle tilde with custom paths

This commit is contained in:
varjolintu 2021-06-22 20:24:30 +03:00 committed by Jonathan White
parent 986fa42ca8
commit 250cd1933c
4 changed files with 40 additions and 12 deletions

View file

@ -20,6 +20,7 @@
#include "BrowserSettings.h"
#include "core/Config.h"
#include "core/PasswordHealth.h"
#include <QDir>
#include <QJsonObject>
@ -516,3 +517,27 @@ void BrowserSettings::updateBinaryPaths()
{
m_nativeMessageInstaller.updateBinaryPaths();
}
QString BrowserSettings::replaceHomePath(QString location)
{
#ifndef Q_OS_WIN
auto homePath = QDir::homePath();
if (location.startsWith(homePath)) {
location.replace(homePath, "~");
}
#endif
return location;
}
QString BrowserSettings::replaceTildeHomePath(QString location)
{
#ifndef Q_OS_WIN
auto homePath = QDir::homePath();
if (location.startsWith("~")) {
location.replace("~", homePath);
}
#endif
return location;
}