|
|
@ -1150,8 +1150,8 @@ QString Core::sanitize(QString name) |
|
|
|
|
|
|
|
|
|
|
|
bool Core::loadConfiguration(QString path) |
|
|
|
bool Core::loadConfiguration(QString path) |
|
|
|
{ |
|
|
|
{ |
|
|
|
loadPath = ""; // if not empty, then user forgot a password
|
|
|
|
loadPath = ""; // if not empty upon return, then user forgot a password and is switching
|
|
|
|
// setting the profile is now the responsibility of the caller
|
|
|
|
|
|
|
|
QFile configurationFile(path); |
|
|
|
QFile configurationFile(path); |
|
|
|
qDebug() << "Core::loadConfiguration: reading from " << path; |
|
|
|
qDebug() << "Core::loadConfiguration: reading from " << path; |
|
|
|
|
|
|
|
|
|
|
@ -1183,17 +1183,17 @@ bool Core::loadConfiguration(QString path) |
|
|
|
QMetaObject::invokeMethod(Widget::getInstance(), "askProfiles", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, profile)); |
|
|
|
QMetaObject::invokeMethod(Widget::getInstance(), "askProfiles", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, profile)); |
|
|
|
|
|
|
|
|
|
|
|
if (!profile.isEmpty()) |
|
|
|
if (!profile.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT); |
|
|
|
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT); |
|
|
|
|
|
|
|
Settings::getInstance().switchProfile(profile); |
|
|
|
|
|
|
|
HistoryKeeper::getInstance()->resetInstance(); |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
configurationFile.close(); |
|
|
|
configurationFile.close(); |
|
|
|
|
|
|
|
|
|
|
|
Settings::getInstance().setCurrentProfile(QFileInfo(path).completeBaseName()); |
|
|
|
|
|
|
|
// this is necessary for anything that doesn't call switchConfiguration, i.e.
|
|
|
|
|
|
|
|
// forgetting a password and choosing a different profile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set GUI with user and statusmsg
|
|
|
|
// set GUI with user and statusmsg
|
|
|
|
QString name = getUsername(); |
|
|
|
QString name = getUsername(); |
|
|
|
if (!name.isEmpty()) |
|
|
|
if (!name.isEmpty()) |
|
|
@ -1233,7 +1233,7 @@ void Core::saveConfiguration() |
|
|
|
if (profile == "") // happens on creation of a new Tox ID
|
|
|
|
if (profile == "") // happens on creation of a new Tox ID
|
|
|
|
profile = getIDString(); |
|
|
|
profile = getIDString(); |
|
|
|
|
|
|
|
|
|
|
|
Settings::getInstance().setCurrentProfile(profile); |
|
|
|
Settings::getInstance().switchProfile(profile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString path = directory.filePath(profile + TOX_EXT); |
|
|
|
QString path = directory.filePath(profile + TOX_EXT); |
|
|
@ -1266,11 +1266,7 @@ void Core::switchConfiguration(const QString& profile) |
|
|
|
else |
|
|
|
else |
|
|
|
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT); |
|
|
|
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT); |
|
|
|
|
|
|
|
|
|
|
|
// the new profile needs to be set before resetting the settings, so that
|
|
|
|
Settings::getInstance().switchProfile(profile); |
|
|
|
// we don't load the old profile's profile.ini
|
|
|
|
|
|
|
|
Settings::getInstance().setCurrentProfile(profile); |
|
|
|
|
|
|
|
Settings::getInstance().save(false); // save new profile, but don't write old profile info to newprofile.ini
|
|
|
|
|
|
|
|
Settings::resetInstance(); |
|
|
|
|
|
|
|
HistoryKeeper::getInstance()->resetInstance(); |
|
|
|
HistoryKeeper::getInstance()->resetInstance(); |
|
|
|
|
|
|
|
|
|
|
|
start(); |
|
|
|
start(); |
|
|
|