Commit a05f3223 authored by Karel Slaný's avatar Karel Slaný
Browse files

Fixed Settings::saveToSettings() and Settings::loadFromSettings().

Made them work on any Settings instance, not just globSet.
parent 1e11ade0
......@@ -58,35 +58,33 @@ void Settings::saveToSettings(QSettings &settings) const
qDebug("%s()", __func__);
settings.beginGroup(SETTINGS_GLOBAL_GROUP);
settings.setValue(SETTINGS_LANGUAGE, globSet.language);
settings.setValue(SETTINGS_FONTSIZE, globSet.fontSize);
settings.setValue(SETTINGS_ONLY_NEW_MSGS, globSet.downloadOnlyNewMsgs);
settings.setValue(SETTINGS_COMPLETE_MSG, globSet.downloadCompleteMsgs);
settings.setValue(SETTINGS_MSG_LIFETIME_IN_DAYS, globSet.msgLifeTimeInDays);
settings.setValue(SETTINGS_FILE_LIFETIME_IN_DAYS,
globSet.fileLifeTimeInDays);
if (!globSet._pinVal.isEmpty()) {
settings.setValue(SETTINGS_LANGUAGE, language);
settings.setValue(SETTINGS_FONTSIZE, fontSize);
settings.setValue(SETTINGS_ONLY_NEW_MSGS, downloadOnlyNewMsgs);
settings.setValue(SETTINGS_COMPLETE_MSG, downloadCompleteMsgs);
settings.setValue(SETTINGS_MSG_LIFETIME_IN_DAYS, msgLifeTimeInDays);
settings.setValue(SETTINGS_FILE_LIFETIME_IN_DAYS, fileLifeTimeInDays);
if (!_pinVal.isEmpty()) {
//settings.setValue(SETTINGS_PIN_VAL,
// QString::fromUtf8(globSet._pinVal.toUtf8().toBase64()));
// QString::fromUtf8(_pinVal.toUtf8().toBase64()));
Q_ASSERT(!globSet.pinAlg.isEmpty());
settings.setValue(SETTINGS_PIN_ALG,
globSet.pinAlg);
Q_ASSERT(!pinAlg.isEmpty());
settings.setValue(SETTINGS_PIN_ALG, pinAlg);
Q_ASSERT(!globSet.pinSalt.isEmpty());
Q_ASSERT(!pinSalt.isEmpty());
settings.setValue(SETTINGS_PIN_SALT,
QString::fromUtf8(globSet.pinSalt.toBase64()));
QString::fromUtf8(pinSalt.toBase64()));
Q_ASSERT(!globSet.pinCode.isEmpty());
Q_ASSERT(!pinCode.isEmpty());
settings.setValue(SETTINGS_PIN_CODE,
QString::fromUtf8(globSet.pinCode.toBase64()));
QString::fromUtf8(pinCode.toBase64()));
}
settings.setValue(SETTINGS_LAST_UPDATE, globSet.lastUpdate);
settings.setValue(SETTINGS_LAST_UPDATE, lastUpdate);
if (globSet.dbsLocation != getDefaultDbAndConfigLocation()) {
settings.setValue(SETTINGS_DBS_LOCATION, globSet.dbsLocation);
if (dbsLocation != getDefaultDbAndConfigLocation()) {
settings.setValue(SETTINGS_DBS_LOCATION, dbsLocation);
}
settings.endGroup();
......@@ -96,47 +94,44 @@ void Settings::loadFromSettings(const QSettings &settings)
{
qDebug("%s()", __func__);
globSet.language = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_LANGUAGE,
language = settings.value(SETTINGS_GLOBAL_GROUP "/" SETTINGS_LANGUAGE,
LANGUAGE_SYSTEM).toString();
globSet.fontSize = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_FONTSIZE,
fontSize = settings.value(SETTINGS_GLOBAL_GROUP "/" SETTINGS_FONTSIZE,
DEFAULT_FONT_SIZE).toInt();
globSet.downloadOnlyNewMsgs = settings.value(
downloadOnlyNewMsgs = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_ONLY_NEW_MSGS, true).toBool();
globSet.downloadCompleteMsgs = settings.value(
downloadCompleteMsgs = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_COMPLETE_MSG, false).toBool();
globSet.msgLifeTimeInDays = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_MSG_LIFETIME_IN_DAYS, DEFAULT_MSG_LIFETIME).toInt();
globSet.fileLifeTimeInDays = settings.value(
msgLifeTimeInDays = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_MSG_LIFETIME_IN_DAYS,
DEFAULT_MSG_LIFETIME).toInt();
fileLifeTimeInDays = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_FILE_LIFETIME_IN_DAYS,
DEFAULT_FILE_LIFETIME).toInt();
//globSet._pinVal = QString::fromUtf8(QByteArray::fromBase64(
//_pinVal = QString::fromUtf8(QByteArray::fromBase64(
// settings.value(SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_VAL,
// QString()).toString().toUtf8()));
globSet.pinAlg = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_ALG, QString()).toString();
pinAlg = settings.value(SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_ALG,
QString()).toString();
globSet.pinSalt = QByteArray::fromBase64(
settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_SALT,
QString()).toString().toUtf8());
pinSalt = QByteArray::fromBase64(settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_SALT,
QString()).toString().toUtf8());
globSet.pinCode = QByteArray::fromBase64(
settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_CODE,
QString()).toString().toUtf8());
pinCode = QByteArray::fromBase64(settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_CODE,
QString()).toString().toUtf8());
globSet.lastUpdate = settings.value(
lastUpdate = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_LAST_UPDATE).toString();
globSet.dbsLocation = settings.value(
dbsLocation = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_DBS_LOCATION).toString();
if (globSet.dbsLocation.isEmpty()) {
globSet.dbsLocation = getDefaultDbAndConfigLocation();
if (dbsLocation.isEmpty()) {
dbsLocation = getDefaultDbAndConfigLocation();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment