void AddContactBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; if (_retryButton.isHidden()) { paintTitle(p, _boxTitle, true); } else { // draw box text p.setPen(st::black->p); p.setFont(st::boxTitleFont->f); int32 h = size().height() - st::boxPadding.top() * 2 - _retryButton.height() - st::boxPadding.bottom(); p.drawText(QRect(st::boxPadding.left(), st::boxPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), h), lng_contact_not_joined(lt_name, _sentName), style::al_topleft); } // paint shadows p.fillRect(0, size().height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b); // paint button sep p.fillRect(st::btnSelectCancel.width, size().height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b); }
void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) { if (isHidden() || !App::main()) return; const MTPDcontacts_importedContacts &d(res.c_contacts_importedContacts()); App::feedUsers(d.vusers); const QVector<MTPImportedContact> &v(d.vimported.c_vector().v); int32 uid = 0; if (!v.isEmpty()) { const MTPDimportedContact &c(v.front().c_importedContact()); if (c.vclient_id.v != _contactId) return; uid = c.vuser_id.v; if (uid && !App::userLoaded(uid)) { uid = 0; } } if (uid) { App::main()->addNewContact(uid); App::wnd()->hideLayer(); } else { _addButton.hide(); _firstInput.hide(); _lastInput.hide(); _phoneInput.hide(); _retryButton.show(); int32 theight = st::boxTitleFont->m.boundingRect(0, 0, width() - st::boxPadding.left() - st::boxPadding.right(), 1, Qt::TextWordWrap, lng_contact_not_joined(lt_name, _sentName)).height(); int32 h = st::boxPadding.top() * 2 + theight + _retryButton.height() + st::boxPadding.bottom(); setMaxHeight(h); update(); } }
void AddContactBox::paintEvent(QPaintEvent *e) { BoxContent::paintEvent(e); Painter p(this); if (_retrying) { p.setPen(st::boxTextFg); p.setFont(st::boxTextFont); auto textHeight = height() - st::contactPadding.top() - st::contactPadding.bottom() - st::boxPadding.bottom(); p.drawText(QRect(st::boxPadding.left(), st::contactPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), textHeight), lng_contact_not_joined(lt_name, _sentName), style::al_topleft); } else { st::contactUserIcon.paint(p, st::boxPadding.left(), _first->y() + st::contactIconTop, width()); st::contactPhoneIcon.paint(p, st::boxPadding.left(), _phone->y() + st::contactIconTop, width()); } }