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

View File

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