diff --git a/core.cpp b/core.cpp index 0fcd09fc6..bdbd1d8c6 100644 --- a/core.cpp +++ b/core.cpp @@ -39,14 +39,14 @@ Core::Core(Camera* cam) : { toxTimer = new QTimer(this); toxTimer->setSingleShot(true); - saveTimer = new QTimer(this); - saveTimer->start(TOX_SAVE_INTERVAL); + //saveTimer = new QTimer(this); + //saveTimer->start(TOX_SAVE_INTERVAL); //fileTimer = new QTimer(this); //fileTimer->start(TOX_FILE_INTERVAL); bootstrapTimer = new QTimer(this); bootstrapTimer->start(TOX_BOOTSTRAP_INTERVAL); 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(bootstrapTimer, &QTimer::timeout, this, &Core::onBootstrapTimer); connect(&Settings::getInstance(), &Settings::dhtServerListChanged, this, &Core::bootstrapDht); @@ -317,6 +317,7 @@ void Core::acceptFriendRequest(const QString& userId) if (friendId == -1) { emit failedToAddFriend(userId); } else { + saveConfiguration(); emit friendAdded(friendId, userId); } } @@ -537,6 +538,7 @@ void Core::removeFriend(int friendId) if (tox_del_friend(tox, friendId) == -1) { emit failedToRemoveFriend(friendId); } else { + saveConfiguration(); emit friendRemoved(friendId); } } @@ -553,6 +555,7 @@ void Core::setUsername(const QString& username) if (tox_set_name(tox, cUsername.data(), cUsername.size()) == -1) { emit failedToSetUsername(username); } else { + saveConfiguration(); emit usernameSet(username); } } @@ -564,6 +567,7 @@ void Core::setStatusMessage(const QString& message) if (tox_set_status_message(tox, cMessage.data(), cMessage.size()) == -1) { emit failedToSetStatusMessage(message); } else { + saveConfiguration(); emit statusMessageSet(message); } } @@ -587,6 +591,7 @@ void Core::setStatus(Status status) } if (tox_set_user_status(tox, userstatus) == 0) { + saveConfiguration(); emit statusSet(status); } else { emit failedToSetStatus(status); diff --git a/core.h b/core.h index 988787a48..0412d1977 100644 --- a/core.h +++ b/core.h @@ -119,6 +119,8 @@ public: void quitGroupChat(int groupId) const; void dispatchVideoFrame(vpx_image img) const; + void saveConfiguration(); + public slots: void start(); void process(); @@ -261,7 +263,6 @@ private: void onBootstrapTimer(); void loadConfiguration(); - void saveConfiguration(); void loadFriends(); static void sendAllFileData(Core* core, ToxFile* file); diff --git a/widget/widget.cpp b/widget/widget.cpp index ea89914a9..d9cfb794a 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -227,6 +227,7 @@ Widget::Widget(QWidget *parent) : Widget::~Widget() { + core->saveConfiguration(); instance = nullptr; coreThread->exit(); 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::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout); connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout); + core->saveConfiguration(); } void Widget::addFriendFailed(const QString&) @@ -763,7 +765,7 @@ bool Widget::event(QEvent * e) Group* g = GroupList::findGroup(activeGroupWidget->groupId); g->hasNewMessages = 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)