mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(paths): add path for log file and tests
This commit is contained in:
parent
2ff649e80d
commit
9f59ec2cc2
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QLatin1Literal globalSettingsFile{"qtox.ini"};
|
const QLatin1Literal globalSettingsFile{"qtox.ini"};
|
||||||
|
const QLatin1Literal logFile{"qtox.log"};
|
||||||
const QLatin1Literal profileFolder{"profiles"};
|
const QLatin1Literal profileFolder{"profiles"};
|
||||||
const QLatin1Literal themeFolder{"themes"};
|
const QLatin1Literal themeFolder{"themes"};
|
||||||
const QLatin1Literal avatarsFolder{"avatars"};
|
const QLatin1Literal avatarsFolder{"avatars"};
|
||||||
|
@ -134,6 +135,29 @@ QString Paths::getGlobalSettingsPath() const
|
||||||
return path % QDir::separator() % globalSettingsFile;
|
return path % QDir::separator() % globalSettingsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the path to the log file "qtox.log"
|
||||||
|
* @return The path to the folder.
|
||||||
|
*/
|
||||||
|
QString Paths::getLogFilePath() const
|
||||||
|
{
|
||||||
|
QString path;
|
||||||
|
|
||||||
|
if (portable) {
|
||||||
|
path = basePath;
|
||||||
|
} else {
|
||||||
|
path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
qDebug() << "Can't find writable location for log file";
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we assume a writeable path for portable mode
|
||||||
|
|
||||||
|
return path % QDir::separator() % logFile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the folder where profile specific information is stored, e.g. <profile>.ini
|
* @brief Get the folder where profile specific information is stored, e.g. <profile>.ini
|
||||||
* @return The path to the folder.
|
* @return The path to the folder.
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
|
|
||||||
bool isPortable() const;
|
bool isPortable() const;
|
||||||
QString getGlobalSettingsPath() const;
|
QString getGlobalSettingsPath() const;
|
||||||
|
QString getLogFilePath() const;
|
||||||
QString getProfilesDir() const;
|
QString getProfilesDir() const;
|
||||||
QString getToxSaveDir() const;
|
QString getToxSaveDir() const;
|
||||||
QString getAvatarsDir() const;
|
QString getAvatarsDir() const;
|
||||||
|
|
|
@ -41,6 +41,7 @@ private:
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QLatin1Literal globalSettingsFile{"qtox.ini"};
|
const QLatin1Literal globalSettingsFile{"qtox.ini"};
|
||||||
|
const QLatin1Literal logFile{"qtox.log"};
|
||||||
const QLatin1Literal profileFolder{"profiles"};
|
const QLatin1Literal profileFolder{"profiles"};
|
||||||
const QLatin1Literal themeFolder{"themes"};
|
const QLatin1Literal themeFolder{"themes"};
|
||||||
const QLatin1Literal avatarsFolder{"avatars"};
|
const QLatin1Literal avatarsFolder{"avatars"};
|
||||||
|
@ -112,10 +113,11 @@ void TestPaths::checkPathsNonPortable()
|
||||||
|
|
||||||
const QString appData{QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)};
|
const QString appData{QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)};
|
||||||
const QString appConfig{QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)};
|
const QString appConfig{QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)};
|
||||||
|
const QString cache{QStandardPaths::writableLocation(QStandardPaths::CacheLocation)};
|
||||||
|
|
||||||
verifyqToxPath(paths->getProfilesDir(), appData, profileFolder % sep);
|
verifyqToxPath(paths->getProfilesDir(), appData, profileFolder % sep);
|
||||||
verifyqToxPath(paths->getGlobalSettingsPath(), appConfig, globalSettingsFile);
|
verifyqToxPath(paths->getGlobalSettingsPath(), appConfig, globalSettingsFile);
|
||||||
|
verifyqToxPath(paths->getLogFilePath(), cache, logFile);
|
||||||
verifyqToxPath(paths->getScreenshotsDir(), appData, screenshotsFolder % sep);
|
verifyqToxPath(paths->getScreenshotsDir(), appData, screenshotsFolder % sep);
|
||||||
verifyqToxPath(paths->getTransfersDir(), appData, transfersFolder % sep);
|
verifyqToxPath(paths->getTransfersDir(), appData, transfersFolder % sep);
|
||||||
|
|
||||||
|
@ -153,6 +155,7 @@ void TestPaths::checkPathsPortable()
|
||||||
|
|
||||||
verifyqToxPath(paths->getProfilesDir(), basePath, profileFolder % sep);
|
verifyqToxPath(paths->getProfilesDir(), basePath, profileFolder % sep);
|
||||||
verifyqToxPath(paths->getGlobalSettingsPath(), basePath, globalSettingsFile);
|
verifyqToxPath(paths->getGlobalSettingsPath(), basePath, globalSettingsFile);
|
||||||
|
verifyqToxPath(paths->getLogFilePath(), basePath, logFile);
|
||||||
verifyqToxPath(paths->getScreenshotsDir(), basePath, screenshotsFolder % sep);
|
verifyqToxPath(paths->getScreenshotsDir(), basePath, screenshotsFolder % sep);
|
||||||
verifyqToxPath(paths->getTransfersDir(), basePath, transfersFolder % sep);
|
verifyqToxPath(paths->getTransfersDir(), basePath, transfersFolder % sep);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user