Browse Source

fix(autoaway): Improve autoaway algorithm.

Fix #3992

Don't reset autoaway flag if the status was changed without UI activity.
It is necessary that otherwise the flag is reseted then tox goes offline
because of not stable internet connection.
reviewable/pr4546/r1
Diadlo 8 years ago
parent
commit
9fe503c708
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 24
      src/widget/widget.cpp

24
src/widget/widget.cpp

@ -1893,20 +1893,16 @@ void Widget::onUserAwayCheck() @@ -1893,20 +1893,16 @@ void Widget::onUserAwayCheck()
{
#ifdef QTOX_PLATFORM_EXT
uint32_t autoAwayTime = Settings::getInstance().getAutoAwayTime() * 60 * 1000;
if (ui->statusButton->property("status").toString() == "online") {
if (autoAwayTime && Platform::getIdleTime() >= autoAwayTime) {
qDebug() << "auto away activated at" << QTime::currentTime().toString();
emit statusSet(Status::Away);
autoAwayActive = true;
}
} else if (ui->statusButton->property("status").toString() == "away") {
if (autoAwayActive && (!autoAwayTime || Platform::getIdleTime() < autoAwayTime)) {
qDebug() << "auto away deactivated at" << QTime::currentTime().toString();
emit statusSet(Status::Online);
autoAwayActive = false;
}
} else if (autoAwayActive) {
bool online = ui->statusButton->property("status").toString() == "online";
bool away = autoAwayTime && Platform::getIdleTime() >= autoAwayTime;
if (online && away) {
qDebug() << "auto away activated at" << QTime::currentTime().toString();
emit statusSet(Status::Away);
autoAwayActive = true;
} else if (autoAwayActive && !away) {
qDebug() << "auto away deactivated at" << QTime::currentTime().toString();
emit statusSet(Status::Online);
autoAwayActive = false;
}
#endif

Loading…
Cancel
Save