1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Remove deprecated profile management functions

This commit is contained in:
tux3 2015-06-04 11:37:54 +02:00
parent 933dce485d
commit abf65a5060
14 changed files with 85 additions and 393 deletions

View File

@ -103,7 +103,7 @@ Core::~Core()
{ {
qDebug() << "Deleting Core"; qDebug() << "Deleting Core";
saveConfiguration(); profile.saveToxSave();
toxTimer->stop(); toxTimer->stop();
coreThread->exit(0); coreThread->exit(0);
while (coreThread->isRunning()) while (coreThread->isRunning())
@ -339,7 +339,7 @@ void Core::start()
// This is useful for e.g. the profileForm that searches for saves. // This is useful for e.g. the profileForm that searches for saves.
if (isNewProfile) if (isNewProfile)
{ {
saveConfiguration(); profile.saveToxSave();
emit idSet(getSelfId().toString()); emit idSet(getSelfId().toString());
} }
@ -582,7 +582,7 @@ void Core::acceptFriendRequest(const QString& userId)
} }
else else
{ {
saveConfiguration(); profile.saveToxSave();
emit friendAdded(friendId, userId); emit friendAdded(friendId, userId);
} }
} }
@ -627,7 +627,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag
emit friendAdded(friendId, userId); emit friendAdded(friendId, userId);
} }
} }
saveConfiguration(); profile.saveToxSave();
} }
int Core::sendMessage(uint32_t friendId, const QString& message) int Core::sendMessage(uint32_t friendId, const QString& message)
@ -742,7 +742,7 @@ void Core::removeFriend(uint32_t friendId, bool fake)
} }
else else
{ {
saveConfiguration(); profile.saveToxSave();
emit friendRemoved(friendId); emit friendRemoved(friendId);
} }
} }
@ -780,7 +780,7 @@ void Core::setUsername(const QString& username)
else else
{ {
emit usernameSet(username); emit usernameSet(username);
saveConfiguration(); profile.saveToxSave();
} }
} }
@ -844,7 +844,7 @@ void Core::setStatusMessage(const QString& message)
} }
else else
{ {
saveConfiguration(); profile.saveToxSave();
emit statusMessageSet(message); emit statusMessageSet(message);
} }
} }
@ -869,7 +869,7 @@ void Core::setStatus(Status status)
} }
tox_self_set_status(tox, userstatus); tox_self_set_status(tox, userstatus);
saveConfiguration(); profile.saveToxSave();
emit statusSet(status); emit statusSet(status);
} }
@ -890,84 +890,13 @@ QString Core::sanitize(QString name)
return name; return name;
} }
void Core::saveConfiguration() QByteArray Core::getToxSaveData()
{ {
if (QThread::currentThread() != coreThread) uint32_t fileSize = tox_get_savedata_size(tox);
return (void) QMetaObject::invokeMethod(this, "saveConfiguration"); QByteArray data;
data.resize(fileSize);
if (!isReady()) tox_get_savedata(tox, (uint8_t*)data.data());
return; return data;
ProfileLocker::assertLock();
QString dir = Settings::getSettingsDirPath();
QDir directory(dir);
if (!directory.exists() && !directory.mkpath(directory.absolutePath()))
{
qCritical() << "Error while creating directory " << dir;
return;
}
QString profile = Settings::getInstance().getCurrentProfile();
if (profile == "")
{ // no profile active; this should only happen on startup, if at all
profile = sanitize(getUsername());
if (profile == "") // happens on creation of a new Tox ID
profile = getIDString();
Settings::getInstance().switchProfile(profile);
}
QString path = directory.filePath(profile + TOX_EXT);
saveConfiguration(path);
}
void Core::switchConfiguration(const QString& _profile)
{
QString profile = QFileInfo(_profile).baseName();
// If we can't get a lock, then another instance is already using that profile
while (!profile.isEmpty() && !ProfileLocker::lock(profile))
{
qWarning() << "Profile "<<profile<<" is already in use, pick another";
GUI::showWarning(tr("Profile already in use"),
tr("This profile is already used by another qTox instance\n"
"Please select another profile"));
do {
profile = Settings::getInstance().askProfiles();
} while (profile.isEmpty());
}
if (profile.isEmpty())
qDebug() << "creating new Id";
else
qDebug() << "switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile;
saveConfiguration();
saveCurrentInformation(); // part of a hack, see core.h
ready = false;
GUI::setEnabled(false);
clearPassword(ptMain);
clearPassword(ptHistory);
toxTimer->stop();
deadifyTox();
emit selfAvatarChanged(QPixmap(":/img/contact_dark.svg"));
emit blockingClearContacts(); // we need this to block, but signals are required for thread safety
//if (profile.isEmpty())
//loadPath = "";
//else
// loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT);
Settings::getInstance().switchProfile(profile);
HistoryKeeper::resetInstance();
start();
} }
void Core::loadFriends() void Core::loadFriends()

View File

@ -92,9 +92,7 @@ public slots:
void process(); ///< Processes toxcore events and ensure we stay connected, called by its own timer void process(); ///< Processes toxcore events and ensure we stay connected, called by its own timer
void bootstrapDht(); ///< Connects us to the Tox network void bootstrapDht(); ///< Connects us to the Tox network
void saveConfiguration(); QByteArray getToxSaveData(); ///< Returns the unencrypted tox save data
void saveConfiguration(const QString& path);
void switchConfiguration(const QString& profile); ///< Load a different profile and restart the core
void acceptFriendRequest(const QString& userId); void acceptFriendRequest(const QString& userId);
void requestFriendship(const QString& friendAddress, const QString& message); void requestFriendship(const QString& friendAddress, const QString& message);
@ -303,16 +301,6 @@ private:
TOX_PASS_KEY* pwsaltedkeys[PasswordType::ptCounter] = {nullptr}; // use the pw's hash as the "pw" TOX_PASS_KEY* pwsaltedkeys[PasswordType::ptCounter] = {nullptr}; // use the pw's hash as the "pw"
// Hack for reloading current profile if switching to an encrypted one fails.
// Testing the passwords before killing the current profile is perfectly doable,
// however it would require major refactoring;
// the Core class as a whole also requires major refactoring (especially to support multiple IDs at once),
// so I'm punting on this until then, when it would get fixed anyways
TOX_PASS_KEY* backupkeys[PasswordType::ptCounter] = {nullptr};
QString* backupProfile = nullptr;
void saveCurrentInformation();
QString loadOldInformation();
static const int videobufsize; static const int videobufsize;
static uint8_t* videobuf; static uint8_t* videobuf;

View File

@ -62,43 +62,6 @@ void Core::clearPassword(PasswordType passtype)
pwsaltedkeys[passtype] = nullptr; pwsaltedkeys[passtype] = nullptr;
} }
// part of a hack, see core.h
void Core::saveCurrentInformation()
{
if (pwsaltedkeys[ptMain])
{
backupkeys[ptMain] = new TOX_PASS_KEY;
std::copy(pwsaltedkeys[ptMain], pwsaltedkeys[ptMain]+1, backupkeys[ptMain]);
}
if (pwsaltedkeys[ptHistory])
{
backupkeys[ptHistory] = new TOX_PASS_KEY;
std::copy(pwsaltedkeys[ptHistory], pwsaltedkeys[ptHistory]+1, backupkeys[ptHistory]);
}
backupProfile = new QString(Settings::getInstance().getCurrentProfile());
}
QString Core::loadOldInformation()
{
QString out;
if (backupProfile)
{
out = *backupProfile;
delete backupProfile;
backupProfile = nullptr;
}
backupProfile = nullptr;
clearPassword(ptMain);
clearPassword(ptHistory);
// we can just copy the pointer, as long as we null out backupkeys
// (if backupkeys was null anyways, then this is a null-op)
pwsaltedkeys[ptMain] = backupkeys[ptMain];
pwsaltedkeys[ptHistory] = backupkeys[ptHistory];
backupkeys[ptMain] = nullptr;
backupkeys[ptHistory] = nullptr;
return out;
}
QByteArray Core::encryptData(const QByteArray& data, PasswordType passtype) QByteArray Core::encryptData(const QByteArray& data, PasswordType passtype)
{ {
if (!pwsaltedkeys[passtype]) if (!pwsaltedkeys[passtype])
@ -228,72 +191,3 @@ void Core::checkEncryptedHistory()
dialogtxt = a + "\n" + c + "\n" + b; dialogtxt = a + "\n" + c + "\n" + b;
} while (error); } while (error);
} }
void Core::saveConfiguration(const QString& path)
{
if (QThread::currentThread() != coreThread)
return (void) QMetaObject::invokeMethod(this, "saveConfiguration", Q_ARG(const QString&, path));
if (!isReady())
{
qWarning() << "saveConfiguration: Tox not started, aborting!";
return;
}
QSaveFile configurationFile(path);
if (!configurationFile.open(QIODevice::WriteOnly))
{
qCritical() << "File " << path << " cannot be opened";
return;
}
qDebug() << "writing tox_save to " << path;
uint32_t fileSize = tox_get_savedata_size(tox);
bool encrypt = Settings::getInstance().getEncryptTox();
if (fileSize > 0 && fileSize <= std::numeric_limits<int32_t>::max())
{
uint8_t *data = new uint8_t[fileSize];
if (encrypt)
{
if (!pwsaltedkeys[ptMain])
{
// probably zero chance event
GUI::showWarning(tr("NO Password"), tr("Local file encryption is enabled, but there is no password! It will be disabled."));
Settings::getInstance().setEncryptTox(false);
tox_get_savedata(tox, data);
}
else
{
tox_get_savedata(tox, data);
uint8_t* newData = new uint8_t[fileSize+TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
if (tox_pass_key_encrypt(data, fileSize, pwsaltedkeys[ptMain], newData, nullptr))
{
delete[] data;
data = newData;
fileSize+=TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
}
else
{
delete[] newData;
delete[] data;
qCritical() << "Core::saveConfiguration(QString): Encryption failed, couldn't save";
configurationFile.cancelWriting();
return;
}
}
}
else
{
tox_get_savedata(tox, data);
}
configurationFile.write(reinterpret_cast<char *>(data), fileSize);
configurationFile.commit();
delete[] data;
}
Settings::getInstance().save();
}

View File

@ -1282,3 +1282,11 @@ void Settings::createPersonal(QString basename)
ps.beginGroup("Privacy"); ps.beginGroup("Privacy");
ps.endGroup(); ps.endGroup();
} }
void Settings::createSettingsDir()
{
QString dir = Settings::getSettingsDirPath();
QDir directory(dir);
if (!directory.exists() && !directory.mkpath(directory.absolutePath()))
qCritical() << "Error while creating directory " << dir;
}

View File

@ -36,6 +36,7 @@ public:
QString detectProfile(); QString detectProfile();
QList<QString> searchProfiles(); QList<QString> searchProfiles();
QString askProfiles(); QString askProfiles();
void createSettingsDir(); ///< Creates a path to the settings dir, if it doesn't already exist
void createPersonal(QString basename); ///< Write a default personnal settings file for a profile void createPersonal(QString basename); ///< Write a default personnal settings file for a profile

View File

@ -148,7 +148,6 @@ void Nexus::showMainGUI()
connect(widget, &Widget::statusSet, core, &Core::setStatus); connect(widget, &Widget::statusSet, core, &Core::setStatus);
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship); connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);
connect(widget, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest); connect(widget, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);
connect(widget, &Widget::changeProfile, core, &Core::switchConfiguration);
#endif #endif
profile->startCore(); profile->startCore();

View File

@ -184,6 +184,11 @@ fail:
return data; return data;
} }
void Profile::saveToxSave()
{
saveToxSave(core->getToxSaveData());
}
void Profile::saveToxSave(QByteArray data) void Profile::saveToxSave(QByteArray data)
{ {
ProfileLocker::assertLock(); ProfileLocker::assertLock();

View File

@ -27,7 +27,8 @@ public:
void startCore(); ///< Starts the Core thread void startCore(); ///< Starts the Core thread
bool isNewProfile(); bool isNewProfile();
QByteArray loadToxSave(); ///< Loads the profile's .tox save from file, unencrypted QByteArray loadToxSave(); ///< Loads the profile's .tox save from file, unencrypted
void saveToxSave(QByteArray data); ///< Saves the profile's .tox save, encrypted if needed void saveToxSave(); ///< Saves the profile's .tox save, encrypted if needed
void saveToxSave(QByteArray data); ///< Saves the profile's .tox save with this data, encrypted if needed
/// Scan for profile, automatically importing them if needed /// Scan for profile, automatically importing them if needed
/// NOT thread-safe /// NOT thread-safe

View File

@ -26,6 +26,7 @@
#include "src/historykeeper.h" #include "src/historykeeper.h"
#include "src/misc/style.h" #include "src/misc/style.h"
#include "src/profilelocker.h" #include "src/profilelocker.h"
#include "src/profile.h"
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QGroupBox> #include <QGroupBox>
@ -35,17 +36,6 @@
#include <QFileDialog> #include <QFileDialog>
#include <QBuffer> #include <QBuffer>
void ProfileForm::refreshProfiles()
{
bodyUI->profiles->clear();
for (QString profile : Settings::getInstance().searchProfiles())
bodyUI->profiles->addItem(profile);
QString current = Settings::getInstance().getCurrentProfile();
if (current != "")
bodyUI->profiles->setCurrentText(current);
}
ProfileForm::ProfileForm(QWidget *parent) : ProfileForm::ProfileForm(QWidget *parent) :
QWidget{parent}, qr{nullptr} QWidget{parent}, qr{nullptr}
{ {
@ -98,25 +88,12 @@ ProfileForm::ProfileForm(QWidget *parent) :
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
connect(core, &Core::idSet, this, &ProfileForm::setToxId); connect(core, &Core::idSet, this, &ProfileForm::setToxId);
connect(core, &Core::statusSet, this, &ProfileForm::onStatusSet);
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
connect(bodyUI->loadButton, &QPushButton::clicked, this, &ProfileForm::onLoadClicked);
connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked); connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked);
connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked); connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked);
connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked); connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked);
connect(bodyUI->importButton, &QPushButton::clicked, this, &ProfileForm::onImportClicked); connect(bodyUI->logoutButton, &QPushButton::clicked, this, &ProfileForm::onLogoutClicked);
connect(bodyUI->newButton, &QPushButton::clicked, this, &ProfileForm::onNewClicked);
connect(core, &Core::avStart, this, &ProfileForm::disableSwitching);
connect(core, &Core::avStarting, this, &ProfileForm::disableSwitching);
connect(core, &Core::avInvite, this, &ProfileForm::disableSwitching);
connect(core, &Core::avRinging, this, &ProfileForm::disableSwitching);
connect(core, &Core::avCancel, this, &ProfileForm::enableSwitching);
connect(core, &Core::avEnd, this, &ProfileForm::enableSwitching);
connect(core, &Core::avEnding, this, &ProfileForm::enableSwitching);
connect(core, &Core::avPeerTimeout, this, &ProfileForm::enableSwitching);
connect(core, &Core::avRequestTimeout, this, &ProfileForm::enableSwitching);
connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); }); connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); });
connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); }); connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); });
@ -187,7 +164,6 @@ void ProfileForm::setToxId(const QString& id)
qr = new QRWidget(); qr = new QRWidget();
qr->setQRData("tox:"+id); qr->setQRData("tox:"+id);
bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150))); bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150)));
refreshProfiles();
} }
void ProfileForm::onAvatarClicked() void ProfileForm::onAvatarClicked()
@ -250,22 +226,9 @@ void ProfileForm::onAvatarClicked()
Nexus::getCore()->setAvatar(bytes); Nexus::getCore()->setAvatar(bytes);
} }
void ProfileForm::onLoadClicked()
{
if (bodyUI->profiles->currentText() != Settings::getInstance().getCurrentProfile())
{
if (Core::getInstance()->anyActiveCalls())
GUI::showWarning(tr("Call active", "popup title"),
tr("You can't switch profiles while a call is active!", "popup text"));
else
emit Widget::getInstance()->changeProfile(bodyUI->profiles->currentText());
// I think by directly calling the function, I may have been causing thread issues
}
}
void ProfileForm::onRenameClicked() void ProfileForm::onRenameClicked()
{ {
QString cur = bodyUI->profiles->currentText(); /** TODO: Create a rename (low level) function in Profile, use it
QString title = tr("Rename \"%1\"", "renaming a profile").arg(cur); QString title = tr("Rename \"%1\"", "renaming a profile").arg(cur);
do do
{ {
@ -297,11 +260,12 @@ void ProfileForm::onRenameClicked()
break; break;
} }
} while (true); } while (true);
*/
} }
void ProfileForm::onExportClicked() void ProfileForm::onExportClicked()
{ {
QString current = bodyUI->profiles->currentText() + Core::TOX_EXT; QString current = Nexus::getProfile()->getName() + Core::TOX_EXT;
QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"), QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"),
QDir::home().filePath(current), QDir::home().filePath(current),
tr("Tox save file (*.tox)", "save dialog filter")); tr("Tox save file (*.tox)", "save dialog filter"));
@ -319,6 +283,7 @@ void ProfileForm::onExportClicked()
void ProfileForm::onDeleteClicked() void ProfileForm::onDeleteClicked()
{ {
/** Add a delete function in profile
if (Settings::getInstance().getCurrentProfile() == bodyUI->profiles->currentText()) if (Settings::getInstance().getCurrentProfile() == bodyUI->profiles->currentText())
{ {
GUI::showWarning(tr("Profile currently loaded","current profile deletion warning title"), tr("This profile is currently in use. Please load a different profile before deleting this one.","current profile deletion warning text")); GUI::showWarning(tr("Profile currently loaded","current profile deletion warning title"), tr("This profile is currently in use. Please load a different profile before deleting this one.","current profile deletion warning text"));
@ -340,76 +305,22 @@ void ProfileForm::onDeleteClicked()
bodyUI->profiles->setCurrentText(Settings::getInstance().getCurrentProfile()); bodyUI->profiles->setCurrentText(Settings::getInstance().getCurrentProfile());
} }
} }
*/
} }
void ProfileForm::onImportClicked() void ProfileForm::onLogoutClicked()
{ {
QString path = QFileDialog::getOpenFileName(0, /// TODO: Save and call Nexus show login?
tr("Import profile", "import dialog title"),
QDir::homePath(),
tr("Tox save file (*.tox)", "import dialog filter"));
if (path.isEmpty())
return;
QFileInfo info(path);
QString profile = info.completeBaseName();
if (info.suffix() != "tox")
{
GUI::showWarning(tr("Ignoring non-Tox file", "popup title"),
tr("Warning: you've chosen a file that is not a Tox save file; ignoring.", "popup text"));
return;
}
QString profilePath = QDir(Settings::getSettingsDirPath()).filePath(profile + Core::TOX_EXT);
if (QFileInfo(profilePath).exists() && !GUI::askQuestion(tr("Profile already exists", "import confirm title"),
tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
return;
QFile::copy(path, profilePath);
bodyUI->profiles->addItem(profile);
} }
void ProfileForm::onStatusSet(Status) void ProfileForm::onCopyQrClicked()
{
refreshProfiles();
}
void ProfileForm::onNewClicked()
{
emit Widget::getInstance()->changeProfile(QString());
}
void ProfileForm::disableSwitching()
{
bodyUI->loadButton->setEnabled(false);
bodyUI->newButton->setEnabled(false);
}
void ProfileForm::enableSwitching()
{
if (!core->anyActiveCalls())
{
bodyUI->loadButton->setEnabled(true);
bodyUI->newButton->setEnabled(true);
}
}
void ProfileForm::showEvent(QShowEvent *event)
{
refreshProfiles();
QWidget::showEvent(event);
}
void ProfileForm::on_copyQr_clicked()
{ {
QApplication::clipboard()->setImage(*qr->getImage()); QApplication::clipboard()->setImage(*qr->getImage());
} }
void ProfileForm::on_saveQr_clicked() void ProfileForm::onSaveQrClicked()
{ {
QString current = bodyUI->profiles->currentText() + ".png"; QString current = Nexus::getProfile()->getName() + ".png";
QString path = QFileDialog::getSaveFileName(0, tr("Save", "save qr image"), QString path = QFileDialog::getSaveFileName(0, tr("Save", "save qr image"),
QDir::home().filePath(current), QDir::home().filePath(current),
tr("Save QrCode (*.png)", "save dialog filter")); tr("Save QrCode (*.png)", "save dialog filter"));
@ -424,14 +335,3 @@ void ProfileForm::on_saveQr_clicked()
GUI::showWarning(tr("Failed to copy file"), tr("The file you chose could not be written to.")); GUI::showWarning(tr("Failed to copy file"), tr("The file you chose could not be written to."));
} }
} }
bool ProfileForm::eventFilter(QObject *o, QEvent *e)
{
if ((e->type() == QEvent::Wheel) &&
(qobject_cast<QComboBox*>(o) || qobject_cast<QAbstractSpinBox*>(o) ))
{
e->ignore();
return true;
}
return QWidget::eventFilter(o, e);
}

View File

@ -56,7 +56,6 @@ signals:
public slots: public slots:
void onSelfAvatarLoaded(const QPixmap &pic); void onSelfAvatarLoaded(const QPixmap &pic);
void onStatusSet(Status status);
private slots: private slots:
void setToxId(const QString& id); void setToxId(const QString& id);
@ -64,21 +63,12 @@ private slots:
void onAvatarClicked(); void onAvatarClicked();
void onUserNameEdited(); void onUserNameEdited();
void onStatusMessageEdited(); void onStatusMessageEdited();
void onLoadClicked();
void onRenameClicked(); void onRenameClicked();
void onExportClicked(); void onExportClicked();
void onDeleteClicked(); void onDeleteClicked();
void onImportClicked(); void onLogoutClicked();
void onNewClicked(); void onCopyQrClicked();
void disableSwitching(); void onSaveQrClicked();
void enableSwitching();
void on_copyQr_clicked();
void on_saveQr_clicked();
protected:
virtual void showEvent(QShowEvent *);
bool eventFilter(QObject *o, QEvent *e);
private: private:
void refreshProfiles(); void refreshProfiles();

View File

@ -37,10 +37,10 @@
<widget class="QWidget" name="scrollAreaWidgetContents"> <widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>-3</x>
<y>0</y> <y>0</y>
<width>565</width> <width>630</width>
<height>617</height> <height>625</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -160,55 +160,44 @@ Share it with your friends to communicate.</string>
<item alignment="Qt::AlignTop"> <item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="profilesGroup"> <widget class="QGroupBox" name="profilesGroup">
<property name="title"> <property name="title">
<string>Profiles</string> <string>Profile</string>
</property> </property>
<layout class="QVBoxLayout" name="profilesVLayout"> <layout class="QVBoxLayout" name="profilesVLayout">
<item>
<layout class="QHBoxLayout" name="profilesComboLayout">
<item>
<widget class="QLabel" name="profilesLabel">
<property name="text">
<string>Available profiles:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string comment="toolTip for currently set profile">Currently selected profile.</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="profilesButtonsLayout"> <layout class="QHBoxLayout" name="profilesButtonsLayout">
<item> <item>
<widget class="QPushButton" name="loadButton"> <spacer name="horizontalSpacer">
<property name="toolTip"> <property name="orientation">
<string comment="tooltip for loading profile button">Load selected profile and switch to it.</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string comment="load profile button">Load</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="renameButton"> <widget class="QPushButton" name="renameButton">
<property name="toolTip"> <property name="toolTip">
<string comment="tooltip for renaming profile button">Rename selected profile.</string> <string comment="tooltip for renaming profile button">Rename profile.</string>
</property> </property>
<property name="text"> <property name="text">
<string comment="rename profile button">Rename</string> <string comment="rename profile button">Rename</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="toolTip">
<string comment="delete profile button tooltip">Delete profile.</string>
</property>
<property name="text">
<string comment="delete profile button">Delete</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="exportButton"> <widget class="QPushButton" name="exportButton">
<property name="toolTip"> <property name="toolTip">
@ -221,38 +210,27 @@ Profile does not contain your history.</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="deleteButton"> <widget class="QPushButton" name="logoutButton">
<property name="toolTip"> <property name="toolTip">
<string comment="delete profile button tooltip">Delete selected profile.</string> <string comment="tooltip for logout button">Go back to the login screen</string>
</property> </property>
<property name="text"> <property name="text">
<string comment="delete profile button">Delete</string> <string comment="import profile button">Logout</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="profilesButtonsLayout2">
<item>
<widget class="QPushButton" name="importButton">
<property name="toolTip">
<string comment="tooltip for importing profile button">Import Tox profile from a .tox file.</string>
</property>
<property name="text">
<string comment="import profile button">Import a profile</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="newButton"> <spacer name="horizontalSpacer_2">
<property name="toolTip"> <property name="orientation">
<string comment="tooltip for creating new Tox ID button">Create new Tox ID and switch to it.</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string comment="new profile button">New Tox ID</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -349,9 +349,9 @@ void GeneralForm::onReconnectClicked()
{ {
if (Core::getInstance()->anyActiveCalls()) if (Core::getInstance()->anyActiveCalls())
QMessageBox::warning(this, tr("Call active", "popup title"), QMessageBox::warning(this, tr("Call active", "popup title"),
tr("You can't disconnect while a call is active!", "popup text")); tr("You can't disconnect while a call is active!", "popup text"));
else else
emit Widget::getInstance()->changeProfile(Settings::getInstance().getCurrentProfile()); ; /// TODO: Add a reset function in Profile to save then restart toxcore
} }
void GeneralForm::reloadSmiles() void GeneralForm::reloadSmiles()

View File

@ -218,7 +218,7 @@ bool PrivacyForm::setToxPassword()
core->setPassword(newpw, Core::ptMain); core->setPassword(newpw, Core::ptMain);
Settings::getInstance().setEncryptTox(true); Settings::getInstance().setEncryptTox(true);
core->saveConfiguration(); Settings::getInstance().save();
return true; return true;
} }
else else

View File

@ -131,7 +131,6 @@ signals:
void statusSelected(Status status); void statusSelected(Status status);
void usernameChanged(const QString& username); void usernameChanged(const QString& username);
void statusMessageChanged(const QString& statusMessage); void statusMessageChanged(const QString& statusMessage);
void changeProfile(const QString& profile);
void resized(); void resized();
private slots: private slots: