bool SessionsBox::Inner::terminateFail(uint64 hash, const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; TerminateButtons::iterator i = _terminateButtons.find(hash); if (i != _terminateButtons.end()) { i.value()->show(); return true; } return false; }
void SessionsInner::onTerminate() { for (TerminateButtons::iterator i = _terminateButtons.begin(), e = _terminateButtons.end(); i != e; ++i) { if (i.value()->getState() & Button::StateOver) { _terminating = i.key(); if (_terminateBox) _terminateBox->deleteLater(); _terminateBox = new ConfirmBox(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button)); connect(_terminateBox, SIGNAL(confirmed()), this, SLOT(onTerminateSure())); connect(_terminateBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoTerminateBox(QObject*))); App::wnd()->replaceLayer(_terminateBox); } }
void SessionsBox::Inner::listUpdated() { if (_list->isEmpty()) { _terminateAll->hide(); } else { _terminateAll->show(); } for (TerminateButtons::iterator i = _terminateButtons.begin(), e = _terminateButtons.end(); i != e; ++i) { i.value()->move(0, -1); } for (int32 i = 0, l = _list->size(); i < l; ++i) { TerminateButtons::iterator j = _terminateButtons.find(_list->at(i).hash); if (j == _terminateButtons.cend()) { j = _terminateButtons.insert(_list->at(i).hash, new Ui::IconButton(this, st::sessionTerminate)); connect(j.value(), SIGNAL(clicked()), this, SLOT(onTerminate())); } j.value()->moveToRight(st::sessionTerminateSkip, st::sessionCurrentHeight + i * st::sessionHeight + st::sessionTerminateTop, width()); j.value()->show(); } for (TerminateButtons::iterator i = _terminateButtons.begin(); i != _terminateButtons.cend();) { if (i.value()->y() >= 0) { ++i; } else { delete i.value(); i = _terminateButtons.erase(i); } } resize(width(), _list->isEmpty() ? (st::sessionCurrentHeight + st::noContactsHeight) : (st::sessionCurrentHeight + _list->size() * st::sessionHeight)); update(); }