Remove hardcode of AppEnv, folder detect now properly

This commit is contained in:
Rafael 2016-12-10 03:40:42 +01:00
parent 3be2e49d5c
commit 601552dc26
2 changed files with 27 additions and 13 deletions

View file

@ -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)

View file

@ -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;