Merge pull request #1458 from marcofernandezheras/Fix-Portable

fix Decks, Pics replays & sounds paths on Portable build
This commit is contained in:
Zach 2015-09-03 14:52:17 -04:00
commit 4eb708c3b0
2 changed files with 15 additions and 5 deletions

View file

@ -1,6 +1,7 @@
#include "settingscache.h" #include "settingscache.h"
#include <QSettings> #include <QSettings>
#include <QFile> #include <QFile>
#include <QApplication>
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <QStandardPaths> #include <QStandardPaths>
@ -10,7 +11,7 @@
QString SettingsCache::getSettingsPath() QString SettingsCache::getSettingsPath()
{ {
QString file = "settings/"; QString file = qApp->applicationDirPath() + "settings/";
#ifndef PORTABLE_BUILD #ifndef PORTABLE_BUILD
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@ -26,7 +27,9 @@ QString SettingsCache::getSettingsPath()
void SettingsCache::translateLegacySettings() void SettingsCache::translateLegacySettings()
{ {
//NOTE Please remove this legacy setting translation after 2016-9-1 (+1 year after creation) #ifdef PORTABLE_BUILD
return;
#endif
//Layouts //Layouts
QFile layoutFile(getSettingsPath()+"layouts/deckLayout.ini"); QFile layoutFile(getSettingsPath()+"layouts/deckLayout.ini");
@ -130,6 +133,13 @@ SettingsCache::SettingsCache()
if(!QFile(settingsPath+"global.ini").exists()) if(!QFile(settingsPath+"global.ini").exists())
translateLegacySettings(); translateLegacySettings();
#ifdef PORTABLE_BUILD
setDeckPath(qApp->applicationDirPath() + "data/decks");
setReplaysPath(qApp->applicationDirPath() +"data/replays");
setPicsPath(qApp->applicationDirPath() + "data/pics");
setSoundPath(qApp->applicationDirPath() +"data/sounds");
#endif
notifyAboutUpdates = settings->value("personal/updatenotification", true).toBool(); notifyAboutUpdates = settings->value("personal/updatenotification", true).toBool();
lang = settings->value("personal/lang").toString(); lang = settings->value("personal/lang").toString();
keepalive = settings->value("personal/keepalive", 5).toInt(); keepalive = settings->value("personal/keepalive", 5).toInt();
@ -627,4 +637,4 @@ void SettingsCache::setNotifyAboutUpdate(int _notifyaboutupdate)
{ {
notifyAboutUpdates = _notifyaboutupdate; notifyAboutUpdates = _notifyaboutupdate;
settings->setValue("personal/updatenotification", notifyAboutUpdates); settings->setValue("personal/updatenotification", notifyAboutUpdates);
} }

View file

@ -516,7 +516,7 @@ bool SaveSetsPage::validatePage()
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
#endif #endif
#else #else
dataDir = "data"; dataDir = qApp->applicationDirPath() + "/data";
#endif #endif
#ifdef PORTABLE_BUILD #ifdef PORTABLE_BUILD
@ -731,7 +731,7 @@ bool SaveTokensPage::validatePage()
dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
#endif #endif
#else #else
dataDir = "data"; dataDir = qApp->applicationDirPath() + "/data";
#endif #endif
#ifdef PORTABLE_BUILD #ifdef PORTABLE_BUILD