mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #2980
Michał Šrajer (4): fix #2976 make fix for #2976 Qt5.3 compatible. fix logs and screenshots path on linux ensure screenshots directory exists
This commit is contained in:
commit
252c9c8fae
|
@ -129,7 +129,8 @@ int main(int argc, char *argv[])
|
||||||
sodium_init(); // For the auto-updater
|
sodium_init(); // For the auto-updater
|
||||||
|
|
||||||
#ifdef LOG_TO_FILE
|
#ifdef LOG_TO_FILE
|
||||||
QString logFileDir = Settings::getInstance().getSettingsDirPath();
|
QString logFileDir = Settings::getInstance().getAppCacheDirPath();
|
||||||
|
QDir(logFileDir).mkpath(".");
|
||||||
logFileStream.reset(new QTextStream);
|
logFileStream.reset(new QTextStream);
|
||||||
logFileFile.reset(new QFile(logFileDir + "qtox.log"));
|
logFileFile.reset(new QFile(logFileDir + "qtox.log"));
|
||||||
|
|
||||||
|
|
|
@ -553,6 +553,45 @@ QString Settings::getSettingsDirPath()
|
||||||
#endif
|
#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
|
||||||
|
// TODO: change QStandardPaths::DataLocation to AppDataLocation when upgrate Qt to 5.4+
|
||||||
|
// For now we need support Qt 5.3, so we use deprecated DataLocation
|
||||||
|
// BTW, it's not a big deal since for linux AppDataLocation and DataLocation are equal
|
||||||
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation))+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();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const QList<DhtServer>& Settings::getDhtServerList() const
|
const QList<DhtServer>& Settings::getDhtServerList() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
static Settings& getInstance();
|
static Settings& getInstance();
|
||||||
static void destroyInstance();
|
static void destroyInstance();
|
||||||
QString getSettingsDirPath(); ///< The returned path ends with a directory separator
|
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 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
|
void createPersonal(QString basename); ///< Write a default personal .ini settings file for a profile
|
||||||
|
|
|
@ -774,7 +774,7 @@ void ChatForm::doScreenshot()
|
||||||
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
|
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
|
||||||
screenshotGrabber->showGrabber();
|
screenshotGrabber->showGrabber();
|
||||||
// Create dir for screenshots
|
// Create dir for screenshots
|
||||||
QDir(Settings::getInstance().getSettingsDirPath()).mkdir("screenshots");
|
QDir(Settings::getInstance().getAppDataDirPath()).mkpath("screenshots");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
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 :/
|
// 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`
|
// Format should be: `qTox_Screenshot_yyyy-MM-dd HH-mm-ss.zzz.png`
|
||||||
QString filepath = QString("%1screenshots%2qTox_Screenshot_%3.png")
|
QString filepath = QString("%1screenshots%2qTox_Screenshot_%3.png")
|
||||||
.arg(Settings::getInstance().getSettingsDirPath())
|
.arg(Settings::getInstance().getAppDataDirPath())
|
||||||
.arg(QDir::separator())
|
.arg(QDir::separator())
|
||||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss.zzz"));
|
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss.zzz"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user