1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

move settings to qtox.ini

This commit is contained in:
Dubslow 2014-12-02 16:47:55 -06:00
parent 3f234fb2eb
commit 4a14155724
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
2 changed files with 21 additions and 10 deletions

View File

@ -36,7 +36,8 @@
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
#endif
const QString Settings::FILENAME = "settings.ini";
const QString Settings::OLDFILENAME = "settings.ini";
const QString Settings::FILENAME = "qtox.ini";
bool Settings::makeToxPortable{false};
Settings::Settings() :
@ -55,28 +56,37 @@ Settings& Settings::getInstance()
void Settings::load()
{
if (loaded) {
if (loaded)
return;
}
QFile portableSettings(FILENAME);
if (portableSettings.exists())
if (QFile(FILENAME).exists())
{
QSettings ps(FILENAME, QSettings::IniFormat);
ps.beginGroup("General");
makeToxPortable = ps.value("makeToxPortable", false).toBool();
ps.endGroup();
}
else if (QFile(OLDFILENAME).exists())
{
QSettings ps(OLDFILENAME, QSettings::IniFormat);
ps.beginGroup("General");
makeToxPortable = ps.value("makeToxPortable", false).toBool();
ps.endGroup();
}
else
makeToxPortable = false;
QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME);
QDir dir(getSettingsDirPath());
QString filePath = dir.filePath(FILENAME);
//if no settings file exist -- use the default one
QFile file(filePath);
if (!file.exists()) {
qDebug() << "No settings file found, using defaults";
filePath = ":/conf/" + FILENAME;
if (!QFile(filePath).exists())
{
if (!QFile(filePath = dir.filePath(OLDFILENAME)).exists())
{
qDebug() << "No settings file found, using defaults";
filePath = ":/conf/" + FILENAME;
}
}
qDebug() << "Settings: Loading from "<<filePath;

View File

@ -228,6 +228,7 @@ private:
Settings& operator=(const Settings&) = delete;
static const QString FILENAME;
static const QString OLDFILENAME;
bool loaded;