void UsernameBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_username_title), true); // paint shadow p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b); // paint button sep p.fillRect(st::usernameCancel.width, size().height() - st::usernameCancel.height, st::lineWidth, st::usernameCancel.height, st::btnSelectSep->b); if (!_errorText.isEmpty()) { p.setPen(st::setErrColor->p); p.setFont(st::setErrFont->f); int32 w = st::setErrFont->m.width(_errorText); p.drawText((width() - w) / 2, _usernameInput.y() + _usernameInput.height() + ((st::usernameSkip - st::setErrFont->height) / 2) + st::setErrFont->ascent, _errorText); } else if (!_goodText.isEmpty()) { p.setPen(st::setGoodColor->p); p.setFont(st::setErrFont->f); int32 w = st::setErrFont->m.width(_goodText); p.drawText((width() - w) / 2, _usernameInput.y() + _usernameInput.height() + ((st::usernameSkip - st::setErrFont->height) / 2) + st::setErrFont->ascent, _goodText); } p.setPen(st::usernameColor->p); _about.draw(p, st::boxTitlePos.x(), _usernameInput.y() + _usernameInput.height() + st::usernameSkip, width() - 2 * st::boxTitlePos.x()); }
void PasscodeBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, _boxTitle); textstyleSet(&st::usernameTextStyle); int32 w = st::boxWidth - st::boxPadding.left() * 1.5; int32 abouty = (_passwordHint.isHidden() ? (_reenterPasscode.isHidden() ? (_oldPasscode.y() + (_hasRecovery && !_hintText.isEmpty() ? st::passcodeSkip : 0)) : _reenterPasscode.y()) + st::passcodeSkip : _passwordHint.y() + st::contactSkip) + _oldPasscode.height(); p.setPen(st::black); _about.drawLeft(p, st::boxPadding.left(), abouty, w, width()); if (!_hintText.isEmpty() && _oldError.isEmpty()) { p.setPen(st::black->p); _hintText.drawLeftElided(p, st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height() + ((st::passcodeSkip - st::normalFont->height) / 2), w, width(), 1, style::al_topleft); } if (!_oldError.isEmpty()) { p.setPen(st::setErrColor->p); p.drawText(QRect(st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height(), w, st::passcodeSkip), _oldError, style::al_left); } if (!_newError.isEmpty()) { p.setPen(st::setErrColor->p); p.drawText(QRect(st::boxPadding.left(), _reenterPasscode.y() + _reenterPasscode.height(), w, st::passcodeSkip), _newError, style::al_left); } if (!_emailError.isEmpty()) { p.setPen(st::setErrColor->p); p.drawText(QRect(st::boxPadding.left(), _recoverEmail.y() + _recoverEmail.height(), w, st::passcodeSkip), _emailError, style::al_left); } textstyleRestore(); }
void GraphicsMovieItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* ) { painter->save(); paintRect( painter, option ); painter->restore(); painter->save(); paintTitle( painter, option ); painter->restore(); }
void DownloadPathBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_download_path_header), true); // paint shadows p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b); // paint button sep p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b); }
void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_profile_convert_title)); // draw box title / text p.setPen(st::black); textstyleSet(&st::boxTextStyle); _text.drawLeft(p, st::boxPadding.left(), st::boxTitleHeight, _textWidth, width()); _note.drawLeft(p, st::boxPadding.left(), st::boxTitleHeight + _textHeight + st::boxPadding.bottom(), _textWidth, width()); textstyleRestore(); }
void ConnectionBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_connection_header), true); // paint separator p.fillRect(st::boxPadding.left(), _tryIPv6.y() - st::connectionSkip - st::lineWidth, width() - st::boxPadding.left() - st::boxPadding.right(), st::lineWidth, st::scrollDef.shColor->b); // paint shadow p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b); // paint button sep p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b); }
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 UsernameBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_username_title)); if (!_copiedTextLink.isEmpty()) { p.setPen(st::usernameDefaultFg); p.setFont(st::boxTextFont); p.drawTextLeft(st::usernamePadding.left(), _username.y() + _username.height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), _copiedTextLink); } else if (!_errorText.isEmpty()) { p.setPen(st::setErrColor); p.setFont(st::boxTextFont); p.drawTextLeft(st::usernamePadding.left(), _username.y() + _username.height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), _errorText); } else if (!_goodText.isEmpty()) { p.setPen(st::setGoodColor); p.setFont(st::boxTextFont); p.drawTextLeft(st::usernamePadding.left(), _username.y() + _username.height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), _goodText); } else { p.setPen(st::usernameDefaultFg); p.setFont(st::boxTextFont); p.drawTextLeft(st::usernamePadding.left(), _username.y() + _username.height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), lang(lng_username_choose)); } p.setPen(st::black); textstyleSet(&st::usernameTextStyle); int32 availw = st::boxWidth - st::usernamePadding.left(), h = _about.countHeight(availw); _about.drawLeft(p, st::usernamePadding.left(), _username.y() + _username.height() + st::usernameSkip, availw, width()); textstyleRestore(); int32 linky = _username.y() + _username.height() + st::usernameSkip + h + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2); if (_link.isHidden()) { p.drawTextLeft(st::usernamePadding.left(), linky, width(), lang(lng_username_link_willbe)); p.setPen(st::usernameDefaultFg); p.drawTextLeft(st::usernamePadding.left(), linky + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2), width(), qsl("https://telegram.me/username")); } else { p.drawTextLeft(st::usernamePadding.left(), linky, width(), lang(lng_username_link)); } }
void LocalStorageBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_local_storage_title)); p.setFont(st::boxTextFont); p.setPen(st::windowTextFg); checkLocalStoredCounts(); int top = st::boxTitleHeight + st::localStorageBoxSkip; if (_imagesCount > 0) { auto text = lng_settings_images_cached(lt_count, _imagesCount, lt_size, formatSizeText(Local::storageImagesSize() + Local::storageStickersSize() + Local::storageWebFilesSize())); p.drawTextLeft(st::boxPadding.left(), top, width(), text); top += st::boxTextFont->height + st::localStorageBoxSkip; } if (_audiosCount > 0) { auto text = lng_settings_audios_cached(lt_count, _audiosCount, lt_size, formatSizeText(Local::storageAudiosSize())); p.drawTextLeft(st::boxPadding.left(), top, width(), text); top += st::boxTextFont->height + st::localStorageBoxSkip; } else if (_imagesCount <= 0) { p.drawTextLeft(st::boxPadding.left(), top, width(), lang(lng_settings_no_data_cached)); top += st::boxTextFont->height + st::localStorageBoxSkip; } auto text = ([this]() -> QString { switch (_state) { case State::Clearing: return lang(lng_local_storage_clearing); case State::Cleared: return lang(lng_local_storage_cleared); case State::ClearFailed: return lang(lng_local_storage_clear_failed); } return QString(); })(); if (!text.isEmpty()) { p.drawTextLeft(st::boxPadding.left(), top, width(), text); top += st::boxTextFont->height + st::localStorageBoxSkip; } }
void AboutBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, qsl("Telegram Desktop")); }
void AutoLockBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_passcode_autolock), true); }
void toBarChart::paintChart(QPainter *p, QRect &rect) { QFontMetrics fm = p->fontMetrics(); if (!Zooming) { if (MinAuto) { bool first = true; std::list<std::list<double> >::reverse_iterator i = Values.rbegin(); if (i != Values.rend()) { for (std::list<double>::iterator j = (*i).begin(); j != (*i).end(); j++) { if (first) { first = false; zMinValue = *j; } else if (zMinValue > *j) zMinValue = *j; } } } if (MaxAuto) { bool first = true; std::list<double> total; std::list<bool>::iterator e = Enabled.begin(); { for (std::list<std::list<double> >::iterator i = Values.begin(); i != Values.end(); i++) { std::list<double>::iterator k = total.begin(); if (e == Enabled.end() || *e) { for (std::list<double>::iterator j = (*i).begin(); j != (*i).end(); j++) { if (k == total.end()) { total.insert(total.end(), *j); k = total.end(); } else { *k += *j; k++; } } } if (e != Enabled.end()) e++; } } for (std::list<double>::iterator i = total.begin(); i != total.end(); i++) { if (first) { first = false; zMaxValue = *i; } else if (zMaxValue < *i) zMaxValue = *i; } } if (!MinAuto) zMinValue = MinValue; else { zMinValue = round(zMinValue, false); MinValue = zMinValue; } if (!MaxAuto) zMaxValue = MaxValue; else { zMaxValue = round(zMaxValue, true); MaxValue = zMaxValue; } } paintTitle(p, rect); paintLegend(p, rect); paintAxis(p, rect); std::list<QPolygon> Points; int cp = 0; int samples = countSamples(); int zeroy = int(rect.height() - 2 - ( -zMinValue / (zMaxValue - zMinValue) * (rect.height() - 4))); if (samples > 1) { const QMatrix &mtx = p->worldMatrix(); p->setClipRect(int(mtx.dx() + 2), int(mtx.dy() + 2), rect.width() - 3, rect.height() - 3); if (Zooming) p->drawText(2, 2, rect.width() - 4, rect.height() - 4, Qt::AlignLeft | Qt::AlignTop, tr("Zoom")); std::list<bool>::reverse_iterator e = Enabled.rbegin(); for (std::list<std::list<double> >::reverse_iterator i = Values.rbegin(); i != Values.rend(); i++) { if (e == Enabled.rend() || *e) { std::list<double> &val = *i; int count = 0; int skip = SkipSamples; QPolygon a(samples + 10); int x = rect.width() - 2; for (std::list<double>::reverse_iterator j = val.rbegin(); j != val.rend() && x >= 2; j++) { if (skip > 0) skip--; else { int val = int(rect.height() - 2 - ((*j - zMinValue) / (zMaxValue - zMinValue) * (rect.height() - 4))); x = rect.width() - 2 - count * (rect.width() - 4) / (samples - 1); a.setPoint(count, x, val); count++; if (count >= samples) break; } } a.resize(count * 2); Points.insert(Points.end(), a); } cp++; if (e != Enabled.rend()) e++; } } std::map<int, int> Bottom; std::list<bool>::reverse_iterator e = Enabled.rbegin(); for (std::list<QPolygon>::iterator i = Points.begin(); i != Points.end();) { while (e != Enabled.rend() && !*e) { cp--; e++; } if (e != Enabled.rend()) e++; cp--; QPolygon a = *i; int lx = 0; int lb = 0; for (int j = 0; j < a.size() / 2; j++) { int x, y; a.point(j, &x, &y); if (Bottom.find(x) == Bottom.end()) Bottom[x] = 0; if (lx != x) lb = Bottom[x]; a.setPoint(a.size() - 1 - j, x, zeroy - lb); y -= lb; a.setPoint(j, x, y); Bottom[x] = zeroy - y; lx = x; } p->save(); QBrush brush(Utils::toChartBrush(cp)); p->setBrush(brush.color()); p->drawPolygon(a); if (brush.style() != Qt::SolidPattern) { p->setBrush(QBrush(Qt::white, brush.style())); p->drawPolygon(a); } p->restore(); i++; } }
void BlockWidget::paintEvent(QPaintEvent *e) { Painter p(this); paintTitle(p); paintContents(p); }
void ConnectionBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_connection_header)); }
void LanguageBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_languages)); }
void DownloadPathBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_download_path_header)); }
void BackgroundBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_backgrounds_header)); }
void CountrySelectBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, lang(lng_country_select)); }
void StickerSetBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; paintTitle(p, _inner.title(), false); }