mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fixed misusing tox_load; profiles are significantly less buggy
This commit is contained in:
parent
e477c4ef64
commit
05c654373f
30
core.cpp
30
core.cpp
|
@ -113,7 +113,7 @@ Core::~Core()
|
|||
alcCaptureCloseDevice(alInDev);
|
||||
}
|
||||
|
||||
void Core::start()
|
||||
void Core::get_tox()
|
||||
{
|
||||
// IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options.
|
||||
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
|
||||
|
@ -160,13 +160,18 @@ void Core::start()
|
|||
emit failedToStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Core::start()
|
||||
{
|
||||
get_tox();
|
||||
|
||||
qsrand(time(nullptr));
|
||||
|
||||
// where do we find the data file?
|
||||
QString path;
|
||||
{ // read data from whose profile?
|
||||
path = Settings::getSettingsDirPath() + '/' + Settings::getInstance().getCurrentProfile() + TOX_EXT;
|
||||
path = Settings::getSettingsDirPath() + QDir::separator() + Settings::getInstance().getCurrentProfile() + TOX_EXT;
|
||||
|
||||
#if 1 // deprecation attempt
|
||||
// if the last profile doesn't exist, fall back to old "data"
|
||||
|
@ -174,7 +179,7 @@ void Core::start()
|
|||
QFile file(path);
|
||||
if (!file.exists())
|
||||
{
|
||||
path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME;
|
||||
path = Settings::getSettingsDirPath() + QDir::separator() + CONFIG_FILE_NAME;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -909,10 +914,10 @@ void Core::saveConfiguration()
|
|||
Settings::getInstance().setCurrentProfile(profile);
|
||||
}
|
||||
|
||||
QString path = dir + '/' + profile + TOX_EXT;
|
||||
QString path = dir + QDir::separator() + profile + TOX_EXT;
|
||||
QFileInfo info(path);
|
||||
if (!info.exists()) // fall back to old school 'data'
|
||||
{ //path = dir + '/' + CONFIG_FILE_NAME;
|
||||
{ //path = dir + QDir::separator() + CONFIG_FILE_NAME;
|
||||
qDebug() << path << " does not exist";
|
||||
}
|
||||
|
||||
|
@ -946,6 +951,21 @@ void Core::saveConfiguration(const QString& path)
|
|||
Settings::getInstance().save();
|
||||
}
|
||||
|
||||
void Core::switchConfiguration(QString profile)
|
||||
{
|
||||
saveConfiguration();
|
||||
|
||||
if (tox) {
|
||||
toxav_kill(toxav);
|
||||
tox_kill(tox);
|
||||
}
|
||||
|
||||
get_tox();
|
||||
|
||||
Settings::getInstance().setCurrentProfile(profile);
|
||||
loadConfiguration(Settings::getSettingsDirPath() + QDir::separator() + profile + TOX_EXT);
|
||||
}
|
||||
|
||||
void Core::loadFriends()
|
||||
{
|
||||
const uint32_t friendCount = tox_count_friendlist(tox);
|
||||
|
|
9
core.h
9
core.h
|
@ -127,9 +127,7 @@ public:
|
|||
|
||||
void saveConfiguration();
|
||||
void saveConfiguration(const QString& path);
|
||||
void loadConfiguration(QString path);
|
||||
|
||||
static QString sanitize(QString name);
|
||||
void switchConfiguration(QString profile);
|
||||
|
||||
QString getIDString();
|
||||
|
||||
|
@ -286,6 +284,11 @@ private:
|
|||
|
||||
void checkConnection();
|
||||
void onBootstrapTimer();
|
||||
|
||||
void loadConfiguration(QString path);
|
||||
static QString sanitize(QString name);
|
||||
|
||||
void get_tox();
|
||||
|
||||
void loadFriends();
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ QList<QString> SettingsForm::searchProfiles()
|
|||
|
||||
QString SettingsForm::getSelectedSavePath()
|
||||
{
|
||||
return Settings::getSettingsDirPath() + profiles.currentText() + Widget::getInstance()->getCore()->TOX_EXT;
|
||||
return Settings::getSettingsDirPath() + QDir::separator() + profiles.currentText() + Widget::getInstance()->getCore()->TOX_EXT;
|
||||
}
|
||||
|
||||
void SettingsForm::setFriendAddress(const QString& friendAddress)
|
||||
|
@ -143,15 +143,13 @@ void SettingsForm::show(Ui::MainWindow &ui)
|
|||
|
||||
void SettingsForm::onLoadClicked()
|
||||
{
|
||||
Widget::getInstance()->getCore()->saveConfiguration();
|
||||
Settings::getInstance().setCurrentProfile(profiles.currentText());
|
||||
Widget::getInstance()->getCore()->loadConfiguration(getSelectedSavePath());
|
||||
Widget::getInstance()->getCore()->switchConfiguration(profiles.currentText());
|
||||
}
|
||||
|
||||
void SettingsForm::onExportClicked()
|
||||
{
|
||||
QString current = getSelectedSavePath();
|
||||
QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"), QDir::homePath() + '/' + profiles.currentText() + Widget::getInstance()->getCore()->TOX_EXT, tr("Tox save file (*.tox)", "save dialog filter"));
|
||||
QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"), QDir::homePath() + QDir::separator() + profiles.currentText() + Widget::getInstance()->getCore()->TOX_EXT, tr("Tox save file (*.tox)", "save dialog filter"));
|
||||
QFile::copy(getSelectedSavePath(), path);
|
||||
}
|
||||
|
||||
|
@ -181,8 +179,8 @@ void SettingsForm::onImportClicked()
|
|||
QString profilePath = Settings::getSettingsDirPath() + profile + Widget::getInstance()->getCore()->TOX_EXT;
|
||||
Settings::getInstance().setCurrentProfile(profile);
|
||||
QFile::copy(path, profilePath);
|
||||
Widget::getInstance()->getCore()->loadConfiguration(profilePath);
|
||||
profiles.addItem(profile);
|
||||
Widget::getInstance()->getCore()->switchConfiguration(profile);
|
||||
}
|
||||
|
||||
void SettingsForm::onTestVideoClicked()
|
||||
|
|
Loading…
Reference in New Issue
Block a user