mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
0ea0918ce9
commit
59ac2e54e1
|
@ -28,6 +28,7 @@
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
|
@ -202,8 +203,7 @@ QString Widget::getSettingsDirPath()
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
wchar_t* path;
|
wchar_t* path;
|
||||||
wchar_t pathOld[MAX_PATH];
|
bool isOld = false; // If true, we can't unelevate and just return the path for our current home
|
||||||
bool isOld = false; // If true, we have to use pathOld and older Windows API.
|
|
||||||
|
|
||||||
auto shell32H = LoadLibrary(TEXT("shell32.dll"));
|
auto shell32H = LoadLibrary(TEXT("shell32.dll"));
|
||||||
if (!(isOld = (shell32H == nullptr)))
|
if (!(isOld = (shell32H == nullptr)))
|
||||||
|
@ -213,15 +213,18 @@ QString Widget::getSettingsDirPath()
|
||||||
if (!(isOld = (SHGetKnownFolderPathH == nullptr)))
|
if (!(isOld = (SHGetKnownFolderPathH == nullptr)))
|
||||||
SHGetKnownFolderPathH(FOLDERID_RoamingAppData, 0, hPrimaryToken, &path);
|
SHGetKnownFolderPathH(FOLDERID_RoamingAppData, 0, hPrimaryToken, &path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOld)
|
if (isOld)
|
||||||
{
|
{
|
||||||
qDebug() << "Falling back to legacy APIs...";
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
||||||
SHGetFolderPathW(nullptr, CSIDL_APPDATA, nullptr, 0, pathOld);
|
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox" + QDir::separator());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
QString pathStr = QString::fromStdWString(isOld ? pathOld : path);
|
{
|
||||||
|
QString pathStr = QString::fromStdWString(path);
|
||||||
pathStr.replace("\\", "/");
|
pathStr.replace("\\", "/");
|
||||||
return pathStr + "/tox";
|
return pathStr + "/tox";
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox");
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user