mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Basic infrastructure for profiles is in place, now I gotta hook up the UI
This commit is contained in:
parent
70321756c0
commit
e3da9badac
67
core.cpp
67
core.cpp
|
@ -30,6 +30,7 @@
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
const QString Core::CONFIG_FILE_NAME = "data";
|
const QString Core::CONFIG_FILE_NAME = "data";
|
||||||
|
const QString Core::TOX_EXT = ".tox";
|
||||||
QList<ToxFile> Core::fileSendQueue;
|
QList<ToxFile> Core::fileSendQueue;
|
||||||
QList<ToxFile> Core::fileRecvQueue;
|
QList<ToxFile> Core::fileRecvQueue;
|
||||||
ToxCall Core::calls[TOXAV_MAX_CALLS];
|
ToxCall Core::calls[TOXAV_MAX_CALLS];
|
||||||
|
@ -108,6 +109,7 @@ void Core::start()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this will attempt to get the last profile from settings
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
|
|
||||||
tox_callback_friend_request(tox, onFriendRequest, this);
|
tox_callback_friend_request(tox, onFriendRequest, this);
|
||||||
|
@ -721,34 +723,55 @@ void Core::checkConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::loadConfiguration()
|
QString sanitize(QString name)
|
||||||
{
|
{
|
||||||
QString path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME;
|
// do things
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
QFile configurationFile(path);
|
void Core::loadConfiguration(QString path)
|
||||||
|
{
|
||||||
|
if (path == "")
|
||||||
|
{
|
||||||
|
// read from settings whose profile?
|
||||||
|
path = Settings::getSettingsDirPath() + '/' + Settings::getInstance().getCurrentProfile() + TOX_EXT;
|
||||||
|
QFile file(path);
|
||||||
|
|
||||||
|
// if the last profile doesn't exist, fall back to old "data"
|
||||||
|
if (!file.exists())
|
||||||
|
{
|
||||||
|
path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!configurationFile.exists()) {
|
QFile conf(path);
|
||||||
|
qDebug() << "Core::loadConfiguration: reading from " << path;
|
||||||
|
|
||||||
|
if (!conf.exists()) {
|
||||||
qWarning() << "The Tox configuration file was not found";
|
qWarning() << "The Tox configuration file was not found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configurationFile.open(QIODevice::ReadOnly)) {
|
if (!conf.open(QIODevice::ReadOnly)) {
|
||||||
qCritical() << "File " << path << " cannot be opened";
|
qCritical() << "File " << path << " cannot be opened";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 fileSize = configurationFile.size();
|
qint64 fileSize = conf.size();
|
||||||
if (fileSize > 0) {
|
if (fileSize > 0) {
|
||||||
QByteArray data = configurationFile.readAll();
|
QByteArray data = conf.readAll();
|
||||||
tox_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size());
|
tox_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
configurationFile.close();
|
conf.close();
|
||||||
|
|
||||||
// set GUI with user and statusmsg
|
// set GUI with user and statusmsg
|
||||||
QString name = getUsername();
|
QString name = getUsername();
|
||||||
if (name != "")
|
if (name != "")
|
||||||
|
{
|
||||||
emit usernameSet(name);
|
emit usernameSet(name);
|
||||||
|
Settings::getInstance().setCurrentProfile(name);
|
||||||
|
}
|
||||||
|
|
||||||
QString msg = getStatusMessage();
|
QString msg = getStatusMessage();
|
||||||
if (msg != "")
|
if (msg != "")
|
||||||
|
@ -757,7 +780,7 @@ void Core::loadConfiguration()
|
||||||
loadFriends();
|
loadFriends();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::saveConfiguration()
|
void Core::saveConfiguration(QString path)
|
||||||
{
|
{
|
||||||
if (!tox)
|
if (!tox)
|
||||||
{
|
{
|
||||||
|
@ -765,23 +788,28 @@ void Core::saveConfiguration()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path = Settings::getSettingsDirPath();
|
if (path == "")
|
||||||
|
{
|
||||||
QDir directory(path);
|
QString dir = Settings::getSettingsDirPath();
|
||||||
|
QDir directory(dir);
|
||||||
if (!directory.exists() && !directory.mkpath(directory.absolutePath())) {
|
if (!directory.exists() && !directory.mkpath(directory.absolutePath())) {
|
||||||
qCritical() << "Error while creating directory " << path;
|
qCritical() << "Error while creating directory " << dir;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = dir + Settings::getInstance().getCurrentProfile() + TOX_EXT;
|
||||||
|
QFileInfo info(dir);
|
||||||
|
if (!info.exists()) // fall back to old school 'data'
|
||||||
|
path = dir + '/' + CONFIG_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
path += '/' + CONFIG_FILE_NAME;
|
|
||||||
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";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Core: writing tox_save";
|
qDebug() << "Core: writing tox_save to " << path;
|
||||||
uint32_t fileSize = tox_size(tox);
|
uint32_t fileSize = tox_size(tox);
|
||||||
if (fileSize > 0 && fileSize <= INT32_MAX) {
|
if (fileSize > 0 && fileSize <= INT32_MAX) {
|
||||||
uint8_t *data = new uint8_t[fileSize];
|
uint8_t *data = new uint8_t[fileSize];
|
||||||
|
@ -789,6 +817,7 @@ void Core::saveConfiguration()
|
||||||
configurationFile.write(reinterpret_cast<char *>(data), fileSize);
|
configurationFile.write(reinterpret_cast<char *>(data), fileSize);
|
||||||
configurationFile.commit();
|
configurationFile.commit();
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
//configurationFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
core.h
7
core.h
|
@ -114,6 +114,8 @@ class Core : public QObject
|
||||||
public:
|
public:
|
||||||
explicit Core(Camera* cam, QThread* coreThread);
|
explicit Core(Camera* cam, QThread* coreThread);
|
||||||
~Core();
|
~Core();
|
||||||
|
|
||||||
|
static const QString TOX_EXT;
|
||||||
|
|
||||||
int getGroupNumberPeers(int groupId) const;
|
int getGroupNumberPeers(int groupId) const;
|
||||||
QString getGroupPeerName(int groupId, int peerId) const;
|
QString getGroupPeerName(int groupId, int peerId) const;
|
||||||
|
@ -122,7 +124,9 @@ 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();
|
void saveConfiguration(QString path = "");
|
||||||
|
void loadConfiguration(QString path = "");
|
||||||
|
QString sanitize(QString name);
|
||||||
|
|
||||||
QString getUsername();
|
QString getUsername();
|
||||||
QString getStatusMessage();
|
QString getStatusMessage();
|
||||||
|
@ -273,7 +277,6 @@ private:
|
||||||
void checkConnection();
|
void checkConnection();
|
||||||
void onBootstrapTimer();
|
void onBootstrapTimer();
|
||||||
|
|
||||||
void loadConfiguration();
|
|
||||||
void loadFriends();
|
void loadFriends();
|
||||||
static void sendAllFileData(Core* core, ToxFile* file);
|
static void sendAllFileData(Core* core, ToxFile* file);
|
||||||
|
|
||||||
|
|
12
settings.cpp
12
settings.cpp
|
@ -81,6 +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();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Widgets");
|
s.beginGroup("Widgets");
|
||||||
|
@ -137,6 +138,7 @@ void Settings::save(QString path)
|
||||||
s.setValue("enableIPv6", enableIPv6);
|
s.setValue("enableIPv6", enableIPv6);
|
||||||
s.setValue("useTranslations",useTranslations);
|
s.setValue("useTranslations",useTranslations);
|
||||||
s.setValue("makeToxPortable",makeToxPortable);
|
s.setValue("makeToxPortable",makeToxPortable);
|
||||||
|
s.setValue("currentProfile", currentProfile);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Widgets");
|
s.beginGroup("Widgets");
|
||||||
|
@ -208,6 +210,16 @@ void Settings::setMakeToxPortable(bool newValue)
|
||||||
save(FILENAME); // Commit to the portable file that we don't want to use it
|
save(FILENAME); // Commit to the portable file that we don't want to use it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Settings::getCurrentProfile() const
|
||||||
|
{
|
||||||
|
return currentProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setCurrentProfile(QString profile)
|
||||||
|
{
|
||||||
|
currentProfile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::getUseTranslations() const
|
bool Settings::getUseTranslations() const
|
||||||
{
|
{
|
||||||
return useTranslations;
|
return useTranslations;
|
||||||
|
|
|
@ -49,6 +49,9 @@ public:
|
||||||
bool getMakeToxPortable() const;
|
bool getMakeToxPortable() const;
|
||||||
void setMakeToxPortable(bool newValue);
|
void setMakeToxPortable(bool newValue);
|
||||||
|
|
||||||
|
QString getCurrentProfile() const;
|
||||||
|
void setCurrentProfile(QString profile);
|
||||||
|
|
||||||
bool getUseTranslations() const;
|
bool getUseTranslations() const;
|
||||||
void setUseTranslations(bool newValue);
|
void setUseTranslations(bool newValue);
|
||||||
|
|
||||||
|
@ -134,6 +137,7 @@ private:
|
||||||
bool enableIPv6;
|
bool enableIPv6;
|
||||||
bool useTranslations;
|
bool useTranslations;
|
||||||
static bool makeToxPortable;
|
static bool makeToxPortable;
|
||||||
|
QString currentProfile;
|
||||||
|
|
||||||
bool enableLogging;
|
bool enableLogging;
|
||||||
bool encryptLogs;
|
bool encryptLogs;
|
||||||
|
|
|
@ -25,14 +25,16 @@ SettingsForm::SettingsForm()
|
||||||
: QObject()
|
: QObject()
|
||||||
{
|
{
|
||||||
main = new QWidget(), head = new QWidget();
|
main = new QWidget(), head = new QWidget();
|
||||||
|
hboxcont1 = new QWidget(), hboxcont2 = new QWidget();
|
||||||
QFont bold, small;
|
QFont bold, small;
|
||||||
bold.setBold(true);
|
bold.setBold(true);
|
||||||
small.setPixelSize(13);
|
small.setPixelSize(13);
|
||||||
headLabel.setText(tr("User Settings","\"Headline\" of the window"));
|
headLabel.setText(tr("User Settings","\"Headline\" of the window"));
|
||||||
headLabel.setFont(bold);
|
headLabel.setFont(bold);
|
||||||
|
|
||||||
nameLabel.setText(tr("Name","Username/nick"));
|
//nameLabel.setText(tr("Name","Username/nick"));
|
||||||
statusTextLabel.setText(tr("Status","Status message"));
|
//statusTextLabel.setText(tr("Status","Status message"));
|
||||||
|
|
||||||
idLabel.setText("Tox ID " + tr("(click here to copy)", "Click on this text to copy TID to clipboard"));
|
idLabel.setText("Tox ID " + tr("(click here to copy)", "Click on this text to copy TID to clipboard"));
|
||||||
id.setFont(small);
|
id.setFont(small);
|
||||||
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
|
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
@ -40,6 +42,15 @@ SettingsForm::SettingsForm()
|
||||||
id.setFrameStyle(QFrame::NoFrame);
|
id.setFrameStyle(QFrame::NoFrame);
|
||||||
id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
id.setFixedHeight(id.document()->size().height());
|
id.setFixedHeight(id.document()->size().height());
|
||||||
|
|
||||||
|
profilesLabel.setText(tr("Available profiles:", "Labels the profile selection box"));
|
||||||
|
populateProfiles();
|
||||||
|
loadConf.setText(tr("Load profile", "button to load selected profile"));
|
||||||
|
exportConf.setText(tr("Export profile", "button to save selected profile elsewhere"));
|
||||||
|
delConf.setText(tr("Delete profile", "button to delete selected profile from disk"));
|
||||||
|
delConf.setToolTip(tr("This is useful to remain safe on public computers", "describes the delete profile button"));
|
||||||
|
//delConf.setWhatsThis(tr("This is useful to remain safe on public computers", "describes the delete profile button"));
|
||||||
|
importConf.setText(tr("Import profile", "button to locate a profile"));
|
||||||
|
|
||||||
videoTest.setText(tr("Test video","Text on a button to test the video/webcam"));
|
videoTest.setText(tr("Test video","Text on a button to test the video/webcam"));
|
||||||
enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6"));
|
enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6"));
|
||||||
|
@ -50,12 +61,21 @@ SettingsForm::SettingsForm()
|
||||||
makeToxPortable.setChecked(Settings::getInstance().getMakeToxPortable());
|
makeToxPortable.setChecked(Settings::getInstance().getMakeToxPortable());
|
||||||
|
|
||||||
main->setLayout(&layout);
|
main->setLayout(&layout);
|
||||||
layout.addWidget(&nameLabel);
|
//layout.addWidget(&nameLabel);
|
||||||
layout.addWidget(&name);
|
//layout.addWidget(&name);
|
||||||
layout.addWidget(&statusTextLabel);
|
//layout.addWidget(&statusTextLabel);
|
||||||
layout.addWidget(&statusText);
|
//layout.addWidget(&statusText);
|
||||||
layout.addWidget(&idLabel);
|
layout.addWidget(&idLabel);
|
||||||
layout.addWidget(&id);
|
layout.addWidget(&id);
|
||||||
|
cbox.addWidget(&profilesLabel);
|
||||||
|
cbox.addWidget(&profiles);
|
||||||
|
hboxcont1->setLayout(&cbox);
|
||||||
|
layout.addWidget(hboxcont1);
|
||||||
|
buttons.addWidget(&loadConf);
|
||||||
|
buttons.addWidget(&exportConf);
|
||||||
|
buttons.addWidget(&delConf);
|
||||||
|
hboxcont2->setLayout(&buttons);
|
||||||
|
layout.addWidget(hboxcont2);
|
||||||
layout.addWidget(&videoTest);
|
layout.addWidget(&videoTest);
|
||||||
layout.addWidget(&enableIPv6);
|
layout.addWidget(&enableIPv6);
|
||||||
layout.addWidget(&useTranslations);
|
layout.addWidget(&useTranslations);
|
||||||
|
@ -76,6 +96,16 @@ SettingsForm::~SettingsForm()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsForm::populateProfiles()
|
||||||
|
{
|
||||||
|
QDir dir(Settings::getSettingsDirPath());
|
||||||
|
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
dir.setNameFilters(QStringList("*.tox"));
|
||||||
|
for(QFileInfo file : dir.entryInfoList()) {
|
||||||
|
profiles.addItem(file.completeBaseName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsForm::setFriendAddress(const QString& friendAddress)
|
void SettingsForm::setFriendAddress(const QString& friendAddress)
|
||||||
{
|
{
|
||||||
id.setText(friendAddress);
|
id.setText(friendAddress);
|
||||||
|
@ -83,8 +113,8 @@ void SettingsForm::setFriendAddress(const QString& friendAddress)
|
||||||
|
|
||||||
void SettingsForm::show(Ui::Widget &ui)
|
void SettingsForm::show(Ui::Widget &ui)
|
||||||
{
|
{
|
||||||
name.setText(ui.nameLabel->text());
|
//name.setText(ui.nameLabel->text());
|
||||||
statusText.setText(ui.statusLabel->text());
|
//statusText.setText(ui.statusLabel->text());
|
||||||
ui.mainContent->layout()->addWidget(main);
|
ui.mainContent->layout()->addWidget(main);
|
||||||
ui.mainHead->layout()->addWidget(head);
|
ui.mainHead->layout()->addWidget(head);
|
||||||
main->show();
|
main->show();
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
#include "widget/tool/clickablelabel.h"
|
#include "widget/tool/clickablelabel.h"
|
||||||
#include "ui_widget.h"
|
#include "ui_widget.h"
|
||||||
#include "widget/selfcamview.h"
|
#include "widget/selfcamview.h"
|
||||||
|
@ -50,16 +53,20 @@ private slots:
|
||||||
void copyIdClicked();
|
void copyIdClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel headLabel, nameLabel, statusTextLabel;
|
QLabel headLabel;/*, nameLabel, statusTextLabel;*/
|
||||||
QTextEdit id;
|
QTextEdit id;
|
||||||
ClickableLabel idLabel;
|
ClickableLabel idLabel;
|
||||||
QPushButton videoTest;
|
QLabel profilesLabel;
|
||||||
|
QComboBox profiles;
|
||||||
|
QPushButton loadConf, exportConf, delConf, importConf, videoTest;
|
||||||
|
QHBoxLayout cbox, buttons;
|
||||||
QCheckBox enableIPv6, useTranslations, makeToxPortable;
|
QCheckBox enableIPv6, useTranslations, makeToxPortable;
|
||||||
QVBoxLayout layout, headLayout;
|
QVBoxLayout layout, headLayout;
|
||||||
QWidget *main, *head;
|
QWidget *main, *head, *hboxcont1, *hboxcont2;
|
||||||
|
void populateProfiles();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QLineEdit name, statusText;
|
//QLineEdit name, statusText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSFORM_H
|
#endif // SETTINGSFORM_H
|
||||||
|
|
|
@ -249,8 +249,8 @@ Widget::Widget(QWidget *parent) :
|
||||||
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||||
connect(&settingsForm.name, SIGNAL(editingFinished()), this, SLOT(onUsernameChanged()));
|
//connect(&settingsForm.name, SIGNAL(editingFinished()), this, SLOT(onUsernameChanged()));
|
||||||
connect(&settingsForm.statusText, SIGNAL(editingFinished()), this, SLOT(onStatusMessageChanged()));
|
//connect(&settingsForm.statusText, SIGNAL(editingFinished()), this, SLOT(onStatusMessageChanged()));
|
||||||
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));
|
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));
|
||||||
|
|
||||||
coreThread->start();
|
coreThread->start();
|
||||||
|
@ -418,44 +418,56 @@ void Widget::hideMainForms()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onUsernameChanged()
|
/*void Widget::onUsernameChanged()
|
||||||
{
|
{
|
||||||
const QString newUsername = settingsForm.name.text();
|
//const QString newUsername = settingsForm.name.text();
|
||||||
ui->nameLabel->setText(newUsername);
|
ui->nameLabel->setText(newUsername);
|
||||||
ui->nameLabel->setToolTip(newUsername); // for overlength names
|
ui->nameLabel->setToolTip(newUsername); // for overlength names
|
||||||
settingsForm.name.setText(newUsername);
|
settingsForm.name.setText(newUsername);
|
||||||
core->setUsername(newUsername);
|
core->setUsername(newUsername);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
|
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
|
||||||
{
|
{
|
||||||
ui->nameLabel->setText(oldUsername); // restore old username until Core tells us to set it
|
ui->nameLabel->setText(oldUsername); // restore old username until Core tells us to set it
|
||||||
ui->nameLabel->setToolTip(oldUsername); // for overlength names
|
ui->nameLabel->setToolTip(oldUsername); // for overlength names
|
||||||
settingsForm.name.setText(oldUsername);
|
//settingsForm.name.setText(oldUsername);
|
||||||
core->setUsername(newUsername);
|
core->setUsername(newUsername);
|
||||||
|
|
||||||
|
// move the data file with it
|
||||||
|
QString dir = Settings::getSettingsDirPath();
|
||||||
|
QFile::rename(dir + '/' + oldUsername + core->TOX_EXT, dir + '/' + newUsername + core->TOX_EXT);
|
||||||
|
// and update current profile
|
||||||
|
Settings::getInstance().setCurrentProfile(newUsername);
|
||||||
}
|
}
|
||||||
|
// ugh... Widget::onUsernameChanged() calls Core::setUsername,
|
||||||
|
// which emits Core::usernameSet, which is connect to this function:
|
||||||
void Widget::setUsername(const QString& username)
|
void Widget::setUsername(const QString& username)
|
||||||
{
|
{
|
||||||
ui->nameLabel->setText(username);
|
ui->nameLabel->setText(username);
|
||||||
ui->nameLabel->setToolTip(username); // for overlength names
|
ui->nameLabel->setToolTip(username); // for overlength names
|
||||||
settingsForm.name.setText(username);
|
//settingsForm.name.setText(username);
|
||||||
}
|
}
|
||||||
|
// the end result is that the ui gets updated twice -- and actually,
|
||||||
|
// I believe this function is dead code, since the only way to change
|
||||||
|
// username now is via the ui (since I killed the settings version)
|
||||||
|
// the chain of calls before was surely much messier with two ways
|
||||||
|
// to modify the username...
|
||||||
|
|
||||||
void Widget::onStatusMessageChanged()
|
/*void Widget::onStatusMessageChanged()
|
||||||
{
|
{
|
||||||
const QString newStatusMessage = settingsForm.statusText.text();
|
const QString newStatusMessage = settingsForm.statusText.text();
|
||||||
ui->statusLabel->setText(newStatusMessage);
|
ui->statusLabel->setText(newStatusMessage);
|
||||||
ui->statusLabel->setToolTip(newStatusMessage); // for overlength messsages
|
ui->statusLabel->setToolTip(newStatusMessage); // for overlength messsages
|
||||||
settingsForm.statusText.setText(newStatusMessage);
|
settingsForm.statusText.setText(newStatusMessage);
|
||||||
core->setStatusMessage(newStatusMessage);
|
core->setStatusMessage(newStatusMessage);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
||||||
{
|
{
|
||||||
ui->statusLabel->setText(oldStatusMessage); // restore old status message until Core tells us to set it
|
ui->statusLabel->setText(oldStatusMessage); // restore old status message until Core tells us to set it
|
||||||
ui->statusLabel->setToolTip(oldStatusMessage); // for overlength messsages
|
ui->statusLabel->setToolTip(oldStatusMessage); // for overlength messsages
|
||||||
settingsForm.statusText.setText(oldStatusMessage);
|
//settingsForm.statusText.setText(oldStatusMessage);
|
||||||
core->setStatusMessage(newStatusMessage);
|
core->setStatusMessage(newStatusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +475,7 @@ void Widget::setStatusMessage(const QString &statusMessage)
|
||||||
{
|
{
|
||||||
ui->statusLabel->setText(statusMessage);
|
ui->statusLabel->setText(statusMessage);
|
||||||
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
|
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
|
||||||
settingsForm.statusText.setText(statusMessage);
|
//settingsForm.statusText.setText(statusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::addFriend(int friendId, const QString &userId)
|
void Widget::addFriend(int friendId, const QString &userId)
|
||||||
|
|
|
@ -86,8 +86,8 @@ private slots:
|
||||||
void onFailedToStartCore();
|
void onFailedToStartCore();
|
||||||
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
|
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
|
||||||
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
|
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
|
||||||
void onUsernameChanged();
|
//void onUsernameChanged();
|
||||||
void onStatusMessageChanged();
|
//void onStatusMessageChanged();
|
||||||
void setUsername(const QString& username);
|
void setUsername(const QString& username);
|
||||||
void setStatusMessage(const QString &statusMessage);
|
void setStatusMessage(const QString &statusMessage);
|
||||||
void addFriend(int friendId, const QString& userId);
|
void addFriend(int friendId, const QString& userId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user