Support for OneDrive on Windows.

Move settings, "Svg fonts", "Font corrections" and "Known measurements" folders to user Documents. This will map to OneDrive's documents folder if OneDrive activated.
This commit is contained in:
Roman Telezhynskyi 2024-04-13 12:34:09 +03:00
parent b4b26b115b
commit e154ba7440
4 changed files with 62 additions and 3 deletions

View File

@ -492,6 +492,13 @@ auto VPApplication::TrVars() -> const VTranslateVars *
//---------------------------------------------------------------------------------------------------------------------
void VPApplication::OpenSettings()
{
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (!docPath.isEmpty())
{
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, docPath);
}
#endif
settings = new VPSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this);
connect(settings, &VPSettings::SVGFontsPathChanged, this, &VPApplication::SVGFontsPathChanged);

View File

@ -614,6 +614,13 @@ void MApplication::AboutToQuit()
//---------------------------------------------------------------------------------------------------------------------
void MApplication::OpenSettings()
{
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (!docPath.isEmpty())
{
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, docPath);
}
#endif
settings = new VTapeSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this);
connect(settings, &VTapeSettings::SVGFontsPathChanged, this, &MApplication::SVGFontsPathChanged);

View File

@ -71,6 +71,13 @@ void VAbstractValApplication::PostWarningMessage(const QString &message, QtMsgTy
*/
void VAbstractValApplication::OpenSettings()
{
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (!docPath.isEmpty())
{
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, docPath);
}
#endif
settings = new VValentinaSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this);
connect(settings, &VValentinaSettings::SVGFontsPathChanged, this, &VAbstractValApplication::SVGFontsPathChanged);

View File

@ -347,7 +347,19 @@ void VCommonSettings::SetPathCustomImage(const QString &value)
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefPathSVGFonts() -> QString
{
return QDir::homePath() + QStringLiteral("/valentina/svg fonts");
QString const defPath = QStringList{QDir::homePath(), "Valentina"_L1, "Svg fonts"_L1}.join(QDir::separator());
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (docPath.isEmpty())
{
return defPath;
}
return QStringList{docPath, "Valentina"_L1, "Svg fonts"_L1}.join(QDir::separator());
#else
return defPath;
#endif
}
//---------------------------------------------------------------------------------------------------------------------
@ -375,7 +387,20 @@ void VCommonSettings::SetPathSVGFonts(const QString &value)
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefPathFontCorrections() -> QString
{
return QDir::homePath() + "/valentina/font corrections"_L1;
QString const defPath =
QStringList{QDir::homePath(), "Valentina"_L1, "Font corrections"_L1}.join(QDir::separator());
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (docPath.isEmpty())
{
return defPath;
}
return QStringList{docPath, "Valentina"_L1, "Font corrections"_L1}.join(QDir::separator());
#else
return defPath;
#endif
}
//---------------------------------------------------------------------------------------------------------------------
@ -396,7 +421,20 @@ void VCommonSettings::SetPathFontCorrections(const QString &value)
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefPathKnownMeasurements() -> QString
{
return QDir::homePath() + "/valentina/known measurements"_L1;
QString const defPath =
QStringList{QDir::homePath(), "Valentina"_L1, "Known measurements"_L1}.join(QDir::separator());
#if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if (docPath.isEmpty())
{
return defPath;
}
return QStringList{docPath, "Valentina"_L1, "Known measurements"_L1}.join(QDir::separator());
#else
return defPath;
#endif
}
//---------------------------------------------------------------------------------------------------------------------