1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
on linux logs goes to ~/.cache/...
and screenshots goes to ~/.local/share/...
This commit is contained in:
Michał Šrajer 2016-02-28 15:16:19 +01:00
parent e5e4d561c9
commit 3227f6ea5b
4 changed files with 44 additions and 3 deletions

View File

@ -129,7 +129,8 @@ int main(int argc, char *argv[])
sodium_init(); // For the auto-updater
#ifdef LOG_TO_FILE
QString logFileDir = Settings::getInstance().getSettingsDirPath();
QString logFileDir = Settings::getInstance().getAppCacheDirPath();
QDir(logFileDir).mkpath(".");
logFileStream.reset(new QTextStream);
logFileFile.reset(new QFile(logFileDir + "qtox.log"));

View File

@ -551,6 +551,44 @@ QString Settings::getSettingsDirPath()
#endif
}
QString Settings::getAppDataDirPath()
{
QMutexLocker locker{&bigLock};
if (makeToxPortable)
return QString(".")+QDir::separator();
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
#ifdef Q_OS_WIN
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
#elif defined(Q_OS_OSX)
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator();
#else
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
+ QDir::separator() + "tox")+QDir::separator();
#endif
}
QString Settings::getAppCacheDirPath()
{
QMutexLocker locker{&bigLock};
if (makeToxPortable)
return QString(".")+QDir::separator();
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
#ifdef Q_OS_WIN
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
#elif defined(Q_OS_OSX)
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator();
#else
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
+ QDir::separator() + "tox")+QDir::separator();
#endif
}
const QList<DhtServer>& Settings::getDhtServerList() const
{
QMutexLocker locker{&bigLock};

View File

@ -42,6 +42,8 @@ public:
static Settings& getInstance();
static void destroyInstance();
QString getSettingsDirPath(); ///< The returned path ends with a directory separator
QString getAppDataDirPath(); ///< The returned path ends with a directory separator
QString getAppCacheDirPath(); ///< The returned path ends with a directory separator
void createSettingsDir(); ///< Creates a path to the settings dir, if it doesn't already exist
void createPersonal(QString basename); ///< Write a default personal .ini settings file for a profile

View File

@ -774,7 +774,7 @@ void ChatForm::doScreenshot()
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
screenshotGrabber->showGrabber();
// Create dir for screenshots
QDir(Settings::getInstance().getSettingsDirPath()).mkdir("screenshots");
QDir(Settings::getInstance().getAppDataDirPath()).mkdir("screenshots");
}
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
@ -783,7 +783,7 @@ void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
// Windows has to be supported, thus filename can't have `:` in it :/
// Format should be: `qTox_Screenshot_yyyy-MM-dd HH-mm-ss.zzz.png`
QString filepath = QString("%1screenshots%2qTox_Screenshot_%3.png")
.arg(Settings::getInstance().getSettingsDirPath())
.arg(Settings::getInstance().getAppDataDirPath())
.arg(QDir::separator())
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss.zzz"));