Browse Source

move settings to qtox.ini

pull/889/head
Dubslow 11 years ago
parent
commit
4a14155724
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
  1. 30
      src/misc/settings.cpp
  2. 1
      src/misc/settings.h

30
src/misc/settings.cpp

@ -36,7 +36,8 @@ @@ -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() @@ -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;

1
src/misc/settings.h

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

Loading…
Cancel
Save