From 601552dc2682802be66bc6b69a76a73b5d0cfa5d Mon Sep 17 00:00:00 2001 From: Rafael Date: Sat, 10 Dec 2016 03:40:42 +0100 Subject: [PATCH] Remove hardcode of AppEnv, folder detect now properly --- AppEnv.cpp | 35 +++++++++++++++++++++++------------ SnapmaticPicture.cpp | 5 ++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/AppEnv.cpp b/AppEnv.cpp index 4303fe9..11b67d7 100755 --- a/AppEnv.cpp +++ b/AppEnv.cpp @@ -37,7 +37,7 @@ AppEnv::AppEnv() QString AppEnv::getGameFolder(bool *ok) { QDir dir; - QString GTAV_FOLDER(qgetenv("GTAV_FOLDER")); + QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER")); if (GTAV_FOLDER != "") { dir.setPath(GTAV_FOLDER); @@ -52,21 +52,21 @@ QString AppEnv::getGameFolder(bool *ok) QString GTAV_defaultFolder = StandardPaths::documentsLocation() + QDir::separator() + "Rockstar Games" + QDir::separator() + "GTA V"; QString GTAV_returnFolder = GTAV_defaultFolder; - QSettings SyncSettings("Syping", "gta5sync"); + QSettings SyncSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); SyncSettings.beginGroup("dir"); bool forceDir = SyncSettings.value("force", false).toBool(); - if (forceDir) - { - GTAV_returnFolder = SyncSettings.value("dir", GTAV_defaultFolder).toString(); - } + GTAV_returnFolder = SyncSettings.value("dir", GTAV_defaultFolder).toString(); SyncSettings.endGroup(); - dir.setPath(GTAV_returnFolder); - if (dir.exists()) + if (forceDir) { - if (ok != 0) *ok = true; - qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); - return dir.absolutePath(); + dir.setPath(GTAV_returnFolder); + if (dir.exists()) + { + if (ok != 0) *ok = true; + qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); + return dir.absolutePath(); + } } dir.setPath(GTAV_defaultFolder); @@ -77,6 +77,17 @@ QString AppEnv::getGameFolder(bool *ok) return dir.absolutePath(); } + if (!forceDir) + { + dir.setPath(GTAV_returnFolder); + if (dir.exists()) + { + if (ok != 0) *ok = true; + qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); + return dir.absolutePath(); + } + } + if (ok != 0) *ok = false; return ""; } @@ -107,7 +118,7 @@ QString AppEnv::getPluginsFolder() QByteArray AppEnv::getUserAgent() { - return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 gta5sync/1.0").toUtf8(); + return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 %1/%2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8(); } QUrl AppEnv::getCrewFetchingUrl(QString crewID) diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index cc4e4f1..1bc0aed 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -339,7 +339,10 @@ bool SnapmaticPicture::setPicture(const QImage &picture) int result = snapmaticStream.write(picByteArray); if (result != 0) { - cachePicture = picture; + if (cacheEnabled) + { + cachePicture = picture; + } return true; } return false;