[Refactoring] change qt math function to cmath analog

This commit is contained in:
Pavel Perekhozhikh 2018-01-19 01:35:50 +03:00 committed by Berkus Decker
parent a4987d41a9
commit 40f8f0939a
109 changed files with 593 additions and 593 deletions

View File

@ -687,7 +687,7 @@ void ApiWrap::lastParticipantsDone(ChannelData *peer, const MTPchannels_ChannelP
if (!keyboardBotFound) { if (!keyboardBotFound) {
h->clearLastKeyboard(); h->clearLastKeyboard();
} }
int newMembersCount = qMax(d.vcount.v, v.count()); int newMembersCount = std::max(d.vcount.v, v.count());
if (newMembersCount > peer->membersCount()) { if (newMembersCount > peer->membersCount()) {
peer->setMembersCount(newMembersCount); peer->setMembersCount(newMembersCount);
} }
@ -1334,7 +1334,7 @@ void ApiWrap::resolveWebPages() {
} }
} }
} else { } else {
m = qMin(m, i.key()->pendingTill - t); m = std::min(m, i.key()->pendingTill - t);
} }
} }

View File

@ -223,7 +223,7 @@ void AuthSession::checkAutoLock() {
auto shouldLockInMs = Global::AutoLock() * 1000LL; auto shouldLockInMs = Global::AutoLock() * 1000LL;
auto idleForMs = psIdleTime(); auto idleForMs = psIdleTime();
auto notPlayingVideoForMs = now - data().lastTimeVideoPlayedAt(); auto notPlayingVideoForMs = now - data().lastTimeVideoPlayedAt();
auto checkTimeMs = qMin(idleForMs, notPlayingVideoForMs); auto checkTimeMs = std::min(idleForMs, notPlayingVideoForMs);
if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) {
Messenger::Instance().setupPasscode(); Messenger::Instance().setupPasscode();
} else { } else {

View File

@ -27,7 +27,7 @@ namespace base {
namespace { namespace {
auto MainThreadId = std::this_thread::get_id(); auto MainThreadId = std::this_thread::get_id();
const auto MaxThreadsCount = qMax(std::thread::hardware_concurrency(), 2U); const auto MaxThreadsCount = std::max(std::thread::hardware_concurrency(), 2U);
} // namespace } // namespace

View File

@ -104,7 +104,7 @@ void BoxContent::onDraggingScrollDelta(int delta) {
} }
void BoxContent::onDraggingScrollTimer() { void BoxContent::onDraggingScrollTimer() {
auto delta = (_draggingScrollDelta > 0) ? qMin(_draggingScrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : qMax(_draggingScrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed)); auto delta = (_draggingScrollDelta > 0) ? std::min(_draggingScrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : std::max(_draggingScrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed));
_scroll->scrollToY(_scroll->scrollTop() + delta); _scroll->scrollToY(_scroll->scrollTop() + delta);
} }
@ -336,7 +336,7 @@ void AbstractBox::updateTitlePosition() {
_titleLeft = _layerType ? st::boxLayerTitlePosition.x() : st::boxTitlePosition.x(); _titleLeft = _layerType ? st::boxLayerTitlePosition.x() : st::boxTitlePosition.x();
_titleTop = _layerType ? st::boxLayerTitlePosition.y() : st::boxTitlePosition.y(); _titleTop = _layerType ? st::boxLayerTitlePosition.y() : st::boxTitlePosition.y();
if (_title) { if (_title) {
_title->resizeToWidth(qMin(_title->naturalWidth(), width() - _titleLeft * 2)); _title->resizeToWidth(std::min(_title->naturalWidth(), width() - _titleLeft * 2));
_title->moveToLeft(_titleLeft, _titleTop); _title->moveToLeft(_titleLeft, _titleTop);
} }
} }
@ -378,7 +378,7 @@ void AbstractBox::setDimensions(int newWidth, int maxHeight) {
auto newGeometry = geometry(); auto newGeometry = geometry();
auto parentHeight = parentWidget()->height(); auto parentHeight = parentWidget()->height();
if (newGeometry.top() + newGeometry.height() + st::boxVerticalMargin > parentHeight) { if (newGeometry.top() + newGeometry.height() + st::boxVerticalMargin > parentHeight) {
auto newTop = qMax(parentHeight - int(st::boxVerticalMargin) - newGeometry.height(), (parentHeight - newGeometry.height()) / 2); auto newTop = std::max(parentHeight - int(st::boxVerticalMargin) - newGeometry.height(), (parentHeight - newGeometry.height()) / 2);
if (newTop != newGeometry.top()) { if (newTop != newGeometry.top()) {
move(newGeometry.left(), newTop); move(newGeometry.left(), newTop);
} }
@ -391,7 +391,7 @@ void AbstractBox::setDimensions(int newWidth, int maxHeight) {
} }
int AbstractBox::countRealHeight() const { int AbstractBox::countRealHeight() const {
return qMin(_fullHeight, parentWidget()->height() - 2 * st::boxVerticalMargin); return std::min(_fullHeight, parentWidget()->height() - 2 * st::boxVerticalMargin);
} }
int AbstractBox::countFullHeight() const { int AbstractBox::countFullHeight() const {

View File

@ -1103,7 +1103,7 @@ void EditBioBox::handleBioUpdated() {
cursor.setPosition(position); cursor.setPosition(position);
_bio->setTextCursor(cursor); _bio->setTextCursor(cursor);
} }
auto countLeft = qMax(kMaxBioLength - text.size(), 0); auto countLeft = std::max(kMaxBioLength - text.size(), 0);
_countdown->setText(QString::number(countLeft)); _countdown->setText(QString::number(countLeft));
} }
@ -1503,7 +1503,7 @@ void RevokePublicLinkBox::Inner::paintChat(Painter &p, const ChatRow &row, bool
if (peer->isVerified()) { if (peer->isVerified()) {
auto icon = &st::dialogsVerifiedIcon; auto icon = &st::dialogsVerifiedIcon;
namew -= icon->width(); namew -= icon->width();
icon->paint(p, namex + qMin(row.name.maxWidth(), namew), st::contactsPadding.top() + st::contactsNameTop, width()); icon->paint(p, namex + std::min(row.name.maxWidth(), namew), st::contactsPadding.top() + st::contactsNameTop, width());
} }
row.name.drawLeftElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew, width()); row.name.drawLeftElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew, width());

View File

@ -130,7 +130,7 @@ void ConfirmBox::prepare() {
void ConfirmBox::textUpdated() { void ConfirmBox::textUpdated() {
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight); _textHeight = std::min(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxPadding.bottom()); setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxPadding.bottom());
setMouseTracking(_text.hasLinks()); setMouseTracking(_text.hasLinks());
@ -227,7 +227,7 @@ void MaxInviteBox::prepare() {
addButton(langFactory(lng_box_ok), [this] { closeBox(); }); addButton(langFactory(lng_box_ok), [this] { closeBox(); });
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight); _textHeight = std::min(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom()); setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) { subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
@ -474,7 +474,7 @@ void DeleteMessagesBox::prepare() {
canDeleteAllForEveryone = false; canDeleteAllForEveryone = false;
} }
} }
auto count = qMax(1, _ids.size()); auto count = std::max(1, _ids.size());
if (canDeleteAllForEveryone) { if (canDeleteAllForEveryone) {
_forEveryone.create(this, forEveryoneText, false, st::defaultBoxCheckbox); _forEveryone.create(this, forEveryoneText, false, st::defaultBoxCheckbox);
} else if (peer && peer->isChannel()) { } else if (peer && peer->isChannel()) {

View File

@ -202,7 +202,7 @@ void EditColorBox::Picker::updateCurrentPoint(QPoint localPosition) {
void EditColorBox::Picker::setHSV(int hue, int saturation, int brightness) { void EditColorBox::Picker::setHSV(int hue, int saturation, int brightness) {
_topleft = QColor(255, 255, 255); _topleft = QColor(255, 255, 255);
_topright.setHsv(qMax(0, hue), 255, 255); _topright.setHsv(std::max(0, hue), 255, 255);
_topright = _topright.toRgb(); _topright = _topright.toRgb();
_bottomleft = _bottomright = QColor(0, 0, 0); _bottomleft = _bottomright = QColor(0, 0, 0);
@ -305,11 +305,11 @@ void EditColorBox::Slider::paintEvent(QPaintEvent *e) {
} }
p.drawPixmap(to, _pixmap, _pixmap.rect()); p.drawPixmap(to, _pixmap, _pixmap.rect());
if (isHorizontal()) { if (isHorizontal()) {
auto x = st::colorSliderSkip + qRound(_value * to.width()); auto x = st::colorSliderSkip + std::round(_value * to.width());
st::colorSliderArrowTop.paint(p, x - st::colorSliderArrowTop.width() / 2, 0, width()); st::colorSliderArrowTop.paint(p, x - st::colorSliderArrowTop.width() / 2, 0, width());
st::colorSliderArrowBottom.paint(p, x - st::colorSliderArrowBottom.width() / 2, height() - st::colorSliderArrowBottom.height(), width()); st::colorSliderArrowBottom.paint(p, x - st::colorSliderArrowBottom.width() / 2, height() - st::colorSliderArrowBottom.height(), width());
} else { } else {
auto y = st::colorSliderSkip + qRound(_value * to.height()); auto y = st::colorSliderSkip + std::round(_value * to.height());
st::colorSliderArrowLeft.paint(p, 0, y - st::colorSliderArrowLeft.height() / 2, width()); st::colorSliderArrowLeft.paint(p, 0, y - st::colorSliderArrowLeft.height() / 2, width());
st::colorSliderArrowRight.paint(p, width() - st::colorSliderArrowRight.width(), y - st::colorSliderArrowRight.height() / 2, width()); st::colorSliderArrowRight.paint(p, width() - st::colorSliderArrowRight.width(), y - st::colorSliderArrowRight.height() / 2, width());
} }
@ -737,10 +737,10 @@ void EditColorBox::saveColor() {
} }
void EditColorBox::updateHSVFields() { void EditColorBox::updateHSVFields() {
auto hue = qRound((1. - _hueSlider->value()) * 360); auto hue = std::round((1. - _hueSlider->value()) * 360);
auto saturation = qRound(_picker->valueX() * 255); auto saturation = std::round(_picker->valueX() * 255);
auto brightness = qRound((1. - _picker->valueY()) * 255); auto brightness = std::round((1. - _picker->valueY()) * 255);
auto alpha = qRound(_opacitySlider->value() * 255); auto alpha = std::round(_opacitySlider->value() * 255);
_hueField->setTextWithFocus(QString::number(hue)); _hueField->setTextWithFocus(QString::number(hue));
_saturationField->setTextWithFocus(QString::number(percentFromByte(saturation))); _saturationField->setTextWithFocus(QString::number(percentFromByte(saturation)));
_brightnessField->setTextWithFocus(QString::number(percentFromByte(brightness))); _brightnessField->setTextWithFocus(QString::number(percentFromByte(brightness)));
@ -827,10 +827,10 @@ void EditColorBox::updateFromColor(QColor color) {
} }
void EditColorBox::updateFromControls() { void EditColorBox::updateFromControls() {
auto hue = qRound((1. - _hueSlider->value()) * 360); auto hue = std::round((1. - _hueSlider->value()) * 360);
auto saturation = qRound(_picker->valueX() * 255); auto saturation = std::round(_picker->valueX() * 255);
auto brightness = qRound((1. - _picker->valueY()) * 255); auto brightness = std::round((1. - _picker->valueY()) * 255);
auto alpha = qRound(_opacitySlider->value() * 255); auto alpha = std::round(_opacitySlider->value() * 255);
setHSV(hue, saturation, brightness, alpha); setHSV(hue, saturation, brightness, alpha);
updateHSVFields(); updateHSVFields();
updateControlsFromHSV(hue, saturation, brightness); updateControlsFromHSV(hue, saturation, brightness);
@ -840,7 +840,7 @@ void EditColorBox::updateFromHSVFields() {
auto hue = _hueField->value(); auto hue = _hueField->value();
auto saturation = percentToByte(_saturationField->value()); auto saturation = percentToByte(_saturationField->value());
auto brightness = percentToByte(_brightnessField->value()); auto brightness = percentToByte(_brightnessField->value());
auto alpha = qRound(_opacitySlider->value() * 255); auto alpha = std::round(_opacitySlider->value() * 255);
setHSV(hue, saturation, brightness, alpha); setHSV(hue, saturation, brightness, alpha);
updateControlsFromHSV(hue, saturation, brightness); updateControlsFromHSV(hue, saturation, brightness);
} }
@ -849,7 +849,7 @@ void EditColorBox::updateFromRGBFields() {
auto red = _redField->value(); auto red = _redField->value();
auto blue = _blueField->value(); auto blue = _blueField->value();
auto green = _greenField->value(); auto green = _greenField->value();
auto alpha = qRound(_opacitySlider->value() * 255); auto alpha = std::round(_opacitySlider->value() * 255);
setRGB(red, green, blue, alpha); setRGB(red, green, blue, alpha);
updateResultField(); updateResultField();
} }

View File

@ -186,7 +186,7 @@ void EditParticipantBox::removeControl(QPointer<TWidget> widget) {
void EditParticipantBox::resizeToContent() { void EditParticipantBox::resizeToContent() {
_inner->resizeToWidth(st::boxWideWidth); _inner->resizeToWidth(st::boxWideWidth);
setDimensions(_inner->width(), qMin(_inner->height(), st::boxMaxListHeight)); setDimensions(_inner->width(), std::min(_inner->height(), st::boxMaxListHeight));
} }
EditAdminBox::EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChannelAdminRights &rights) : EditParticipantBox(nullptr, channel, user, (rights.c_channelAdminRights().vflags.v != 0)) EditAdminBox::EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChannelAdminRights &rights) : EditParticipantBox(nullptr, channel, user, (rights.c_channelAdminRights().vflags.v != 0))

View File

@ -133,7 +133,7 @@ void LanguageBox::refresh() {
refreshLanguages(); refreshLanguages();
_inner->refresh(); _inner->refresh();
setDimensions(st::langsWidth, qMin(_inner->height(), st::boxMaxListHeight)); setDimensions(st::langsWidth, std::min(_inner->height(), st::boxMaxListHeight));
} }
void LanguageBox::refreshLanguages() { void LanguageBox::refreshLanguages() {

View File

@ -360,7 +360,7 @@ void NotificationsBox::setOverCorner(Notify::ScreenCorner corner) {
auto &samples = _cornerSamples[static_cast<int>(_overCorner)]; auto &samples = _cornerSamples[static_cast<int>(_overCorner)];
auto samplesAlready = samples.size(); auto samplesAlready = samples.size();
auto samplesNeeded = currentCount(); auto samplesNeeded = currentCount();
auto samplesLeave = qMin(samplesAlready, samplesNeeded); auto samplesLeave = std::min(samplesAlready, samplesNeeded);
for (int i = 0; i != samplesLeave; ++i) { for (int i = 0; i != samplesLeave; ++i) {
samples[i]->showFast(); samples[i]->showFast();
} }

View File

@ -840,7 +840,7 @@ int PeerListBox::Inner::resizeGetHeight(int newWidth) {
_aboveHeight = _aboveWidget->height(); _aboveHeight = _aboveWidget->height();
} }
} }
auto labelTop = rowsTop() + qMax(1, shownRowsCount()) * _rowHeight; auto labelTop = rowsTop() + std::max(1, shownRowsCount()) * _rowHeight;
if (_description) { if (_description) {
_description->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth); _description->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth);
_description->setVisible(!showingSearch()); _description->setVisible(!showingSearch());
@ -953,7 +953,7 @@ void PeerListBox::Inner::paintRow(Painter &p, TimeMs ms, RowIndex index) {
if (row->needsVerifiedIcon()) { if (row->needsVerifiedIcon()) {
auto icon = &st::dialogsVerifiedIcon; auto icon = &st::dialogsVerifiedIcon;
namew -= icon->width(); namew -= icon->width();
icon->paint(p, namex + qMin(name.maxWidth(), namew), st::contactsPadding.top() + st::contactsNameTop, width()); icon->paint(p, namex + std::min(name.maxWidth(), namew), st::contactsPadding.top() + st::contactsNameTop, width());
} }
auto nameCheckedRatio = row->disabled() ? 0. : row->checkedRatio(); auto nameCheckedRatio = row->disabled() ? 0. : row->checkedRatio();
p.setPen(anim::pen(st::contactsNameFg, st::contactsNameCheckedFg, nameCheckedRatio)); p.setPen(anim::pen(st::contactsNameFg, st::contactsNameCheckedFg, nameCheckedRatio));

View File

@ -397,9 +397,9 @@ int AddParticipantsBoxController::alreadyInCount() const {
return 1; // self return 1; // self
} }
if (auto chat = _peer->asChat()) { if (auto chat = _peer->asChat()) {
return qMax(chat->count, 1); return std::max(chat->count, 1);
} else if (auto channel = _peer->asChannel()) { } else if (auto channel = _peer->asChannel()) {
return qMax(channel->membersCount(), int(_alreadyIn.size())); return std::max(channel->membersCount(), int(_alreadyIn.size()));
} }
Unexpected("User in AddParticipantsBoxController::alreadyInCount"); Unexpected("User in AddParticipantsBoxController::alreadyInCount");
} }
@ -530,7 +530,7 @@ int EditChatAdminsBoxController::LabeledCheckbox::resizeGetHeight(int newWidth)
_labelWidth = newWidth - st::contactsPadding.left() - st::contactsPadding.right(); _labelWidth = newWidth - st::contactsPadding.left() - st::contactsPadding.right();
_checkbox->resizeToNaturalWidth(_labelWidth); _checkbox->resizeToNaturalWidth(_labelWidth);
_checkbox->moveToLeft(st::contactsPadding.left(), st::contactsAllAdminsTop); _checkbox->moveToLeft(st::contactsPadding.left(), st::contactsAllAdminsTop);
auto labelHeight = qMax( auto labelHeight = std::max(
_labelChecked.countHeight(_labelWidth), _labelChecked.countHeight(_labelWidth),
_labelUnchecked.countHeight(_labelWidth)); _labelUnchecked.countHeight(_labelWidth));
return st::contactsAboutTop + labelHeight + st::contactsAboutBottom; return st::contactsAboutTop + labelHeight + st::contactsAboutBottom;

View File

@ -65,7 +65,7 @@ void SelfDestructionBox::prepare() {
auto count = int(_ttlValues.size()); auto count = int(_ttlValues.size());
_options.reserve(count); _options.reserve(count);
for (auto days : _ttlValues) { for (auto days : _ttlValues) {
_options.emplace_back(this, group, days, (days > 364) ? lng_self_destruct_years(lt_count, days / 365) : lng_self_destruct_months(lt_count, qMax(days / 30, 1)), st::langsButton); _options.emplace_back(this, group, days, (days > 364) ? lng_self_destruct_years(lt_count, days / 365) : lng_self_destruct_months(lt_count, std::max(days / 30, 1)), st::langsButton);
_options.back()->moveToLeft(st::boxPadding.left(), y); _options.back()->moveToLeft(st::boxPadding.left(), y);
y += _options.back()->heightNoMargins() + st::boxOptionListSkip; y += _options.back()->heightNoMargins() + st::boxOptionListSkip;
} }

View File

@ -87,8 +87,8 @@ void SendFilesBox::prepareSingleFileLayout() {
if (_animated) { if (_animated) {
auto limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); auto limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
auto limitH = st::confirmMaxHeight; auto limitH = st::confirmMaxHeight;
maxW = qMax(image.width(), 1); maxW = std::max(image.width(), 1);
maxH = qMax(image.height(), 1); maxH = std::max(image.height(), 1);
if (maxW * limitH > maxH * limitW) { if (maxW * limitH > maxH * limitW) {
if (maxW < limitW) { if (maxW < limitW) {
maxH = maxH * limitW / maxW; maxH = maxH * limitW / maxW;
@ -109,12 +109,12 @@ void SendFilesBox::prepareSingleFileLayout() {
} }
_previewWidth = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); _previewWidth = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
if (image.width() < _previewWidth) { if (image.width() < _previewWidth) {
_previewWidth = qMax(image.width(), kMinPreviewWidth); _previewWidth = std::max(image.width(), kMinPreviewWidth);
} }
auto maxthumbh = qMin(qRound(1.5 * _previewWidth), st::confirmMaxHeight); auto maxthumbh = std::min<int>(std::round(1.5 * _previewWidth), st::confirmMaxHeight);
_previewHeight = qRound(originalHeight * double(_previewWidth) / originalWidth); _previewHeight = std::round(originalHeight * double(_previewWidth) / originalWidth);
if (_previewHeight > maxthumbh) { if (_previewHeight > maxthumbh) {
_previewWidth = qRound(_previewWidth * double(maxthumbh) / _previewHeight); _previewWidth = std::round(_previewWidth * double(maxthumbh) / _previewHeight);
accumulate_max(_previewWidth, kMinPreviewWidth); accumulate_max(_previewWidth, kMinPreviewWidth);
_previewHeight = maxthumbh; _previewHeight = maxthumbh;
} }
@ -182,7 +182,7 @@ void SendFilesBox::prepareDocumentLayout() {
auto filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true); auto filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
_nameText.setText(st::semiboldTextStyle, filename, _textNameOptions); _nameText.setText(st::semiboldTextStyle, filename, _textNameOptions);
_statusText = qsl("%1x%2").arg(_image.width()).arg(_image.height()); _statusText = qsl("%1x%2").arg(_image.width()).arg(_image.height());
_statusWidth = qMax(_nameText.maxWidth(), st::normalFont->width(_statusText)); _statusWidth = std::max(_nameText.maxWidth(), st::normalFont->width(_statusText));
_fileIsImage = true; _fileIsImage = true;
} else { } else {
auto fileinfo = QFileInfo(filepath); auto fileinfo = QFileInfo(filepath);
@ -202,7 +202,7 @@ void SendFilesBox::prepareDocumentLayout() {
auto nameString = DocumentData::composeNameString(filename, songTitle, songPerformer); auto nameString = DocumentData::composeNameString(filename, songTitle, songPerformer);
_nameText.setText(st::semiboldTextStyle, nameString, _textNameOptions); _nameText.setText(st::semiboldTextStyle, nameString, _textNameOptions);
_statusText = formatSizeText(fileinfo.size()); _statusText = formatSizeText(fileinfo.size());
_statusWidth = qMax(_nameText.maxWidth(), st::normalFont->width(_statusText)); _statusWidth = std::max(_nameText.maxWidth(), st::normalFont->width(_statusText));
} }
} }
@ -226,7 +226,7 @@ SendFilesBox::SendFilesBox(QWidget*, const QString &phone, const QString &firstn
auto name = lng_full_name(lt_first_name, _contactFirstName, lt_last_name, _contactLastName); auto name = lng_full_name(lt_first_name, _contactFirstName, lt_last_name, _contactLastName);
_nameText.setText(st::semiboldTextStyle, name, _textNameOptions); _nameText.setText(st::semiboldTextStyle, name, _textNameOptions);
_statusText = _contactPhone; _statusText = _contactPhone;
_statusWidth = qMax(_nameText.maxWidth(), st::normalFont->width(_statusText)); _statusWidth = std::max(_nameText.maxWidth(), st::normalFont->width(_statusText));
_contactPhotoEmpty.set(0, name); _contactPhotoEmpty.set(0, name);
} }
@ -510,7 +510,7 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
_name.setText(st::semiboldTextStyle, doc->composeNameString(), _textNameOptions); _name.setText(st::semiboldTextStyle, doc->composeNameString(), _textNameOptions);
} }
_status = formatSizeText(doc->size); _status = formatSizeText(doc->size);
_statusw = qMax(_name.maxWidth(), st::normalFont->width(_status)); _statusw = std::max(_name.maxWidth(), st::normalFont->width(_status));
_isImage = doc->isImage(); _isImage = doc->isImage();
_isAudio = (doc->voice() || doc->song()); _isAudio = (doc->voice() || doc->song());
} }
@ -519,8 +519,8 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
if (_animated) { if (_animated) {
qint32 limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); qint32 limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
qint32 limitH = st::confirmMaxHeight; qint32 limitH = st::confirmMaxHeight;
maxW = qMax(dimensions.width(), 1); maxW = std::max(dimensions.width(), 1);
maxH = qMax(dimensions.height(), 1); maxH = std::max(dimensions.height(), 1);
if (maxW * limitH > maxH * limitW) { if (maxW * limitH > maxH * limitW) {
if (maxW < limitW) { if (maxW < limitW) {
maxH = maxH * limitW / maxW; maxH = maxH * limitW / maxW;
@ -547,10 +547,10 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) :
if (_thumb.width() < _thumbw) { if (_thumb.width() < _thumbw) {
_thumbw = (_thumb.width() > 20) ? _thumb.width() : 20; _thumbw = (_thumb.width() > 20) ? _thumb.width() : 20;
} }
qint32 maxthumbh = qMin(qRound(1.5 * _thumbw), int(st::confirmMaxHeight)); qint32 maxthumbh = std::min<int>(std::round(1.5 * _thumbw), int(st::confirmMaxHeight));
_thumbh = qRound(th * double(_thumbw) / tw); _thumbh = std::round(th * double(_thumbw) / tw);
if (_thumbh > maxthumbh) { if (_thumbh > maxthumbh) {
_thumbw = qRound(_thumbw * double(maxthumbh) / _thumbh); _thumbw = std::round(_thumbw * double(maxthumbh) / _thumbh);
_thumbh = maxthumbh; _thumbh = maxthumbh;
if (_thumbw < 10) { if (_thumbw < 10) {
_thumbw = 10; _thumbw = 10;

View File

@ -269,7 +269,7 @@ void ShareBox::onMustScrollTo(int top, int bottom) {
} }
void ShareBox::scrollAnimationCallback() { void ShareBox::scrollAnimationCallback() {
//auto scrollTop = qRound(_scrollAnimation.current(scrollArea()->scrollTop())); //auto scrollTop = std::round(_scrollAnimation.current(scrollArea()->scrollTop()));
//scrollArea()->scrollToY(scrollTop); //scrollArea()->scrollToY(scrollTop);
} }
@ -370,7 +370,7 @@ void ShareBox::Inner::repaintChatAtIndex(int index) {
auto row = index / _columnCount; auto row = index / _columnCount;
auto column = index % _columnCount; auto column = index % _columnCount;
update(rtlrect(_rowsLeft + qFloor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width())); update(rtlrect(_rowsLeft + std::floor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width()));
} }
ShareBox::Inner::Chat *ShareBox::Inner::getChatAtIndex(int index) { ShareBox::Inner::Chat *ShareBox::Inner::getChatAtIndex(int index) {
@ -497,7 +497,7 @@ void ShareBox::Inner::setActive(int active) {
} }
void ShareBox::Inner::paintChat(Painter &p, TimeMs ms, Chat *chat, int index) { void ShareBox::Inner::paintChat(Painter &p, TimeMs ms, Chat *chat, int index) {
auto x = _rowsLeft + qFloor((index % _columnCount) * _rowWidthReal); auto x = _rowsLeft + std::floor((index % _columnCount) * _rowWidthReal);
auto y = _rowsTop + (index / _columnCount) * _rowHeight; auto y = _rowsTop + (index / _columnCount) * _rowHeight;
auto outerWidth = width(); auto outerWidth = width();
@ -596,8 +596,8 @@ void ShareBox::Inner::mouseMoveEvent(QMouseEvent *e) {
void ShareBox::Inner::updateUpon(const QPoint &pos) { void ShareBox::Inner::updateUpon(const QPoint &pos) {
auto x = pos.x(), y = pos.y(); auto x = pos.x(), y = pos.y();
auto row = (y - _rowsTop) / _rowHeight; auto row = (y - _rowsTop) / _rowHeight;
auto column = qFloor((x - _rowsLeft) / _rowWidthReal); auto column = std::floor((x - _rowsLeft) / _rowWidthReal);
auto left = _rowsLeft + qFloor(column * _rowWidthReal) + st::shareColumnSkip / 2; auto left = _rowsLeft + std::floor(column * _rowWidthReal) + st::shareColumnSkip / 2;
auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop; auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop;
auto xupon = (x >= left) && (x < left + (_rowWidth - st::shareColumnSkip)); auto xupon = (x >= left) && (x < left + (_rowWidth - st::shareColumnSkip));
auto yupon = (y >= top) && (y < top + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop + st::shareNameStyle.font->height * 2); auto yupon = (y >= top) && (y < top + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop + st::shareNameStyle.font->height * 2);
@ -622,8 +622,8 @@ void ShareBox::Inner::onSelectActive() {
void ShareBox::Inner::resizeEvent(QResizeEvent *e) { void ShareBox::Inner::resizeEvent(QResizeEvent *e) {
_columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / double(_columnCount + 1); _columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / double(_columnCount + 1);
_rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip; _rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip;
_rowsLeft = qFloor(_columnSkip / 2); _rowsLeft = std::floor(_columnSkip / 2);
_rowWidth = qFloor(_rowWidthReal); _rowWidth = std::floor(_rowWidthReal);
update(); update();
} }

View File

@ -338,8 +338,8 @@ void StickerSetBox::Inner::onPreview() {
qint32 StickerSetBox::Inner::stickerFromGlobalPos(const QPoint &p) const { qint32 StickerSetBox::Inner::stickerFromGlobalPos(const QPoint &p) const {
QPoint l(mapFromGlobal(p)); QPoint l(mapFromGlobal(p));
if (rtl()) l.setX(width() - l.x()); if (rtl()) l.setX(width() - l.x());
qint32 row = (l.y() >= st::stickersPadding.top()) ? qFloor((l.y() - st::stickersPadding.top()) / st::stickersSize.height()) : -1; qint32 row = (l.y() >= st::stickersPadding.top()) ? std::floor((l.y() - st::stickersPadding.top()) / st::stickersSize.height()) : -1;
qint32 col = (l.x() >= st::stickersPadding.left()) ? qFloor((l.x() - st::stickersPadding.left()) / st::stickersSize.width()) : -1; qint32 col = (l.x() >= st::stickersPadding.left()) ? std::floor((l.x() - st::stickersPadding.left()) / st::stickersSize.width()) : -1;
if (row >= 0 && col >= 0 && col < kStickersPanelPerRow) { if (row >= 0 && col >= 0 && col < kStickersPanelPerRow) {
qint32 result = row * kStickersPanelPerRow + col; qint32 result = row * kStickersPanelPerRow + col;
return (result < _pack.size()) ? result : -1; return (result < _pack.size()) ? result : -1;
@ -355,7 +355,7 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
auto ms = getms(); auto ms = getms();
qint32 rows = _pack.size() / kStickersPanelPerRow + ((_pack.size() % kStickersPanelPerRow) ? 1 : 0); qint32 rows = _pack.size() / kStickersPanelPerRow + ((_pack.size() % kStickersPanelPerRow) ? 1 : 0);
qint32 from = qFloor(e->rect().top() / st::stickersSize.height()), to = qFloor(e->rect().bottom() / st::stickersSize.height()) + 1; qint32 from = std::floor(e->rect().top() / st::stickersSize.height()), to = std::floor(e->rect().bottom() / st::stickersSize.height()) + 1;
for (qint32 i = from; i < to; ++i) { for (qint32 i = from; i < to; ++i) {
for (qint32 j = 0; j < kStickersPanelPerRow; ++j) { for (qint32 j = 0; j < kStickersPanelPerRow; ++j) {
@ -386,9 +386,9 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
double coef = qMin((st::stickersSize.width() - st::buttonRadius * 2) / double(doc->dimensions.width()), (st::stickersSize.height() - st::buttonRadius * 2) / double(doc->dimensions.height())); double coef = std::min((st::stickersSize.width() - st::buttonRadius * 2) / double(doc->dimensions.width()), (st::stickersSize.height() - st::buttonRadius * 2) / double(doc->dimensions.height()));
if (coef > 1) coef = 1; if (coef > 1) coef = 1;
qint32 w = qRound(coef * doc->dimensions.width()), h = qRound(coef * doc->dimensions.height()); qint32 w = std::round(coef * doc->dimensions.width()), h = std::round(coef * doc->dimensions.height());
if (w < 1) w = 1; if (w < 1) w = 1;
if (h < 1) h = 1; if (h < 1) h = 1;
QPoint ppos = pos + QPoint((st::stickersSize.width() - w) / 2, (st::stickersSize.height() - h) / 2); QPoint ppos = pos + QPoint((st::stickersSize.width() - w) / 2, (st::stickersSize.height() - h) / 2);

View File

@ -714,7 +714,7 @@ QRect StickersBox::Inner::relativeButtonRect(bool removeButton) const {
} }
void StickersBox::Inner::paintRow(Painter &p, Row *set, int index, TimeMs ms) { void StickersBox::Inner::paintRow(Painter &p, Row *set, int index, TimeMs ms) {
auto xadd = 0, yadd = qRound(set->yadd.current()); int xadd = 0, yadd = std::round(set->yadd.current());
if (xadd || yadd) p.translate(xadd, yadd); if (xadd || yadd) p.translate(xadd, yadd);
if (_megagroupSet) { if (_megagroupSet) {
@ -1041,8 +1041,8 @@ double StickersBox::Inner::aboveShadowOpacity() const {
if (_above < 0) return 0; if (_above < 0) return 0;
auto dx = 0; auto dx = 0;
auto dy = qAbs(_above * _rowHeight + qRound(_rows[_above]->yadd.current()) - _started * _rowHeight); auto dy = qAbs(_above * _rowHeight + std::round(_rows[_above]->yadd.current()) - _started * _rowHeight);
return qMin((dx + dy) * 2. / _rowHeight, 1.); return std::min((dx + dy) * 2. / _rowHeight, 1.);
} }
void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
@ -1324,7 +1324,7 @@ void StickersBox::Inner::setMinHeight(int newWidth, int minHeight) {
void StickersBox::Inner::updateSize(int newWidth) { void StickersBox::Inner::updateSize(int newWidth) {
auto naturalHeight = _itemsTop + int(_rows.size()) * _rowHeight + st::membersMarginBottom; auto naturalHeight = _itemsTop + int(_rows.size()) * _rowHeight + st::membersMarginBottom;
resize(newWidth ? newWidth : width(), qMax(_minHeight, naturalHeight)); resize(newWidth ? newWidth : width(), std::max(_minHeight, naturalHeight));
checkLoadMore(); checkLoadMore();
} }

View File

@ -463,10 +463,10 @@ void Panel::createUserpicCache(ImagePtr image) {
auto width = image->width(); auto width = image->width();
auto height = image->height(); auto height = image->height();
if (width > height) { if (width > height) {
width = qMax((width * size) / height, 1); width = std::max((width * size) / height, 1);
height = size; height = size;
} else { } else {
height = qMax((height * size) / width, 1); height = std::max((height * size) / width, 1);
width = size; width = size;
} }
_userPhoto = image->pixNoCache(width, height, options, st::callWidth, st::callWidth); _userPhoto = image->pixNoCache(width, height, options, st::callWidth, st::callWidth);
@ -611,8 +611,8 @@ void Panel::paintEvent(QPaintEvent *e) {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
auto marginRatio = (1. - opacity) / 5; auto marginRatio = (1. - opacity) / 5;
auto marginWidth = qRound(width() * marginRatio); auto marginWidth = std::round(width() * marginRatio);
auto marginHeight = qRound(height() * marginRatio); auto marginHeight = std::round(height() * marginRatio);
p.drawPixmap(rect().marginsRemoved(QMargins(marginWidth, marginHeight, marginWidth, marginHeight)), _animationCache, QRect(QPoint(0, 0), _animationCache.size())); p.drawPixmap(rect().marginsRemoved(QMargins(marginWidth, marginHeight, marginWidth, marginHeight)), _animationCache, QRect(QPoint(0, 0), _animationCache.size()));
return; return;
} }

View File

@ -187,7 +187,7 @@ void TopBar::updateControlsGeometry() {
_shortInfoLabel->setVisible(!showFull); _shortInfoLabel->setVisible(!showFull);
auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) { auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) {
auto minPadding = qMax(left, right); auto minPadding = std::max(left, right);
auto infoWidth = infoLabel->naturalWidth(); auto infoWidth = infoLabel->naturalWidth();
auto infoLeft = (width() - infoWidth) / 2; auto infoLeft = (width() - infoWidth) / 2;
if (infoLeft < minPadding) { if (infoLeft < minPadding) {

View File

@ -555,7 +555,7 @@ void EmojiListWidget::onShowPicker() {
auto xmax = width() - _picker->width(); auto xmax = width() - _picker->width();
auto coef = double(sel % kEmojiPanelPerRow) / double(kEmojiPanelPerRow - 1); auto coef = double(sel % kEmojiPanelPerRow) / double(kEmojiPanelPerRow - 1);
if (rtl()) coef = 1. - coef; if (rtl()) coef = 1. - coef;
_picker->move(qRound(xmax * coef), y); _picker->move(std::round(xmax * coef), y);
emit disableScroll(true); emit disableScroll(true);
} }
@ -672,7 +672,7 @@ void EmojiListWidget::updateSelected() {
if (p.y() >= info.rowsTop && p.y() < info.rowsBottom) { if (p.y() >= info.rowsTop && p.y() < info.rowsBottom) {
auto sx = (rtl() ? width() - p.x() : p.x()) - st::emojiPanPadding; auto sx = (rtl() ? width() - p.x() : p.x()) - st::emojiPanPadding;
if (sx >= 0 && sx < kEmojiPanelPerRow * st::emojiPanSize.width()) { if (sx >= 0 && sx < kEmojiPanelPerRow * st::emojiPanSize.width()) {
newSelected = qFloor((p.y() - info.rowsTop) / st::emojiPanSize.height()) * kEmojiPanelPerRow + qFloor(sx / st::emojiPanSize.width()); newSelected = std::floor((p.y() - info.rowsTop) / st::emojiPanSize.height()) * kEmojiPanelPerRow + std::floor(sx / st::emojiPanSize.width());
if (newSelected >= _emoji[info.section].size()) { if (newSelected >= _emoji[info.section].size()) {
newSelected = -1; newSelected = -1;
} else { } else {

View File

@ -132,7 +132,7 @@ bool FieldAutocomplete::clearFilteredBotCommands() {
namespace { namespace {
template <typename T, typename U> template <typename T, typename U>
inline int indexOfInFirstN(const T &v, const U &elem, int last) { inline int indexOfInFirstN(const T &v, const U &elem, int last) {
for (auto b = v.cbegin(), i = b, e = b + qMax(v.size(), last); i != e; ++i) { for (auto b = v.cbegin(), i = b, e = b + std::max(v.size(), last); i != e; ++i) {
if (*i == elem) { if (*i == elem) {
return (i - b); return (i - b);
} }
@ -366,7 +366,7 @@ void FieldAutocomplete::setBoundings(QRect boundings) {
void FieldAutocomplete::recount(bool resetScroll) { void FieldAutocomplete::recount(bool resetScroll) {
qint32 h = 0, oldst = _scroll->scrollTop(), st = oldst, maxh = 4.5 * st::mentionHeight; qint32 h = 0, oldst = _scroll->scrollTop(), st = oldst, maxh = 4.5 * st::mentionHeight;
if (!_srows.isEmpty()) { if (!_srows.isEmpty()) {
qint32 stickersPerRow = qMax(1, qint32(_boundings.width() - 2 * st::stickerPanPadding) / qint32(st::stickerPanSize.width())); qint32 stickersPerRow = std::max(1, qint32(_boundings.width() - 2 * st::stickerPanPadding) / qint32(st::stickerPanSize.width()));
qint32 rows = rowscount(_srows.size(), stickersPerRow); qint32 rows = rowscount(_srows.size(), stickersPerRow);
h = st::stickerPanPadding + rows * st::stickerPanSize.height(); h = st::stickerPanPadding + rows * st::stickerPanSize.height();
} else if (!_mrows.isEmpty()) { } else if (!_mrows.isEmpty()) {
@ -564,9 +564,9 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {
sticker->checkSticker(); sticker->checkSticker();
} }
double coef = qMin((st::stickerPanSize.width() - st::buttonRadius * 2) / double(sticker->dimensions.width()), (st::stickerPanSize.height() - st::buttonRadius * 2) / double(sticker->dimensions.height())); double coef = std::min((st::stickerPanSize.width() - st::buttonRadius * 2) / double(sticker->dimensions.width()), (st::stickerPanSize.height() - st::buttonRadius * 2) / double(sticker->dimensions.height()));
if (coef > 1) coef = 1; if (coef > 1) coef = 1;
qint32 w = qRound(coef * sticker->dimensions.width()), h = qRound(coef * sticker->dimensions.height()); qint32 w = std::round(coef * sticker->dimensions.width()), h = std::round(coef * sticker->dimensions.height());
if (w < 1) w = 1; if (w < 1) w = 1;
if (h < 1) h = 1; if (h < 1) h = 1;
QPoint ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2); QPoint ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2);
@ -578,7 +578,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {
} }
} }
} else { } else {
qint32 from = qFloor(e->rect().top() / st::mentionHeight), to = qFloor(e->rect().bottom() / st::mentionHeight) + 1; qint32 from = std::floor(e->rect().top() / st::mentionHeight), to = std::floor(e->rect().bottom() / st::mentionHeight) + 1;
qint32 last = _mrows->isEmpty() ? (_hrows->isEmpty() ? _brows->size() : _hrows->size()) : _mrows->size(); qint32 last = _mrows->isEmpty() ? (_hrows->isEmpty() ? _brows->size() : _hrows->size()) : _mrows->size();
auto filter = _parent->filter(); auto filter = _parent->filter();
bool hasUsername = filter.indexOf('@') > 0; bool hasUsername = filter.indexOf('@') > 0;
@ -684,7 +684,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {
} }
void FieldAutocompleteInner::resizeEvent(QResizeEvent *e) { void FieldAutocompleteInner::resizeEvent(QResizeEvent *e) {
_stickersPerRow = qMax(1, qint32(width() - 2 * st::stickerPanPadding) / qint32(st::stickerPanSize.width())); _stickersPerRow = std::max(1, qint32(width() - 2 * st::stickerPanPadding) / qint32(st::stickerPanSize.width()));
} }
void FieldAutocompleteInner::mouseMoveEvent(QMouseEvent *e) { void FieldAutocompleteInner::mouseMoveEvent(QMouseEvent *e) {

View File

@ -182,7 +182,7 @@ int GifsListWidget::countHeight() {
for (int i = 0, l = _rows.count(); i < l; ++i) { for (int i = 0, l = _rows.count(); i < l; ++i) {
result += _rows[i].height; result += _rows[i].height;
} }
return qMax(minimalLastHeight, result) + st::stickerPanPadding; return std::max(minimalLastHeight, result) + st::stickerPanPadding;
} }
GifsListWidget::~GifsListWidget() { GifsListWidget::~GifsListWidget() {
@ -581,8 +581,8 @@ GifsListWidget::Row &GifsListWidget::layoutInlineRow(Row &row, qint32 sumWidth)
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int index = indices[i]; int index = indices[i];
int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth(); int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth();
int actualw = qMax(w, int(st::inlineResultsMinWidth)); int actualw = std::max(w, int(st::inlineResultsMinWidth));
row.height = qMax(row.height, row.items[index]->resizeGetHeight(actualw)); row.height = std::max(row.height, row.items[index]->resizeGetHeight(actualw));
if (sumWidth) { if (sumWidth) {
availw -= actualw; availw -= actualw;
sumWidth -= row.items.at(index)->maxWidth(); sumWidth -= row.items.at(index)->maxWidth();

View File

@ -125,11 +125,11 @@ StickersListWidget::Footer::Footer(not_null<StickersListWidget*> parent) : Inner
template <typename Callback> template <typename Callback>
void StickersListWidget::Footer::enumerateVisibleIcons(Callback callback) { void StickersListWidget::Footer::enumerateVisibleIcons(Callback callback) {
auto iconsX = qRound(_iconsX.current()); int iconsX = std::round(_iconsX.current());
auto index = iconsX / st::emojiCategory.width; auto index = iconsX / st::emojiCategory.width;
auto x = _iconsLeft - (iconsX % st::emojiCategory.width); auto x = _iconsLeft - (iconsX % st::emojiCategory.width);
for (auto index = qMin(_icons.size(), iconsX / st::emojiCategory.width), for (auto index = std::min<int>(_icons.size(), iconsX / st::emojiCategory.width),
last = qMin(_icons.size(), index + kVisibleIconsCount); index != last; ++index) { last = std::min(_icons.size(), index + kVisibleIconsCount); index != last; ++index) {
callback(_icons[index], x); callback(_icons[index], x);
x += st::emojiCategory.width; x += st::emojiCategory.width;
} }
@ -198,8 +198,8 @@ void StickersListWidget::Footer::paintEvent(QPaintEvent *e) {
paintStickerSettingsIcon(p); paintStickerSettingsIcon(p);
} }
auto selxrel = _iconsLeft + qRound(_iconSelX.current()); auto selxrel = _iconsLeft + std::round(_iconSelX.current());
auto selx = selxrel - qRound(_iconsX.current()); auto selx = selxrel - std::round(_iconsX.current());
auto clip = QRect(_iconsLeft, _iconsTop, _iconsLeft + (kVisibleIconsCount - 1) * st::emojiCategory.width - _iconsLeft, st::emojiCategory.height); auto clip = QRect(_iconsLeft, _iconsTop, _iconsLeft + (kVisibleIconsCount - 1) * st::emojiCategory.width - _iconsLeft, st::emojiCategory.height);
if (rtl()) clip.moveLeft(width() - _iconsLeft - clip.width()); if (rtl()) clip.moveLeft(width() - _iconsLeft - clip.width());
@ -258,7 +258,7 @@ void StickersListWidget::Footer::mousePressEvent(QMouseEvent *e) {
} else { } else {
_iconDown = _iconOver; _iconDown = _iconOver;
_iconsMouseDown = _iconsMousePos; _iconsMouseDown = _iconsMousePos;
_iconsStartX = qRound(_iconsX.current()); _iconsStartX = std::round(_iconsX.current());
} }
} }
@ -273,7 +273,7 @@ void StickersListWidget::Footer::mouseMoveEvent(QMouseEvent *e) {
} }
if (_iconsDragging) { if (_iconsDragging) {
auto newX = snap(_iconsStartX + (rtl() ? -1 : 1) * (_iconsMouseDown.x() - _iconsMousePos.x()), 0, _iconsMax); auto newX = snap(_iconsStartX + (rtl() ? -1 : 1) * (_iconsMouseDown.x() - _iconsMousePos.x()), 0, _iconsMax);
if (newX != qRound(_iconsX.current())) { if (newX != std::round(_iconsX.current())) {
_iconsX = anim::value(newX, newX); _iconsX = anim::value(newX, newX);
_iconsStartAnim = 0; _iconsStartAnim = 0;
_a_icons.stop(); _a_icons.stop();
@ -293,7 +293,7 @@ void StickersListWidget::Footer::mouseReleaseEvent(QMouseEvent *e) {
_iconsMousePos = e ? e->globalPos() : QCursor::pos(); _iconsMousePos = e ? e->globalPos() : QCursor::pos();
if (_iconsDragging) { if (_iconsDragging) {
auto newX = snap(_iconsStartX + _iconsMouseDown.x() - _iconsMousePos.x(), 0, _iconsMax); auto newX = snap(_iconsStartX + _iconsMouseDown.x() - _iconsMousePos.x(), 0, _iconsMax);
if (newX != qRound(_iconsX.current())) { if (newX != std::round(_iconsX.current())) {
_iconsX = anim::value(newX, newX); _iconsX = anim::value(newX, newX);
_iconsStartAnim = 0; _iconsStartAnim = 0;
_a_icons.stop(); _a_icons.stop();
@ -320,13 +320,13 @@ bool StickersListWidget::Footer::event(QEvent *e) {
auto horizontal = (ev->angleDelta().x() != 0 || ev->orientation() == Qt::Horizontal); auto horizontal = (ev->angleDelta().x() != 0 || ev->orientation() == Qt::Horizontal);
auto vertical = (ev->angleDelta().y() != 0 || ev->orientation() == Qt::Vertical); auto vertical = (ev->angleDelta().y() != 0 || ev->orientation() == Qt::Vertical);
if (horizontal) _horizontal = true; if (horizontal) _horizontal = true;
auto newX = qRound(_iconsX.current()); int newX = std::round(_iconsX.current());
if (/*_horizontal && */horizontal) { if (/*_horizontal && */horizontal) {
newX = snap(newX - (rtl() ? -1 : 1) * (ev->pixelDelta().x() ? ev->pixelDelta().x() : ev->angleDelta().x()), 0, _iconsMax); newX = snap(newX - (rtl() ? -1 : 1) * (ev->pixelDelta().x() ? ev->pixelDelta().x() : ev->angleDelta().x()), 0, _iconsMax);
} else if (/*!_horizontal && */vertical) { } else if (/*!_horizontal && */vertical) {
newX = snap(newX - (ev->pixelDelta().y() ? ev->pixelDelta().y() : ev->angleDelta().y()), 0, _iconsMax); newX = snap(newX - (ev->pixelDelta().y() ? ev->pixelDelta().y() : ev->angleDelta().y()), 0, _iconsMax);
} }
if (newX != qRound(_iconsX.current())) { if (newX != std::round(_iconsX.current())) {
_iconsX = anim::value(newX, newX); _iconsX = anim::value(newX, newX);
_iconsStartAnim = 0; _iconsStartAnim = 0;
_a_icons.stop(); _a_icons.stop();
@ -353,8 +353,8 @@ void StickersListWidget::Footer::updateSelected() {
} }
} else if (!_icons.isEmpty()) { } else if (!_icons.isEmpty()) {
if (y >= _iconsTop && y < _iconsTop + st::emojiCategory.height && x >= 0 && x < (kVisibleIconsCount - 1) * st::emojiCategory.width && x < _icons.size() * st::emojiCategory.width) { if (y >= _iconsTop && y < _iconsTop + st::emojiCategory.height && x >= 0 && x < (kVisibleIconsCount - 1) * st::emojiCategory.width && x < _icons.size() * st::emojiCategory.width) {
x += qRound(_iconsX.current()); x += std::round(_iconsX.current());
newOver = qFloor(x / st::emojiCategory.width); newOver = std::floor(x / st::emojiCategory.width);
} }
} }
if (newOver != _iconOver) { if (newOver != _iconOver) {
@ -377,7 +377,7 @@ void StickersListWidget::Footer::refreshIcons(ValidateIconAnimations animations)
if (_icons.isEmpty()) { if (_icons.isEmpty()) {
_iconsMax = 0; _iconsMax = 0;
} else { } else {
_iconsMax = qMax(int((_icons.size() + 1 - kVisibleIconsCount) * st::emojiCategory.width), 0); _iconsMax = std::max(int((_icons.size() + 1 - kVisibleIconsCount) * st::emojiCategory.width), 0);
} }
if (_iconsX.current() > _iconsMax) { if (_iconsX.current() > _iconsMax) {
_iconsX = anim::value(_iconsMax, _iconsMax); _iconsX = anim::value(_iconsMax, _iconsMax);
@ -491,7 +491,7 @@ void StickersListWidget::readVisibleSets() {
if (i * rowHeight < itemsVisibleTop || (i + 1) * rowHeight > itemsVisibleBottom) { if (i * rowHeight < itemsVisibleTop || (i + 1) * rowHeight > itemsVisibleBottom) {
continue; continue;
} }
int count = qMin(set.pack.size(), static_cast<int>(kStickersPanelPerRow)); int count = std::min(set.pack.size(), static_cast<int>(kStickersPanelPerRow));
int loaded = 0; int loaded = 0;
for (int j = 0; j < count; ++j) { for (int j = 0; j < count; ++j) {
if (set.pack[j]->thumb->loaded() || set.pack[j]->loaded()) { if (set.pack[j]->thumb->loaded() || set.pack[j]->loaded()) {
@ -568,11 +568,11 @@ int StickersListWidget::countHeight() {
return st::stickerPanPadding + shownSets().size() * featuredRowHeight(); return st::stickerPanPadding + shownSets().size() * featuredRowHeight();
} else if (!shownSets().empty()) { } else if (!shownSets().empty()) {
auto info = sectionInfo(shownSets().size() - 1); auto info = sectionInfo(shownSets().size() - 1);
return info.top + qMax(info.rowsBottom - info.top, minimalLastHeight); return info.top + std::max(info.rowsBottom - info.top, minimalLastHeight);
} }
return 0; return 0;
}; };
return qMax(minimalLastHeight, countResult()) + st::stickerPanPadding; return std::max(minimalLastHeight, countResult()) + st::stickerPanPadding;
} }
void StickersListWidget::installedLocally(quint64 setId) { void StickersListWidget::installedLocally(quint64 setId) {
@ -827,10 +827,10 @@ void StickersListWidget::paintSticker(Painter &p, Set &set, int y, int index, bo
sticker->checkSticker(); sticker->checkSticker();
} }
auto coef = qMin((st::stickerPanSize.width() - st::buttonRadius * 2) / double(sticker->dimensions.width()), (st::stickerPanSize.height() - st::buttonRadius * 2) / double(sticker->dimensions.height())); auto coef = std::min((st::stickerPanSize.width() - st::buttonRadius * 2) / double(sticker->dimensions.width()), (st::stickerPanSize.height() - st::buttonRadius * 2) / double(sticker->dimensions.height()));
if (coef > 1) coef = 1; if (coef > 1) coef = 1;
auto w = qMax(qRound(coef * sticker->dimensions.width()), 1); auto w = std::max<int>(std::round(coef * sticker->dimensions.width()), 1);
auto h = qMax(qRound(coef * sticker->dimensions.height()), 1); auto h = std::max<int>(std::round(coef * sticker->dimensions.height()), 1);
auto ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2); auto ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2);
if (goodThumb) { if (goodThumb) {
p.drawPixmapLeft(ppos, width(), sticker->thumb->pix(w, h)); p.drawPixmapLeft(ppos, width(), sticker->thumb->pix(w, h));
@ -1431,7 +1431,7 @@ void StickersListWidget::updateSelected() {
} }
} else if (yOffset >= st::stickersTrendingHeader && yOffset < st::stickersTrendingHeader + st::stickerPanSize.height()) { } else if (yOffset >= st::stickersTrendingHeader && yOffset < st::stickersTrendingHeader + st::stickerPanSize.height()) {
if (sx >= 0 && sx < kStickersPanelPerRow * st::stickerPanSize.width()) { if (sx >= 0 && sx < kStickersPanelPerRow * st::stickerPanSize.width()) {
auto index = qFloor(sx / st::stickerPanSize.width()); int index = std::floor(sx / st::stickerPanSize.width());
if (index >= 0 && index < set.pack.size()) { if (index >= 0 && index < set.pack.size()) {
auto overDelete = false; auto overDelete = false;
newSelected = OverSticker { section, index, overDelete }; newSelected = OverSticker { section, index, overDelete };
@ -1460,8 +1460,8 @@ void StickersListWidget::updateSelected() {
} }
} else { } else {
auto special = ((set.flags & MTPDstickerSet::Flag::f_official) != 0); auto special = ((set.flags & MTPDstickerSet::Flag::f_official) != 0);
auto rowIndex = qFloor(yOffset / st::stickerPanSize.height()); int rowIndex = std::floor(yOffset / st::stickerPanSize.height());
auto columnIndex = qFloor(sx / st::stickerPanSize.width()); int columnIndex = std::floor(sx / st::stickerPanSize.width());
auto index = rowIndex * kStickersPanelPerRow + columnIndex; auto index = rowIndex * kStickersPanelPerRow + columnIndex;
if (index >= 0 && index < set.pack.size()) { if (index >= 0 && index < set.pack.size()) {
auto overDelete = false; auto overDelete = false;

View File

@ -100,7 +100,7 @@ void TabbedPanel::updateContentHeight() {
auto addedHeight = innerPadding().top() + innerPadding().bottom(); auto addedHeight = innerPadding().top() + innerPadding().bottom();
auto marginsHeight = _selector->marginTop() + _selector->marginBottom(); auto marginsHeight = _selector->marginTop() + _selector->marginBottom();
auto availableHeight = _bottom - marginsHeight; auto availableHeight = _bottom - marginsHeight;
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * availableHeight) - addedHeight; int wantedContentHeight = std::round(st::emojiPanHeightRatio * availableHeight) - addedHeight;
auto contentHeight = marginsHeight + snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight); auto contentHeight = marginsHeight + snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
auto resultTop = _bottom - addedHeight - contentHeight; auto resultTop = _bottom - addedHeight - contentHeight;
if (contentHeight == _contentHeight) { if (contentHeight == _contentHeight) {

View File

@ -459,7 +459,7 @@ void Generator::writeSetSearch(const std::set<QString, std::greater<QString>> &s
for (auto i = 1; i != usedIfForCheckCount; ++i) { for (auto i = 1; i != usedIfForCheckCount; ++i) {
checkTypes.push_back(UsedCheckType::UpcomingIf); checkTypes.push_back(UsedCheckType::UpcomingIf);
chars.push_back(keyChar); chars.push_back(keyChar);
checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back()));
keyChar = name[checking + i]; keyChar = name[checking + i];
} }
} else { } else {
@ -468,7 +468,7 @@ void Generator::writeSetSearch(const std::set<QString, std::greater<QString>> &s
} }
++tabsUsed; ++tabsUsed;
chars.push_back(keyChar); chars.push_back(keyChar);
checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back()));
} }
source_->stream() << tabs(tabsUsed) << "return (size == " << chars.size() << ") ? " << computeResult(name) << " : " << invalidResult << ";\n"; source_->stream() << tabs(tabsUsed) << "return (size == " << chars.size() << ") ? " << computeResult(name) << " : " << invalidResult << ";\n";
} }

View File

@ -931,7 +931,7 @@ int getPaletteIndex(QLatin1String name) {\n\
for (auto i = 1; i != usedIfForCheckCount; ++i) { for (auto i = 1; i != usedIfForCheckCount; ++i) {
checkTypes.push_back(UsedCheckType::UpcomingIf); checkTypes.push_back(UsedCheckType::UpcomingIf);
chars.push_back(keyChar); chars.push_back(keyChar);
checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back()));
keyChar = name[checking + i]; keyChar = name[checking + i];
} }
} else { } else {
@ -940,7 +940,7 @@ int getPaletteIndex(QLatin1String name) {\n\
} }
++tabsUsed; ++tabsUsed;
chars.push_back(keyChar); chars.push_back(keyChar);
checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back()));
} }
source_->stream() << tabs(tabsUsed) << "return (size == " << chars.size() << ") ? " << index << " : -1;\n"; source_->stream() << tabs(tabsUsed) << "return (size == " << chars.size() << ") ? " << index << " : -1;\n";
} }

View File

@ -79,7 +79,7 @@ bool isValidColor(const QString &str) {
} }
uchar toGray(uchar r, uchar g, uchar b) { uchar toGray(uchar r, uchar g, uchar b) {
return qMax(qMin(int(0.21 * r + 0.72 * g + 0.07 * b), 255), 0); return std::max(std::min(int(0.21 * r + 0.72 * g + 0.07 * b), 255), 0);
} }
uchar readHexUchar(QChar ch) { uchar readHexUchar(QChar ch) {

View File

@ -374,7 +374,7 @@ void DialogsInner::paintDialog(Painter &p, Dialogs::Row *row, int fullWidth, Pee
auto pos = row->pos(); auto pos = row->pos();
auto xadd = 0, yadd = 0; auto xadd = 0, yadd = 0;
if (pos < _pinnedRows.size()) { if (pos < _pinnedRows.size()) {
yadd = qRound(_pinnedRows[pos].yadd.current()); yadd = std::round(_pinnedRows[pos].yadd.current());
} }
if (xadd || yadd) p.translate(xadd, yadd); if (xadd || yadd) p.translate(xadd, yadd);
auto isActive = (row->history()->peer == active) || (row->history()->peer->migrateTo() && row->history()->peer->migrateTo() == active); auto isActive = (row->history()->peer == active) || (row->history()->peer->migrateTo() && row->history()->peer->migrateTo() == active);
@ -407,7 +407,7 @@ void DialogsInner::paintPeerSearchResult(Painter &p, const PeerSearchResult *res
if (peer->isVerified()) { if (peer->isVerified()) {
auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon)); auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon));
rectForName.setWidth(rectForName.width() - icon->width()); rectForName.setWidth(rectForName.width() - icon->width());
icon->paint(p, rectForName.topLeft() + QPoint(qMin(peer->dialogName().maxWidth(), rectForName.width()), 0), fullWidth); icon->paint(p, rectForName.topLeft() + QPoint(std::min(peer->dialogName().maxWidth(), rectForName.width()), 0), fullWidth);
} }
QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height); QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height);
@ -784,7 +784,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
_a_pinnedShifting.start(); _a_pinnedShifting.start();
} }
} }
_aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current()); _aboveTopShift = std::ceil(_pinnedRows[_aboveIndex].yadd.current());
_pinnedRows[_draggingIndex].yadd = anim::value(yaddWas - shift * rowHeight, localPosition.y() - _dragStart.y()); _pinnedRows[_draggingIndex].yadd = anim::value(yaddWas - shift * rowHeight, localPosition.y() - _dragStart.y());
if (!_pinnedRows[_draggingIndex].animStartTime) { if (!_pinnedRows[_draggingIndex].animStartTime) {
_pinnedRows[_draggingIndex].yadd.finish(); _pinnedRows[_draggingIndex].yadd.finish();
@ -835,7 +835,7 @@ void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) {
if (_aboveIndex >= 0 && _aboveIndex < _pinnedRows.size()) { if (_aboveIndex >= 0 && _aboveIndex < _pinnedRows.size()) {
// Always include currently dragged chat in its current and old positions. // Always include currently dragged chat in its current and old positions.
auto aboveRowBottom = top + (_aboveIndex + 1) * st::dialogsRowHeight; auto aboveRowBottom = top + (_aboveIndex + 1) * st::dialogsRowHeight;
auto aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current()); int aboveTopShift = std::ceil(_pinnedRows[_aboveIndex].yadd.current());
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift); accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift);
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift); accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift);
_aboveTopShift = aboveTopShift; _aboveTopShift = aboveTopShift;
@ -951,7 +951,7 @@ void DialogsInner::setSearchedPressed(int pressed) {
void DialogsInner::resizeEvent(QResizeEvent *e) { void DialogsInner::resizeEvent(QResizeEvent *e) {
_addContactLnk->move((width() - _addContactLnk->width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2); _addContactLnk->move((width() - _addContactLnk->width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2);
auto widthForCancelButton = qMax(width() + otherWidth(), st::dialogsWidthMin); auto widthForCancelButton = std::max(width() + otherWidth(), st::dialogsWidthMin);
_cancelSearchInPeer->moveToLeft(widthForCancelButton - st::dialogsSearchInSkip - _cancelSearchInPeer->width(), st::searchedBarHeight + (st::dialogsSearchInHeight - st::dialogsCancelSearchInPeer.height) / 2); _cancelSearchInPeer->moveToLeft(widthForCancelButton - st::dialogsSearchInSkip - _cancelSearchInPeer->width(), st::searchedBarHeight + (st::dialogsSearchInHeight - st::dialogsCancelSearchInPeer.height) / 2);
_cancelSearchFromUser->moveToLeft(widthForCancelButton - st::dialogsSearchInSkip - _cancelSearchFromUser->width(), st::searchedBarHeight + st::dialogsSearchInHeight + st::lineWidth + (st::dialogsSearchInHeight - st::dialogsCancelSearchInPeer.height) / 2); _cancelSearchFromUser->moveToLeft(widthForCancelButton - st::dialogsSearchInSkip - _cancelSearchFromUser->width(), st::searchedBarHeight + st::dialogsSearchInHeight + st::lineWidth + (st::dialogsSearchInHeight - st::dialogsCancelSearchInPeer.height) / 2);
} }
@ -1029,7 +1029,7 @@ void DialogsInner::createDialog(History *history) {
if (creating) { if (creating) {
refresh(); refresh();
} else if (_state == DefaultState && changed.movedFrom != changed.movedTo) { } else if (_state == DefaultState && changed.movedFrom != changed.movedTo) {
update(0, qMin(from, to), getFullWidth(), qAbs(from - to) + st::dialogsRowHeight); update(0, std::min(from, to), getFullWidth(), qAbs(from - to) + st::dialogsRowHeight);
} }
} }
@ -1068,7 +1068,7 @@ void DialogsInner::dlgUpdated(Dialogs::Mode list, Dialogs::Row *row) {
auto position = row->pos(); auto position = row->pos();
auto top = dialogsOffset(); auto top = dialogsOffset();
if (position >= 0 && position < _pinnedRows.size()) { if (position >= 0 && position < _pinnedRows.size()) {
top += qRound(_pinnedRows[position].yadd.current()); top += std::round(_pinnedRows[position].yadd.current());
} }
update(0, top + position * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight); update(0, top + position * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight);
} }
@ -1098,7 +1098,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect
auto position = row->pos(); auto position = row->pos();
auto top = dialogsOffset(); auto top = dialogsOffset();
if (position >= 0 && position < _pinnedRows.size()) { if (position >= 0 && position < _pinnedRows.size()) {
top += qRound(_pinnedRows[position].yadd.current()); top += std::round(_pinnedRows[position].yadd.current());
} }
updateRow(top + position * st::dialogsRowHeight); updateRow(top + position * st::dialogsRowHeight);
} }
@ -1151,7 +1151,7 @@ void DialogsInner::updateSelectedRow(PeerData *peer) {
auto position = h->posInChatList(Global::DialogsMode()); auto position = h->posInChatList(Global::DialogsMode());
auto top = dialogsOffset(); auto top = dialogsOffset();
if (position >= 0 && position < _pinnedRows.size()) { if (position >= 0 && position < _pinnedRows.size()) {
top += qRound(_pinnedRows[position].yadd.current()); top += std::round(_pinnedRows[position].yadd.current());
} }
update(0, top + position * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight); update(0, top + position * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight);
} }
@ -1381,7 +1381,7 @@ void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) {
auto &recent = cRecentSearchHashtags(); auto &recent = cRecentSearchHashtags();
_hashtagResults.clear(); _hashtagResults.clear();
if (!recent.isEmpty()) { if (!recent.isEmpty()) {
_hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit)); _hashtagResults.reserve(std::min(recent.size(), kHashtagResultsLimit));
for (auto i = recent.cbegin(), e = recent.cend(); i != e; ++i) { for (auto i = recent.cbegin(), e = recent.cend(); i != e; ++i) {
if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) { if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) {
_hashtagResults.push_back(std::make_unique<HashtagResult>(i->first)); _hashtagResults.push_back(std::make_unique<HashtagResult>(i->first));
@ -1663,7 +1663,7 @@ void DialogsInner::notify_historyMuteUpdated(History *history) {
if (creating) { if (creating) {
refresh(); refresh();
} else if (_state == DefaultState && changed.movedFrom != changed.movedTo) { } else if (_state == DefaultState && changed.movedFrom != changed.movedTo) {
update(0, qMin(from, to), getFullWidth(), qAbs(from - to) + st::dialogsRowHeight); update(0, std::min(from, to), getFullWidth(), qAbs(from - to) + st::dialogsRowHeight);
} }
} }
} }

View File

@ -153,7 +153,7 @@ void paintRow(Painter &p, const RippleRow *row, History *history, not_null<PeerD
if (from == history->peer && from->isVerified()) { if (from == history->peer && from->isVerified()) {
auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon)); auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon));
rectForName.setWidth(rectForName.width() - icon->width()); rectForName.setWidth(rectForName.width() - icon->width());
icon->paint(p, rectForName.topLeft() + QPoint(qMin(from->dialogName().maxWidth(), rectForName.width()), 0), fullWidth); icon->paint(p, rectForName.topLeft() + QPoint(std::min(from->dialogName().maxWidth(), rectForName.width()), 0), fullWidth);
} }
p.setPen(active ? st::dialogsNameFgActive : (selected ? st::dialogsNameFgOver : st::dialogsNameFg)); p.setPen(active ? st::dialogsNameFgActive : (selected ? st::dialogsNameFgOver : st::dialogsNameFg));

View File

@ -436,7 +436,7 @@ void DialogsWidget::onDraggingScrollDelta(int delta) {
} }
void DialogsWidget::onDraggingScrollTimer() { void DialogsWidget::onDraggingScrollTimer() {
auto delta = (_draggingScrollDelta > 0) ? qMin(_draggingScrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : qMax(_draggingScrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed)); auto delta = (_draggingScrollDelta > 0) ? std::min(_draggingScrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : std::max(_draggingScrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed));
_scroll->scrollToY(_scroll->scrollTop() + delta); _scroll->scrollToY(_scroll->scrollTop() + delta);
} }
@ -943,7 +943,7 @@ void DialogsWidget::updateControlsGeometry() {
auto smallLayoutRatio = (width() < st::dialogsWidthMin) ? (st::dialogsWidthMin - width()) / double(st::dialogsWidthMin - smallLayoutWidth) : 0.; auto smallLayoutRatio = (width() < st::dialogsWidthMin) ? (st::dialogsWidthMin - width()) / double(st::dialogsWidthMin - smallLayoutWidth) : 0.;
auto filterLeft = st::dialogsFilterPadding.x() + _mainMenuToggle->width() + st::dialogsFilterPadding.x(); auto filterLeft = st::dialogsFilterPadding.x() + _mainMenuToggle->width() + st::dialogsFilterPadding.x();
auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x(); auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
auto filterWidth = qMax(width(), st::dialogsWidthMin) - filterLeft - filterRight; auto filterWidth = std::max(width(), st::dialogsWidthMin) - filterLeft - filterRight;
auto filterAreaHeight = st::dialogsFilterPadding.y() + _mainMenuToggle->height() + st::dialogsFilterPadding.y(); auto filterAreaHeight = st::dialogsFilterPadding.y() + _mainMenuToggle->height() + st::dialogsFilterPadding.y();
auto filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2; auto filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2;
filterLeft = anim::interpolate(filterLeft, smallLayoutWidth, smallLayoutRatio); filterLeft = anim::interpolate(filterLeft, smallLayoutWidth, smallLayoutRatio);
@ -1062,7 +1062,7 @@ void DialogsWidget::paintEvent(QPaintEvent *e) {
p.fillRect(above.intersected(r), st::dialogsBg); p.fillRect(above.intersected(r), st::dialogsBg);
} }
auto belowTop = _scroll->y() + qMin(_scroll->height(), _inner->height()); auto belowTop = _scroll->y() + std::min(_scroll->height(), _inner->height());
if (!_widthAnimationCache.isNull()) { if (!_widthAnimationCache.isNull()) {
p.drawPixmapLeft(0, _scroll->y(), width(), _widthAnimationCache); p.drawPixmapLeft(0, _scroll->y(), width(), _widthAnimationCache);
belowTop = _scroll->y() + (_widthAnimationCache.height() / cIntRetinaFactor()); belowTop = _scroll->y() + (_widthAnimationCache.height() / cIntRetinaFactor());

View File

@ -428,7 +428,7 @@ bool CheckBetaVersionDir() {
QByteArray k; QByteArray k;
dataStream >> v >> k; dataStream >> v >> k;
if (dataStream.status() == QDataStream::Ok) { if (dataStream.status() == QDataStream::Ok) {
cSetBetaVersion(qMax(v, AppVersion * 1000ULL)); cSetBetaVersion(std::max(v, AppVersion * 1000ULL));
cSetBetaPrivateKey(k); cSetBetaPrivateKey(k);
cSetRealBetaVersion(v); cSetRealBetaVersion(v);
} else { } else {

View File

@ -1680,10 +1680,10 @@ void History::setUnreadCount(int newUnreadCount) {
if (_unreadCount != newUnreadCount) { if (_unreadCount != newUnreadCount) {
if (newUnreadCount == 1) { if (newUnreadCount == 1) {
if (loadedAtBottom()) showFrom = lastAvailableMessage(); if (loadedAtBottom()) showFrom = lastAvailableMessage();
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead()); inboxReadBefore = std::max(inboxReadBefore, msgIdForRead());
} else if (!newUnreadCount) { } else if (!newUnreadCount) {
showFrom = nullptr; showFrom = nullptr;
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead() + 1); inboxReadBefore = std::max(inboxReadBefore, msgIdForRead() + 1);
} else { } else {
if (!showFrom && !unreadBar && loadedAtBottom()) updateShowFrom(); if (!showFrom && !unreadBar && loadedAtBottom()) updateShowFrom();
} }
@ -2069,7 +2069,7 @@ MsgId History::maxMsgId() const {
MsgId History::msgIdForRead() const { MsgId History::msgIdForRead() const {
MsgId result = (lastMsg && lastMsg->id > 0) ? lastMsg->id : 0; MsgId result = (lastMsg && lastMsg->id > 0) ? lastMsg->id : 0;
if (loadedAtBottom()) result = qMax(result, maxMsgId()); if (loadedAtBottom()) result = std::max(result, maxMsgId());
return result; return result;
} }

View File

@ -370,7 +370,7 @@ void FilterBox::prepare() {
_inner->resizeToWidth(st::boxWideWidth); _inner->resizeToWidth(st::boxWideWidth);
refreshButtons(); refreshButtons();
setDimensions(st::boxWideWidth, qMin(_inner->height(), st::boxMaxListHeight)); setDimensions(st::boxWideWidth, std::min(_inner->height(), st::boxMaxListHeight));
} }
void FilterBox::refreshButtons() { void FilterBox::refreshButtons() {

View File

@ -140,10 +140,10 @@ void InnerWidget::enumerateUserpics(Method method) {
} }
// Attach userpic to the bottom of the visible area with the same margin as the last message. // Attach userpic to the bottom of the visible area with the same margin as the last message.
auto userpicMinBottomSkip = st::historyPaddingBottom + st::msgMargin.bottom(); auto userpicMinBottomSkip = st::historyPaddingBottom + st::msgMargin.bottom();
auto userpicBottom = qMin(itembottom - message->marginBottom(), _visibleBottom - userpicMinBottomSkip); auto userpicBottom = std::min(itembottom - message->marginBottom(), _visibleBottom - userpicMinBottomSkip);
// Do not let the userpic go above the attached messages pack top line. // Do not let the userpic go above the attached messages pack top line.
userpicBottom = qMax(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); userpicBottom = std::max(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize);
// Call the template callback function that was passed // Call the template callback function that was passed
// and return if it finished everything it needed. // and return if it finished everything it needed.
@ -181,11 +181,11 @@ void InnerWidget::enumerateDates(Method method) {
lowestInOneDayItemBottom = itembottom - item->marginBottom(); lowestInOneDayItemBottom = itembottom - item->marginBottom();
} }
// Attach date to the top of the visible area with the same margin as it has in service message. // Attach date to the top of the visible area with the same margin as it has in service message.
auto dateTop = qMax(itemtop, _visibleTop) + st::msgServiceMargin.top(); auto dateTop = std::max(itemtop, _visibleTop) + st::msgServiceMargin.top();
// Do not let the date go below the single-day messages pack bottom line. // Do not let the date go below the single-day messages pack bottom line.
auto dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top(); auto dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top();
dateTop = qMin(dateTop, lowestInOneDayItemBottom - dateHeight); dateTop = std::min(dateTop, lowestInOneDayItemBottom - dateHeight);
// Call the template callback function that was passed // Call the template callback function that was passed
// and return if it finished everything it needed. // and return if it finished everything it needed.
@ -1333,7 +1333,7 @@ void InnerWidget::updateSelected() {
if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) { if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) {
++second; ++second;
} }
auto selection = TextSelection { qMin(second, _mouseTextSymbol), qMax(second, _mouseTextSymbol) }; auto selection = TextSelection { std::min(second, _mouseTextSymbol), std::max(second, _mouseTextSymbol) };
if (_mouseSelectType != TextSelectType::Letters) { if (_mouseSelectType != TextSelectType::Letters) {
selection = _mouseActionItem->adjustSelection(selection, _mouseSelectType); selection = _mouseActionItem->adjustSelection(selection, _mouseSelectType);
} }

View File

@ -391,10 +391,10 @@ void Widget::paintEvent(QPaintEvent *e) {
auto bottom = clip.top() + clip.height(); auto bottom = clip.top() + clip.height();
auto w = pix.width() / cRetinaFactor(); auto w = pix.width() / cRetinaFactor();
auto h = pix.height() / cRetinaFactor(); auto h = pix.height() / cRetinaFactor();
auto sx = qFloor(left / w); auto sx = std::floor(left / w);
auto sy = qFloor((top - fromy) / h); auto sy = std::floor((top - fromy) / h);
auto cx = qCeil(right / w); auto cx = std::ceil(right / w);
auto cy = qCeil((bottom - fromy) / h); auto cy = std::ceil((bottom - fromy) / h);
for (auto i = sx; i < cx; ++i) { for (auto i = sx; i < cx; ++i) {
for (auto j = sy; j < cy; ++j) { for (auto j = sy; j < cy; ++j) {
p.drawPixmap(QPointF(i * w, fromy + j * h), pix); p.drawPixmap(QPointF(i * w, fromy + j * h), pix);

View File

@ -273,10 +273,10 @@ void HistoryInner::enumerateUserpics(Method method) {
} }
// Attach userpic to the bottom of the visible area with the same margin as the last message. // Attach userpic to the bottom of the visible area with the same margin as the last message.
auto userpicMinBottomSkip = st::historyPaddingBottom + st::msgMargin.bottom(); auto userpicMinBottomSkip = st::historyPaddingBottom + st::msgMargin.bottom();
auto userpicBottom = qMin(itembottom - message->marginBottom(), _visibleAreaBottom - userpicMinBottomSkip); auto userpicBottom = std::min(itembottom - message->marginBottom(), _visibleAreaBottom - userpicMinBottomSkip);
// Do not let the userpic go above the attached messages pack top line. // Do not let the userpic go above the attached messages pack top line.
userpicBottom = qMax(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); userpicBottom = std::max(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize);
// Call the template callback function that was passed // Call the template callback function that was passed
// and return if it finished everything it needed. // and return if it finished everything it needed.
@ -328,11 +328,11 @@ void HistoryInner::enumerateDates(Method method) {
lowestInOneDayItemBottom = itembottom - item->marginBottom(); lowestInOneDayItemBottom = itembottom - item->marginBottom();
} }
// Attach date to the top of the visible area with the same margin as it has in service message. // Attach date to the top of the visible area with the same margin as it has in service message.
int dateTop = qMax(itemtop, _visibleAreaTop) + st::msgServiceMargin.top(); int dateTop = std::max(itemtop, _visibleAreaTop) + st::msgServiceMargin.top();
// Do not let the date go below the single-day messages pack bottom line. // Do not let the date go below the single-day messages pack bottom line.
int dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top(); int dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top();
dateTop = qMin(dateTop, lowestInOneDayItemBottom - dateHeight); dateTop = std::min(dateTop, lowestInOneDayItemBottom - dateHeight);
// Call the template callback function that was passed // Call the template callback function that was passed
// and return if it finished everything it needed. // and return if it finished everything it needed.
@ -649,8 +649,8 @@ void HistoryInner::touchResetSpeed() {
void HistoryInner::touchDeaccelerate(qint32 elapsed) { void HistoryInner::touchDeaccelerate(qint32 elapsed) {
qint32 x = _touchSpeed.x(); qint32 x = _touchSpeed.x();
qint32 y = _touchSpeed.y(); qint32 y = _touchSpeed.y();
_touchSpeed.setX((x == 0) ? x : (x > 0) ? qMax(0, x - elapsed) : qMin(0, x + elapsed)); _touchSpeed.setX((x == 0) ? x : (x > 0) ? std::max(0, x - elapsed) : std::min(0, x + elapsed));
_touchSpeed.setY((y == 0) ? y : (y > 0) ? qMax(0, y - elapsed) : qMin(0, y + elapsed)); _touchSpeed.setY((y == 0) ? y : (y > 0) ? std::max(0, y - elapsed) : std::min(0, y + elapsed));
} }
void HistoryInner::touchEvent(QTouchEvent *e) { void HistoryInner::touchEvent(QTouchEvent *e) {
@ -1581,7 +1581,7 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) {
void HistoryInner::recountHeight() { void HistoryInner::recountHeight() {
int visibleHeight = _scroll->height(); int visibleHeight = _scroll->height();
int oldHistoryPaddingTop = qMax(visibleHeight - historyHeight() - st::historyPaddingBottom, 0); int oldHistoryPaddingTop = std::max(visibleHeight - historyHeight() - st::historyPaddingBottom, 0);
if (_botAbout && !_botAbout->info->text.isEmpty()) { if (_botAbout && !_botAbout->info->text.isEmpty()) {
accumulate_max(oldHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height); accumulate_max(oldHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height);
} }
@ -1612,7 +1612,7 @@ void HistoryInner::recountHeight() {
qint32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); qint32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right(); tw -= st::msgPadding.left() + st::msgPadding.right();
qint32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description))); qint32 mw = std::max(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description)));
if (tw > mw) tw = mw; if (tw > mw) tw = mw;
_botAbout->width = tw; _botAbout->width = tw;
@ -1621,10 +1621,10 @@ void HistoryInner::recountHeight() {
qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
qint32 descMaxWidth = _scroll->width(); qint32 descMaxWidth = _scroll->width();
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
descMaxWidth = qMin(descMaxWidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); descMaxWidth = std::min(descMaxWidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
qint32 descAtY = qMin(_historyPaddingTop - descH, qMax(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); qint32 descAtY = std::min(_historyPaddingTop - descH, std::max(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top();
_botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom()); _botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom());
} else if (_botAbout) { } else if (_botAbout) {
@ -1632,7 +1632,7 @@ void HistoryInner::recountHeight() {
_botAbout->rect = QRect(); _botAbout->rect = QRect();
} }
int newHistoryPaddingTop = qMax(visibleHeight - historyHeight() - st::historyPaddingBottom, 0); int newHistoryPaddingTop = std::max(visibleHeight - historyHeight() - st::historyPaddingBottom, 0);
if (_botAbout && !_botAbout->info->text.isEmpty()) { if (_botAbout && !_botAbout->info->text.isEmpty()) {
accumulate_max(newHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height); accumulate_max(newHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height);
} }
@ -1656,7 +1656,7 @@ void HistoryInner::updateBotInfo(bool recount) {
qint32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); qint32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right(); tw -= st::msgPadding.left() + st::msgPadding.right();
qint32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description))); qint32 mw = std::max(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description)));
if (tw > mw) tw = mw; if (tw > mw) tw = mw;
_botAbout->width = tw; _botAbout->width = tw;
@ -1674,7 +1674,7 @@ void HistoryInner::updateBotInfo(bool recount) {
if (_botAbout->height > 0) { if (_botAbout->height > 0) {
qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
qint32 descAtX = (_scroll->width() - _botAbout->width) / 2 - st::msgPadding.left(); qint32 descAtX = (_scroll->width() - _botAbout->width) / 2 - st::msgPadding.left();
qint32 descAtY = qMin(_historyPaddingTop - descH, (_scroll->height() - descH) / 2) + st::msgMargin.top(); qint32 descAtY = std::min(_historyPaddingTop - descH, (_scroll->height() - descH) / 2) + st::msgMargin.top();
_botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom()); _botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom());
} else { } else {
@ -1796,7 +1796,7 @@ void HistoryInner::repaintScrollDateCallback() {
void HistoryInner::updateSize() { void HistoryInner::updateSize() {
int visibleHeight = _scroll->height(); int visibleHeight = _scroll->height();
int newHistoryPaddingTop = qMax(visibleHeight - historyHeight() - st::historyPaddingBottom, 0); int newHistoryPaddingTop = std::max(visibleHeight - historyHeight() - st::historyPaddingBottom, 0);
if (_botAbout && !_botAbout->info->text.isEmpty()) { if (_botAbout && !_botAbout->info->text.isEmpty()) {
accumulate_max(newHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height); accumulate_max(newHistoryPaddingTop, st::msgMargin.top() + st::msgMargin.bottom() + st::msgPadding.top() + st::msgPadding.bottom() + st::msgNameFont->height + st::botDescSkip + _botAbout->height);
} }
@ -1805,10 +1805,10 @@ void HistoryInner::updateSize() {
qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); qint32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
qint32 descMaxWidth = _scroll->width(); qint32 descMaxWidth = _scroll->width();
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
descMaxWidth = qMin(descMaxWidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); descMaxWidth = std::min(descMaxWidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
qint32 descAtY = qMin(newHistoryPaddingTop - descH, qMax(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); qint32 descAtY = std::min(newHistoryPaddingTop - descH, std::max(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top();
_botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom()); _botAbout->rect = QRect(descAtX, descAtY, _botAbout->width + st::msgPadding.left() + st::msgPadding.right(), descH - st::msgMargin.top() - st::msgMargin.bottom());
} }
@ -2082,7 +2082,7 @@ void HistoryInner::onUpdateSelected() {
auto dateLeft = st::msgServiceMargin.left(); auto dateLeft = st::msgServiceMargin.left();
auto maxwidth = item->history()->width; auto maxwidth = item->history()->width;
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
maxwidth = qMin(maxwidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); maxwidth = std::min(maxwidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
@ -2159,7 +2159,7 @@ void HistoryInner::onUpdateSelected() {
if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) { if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) {
++second; ++second;
} }
auto selState = TextSelection { qMin(second, _mouseTextSymbol), qMax(second, _mouseTextSymbol) }; auto selState = TextSelection { std::min(second, _mouseTextSymbol), std::max(second, _mouseTextSymbol) };
if (_mouseSelectType != TextSelectType::Letters) { if (_mouseSelectType != TextSelectType::Letters) {
selState = _mouseActionItem->adjustSelection(selState, _mouseSelectType); selState = _mouseActionItem->adjustSelection(selState, _mouseSelectType);
} }

View File

@ -146,7 +146,7 @@ void ReplyKeyboard::resize(int width, int height) {
int widthOfText = 0; int widthOfText = 0;
int maxMinButtonWidth = 0; int maxMinButtonWidth = 0;
for_const (auto &button, row) { for_const (auto &button, row) {
widthOfText += qMax(button.text.maxWidth(), 1); widthOfText += std::max(button.text.maxWidth(), 1);
int minButtonWidth = _st->minButtonWidth(button.type); int minButtonWidth = _st->minButtonWidth(button.type);
widthForText -= minButtonWidth; widthForText -= minButtonWidth;
accumulate_max(maxMinButtonWidth, minButtonWidth); accumulate_max(maxMinButtonWidth, minButtonWidth);
@ -156,7 +156,7 @@ void ReplyKeyboard::resize(int width, int height) {
double x = 0; double x = 0;
for (Button &button : row) { for (Button &button : row) {
int buttonw = qMax(button.text.maxWidth(), 1); int buttonw = std::max(button.text.maxWidth(), 1);
double textw = buttonw, minw = _st->minButtonWidth(button.type); double textw = buttonw, minw = _st->minButtonWidth(button.type);
double w = textw; double w = textw;
if (exact) { if (exact) {
@ -172,7 +172,7 @@ void ReplyKeyboard::resize(int width, int height) {
int rectx = static_cast<int>(std::floor(x)); int rectx = static_cast<int>(std::floor(x));
int rectw = static_cast<int>(std::floor(x + w)) - rectx; int rectw = static_cast<int>(std::floor(x + w)) - rectx;
button.rect = QRect(rectx, qRound(y), rectw, qRound(buttonHeight - _st->buttonSkip())); button.rect = QRect(rectx, std::round(y), rectw, std::round(buttonHeight - _st->buttonSkip()));
if (rtl()) button.rect.setX(_width - button.rect.x() - button.rect.width()); if (rtl()) button.rect.setX(_width - button.rect.x() - button.rect.width());
x += w + _st->buttonSkip(); x += w + _st->buttonSkip();
@ -187,7 +187,7 @@ bool ReplyKeyboard::isEnoughSpace(int width, const style::BotKeyboardButton &st)
int s = row.size(); int s = row.size();
int widthLeft = width - ((s - 1) * st.margin + s * 2 * st.padding); int widthLeft = width - ((s - 1) * st.margin + s * 2 * st.padding);
for_const (auto &button, row) { for_const (auto &button, row) {
widthLeft -= qMax(button.text.maxWidth(), 1); widthLeft -= std::max(button.text.maxWidth(), 1);
if (widthLeft < 0) { if (widthLeft < 0) {
if (row.size() > 3) { if (row.size() > 3) {
return false; return false;
@ -213,7 +213,7 @@ int ReplyKeyboard::naturalWidth() const {
} }
auto rowMaxButtonWidth = 0; auto rowMaxButtonWidth = 0;
for_const (auto &button, row) { for_const (auto &button, row) {
accumulate_max(rowMaxButtonWidth, qMax(button.text.maxWidth(), 1) + maxMinButtonWidth); accumulate_max(rowMaxButtonWidth, std::max(button.text.maxWidth(), 1) + maxMinButtonWidth);
} }
auto rowSize = row.size(); auto rowSize = row.size();
@ -525,7 +525,7 @@ void HistoryMessageUnreadBar::paint(Painter &p, int y, int w) const {
int left = st::msgServiceMargin.left(); int left = st::msgServiceMargin.left();
int maxwidth = w; int maxwidth = w;
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
maxwidth = qMin(maxwidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); maxwidth = std::min(maxwidth, qint32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
w = maxwidth; w = maxwidth;

View File

@ -103,22 +103,22 @@ namespace {
qint32 documentMaxStatusWidth(DocumentData *document) { qint32 documentMaxStatusWidth(DocumentData *document) {
qint32 result = st::normalFont->width(formatDownloadText(document->size, document->size)); qint32 result = st::normalFont->width(formatDownloadText(document->size, document->size));
if (auto song = document->song()) { if (auto song = document->song()) {
result = qMax(result, st::normalFont->width(formatPlayedText(song->duration, song->duration))); result = std::max(result, st::normalFont->width(formatPlayedText(song->duration, song->duration)));
result = qMax(result, st::normalFont->width(formatDurationAndSizeText(song->duration, document->size))); result = std::max(result, st::normalFont->width(formatDurationAndSizeText(song->duration, document->size)));
} else if (auto voice = document->voice()) { } else if (auto voice = document->voice()) {
result = qMax(result, st::normalFont->width(formatPlayedText(voice->duration, voice->duration))); result = std::max(result, st::normalFont->width(formatPlayedText(voice->duration, voice->duration)));
result = qMax(result, st::normalFont->width(formatDurationAndSizeText(voice->duration, document->size))); result = std::max(result, st::normalFont->width(formatDurationAndSizeText(voice->duration, document->size)));
} else if (document->isVideo()) { } else if (document->isVideo()) {
result = qMax(result, st::normalFont->width(formatDurationAndSizeText(document->duration(), document->size))); result = std::max(result, st::normalFont->width(formatDurationAndSizeText(document->duration(), document->size)));
} else { } else {
result = qMax(result, st::normalFont->width(formatSizeText(document->size))); result = std::max(result, st::normalFont->width(formatSizeText(document->size)));
} }
return result; return result;
} }
qint32 gifMaxStatusWidth(DocumentData *document) { qint32 gifMaxStatusWidth(DocumentData *document) {
qint32 result = st::normalFont->width(formatDownloadText(document->size, document->size)); qint32 result = st::normalFont->width(formatDownloadText(document->size, document->size));
result = qMax(result, st::normalFont->width(formatGifAndSizeText(document->size))); result = std::max(result, st::normalFont->width(formatGifAndSizeText(document->size)));
return result; return result;
} }
@ -285,10 +285,10 @@ void HistoryPhoto::initDimensions() {
if (_parent->toHistoryMessage()) { if (_parent->toHistoryMessage()) {
bool bubble = _parent->hasBubble(); bool bubble = _parent->hasBubble();
qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
qint32 maxActualWidth = qMax(tw, minWidth); qint32 maxActualWidth = std::max(tw, minWidth);
_maxw = qMax(maxActualWidth, th); _maxw = std::max(maxActualWidth, th);
_minh = qMax(th, qint32(st::minPhotoSize)); _minh = std::max(th, qint32(st::minPhotoSize));
if (bubble) { if (bubble) {
maxActualWidth += st::mediaPadding.left() + st::mediaPadding.right(); maxActualWidth += st::mediaPadding.left() + st::mediaPadding.right();
_maxw += st::mediaPadding.left() + st::mediaPadding.right(); _maxw += st::mediaPadding.left() + st::mediaPadding.right();
@ -319,7 +319,7 @@ int HistoryPhoto::resizeGetHeight(int width) {
th = st::maxMediaSize; th = st::maxMediaSize;
} }
_pixw = qMin(width, _maxw); _pixw = std::min(width, _maxw);
if (bubble) { if (bubble) {
_pixw -= st::mediaPadding.left() + st::mediaPadding.right(); _pixw -= st::mediaPadding.left() + st::mediaPadding.right();
} }
@ -336,9 +336,9 @@ int HistoryPhoto::resizeGetHeight(int width) {
if (_pixw < 1) _pixw = 1; if (_pixw < 1) _pixw = 1;
if (_pixh < 1) _pixh = 1; if (_pixh < 1) _pixh = 1;
int minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); int minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
_width = qMax(_pixw, qint16(minWidth)); _width = std::max(_pixw, qint16(minWidth));
_height = qMax(_pixh, qint16(st::minPhotoSize)); _height = std::max(_pixh, qint16(st::minPhotoSize));
if (bubble) { if (bubble) {
_width += st::mediaPadding.left() + st::mediaPadding.right(); _width += st::mediaPadding.left() + st::mediaPadding.right();
_height += st::mediaPadding.top() + st::mediaPadding.bottom(); _height += st::mediaPadding.top() + st::mediaPadding.bottom();
@ -693,18 +693,18 @@ void HistoryVideo::initDimensions() {
tw = th = 1; tw = th = 1;
} }
if (tw * st::msgVideoSize.height() > th * st::msgVideoSize.width()) { if (tw * st::msgVideoSize.height() > th * st::msgVideoSize.width()) {
th = qRound((st::msgVideoSize.width() / double(tw)) * th); th = std::round((st::msgVideoSize.width() / double(tw)) * th);
tw = st::msgVideoSize.width(); tw = st::msgVideoSize.width();
} else { } else {
tw = qRound((st::msgVideoSize.height() / double(th)) * tw); tw = std::round((st::msgVideoSize.height() / double(th)) * tw);
th = st::msgVideoSize.height(); th = st::msgVideoSize.height();
} }
_thumbw = qMax(tw, 1); _thumbw = std::max(tw, 1);
qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
minWidth = qMax(minWidth, documentMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); minWidth = std::max(minWidth, documentMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x()));
_maxw = qMax(_thumbw, qint32(minWidth)); _maxw = std::max(_thumbw, qint32(minWidth));
_minh = qMax(th, qint32(st::minPhotoSize)); _minh = std::max(th, qint32(st::minPhotoSize));
if (bubble) { if (bubble) {
_maxw += st::mediaPadding.left() + st::mediaPadding.right(); _maxw += st::mediaPadding.left() + st::mediaPadding.right();
_minh += st::mediaPadding.top() + st::mediaPadding.bottom(); _minh += st::mediaPadding.top() + st::mediaPadding.bottom();
@ -726,10 +726,10 @@ int HistoryVideo::resizeGetHeight(int width) {
tw = th = 1; tw = th = 1;
} }
if (tw * st::msgVideoSize.height() > th * st::msgVideoSize.width()) { if (tw * st::msgVideoSize.height() > th * st::msgVideoSize.width()) {
th = qRound((st::msgVideoSize.width() / double(tw)) * th); th = std::round((st::msgVideoSize.width() / double(tw)) * th);
tw = st::msgVideoSize.width(); tw = st::msgVideoSize.width();
} else { } else {
tw = qRound((st::msgVideoSize.height() / double(th)) * tw); tw = std::round((st::msgVideoSize.height() / double(th)) * tw);
th = st::msgVideoSize.height(); th = st::msgVideoSize.height();
} }
@ -737,15 +737,15 @@ int HistoryVideo::resizeGetHeight(int width) {
width -= st::mediaPadding.left() + st::mediaPadding.right(); width -= st::mediaPadding.left() + st::mediaPadding.right();
} }
if (width < tw) { if (width < tw) {
th = qRound((width / double(tw)) * th); th = std::round((width / double(tw)) * th);
tw = width; tw = width;
} }
_thumbw = qMax(tw, 1); _thumbw = std::max(tw, 1);
int minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); int minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
minWidth = qMax(minWidth, documentMaxStatusWidth(_data) + 2 * int(st::msgDateImgDelta + st::msgDateImgPadding.x())); minWidth = std::max(minWidth, documentMaxStatusWidth(_data) + 2 * int(st::msgDateImgDelta + st::msgDateImgPadding.x()));
_width = qMax(_thumbw, int(minWidth)); _width = std::max(_thumbw, int(minWidth));
_height = qMax(th, int(st::minPhotoSize)); _height = std::max(th, int(st::minPhotoSize));
if (bubble) { if (bubble) {
_width += st::mediaPadding.left() + st::mediaPadding.right(); _width += st::mediaPadding.left() + st::mediaPadding.right();
_height += st::mediaPadding.top() + st::mediaPadding.bottom(); _height += st::mediaPadding.top() + st::mediaPadding.bottom();
@ -1142,17 +1142,17 @@ void HistoryDocument::initDimensions() {
if (thumbed) { if (thumbed) {
tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right();
tright = st::msgFileThumbPadding.left(); tright = st::msgFileThumbPadding.left();
_maxw = qMax(_maxw, tleft + documentMaxStatusWidth(_data) + tright); _maxw = std::max(_maxw, tleft + documentMaxStatusWidth(_data) + tright);
} else { } else {
tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right();
tright = st::msgFileThumbPadding.left(); tright = st::msgFileThumbPadding.left();
auto unread = _data->voice() ? (st::mediaUnreadSkip + st::mediaUnreadSize) : 0; auto unread = _data->voice() ? (st::mediaUnreadSkip + st::mediaUnreadSize) : 0;
_maxw = qMax(_maxw, tleft + documentMaxStatusWidth(_data) + unread + _parent->skipBlockWidth() + st::msgPadding.right()); _maxw = std::max(_maxw, tleft + documentMaxStatusWidth(_data) + unread + _parent->skipBlockWidth() + st::msgPadding.right());
} }
if (auto named = Get<HistoryDocumentNamed>()) { if (auto named = Get<HistoryDocumentNamed>()) {
_maxw = qMax(tleft + named->_namew + tright, _maxw); _maxw = std::max(tleft + named->_namew + tright, _maxw);
_maxw = qMin(_maxw, int(st::msgMaxWidth)); _maxw = std::min(_maxw, int(st::msgMaxWidth));
} }
if (thumbed) { if (thumbed) {
@ -1184,7 +1184,7 @@ int HistoryDocument::resizeGetHeight(int width) {
return HistoryFileMedia::resizeGetHeight(width); return HistoryFileMedia::resizeGetHeight(width);
} }
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
if (Get<HistoryDocumentThumbed>()) { if (Get<HistoryDocumentThumbed>()) {
_height = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); _height = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
} else { } else {
@ -1367,7 +1367,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
return 0.; return 0.;
})(); })();
if (voice->seeking()) { if (voice->seeking()) {
voiceStatusOverride = formatPlayedText(qRound(progress * voice->_lastDurationMs) / 1000, voice->_lastDurationMs / 1000); voiceStatusOverride = formatPlayedText(std::round(progress * voice->_lastDurationMs) / 1000, voice->_lastDurationMs / 1000);
} }
// rescale waveform by going in waveform.size * bar_count 1D grid // rescale waveform by going in waveform.size * bar_count 1D grid
@ -1375,11 +1375,11 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
auto inactive = outbg ? (selected ? st::msgWaveformOutInactiveSelected : st::msgWaveformOutInactive) : (selected ? st::msgWaveformInInactiveSelected : st::msgWaveformInInactive); auto inactive = outbg ? (selected ? st::msgWaveformOutInactiveSelected : st::msgWaveformOutInactive) : (selected ? st::msgWaveformInInactiveSelected : st::msgWaveformInInactive);
auto wf_size = wf ? wf->size() : Media::Player::kWaveformSamplesCount; auto wf_size = wf ? wf->size() : Media::Player::kWaveformSamplesCount;
auto availw = namewidth + st::msgWaveformSkip; auto availw = namewidth + st::msgWaveformSkip;
auto activew = qRound(availw * progress); auto activew = std::round(availw * progress);
if (!outbg && !voice->_playback && _parent->isMediaUnread()) { if (!outbg && !voice->_playback && _parent->isMediaUnread()) {
activew = availw; activew = availw;
} }
auto bar_count = qMin(availw / (st::msgWaveformBar + st::msgWaveformSkip), wf_size); auto bar_count = std::min(availw / (st::msgWaveformBar + st::msgWaveformSkip), wf_size);
auto max_value = 0; auto max_value = 0;
auto max_delta = st::msgWaveformMax - st::msgWaveformMin; auto max_delta = st::msgWaveformMax - st::msgWaveformMin;
auto bottom = st::msgFilePadding.top() - topMinus + st::msgWaveformMax; auto bottom = st::msgFilePadding.top() - topMinus + st::msgWaveformMax;
@ -1718,7 +1718,7 @@ void HistoryDocument::step_voiceProgress(double ms, bool timer) {
voice->_playback->_a_progress.stop(); voice->_playback->_a_progress.stop();
voice->_playback->a_progress.finish(); voice->_playback->a_progress.finish();
} else { } else {
voice->_playback->a_progress.update(qMin(dt, 1.), anim::linear); voice->_playback->a_progress.update(std::min(dt, 1.), anim::linear);
} }
if (timer) Ui::repaintHistoryItem(_parent); if (timer) Ui::repaintHistoryItem(_parent);
} }
@ -1734,7 +1734,7 @@ void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool
auto state = Media::Player::mixer()->currentState(type); auto state = Media::Player::mixer()->currentState(type);
if (state.id == AudioMsgId(_data, _parent->fullId()) && state.length) { if (state.id == AudioMsgId(_data, _parent->fullId()) && state.length) {
auto currentProgress = voice->seekingCurrent(); auto currentProgress = voice->seekingCurrent();
auto currentPosition = qRound(currentProgress * state.length); auto currentPosition = std::round(currentProgress * state.length);
Media::Player::mixer()->seek(type, currentPosition); Media::Player::mixer()->seek(type, currentPosition);
voice->ensurePlayback(this); voice->ensurePlayback(this);
@ -1856,11 +1856,11 @@ void HistoryGif::initDimensions() {
} }
_thumbw = tw; _thumbw = tw;
_thumbh = th; _thumbh = th;
_maxw = qMax(tw, qint32(st::minPhotoSize)); _maxw = std::max(tw, qint32(st::minPhotoSize));
_minh = qMax(th, qint32(st::minPhotoSize)); _minh = std::max(th, qint32(st::minPhotoSize));
_maxw = qMax(_maxw, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); _maxw = std::max(_maxw, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x()));
if (!_gif || !_gif->ready()) { if (!_gif || !_gif->ready()) {
_maxw = qMax(_maxw, gifMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); _maxw = std::max(_maxw, gifMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x()));
} }
if (bubble) { if (bubble) {
_maxw += st::mediaPadding.left() + st::mediaPadding.right(); _maxw += st::mediaPadding.left() + st::mediaPadding.right();
@ -1913,15 +1913,15 @@ int HistoryGif::resizeGetHeight(int width) {
width -= st::mediaPadding.left() + st::mediaPadding.right(); width -= st::mediaPadding.left() + st::mediaPadding.right();
} }
if (width < tw) { if (width < tw) {
th = qRound((width / double(tw)) * th); th = std::round((width / double(tw)) * th);
tw = width; tw = width;
} }
_thumbw = tw; _thumbw = tw;
_thumbh = th; _thumbh = th;
_width = qMax(tw, qint32(st::minPhotoSize)); _width = std::max(tw, qint32(st::minPhotoSize));
_height = qMax(th, qint32(st::minPhotoSize)); _height = std::max(th, qint32(st::minPhotoSize));
_width = qMax(_width, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); _width = std::max(_width, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x()));
if (_gif && _gif->ready()) { if (_gif && _gif->ready()) {
if (!_gif->started()) { if (!_gif->started()) {
auto isRound = _data->isRoundVideo(); auto isRound = _data->isRoundVideo();
@ -1932,7 +1932,7 @@ int HistoryGif::resizeGetHeight(int width) {
_gif->start(_thumbw, _thumbh, _width, _height, roundRadius, roundCorners); _gif->start(_thumbw, _thumbh, _width, _height, roundRadius, roundCorners);
} }
} else { } else {
_width = qMax(_width, gifMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); _width = std::max(_width, gifMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x()));
} }
if (bubble) { if (bubble) {
_width += st::mediaPadding.left() + st::mediaPadding.right(); _width += st::mediaPadding.left() + st::mediaPadding.right();
@ -2062,7 +2062,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
p.setOpacity(st::historyVideoMessageProgressOpacity); p.setOpacity(st::historyVideoMessageProgressOpacity);
auto from = QuarterArcLength; auto from = QuarterArcLength;
auto len = -qRound(FullArcLength * value); auto len = -std::round(FullArcLength * value);
auto stepInside = st::radialLine / 2; auto stepInside = st::radialLine / 2;
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -2169,7 +2169,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
auto innerw = rectw - (st::msgReplyPadding.left() + st::msgReplyPadding.right()); auto innerw = rectw - (st::msgReplyPadding.left() + st::msgReplyPadding.right());
auto recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom(); auto recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom();
auto forwardedHeightReal = forwarded ? forwarded->_text.countHeight(innerw) : 0; auto forwardedHeightReal = forwarded ? forwarded->_text.countHeight(innerw) : 0;
auto forwardedHeight = qMin(forwardedHeightReal, kMaxGifForwardedBarLines * st::msgServiceNameFont->height); auto forwardedHeight = std::min(forwardedHeightReal, kMaxGifForwardedBarLines * st::msgServiceNameFont->height);
if (forwarded) { if (forwarded) {
recth += forwardedHeight; recth += forwardedHeight;
} else if (via) { } else if (via) {
@ -2290,7 +2290,7 @@ HistoryTextState HistoryGif::getState(QPoint point, HistoryStateRequest request)
auto innerw = rectw - (st::msgReplyPadding.left() + st::msgReplyPadding.right()); auto innerw = rectw - (st::msgReplyPadding.left() + st::msgReplyPadding.right());
auto recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom(); auto recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom();
auto forwardedHeightReal = forwarded ? forwarded->_text.countHeight(innerw) : 0; auto forwardedHeightReal = forwarded ? forwarded->_text.countHeight(innerw) : 0;
auto forwardedHeight = qMin(forwardedHeightReal, kMaxGifForwardedBarLines * st::msgServiceNameFont->height); auto forwardedHeight = std::min(forwardedHeightReal, kMaxGifForwardedBarLines * st::msgServiceNameFont->height);
if (forwarded) { if (forwarded) {
recth += forwardedHeight; recth += forwardedHeight;
} else if (via) { } else if (via) {
@ -2660,8 +2660,8 @@ void HistorySticker::initDimensions() {
} }
if (_pixw < 1) _pixw = 1; if (_pixw < 1) _pixw = 1;
if (_pixh < 1) _pixh = 1; if (_pixh < 1) _pixh = 1;
_maxw = qMax(_pixw, qint16(st::minPhotoSize)); _maxw = std::max(_pixw, qint16(st::minPhotoSize));
_minh = qMax(_pixh, qint16(st::minPhotoSize)); _minh = std::max(_pixh, qint16(st::minPhotoSize));
if (_parent->getMedia() == this) { if (_parent->getMedia() == this) {
_maxw += additionalWidth(); _maxw += additionalWidth();
} }
@ -2670,7 +2670,7 @@ void HistorySticker::initDimensions() {
} }
int HistorySticker::resizeGetHeight(int width) { // return new height int HistorySticker::resizeGetHeight(int width) { // return new height
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
if (_parent->getMedia() == this) { if (_parent->getMedia() == this) {
auto via = _parent->Get<HistoryMessageVia>(); auto via = _parent->Get<HistoryMessageVia>();
auto reply = _parent->Get<HistoryMessageReply>(); auto reply = _parent->Get<HistoryMessageReply>();
@ -2954,15 +2954,15 @@ void HistoryContact::initDimensions() {
if (_userId) { if (_userId) {
tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right();
tright = st::msgFileThumbPadding.left(); tright = st::msgFileThumbPadding.left();
_maxw = qMax(_maxw, tleft + _phonew + tright); _maxw = std::max(_maxw, tleft + _phonew + tright);
} else { } else {
tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right();
tright = st::msgFileThumbPadding.left(); tright = st::msgFileThumbPadding.left();
_maxw = qMax(_maxw, tleft + _phonew + _parent->skipBlockWidth() + st::msgPadding.right()); _maxw = std::max(_maxw, tleft + _phonew + _parent->skipBlockWidth() + st::msgPadding.right());
} }
_maxw = qMax(tleft + _name.maxWidth() + tright, _maxw); _maxw = std::max(tleft + _name.maxWidth() + tright, _maxw);
_maxw = qMin(_maxw, int(st::msgMaxWidth)); _maxw = std::min(_maxw, int(st::msgMaxWidth));
if (_userId) { if (_userId) {
_minh = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); _minh = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
@ -3225,15 +3225,15 @@ QString siteNameFromUrl(const QString &url) {
qint32 articleThumbWidth(PhotoData *thumb, qint32 height) { qint32 articleThumbWidth(PhotoData *thumb, qint32 height) {
qint32 w = thumb->medium->width(), h = thumb->medium->height(); qint32 w = thumb->medium->width(), h = thumb->medium->height();
return qMax(qMin(height * w / h, height), 1); return std::max(std::min(height * w / h, height), 1);
} }
qint32 articleThumbHeight(PhotoData *thumb, qint32 width) { qint32 articleThumbHeight(PhotoData *thumb, qint32 width) {
return qMax(thumb->medium->height() * width / thumb->medium->width(), 1); return std::max(thumb->medium->height() * width / thumb->medium->width(), 1);
} }
int unitedLineHeight() { int unitedLineHeight() {
return qMax(st::webPageTitleFont->height, st::webPageDescriptionFont->height); return std::max(st::webPageTitleFont->height, st::webPageDescriptionFont->height);
} }
} // namespace } // namespace
@ -3347,11 +3347,11 @@ void HistoryWebPage::initDimensions() {
auto siteNameHeight = _data->siteName.isEmpty() ? 0 : lineHeight; auto siteNameHeight = _data->siteName.isEmpty() ? 0 : lineHeight;
auto titleMinHeight = _title.isEmpty() ? 0 : lineHeight; auto titleMinHeight = _title.isEmpty() ? 0 : lineHeight;
auto descMaxLines = isLogEntryOriginal() ? kMaxOriginalEntryLines : (3 + (siteNameHeight ? 0 : 1) + (titleMinHeight ? 0 : 1)); auto descMaxLines = isLogEntryOriginal() ? kMaxOriginalEntryLines : (3 + (siteNameHeight ? 0 : 1) + (titleMinHeight ? 0 : 1));
auto descriptionMinHeight = _description.isEmpty() ? 0 : qMin(_description.minHeight(), descMaxLines * lineHeight); auto descriptionMinHeight = _description.isEmpty() ? 0 : std::min(_description.minHeight(), descMaxLines * lineHeight);
auto articleMinHeight = siteNameHeight + titleMinHeight + descriptionMinHeight; auto articleMinHeight = siteNameHeight + titleMinHeight + descriptionMinHeight;
auto articlePhotoMaxWidth = 0; auto articlePhotoMaxWidth = 0;
if (_asArticle) { if (_asArticle) {
articlePhotoMaxWidth = st::webPagePhotoDelta + qMax(articleThumbWidth(_data->photo, articleMinHeight), lineHeight); articlePhotoMaxWidth = st::webPagePhotoDelta + std::max(articleThumbWidth(_data->photo, articleMinHeight), lineHeight);
} }
if (_siteNameWidth) { if (_siteNameWidth) {
@ -3406,7 +3406,7 @@ int HistoryWebPage::resizeGetHeight(int width) {
return _height; return _height;
} }
_width = width/* = qMin(width, _maxw)*/; _width = width/* = std::min(width, _maxw)*/;
width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
auto lineHeight = unitedLineHeight(); auto lineHeight = unitedLineHeight();
@ -3417,7 +3417,7 @@ int HistoryWebPage::resizeGetHeight(int width) {
_pixh = linesMax * lineHeight; _pixh = linesMax * lineHeight;
do { do {
_pixw = articleThumbWidth(_data->photo, _pixh); _pixw = articleThumbWidth(_data->photo, _pixh);
qint32 wleft = width - st::webPagePhotoDelta - qMax(_pixw, int16_t(lineHeight)); qint32 wleft = width - st::webPagePhotoDelta - std::max(_pixw, int16_t(lineHeight));
_height = siteNameHeight; _height = siteNameHeight;
@ -3531,13 +3531,13 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, T
_data->photo->medium->load(false, false); _data->photo->medium->load(false, false);
bool full = _data->photo->medium->loaded(); bool full = _data->photo->medium->loaded();
QPixmap pix; QPixmap pix;
qint32 pw = qMax(_pixw, int16_t(lineHeight)), ph = _pixh; qint32 pw = std::max(_pixw, int16_t(lineHeight)), ph = _pixh;
qint32 pixw = _pixw, pixh = articleThumbHeight(_data->photo, _pixw); qint32 pixw = _pixw, pixh = articleThumbHeight(_data->photo, _pixw);
qint32 maxw = convertScale(_data->photo->medium->width()), maxh = convertScale(_data->photo->medium->height()); qint32 maxw = convertScale(_data->photo->medium->width()), maxh = convertScale(_data->photo->medium->height());
if (pixw * ph != pixh * pw) { if (pixw * ph != pixh * pw) {
double coef = (pixw * ph > pixh * pw) ? qMin(ph / double(pixh), maxh / double(pixh)) : qMin(pw / double(pixw), maxw / double(pixw)); double coef = (pixw * ph > pixh * pw) ? std::min(ph / double(pixh), maxh / double(pixh)) : std::min(pw / double(pixw), maxw / double(pixw));
pixh = qRound(pixh * coef); pixh = std::round(pixh * coef);
pixw = qRound(pixw * coef); pixw = std::round(pixw * coef);
} }
if (full) { if (full) {
pix = _data->photo->medium->pixSingle(pixw, pixh, pw, ph, ImageRoundRadius::Small); pix = _data->photo->medium->pixSingle(pixw, pixh, pw, ph, ImageRoundRadius::Small);
@ -3643,7 +3643,7 @@ HistoryTextState HistoryWebPage::getState(QPoint point, HistoryStateRequest requ
auto lineHeight = unitedLineHeight(); auto lineHeight = unitedLineHeight();
auto inThumb = false; auto inThumb = false;
if (_asArticle) { if (_asArticle) {
qint32 pw = qMax(_pixw, int16_t(lineHeight)); qint32 pw = std::max(_pixw, int16_t(lineHeight));
if (rtlrect(padding.left() + width - pw, 0, pw, _pixh, _width).contains(point)) { if (rtlrect(padding.left() + width - pw, 0, pw, _pixh, _width).contains(point)) {
inThumb = true; inThumb = true;
} }
@ -3856,7 +3856,7 @@ void HistoryGame::initDimensions() {
qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight; qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight;
// enable any count of lines in game description / message // enable any count of lines in game description / message
int descMaxLines = 4096; int descMaxLines = 4096;
qint32 descriptionMinHeight = _description.isEmpty() ? 0 : qMin(_description.minHeight(), descMaxLines * lineHeight); qint32 descriptionMinHeight = _description.isEmpty() ? 0 : std::min(_description.minHeight(), descMaxLines * lineHeight);
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
accumulate_max(_maxw, _title.maxWidth()); accumulate_max(_maxw, _title.maxWidth());
@ -3895,7 +3895,7 @@ void HistoryGame::updateMessageId() {
} }
int HistoryGame::resizeGetHeight(int width) { int HistoryGame::resizeGetHeight(int width) {
_width = width = qMin(width, _maxw); _width = width = std::min(width, _maxw);
width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
// enable any count of lines in game description / message // enable any count of lines in game description / message
@ -4296,7 +4296,7 @@ void HistoryInvoice::initDimensions() {
qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight; qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight;
// enable any count of lines in game description / message // enable any count of lines in game description / message
int descMaxLines = 4096; int descMaxLines = 4096;
qint32 descriptionMinHeight = _description.isEmpty() ? 0 : qMin(_description.minHeight(), descMaxLines * lineHeight); qint32 descriptionMinHeight = _description.isEmpty() ? 0 : std::min(_description.minHeight(), descMaxLines * lineHeight);
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
accumulate_max(_maxw, _title.maxWidth()); accumulate_max(_maxw, _title.maxWidth());
@ -4328,7 +4328,7 @@ void HistoryInvoice::initDimensions() {
} }
int HistoryInvoice::resizeGetHeight(int width) { int HistoryInvoice::resizeGetHeight(int width) {
_width = width = qMin(width, _maxw); _width = width = std::min(width, _maxw);
width -= st::msgPadding.left() + st::msgPadding.right(); width -= st::msgPadding.left() + st::msgPadding.right();
auto lineHeight = unitedLineHeight(); auto lineHeight = unitedLineHeight();
@ -4596,17 +4596,17 @@ void HistoryLocation::initDimensions() {
th = (st::maxMediaSize * th) / tw; th = (st::maxMediaSize * th) / tw;
tw = st::maxMediaSize; tw = st::maxMediaSize;
} }
qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
_maxw = qMax(tw, qint32(minWidth)); _maxw = std::max(tw, qint32(minWidth));
_minh = qMax(th, qint32(st::minPhotoSize)); _minh = std::max(th, qint32(st::minPhotoSize));
if (bubble) { if (bubble) {
_maxw += st::mediaPadding.left() + st::mediaPadding.right(); _maxw += st::mediaPadding.left() + st::mediaPadding.right();
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
_minh += qMin(_title.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height); _minh += std::min(_title.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height);
} }
if (!_description.isEmpty()) { if (!_description.isEmpty()) {
_minh += qMin(_description.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height); _minh += std::min(_description.countHeight(_maxw - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height);
} }
_minh += st::mediaPadding.top() + st::mediaPadding.bottom(); _minh += st::mediaPadding.top() + st::mediaPadding.bottom();
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
@ -4621,7 +4621,7 @@ void HistoryLocation::initDimensions() {
int HistoryLocation::resizeGetHeight(int width) { int HistoryLocation::resizeGetHeight(int width) {
bool bubble = _parent->hasBubble(); bool bubble = _parent->hasBubble();
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
if (bubble) { if (bubble) {
_width -= st::mediaPadding.left() + st::mediaPadding.right(); _width -= st::mediaPadding.left() + st::mediaPadding.right();
} }
@ -4637,17 +4637,17 @@ int HistoryLocation::resizeGetHeight(int width) {
} else { } else {
_width = tw; _width = tw;
} }
qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
_width = qMax(_width, qint32(minWidth)); _width = std::max(_width, qint32(minWidth));
_height = qMax(_height, qint32(st::minPhotoSize)); _height = std::max(_height, qint32(st::minPhotoSize));
if (bubble) { if (bubble) {
_width += st::mediaPadding.left() + st::mediaPadding.right(); _width += st::mediaPadding.left() + st::mediaPadding.right();
_height += st::mediaPadding.top() + st::mediaPadding.bottom(); _height += st::mediaPadding.top() + st::mediaPadding.bottom();
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
_height += qMin(_title.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()), st::webPageTitleFont->height * 2); _height += std::min(_title.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()), st::webPageTitleFont->height * 2);
} }
if (!_description.isEmpty()) { if (!_description.isEmpty()) {
_height += qMin(_description.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()), st::webPageDescriptionFont->height * 3); _height += std::min(_description.countHeight(_width - st::msgPadding.left() - st::msgPadding.right()), st::webPageDescriptionFont->height * 3);
} }
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
_height += st::mediaInBubbleSkip; _height += st::mediaInBubbleSkip;
@ -4682,12 +4682,12 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection,
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
p.setPen(outbg ? st::webPageTitleOutFg : st::webPageTitleInFg); p.setPen(outbg ? st::webPageTitleOutFg : st::webPageTitleInFg);
_title.drawLeftElided(p, skipx + st::msgPadding.left(), skipy, textw, _width, 2, style::al_left, 0, -1, 0, false, selection); _title.drawLeftElided(p, skipx + st::msgPadding.left(), skipy, textw, _width, 2, style::al_left, 0, -1, 0, false, selection);
skipy += qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height); skipy += std::min(_title.countHeight(textw), 2 * st::webPageTitleFont->height);
} }
if (!_description.isEmpty()) { if (!_description.isEmpty()) {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg);
_description.drawLeftElided(p, skipx + st::msgPadding.left(), skipy, textw, _width, 3, style::al_left, 0, -1, 0, false, toDescriptionSelection(selection)); _description.drawLeftElided(p, skipx + st::msgPadding.left(), skipy, textw, _width, 3, style::al_left, 0, -1, 0, false, toDescriptionSelection(selection));
skipy += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); skipy += std::min(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height);
} }
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
skipy += st::mediaInBubbleSkip; skipy += st::mediaInBubbleSkip;
@ -4756,7 +4756,7 @@ HistoryTextState HistoryLocation::getState(QPoint point, HistoryStateRequest req
auto textw = _width - st::msgPadding.left() - st::msgPadding.right(); auto textw = _width - st::msgPadding.left() - st::msgPadding.right();
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
auto titleh = qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height); auto titleh = std::min(_title.countHeight(textw), 2 * st::webPageTitleFont->height);
if (point.y() >= skipy && point.y() < skipy + titleh) { if (point.y() >= skipy && point.y() < skipy + titleh) {
result = _title.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText()); result = _title.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText());
return result; return result;
@ -4766,7 +4766,7 @@ HistoryTextState HistoryLocation::getState(QPoint point, HistoryStateRequest req
skipy += titleh; skipy += titleh;
} }
if (!_description.isEmpty()) { if (!_description.isEmpty()) {
auto descriptionh = qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); auto descriptionh = std::min(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height);
if (point.y() >= skipy && point.y() < skipy + descriptionh) { if (point.y() >= skipy && point.y() < skipy + descriptionh) {
result = _description.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText()); result = _description.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText());
} else if (point.y() >= skipy + descriptionh) { } else if (point.y() >= skipy + descriptionh) {

View File

@ -463,7 +463,7 @@ void HistoryMessageReply::updateName() const {
w += st::msgServiceFont->spacew + _replyToVia->_maxWidth; w += st::msgServiceFont->spacew + _replyToVia->_maxWidth;
} }
_maxReplyWidth = previewSkip + qMax(w, qMin(replyToText.maxWidth(), qint32(st::maxSignatureSize))); _maxReplyWidth = previewSkip + std::max(w, std::min(replyToText.maxWidth(), qint32(st::maxSignatureSize)));
} else { } else {
_maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message)); _maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message));
} }
@ -1142,9 +1142,9 @@ bool HistoryMessage::drawBubble() const {
} }
QRect HistoryMessage::countGeometry() const { QRect HistoryMessage::countGeometry() const {
auto maxwidth = qMin(st::msgMaxWidth, _maxw); auto maxwidth = std::min(st::msgMaxWidth, _maxw);
if (_media && _media->currentWidth() < maxwidth) { if (_media && _media->currentWidth() < maxwidth) {
maxwidth = qMax(_media->currentWidth(), qMin(maxwidth, plainMaxWidth())); maxwidth = std::max(_media->currentWidth(), std::min(maxwidth, plainMaxWidth()));
} }
auto contentLeft = (!isPost() && out() && !Adaptive::ChatWide()) ? st::msgMargin.right() : st::msgMargin.left(); auto contentLeft = (!isPost() && out() && !Adaptive::ChatWide()) ? st::msgMargin.right() : st::msgMargin.left();
@ -1619,7 +1619,7 @@ void HistoryMessage::draw(Painter &p, QRect clip, TextSelection selection, TimeM
if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) { if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) {
auto top = marginTop(); auto top = marginTop();
auto bottom = marginBottom(); auto bottom = marginBottom();
auto fill = qMin(top, bottom); auto fill = std::min(top, bottom);
auto skiptop = top - fill; auto skiptop = top - fill;
auto fillheight = fill + g.height() + fill; auto fillheight = fill + g.height() + fill;
@ -1878,7 +1878,7 @@ int HistoryMessage::performResizeGetHeight() {
if (emptyText()) { if (emptyText()) {
_height = 0; _height = 0;
} else { } else {
auto textWidth = qMax(contentWidth - st::msgPadding.left() - st::msgPadding.right(), 1); auto textWidth = std::max(contentWidth - st::msgPadding.left() - st::msgPadding.right(), 1);
if (textWidth != _textWidth) { if (textWidth != _textWidth) {
_textWidth = textWidth; _textWidth = textWidth;
_textHeight = _text.countHeight(textWidth); _textHeight = _text.countHeight(textWidth);

View File

@ -436,7 +436,7 @@ bool HistoryService::updateDependencyItem() {
QRect HistoryService::countGeometry() const { QRect HistoryService::countGeometry() const {
auto result = QRect(0, 0, width(), _height); auto result = QRect(0, 0, width(), _height);
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); result.setWidth(std::min(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
} }
return result.marginsRemoved(st::msgServiceMargin); return result.marginsRemoved(st::msgServiceMargin);
} }
@ -513,7 +513,7 @@ int HistoryService::resizeContentGetHeight() {
contentWidth = st::msgServicePadding.left() + st::msgServicePadding.right() + 1; contentWidth = st::msgServicePadding.left() + st::msgServicePadding.right() + 1;
} }
auto nwidth = qMax(contentWidth - st::msgServicePadding.left() - st::msgServicePadding.right(), 0); auto nwidth = std::max(contentWidth - st::msgServicePadding.left() - st::msgServicePadding.right(), 0);
if (nwidth != _textWidth) { if (nwidth != _textWidth) {
_textWidth = nwidth; _textWidth = nwidth;
_textHeight = _text.countHeight(nwidth); _textHeight = _text.countHeight(nwidth);

View File

@ -169,7 +169,7 @@ void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, i
int left = st::msgServiceMargin.left(); int left = st::msgServiceMargin.left();
int maxwidth = w; int maxwidth = w;
if (Adaptive::ChatWide()) { if (Adaptive::ChatWide()) {
maxwidth = qMin(maxwidth, WideChatWidth()); maxwidth = std::min(maxwidth, WideChatWidth());
} }
w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
@ -202,7 +202,7 @@ void ServiceMessagePainter::paint(
if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) { if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) {
auto top = st::msgServiceMargin.top(); auto top = st::msgServiceMargin.top();
auto bottom = st::msgServiceMargin.bottom(); auto bottom = st::msgServiceMargin.bottom();
auto fill = qMin(top, bottom); auto fill = std::min(top, bottom);
auto skiptop = top - fill; auto skiptop = top - fill;
auto fillheight = fill + height + fill; auto fillheight = fill + height + fill;
@ -305,14 +305,14 @@ void ServiceMessagePainter::paintComplexBubble(Painter &p, int left, int width,
} }
QVector<int> ServiceMessagePainter::countLineWidths(const Text &text, const QRect &textRect) { QVector<int> ServiceMessagePainter::countLineWidths(const Text &text, const QRect &textRect) {
int linesCount = qMax(textRect.height() / st::msgServiceFont->height, 1); int linesCount = std::max(textRect.height() / st::msgServiceFont->height, 1);
QVector<int> lineWidths; QVector<int> lineWidths;
lineWidths.reserve(linesCount); lineWidths.reserve(linesCount);
text.countLineWidths(textRect.width(), &lineWidths); text.countLineWidths(textRect.width(), &lineWidths);
int minDelta = 2 * (historyServiceMsgRadius() + historyServiceMsgInvertedRadius() - historyServiceMsgInvertedShrink()); int minDelta = 2 * (historyServiceMsgRadius() + historyServiceMsgInvertedRadius() - historyServiceMsgInvertedShrink());
for (int i = 0, count = lineWidths.size(); i < count; ++i) { for (int i = 0, count = lineWidths.size(); i < count; ++i) {
int width = qMax(lineWidths.at(i), 0); int width = std::max(lineWidths.at(i), 0);
if (i > 0) { if (i > 0) {
int widthBefore = lineWidths.at(i - 1); int widthBefore = lineWidths.at(i - 1);
if (width < widthBefore && width + minDelta > widthBefore) { if (width < widthBefore && width + minDelta > widthBefore) {

View File

@ -453,7 +453,7 @@ void HistoryHider::updateControlsGeometry() {
_send->show(); _send->show();
_cancel->show(); _cancel->show();
} }
h += st::boxTopMargin + qMax(st::boxTextFont->height, st::boxLabelStyle.lineHeight) + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom(); h += st::boxTopMargin + std::max(st::boxTextFont->height, st::boxLabelStyle.lineHeight) + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom();
} else { } else {
h += st::historyForwardChooseFont->height; h += st::historyForwardChooseFont->height;
_send->hide(); _send->hide();
@ -939,7 +939,7 @@ void HistoryWidget::scrollToAnimationCallback(FullMsgId attachToId) {
if (itemTop < 0) { if (itemTop < 0) {
_scrollToAnimation.finish(); _scrollToAnimation.finish();
} else { } else {
synteticScrollToY(qRound(_scrollToAnimation.current()) + itemTop); synteticScrollToY(std::round(_scrollToAnimation.current()) + itemTop);
} }
if (!_scrollToAnimation.animating()) { if (!_scrollToAnimation.animating()) {
preloadHistoryByScroll(); preloadHistoryByScroll();
@ -1057,7 +1057,7 @@ int HistoryWidget::itemTopForHighlight(not_null<HistoryItem*> item) const {
if (heightLeft <= 0) { if (heightLeft <= 0) {
return itemTop; return itemTop;
} }
return qMax(itemTop - (heightLeft / 2), 0); return std::max(itemTop - (heightLeft / 2), 0);
} }
void HistoryWidget::start() { void HistoryWidget::start() {
@ -1551,7 +1551,7 @@ bool HistoryWidget::cmd_search() {
bool HistoryWidget::cmd_next_chat() { bool HistoryWidget::cmd_next_chat() {
PeerData *p = 0; PeerData *p = 0;
MsgId m = 0; MsgId m = 0;
App::main()->peerAfter(_peer, qMax(_showAtMsgId, 0), p, m); App::main()->peerAfter(_peer, std::max(_showAtMsgId, 0), p, m);
if (p) { if (p) {
Ui::showPeerHistory(p, m); Ui::showPeerHistory(p, m);
return true; return true;
@ -1562,7 +1562,7 @@ bool HistoryWidget::cmd_next_chat() {
bool HistoryWidget::cmd_previous_chat() { bool HistoryWidget::cmd_previous_chat() {
PeerData *p = 0; PeerData *p = 0;
MsgId m = 0; MsgId m = 0;
App::main()->peerBefore(_peer, qMax(_showAtMsgId, 0), p, m); App::main()->peerBefore(_peer, std::max(_showAtMsgId, 0), p, m);
if (p) { if (p) {
Ui::showPeerHistory(p, m); Ui::showPeerHistory(p, m);
return true; return true;
@ -3777,7 +3777,7 @@ void HistoryWidget::onKbToggle(bool manual) {
_kbScroll->show(); _kbScroll->show();
_kbShown = true; _kbShown = true;
qint32 maxh = qMin(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2)); qint32 maxh = std::min(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2));
_field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh); _field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh);
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0; _kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0;
@ -4108,7 +4108,7 @@ void HistoryWidget::moveFieldControls() {
auto maxKeyboardHeight = st::historyComposeFieldMaxHeight - _field->height(); auto maxKeyboardHeight = st::historyComposeFieldMaxHeight - _field->height();
_keyboard->resizeToWidth(_chatWidth, maxKeyboardHeight); _keyboard->resizeToWidth(_chatWidth, maxKeyboardHeight);
if (_kbShown) { if (_kbShown) {
keyboardHeight = qMin(_keyboard->height(), maxKeyboardHeight); keyboardHeight = std::min(_keyboard->height(), maxKeyboardHeight);
bottom -= keyboardHeight; bottom -= keyboardHeight;
_kbScroll->setGeometryToLeft(0, bottom, _chatWidth, keyboardHeight); _kbScroll->setGeometryToLeft(0, bottom, _chatWidth, keyboardHeight);
} }
@ -4898,7 +4898,7 @@ int HistoryWidget::countInitialScrollTop() {
} else { } else {
return countAutomaticScrollTop(); return countAutomaticScrollTop();
} }
return qMin(result, _scroll->scrollTopMax()); return std::min(result, _scroll->scrollTopMax());
} }
int HistoryWidget::countAutomaticScrollTop() { int HistoryWidget::countAutomaticScrollTop() {
@ -4932,7 +4932,7 @@ int HistoryWidget::countAutomaticScrollTop() {
} }
} }
} }
return qMin(result, _scroll->scrollTopMax()); return std::min(result, _scroll->scrollTopMax());
} }
void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const ScrollChange &change) { void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const ScrollChange &change) {
@ -4990,7 +4990,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S
_updateHistoryGeometryRequired = false; _updateHistoryGeometryRequired = false;
if ((!initial && !wasAtBottom) || (loadedDown && (!_history->showFrom || _history->unreadBar || _history->loadedAtBottom()) && (!_migrated || !_migrated->showFrom || _migrated->unreadBar || _history->loadedAtBottom()))) { if ((!initial && !wasAtBottom) || (loadedDown && (!_history->showFrom || _history->unreadBar || _history->loadedAtBottom()) && (!_migrated || !_migrated->showFrom || _migrated->unreadBar || _history->loadedAtBottom()))) {
auto toY = qMin(_list->historyScrollTop(), _scroll->scrollTopMax()); auto toY = std::min(_list->historyScrollTop(), _scroll->scrollTopMax());
if (change.type == ScrollChangeAdd) { if (change.type == ScrollChangeAdd) {
toY += change.value; toY += change.value;
} else if (change.type == ScrollChangeNoJumpToBottom) { } else if (change.type == ScrollChangeNoJumpToBottom) {
@ -5117,7 +5117,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->hide(); _botCommandStart->hide();
} }
qint32 maxh = hasMarkup ? qMin(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2)) : 0; qint32 maxh = hasMarkup ? std::min(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2)) : 0;
_field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh); _field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh);
_kbShown = hasMarkup; _kbShown = hasMarkup;
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0; _kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0;
@ -6500,7 +6500,7 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int
if (editTimeLeft < 2) { if (editTimeLeft < 2) {
editTimeLeftText = qsl("0:00"); editTimeLeftText = qsl("0:00");
} else if (editTimeLeft > kDisplayEditTimeWarningMs) { } else if (editTimeLeft > kDisplayEditTimeWarningMs) {
updateIn = static_cast<int>(qMin(editTimeLeft - kDisplayEditTimeWarningMs, qint64(kFullDayInMs))); updateIn = static_cast<int>(std::min(editTimeLeft - kDisplayEditTimeWarningMs, qint64(kFullDayInMs)));
} else { } else {
updateIn = static_cast<int>(editTimeLeft % 1000); updateIn = static_cast<int>(editTimeLeft % 1000);
if (!updateIn) { if (!updateIn) {
@ -6528,8 +6528,8 @@ void HistoryWidget::drawRecording(Painter &p, double recordActive) {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(st::historyRecordSignalColor); p.setBrush(st::historyRecordSignalColor);
auto delta = qMin(a_recordingLevel.current() / 0x4000, 1.); auto delta = std::min(a_recordingLevel.current() / 0x4000, 1.);
auto d = 2 * qRound(st::historyRecordSignalMin + (delta * (st::historyRecordSignalMax - st::historyRecordSignalMin))); auto d = 2 * std::round(st::historyRecordSignalMin + (delta * (st::historyRecordSignalMax - st::historyRecordSignalMin)));
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(_attachToggle->x() + (_tabbedSelectorToggle->width() - d) / 2, _attachToggle->y() + (_attachToggle->height() - d) / 2, d, d); p.drawEllipse(_attachToggle->x() + (_tabbedSelectorToggle->width() - d) / 2, _attachToggle->y() + (_attachToggle->height() - d) / 2, d, d);
@ -6634,10 +6634,10 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
auto bottom = r.top() + r.height(); auto bottom = r.top() + r.height();
auto w = pix.width() / cRetinaFactor(); auto w = pix.width() / cRetinaFactor();
auto h = pix.height() / cRetinaFactor(); auto h = pix.height() / cRetinaFactor();
auto sx = qFloor(left / w); auto sx = std::floor(left / w);
auto sy = qFloor((top - fromy) / h); auto sy = std::floor((top - fromy) / h);
auto cx = qCeil(right / w); auto cx = std::ceil(right / w);
auto cy = qCeil((bottom - fromy) / h); auto cy = std::ceil((bottom - fromy) / h);
for (auto i = sx; i < cx; ++i) { for (auto i = sx; i < cx; ++i) {
for (auto j = sy; j < cy; ++j) { for (auto j = sy; j < cy; ++j) {
p.drawPixmap(QPointF(i * w, fromy + j * h), pix); p.drawPixmap(QPointF(i * w, fromy + j * h), pix);
@ -6707,7 +6707,7 @@ QPoint HistoryWidget::clampMousePosition(QPoint point) {
} }
void HistoryWidget::onScrollTimer() { void HistoryWidget::onScrollTimer() {
auto d = (_scrollDelta > 0) ? qMin(_scrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : qMax(_scrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed)); auto d = (_scrollDelta > 0) ? std::min(_scrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : std::max(_scrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed));
_scroll->scrollToY(_scroll->scrollTop() + d); _scroll->scrollToY(_scroll->scrollTop() + d);
} }

View File

@ -109,7 +109,7 @@ void Gif::initDimensions() {
_maxw = 0; _maxw = 0;
} else { } else {
w = w * st::inlineMediaHeight / h; w = w * st::inlineMediaHeight / h;
_maxw = qMax(w, qint32(st::inlineResultsMinWidth)); _maxw = std::max(w, qint32(st::inlineResultsMinWidth));
} }
_minh = st::inlineMediaHeight + st::inlineResultsSkip; _minh = st::inlineMediaHeight + st::inlineResultsSkip;
} }
@ -423,12 +423,12 @@ void Sticker::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
} }
QSize Sticker::getThumbSize() const { QSize Sticker::getThumbSize() const {
int width = qMax(content_width(), 1), height = qMax(content_height(), 1); int width = std::max(content_width(), 1), height = std::max(content_height(), 1);
double coefw = (st::stickerPanSize.width() - st::buttonRadius * 2) / double(width); double coefw = (st::stickerPanSize.width() - st::buttonRadius * 2) / double(width);
double coefh = (st::stickerPanSize.height() - st::buttonRadius * 2) / double(height); double coefh = (st::stickerPanSize.height() - st::buttonRadius * 2) / double(height);
double coef = qMin(qMin(coefw, coefh), 1.); double coef = std::min(std::min(coefw, coefh), 1.);
int w = qRound(coef * content_width()), h = qRound(coef * content_height()); int w = std::round(coef * content_width()), h = std::round(coef * content_height());
return QSize(qMax(w, 1), qMax(h, 1)); return QSize(std::max(w, 1), std::max(h, 1));
} }
void Sticker::prepareThumb() const { void Sticker::prepareThumb() const {
@ -470,7 +470,7 @@ void Photo::initDimensions() {
_maxw = 0; _maxw = 0;
} else { } else {
w = w * st::inlineMediaHeight / h; w = w * st::inlineMediaHeight / h;
_maxw = qMax(w, qint32(st::inlineResultsMinWidth)); _maxw = std::max(w, qint32(st::inlineResultsMinWidth));
} }
_minh = st::inlineMediaHeight + st::inlineResultsSkip; _minh = st::inlineMediaHeight + st::inlineResultsSkip;
} }
@ -577,7 +577,7 @@ void Video::initDimensions() {
title = lang(lng_media_video); title = lang(lng_media_video);
} }
_title.setText(st::semiboldTextStyle, title, titleOpts); _title.setText(st::semiboldTextStyle, title, titleOpts);
qint32 titleHeight = qMin(_title.countHeight(_maxw), 2 * st::semiboldFont->height); qint32 titleHeight = std::min(_title.countHeight(_maxw), 2 * st::semiboldFont->height);
qint32 descriptionLines = withThumb ? (titleHeight > st::semiboldFont->height ? 1 : 2) : 3; qint32 descriptionLines = withThumb ? (titleHeight > st::semiboldFont->height ? 1 : 2) : 3;
@ -587,7 +587,7 @@ void Video::initDimensions() {
description = _duration; description = _duration;
} }
_description.setText(st::defaultTextStyle, description, descriptionOpts); _description.setText(st::defaultTextStyle, description, descriptionOpts);
qint32 descriptionHeight = qMin(_description.countHeight(_maxw), descriptionLines * st::normalFont->height); qint32 descriptionHeight = std::min(_description.countHeight(_maxw), descriptionLines * st::normalFont->height);
_minh = st::inlineThumbSize; _minh = st::inlineThumbSize;
_minh += st::inlineRowMargin * 2 + st::inlineRowBorder; _minh += st::inlineRowMargin * 2 + st::inlineRowBorder;
@ -620,7 +620,7 @@ void Video::paint(Painter &p, const QRect &clip, const PaintContext *context) co
p.setPen(st::inlineTitleFg); p.setPen(st::inlineTitleFg);
_title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2); _title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2);
qint32 titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2); qint32 titleHeight = std::min(_title.countHeight(_width - left), st::semiboldFont->height * 2);
p.setPen(st::inlineDescriptionFg); p.setPen(st::inlineDescriptionFg);
qint32 descriptionLines = withThumb ? (titleHeight > st::semiboldFont->height ? 1 : 2) : 3; qint32 descriptionLines = withThumb ? (titleHeight > st::semiboldFont->height ? 1 : 2) : 3;
@ -646,7 +646,7 @@ void Video::prepareThumb(qint32 width, qint32 height) const {
ImagePtr thumb = content_thumb(); ImagePtr thumb = content_thumb();
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
qint32 w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); qint32 w = std::max(convertScale(thumb->width()), 1), h = std::max(convertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -893,18 +893,18 @@ void Contact::initDimensions() {
qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip); qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip);
TextParseOptions titleOpts = { 0, _maxw, st::semiboldFont->height, Qt::LayoutDirectionAuto }; TextParseOptions titleOpts = { 0, _maxw, st::semiboldFont->height, Qt::LayoutDirectionAuto };
_title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts); _title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts);
qint32 titleHeight = qMin(_title.countHeight(_maxw), st::semiboldFont->height); qint32 titleHeight = std::min(_title.countHeight(_maxw), st::semiboldFont->height);
TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, st::normalFont->height, Qt::LayoutDirectionAuto }; TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, st::normalFont->height, Qt::LayoutDirectionAuto };
_description.setText(st::defaultTextStyle, _result->getLayoutDescription(), descriptionOpts); _description.setText(st::defaultTextStyle, _result->getLayoutDescription(), descriptionOpts);
qint32 descriptionHeight = qMin(_description.countHeight(_maxw), st::normalFont->height); qint32 descriptionHeight = std::min(_description.countHeight(_maxw), st::normalFont->height);
_minh = st::msgFileSize; _minh = st::msgFileSize;
_minh += st::inlineRowMargin * 2 + st::inlineRowBorder; _minh += st::inlineRowMargin * 2 + st::inlineRowBorder;
} }
qint32 Contact::resizeGetHeight(qint32 width) { qint32 Contact::resizeGetHeight(qint32 width) {
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
_height = _minh; _height = _minh;
return _height; return _height;
} }
@ -953,7 +953,7 @@ void Contact::prepareThumb(int width, int height) const {
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = std::max(convertScale(thumb->width()), 1), h = std::max(convertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -990,22 +990,22 @@ void Article::initDimensions() {
qint32 textWidth = _maxw - (_withThumb ? (st::inlineThumbSize + st::inlineThumbSkip) : 0); qint32 textWidth = _maxw - (_withThumb ? (st::inlineThumbSize + st::inlineThumbSkip) : 0);
TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto }; TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto };
_title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts); _title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts);
qint32 titleHeight = qMin(_title.countHeight(_maxw), 2 * st::semiboldFont->height); qint32 titleHeight = std::min(_title.countHeight(_maxw), 2 * st::semiboldFont->height);
qint32 descriptionLines = (_withThumb || _url) ? 2 : 3; qint32 descriptionLines = (_withThumb || _url) ? 2 : 3;
QString description = _result->getLayoutDescription(); QString description = _result->getLayoutDescription();
TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto }; TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto };
_description.setText(st::defaultTextStyle, description, descriptionOpts); _description.setText(st::defaultTextStyle, description, descriptionOpts);
qint32 descriptionHeight = qMin(_description.countHeight(_maxw), descriptionLines * st::normalFont->height); qint32 descriptionHeight = std::min(_description.countHeight(_maxw), descriptionLines * st::normalFont->height);
_minh = titleHeight + descriptionHeight; _minh = titleHeight + descriptionHeight;
if (_url) _minh += st::normalFont->height; if (_url) _minh += st::normalFont->height;
if (_withThumb) _minh = qMax(_minh, qint32(st::inlineThumbSize)); if (_withThumb) _minh = std::max(_minh, qint32(st::inlineThumbSize));
_minh += st::inlineRowMargin * 2 + st::inlineRowBorder; _minh += st::inlineRowMargin * 2 + st::inlineRowBorder;
} }
qint32 Article::resizeGetHeight(qint32 width) { qint32 Article::resizeGetHeight(qint32 width) {
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
if (_url) { if (_url) {
_urlText = getResultUrl(); _urlText = getResultUrl();
_urlWidth = st::normalFont->width(_urlText); _urlWidth = st::normalFont->width(_urlText);
@ -1051,14 +1051,14 @@ void Article::paint(Painter &p, const QRect &clip, const PaintContext *context)
p.setPen(st::inlineTitleFg); p.setPen(st::inlineTitleFg);
_title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2); _title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2);
qint32 titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2); qint32 titleHeight = std::min(_title.countHeight(_width - left), st::semiboldFont->height * 2);
p.setPen(st::inlineDescriptionFg); p.setPen(st::inlineDescriptionFg);
qint32 descriptionLines = (_withThumb || _url) ? 2 : 3; qint32 descriptionLines = (_withThumb || _url) ? 2 : 3;
_description.drawLeftElided(p, left, st::inlineRowMargin + titleHeight, _width - left, _width, descriptionLines); _description.drawLeftElided(p, left, st::inlineRowMargin + titleHeight, _width - left, _width, descriptionLines);
if (_url) { if (_url) {
qint32 descriptionHeight = qMin(_description.countHeight(_width - left), st::normalFont->height * descriptionLines); qint32 descriptionHeight = std::min(_description.countHeight(_width - left), st::normalFont->height * descriptionLines);
p.drawTextLeft(left, st::inlineRowMargin + titleHeight + descriptionHeight, _width, _urlText, _urlWidth); p.drawTextLeft(left, st::inlineRowMargin + titleHeight + descriptionHeight, _width, _urlText, _urlWidth);
} }
@ -1076,9 +1076,9 @@ void Article::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint
if (QRect(left, 0, _width - left, _height).contains(point)) { if (QRect(left, 0, _width - left, _height).contains(point)) {
if (_url) { if (_url) {
auto left = st::inlineThumbSize + st::inlineThumbSkip; auto left = st::inlineThumbSize + st::inlineThumbSkip;
auto titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2); auto titleHeight = std::min(_title.countHeight(_width - left), st::semiboldFont->height * 2);
auto descriptionLines = 2; auto descriptionLines = 2;
auto descriptionHeight = qMin(_description.countHeight(_width - left), st::normalFont->height * descriptionLines); auto descriptionHeight = std::min(_description.countHeight(_width - left), st::normalFont->height * descriptionLines);
if (rtlrect(left, st::inlineRowMargin + titleHeight + descriptionHeight, _urlWidth, st::normalFont->height, _width).contains(point)) { if (rtlrect(left, st::inlineRowMargin + titleHeight + descriptionHeight, _urlWidth, st::normalFont->height, _width).contains(point)) {
link = _url; link = _url;
return; return;
@ -1100,7 +1100,7 @@ void Article::prepareThumb(int width, int height) const {
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = std::max(convertScale(thumb->width()), 1), h = std::max(convertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -1158,13 +1158,13 @@ void Game::initDimensions() {
qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip); qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip);
TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto }; TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto };
_title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts); _title.setText(st::semiboldTextStyle, TextUtilities::SingleLine(_result->getLayoutTitle()), titleOpts);
qint32 titleHeight = qMin(_title.countHeight(_maxw), 2 * st::semiboldFont->height); qint32 titleHeight = std::min(_title.countHeight(_maxw), 2 * st::semiboldFont->height);
qint32 descriptionLines = 2; qint32 descriptionLines = 2;
QString description = _result->getLayoutDescription(); QString description = _result->getLayoutDescription();
TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto }; TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto };
_description.setText(st::defaultTextStyle, description, descriptionOpts); _description.setText(st::defaultTextStyle, description, descriptionOpts);
qint32 descriptionHeight = qMin(_description.countHeight(_maxw), descriptionLines * st::normalFont->height); qint32 descriptionHeight = std::min(_description.countHeight(_maxw), descriptionLines * st::normalFont->height);
_minh = titleHeight + descriptionHeight; _minh = titleHeight + descriptionHeight;
accumulate_max(_minh, st::inlineThumbSize); accumulate_max(_minh, st::inlineThumbSize);
@ -1240,7 +1240,7 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
p.setPen(st::inlineTitleFg); p.setPen(st::inlineTitleFg);
_title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2); _title.drawLeftElided(p, left, st::inlineRowMargin, _width - left, _width, 2);
qint32 titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2); qint32 titleHeight = std::min(_title.countHeight(_width - left), st::semiboldFont->height * 2);
p.setPen(st::inlineDescriptionFg); p.setPen(st::inlineDescriptionFg);
qint32 descriptionLines = 2; qint32 descriptionLines = 2;
@ -1278,7 +1278,7 @@ void Game::prepareThumb(int width, int height) const {
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = std::max(convertScale(thumb->width()), 1), h = std::max(convertScale(thumb->height()), 1);
auto resizeByHeight1 = (w * height > h * width) && (h >= height); auto resizeByHeight1 = (w * height > h * width) && (h >= height);
auto resizeByHeight2 = (h * width >= w * height) && (w < width); auto resizeByHeight2 = (h * width >= w * height) && (w < width);
if (resizeByHeight1 || resizeByHeight2) { if (resizeByHeight1 || resizeByHeight2) {

View File

@ -392,8 +392,8 @@ Inner::Row &Inner::layoutInlineRow(Row &row, qint32 sumWidth) {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int index = indices[i]; int index = indices[i];
int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth(); int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth();
int actualw = qMax(w, int(st::inlineResultsMinWidth)); int actualw = std::max(w, int(st::inlineResultsMinWidth));
row.height = qMax(row.height, row.items.at(index)->resizeGetHeight(actualw)); row.height = std::max(row.height, row.items.at(index)->resizeGetHeight(actualw));
if (sumWidth) { if (sumWidth) {
availw -= actualw; availw -= actualw;
sumWidth -= row.items.at(index)->maxWidth(); sumWidth -= row.items.at(index)->maxWidth();
@ -758,7 +758,7 @@ void Widget::moveBottom(int bottom) {
void Widget::updateContentHeight() { void Widget::updateContentHeight() {
auto addedHeight = innerPadding().top() + innerPadding().bottom(); auto addedHeight = innerPadding().top() + innerPadding().bottom();
auto wantedContentHeight = qRound(st::emojiPanHeightRatio * _bottom) - addedHeight; int wantedContentHeight = std::round(st::emojiPanHeightRatio * _bottom) - addedHeight;
auto contentHeight = snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight); auto contentHeight = snap(wantedContentHeight, st::emojiPanMinHeight, st::emojiPanMaxHeight);
accumulate_min(contentHeight, _bottom - addedHeight); accumulate_min(contentHeight, _bottom - addedHeight);
accumulate_min(contentHeight, _contentMaxHeight); accumulate_min(contentHeight, _contentMaxHeight);

View File

@ -619,9 +619,9 @@ void Widget::Step::paintCover(Painter &p, int top) {
} }
if (top < 0) { if (top < 0) {
auto shown = double(coverHeight) / st::introCoverHeight; auto shown = double(coverHeight) / st::introCoverHeight;
auto leftShown = qRound(shown * (left + st::introCoverLeft.width())); auto leftShown = std::round(shown * (left + st::introCoverLeft.width()));
left = leftShown - st::introCoverLeft.width(); left = leftShown - st::introCoverLeft.width();
auto rightShown = qRound(shown * (right + st::introCoverRight.width())); auto rightShown = std::round(shown * (right + st::introCoverRight.width()));
right = rightShown - st::introCoverRight.width(); right = rightShown - st::introCoverRight.width();
} }
st::introCoverLeft.paint(p, left, coverHeight - st::introCoverLeft.height(), width()); st::introCoverLeft.paint(p, left, coverHeight - st::introCoverLeft.height(), width());
@ -630,7 +630,7 @@ void Widget::Step::paintCover(Painter &p, int top) {
auto planeLeft = (width() - st::introCoverIcon.width()) / 2 - st::introCoverIconLeft; auto planeLeft = (width() - st::introCoverIcon.width()) / 2 - st::introCoverIconLeft;
auto planeTop = top + st::introCoverIconTop; auto planeTop = top + st::introCoverIconTop;
if (top < 0 && !_hasCover) { if (top < 0 && !_hasCover) {
auto deltaLeft = -qRound(double(st::introPlaneWidth / st::introPlaneHeight) * top); auto deltaLeft = -std::round(double(st::introPlaneWidth / st::introPlaneHeight) * top);
// auto deltaTop = top; // auto deltaTop = top;
planeLeft += deltaLeft; planeLeft += deltaLeft;
// planeTop += top; // planeTop += top;
@ -646,7 +646,7 @@ int Widget::Step::contentTop() const {
auto result = height() - st::introStepHeight - st::introStepHeightAdd; auto result = height() - st::introStepHeight - st::introStepHeightAdd;
if (_hasCover) { if (_hasCover) {
auto added = 1. - snap(double(height() - st::windowMinHeight) / (st::introStepHeightFull - st::windowMinHeight), 0., 1.); auto added = 1. - snap(double(height() - st::windowMinHeight) / (st::introStepHeightFull - st::windowMinHeight), 0., 1.);
result += qRound(added * st::introStepHeightAdd); result += std::round(added * st::introStepHeightAdd);
} }
return result; return result;
} }

View File

@ -157,8 +157,8 @@ int FindTagReplacementPosition(const QString &original, ushort tag) {
PluralResult Plural(ushort keyBase, double value) { PluralResult Plural(ushort keyBase, double value) {
// Simplified. // Simplified.
auto n = qAbs(value); auto n = qAbs(value);
auto i = qFloor(n); auto i = std::floor(n);
auto integer = (qCeil(n) == i); auto integer = (std::ceil(n) == i);
auto v = integer ? 0 : 6; auto v = integer ? 0 : 6;
auto w = v; auto w = v;
auto f = integer ? 0 : 111111; auto f = integer ? 0 : 111111;
@ -168,8 +168,8 @@ PluralResult Plural(ushort keyBase, double value) {
auto useNonDefaultPlural = (ChoosePlural != ChoosePluralEn && langpack.isNonDefaultPlural(LangKey(keyBase))); auto useNonDefaultPlural = (ChoosePlural != ChoosePluralEn && langpack.isNonDefaultPlural(LangKey(keyBase)));
auto shift = (useNonDefaultPlural ? ChoosePlural : ChoosePluralEn)((integer ? i : -1), i, v, w, f, t); auto shift = (useNonDefaultPlural ? ChoosePlural : ChoosePluralEn)((integer ? i : -1), i, v, w, f, t);
auto string = langpack.getValue(LangKey(keyBase + shift)); auto string = langpack.getValue(LangKey(keyBase + shift));
if (i == qCeil(n)) { if (i == std::ceil(n)) {
return { string, QString::number(qRound(value)) }; return { string, QString::number(std::round(value)) };
} }
return { string, QString::number(value) }; return { string, QString::number(value) };
} }

View File

@ -752,8 +752,8 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
} }
} else { } else {
p.setOpacity(shown); p.setOpacity(shown);
// w = qMax(qRound(w * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(w % 2), 1); // w = std::max(std::round(w * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(w % 2), 1);
// h = qMax(qRound(h * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(h % 2), 1); // h = std::max(std::round(h * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(h % 2), 1);
} }
p.fillRect(r, st::stickerPreviewBg); p.fillRect(r, st::stickerPreviewBg);
p.drawPixmap((width() - w) / 2, (height() - h) / 2, image); p.drawPixmap((width() - w) / 2, (height() - h) / 2, image);
@ -872,13 +872,13 @@ QSize MediaPreviewWidget::currentDimensions() const {
box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize); box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize);
} }
} }
result = QSize(qMax(convertScale(result.width()), 1), qMax(convertScale(result.height()), 1)); result = QSize(std::max(convertScale(result.width()), 1), std::max(convertScale(result.height()), 1));
if (result.width() > box.width()) { if (result.width() > box.width()) {
result.setHeight(qMax((box.width() * result.height()) / result.width(), 1)); result.setHeight(std::max((box.width() * result.height()) / result.width(), 1));
result.setWidth(box.width()); result.setWidth(box.width());
} }
if (result.height() > box.height()) { if (result.height() > box.height()) {
result.setWidth(qMax((box.height() * result.width()) / result.height(), 1)); result.setWidth(std::max((box.height() * result.width()) / result.height(), 1));
result.setHeight(box.height()); result.setHeight(box.height());
} }
if (_photo) { if (_photo) {

View File

@ -1169,7 +1169,7 @@ void MainWidget::addParticipants(PeerData *chatOrChannel, const std::vector<not_
} }
} else if (chatOrChannel->isChannel()) { } else if (chatOrChannel->isChannel()) {
QVector<MTPInputUser> inputUsers; QVector<MTPInputUser> inputUsers;
inputUsers.reserve(qMin(int(users.size()), int(MaxUsersPerInvite))); inputUsers.reserve(std::min(int(users.size()), int(MaxUsersPerInvite)));
for (auto i = users.cbegin(), e = users.cend(); i != e; ++i) { for (auto i = users.cbegin(), e = users.cend(); i != e; ++i) {
inputUsers.push_back((*i)->inputUser); inputUsers.push_back((*i)->inputUser);
if (inputUsers.size() == MaxUsersPerInvite) { if (inputUsers.size() == MaxUsersPerInvite) {
@ -1331,8 +1331,8 @@ void MainWidget::onCacheBackground() {
auto h = bg.height() / cRetinaFactor(); auto h = bg.height() / cRetinaFactor();
auto sx = 0; auto sx = 0;
auto sy = 0; auto sy = 0;
auto cx = qCeil(_willCacheFor.width() / w); auto cx = std::ceil(_willCacheFor.width() / w);
auto cy = qCeil(_willCacheFor.height() / h); auto cy = std::ceil(_willCacheFor.height() / h);
for (int i = sx; i < cx; ++i) { for (int i = sx; i < cx; ++i) {
for (int j = sy; j < cy; ++j) { for (int j = sy; j < cy; ++j) {
p.drawPixmap(QPointF(i * w, j * h), bg); p.drawPixmap(QPointF(i * w, j * h), bg);
@ -3200,7 +3200,7 @@ void MainWidget::updateControlsGeometry() {
_dialogs->stopWidthAnimation(); _dialogs->stopWidthAnimation();
} }
auto sectionTop = getSectionTop(); auto sectionTop = getSectionTop();
auto dialogsWidth = qRound(_a_dialogsWidth.current(_dialogsWidth)); int dialogsWidth = std::round(_a_dialogsWidth.current(_dialogsWidth));
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
if (_callTopBar) { if (_callTopBar) {
_callTopBar->resizeToWidth(dialogsWidth); _callTopBar->resizeToWidth(dialogsWidth);
@ -3384,8 +3384,8 @@ void MainWidget::updateWindowAdaptiveLayout() {
if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) { if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) {
auto thirdColumnWidth = _history->tabbedSelectorSectionWidth(); auto thirdColumnWidth = _history->tabbedSelectorSectionWidth();
auto twoColumnsWidth = (layout.bodyWidth - thirdColumnWidth); auto twoColumnsWidth = (layout.bodyWidth - thirdColumnWidth);
auto sameRatioChatWidth = twoColumnsWidth - qRound(dialogsWidthRatio * twoColumnsWidth); int sameRatioChatWidth = twoColumnsWidth - std::round(dialogsWidthRatio * twoColumnsWidth);
auto desiredChatWidth = qMax(sameRatioChatWidth, HistoryLayout::WideChatWidth()); auto desiredChatWidth = std::max(sameRatioChatWidth, HistoryLayout::WideChatWidth());
chatWidth -= thirdColumnWidth; chatWidth -= thirdColumnWidth;
auto extendChatBy = desiredChatWidth - chatWidth; auto extendChatBy = desiredChatWidth - chatWidth;
accumulate_min(extendChatBy, layout.dialogsWidth - st::dialogsWidthMin); accumulate_min(extendChatBy, layout.dialogsWidth - st::dialogsWidthMin);
@ -3824,7 +3824,7 @@ void MainWidget::onGetDifferenceTimeByPts() {
} }
for (ChannelGetDifferenceTime::iterator i = _channelGetDifferenceTimeByPts.begin(); i != _channelGetDifferenceTimeByPts.cend();) { for (ChannelGetDifferenceTime::iterator i = _channelGetDifferenceTimeByPts.begin(); i != _channelGetDifferenceTimeByPts.cend();) {
if (i.value() > now) { if (i.value() > now) {
wait = wait ? qMin(wait, i.value() - now) : (i.value() - now); wait = wait ? std::min(wait, i.value() - now) : (i.value() - now);
++i; ++i;
} else { } else {
getChannelDifference(i.key(), ChannelDifferenceRequest::PtsGapOrShortPoll); getChannelDifference(i.key(), ChannelDifferenceRequest::PtsGapOrShortPoll);
@ -3851,7 +3851,7 @@ void MainWidget::onGetDifferenceTimeAfterFail() {
} }
for (auto i = _channelGetDifferenceTimeAfterFail.begin(); i != _channelGetDifferenceTimeAfterFail.cend();) { for (auto i = _channelGetDifferenceTimeAfterFail.begin(); i != _channelGetDifferenceTimeAfterFail.cend();) {
if (i.value() > now) { if (i.value() > now) {
wait = wait ? qMin(wait, i.value() - now) : (i.value() - now); wait = wait ? std::min(wait, i.value() - now) : (i.value() - now);
++i; ++i;
} else { } else {
getChannelDifference(i.key(), ChannelDifferenceRequest::AfterFail); getChannelDifference(i.key(), ChannelDifferenceRequest::AfterFail);
@ -4415,7 +4415,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
_idleFinishTimer.start(900); _idleFinishTimer.start(900);
} }
} else { } else {
updateIn = qMin(updateIn, int(Global::OfflineIdleTimeout() - idle)); updateIn = std::min(updateIn, int(Global::OfflineIdleTimeout() - idle));
} }
} }
auto ms = getms(true); auto ms = getms(true);
@ -4441,7 +4441,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
updateOnlineDisplay(); updateOnlineDisplay();
} else if (isOnline) { } else if (isOnline) {
updateIn = qMin(updateIn, int(_lastSetOnline + Global::OnlineUpdatePeriod() - ms)); updateIn = std::min(updateIn, int(_lastSetOnline + Global::OnlineUpdatePeriod() - ms));
} }
_onlineTimer.start(updateIn); _onlineTimer.start(updateIn);
} }

View File

@ -317,7 +317,7 @@ void Mixer::Track::reattach(AudioMsgId::Type type) {
alSourceQueueBuffers(stream.source, 1, stream.buffers + i); alSourceQueueBuffers(stream.source, 1, stream.buffers + i);
} }
alSourcei(stream.source, AL_SAMPLE_OFFSET, qMax(state.position - bufferedPosition, Q_INT64_C(0))); alSourcei(stream.source, AL_SAMPLE_OFFSET, std::max(state.position - bufferedPosition, Q_INT64_C(0)));
if (!IsStopped(state.state) && state.state != State::PausedAtEnd) { if (!IsStopped(state.state) && state.state != State::PausedAtEnd) {
alSourcef(stream.source, AL_GAIN, ComputeVolume(type)); alSourcef(stream.source, AL_GAIN, ComputeVolume(type));
alSourcePlay(stream.source); alSourcePlay(stream.source);
@ -830,7 +830,7 @@ void Mixer::resume(const AudioMsgId &audio, bool fast) {
Audio::AttachToDevice(); Audio::AttachToDevice();
if (track->state.state == State::PausedAtEnd) { if (track->state.state == State::PausedAtEnd) {
if (track->isStreamCreated()) { if (track->isStreamCreated()) {
alSourcei(track->stream.source, AL_SAMPLE_OFFSET, qMax(track->state.position - track->bufferedPosition, Q_INT64_C(0))); alSourcei(track->stream.source, AL_SAMPLE_OFFSET, std::max(track->state.position - track->bufferedPosition, Q_INT64_C(0)));
if (!checkCurrentALError(type)) return; if (!checkCurrentALError(type)) return;
} }
} }
@ -1067,7 +1067,7 @@ void Mixer::reattachTracks() {
} }
void Mixer::setSongVolume(double volume) { void Mixer::setSongVolume(double volume) {
_volumeSong.storeRelease(qRound(volume * kVolumeRound)); _volumeSong.storeRelease(std::round(volume * kVolumeRound));
} }
double Mixer::getSongVolume() const { double Mixer::getSongVolume() const {
@ -1075,7 +1075,7 @@ double Mixer::getSongVolume() const {
} }
void Mixer::setVideoVolume(double volume) { void Mixer::setVideoVolume(double volume) {
_volumeVideo.storeRelease(qRound(volume * kVolumeRound)); _volumeVideo.storeRelease(std::round(volume * kVolumeRound));
} }
double Mixer::getVideoVolume() const { double Mixer::getVideoVolume() const {
@ -1555,11 +1555,11 @@ public:
} }
auto sum = std::accumulate(peaks.cbegin(), peaks.cend(), 0LL); auto sum = std::accumulate(peaks.cbegin(), peaks.cend(), 0LL);
peak = qMax(qint32(sum * 1.8 / peaks.size()), 2500); peak = std::max(qint32(sum * 1.8 / peaks.size()), 2500);
result.resize(peaks.size()); result.resize(peaks.size());
for (qint32 i = 0, l = peaks.size(); i != l; ++i) { for (qint32 i = 0, l = peaks.size(); i != l; ++i) {
result[i] = char(qMin(31U, quint32(qMin(peaks.at(i), peak)) * 31 / peak)); result[i] = char(std::min(31U, quint32(std::min(peaks.at(i), peak)) * 31 / peak));
} }
return true; return true;

View File

@ -126,7 +126,7 @@ struct Instance::Inner::Private {
static int _read_data(void *opaque, uint8_t *buf, int buf_size) { static int _read_data(void *opaque, uint8_t *buf, int buf_size) {
auto l = reinterpret_cast<Private*>(opaque); auto l = reinterpret_cast<Private*>(opaque);
qint32 nbytes = qMin(l->data.size() - l->dataPos, qint32(buf_size)); qint32 nbytes = std::min(l->data.size() - l->dataPos, qint32(buf_size));
if (nbytes <= 0) { if (nbytes <= 0) {
return 0; return 0;
} }
@ -360,7 +360,7 @@ void Instance::Inner::onStop(bool needResult) {
double coef = 1. / fadeSamples, fadedFrom = 0; double coef = 1. / fadeSamples, fadedFrom = 0;
for (short *ptr = ((short*)_captured.data()) + capturedSamples, *end = ptr - fadeSamples; ptr != end; ++fadedFrom) { for (short *ptr = ((short*)_captured.data()) + capturedSamples, *end = ptr - fadeSamples; ptr != end; ++fadedFrom) {
--ptr; --ptr;
*ptr = qRound(fadedFrom * coef * *ptr); *ptr = std::round(fadedFrom * coef * *ptr);
} }
if (capturedSamples % d->srcSamples) { if (capturedSamples % d->srcSamples) {
qint32 s = _captured.size(); qint32 s = _captured.size();
@ -416,11 +416,11 @@ void Instance::Inner::onStop(bool needResult) {
} }
auto sum = std::accumulate(peaks.cbegin(), peaks.cend(), 0LL); auto sum = std::accumulate(peaks.cbegin(), peaks.cend(), 0LL);
peak = qMax(qint32(sum * 1.8 / peaks.size()), 2500); peak = std::max(qint32(sum * 1.8 / peaks.size()), 2500);
waveform.resize(peaks.size()); waveform.resize(peaks.size());
for (qint32 i = 0, l = peaks.size(); i != l; ++i) { for (qint32 i = 0, l = peaks.size(); i != l; ++i) {
waveform[i] = char(qMin(31U, quint32(qMin(peaks.at(i), peak)) * 31 / peak)); waveform[i] = char(std::min(31U, quint32(std::min(peaks.at(i), peak)) * 31 / peak));
} }
} }
} }
@ -517,7 +517,7 @@ void Instance::Inner::onTimeout() {
if (levelindex > skipSamples) { if (levelindex > skipSamples) {
quint16 value = qAbs(*ptr); quint16 value = qAbs(*ptr);
if (levelindex < skipSamples + fadeSamples) { if (levelindex < skipSamples + fadeSamples) {
value = qRound(value * double(levelindex - skipSamples) / fadeSamples); value = std::round(value * double(levelindex - skipSamples) / fadeSamples);
} }
if (d->levelMax < value) { if (d->levelMax < value) {
d->levelMax = value; d->levelMax = value;
@ -569,14 +569,14 @@ void Instance::Inner::processFrame(qint32 offset, qint32 framesize) {
auto skipSamples = static_cast<int>(kCaptureSkipDuration * kCaptureFrequency / 1000); auto skipSamples = static_cast<int>(kCaptureSkipDuration * kCaptureFrequency / 1000);
auto fadeSamples = static_cast<int>(kCaptureFadeInDuration * kCaptureFrequency / 1000); auto fadeSamples = static_cast<int>(kCaptureFadeInDuration * kCaptureFrequency / 1000);
if (d->fullSamples < skipSamples + fadeSamples) { if (d->fullSamples < skipSamples + fadeSamples) {
qint32 fadedCnt = qMin(samplesCnt, skipSamples + fadeSamples - d->fullSamples); qint32 fadedCnt = std::min(samplesCnt, skipSamples + fadeSamples - d->fullSamples);
double coef = 1. / fadeSamples, fadedFrom = d->fullSamples - skipSamples; double coef = 1. / fadeSamples, fadedFrom = d->fullSamples - skipSamples;
short *ptr = srcSamplesDataChannel, *zeroEnd = ptr + qMin(samplesCnt, qMax(0, skipSamples - d->fullSamples)), *end = ptr + fadedCnt; short *ptr = srcSamplesDataChannel, *zeroEnd = ptr + std::min(samplesCnt, std::max(0, skipSamples - d->fullSamples)), *end = ptr + fadedCnt;
for (; ptr != zeroEnd; ++ptr, ++fadedFrom) { for (; ptr != zeroEnd; ++ptr, ++fadedFrom) {
*ptr = 0; *ptr = 0;
} }
for (; ptr != end; ++ptr, ++fadedFrom) { for (; ptr != end; ++ptr, ++fadedFrom) {
*ptr = qRound(fadedFrom * coef * *ptr); *ptr = std::round(fadedFrom * coef * *ptr);
} }
} }

View File

@ -92,7 +92,7 @@ AbstractFFMpegLoader::~AbstractFFMpegLoader() {
int AbstractFFMpegLoader::_read_data(void *opaque, uint8_t *buf, int buf_size) { int AbstractFFMpegLoader::_read_data(void *opaque, uint8_t *buf, int buf_size) {
auto l = reinterpret_cast<AbstractFFMpegLoader*>(opaque); auto l = reinterpret_cast<AbstractFFMpegLoader*>(opaque);
auto nbytes = qMin(l->_data.size() - l->_dataPos, qint32(buf_size)); auto nbytes = std::min(l->_data.size() - l->_dataPos, qint32(buf_size));
if (nbytes <= 0) { if (nbytes <= 0) {
return 0; return 0;
} }
@ -125,7 +125,7 @@ int64_t AbstractFFMpegLoader::_seek_data(void *opaque, int64_t offset, int whenc
int AbstractFFMpegLoader::_read_bytes(void *opaque, uint8_t *buf, int buf_size) { int AbstractFFMpegLoader::_read_bytes(void *opaque, uint8_t *buf, int buf_size) {
auto l = reinterpret_cast<AbstractFFMpegLoader*>(opaque); auto l = reinterpret_cast<AbstractFFMpegLoader*>(opaque);
auto nbytes = qMin(static_cast<int>(l->_bytes.size()) - l->_dataPos, buf_size); auto nbytes = std::min(static_cast<int>(l->_bytes.size()) - l->_dataPos, buf_size);
if (nbytes <= 0) { if (nbytes <= 0) {
return 0; return 0;
} }

View File

@ -211,7 +211,7 @@ TimeMs FFMpegReaderImplementation::frameRealTime() const {
} }
TimeMs FFMpegReaderImplementation::framePresentationTime() const { TimeMs FFMpegReaderImplementation::framePresentationTime() const {
return qMax(_frameTime + _frameTimeCorrection, Q_INT64_C(0)); return std::max(_frameTime + _frameTimeCorrection, Q_INT64_C(0));
} }
TimeMs FFMpegReaderImplementation::durationMs() const { TimeMs FFMpegReaderImplementation::durationMs() const {
@ -240,7 +240,7 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q
} }
hasAlpha = (_frame->format == AV_PIX_FMT_BGRA || (_frame->format == -1 && _codecContext->pix_fmt == AV_PIX_FMT_BGRA)); hasAlpha = (_frame->format == AV_PIX_FMT_BGRA || (_frame->format == -1 && _codecContext->pix_fmt == AV_PIX_FMT_BGRA));
if (_frame->width == toSize.width() && _frame->height == toSize.height() && hasAlpha) { if (_frame->width == toSize.width() && _frame->height == toSize.height() && hasAlpha) {
qint32 sbpl = _frame->linesize[0], dbpl = to.bytesPerLine(), bpl = qMin(sbpl, dbpl); qint32 sbpl = _frame->linesize[0], dbpl = to.bytesPerLine(), bpl = std::min(sbpl, dbpl);
uchar *s = _frame->data[0], *d = to.bits(); uchar *s = _frame->data[0], *d = to.bits();
for (qint32 i = 0, l = _frame->height; i < l; ++i) { for (qint32 i = 0, l = _frame->height; i < l; ++i) {
memcpy(d + i * dbpl, s + i * sbpl, bpl); memcpy(d + i * dbpl, s + i * sbpl, bpl);

View File

@ -47,7 +47,7 @@ TimeMs QtGifReaderImplementation::frameRealTime() const {
} }
TimeMs QtGifReaderImplementation::framePresentationTime() const { TimeMs QtGifReaderImplementation::framePresentationTime() const {
return qMax(_frameTime, Q_INT64_C(0)); return std::max(_frameTime, Q_INT64_C(0));
} }
ReaderImplementation::ReadResult QtGifReaderImplementation::readNextFrame() { ReaderImplementation::ReadResult QtGifReaderImplementation::readNextFrame() {
@ -76,7 +76,7 @@ bool QtGifReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const QS
qint32 w = _frame.width(), h = _frame.height(); qint32 w = _frame.width(), h = _frame.height();
if (to.width() == w && to.height() == h && to.format() == _frame.format()) { if (to.width() == w && to.height() == h && to.format() == _frame.format()) {
if (to.byteCount() != _frame.byteCount()) { if (to.byteCount() != _frame.byteCount()) {
int bpl = qMin(to.bytesPerLine(), _frame.bytesPerLine()); int bpl = std::min(to.bytesPerLine(), _frame.bytesPerLine());
for (int i = 0; i < h; ++i) { for (int i = 0; i < h; ++i) {
memcpy(to.scanLine(i), _frame.constScanLine(i), bpl); memcpy(to.scanLine(i), _frame.constScanLine(i), bpl);
} }

View File

@ -63,12 +63,12 @@ QImage PrepareFrameImage(const FrameRequest &request, const QImage &original, bo
p.fillRect((request.outerw - request.framew) / (2 * factor) + (request.framew / factor), 0, (cache.width() / factor) - ((request.outerw - request.framew) / (2 * factor) + (request.framew / factor)), cache.height() / factor, st::imageBg); p.fillRect((request.outerw - request.framew) / (2 * factor) + (request.framew / factor), 0, (cache.width() / factor) - ((request.outerw - request.framew) / (2 * factor) + (request.framew / factor)), cache.height() / factor, st::imageBg);
} }
if (request.frameh < request.outerh) { if (request.frameh < request.outerh) {
p.fillRect(qMax(0, (request.outerw - request.framew) / (2 * factor)), 0, qMin(cache.width(), request.framew) / factor, (request.outerh - request.frameh) / (2 * factor), st::imageBg); p.fillRect(std::max(0, (request.outerw - request.framew) / (2 * factor)), 0, std::min(cache.width(), request.framew) / factor, (request.outerh - request.frameh) / (2 * factor), st::imageBg);
p.fillRect(qMax(0, (request.outerw - request.framew) / (2 * factor)), (request.outerh - request.frameh) / (2 * factor) + (request.frameh / factor), qMin(cache.width(), request.framew) / factor, (cache.height() / factor) - ((request.outerh - request.frameh) / (2 * factor) + (request.frameh / factor)), st::imageBg); p.fillRect(std::max(0, (request.outerw - request.framew) / (2 * factor)), (request.outerh - request.frameh) / (2 * factor) + (request.frameh / factor), std::min(cache.width(), request.framew) / factor, (cache.height() / factor) - ((request.outerh - request.frameh) / (2 * factor) + (request.frameh / factor)), st::imageBg);
} }
} }
if (hasAlpha) { if (hasAlpha) {
p.fillRect(qMax(0, (request.outerw - request.framew) / (2 * factor)), qMax(0, (request.outerh - request.frameh) / (2 * factor)), qMin(cache.width(), request.framew) / factor, qMin(cache.height(), request.frameh) / factor, st::imageBgTransparent); p.fillRect(std::max(0, (request.outerw - request.framew) / (2 * factor)), std::max(0, (request.outerh - request.frameh) / (2 * factor)), std::min(cache.width(), request.framew) / factor, std::min(cache.height(), request.frameh) / factor, st::imageBgTransparent);
} }
auto position = QPoint((request.outerw - request.framew) / (2 * factor), (request.outerh - request.frameh) / (2 * factor)); auto position = QPoint((request.outerw - request.framew) / (2 * factor), (request.outerh - request.frameh) / (2 * factor));
if (needResize) { if (needResize) {

View File

@ -171,7 +171,7 @@ void CoverWidget::handleSeekFinished(double progress) {
auto type = AudioMsgId::Type::Song; auto type = AudioMsgId::Type::Song;
auto state = Media::Player::mixer()->currentState(type); auto state = Media::Player::mixer()->currentState(type);
if (state.id && state.length) { if (state.id && state.length) {
Media::Player::mixer()->seek(type, qRound(progress * state.length)); Media::Player::mixer()->seek(type, std::round(progress * state.length));
} }
instance()->stopSeeking(type); instance()->stopSeeking(type);
@ -286,7 +286,7 @@ void CoverWidget::updateTimeText(const TrackState &state) {
_lastDurationMs = (state.length * 1000LL) / frequency; _lastDurationMs = (state.length * 1000LL) / frequency;
if (state.id.audio()->loading()) { if (state.id.audio()->loading()) {
_time = QString::number(qRound(state.id.audio()->progress() * 100)) + '%'; _time = QString::number(std::round(state.id.audio()->progress() * 100)) + '%';
_playbackSlider->setDisabled(true); _playbackSlider->setDisabled(true);
} else { } else {
display = display / frequency; display = display / frequency;

View File

@ -172,7 +172,7 @@ void Float::paintEvent(QPaintEvent *e) {
p.setOpacity(_opacity * st::historyVideoMessageProgressOpacity); p.setOpacity(_opacity * st::historyVideoMessageProgressOpacity);
auto from = QuarterArcLength; auto from = QuarterArcLength;
auto len = -qRound(FullArcLength * progress); auto len = -std::round(FullArcLength * progress);
auto stepInside = st::radialLine / 2; auto stepInside = st::radialLine / 2;
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);

View File

@ -86,7 +86,7 @@ void Panel::updateControlsGeometry() {
_scrollShadow->moveToRight(contentRight(), scrollTop); _scrollShadow->moveToRight(contentRight(), scrollTop);
} }
} }
auto scrollHeight = qMax(height() - scrollTop - contentBottom() - scrollMarginBottom(), 0); auto scrollHeight = std::max(height() - scrollTop - contentBottom() - scrollMarginBottom(), 0);
if (scrollHeight > 0) { if (scrollHeight > 0) {
_scroll->setGeometryToRight(contentRight(), scrollTop, width, scrollHeight); _scroll->setGeometryToRight(contentRight(), scrollTop, width, scrollHeight);
} }
@ -136,7 +136,7 @@ void Panel::updateSize() {
listHeight = widget->height(); listHeight = widget->height();
} }
auto scrollVisible = (listHeight > 0); auto scrollVisible = (listHeight > 0);
auto scrollHeight = scrollVisible ? (qMin(listHeight, st::mediaPlayerListHeightMax) + st::mediaPlayerListMarginBottom) : 0; auto scrollHeight = scrollVisible ? (std::min(listHeight, st::mediaPlayerListHeightMax) + st::mediaPlayerListMarginBottom) : 0;
height += scrollHeight + contentBottom(); height += scrollHeight + contentBottom();
resize(width, height); resize(width, height);
_scroll->setVisible(scrollVisible); _scroll->setVisible(scrollVisible);

View File

@ -253,7 +253,7 @@ void Widget::handleSeekFinished(double progress) {
auto state = mixer()->currentState(_type); auto state = mixer()->currentState(_type);
if (state.id && state.length) { if (state.id && state.length) {
mixer()->seek(_type, qRound(progress * state.length)); mixer()->seek(_type, std::round(progress * state.length));
} }
instance()->stopSeeking(_type); instance()->stopSeeking(_type);
@ -443,7 +443,7 @@ void Widget::updateTimeText(const TrackState &state) {
_lastDurationMs = (state.length * 1000LL) / frequency; _lastDurationMs = (state.length * 1000LL) / frequency;
if (state.id.audio()->loading()) { if (state.id.audio()->loading()) {
_time = QString::number(qRound(state.id.audio()->progress() * 100)) + '%'; _time = QString::number(std::round(state.id.audio()->progress() * 100)) + '%';
_playbackSlider->setDisabled(true); _playbackSlider->setDisabled(true);
} else { } else {
display = display / frequency; display = display / frequency;

View File

@ -61,7 +61,7 @@ void Playback::updateState(const Player::TrackState &state) {
progress = snap(double(position) / length, 0., 1.); progress = snap(double(position) / length, 0., 1.);
} }
auto animatedPosition = position + (state.frequency * kPlaybackAnimationDurationMs / 1000); auto animatedPosition = position + (state.frequency * kPlaybackAnimationDurationMs / 1000);
auto animatedProgress = length ? qMax(double(animatedPosition) / length, 0.) : 0.; auto animatedProgress = length ? std::max(double(animatedPosition) / length, 0.) : 0.;
if (length != _length || position != _position || wasInLoadingState) { if (length != _length || position != _position || wasInLoadingState) {
if (auto animated = (length && _length && animatedProgress > value())) { if (auto animated = (length && _length && animatedProgress > value())) {
setValue(animatedProgress, animated); setValue(animatedProgress, animated);
@ -85,7 +85,7 @@ void Playback::updateLoadingState(double progress) {
} }
double Playback::value() const { double Playback::value() const {
return qMin(a_value.current(), 1.); return std::min(a_value.current(), 1.);
} }
double Playback::value(TimeMs ms) { double Playback::value(TimeMs ms) {

View File

@ -41,7 +41,7 @@ void VolumeController::paintEvent(QPaintEvent *e) {
qint32 top = st::mediaviewVolumeIconTop; qint32 top = st::mediaviewVolumeIconTop;
qint32 left = (width() - st::mediaviewVolumeIcon.width()) / 2; qint32 left = (width() - st::mediaviewVolumeIcon.width()) / 2;
qint32 mid = left + qRound(st::mediaviewVolumeIcon.width() * _volume); qint32 mid = left + std::round(st::mediaviewVolumeIcon.width() * _volume);
qint32 right = left + st::mediaviewVolumeIcon.width(); qint32 right = left + st::mediaviewVolumeIcon.width();
if (mid > left) { if (mid > left) {

View File

@ -386,7 +386,7 @@ void MediaView::updateControls() {
} }
if (_from) { if (_from) {
_fromName.setText(st::mediaviewTextStyle, (_from->migrateTo() ? _from->migrateTo() : _from)->name, _textNameOptions); _fromName.setText(st::mediaviewTextStyle, (_from->migrateTo() ? _from->migrateTo() : _from)->name, _textNameOptions);
_nameNav = myrtlrect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, qMin(_fromName.maxWidth(), width() / 3), st::mediaviewFont->height); _nameNav = myrtlrect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, std::min(_fromName.maxWidth(), width() / 3), st::mediaviewFont->height);
_dateNav = myrtlrect(st::mediaviewTextLeft + _nameNav.width() + st::mediaviewTextSkip, height() - st::mediaviewTextTop, st::mediaviewFont->width(_dateText), st::mediaviewFont->height); _dateNav = myrtlrect(st::mediaviewTextLeft + _nameNav.width() + st::mediaviewTextSkip, height() - st::mediaviewTextTop, st::mediaviewFont->width(_dateText), st::mediaviewFont->height);
} else { } else {
_nameNav = QRect(); _nameNav = QRect();
@ -417,9 +417,9 @@ void MediaView::updateControls() {
} }
if (!_caption.isEmpty()) { if (!_caption.isEmpty()) {
qint32 skipw = qMax(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); qint32 skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width());
qint32 maxw = qMin(qMax(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); qint32 maxw = std::min(std::max(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth());
qint32 maxh = qMin(_caption.countHeight(maxw), int(height() / 4 - st::mediaviewCaptionPadding.top() - st::mediaviewCaptionPadding.bottom() - 2 * st::mediaviewCaptionMargin.height())); qint32 maxh = std::min(_caption.countHeight(maxw), int(height() / 4 - st::mediaviewCaptionPadding.top() - st::mediaviewCaptionPadding.bottom() - 2 * st::mediaviewCaptionMargin.height()));
_captionRect = QRect((width() - maxw) / 2, height() - maxh - st::mediaviewCaptionPadding.bottom() - st::mediaviewCaptionMargin.height(), maxw, maxh); _captionRect = QRect((width() - maxw) / 2, height() - maxh - st::mediaviewCaptionPadding.bottom() - st::mediaviewCaptionMargin.height(), maxw, maxh);
} else { } else {
_captionRect = QRect(); _captionRect = QRect();
@ -576,8 +576,8 @@ void MediaView::step_radial(TimeMs ms, bool timer) {
void MediaView::zoomIn() { void MediaView::zoomIn() {
qint32 newZoom = _zoom; qint32 newZoom = _zoom;
if (newZoom == ZoomToScreenLevel) { if (newZoom == ZoomToScreenLevel) {
if (qCeil(_zoomToScreen) <= MaxZoomLevel) { if (std::ceil(_zoomToScreen) <= MaxZoomLevel) {
newZoom = qCeil(_zoomToScreen); newZoom = std::ceil(_zoomToScreen);
} }
} else { } else {
if (newZoom < _zoomToScreen && (newZoom + 1 > _zoomToScreen || (_zoomToScreen > MaxZoomLevel && newZoom == MaxZoomLevel))) { if (newZoom < _zoomToScreen && (newZoom + 1 > _zoomToScreen || (_zoomToScreen > MaxZoomLevel && newZoom == MaxZoomLevel))) {
@ -592,8 +592,8 @@ void MediaView::zoomIn() {
void MediaView::zoomOut() { void MediaView::zoomOut() {
qint32 newZoom = _zoom; qint32 newZoom = _zoom;
if (newZoom == ZoomToScreenLevel) { if (newZoom == ZoomToScreenLevel) {
if (qFloor(_zoomToScreen) >= -MaxZoomLevel) { if (std::floor(_zoomToScreen) >= -MaxZoomLevel) {
newZoom = qFloor(_zoomToScreen); newZoom = std::floor(_zoomToScreen);
} }
} else { } else {
if (newZoom > _zoomToScreen && (newZoom - 1 < _zoomToScreen || (_zoomToScreen < -MaxZoomLevel && newZoom == -MaxZoomLevel))) { if (newZoom > _zoomToScreen && (newZoom - 1 < _zoomToScreen || (_zoomToScreen < -MaxZoomLevel && newZoom == -MaxZoomLevel))) {
@ -608,8 +608,8 @@ void MediaView::zoomOut() {
void MediaView::zoomReset() { void MediaView::zoomReset() {
qint32 newZoom = _zoom; qint32 newZoom = _zoom;
if (_zoom == 0) { if (_zoom == 0) {
if (qFloor(_zoomToScreen) == qCeil(_zoomToScreen) && qRound(_zoomToScreen) >= -MaxZoomLevel && qRound(_zoomToScreen) <= MaxZoomLevel) { if (std::floor(_zoomToScreen) == std::ceil(_zoomToScreen) && std::round(_zoomToScreen) >= -MaxZoomLevel && std::round(_zoomToScreen) <= MaxZoomLevel) {
newZoom = qRound(_zoomToScreen); newZoom = std::round(_zoomToScreen);
} else { } else {
newZoom = ZoomToScreenLevel; newZoom = ZoomToScreenLevel;
} }
@ -620,11 +620,11 @@ void MediaView::zoomReset() {
_y = -((gifShown() ? _gif->height() : (_current.height() / cIntRetinaFactor())) / 2); _y = -((gifShown() ? _gif->height() : (_current.height() / cIntRetinaFactor())) / 2);
double z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; double z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
if (z >= 0) { if (z >= 0) {
_x = qRound(_x * (z + 1)); _x = std::round(_x * (z + 1));
_y = qRound(_y * (z + 1)); _y = std::round(_y * (z + 1));
} else { } else {
_x = qRound(_x / (-z + 1)); _x = std::round(_x / (-z + 1));
_y = qRound(_y / (-z + 1)); _y = std::round(_y / (-z + 1));
} }
_x += width() / 2; _x += width() / 2;
_y += height() / 2; _y += height() / 2;
@ -1204,8 +1204,8 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) {
if (auto photoMsg = dynamic_cast<HistoryPhoto*>(itemMsg->getMedia())) { if (auto photoMsg = dynamic_cast<HistoryPhoto*>(itemMsg->getMedia())) {
auto asBot = (item->author()->isUser() auto asBot = (item->author()->isUser()
&& item->author()->asUser()->botInfo); && item->author()->asUser()->botInfo);
auto skipw = qMax(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); auto skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width());
auto maxw = qMin(qMax(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); auto maxw = std::min(std::max(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth());
_caption = Text(maxw); _caption = Text(maxw);
_caption.setMarkedText( _caption.setMarkedText(
st::mediaviewCaptionStyle, st::mediaviewCaptionStyle,
@ -1225,11 +1225,11 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) {
moveToScreen(); moveToScreen();
} }
if (_w > width()) { if (_w > width()) {
_h = qRound(_h * width() / double(_w)); _h = std::round(_h * width() / double(_w));
_w = width(); _w = width();
} }
if (_h > height()) { if (_h > height()) {
_w = qRound(_w * height() / double(_h)); _w = std::round(_w * height() / double(_h));
_h = height(); _h = height();
} }
_x = (width() - _w) / 2; _x = (width() - _w) / 2;
@ -1377,11 +1377,11 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty
if ((_w > width()) || (_h > height()) || _fullScreenVideo) { if ((_w > width()) || (_h > height()) || _fullScreenVideo) {
_zoom = ZoomToScreenLevel; _zoom = ZoomToScreenLevel;
if (_zoomToScreen >= 0) { if (_zoomToScreen >= 0) {
_w = qRound(_w * (_zoomToScreen + 1)); _w = std::round(_w * (_zoomToScreen + 1));
_h = qRound(_h * (_zoomToScreen + 1)); _h = std::round(_h * (_zoomToScreen + 1));
} else { } else {
_w = qRound(_w / (-_zoomToScreen + 1)); _w = std::round(_w / (-_zoomToScreen + 1));
_h = qRound(_h / (-_zoomToScreen + 1)); _h = std::round(_h / (-_zoomToScreen + 1));
} }
snapXY(); snapXY();
} else { } else {
@ -1403,8 +1403,8 @@ void MediaView::updateThemePreviewGeometry() {
auto previewRect = QRect((width() - st::themePreviewSize.width()) / 2, (height() - st::themePreviewSize.height()) / 2, st::themePreviewSize.width(), st::themePreviewSize.height()); auto previewRect = QRect((width() - st::themePreviewSize.width()) / 2, (height() - st::themePreviewSize.height()) / 2, st::themePreviewSize.width(), st::themePreviewSize.height());
_themePreviewRect = previewRect.marginsAdded(st::themePreviewMargin); _themePreviewRect = previewRect.marginsAdded(st::themePreviewMargin);
if (_themeApply) { if (_themeApply) {
auto right = qMax(width() - _themePreviewRect.x() - _themePreviewRect.width(), 0) + st::themePreviewMargin.right(); auto right = std::max(width() - _themePreviewRect.x() - _themePreviewRect.width(), 0) + st::themePreviewMargin.right();
auto bottom = qMin(height(), _themePreviewRect.y() + _themePreviewRect.height()); auto bottom = std::min(height(), _themePreviewRect.y() + _themePreviewRect.height());
_themeApply->moveToRight(right, bottom - st::themePreviewMargin.bottom() + (st::themePreviewMargin.bottom() - _themeApply->height()) / 2); _themeApply->moveToRight(right, bottom - st::themePreviewMargin.bottom() + (st::themePreviewMargin.bottom() - _themeApply->height()) / 2);
right += _themeApply->width() + st::themePreviewButtonsSkip; right += _themeApply->width() + st::themePreviewButtonsSkip;
_themeCancel->moveToRight(right, _themeApply->y()); _themeCancel->moveToRight(right, _themeApply->y());
@ -1782,7 +1782,7 @@ void MediaView::paintEvent(QPaintEvent *e) {
_saveMsgOpacity.start(0); _saveMsgOpacity.start(0);
} }
double progress = (hidingDt >= 0) ? (hidingDt / st::mediaviewSaveMsgHiding) : (dt / st::mediaviewSaveMsgShowing); double progress = (hidingDt >= 0) ? (hidingDt / st::mediaviewSaveMsgHiding) : (dt / st::mediaviewSaveMsgShowing);
_saveMsgOpacity.update(qMin(progress, 1.), anim::linear); _saveMsgOpacity.update(std::min(progress, 1.), anim::linear);
if (_saveMsgOpacity.current() > 0) { if (_saveMsgOpacity.current() > 0) {
p.setOpacity(_saveMsgOpacity.current()); p.setOpacity(_saveMsgOpacity.current());
App::roundRect(p, _saveMsg, st::mediaviewSaveMsgBg, MediaviewSaveCorners); App::roundRect(p, _saveMsg, st::mediaviewSaveMsgBg, MediaviewSaveCorners);
@ -2145,15 +2145,15 @@ void MediaView::setZoomLevel(int newZoom) {
_zoom = newZoom; _zoom = newZoom;
z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
if (z > 0) { if (z > 0) {
_w = qRound(_w * (z + 1)); _w = std::round(_w * (z + 1));
_h = qRound(_h * (z + 1)); _h = std::round(_h * (z + 1));
_x = qRound(nx * (z + 1) + width() / 2.); _x = std::round(nx * (z + 1) + width() / 2.);
_y = qRound(ny * (z + 1) + height() / 2.); _y = std::round(ny * (z + 1) + height() / 2.);
} else { } else {
_w = qRound(_w / (-z + 1)); _w = std::round(_w / (-z + 1));
_h = qRound(_h / (-z + 1)); _h = std::round(_h / (-z + 1));
_x = qRound(nx / (-z + 1) + width() / 2.); _x = std::round(nx / (-z + 1) + width() / 2.);
_y = qRound(ny / (-z + 1) + height() / 2.); _y = std::round(ny / (-z + 1) + height() / 2.);
} }
snapXY(); snapXY();
update(); update();

View File

@ -1139,7 +1139,7 @@ void ConnectionPrivate::onReceivedSome() {
qint32 ms = getms(true) - firstSentAt; qint32 ms = getms(true) - firstSentAt;
DEBUG_LOG(("MTP Info: response in %1ms, _waitForReceived: %2ms").arg(ms).arg(_waitForReceived)); DEBUG_LOG(("MTP Info: response in %1ms, _waitForReceived: %2ms").arg(ms).arg(_waitForReceived));
if (ms > 0 && ms * 2 < qint32(_waitForReceived)) _waitForReceived = qMax(ms * 2, qint32(MTPMinReceiveDelay)); if (ms > 0 && ms * 2 < qint32(_waitForReceived)) _waitForReceived = std::max(ms * 2, qint32(MTPMinReceiveDelay));
firstSentAt = -1; firstSentAt = -1;
} }
} }

View File

@ -221,9 +221,9 @@ void Photo::initDimensions() {
} }
qint32 Photo::resizeGetHeight(qint32 width) { qint32 Photo::resizeGetHeight(qint32 width) {
width = qMin(width, _maxw); width = std::min(width, _maxw);
if (width != _width || width != _height) { if (width != _width || width != _height) {
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
_height = _width; _height = _width;
} }
return _height; return _height;
@ -321,7 +321,7 @@ void Video::initDimensions() {
} }
qint32 Video::resizeGetHeight(qint32 width) { qint32 Video::resizeGetHeight(qint32 width) {
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
_height = _width; _height = _width;
return _height; return _height;
} }
@ -866,7 +866,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
} }
int availwidth = _width - nameleft - nameright; int availwidth = _width - nameleft - nameright;
int namewidth = qMin(availwidth, _name.maxWidth()); int namewidth = std::min(availwidth, _name.maxWidth());
if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) { if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) {
p.setPen(st::historyFileNameInFg); p.setPen(st::historyFileNameInFg);
_name.drawLeftElided(p, nameleft, nametop, namewidth, _width); _name.drawLeftElided(p, nameleft, nametop, namewidth, _width);
@ -929,7 +929,7 @@ void Document::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoin
link = _namel; link = _namel;
return; return;
} }
if (rtlrect(nameleft, nametop, qMin(_width - nameleft - nameright, _name.maxWidth()), st::semiboldFont->height, _width).contains(point)) { if (rtlrect(nameleft, nametop, std::min(_width - nameleft - nameright, _name.maxWidth()), st::semiboldFont->height, _width).contains(point)) {
link = _namel; link = _namel;
return; return;
} }
@ -1064,8 +1064,8 @@ Link::Link(HistoryMedia *media, HistoryItem *parent) : ItemBase(parent) {
th = st::linksPhotoSize; th = st::linksPhotoSize;
} }
} }
_pixw = qMax(tw, 1); _pixw = std::max(tw, 1);
_pixh = qMax(th, 1); _pixh = std::max(th, 1);
if (_page) { if (_page) {
_title = _page->title; _title = _page->title;
@ -1101,14 +1101,14 @@ void Link::initDimensions() {
_minh += st::semiboldFont->height; _minh += st::semiboldFont->height;
} }
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
_minh += qMin(3 * st::normalFont->height, _text.countHeight(_maxw - st::linksPhotoSize - st::linksPhotoPadding)); _minh += std::min(3 * st::normalFont->height, _text.countHeight(_maxw - st::linksPhotoSize - st::linksPhotoPadding));
} }
_minh += _links.size() * st::normalFont->height; _minh += _links.size() * st::normalFont->height;
_minh = qMax(_minh, qint32(st::linksPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; _minh = std::max(_minh, qint32(st::linksPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder;
} }
qint32 Link::resizeGetHeight(qint32 width) { qint32 Link::resizeGetHeight(qint32 width) {
_width = qMin(width, _maxw); _width = std::min(width, _maxw);
qint32 w = _width - st::linksPhotoSize - st::linksPhotoPadding; qint32 w = _width - st::linksPhotoSize - st::linksPhotoPadding;
for (qint32 i = 0, l = _links.size(); i < l; ++i) { for (qint32 i = 0, l = _links.size(); i < l; ++i) {
_links.at(i).lnk->setFullDisplayed(w >= _links.at(i).width); _links.at(i).lnk->setFullDisplayed(w >= _links.at(i).width);
@ -1119,10 +1119,10 @@ qint32 Link::resizeGetHeight(qint32 width) {
_height += st::semiboldFont->height; _height += st::semiboldFont->height;
} }
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
_height += qMin(3 * st::normalFont->height, _text.countHeight(_width - st::linksPhotoSize - st::linksPhotoPadding)); _height += std::min(3 * st::normalFont->height, _text.countHeight(_width - st::linksPhotoSize - st::linksPhotoPadding));
} }
_height += _links.size() * st::normalFont->height; _height += _links.size() * st::normalFont->height;
_height = qMax(_height, qint32(st::linksPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; _height = std::max(_height, qint32(st::linksPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder;
return _height; return _height;
} }
@ -1175,14 +1175,14 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
p.setPen(st::linksTextFg); p.setPen(st::linksTextFg);
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
if (clip.intersects(rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width))) { if (clip.intersects(rtlrect(left, top, std::min(w, _titlew), st::semiboldFont->height, _width))) {
p.drawTextLeft(left, top, _width, (w < _titlew) ? st::semiboldFont->elided(_title, w) : _title); p.drawTextLeft(left, top, _width, (w < _titlew) ? st::semiboldFont->elided(_title, w) : _title);
} }
top += st::semiboldFont->height; top += st::semiboldFont->height;
} }
p.setFont(st::msgFont); p.setFont(st::msgFont);
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
qint32 h = qMin(st::normalFont->height * 3, _text.countHeight(w)); qint32 h = std::min(st::normalFont->height * 3, _text.countHeight(w));
if (clip.intersects(rtlrect(left, top, w, h, _width))) { if (clip.intersects(rtlrect(left, top, w, h, _width))) {
_text.drawLeftElided(p, left, top, w, _width, 3); _text.drawLeftElided(p, left, top, w, _width, 3);
} }
@ -1191,7 +1191,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
p.setPen(st::windowActiveTextFg); p.setPen(st::windowActiveTextFg);
for (qint32 i = 0, l = _links.size(); i < l; ++i) { for (qint32 i = 0, l = _links.size(); i < l; ++i) {
if (clip.intersects(rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width))) { if (clip.intersects(rtlrect(left, top, std::min(w, _links.at(i).width), st::normalFont->height, _width))) {
p.setFont(ClickHandler::showAsActive(_links.at(i).lnk) ? st::normalFont->underline() : st::normalFont); p.setFont(ClickHandler::showAsActive(_links.at(i).lnk) ? st::normalFont->underline() : st::normalFont);
p.drawTextLeft(left, top, _width, (w < _links.at(i).width) ? st::normalFont->elided(_links.at(i).text, w) : _links.at(i).text); p.drawTextLeft(left, top, _width, (w < _links.at(i).width) ? st::normalFont->elided(_links.at(i).text, w) : _links.at(i).text);
} }
@ -1215,17 +1215,17 @@ void Link::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint po
top += (st::linksPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2; top += (st::linksPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2;
} }
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
if (rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width).contains(point)) { if (rtlrect(left, top, std::min(w, _titlew), st::semiboldFont->height, _width).contains(point)) {
link = _photol; link = _photol;
return; return;
} }
top += st::webPageTitleFont->height; top += st::webPageTitleFont->height;
} }
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
top += qMin(st::normalFont->height * 3, _text.countHeight(w)); top += std::min(st::normalFont->height * 3, _text.countHeight(w));
} }
for (qint32 i = 0, l = _links.size(); i < l; ++i) { for (qint32 i = 0, l = _links.size(); i < l; ++i) {
if (rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width).contains(point)) { if (rtlrect(left, top, std::min(w, _links.at(i).width), st::normalFont->height, _width).contains(point)) {
link = _links.at(i).lnk; link = _links.at(i).lnk;
return; return;
} }

View File

@ -348,7 +348,7 @@ void OverviewInner::repaintItem(MsgId itemId, qint32 itemIndex) {
double w = (double(_width - st::overviewPhotoSkip) / _photosInRow); double w = (double(_width - st::overviewPhotoSkip) / _photosInRow);
qint32 vsize = (_rowWidth + st::overviewPhotoSkip); qint32 vsize = (_rowWidth + st::overviewPhotoSkip);
qint32 row = itemIndex / _photosInRow, col = itemIndex % _photosInRow; qint32 row = itemIndex / _photosInRow, col = itemIndex % _photosInRow;
update(qint32(col * w), _marginTop + qint32(row * vsize), qCeil(w), vsize); update(qint32(col * w), _marginTop + qint32(row * vsize), std::ceil(w), vsize);
} else { } else {
qint32 top = _items.at(itemIndex)->Get<Overview::Layout::Info>()->top; qint32 top = _items.at(itemIndex)->Get<Overview::Layout::Info>()->top;
if (_reversed) top = _height - top; if (_reversed) top = _height - top;
@ -365,8 +365,8 @@ void OverviewInner::touchResetSpeed() {
void OverviewInner::touchDeaccelerate(qint32 elapsed) { void OverviewInner::touchDeaccelerate(qint32 elapsed) {
qint32 x = _touchSpeed.x(); qint32 x = _touchSpeed.x();
qint32 y = _touchSpeed.y(); qint32 y = _touchSpeed.y();
_touchSpeed.setX((x == 0) ? x : (x > 0) ? qMax(0, x - elapsed) : qMin(0, x + elapsed)); _touchSpeed.setX((x == 0) ? x : (x > 0) ? std::max(0, x - elapsed) : std::min(0, x + elapsed));
_touchSpeed.setY((y == 0) ? y : (y > 0) ? qMax(0, y - elapsed) : qMin(0, y + elapsed)); _touchSpeed.setY((y == 0) ? y : (y > 0) ? std::max(0, y - elapsed) : std::min(0, y + elapsed));
} }
void OverviewInner::touchEvent(QTouchEvent *e) { void OverviewInner::touchEvent(QTouchEvent *e) {
@ -1316,8 +1316,8 @@ qint32 OverviewInner::resizeToWidth(qint32 nwidth, qint32 scrollTop, qint32 minH
} }
auto widthWithMin = st::windowMinWidth; auto widthWithMin = st::windowMinWidth;
auto widthWithMax = st::overviewFileLayout.maxWidth + 2 * contentLeftMax; auto widthWithMax = st::overviewFileLayout.maxWidth + 2 * contentLeftMax;
_rowsLeft = anim::interpolate(contentLeftMax, contentLeftMin, qMax(widthWithMax - _width, 0) / double(widthWithMax - widthWithMin)); _rowsLeft = anim::interpolate(contentLeftMax, contentLeftMin, std::max(widthWithMax - _width, 0) / double(widthWithMax - widthWithMin));
_rowWidth = qMin(_width - 2 * _rowsLeft, st::overviewFileLayout.maxWidth); _rowWidth = std::min(_width - 2 * _rowsLeft, st::overviewFileLayout.maxWidth);
} }
_search->setGeometry(_rowsLeft, st::linksSearchTop, _rowWidth, _search->height()); _search->setGeometry(_rowsLeft, st::linksSearchTop, _rowWidth, _search->height());
@ -1630,7 +1630,7 @@ void OverviewInner::mediaOverviewUpdated() {
auto migrateCount = migratedIndexSkip(); auto migrateCount = migratedIndexSkip();
auto wasCount = _items.size(); auto wasCount = _items.size();
auto fullCount = (migrateCount + o.size()); auto fullCount = (migrateCount + o.size());
auto tocheck = qMin(fullCount, _itemsToBeLoaded); auto tocheck = std::min(fullCount, _itemsToBeLoaded);
_items.reserve(tocheck); _items.reserve(tocheck);
auto index = 0; auto index = 0;
@ -1672,7 +1672,7 @@ void OverviewInner::mediaOverviewUpdated() {
auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr;
auto migrateCount = migratedIndexSkip(); auto migrateCount = migratedIndexSkip();
auto l = _inSearch ? _searchResults.size() : (migrateCount + o.size()); auto l = _inSearch ? _searchResults.size() : (migrateCount + o.size());
auto tocheck = qMin(l, _itemsToBeLoaded); auto tocheck = std::min(l, _itemsToBeLoaded);
_items.reserve((withDates ? 2 : 1) * tocheck); // day items _items.reserve((withDates ? 2 : 1) * tocheck); // day items
auto migrateIt = migratedOverview ? migratedOverview->end() : o.end(); auto migrateIt = migratedOverview ? migratedOverview->end() : o.end();
@ -1835,7 +1835,7 @@ void OverviewInner::repaintItem(const HistoryItem *msg) {
double w = (double(width() - st::overviewPhotoSkip) / _photosInRow); double w = (double(width() - st::overviewPhotoSkip) / _photosInRow);
qint32 vsize = (_rowWidth + st::overviewPhotoSkip); qint32 vsize = (_rowWidth + st::overviewPhotoSkip);
qint32 row = i / _photosInRow, col = i % _photosInRow; qint32 row = i / _photosInRow, col = i % _photosInRow;
update(qint32(col * w), _marginTop + qint32(row * vsize), qCeil(w), vsize); update(qint32(col * w), _marginTop + qint32(row * vsize), std::ceil(w), vsize);
break; break;
} }
} }
@ -1866,17 +1866,17 @@ int OverviewInner::countHeight() {
void OverviewInner::recountMargins() { void OverviewInner::recountMargins() {
if (_type == OverviewPhotos || _type == OverviewVideos) { if (_type == OverviewPhotos || _type == OverviewVideos) {
_marginBottom = qMax(_minHeight - _height - _marginTop, 0); _marginBottom = std::max(_minHeight - _height - _marginTop, 0);
_marginTop = 0; _marginTop = 0;
} else if (_type == OverviewMusicFiles) { } else if (_type == OverviewMusicFiles) {
_marginTop = st::playlistPadding; _marginTop = st::playlistPadding;
_marginBottom = qMax(_minHeight - _height - _marginTop, qint32(st::playlistPadding)); _marginBottom = std::max(_minHeight - _height - _marginTop, qint32(st::playlistPadding));
} else if (_type == OverviewLinks || _type == OverviewFiles) { } else if (_type == OverviewLinks || _type == OverviewFiles) {
_marginTop = st::linksSearchTop + _search->height(); _marginTop = st::linksSearchTop + _search->height();
_marginBottom = qMax(_minHeight - _height - _marginTop, qint32(st::playlistPadding)); _marginBottom = std::max(_minHeight - _height - _marginTop, qint32(st::playlistPadding));
} else { } else {
_marginBottom = st::playlistPadding; _marginBottom = st::playlistPadding;
_marginTop = qMax(_minHeight - _height - _marginBottom, qint32(st::playlistPadding)); _marginTop = std::max(_minHeight - _height - _marginBottom, qint32(st::playlistPadding));
} }
} }
@ -2334,7 +2334,7 @@ QPoint OverviewWidget::clampMousePosition(QPoint point) {
} }
void OverviewWidget::onScrollTimer() { void OverviewWidget::onScrollTimer() {
qint32 d = (_scrollDelta > 0) ? qMin(_scrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : qMax(_scrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed)); qint32 d = (_scrollDelta > 0) ? std::min(_scrollDelta * 3 / 20 + 1, qint32(MaxScrollSpeed)) : std::max(_scrollDelta * 3 / 20 - 1, -qint32(MaxScrollSpeed));
_scroll->scrollToY(_scroll->scrollTop() + d); _scroll->scrollToY(_scroll->scrollTop() + d);
} }

View File

@ -166,7 +166,7 @@ void MainWindow::Private::initCustomTitle(NSWindow *window, NSView *view) {
[window setTitlebarAppearsTransparent:YES]; [window setTitlebarAppearsTransparent:YES];
auto inner = [window contentLayoutRect]; auto inner = [window contentLayoutRect];
auto full = [view frame]; auto full = [view frame];
_public->_customTitleHeight = qMax(qRound(full.size.height - inner.size.height), 0); _public->_customTitleHeight = std::max<int>(std::round(full.size.height - inner.size.height), 0);
#ifndef OS_MAC_OLD #ifndef OS_MAC_OLD
[[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window]; [[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];

View File

@ -82,7 +82,7 @@ void ChannelMembersWidget::refreshAdmins() {
auto getAdminsText = [this] { auto getAdminsText = [this] {
if (auto channel = peer()->asChannel()) { if (auto channel = peer()->asChannel()) {
if (!channel->isMegagroup() && channel->canViewAdmins()) { if (!channel->isMegagroup() && channel->canViewAdmins()) {
auto adminsCount = qMax(channel->adminsCount(), 1); auto adminsCount = std::max(channel->adminsCount(), 1);
return lng_channel_admins_link(lt_count, adminsCount); return lng_channel_admins_link(lt_count, adminsCount);
} }
} }
@ -105,7 +105,7 @@ void ChannelMembersWidget::refreshMembers() {
auto getMembersText = [this]() -> QString { auto getMembersText = [this]() -> QString {
if (auto channel = peer()->asChannel()) { if (auto channel = peer()->asChannel()) {
if (!channel->isMegagroup() && channel->canViewMembers()) { if (!channel->isMegagroup() && channel->canViewMembers()) {
int membersCount = qMax(channel->membersCount(), 1); int membersCount = std::max(channel->membersCount(), 1);
return lng_channel_members_link(lt_count, membersCount); return lng_channel_members_link(lt_count, membersCount);
} }
} }

View File

@ -111,7 +111,7 @@ int InfoWidget::resizeGetHeight(int newWidth) {
text->show(); text->show();
} }
} }
newHeight += qMax(label->height(), text->height() - st::profileBlockTextPart.margin.top() - st::profileBlockTextPart.margin.bottom()) + st::profileBlockOneLineSkip; newHeight += std::max(label->height(), text->height() - st::profileBlockTextPart.margin.top() - st::profileBlockTextPart.margin.bottom()) + st::profileBlockOneLineSkip;
}; };
moveLabeledText(_channelLinkLabel, _channelLink, _channelLinkShort); moveLabeledText(_channelLinkLabel, _channelLink, _channelLinkShort);
moveLabeledText(_mobileNumberLabel, _mobileNumber, nullptr); moveLabeledText(_mobileNumberLabel, _mobileNumber, nullptr);

View File

@ -113,7 +113,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
} }
if (item->adminState != Item::AdminState::None) { if (item->adminState != Item::AdminState::None) {
nameWidth -= st::profileMemberAdminIcon.width(); nameWidth -= st::profileMemberAdminIcon.width();
auto iconLeft = nameLeft + qMin(nameWidth, item->name.maxWidth()); auto iconLeft = nameLeft + std::min(nameWidth, item->name.maxWidth());
auto &icon = (item->adminState == Item::AdminState::Creator) auto &icon = (item->adminState == Item::AdminState::Creator)
? (selected ? st::profileMemberCreatorIconOver : st::profileMemberCreatorIcon) ? (selected ? st::profileMemberCreatorIconOver : st::profileMemberCreatorIcon)
: (selected ? st::profileMemberAdminIconOver : st::profileMemberAdminIcon); : (selected ? st::profileMemberAdminIconOver : st::profileMemberAdminIcon);
@ -303,7 +303,7 @@ int PeerListWidget::getListLeft() const {
} }
int PeerListWidget::rowWidth() const { int PeerListWidget::rowWidth() const {
return qMin(width() - getListLeft(), st::profileBlockWideWidthMax); return std::min(width() - getListLeft(), st::profileBlockWideWidthMax);
} }
void PeerListWidget::preloadPhotos() { void PeerListWidget::preloadPhotos() {

View File

@ -196,13 +196,13 @@ int InnerWidget::resizeGetHeight(int newWidth) {
auto contentLeftMax = st::profileCommonGroupsLeftMax; auto contentLeftMax = st::profileCommonGroupsLeftMax;
auto widthWithMin = st::windowMinWidth; auto widthWithMin = st::windowMinWidth;
auto widthWithMax = st::profileCommonGroupsWidthMax + 2 * contentLeftMax; auto widthWithMax = st::profileCommonGroupsWidthMax + 2 * contentLeftMax;
_contentLeft = anim::interpolate(contentLeftMax, contentLeftMin, qMax(widthWithMax - newWidth, 0) / double(widthWithMax - widthWithMin)); _contentLeft = anim::interpolate(contentLeftMax, contentLeftMin, std::max(widthWithMax - newWidth, 0) / double(widthWithMax - widthWithMin));
_contentWidth = qMin(newWidth - 2 * _contentLeft, st::profileCommonGroupsWidthMax); _contentWidth = std::min(newWidth - 2 * _contentLeft, st::profileCommonGroupsWidthMax);
auto newHeight = _contentTop; auto newHeight = _contentTop;
newHeight += _items.size() * _rowHeight; newHeight += _items.size() * _rowHeight;
newHeight += st::profileCommonGroupsSkip; newHeight += st::profileCommonGroupsSkip;
return qMax(newHeight, _minHeight); return std::max(newHeight, _minHeight);
} }
void InnerWidget::paintEvent(QPaintEvent *e) { void InnerWidget::paintEvent(QPaintEvent *e) {

View File

@ -118,7 +118,7 @@ void CoverWidget::onCancelPhotoUpload() {
int CoverWidget::countPhotoLeft(int newWidth) const { int CoverWidget::countPhotoLeft(int newWidth) const {
int result = st::profilePhotoLeftMin; int result = st::profilePhotoLeftMin;
result += (newWidth - st::windowMinWidth) / 2; result += (newWidth - st::windowMinWidth) / 2;
return qMin(result, st::profilePhotoLeftMax); return std::min(result, st::profilePhotoLeftMax);
} }
int CoverWidget::resizeGetHeight(int newWidth) { int CoverWidget::resizeGetHeight(int newWidth) {
@ -160,7 +160,7 @@ void CoverWidget::refreshNameGeometry(int newWidth) {
nameWidth -= st::profileVerifiedCheckShift + st::profileVerifiedCheck.width(); nameWidth -= st::profileVerifiedCheckShift + st::profileVerifiedCheck.width();
} }
int marginsAdd = st::profileNameLabel.margin.left() + st::profileNameLabel.margin.right(); int marginsAdd = st::profileNameLabel.margin.left() + st::profileNameLabel.margin.right();
_name->resizeToWidth(qMin(nameWidth - marginsAdd, _name->naturalWidth()) + marginsAdd); _name->resizeToWidth(std::min(nameWidth - marginsAdd, _name->naturalWidth()) + marginsAdd);
_name->moveToLeft(nameLeft, nameTop); _name->moveToLeft(nameLeft, nameTop);
} }
@ -380,7 +380,7 @@ void CoverWidget::refreshStatusText() {
_statusText = App::onlineText(_peerUser, currentTime, true); _statusText = App::onlineText(_peerUser, currentTime, true);
_statusTextIsOnline = App::onlineColorUse(_peerUser, currentTime); _statusTextIsOnline = App::onlineColorUse(_peerUser, currentTime);
} else if (_peerChat && _peerChat->amIn()) { } else if (_peerChat && _peerChat->amIn()) {
auto fullCount = qMax(_peerChat->count, _peerChat->participants.size()); auto fullCount = std::max(_peerChat->count, _peerChat->participants.size());
if (_onlineCount > 0 && _onlineCount <= fullCount) { if (_onlineCount > 0 && _onlineCount <= fullCount) {
auto membersCount = lng_chat_status_members(lt_count, fullCount); auto membersCount = lng_chat_status_members(lt_count, fullCount);
auto onlineCount = lng_chat_status_online(lt_count, _onlineCount); auto onlineCount = lng_chat_status_online(lt_count, _onlineCount);

View File

@ -120,7 +120,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
if (_mode == Mode::TwoColumn) { if (_mode == Mode::TwoColumn) {
int leftHeight = countBlocksHeight(RectPart::Left); int leftHeight = countBlocksHeight(RectPart::Left);
int rightHeight = countBlocksHeight(RectPart::Right); int rightHeight = countBlocksHeight(RectPart::Right);
int shadowHeight = rightHeight;// qMin(leftHeight, rightHeight); int shadowHeight = rightHeight;// std::min(leftHeight, rightHeight);
int shadowLeft = _blocksLeft + _leftColumnWidth + _columnDivider; int shadowLeft = _blocksLeft + _leftColumnWidth + _columnDivider;
int shadowTop = _blocksTop + st::profileBlockMarginTop; int shadowTop = _blocksTop + st::profileBlockMarginTop;
@ -149,7 +149,7 @@ int InnerWidget::countBlocksHeight(RectPart countSide) const {
int InnerWidget::countBlocksLeft(int newWidth) const { int InnerWidget::countBlocksLeft(int newWidth) const {
int result = st::profileBlockLeftMin; int result = st::profileBlockLeftMin;
result += (newWidth - st::windowMinWidth) / 2; result += (newWidth - st::windowMinWidth) / 2;
return qMin(result, st::profileBlockLeftMax); return std::min(result, st::profileBlockLeftMax);
} }
InnerWidget::Mode InnerWidget::countBlocksMode(int newWidth) const { InnerWidget::Mode InnerWidget::countBlocksMode(int newWidth) const {
@ -239,7 +239,7 @@ int InnerWidget::resizeGetHeight(int newWidth) {
update(); update();
auto naturalHeight = countHeight(); auto naturalHeight = countHeight();
_addedHeight = qMax(_minHeight - naturalHeight, 0); _addedHeight = std::max(_minHeight - naturalHeight, 0);
return naturalHeight + _addedHeight; return naturalHeight + _addedHeight;
} }
@ -248,7 +248,7 @@ int InnerWidget::countHeight() const {
auto leftHeight = countBlocksHeight(RectPart::Left); auto leftHeight = countBlocksHeight(RectPart::Left);
auto rightHeight = countBlocksHeight(RectPart::Right); auto rightHeight = countBlocksHeight(RectPart::Right);
auto blocksHeight = (_mode == Mode::OneColumn) ? (leftHeight + rightHeight) : qMax(leftHeight, rightHeight); auto blocksHeight = (_mode == Mode::OneColumn) ? (leftHeight + rightHeight) : std::max(leftHeight, rightHeight);
newHeight += st::profileBlocksTop + blocksHeight + st::profileBlocksBottom; newHeight += st::profileBlocksTop + blocksHeight + st::profileBlocksBottom;
return newHeight; return newHeight;

View File

@ -109,11 +109,11 @@ int BackgroundRow::resizeGetHeight(int newWidth) {
auto linkTop = 0; auto linkTop = 0;
auto linkLeft = st::settingsBackgroundSize + st::settingsSmallSkip; auto linkLeft = st::settingsBackgroundSize + st::settingsSmallSkip;
auto linkWidth = newWidth - linkLeft; auto linkWidth = newWidth - linkLeft;
_chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth())); _chooseFromGallery->resizeToWidth(std::min(linkWidth, _chooseFromGallery->naturalWidth()));
_chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth())); _chooseFromFile->resizeToWidth(std::min(linkWidth, _chooseFromFile->naturalWidth()));
_editTheme->resizeToWidth(qMin(linkWidth, _editTheme->naturalWidth())); _editTheme->resizeToWidth(std::min(linkWidth, _editTheme->naturalWidth()));
if (_useDefaultTheme) { if (_useDefaultTheme) {
_useDefaultTheme->resizeToWidth(qMin(linkWidth, _useDefaultTheme->naturalWidth())); _useDefaultTheme->resizeToWidth(std::min(linkWidth, _useDefaultTheme->naturalWidth()));
_useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth); _useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _useDefaultTheme->height() + st::settingsSmallSkip; linkTop += _useDefaultTheme->height() + st::settingsSmallSkip;
} }

View File

@ -47,7 +47,7 @@ int BlockWidget::resizeGetHeight(int newWidth) {
row.child->moveToLeft(x + row.margin.left(), result + row.margin.top(), newWidth); row.child->moveToLeft(x + row.margin.left(), result + row.margin.top(), newWidth);
auto availRowWidth = availw - row.margin.left() - row.margin.right() - x; auto availRowWidth = availw - row.margin.left() - row.margin.right() - x;
auto natural = row.child->naturalWidth(); auto natural = row.child->naturalWidth();
auto rowWidth = (natural < 0) ? availRowWidth : qMin(natural, availRowWidth); auto rowWidth = (natural < 0) ? availRowWidth : std::min(natural, availRowWidth);
if (row.child->widthNoMargins() != rowWidth) { if (row.child->widthNoMargins() != rowWidth) {
row.child->resizeToWidth(rowWidth); row.child->resizeToWidth(rowWidth);
} }

View File

@ -77,7 +77,7 @@ DownloadPathState::DownloadPathState(QWidget *parent) : TWidget(parent)
} }
int DownloadPathState::resizeGetHeight(int newWidth) { int DownloadPathState::resizeGetHeight(int newWidth) {
_path->resizeToWidth(qMin(newWidth, _path->naturalWidth())); _path->resizeToWidth(std::min(newWidth, _path->naturalWidth()));
_path->moveToLeft(0, 0, newWidth); _path->moveToLeft(0, 0, newWidth);
_clear->moveToRight(0, 0, newWidth); _clear->moveToRight(0, 0, newWidth);
return _path->height(); return _path->height();

View File

@ -145,7 +145,7 @@ void CoverWidget::refreshNameGeometry(int newWidth) {
} }
int marginsAdd = st::settingsNameLabel.margin.left() + st::settingsNameLabel.margin.right(); int marginsAdd = st::settingsNameLabel.margin.left() + st::settingsNameLabel.margin.right();
_name->resizeToWidth(qMin(nameWidth - marginsAdd, _name->naturalWidth()) + marginsAdd); _name->resizeToWidth(std::min(nameWidth - marginsAdd, _name->naturalWidth()) + marginsAdd);
_name->moveToLeft(nameLeft, nameTop, newWidth); _name->moveToLeft(nameLeft, nameTop, newWidth);
_editNameInline->moveToLeft(nameLeft + _name->width(), nameTop, newWidth); _editNameInline->moveToLeft(nameLeft + _name->width(), nameTop, newWidth);

View File

@ -191,7 +191,7 @@ int InfoWidget::LabeledWidget::resizeGetHeight(int newWidth) {
auto labelNatural = _label->naturalWidth(); auto labelNatural = _label->naturalWidth();
Assert(labelNatural >= 0); Assert(labelNatural >= 0);
_label->resize(qMin(newWidth, labelNatural), _label->height()); _label->resize(std::min(newWidth, labelNatural), _label->height());
int textLeft = _label->width() + st::normalFont->spacew; int textLeft = _label->width() + st::normalFont->spacew;
int textWidth = _text->naturalWidth(); int textWidth = _text->naturalWidth();
@ -215,7 +215,7 @@ int InfoWidget::LabeledWidget::resizeGetHeight(int newWidth) {
_text->show(); _text->show();
} }
} }
return st::settingsBlockOneLineTextPart.margin.top() + qMax(_label->height(), _text->height() - st::settingsBlockOneLineTextPart.margin.top() - st::settingsBlockOneLineTextPart.margin.bottom()) + st::settingsBlockOneLineTextPart.margin.bottom(); return st::settingsBlockOneLineTextPart.margin.top() + std::max(_label->height(), _text->height() - st::settingsBlockOneLineTextPart.margin.top() - st::settingsBlockOneLineTextPart.margin.bottom()) + st::settingsBlockOneLineTextPart.margin.bottom();
} }
} // namespace Settings } // namespace Settings

View File

@ -1026,7 +1026,7 @@ public:
} }
void setProgress(qint64 already, qint64 size) { void setProgress(qint64 already, qint64 size) {
_already = already; _already = already;
_size = qMax(size, 0LL); _size = std::max(size, 0LL);
} }
qint64 size() const { qint64 size() const {
@ -1236,7 +1236,7 @@ void WebLoadManager::onMeta() {
if (QString::fromUtf8(i->first).toLower() == "content-range") { if (QString::fromUtf8(i->first).toLower() == "content-range") {
QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second)); QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second));
if (m.hasMatch()) { if (m.hasMatch()) {
loader->setProgress(qMax(qint64(loader->data().size()), loader->already()), m.captured(1).toLongLong()); loader->setProgress(std::max(qint64(loader->data().size()), loader->already()), m.captured(1).toLongLong());
if (!handleReplyResult(loader, WebReplyProcessProgress)) { if (!handleReplyResult(loader, WebReplyProcessProgress)) {
_replies.erase(j); _replies.erase(j);
_loaders.remove(loader); _loaders.remove(loader);

View File

@ -410,7 +410,7 @@ void FileLoadTask::process() {
fullimage = Images::prepareOpaque(std::move(fullimage)); fullimage = Images::prepareOpaque(std::move(fullimage));
} }
} }
_result->filesize = (qint32)qMin(filesize, qint64(INT_MAX)); _result->filesize = (qint32)std::min(filesize, qint64(INT_MAX));
if (!filesize || filesize > App::kFileSizeLimit) { if (!filesize || filesize > App::kFileSizeLimit) {
return; return;

View File

@ -1811,13 +1811,13 @@ void _writeUserSettings() {
data.stream << quint32(dbiDownloadPath) << (Global::AskDownloadPath() ? QString() : Global::DownloadPath()) << (Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark()); data.stream << quint32(dbiDownloadPath) << (Global::AskDownloadPath() ? QString() : Global::DownloadPath()) << (Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage()); data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage());
data.stream << quint32(dbiDialogLastPath) << cDialogLastPath(); data.stream << quint32(dbiDialogLastPath) << cDialogLastPath();
data.stream << quint32(dbiSongVolume) << qint32(qRound(Global::SongVolume() * 1e6)); data.stream << quint32(dbiSongVolume) << qint32(std::round(Global::SongVolume() * 1e6));
data.stream << quint32(dbiVideoVolume) << qint32(qRound(Global::VideoVolume() * 1e6)); data.stream << quint32(dbiVideoVolume) << qint32(std::round(Global::VideoVolume() * 1e6));
data.stream << quint32(dbiAutoDownload) << qint32(cAutoDownloadPhoto()) << qint32(cAutoDownloadAudio()) << qint32(cAutoDownloadGif()); data.stream << quint32(dbiAutoDownload) << qint32(cAutoDownloadPhoto()) << qint32(cAutoDownloadAudio()) << qint32(cAutoDownloadGif());
data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast<qint32>(Global::DialogsMode()); data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast<qint32>(Global::DialogsMode());
data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 1 : 0); data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 1 : 0);
data.stream << quint32(dbiAutoPlay) << qint32(cAutoPlayGif() ? 1 : 0); data.stream << quint32(dbiAutoPlay) << qint32(cAutoPlayGif() ? 1 : 0);
data.stream << quint32(dbiDialogsWidthRatio) << qint32(snap(qRound(dialogsWidthRatio() * 1000000), 0, 1000000)); data.stream << quint32(dbiDialogsWidthRatio) << qint32(snap<int>(std::round(dialogsWidthRatio() * 1000000), 0, 1000000));
data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer()); data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer());
if (!userData.isEmpty()) { if (!userData.isEmpty()) {
data.stream << quint32(dbiAuthSessionData) << userData; data.stream << quint32(dbiAuthSessionData) << userData;

View File

@ -138,7 +138,7 @@ void EmptyUserpic::Impl::paintSquare(Painter &p, int x, int y, int size) {
StorageKey EmptyUserpic::Impl::uniqueKey() const { StorageKey EmptyUserpic::Impl::uniqueKey() const {
auto first = 0xFFFFFFFF00000000ULL | anim::getPremultiplied(_color->c); auto first = 0xFFFFFFFF00000000ULL | anim::getPremultiplied(_color->c);
auto second = quint64(0); auto second = quint64(0);
memcpy(&second, _string.constData(), qMin(sizeof(second), _string.size() * sizeof(QChar))); memcpy(&second, _string.constData(), std::min(sizeof(second), _string.size() * sizeof(QChar)));
return StorageKey(first, second); return StorageKey(first, second);
} }
@ -1122,7 +1122,7 @@ bool PtsWaiter::check(ChannelData *channel, qint32 pts, qint32 count) { // retur
return true; return true;
} }
_last = qMax(_last, pts); _last = std::max(_last, pts);
_count += count; _count += count;
if (_last == _count) { if (_last == _count) {
_good = _last; _good = _last;

View File

@ -135,7 +135,7 @@ void CrossAnimation::paint(Painter &p, const style::CrossAnimation &st, style::c
transformLoadingCross(loading, pathDelete, pathDeleteSize); transformLoadingCross(loading, pathDelete, pathDeleteSize);
auto loadingArc = (loading >= 0.5) ? (loading - 1.) : loading; auto loadingArc = (loading >= 0.5) ? (loading - 1.) : loading;
loadingArcLength = qRound(-loadingArc * 2 * FullArcLength); loadingArcLength = std::round(-loadingArc * 2 * FullArcLength);
} }
if (shown < 1.) { if (shown < 1.) {
@ -164,7 +164,7 @@ void CrossAnimation::paint(Painter &p, const style::CrossAnimation &st, style::c
auto roundSkip = (st.size * (1 - sqrt2) + 2 * sqrt2 * deleteSkip + st.stroke) / 2; auto roundSkip = (st.size * (1 - sqrt2) + 2 * sqrt2 * deleteSkip + st.stroke) / 2;
auto roundPart = QRectF(x + roundSkip, y + roundSkip, st.size - 2 * roundSkip, st.size - 2 * roundSkip); auto roundPart = QRectF(x + roundSkip, y + roundSkip, st.size - 2 * roundSkip, st.size - 2 * roundSkip);
if (shown < 1.) { if (shown < 1.) {
loadingArcStart -= qRound(-(shown - 1.) * FullArcLength / 4.); loadingArcStart -= std::round(-(shown - 1.) * FullArcLength / 4.);
} }
p.setBrush(Qt::NoBrush); p.setBrush(Qt::NoBrush);
auto pen = color->p; auto pen = color->p;

View File

@ -159,7 +159,7 @@ void RoundShadowAnimation::paintShadowCorner(int left, int top, const QImage &im
for (auto y = 0; y != imageHeight; ++y) { for (auto y = 0; y != imageHeight; ++y) {
for (auto x = 0; x != imageWidth; ++x) { for (auto x = 0; x != imageWidth; ++x) {
auto source = *frameInts; auto source = *frameInts;
auto shadowAlpha = qMax(_frameAlpha - int(source >> 24), 0); auto shadowAlpha = std::max(_frameAlpha - int(source >> 24), 0);
*frameInts = anim::unshifted(anim::shifted(source) * 256 + anim::shifted(*imageInts) * shadowAlpha); *frameInts = anim::unshifted(anim::shifted(source) * 256 + anim::shifted(*imageInts) * shadowAlpha);
++frameInts; ++frameInts;
++imageInts; ++imageInts;
@ -274,30 +274,30 @@ void PanelAnimation::setFinalImage(QImage &&finalImage, QRect inner) {
} }
void PanelAnimation::setStartWidth() { void PanelAnimation::setStartWidth() {
_startWidth = qRound(_st.startWidth * _finalInnerWidth); _startWidth = std::round(_st.startWidth * _finalInnerWidth);
if (_startWidth >= 0) Assert(_startWidth <= _finalInnerWidth); if (_startWidth >= 0) Assert(_startWidth <= _finalInnerWidth);
} }
void PanelAnimation::setStartHeight() { void PanelAnimation::setStartHeight() {
_startHeight = qRound(_st.startHeight * _finalInnerHeight); _startHeight = std::round(_st.startHeight * _finalInnerHeight);
if (_startHeight >= 0) Assert(_startHeight <= _finalInnerHeight); if (_startHeight >= 0) Assert(_startHeight <= _finalInnerHeight);
} }
void PanelAnimation::setStartAlpha() { void PanelAnimation::setStartAlpha() {
_startAlpha = qRound(_st.startOpacity * 255); _startAlpha = std::round(_st.startOpacity * 255);
Assert(_startAlpha >= 0 && _startAlpha < 256); Assert(_startAlpha >= 0 && _startAlpha < 256);
} }
void PanelAnimation::setStartFadeTop() { void PanelAnimation::setStartFadeTop() {
_startFadeTop = qRound(_st.startFadeTop * _finalInnerHeight); _startFadeTop = std::round(_st.startFadeTop * _finalInnerHeight);
} }
void PanelAnimation::createFadeMask() { void PanelAnimation::createFadeMask() {
auto resultHeight = qRound(_finalImage.height() * _st.fadeHeight); int resultHeight = std::round(_finalImage.height() * _st.fadeHeight);
if (auto remove = (resultHeight % cIntRetinaFactor())) { if (auto remove = (resultHeight % cIntRetinaFactor())) {
resultHeight -= remove; resultHeight -= remove;
} }
auto finalAlpha = qRound(_st.fadeOpacity * 255); int finalAlpha = std::round(_st.fadeOpacity * 255);
Assert(finalAlpha >= 0 && finalAlpha < 256); Assert(finalAlpha >= 0 && finalAlpha < 256);
auto result = QImage(cIntRetinaFactor(), resultHeight, QImage::Format_ARGB32_Premultiplied); auto result = QImage(cIntRetinaFactor(), resultHeight, QImage::Format_ARGB32_Premultiplied);
auto ints = reinterpret_cast<quint32*>(result.bits()); auto ints = reinterpret_cast<quint32*>(result.bits());
@ -386,7 +386,7 @@ void PanelAnimation::paintFrame(QPainter &p, int x, int y, int outerWidth, doubl
if (auto decrease = (fadeTop % cIntRetinaFactor())) { if (auto decrease = (fadeTop % cIntRetinaFactor())) {
fadeTop -= decrease; fadeTop -= decrease;
} }
auto fadeBottom = (fadeTop < frameHeight) ? qMin(fadeTop + _fadeHeight, frameHeight) : frameHeight; auto fadeBottom = (fadeTop < frameHeight) ? std::min(fadeTop + _fadeHeight, frameHeight) : frameHeight;
auto fadeSkipLines = 0; auto fadeSkipLines = 0;
if (_origin == Origin::BottomLeft || _origin == Origin::BottomRight) { if (_origin == Origin::BottomLeft || _origin == Origin::BottomRight) {
fadeTop = frameHeight - fadeTop; fadeTop = frameHeight - fadeTop;

View File

@ -29,14 +29,14 @@ RadialAnimation::RadialAnimation(AnimationCallbacks &&callbacks)
void RadialAnimation::start(double prg) { void RadialAnimation::start(double prg) {
_firstStart = _lastStart = _lastTime = getms(); _firstStart = _lastStart = _lastTime = getms();
qint32 iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength), iprgstrict = qRound(prg * AlmostFullArcLength); qint32 iprg = std::round(std::max(prg, 0.0001) * AlmostFullArcLength), iprgstrict = std::round(prg * AlmostFullArcLength);
a_arcEnd = anim::value(iprgstrict, iprg); a_arcEnd = anim::value(iprgstrict, iprg);
_animation.start(); _animation.start();
} }
void RadialAnimation::update(double prg, bool finished, TimeMs ms) { void RadialAnimation::update(double prg, bool finished, TimeMs ms) {
auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength); auto iprg = std::round(std::max(prg, 0.0001) * AlmostFullArcLength);
if (iprg != qRound(a_arcEnd.to())) { if (iprg != std::round(a_arcEnd.to())) {
a_arcEnd.start(iprg); a_arcEnd.start(iprg);
_lastStart = _lastTime; _lastStart = _lastTime;
} }
@ -44,7 +44,7 @@ void RadialAnimation::update(double prg, bool finished, TimeMs ms) {
auto dt = double(ms - _lastStart); auto dt = double(ms - _lastStart);
auto fulldt = double(ms - _firstStart); auto fulldt = double(ms - _firstStart);
_opacity = qMin(fulldt / st::radialDuration, 1.); _opacity = std::min(fulldt / st::radialDuration, 1.);
if (!finished) { if (!finished) {
a_arcEnd.update(1. - (st::radialDuration / (st::radialDuration + dt)), anim::linear); a_arcEnd.update(1. - (st::radialDuration / (st::radialDuration + dt)), anim::linear);
} else if (dt >= st::radialDuration) { } else if (dt >= st::radialDuration) {
@ -79,8 +79,8 @@ void RadialAnimation::draw(Painter &p, const QRect &inner, qint32 thickness, sty
pen.setCapStyle(Qt::RoundCap); pen.setCapStyle(Qt::RoundCap);
p.setPen(pen); p.setPen(pen);
auto len = MinArcLength + qRound(a_arcEnd.current()); auto len = MinArcLength + std::round(a_arcEnd.current());
auto from = QuarterArcLength - qRound(a_arcStart.current()) - len; auto from = QuarterArcLength - std::round(a_arcStart.current()) - len;
if (rtl()) { if (rtl()) {
from = QuarterArcLength - (from - QuarterArcLength) - len; from = QuarterArcLength - (from - QuarterArcLength) - len;
if (from < 0) from += FullArcLength; if (from < 0) from += FullArcLength;

View File

@ -69,7 +69,7 @@ RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, QPoint origin,
for (auto point : points) { for (auto point : points) {
accumulate_max(_radiusTo, style::point::dotProduct(_origin - point, _origin - point)); accumulate_max(_radiusTo, style::point::dotProduct(_origin - point, _origin - point));
} }
_radiusTo = qRound(sqrt(_radiusTo)); _radiusTo = std::round(sqrt(_radiusTo));
_show.start(UpdateCallback(_update), 0., 1., _st.showDuration, anim::easeOutQuint); _show.start(UpdateCallback(_update), 0., 1., _st.showDuration, anim::easeOutQuint);
} }

View File

@ -65,7 +65,7 @@ RoundCheckbox::RoundCheckbox(const style::RoundCheckbox &st, base::lambda<void()
QRect RoundCheckbox::cacheDestRect(int x, int y, double scale) const { QRect RoundCheckbox::cacheDestRect(int x, int y, double scale) const {
auto iconSizeFull = kWideScale * _st.size; auto iconSizeFull = kWideScale * _st.size;
auto iconSize = qRound(iconSizeFull * scale); int iconSize = std::round(iconSizeFull * scale);
if (iconSize % 2 != iconSizeFull % 2) { if (iconSize % 2 != iconSizeFull % 2) {
++iconSize; ++iconSize;
} }
@ -101,9 +101,9 @@ void RoundCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWidth, d
} else if (fadeIn == 1.) { } else if (fadeIn == 1.) {
p.drawPixmapLeft(to, outerWidth, _wideCheckFullCache, cacheFrom); p.drawPixmapLeft(to, outerWidth, _wideCheckFullCache, cacheFrom);
} else { } else {
auto realDivider = ((kWideScale - 1) * _st.size / 2 + qMax(fadeIn - 0.5, 0.) * 2. * _st.size); auto realDivider = ((kWideScale - 1) * _st.size / 2 + std::max(fadeIn - 0.5, 0.) * 2. * _st.size);
auto divider = qRound(realDivider * masterScale); auto divider = std::round(realDivider * masterScale);
auto cacheDivider = qRound(realDivider) * cIntRetinaFactor(); auto cacheDivider = std::round(realDivider) * cIntRetinaFactor();
p.drawPixmapLeft(QRect(to.x(), to.y(), divider, to.height()), outerWidth, _wideCheckFullCache, QRect(0, 0, cacheDivider, cacheFrom.height())); p.drawPixmapLeft(QRect(to.x(), to.y(), divider, to.height()), outerWidth, _wideCheckFullCache, QRect(0, 0, cacheDivider, cacheFrom.height()));
p.drawPixmapLeft(QRect(to.x() + divider, to.y(), to.width() - divider, to.height()), outerWidth, _wideCheckBgCache, QRect(cacheDivider, 0, cacheFrom.width() - cacheDivider, _wideCheckBgCache.height())); p.drawPixmapLeft(QRect(to.x() + divider, to.y(), to.width() - divider, to.height()), outerWidth, _wideCheckBgCache, QRect(cacheDivider, 0, cacheFrom.width() - cacheDivider, _wideCheckBgCache.height()));
} }
@ -190,9 +190,9 @@ void RoundCheckbox::prepareWideCheckIconCache(Icon *icon) {
Painter p(&wideCache); Painter p(&wideCache);
p.setCompositionMode(QPainter::CompositionMode_Source); p.setCompositionMode(QPainter::CompositionMode_Source);
auto iconSize = kWideScale * _st.size; auto iconSize = kWideScale * _st.size;
auto realDivider = ((kWideScale - 1) * _st.size / 2 + qMax(icon->fadeIn.current(1.) - 0.5, 0.) * 2. * _st.size); auto realDivider = ((kWideScale - 1) * _st.size / 2 + std::max(icon->fadeIn.current(1.) - 0.5, 0.) * 2. * _st.size);
auto divider = qRound(realDivider); auto divider = std::round(realDivider);
auto cacheDivider = qRound(realDivider) * cIntRetinaFactor(); auto cacheDivider = std::round(realDivider) * cIntRetinaFactor();
p.drawPixmapLeft(QRect(0, 0, divider, iconSize), cacheWidth, _wideCheckFullCache, QRect(0, 0, divider * cIntRetinaFactor(), _wideCheckFullCache.height())); p.drawPixmapLeft(QRect(0, 0, divider, iconSize), cacheWidth, _wideCheckFullCache, QRect(0, 0, divider * cIntRetinaFactor(), _wideCheckFullCache.height()));
p.drawPixmapLeft(QRect(divider, 0, iconSize - divider, iconSize), cacheWidth, _wideCheckBgCache, QRect(cacheDivider, 0, _wideCheckBgCache.width() - cacheDivider, _wideCheckBgCache.height())); p.drawPixmapLeft(QRect(divider, 0, iconSize - divider, iconSize), cacheWidth, _wideCheckBgCache, QRect(cacheDivider, 0, _wideCheckBgCache.width() - cacheDivider, _wideCheckBgCache.height()));
} }
@ -243,7 +243,7 @@ void RoundImageCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWid
auto selectionLevel = _selection.current(checked() ? 1. : 0.); auto selectionLevel = _selection.current(checked() ? 1. : 0.);
if (_selection.animating()) { if (_selection.animating()) {
auto userpicRadius = qRound(kWideScale * (_st.imageRadius + (_st.imageSmallRadius - _st.imageRadius) * selectionLevel)); auto userpicRadius = std::round(kWideScale * (_st.imageRadius + (_st.imageSmallRadius - _st.imageRadius) * selectionLevel));
auto userpicShift = kWideScale * _st.imageRadius - userpicRadius; auto userpicShift = kWideScale * _st.imageRadius - userpicRadius;
auto userpicLeft = x - (kWideScale - 1) * _st.imageRadius + userpicShift; auto userpicLeft = x - (kWideScale - 1) * _st.imageRadius + userpicShift;
auto userpicTop = y - (kWideScale - 1) * _st.imageRadius + userpicShift; auto userpicTop = y - (kWideScale - 1) * _st.imageRadius + userpicShift;

View File

@ -65,7 +65,7 @@ void WidgetSlideWrap<TWidget>::showAnimated() {
if (!_hiding) return; if (!_hiding) return;
} }
_hiding = false; _hiding = false;
_forceHeight = qRound(_a_height.current(0.)); _forceHeight = std::round(_a_height.current(0.));
_a_height.start([this] { animationCallback(); }, 0., _realSize.height(), _duration); _a_height.start([this] { animationCallback(); }, 0., _realSize.height(), _duration);
} }
@ -122,7 +122,7 @@ int WidgetSlideWrap<TWidget>::resizeGetHeight(int newWidth) {
} }
void WidgetSlideWrap<TWidget>::animationCallback() { void WidgetSlideWrap<TWidget>::animationCallback() {
_forceHeight = qRound(_a_height.current(_hiding ? 0 : -1)); _forceHeight = std::round(_a_height.current(_hiding ? 0 : -1));
resizeToWidth(_realSize.width()); resizeToWidth(_realSize.width());
if (!_a_height.animating()) { if (!_a_height.animating()) {
_forceHeight = _hiding ? 0 : -1; _forceHeight = _hiding ? 0 : -1;

View File

@ -703,7 +703,7 @@ QPixmap Image::pixNoCache(int w, int h, Images::Options options, int outerw, int
if (_data.isNull()) { if (_data.isNull()) {
if (h <= 0 && height() > 0) { if (h <= 0 && height() > 0) {
h = qRound(width() * w / double(height())); h = std::round(width() * w / double(height()));
} }
return blank()->pixNoCache(w, h, options, outerw, outerh); return blank()->pixNoCache(w, h, options, outerw, outerh);
} }
@ -722,10 +722,10 @@ QPixmap Image::pixNoCache(int w, int h, Images::Options options, int outerw, int
p.fillRect(((outerw - w) / 2) + w, 0, result.width() - (((outerw - w) / 2) + w), result.height(), st::imageBg); p.fillRect(((outerw - w) / 2) + w, 0, result.width() - (((outerw - w) / 2) + w), result.height(), st::imageBg);
} }
if (h < outerh) { if (h < outerh) {
p.fillRect(qMax(0, (outerw - w) / 2), 0, qMin(result.width(), w), (outerh - h) / 2, st::imageBg); p.fillRect(std::max(0, (outerw - w) / 2), 0, std::min(result.width(), w), (outerh - h) / 2, st::imageBg);
p.fillRect(qMax(0, (outerw - w) / 2), ((outerh - h) / 2) + h, qMin(result.width(), w), result.height() - (((outerh - h) / 2) + h), st::imageBg); p.fillRect(std::max(0, (outerw - w) / 2), ((outerh - h) / 2) + h, std::min(result.width(), w), result.height() - (((outerh - h) / 2) + h), st::imageBg);
} }
p.fillRect(qMax(0, (outerw - w) / 2), qMax(0, (outerh - h) / 2), qMin(result.width(), w), qMin(result.height(), h), st::imageBgTransparent); p.fillRect(std::max(0, (outerw - w) / 2), std::max(0, (outerh - h) / 2), std::min(result.width(), w), std::min(result.height(), h), st::imageBgTransparent);
} }
auto corners = [](Images::Options options) { auto corners = [](Images::Options options) {

View File

@ -112,7 +112,7 @@ void EmojiButton::paintEvent(QPaintEvent *e) {
QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle); QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle);
if (loading > 0) { if (loading > 0) {
qint32 full = FullArcLength; qint32 full = FullArcLength;
qint32 start = qRound(full * double(ms % st::historyEmojiCirclePeriod) / st::historyEmojiCirclePeriod), part = qRound(loading * full / st::historyEmojiCirclePart); qint32 start = std::round(full * double(ms % st::historyEmojiCirclePeriod) / st::historyEmojiCirclePeriod), part = std::round(loading * full / st::historyEmojiCirclePart);
p.drawArc(inner, start, full - part); p.drawArc(inner, start, full - part);
} else { } else {
p.drawEllipse(inner); p.drawEllipse(inner);

View File

@ -39,7 +39,7 @@ inline int pxAdjust(int value, int scale) {
if (value < 0) { if (value < 0) {
return -pxAdjust(-value, scale); return -pxAdjust(-value, scale);
} }
return qFloor((value * scale / 4.) + 0.1); return std::floor((value * scale / 4.) + 0.1);
} }
QImage createIconMask(const IconMask *mask, DBIScale scale) { QImage createIconMask(const IconMask *mask, DBIScale scale) {
@ -51,7 +51,7 @@ QImage createIconMask(const IconMask *mask, DBIScale scale) {
// 200x 100x // 200x 100x
// 150x 125x // 150x 125x
int width = maskImage.width() / 3; int width = maskImage.width() / 3;
int height = qRound((maskImage.height() * 2) / 7.); int height = std::round((maskImage.height() * 2) / 7.);
auto r = QRect(0, 0, width * 2, height * 2); auto r = QRect(0, 0, width * 2, height * 2);
if (!cRetina() && scale != dbisTwo) { if (!cRetina() && scale != dbisTwo) {
if (scale == dbisOne) { if (scale == dbisOne) {

View File

@ -898,7 +898,7 @@ public:
_last_rPadding = b->f_rpadding(); _last_rPadding = b->f_rpadding();
_wLeft = newWidthLeft; _wLeft = newWidthLeft;
_lineHeight = qMax(_lineHeight, blockHeight); _lineHeight = std::max(_lineHeight, blockHeight);
longWordLine = false; longWordLine = false;
continue; continue;
@ -909,7 +909,7 @@ public:
if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line
_last_rPadding += b->f_rpadding(); _last_rPadding += b->f_rpadding();
_lineHeight = qMax(_lineHeight, blockHeight); _lineHeight = std::max(_lineHeight, blockHeight);
longWordLine = false; longWordLine = false;
continue; continue;
@ -927,7 +927,7 @@ public:
_last_rPadding = j->f_rpadding(); _last_rPadding = j->f_rpadding();
_wLeft = newWidthLeft; _wLeft = newWidthLeft;
_lineHeight = qMax(_lineHeight, blockHeight); _lineHeight = std::max(_lineHeight, blockHeight);
if (wordEndsHere) { if (wordEndsHere) {
longWordLine = false; longWordLine = false;
@ -940,7 +940,7 @@ public:
continue; continue;
} }
auto elidedLineHeight = qMax(_lineHeight, blockHeight); auto elidedLineHeight = std::max(_lineHeight, blockHeight);
auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide); auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide);
if (elidedLine) { if (elidedLine) {
_lineHeight = elidedLineHeight; _lineHeight = elidedLineHeight;
@ -955,7 +955,7 @@ public:
return; return;
} }
_y += _lineHeight; _y += _lineHeight;
_lineHeight = qMax(0, blockHeight); _lineHeight = std::max(0, blockHeight);
_lineStart = j->from(); _lineStart = j->from();
_lineStartBlock = blockIndex; _lineStartBlock = blockIndex;
@ -974,7 +974,7 @@ public:
continue; continue;
} }
auto elidedLineHeight = qMax(_lineHeight, blockHeight); auto elidedLineHeight = std::max(_lineHeight, blockHeight);
auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide); auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide);
if (elidedLine) { if (elidedLine) {
_lineHeight = elidedLineHeight; _lineHeight = elidedLineHeight;
@ -983,7 +983,7 @@ public:
return; return;
} }
_y += _lineHeight; _y += _lineHeight;
_lineHeight = qMax(0, blockHeight); _lineHeight = std::max(0, blockHeight);
_lineStart = b->from(); _lineStart = b->from();
_lineStartBlock = blockIndex; _lineStartBlock = blockIndex;
@ -1158,9 +1158,9 @@ private:
auto currentBlock = _t->_blocks[blockIndex].get(); auto currentBlock = _t->_blocks[blockIndex].get();
auto nextBlock = (++blockIndex < _blocksSize) ? _t->_blocks[blockIndex].get() : nullptr; auto nextBlock = (++blockIndex < _blocksSize) ? _t->_blocks[blockIndex].get() : nullptr;
qint32 delta = (currentBlock->from() < _lineStart ? qMin(_lineStart - currentBlock->from(), 2) : 0); qint32 delta = (currentBlock->from() < _lineStart ? std::min(_lineStart - currentBlock->from(), 2) : 0);
_localFrom = _lineStart - delta; _localFrom = _lineStart - delta;
qint32 lineEnd = (_endBlock && _endBlock->from() < trimmedLineEnd && !elidedLine) ? qMin(quint16(trimmedLineEnd + 2), _t->countBlockEnd(_endBlockIter, _end)) : trimmedLineEnd; qint32 lineEnd = (_endBlock && _endBlock->from() < trimmedLineEnd && !elidedLine) ? std::min(quint16(trimmedLineEnd + 2), _t->countBlockEnd(_endBlockIter, _end)) : trimmedLineEnd;
auto lineText = _t->_text.mid(_localFrom, lineEnd - _localFrom); auto lineText = _t->_text.mid(_localFrom, lineEnd - _localFrom);
auto lineStart = delta; auto lineStart = delta;
@ -1392,7 +1392,7 @@ private:
unsigned short *logClusters = engine.logClusters(&si); unsigned short *logClusters = engine.logClusters(&si);
QGlyphLayout glyphs = engine.shapedGlyphs(&si); QGlyphLayout glyphs = engine.shapedGlyphs(&si);
int itemStart = qMax(line.from, si.position), itemEnd; int itemStart = std::max(line.from, si.position), itemEnd;
int itemLength = engine.length(item); int itemLength = engine.length(item);
int glyphsStart = logClusters[itemStart - si.position], glyphsEnd; int glyphsStart = logClusters[itemStart - si.position], glyphsEnd;
if (line.from + line.length < si.position + itemLength) { if (line.from + line.length < si.position + itemLength) {
@ -1611,7 +1611,7 @@ private:
if (_wLeft < si.width) { if (_wLeft < si.width) {
lineText = lineText.mid(0, currentBlock->from() - _localFrom) + _Elide; lineText = lineText.mid(0, currentBlock->from() - _localFrom) + _Elide;
lineLength = currentBlock->from() + _Elide.size() - _lineStart; lineLength = currentBlock->from() + _Elide.size() - _lineStart;
_selection.to = qMin(_selection.to, currentBlock->from()); _selection.to = std::min(_selection.to, currentBlock->from());
setElideBidi(currentBlock->from(), _Elide.size()); setElideBidi(currentBlock->from(), _Elide.size());
elideSaveBlock(blockIndex - 1, _endBlock, currentBlock->from(), elideWidth); elideSaveBlock(blockIndex - 1, _endBlock, currentBlock->from(), elideWidth);
return; return;
@ -1621,7 +1621,7 @@ private:
unsigned short *logClusters = engine.logClusters(&si); unsigned short *logClusters = engine.logClusters(&si);
QGlyphLayout glyphs = engine.shapedGlyphs(&si); QGlyphLayout glyphs = engine.shapedGlyphs(&si);
int itemStart = qMax(line.from, si.position), itemEnd; int itemStart = std::max(line.from, si.position), itemEnd;
int itemLength = engine.length(firstItem + i); int itemLength = engine.length(firstItem + i);
int glyphsStart = logClusters[itemStart - si.position], glyphsEnd; int glyphsStart = logClusters[itemStart - si.position], glyphsEnd;
if (line.from + line.length < si.position + itemLength) { if (line.from + line.length < si.position + itemLength) {
@ -1643,7 +1643,7 @@ private:
if (lineText.size() <= pos || repeat > 3) { if (lineText.size() <= pos || repeat > 3) {
lineText += _Elide; lineText += _Elide;
lineLength = _localFrom + pos + _Elide.size() - _lineStart; lineLength = _localFrom + pos + _Elide.size() - _lineStart;
_selection.to = qMin(_selection.to, quint16(_localFrom + pos)); _selection.to = std::min(_selection.to, quint16(_localFrom + pos));
setElideBidi(_localFrom + pos, _Elide.size()); setElideBidi(_localFrom + pos, _Elide.size());
_blocksSize = blockIndex; _blocksSize = blockIndex;
_endBlock = nextBlock; _endBlock = nextBlock;
@ -1663,7 +1663,7 @@ private:
} }
qint32 elideStart = _localFrom + lineText.size(); qint32 elideStart = _localFrom + lineText.size();
_selection.to = qMin(_selection.to, quint16(elideStart)); _selection.to = std::min(_selection.to, quint16(elideStart));
setElideBidi(elideStart, _Elide.size()); setElideBidi(elideStart, _Elide.size());
lineText += _Elide; lineText += _Elide;
@ -2515,7 +2515,7 @@ void Text::recountNaturalSize(bool initial, Qt::LayoutDirection optionsDir) {
accumulate_max(_maxWidth, _width); accumulate_max(_maxWidth, _width);
_width += last_rBearing + (last_rPadding + b->f_width() - b__f_rbearing); _width += last_rBearing + (last_rPadding + b->f_width() - b__f_rbearing);
lineHeight = qMax(lineHeight, blockHeight); lineHeight = std::max(lineHeight, blockHeight);
last_rBearing = b__f_rbearing; last_rBearing = b__f_rbearing;
last_rPadding = b->f_rpadding(); last_rPadding = b->f_rpadding();
@ -2747,7 +2747,7 @@ void Text::enumerateLines(int w, Callback callback) const {
last_rPadding = b->f_rpadding(); last_rPadding = b->f_rpadding();
widthLeft = newWidthLeft; widthLeft = newWidthLeft;
lineHeight = qMax(lineHeight, blockHeight); lineHeight = std::max(lineHeight, blockHeight);
longWordLine = false; longWordLine = false;
continue; continue;
@ -2758,7 +2758,7 @@ void Text::enumerateLines(int w, Callback callback) const {
if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line
last_rPadding += b->f_rpadding(); last_rPadding += b->f_rpadding();
lineHeight = qMax(lineHeight, blockHeight); lineHeight = std::max(lineHeight, blockHeight);
longWordLine = false; longWordLine = false;
continue; continue;
@ -2776,7 +2776,7 @@ void Text::enumerateLines(int w, Callback callback) const {
last_rPadding = j->f_rpadding(); last_rPadding = j->f_rpadding();
widthLeft = newWidthLeft; widthLeft = newWidthLeft;
lineHeight = qMax(lineHeight, blockHeight); lineHeight = std::max(lineHeight, blockHeight);
if (wordEndsHere) { if (wordEndsHere) {
longWordLine = false; longWordLine = false;
@ -2798,7 +2798,7 @@ void Text::enumerateLines(int w, Callback callback) const {
callback(width - widthLeft, lineHeight); callback(width - widthLeft, lineHeight);
lineHeight = qMax(0, blockHeight); lineHeight = std::max(0, blockHeight);
last_rBearing = j->f_rbearing(); last_rBearing = j->f_rbearing();
last_rPadding = j->f_rpadding(); last_rPadding = j->f_rpadding();
widthLeft = width - (j_width - last_rBearing); widthLeft = width - (j_width - last_rBearing);
@ -2813,7 +2813,7 @@ void Text::enumerateLines(int w, Callback callback) const {
callback(width - widthLeft, lineHeight); callback(width - widthLeft, lineHeight);
lineHeight = qMax(0, blockHeight); lineHeight = std::max(0, blockHeight);
last_rBearing = b__f_rbearing; last_rBearing = b__f_rbearing;
last_rPadding = b->f_rpadding(); last_rPadding = b->f_rpadding();
widthLeft = width - (b->f_width() - last_rBearing); widthLeft = width - (b->f_width() - last_rBearing);
@ -2923,8 +2923,8 @@ void Text::enumerateText(TextSelection selection, AppendPartCallback appendPartC
} }
if (blockLnkIndex != lnkIndex) { if (blockLnkIndex != lnkIndex) {
if (lnkIndex) { if (lnkIndex) {
auto rangeFrom = qMax(selection.from, lnkFrom); auto rangeFrom = std::max(selection.from, lnkFrom);
auto rangeTo = qMin(blockFrom, selection.to); auto rangeTo = std::min(blockFrom, selection.to);
if (rangeTo > rangeFrom) { // handle click handler if (rangeTo > rangeFrom) { // handle click handler
QStringRef r = _text.midRef(rangeFrom, rangeTo - rangeFrom); QStringRef r = _text.midRef(rangeFrom, rangeTo - rangeFrom);
if (lnkFrom != rangeFrom || blockFrom != rangeTo) { if (lnkFrom != rangeFrom || blockFrom != rangeTo) {
@ -2945,8 +2945,8 @@ void Text::enumerateText(TextSelection selection, AppendPartCallback appendPartC
if ((*i)->type() == TextBlockTSkip) continue; if ((*i)->type() == TextBlockTSkip) continue;
if (!blockLnkIndex) { if (!blockLnkIndex) {
auto rangeFrom = qMax(selection.from, blockFrom); auto rangeFrom = std::max(selection.from, blockFrom);
auto rangeTo = qMin(selection.to, quint16(blockFrom + countBlockLength(i, e))); auto rangeTo = std::min(selection.to, quint16(blockFrom + countBlockLength(i, e)));
if (rangeTo > rangeFrom) { if (rangeTo > rangeFrom) {
appendPartCallback(_text.midRef(rangeFrom, rangeTo - rangeFrom)); appendPartCallback(_text.midRef(rangeFrom, rangeTo - rangeFrom));
} }

View File

@ -86,7 +86,7 @@ struct LineBreakHelper
// of the bearing here so that we can assume it's negative in the rest // of the bearing here so that we can assume it's negative in the rest
// of the code, as well ase use QFixed(1) as a sentinel to represent // of the code, as well ase use QFixed(1) as a sentinel to represent
// the state where we have yet to compute the right bearing. // the state where we have yet to compute the right bearing.
rightBearing = qMin(QFixed::fromReal(rb), QFixed(0)); rightBearing = std::min(QFixed::fromReal(rb), QFixed(0));
} }
inline void calculateRightBearing() inline void calculateRightBearing()

View File

@ -1716,14 +1716,14 @@ void ParseMarkdown(TextWithEntities &result, bool rich) {
// Check if start or end sequences intersect any existing entity. // Check if start or end sequences intersect any existing entity.
auto intersectedEntityEnd = 0; auto intersectedEntityEnd = 0;
for_const (auto &entity, result.entities) { for_const (auto &entity, result.entities) {
if (qMin(part.innerStart, entity.offset() + entity.length()) > qMax(part.outerStart, entity.offset()) || if (std::min(part.innerStart, entity.offset() + entity.length()) > std::max(part.outerStart, entity.offset()) ||
qMin(part.outerEnd, entity.offset() + entity.length()) > qMax(part.innerEnd, entity.offset())) { std::min(part.outerEnd, entity.offset() + entity.length()) > std::max(part.innerEnd, entity.offset())) {
intersectedEntityEnd = entity.offset() + entity.length(); intersectedEntityEnd = entity.offset() + entity.length();
break; break;
} }
} }
if (intersectedEntityEnd > 0) { if (intersectedEntityEnd > 0) {
matchFromOffset = qMax(part.innerStart, intersectedEntityEnd); matchFromOffset = std::max(part.innerStart, intersectedEntityEnd);
continue; continue;
} }
@ -1799,7 +1799,7 @@ void ParseEntities(TextWithEntities &result, qint32 flags, bool rich) {
auto mDomain = RegExpDomain().match(result.text, matchOffset); auto mDomain = RegExpDomain().match(result.text, matchOffset);
auto mExplicitDomain = RegExpDomainExplicit().match(result.text, matchOffset); auto mExplicitDomain = RegExpDomainExplicit().match(result.text, matchOffset);
auto mHashtag = withHashtags ? RegExpHashtag().match(result.text, matchOffset) : QRegularExpressionMatch(); auto mHashtag = withHashtags ? RegExpHashtag().match(result.text, matchOffset) : QRegularExpressionMatch();
auto mMention = withMentions ? RegExpMention().match(result.text, qMax(mentionSkip, matchOffset)) : QRegularExpressionMatch(); auto mMention = withMentions ? RegExpMention().match(result.text, std::max(mentionSkip, matchOffset)) : QRegularExpressionMatch();
auto mBotCommand = withBotCommands ? RegExpBotCommand().match(result.text, matchOffset) : QRegularExpressionMatch(); auto mBotCommand = withBotCommands ? RegExpBotCommand().match(result.text, matchOffset) : QRegularExpressionMatch();
EntityInTextType lnkType = EntityInTextUrl; EntityInTextType lnkType = EntityInTextUrl;
@ -1831,7 +1831,7 @@ void ParseEntities(TextWithEntities &result, qint32 flags, bool rich) {
} }
if (!(start + mentionStart + 1)->isLetter() || !(start + mentionEnd - 1)->isLetterOrNumber()) { if (!(start + mentionStart + 1)->isLetter() || !(start + mentionEnd - 1)->isLetterOrNumber()) {
mentionSkip = mentionEnd; mentionSkip = mentionEnd;
mMention = RegExpMention().match(result.text, qMax(mentionSkip, matchOffset)); mMention = RegExpMention().match(result.text, std::max(mentionSkip, matchOffset));
if (mMention.hasMatch()) { if (mMention.hasMatch()) {
mentionStart = mMention.capturedStart(); mentionStart = mMention.capturedStart();
mentionEnd = mMention.capturedEnd(); mentionEnd = mMention.capturedEnd();
@ -2022,7 +2022,7 @@ QString ApplyEntities(const TextWithEntities &text) {
already = offset; already = offset;
} }
result.append(tag); result.append(tag);
closingTags.insert(qMin(entity->offset() + entity->length(), size), tag); closingTags.insert(std::min(entity->offset() + entity->length(), size), tag);
++entity; ++entity;
tag = skipTillRelevantAndGetTag(); tag = skipTillRelevantAndGetTag();

View File

@ -53,7 +53,7 @@ void Widget::onParentResized() {
accumulate_min(newWidth, parentWidget()->width() - 2 * st::toastMinMargin); accumulate_min(newWidth, parentWidget()->width() - 2 * st::toastMinMargin);
_textWidth = newWidth - _padding.left() - _padding.right(); _textWidth = newWidth - _padding.left() - _padding.right();
auto maxHeight = kToastMaxLines * st::toastTextStyle.font->height; auto maxHeight = kToastMaxLines * st::toastTextStyle.font->height;
auto textHeight = _multiline ? qMin(_text.countHeight(_textWidth), maxHeight) : _text.minHeight(); auto textHeight = _multiline ? std::min(_text.countHeight(_textWidth), maxHeight) : _text.minHeight();
auto newHeight = _padding.top() + textHeight + _padding.bottom(); auto newHeight = _padding.top() + textHeight + _padding.bottom();
setGeometry((parentWidget()->width() - newWidth) / 2, (parentWidget()->height() - newHeight) / 2, newWidth, newHeight); setGeometry((parentWidget()->width() - newWidth) / 2, (parentWidget()->height() - newHeight) / 2, newWidth, newHeight);
} }

View File

@ -431,7 +431,7 @@ void RoundButton::resizeToText() {
resize(innerWidth - _st.width + _st.padding.left() + _st.padding.right(), _st.height + _st.padding.top() + _st.padding.bottom()); resize(innerWidth - _st.width + _st.padding.left() + _st.padding.right(), _st.height + _st.padding.top() + _st.padding.bottom());
} else { } else {
if (_st.width < innerWidth + (_st.height - _st.font->height)) { if (_st.width < innerWidth + (_st.height - _st.font->height)) {
_text = _st.font->elided(computeFullText(), qMax(_st.width - (_st.height - _st.font->height), 1)); _text = _st.font->elided(computeFullText(), std::max(_st.width - (_st.height - _st.font->height), 1));
_textWidth = _st.font->width(_text); _textWidth = _st.font->width(_text);
} }
resize(_st.width + _st.padding.left() + _st.padding.right(), _st.height + _st.padding.top() + _st.padding.bottom()); resize(_st.width + _st.padding.left() + _st.padding.right(), _st.height + _st.padding.top() + _st.padding.bottom());
@ -600,7 +600,7 @@ void LeftOutlineButton::setText(const QString &text) {
} }
int LeftOutlineButton::resizeGetHeight(int newWidth) { int LeftOutlineButton::resizeGetHeight(int newWidth) {
int availableWidth = qMax(newWidth - _st.padding.left() - _st.padding.right(), 1); int availableWidth = std::max(newWidth - _st.padding.left() - _st.padding.right(), 1);
if ((availableWidth < _fullTextWidth) || (_textWidth < availableWidth)) { if ((availableWidth < _fullTextWidth) || (_textWidth < availableWidth)) {
_text = _st.font->elided(_fullText, availableWidth); _text = _st.font->elided(_fullText, availableWidth);
_textWidth = _st.font->width(_text); _textWidth = _st.font->width(_text);

View File

@ -268,7 +268,7 @@ void RadioView::paint(Painter &p, int left, int top, int outerWidth, TimeMs ms)
pen.setWidth(_st->thickness); pen.setWidth(_st->thickness);
p.setPen(pen); p.setPen(pen);
p.setBrush(_st->bg); p.setBrush(_st->bg);
//qint32 skip = qCeil(_st->thickness / 2.); //qint32 skip = std::ceil(_st->thickness / 2.);
//p.drawEllipse(_checkRect.marginsRemoved(QMargins(skip, skip, skip, skip))); //p.drawEllipse(_checkRect.marginsRemoved(QMargins(skip, skip, skip, skip)));
p.drawEllipse(rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(_st->thickness / 2., _st->thickness / 2., _st->thickness / 2., _st->thickness / 2.)), outerWidth)); p.drawEllipse(rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(_st->thickness / 2., _st->thickness / 2., _st->thickness / 2., _st->thickness / 2.)), outerWidth));
@ -278,7 +278,7 @@ void RadioView::paint(Painter &p, int left, int top, int outerWidth, TimeMs ms)
auto skip0 = _st->diameter / 2., skip1 = _st->skip / 10., checkSkip = skip0 * (1. - toggled) + skip1 * toggled; auto skip0 = _st->diameter / 2., skip1 = _st->skip / 10., checkSkip = skip0 * (1. - toggled) + skip1 * toggled;
p.drawEllipse(rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip)), outerWidth)); p.drawEllipse(rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip)), outerWidth));
//qint32 fskip = qFloor(checkSkip), cskip = qCeil(checkSkip); //qint32 fskip = std::floor(checkSkip), cskip = std::ceil(checkSkip);
//if (2 * fskip < _checkRect.width()) { //if (2 * fskip < _checkRect.width()) {
// if (fskip != cskip) { // if (fskip != cskip) {
// p.setOpacity(double(cskip) - checkSkip); // p.setOpacity(double(cskip) - checkSkip);
@ -376,7 +376,7 @@ void Checkbox::paintEvent(QPaintEvent *e) {
} }
if (realCheckRect.contains(e->rect())) return; if (realCheckRect.contains(e->rect())) return;
auto textWidth = qMax(width() - (_checkRect.width() + _st.textPosition.x() + _st.textPosition.x()), 1); auto textWidth = std::max(width() - (_checkRect.width() + _st.textPosition.x() + _st.textPosition.x()), 1);
p.setPen(_st.textFg); p.setPen(_st.textFg);
_text.drawLeftElided(p, _st.margin.left() + _checkRect.width() + _st.textPosition.x(), _st.margin.top() + _st.textPosition.y(), textWidth, width()); _text.drawLeftElided(p, _st.margin.left() + _checkRect.width() + _st.textPosition.x(), _st.margin.top() + _st.textPosition.y(), textWidth, width());

View File

@ -171,11 +171,11 @@ void FilledSlider::paintEvent(QPaintEvent *e) {
auto disabled = isDisabled(); auto disabled = isDisabled();
auto over = getCurrentOverFactor(ms); auto over = getCurrentOverFactor(ms);
auto lineWidth = _st.lineWidth + ((_st.fullWidth - _st.lineWidth) * over); auto lineWidth = _st.lineWidth + ((_st.fullWidth - _st.lineWidth) * over);
auto lineWidthRounded = qFloor(lineWidth); auto lineWidthRounded = std::floor(lineWidth);
auto lineWidthPartial = lineWidth - lineWidthRounded; auto lineWidthPartial = lineWidth - lineWidthRounded;
auto seekRect = getSeekRect(); auto seekRect = getSeekRect();
auto value = getCurrentValue(); auto value = getCurrentValue();
auto from = seekRect.x(), mid = qRound(from + value * seekRect.width()), end = from + seekRect.width(); int from = seekRect.x(), mid = std::round(from + value * seekRect.width()), end = from + seekRect.width();
if (mid > from) { if (mid > from) {
p.setOpacity(masterOpacity); p.setOpacity(masterOpacity);
p.fillRect(from, height() - lineWidthRounded, (mid - from), lineWidthRounded, disabled ? _st.disabledFg : _st.activeFg); p.fillRect(from, height() - lineWidthRounded, (mid - from), lineWidthRounded, disabled ? _st.disabledFg : _st.activeFg);
@ -230,7 +230,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
auto markerLength = (horizontal ? seekRect.width() : seekRect.height()); auto markerLength = (horizontal ? seekRect.width() : seekRect.height());
auto from = _alwaysDisplayMarker ? 0 : markerFrom; auto from = _alwaysDisplayMarker ? 0 : markerFrom;
auto length = _alwaysDisplayMarker ? (horizontal ? width() : height()) : markerLength; auto length = _alwaysDisplayMarker ? (horizontal ? width() : height()) : markerLength;
auto mid = qRound(from + value * length); auto mid = std::round(from + value * length);
auto end = from + length; auto end = from + length;
auto activeFg = disabled ? _st.activeFgDisabled : anim::brush(_st.activeFg, _st.activeFgOver, over); auto activeFg = disabled ? _st.activeFgDisabled : anim::brush(_st.activeFg, _st.activeFgOver, over);
auto inactiveFg = disabled ? _st.inactiveFgDisabled : anim::brush(_st.inactiveFg, _st.inactiveFgOver, over); auto inactiveFg = disabled ? _st.inactiveFgDisabled : anim::brush(_st.inactiveFg, _st.inactiveFgOver, over);
@ -254,7 +254,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
} }
auto markerSizeRatio = disabled ? 0. : (_alwaysDisplayMarker ? 1. : over); auto markerSizeRatio = disabled ? 0. : (_alwaysDisplayMarker ? 1. : over);
if (markerSizeRatio > 0) { if (markerSizeRatio > 0) {
auto position = qRound(markerFrom + value * markerLength) - (horizontal ? seekRect.x() : seekRect.y()); auto position = std::round(markerFrom + value * markerLength) - (horizontal ? seekRect.x() : seekRect.y());
auto seekButton = horizontal auto seekButton = horizontal
? QRect(position, (height() - _st.seekSize.height()) / 2, _st.seekSize.width(), _st.seekSize.height()) ? QRect(position, (height() - _st.seekSize.height()) / 2, _st.seekSize.width(), _st.seekSize.height())
: QRect((width() - _st.seekSize.width()) / 2, position, _st.seekSize.width(), _st.seekSize.height()); : QRect((width() - _st.seekSize.width()) / 2, position, _st.seekSize.width(), _st.seekSize.height());

View File

@ -190,9 +190,9 @@ void SettingsSlider::resizeSections(int newWidth) {
auto skip = 0; auto skip = 0;
auto x = 0.; auto x = 0.;
enumerateSections([this, &x, &skip, sectionWidth](Section &section) { enumerateSections([this, &x, &skip, sectionWidth](Section &section) {
section.left = qFloor(x) + skip; section.left = std::floor(x) + skip;
x += sectionWidth; x += sectionWidth;
section.width = qRound(x) - (section.left - skip); section.width = std::round(x) - (section.left - skip);
skip += _st.barSkip; skip += _st.barSkip;
return true; return true;
}); });
@ -256,13 +256,13 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
} }
auto from = section.left, tofill = section.width; auto from = section.left, tofill = section.width;
if (activeLeft > from) { if (activeLeft > from) {
auto fill = qMin(tofill, activeLeft - from); auto fill = std::min(tofill, activeLeft - from);
p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFg); p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFg);
from += fill; from += fill;
tofill -= fill; tofill -= fill;
} }
if (activeLeft + section.width > from) { if (activeLeft + section.width > from) {
if (auto fill = qMin(tofill, activeLeft + section.width - from)) { if (auto fill = std::min(tofill, activeLeft + section.width - from)) {
p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFgActive); p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFgActive);
from += fill; from += fill;
tofill -= fill; tofill -= fill;

View File

@ -926,7 +926,7 @@ void FlatTextarea::insertFromMimeData(const QMimeData *source) {
_insertedTags.clear(); _insertedTags.clear();
} }
auto cursor = textCursor(); auto cursor = textCursor();
_realInsertPosition = qMin(cursor.position(), cursor.anchor()); _realInsertPosition = std::min(cursor.position(), cursor.anchor());
_realCharsAdded = text.size(); _realCharsAdded = text.size();
QTextEdit::insertFromMimeData(source); QTextEdit::insertFromMimeData(source);
if (!_inDrop) { if (!_inDrop) {
@ -1129,7 +1129,7 @@ void FlatTextarea::processFormatting(int insertPosition, int insertEnd) {
} }
} }
auto *ch = textStart + qMax(changedPositionInFragment, 0); auto *ch = textStart + std::max(changedPositionInFragment, 0);
for (; ch < textEnd; ++ch) { for (; ch < textEnd; ++ch) {
int emojiLength = 0; int emojiLength = 0;
if (auto emoji = Ui::Emoji::Find(ch, textEnd, &emojiLength)) { if (auto emoji = Ui::Emoji::Find(ch, textEnd, &emojiLength)) {
@ -1815,7 +1815,7 @@ bool InputArea::heightAutoupdated() {
myEnsureResized(this); myEnsureResized(this);
int newh = qCeil(_inner->document()->size().height()) + _st.textMargins.top() + _st.textMargins.bottom(); int newh = std::ceil(_inner->document()->size().height()) + _st.textMargins.top() + _st.textMargins.bottom();
if (newh > _st.heightMax) { if (newh > _st.heightMax) {
newh = _st.heightMax; newh = _st.heightMax;
} else if (newh < _st.heightMin) { } else if (newh < _st.heightMin) {
@ -1904,8 +1904,8 @@ void InputArea::paintEvent(QPaintEvent *e) {
auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.);
if (_st.borderActive && (borderOpacity > 0.)) { if (_st.borderActive && (borderOpacity > 0.)) {
auto borderStart = snap(_borderAnimationStart, 0, width()); auto borderStart = snap(_borderAnimationStart, 0, width());
auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); auto borderFrom = std::round(borderStart * (1. - borderShownDegree));
auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree);
if (borderTo > borderFrom) { if (borderTo > borderFrom) {
auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree);
p.setOpacity(borderOpacity); p.setOpacity(borderOpacity);
@ -2637,8 +2637,8 @@ void InputField::paintEvent(QPaintEvent *e) {
auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.);
if (_st.borderActive && (borderOpacity > 0.)) { if (_st.borderActive && (borderOpacity > 0.)) {
auto borderStart = snap(_borderAnimationStart, 0, width()); auto borderStart = snap(_borderAnimationStart, 0, width());
auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); auto borderFrom = std::round(borderStart * (1. - borderShownDegree));
auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree);
if (borderTo > borderFrom) { if (borderTo > borderFrom) {
auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree);
p.setOpacity(borderOpacity); p.setOpacity(borderOpacity);
@ -3412,8 +3412,8 @@ void MaskedInputField::paintEvent(QPaintEvent *e) {
auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.);
if (_st.borderActive && (borderOpacity > 0.)) { if (_st.borderActive && (borderOpacity > 0.)) {
auto borderStart = snap(_borderAnimationStart, 0, width()); auto borderStart = snap(_borderAnimationStart, 0, width());
auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); auto borderFrom = std::round(borderStart * (1. - borderShownDegree));
auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree);
if (borderTo > borderFrom) { if (borderTo > borderFrom) {
auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree);
p.setOpacity(borderOpacity); p.setOpacity(borderOpacity);
@ -4003,7 +4003,7 @@ void PhoneInput::correctValue(const QString &was, qint32 wasCursor, QString &now
} }
QString newText; QString newText;
int oldPos(nowCursor), newPos(-1), oldLen(now.length()), digitCount = qMin(digits.size(), MaxPhoneCodeLength + MaxPhoneTailLength); int oldPos(nowCursor), newPos(-1), oldLen(now.length()), digitCount = std::min(digits.size(), MaxPhoneCodeLength + MaxPhoneTailLength);
bool inPart = !_pattern.isEmpty(), plusFound = false; bool inPart = !_pattern.isEmpty(), plusFound = false;
int curPart = 0, leftInPart = inPart ? _pattern.at(curPart) : 0; int curPart = 0, leftInPart = inPart ? _pattern.at(curPart) : 0;

View File

@ -222,7 +222,7 @@ int FlatLabel::countTextWidth() const {
int FlatLabel::countTextHeight(int textWidth) { int FlatLabel::countTextHeight(int textWidth) {
_fullTextHeight = _text.countHeight(textWidth); _fullTextHeight = _text.countHeight(textWidth);
return _st.maxHeight ? qMin(_fullTextHeight, _st.maxHeight) : _fullTextHeight; return _st.maxHeight ? std::min(_fullTextHeight, _st.maxHeight) : _fullTextHeight;
} }
void FlatLabel::refreshSize() { void FlatLabel::refreshSize() {
@ -618,7 +618,7 @@ std::unique_ptr<CrossFadeAnimation> FlatLabel::CrossFade(FlatLabel *from, FlatLa
auto was = prepareData(from); auto was = prepareData(from);
auto now = prepareData(to); auto now = prepareData(to);
auto maxLines = qMax(was.lineWidths.size(), now.lineWidths.size()); auto maxLines = std::max(was.lineWidths.size(), now.lineWidths.size());
auto fillDataTill = [maxLines](Data &data) { auto fillDataTill = [maxLines](Data &data) {
for (auto i = data.lineWidths.size(); i != maxLines; ++i) { for (auto i = data.lineWidths.size(); i != maxLines; ++i) {
data.lineWidths.push_back(-1); data.lineWidths.push_back(-1);
@ -690,7 +690,7 @@ void FlatLabel::updateHover(const Text::StateResult &state) {
if (state.afterSymbol && _selectionType == TextSelectType::Letters) { if (state.afterSymbol && _selectionType == TextSelectType::Letters) {
++second; ++second;
} }
auto selection = _text.adjustSelection({ qMin(second, _dragSymbol), qMax(second, _dragSymbol) }, _selectionType); auto selection = _text.adjustSelection({ std::min(second, _dragSymbol), std::max(second, _dragSymbol) }, _selectionType);
if (_selection != selection) { if (_selection != selection) {
_selection = selection; _selection = selection;
_savedSelection = { 0, 0 }; _savedSelection = { 0, 0 };
@ -744,8 +744,8 @@ Text::StateResult FlatLabel::getTextState(const QPoint &m) const {
bool heightExceeded = _st.maxHeight && (_st.maxHeight < _fullTextHeight || textWidth < _text.maxWidth()); bool heightExceeded = _st.maxHeight && (_st.maxHeight < _fullTextHeight || textWidth < _text.maxWidth());
bool renderElided = _breakEverywhere || heightExceeded; bool renderElided = _breakEverywhere || heightExceeded;
if (renderElided) { if (renderElided) {
auto lineHeight = qMax(_st.style.lineHeight, _st.style.font->height); auto lineHeight = std::max(_st.style.lineHeight, _st.style.font->height);
auto lines = _st.maxHeight ? qMax(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2); auto lines = _st.maxHeight ? std::max(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2);
request.lines = lines; request.lines = lines;
if (_breakEverywhere) { if (_breakEverywhere) {
request.flags |= Text::StateRequest::Flag::BreakEverywhere; request.flags |= Text::StateRequest::Flag::BreakEverywhere;
@ -773,8 +773,8 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
bool heightExceeded = _st.maxHeight && (_st.maxHeight < _fullTextHeight || textWidth < _text.maxWidth()); bool heightExceeded = _st.maxHeight && (_st.maxHeight < _fullTextHeight || textWidth < _text.maxWidth());
bool renderElided = _breakEverywhere || heightExceeded; bool renderElided = _breakEverywhere || heightExceeded;
if (renderElided) { if (renderElided) {
auto lineHeight = qMax(_st.style.lineHeight, _st.style.font->height); auto lineHeight = std::max(_st.style.lineHeight, _st.style.font->height);
auto lines = _st.maxHeight ? qMax(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2); auto lines = _st.maxHeight ? std::max(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2);
_text.drawElided(p, _st.margin.left(), _st.margin.top(), textWidth, lines, _st.align, e->rect().y(), e->rect().bottom(), 0, _breakEverywhere, selection); _text.drawElided(p, _st.margin.left(), _st.margin.top(), textWidth, lines, _st.align, e->rect().y(), e->rect().bottom(), 0, _breakEverywhere, selection);
} else { } else {
_text.draw(p, _st.margin.left(), _st.margin.top(), textWidth, _st.align, e->rect().y(), e->rect().bottom(), selection); _text.draw(p, _st.margin.left(), _st.margin.top(), textWidth, _st.align, e->rect().y(), e->rect().bottom(), selection);

View File

@ -78,7 +78,7 @@ QAction *Menu::addAction(QAction *action, const style::icon *icon, const style::
}; };
_actionsData.push_back(createData()); _actionsData.push_back(createData());
auto newWidth = qMax(width(), _st.widthMin); auto newWidth = std::max(width(), _st.widthMin);
newWidth = processAction(action, _actions.size() - 1, newWidth); newWidth = processAction(action, _actions.size() - 1, newWidth);
auto newHeight = height() + (action->isSeparator() ? _separatorHeight : _itemHeight); auto newHeight = height() + (action->isSeparator() ? _separatorHeight : _itemHeight);
resize(_forceWidth ? _forceWidth : newWidth, newHeight); resize(_forceWidth ? _forceWidth : newWidth, newHeight);

Some files were not shown because too many files have changed in this diff Show More