mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
IT WORKS, IT FINALLY WORKS
This commit is contained in:
parent
0050589cde
commit
983879e799
27
core.cpp
27
core.cpp
|
@ -279,9 +279,9 @@ void Core::start()
|
||||||
* 5 disconnected; 4 were DCd for less than 20 ticks, while the 5th was ~50 ticks.
|
* 5 disconnected; 4 were DCd for less than 20 ticks, while the 5th was ~50 ticks.
|
||||||
* So I set the tolerance here at 25, and initial DCs should be very rare now.
|
* So I set the tolerance here at 25, and initial DCs should be very rare now.
|
||||||
* This should be able to go to 50 or 100 without affecting legitimate disconnects'
|
* This should be able to go to 50 or 100 without affecting legitimate disconnects'
|
||||||
* downtime, but lets be conservative for now. Edit: now 40.
|
* downtime, but lets be conservative for now. Edit: now ~~40~~ 30.
|
||||||
*/
|
*/
|
||||||
#define CORE_DISCONNECT_TOLERANCE 40
|
#define CORE_DISCONNECT_TOLERANCE 30
|
||||||
|
|
||||||
void Core::process()
|
void Core::process()
|
||||||
{
|
{
|
||||||
|
@ -936,6 +936,8 @@ void Core::removeFriend(int friendId)
|
||||||
|
|
||||||
void Core::removeGroup(int groupId)
|
void Core::removeGroup(int groupId)
|
||||||
{
|
{
|
||||||
|
if (!tox)
|
||||||
|
return;
|
||||||
tox_del_groupchat(tox, groupId);
|
tox_del_groupchat(tox, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1183,35 +1185,24 @@ void Core::switchConfiguration(QString profile)
|
||||||
|
|
||||||
toxTimer->stop();
|
toxTimer->stop();
|
||||||
|
|
||||||
Widget::getInstance()->clearContactsList(); // we need this to block, so no signals for us
|
|
||||||
|
|
||||||
if (tox) {
|
if (tox) {
|
||||||
toxav_kill(toxav);
|
toxav_kill(toxav);
|
||||||
toxav = nullptr;
|
toxav = nullptr;
|
||||||
tox_kill(tox);
|
tox_kill(tox);
|
||||||
tox = nullptr;
|
tox = nullptr;
|
||||||
}
|
}
|
||||||
|
emit selfAvatarChanged(QPixmap(":/img/contact_dark.png"));
|
||||||
|
Widget::getInstance()->clearContactsList(); // we need this to block, so no signals for us
|
||||||
|
|
||||||
make_tox();
|
loadPath = QDir(Settings::getSettingsDirPath()).filePath(profile + TOX_EXT);
|
||||||
|
|
||||||
Settings::getInstance().setCurrentProfile(profile);
|
Settings::getInstance().setCurrentProfile(profile);
|
||||||
if (!loadConfiguration(Settings::getSettingsDirPath() + QDir::separator() + profile + TOX_EXT))
|
|
||||||
{
|
|
||||||
emit failedToStart();
|
|
||||||
toxav_kill(toxav);
|
|
||||||
toxav = nullptr;
|
|
||||||
tox_kill(tox);
|
|
||||||
tox = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
process(); // restarts toxTimer
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::loadFriends()
|
void Core::loadFriends()
|
||||||
{
|
{
|
||||||
const uint32_t friendCount = tox_count_friendlist(tox);
|
const uint32_t friendCount = tox_count_friendlist(tox);
|
||||||
qDebug() << "Core: loading" << friendCount << "friends. profile:" << Settings::getInstance().getCurrentProfile();
|
|
||||||
if (friendCount > 0) {
|
if (friendCount > 0) {
|
||||||
// assuming there are not that many friends to fill up the whole stack
|
// assuming there are not that many friends to fill up the whole stack
|
||||||
int32_t *ids = new int32_t[friendCount];
|
int32_t *ids = new int32_t[friendCount];
|
||||||
|
@ -1220,7 +1211,7 @@ void Core::loadFriends()
|
||||||
for (int32_t i = 0; i < static_cast<int32_t>(friendCount); ++i) {
|
for (int32_t i = 0; i < static_cast<int32_t>(friendCount); ++i) {
|
||||||
if (tox_get_client_id(tox, ids[i], clientId) == 0) {
|
if (tox_get_client_id(tox, ids[i], clientId) == 0) {
|
||||||
emit friendAdded(ids[i], CUserId::toString(clientId));
|
emit friendAdded(ids[i], CUserId::toString(clientId));
|
||||||
qDebug() << "Core: just added friend" << CUserId::toString(clientId);
|
|
||||||
const int nameSize = tox_get_name_size(tox, ids[i]);
|
const int nameSize = tox_get_name_size(tox, ids[i]);
|
||||||
if (nameSize > 0) {
|
if (nameSize > 0) {
|
||||||
uint8_t *name = new uint8_t[nameSize];
|
uint8_t *name = new uint8_t[nameSize];
|
||||||
|
|
|
@ -44,7 +44,7 @@ IdentityForm::IdentityForm() :
|
||||||
|
|
||||||
// toxId->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
// toxId->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
toxId->setReadOnly(true);
|
toxId->setReadOnly(true);
|
||||||
// toxId->setFrameStyle(QFrame::NoFrame);
|
toxId->setFrame(false);
|
||||||
// toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
// toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
// toxId->setFixedHeight(toxId->document()->size().height()*2);
|
// toxId->setFixedHeight(toxId->document()->size().height()*2);
|
||||||
toxId->setFont(small);
|
toxId->setFont(small);
|
||||||
|
@ -72,6 +72,7 @@ void IdentityForm::copyIdClicked()
|
||||||
QString txt = toxId->text();
|
QString txt = toxId->text();
|
||||||
txt.replace('\n',"");
|
txt.replace('\n',"");
|
||||||
QApplication::clipboard()->setText(txt);
|
QApplication::clipboard()->setText(txt);
|
||||||
|
toxId->setCursorPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onUserNameEdited()
|
void IdentityForm::onUserNameEdited()
|
||||||
|
@ -87,6 +88,7 @@ void IdentityForm::onStatusMessageEdited()
|
||||||
void IdentityForm::updateContent()
|
void IdentityForm::updateContent()
|
||||||
{
|
{
|
||||||
toxId->setText(Core::getInstance()->getSelfId().toString());
|
toxId->setText(Core::getInstance()->getSelfId().toString());
|
||||||
|
toxId->setCursorPosition(0);
|
||||||
bodyUI->profiles->clear();
|
bodyUI->profiles->clear();
|
||||||
for (QString profile : Widget::searchProfiles())
|
for (QString profile : Widget::searchProfiles())
|
||||||
bodyUI->profiles->addItem(profile);
|
bodyUI->profiles->addItem(profile);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user