mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Save on event instead of timer trigger
This commit is contained in:
parent
f1d30cbc14
commit
16df8e553e
11
core.cpp
11
core.cpp
@ -39,14 +39,14 @@ Core::Core(Camera* cam) :
|
|||||||
{
|
{
|
||||||
toxTimer = new QTimer(this);
|
toxTimer = new QTimer(this);
|
||||||
toxTimer->setSingleShot(true);
|
toxTimer->setSingleShot(true);
|
||||||
saveTimer = new QTimer(this);
|
//saveTimer = new QTimer(this);
|
||||||
saveTimer->start(TOX_SAVE_INTERVAL);
|
//saveTimer->start(TOX_SAVE_INTERVAL);
|
||||||
//fileTimer = new QTimer(this);
|
//fileTimer = new QTimer(this);
|
||||||
//fileTimer->start(TOX_FILE_INTERVAL);
|
//fileTimer->start(TOX_FILE_INTERVAL);
|
||||||
bootstrapTimer = new QTimer(this);
|
bootstrapTimer = new QTimer(this);
|
||||||
bootstrapTimer->start(TOX_BOOTSTRAP_INTERVAL);
|
bootstrapTimer->start(TOX_BOOTSTRAP_INTERVAL);
|
||||||
connect(toxTimer, &QTimer::timeout, this, &Core::process);
|
connect(toxTimer, &QTimer::timeout, this, &Core::process);
|
||||||
connect(saveTimer, &QTimer::timeout, this, &Core::saveConfiguration);
|
//connect(saveTimer, &QTimer::timeout, this, &Core::saveConfiguration); //Disable save timer in favor of saving on events
|
||||||
//connect(fileTimer, &QTimer::timeout, this, &Core::fileHeartbeat);
|
//connect(fileTimer, &QTimer::timeout, this, &Core::fileHeartbeat);
|
||||||
connect(bootstrapTimer, &QTimer::timeout, this, &Core::onBootstrapTimer);
|
connect(bootstrapTimer, &QTimer::timeout, this, &Core::onBootstrapTimer);
|
||||||
connect(&Settings::getInstance(), &Settings::dhtServerListChanged, this, &Core::bootstrapDht);
|
connect(&Settings::getInstance(), &Settings::dhtServerListChanged, this, &Core::bootstrapDht);
|
||||||
@ -317,6 +317,7 @@ void Core::acceptFriendRequest(const QString& userId)
|
|||||||
if (friendId == -1) {
|
if (friendId == -1) {
|
||||||
emit failedToAddFriend(userId);
|
emit failedToAddFriend(userId);
|
||||||
} else {
|
} else {
|
||||||
|
saveConfiguration();
|
||||||
emit friendAdded(friendId, userId);
|
emit friendAdded(friendId, userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,6 +538,7 @@ void Core::removeFriend(int friendId)
|
|||||||
if (tox_del_friend(tox, friendId) == -1) {
|
if (tox_del_friend(tox, friendId) == -1) {
|
||||||
emit failedToRemoveFriend(friendId);
|
emit failedToRemoveFriend(friendId);
|
||||||
} else {
|
} else {
|
||||||
|
saveConfiguration();
|
||||||
emit friendRemoved(friendId);
|
emit friendRemoved(friendId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,6 +555,7 @@ void Core::setUsername(const QString& username)
|
|||||||
if (tox_set_name(tox, cUsername.data(), cUsername.size()) == -1) {
|
if (tox_set_name(tox, cUsername.data(), cUsername.size()) == -1) {
|
||||||
emit failedToSetUsername(username);
|
emit failedToSetUsername(username);
|
||||||
} else {
|
} else {
|
||||||
|
saveConfiguration();
|
||||||
emit usernameSet(username);
|
emit usernameSet(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,6 +567,7 @@ void Core::setStatusMessage(const QString& message)
|
|||||||
if (tox_set_status_message(tox, cMessage.data(), cMessage.size()) == -1) {
|
if (tox_set_status_message(tox, cMessage.data(), cMessage.size()) == -1) {
|
||||||
emit failedToSetStatusMessage(message);
|
emit failedToSetStatusMessage(message);
|
||||||
} else {
|
} else {
|
||||||
|
saveConfiguration();
|
||||||
emit statusMessageSet(message);
|
emit statusMessageSet(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,6 +591,7 @@ void Core::setStatus(Status status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tox_set_user_status(tox, userstatus) == 0) {
|
if (tox_set_user_status(tox, userstatus) == 0) {
|
||||||
|
saveConfiguration();
|
||||||
emit statusSet(status);
|
emit statusSet(status);
|
||||||
} else {
|
} else {
|
||||||
emit failedToSetStatus(status);
|
emit failedToSetStatus(status);
|
||||||
|
3
core.h
3
core.h
@ -119,6 +119,8 @@ 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();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
void process();
|
void process();
|
||||||
@ -261,7 +263,6 @@ private:
|
|||||||
void onBootstrapTimer();
|
void onBootstrapTimer();
|
||||||
|
|
||||||
void loadConfiguration();
|
void loadConfiguration();
|
||||||
void saveConfiguration();
|
|
||||||
void loadFriends();
|
void loadFriends();
|
||||||
static void sendAllFileData(Core* core, ToxFile* file);
|
static void sendAllFileData(Core* core, ToxFile* file);
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ Widget::Widget(QWidget *parent) :
|
|||||||
|
|
||||||
Widget::~Widget()
|
Widget::~Widget()
|
||||||
{
|
{
|
||||||
|
core->saveConfiguration();
|
||||||
instance = nullptr;
|
instance = nullptr;
|
||||||
coreThread->exit();
|
coreThread->exit();
|
||||||
coreThread->wait();
|
coreThread->wait();
|
||||||
@ -428,6 +429,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||||||
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
|
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
|
||||||
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
||||||
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
||||||
|
core->saveConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::addFriendFailed(const QString&)
|
void Widget::addFriendFailed(const QString&)
|
||||||
@ -763,7 +765,7 @@ bool Widget::event(QEvent * e)
|
|||||||
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
|
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
|
||||||
g->hasNewMessages = 0;
|
g->hasNewMessages = 0;
|
||||||
g->userWasMentioned = 0;
|
g->userWasMentioned = 0;
|
||||||
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat.png"));
|
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e->type() == QEvent::WindowDeactivate && !useNativeTheme)
|
else if (e->type() == QEvent::WindowDeactivate && !useNativeTheme)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user