mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
more incremental changes, nothing works yet
(I just want to change branches)
This commit is contained in:
parent
f9a3192f30
commit
b4a42cb34a
30
core.cpp
30
core.cpp
|
@ -732,6 +732,7 @@ QString Core::sanitize(QString name)
|
||||||
void Core::loadConfiguration(QString path)
|
void Core::loadConfiguration(QString path)
|
||||||
{ // note to self: this really needs refactoring into the GUI, making the path mandatory here
|
{ // note to self: this really needs refactoring into the GUI, making the path mandatory here
|
||||||
// but for now it's bedtime
|
// but for now it's bedtime
|
||||||
|
// also loadFriends/clearFriends is borked as fuck
|
||||||
if (path == "")
|
if (path == "")
|
||||||
{
|
{
|
||||||
// read from settings whose profile?
|
// read from settings whose profile?
|
||||||
|
@ -784,15 +785,7 @@ void Core::loadConfiguration(QString path)
|
||||||
loadFriends();
|
loadFriends();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::saveConfiguration(QString path)
|
void Core::saveConfiguration()
|
||||||
{
|
|
||||||
if (!tox)
|
|
||||||
{
|
|
||||||
qWarning() << "Core::saveConfiguration: Tox not started, aborting!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == "")
|
|
||||||
{
|
{
|
||||||
QString dir = Settings::getSettingsDirPath();
|
QString dir = Settings::getSettingsDirPath();
|
||||||
QDir directory(dir);
|
QDir directory(dir);
|
||||||
|
@ -801,12 +794,27 @@ void Core::saveConfiguration(QString path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = dir + Settings::getInstance().getCurrentProfile() + TOX_EXT;
|
QString profile = Settings::getInstance().getCurrentProfile();
|
||||||
QFileInfo info(dir);
|
if (profile == "")
|
||||||
|
{ // no profile active; this should only happen on startup, if at all
|
||||||
|
profile = sanitize(getUsername());
|
||||||
|
Settings::getInstance().setCurrentProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path = dir + profile + TOX_EXT;
|
||||||
|
QFileInfo info(path);
|
||||||
if (!info.exists()) // fall back to old school 'data'
|
if (!info.exists()) // fall back to old school 'data'
|
||||||
path = dir + '/' + CONFIG_FILE_NAME;
|
path = dir + '/' + CONFIG_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::saveConfiguration(const QString& path)
|
||||||
|
{
|
||||||
|
if (!tox)
|
||||||
|
{
|
||||||
|
qWarning() << "Core::saveConfiguration: Tox not started, aborting!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QSaveFile configurationFile(path);
|
QSaveFile configurationFile(path);
|
||||||
if (!configurationFile.open(QIODevice::WriteOnly)) {
|
if (!configurationFile.open(QIODevice::WriteOnly)) {
|
||||||
qCritical() << "File " << path << " cannot be opened";
|
qCritical() << "File " << path << " cannot be opened";
|
||||||
|
|
6
core.h
6
core.h
|
@ -124,8 +124,10 @@ public:
|
||||||
void quitGroupChat(int groupId) const;
|
void quitGroupChat(int groupId) const;
|
||||||
void dispatchVideoFrame(vpx_image img) const;
|
void dispatchVideoFrame(vpx_image img) const;
|
||||||
|
|
||||||
void saveConfiguration(QString path = "");
|
void saveConfiguration();
|
||||||
void loadConfiguration(QString path = "");
|
void saveConfiguration(const QString& path);
|
||||||
|
void loadConfiguration(QString path);
|
||||||
|
|
||||||
static QString sanitize(QString name);
|
static QString sanitize(QString name);
|
||||||
|
|
||||||
QString getUsername();
|
QString getUsername();
|
||||||
|
|
|
@ -81,7 +81,7 @@ void Settings::load()
|
||||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||||
useTranslations = s.value("useTranslations", true).toBool();
|
useTranslations = s.value("useTranslations", true).toBool();
|
||||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||||
currentProfile = s.value("currentProfile", ".data").toString();
|
currentProfile = s.value("currentProfile", "").toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Widgets");
|
s.beginGroup("Widgets");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user