diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 521771dd0..ed5385d2a 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -687,7 +687,7 @@ void ApiWrap::lastParticipantsDone(ChannelData *peer, const MTPchannels_ChannelP if (!keyboardBotFound) { h->clearLastKeyboard(); } - int newMembersCount = qMax(d.vcount.v, v.count()); + int newMembersCount = std::max(d.vcount.v, v.count()); if (newMembersCount > peer->membersCount()) { peer->setMembersCount(newMembersCount); } @@ -1334,7 +1334,7 @@ void ApiWrap::resolveWebPages() { } } } else { - m = qMin(m, i.key()->pendingTill - t); + m = std::min(m, i.key()->pendingTill - t); } } diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index 08db86bfd..42603af23 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -223,7 +223,7 @@ void AuthSession::checkAutoLock() { auto shouldLockInMs = Global::AutoLock() * 1000LL; auto idleForMs = psIdleTime(); auto notPlayingVideoForMs = now - data().lastTimeVideoPlayedAt(); - auto checkTimeMs = qMin(idleForMs, notPlayingVideoForMs); + auto checkTimeMs = std::min(idleForMs, notPlayingVideoForMs); if (checkTimeMs >= shouldLockInMs || (_shouldLockAt > 0 && now > _shouldLockAt + kAutoLockTimeoutLateMs)) { Messenger::Instance().setupPasscode(); } else { diff --git a/Telegram/SourceFiles/base/task_queue.cpp b/Telegram/SourceFiles/base/task_queue.cpp index 02395e481..b31d07a5d 100644 --- a/Telegram/SourceFiles/base/task_queue.cpp +++ b/Telegram/SourceFiles/base/task_queue.cpp @@ -27,7 +27,7 @@ namespace base { namespace { 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 diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index 2c14d811b..f0662a0a4 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -104,7 +104,7 @@ void BoxContent::onDraggingScrollDelta(int delta) { } 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); } @@ -336,7 +336,7 @@ void AbstractBox::updateTitlePosition() { _titleLeft = _layerType ? st::boxLayerTitlePosition.x() : st::boxTitlePosition.x(); _titleTop = _layerType ? st::boxLayerTitlePosition.y() : st::boxTitlePosition.y(); if (_title) { - _title->resizeToWidth(qMin(_title->naturalWidth(), width() - _titleLeft * 2)); + _title->resizeToWidth(std::min(_title->naturalWidth(), width() - _titleLeft * 2)); _title->moveToLeft(_titleLeft, _titleTop); } } @@ -378,7 +378,7 @@ void AbstractBox::setDimensions(int newWidth, int maxHeight) { auto newGeometry = geometry(); auto parentHeight = parentWidget()->height(); 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()) { move(newGeometry.left(), newTop); } @@ -391,7 +391,7 @@ void AbstractBox::setDimensions(int newWidth, int maxHeight) { } 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 { diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index b45dfc3b2..b9e5e972a 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -1103,7 +1103,7 @@ void EditBioBox::handleBioUpdated() { cursor.setPosition(position); _bio->setTextCursor(cursor); } - auto countLeft = qMax(kMaxBioLength - text.size(), 0); + auto countLeft = std::max(kMaxBioLength - text.size(), 0); _countdown->setText(QString::number(countLeft)); } @@ -1503,7 +1503,7 @@ void RevokePublicLinkBox::Inner::paintChat(Painter &p, const ChatRow &row, bool if (peer->isVerified()) { auto icon = &st::dialogsVerifiedIcon; 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()); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 681a0a7e4..791ca403a 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -130,7 +130,7 @@ void ConfirmBox::prepare() { void ConfirmBox::textUpdated() { _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()); setMouseTracking(_text.hasLinks()); @@ -227,7 +227,7 @@ void MaxInviteBox::prepare() { addButton(langFactory(lng_box_ok), [this] { closeBox(); }); _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()); subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) { @@ -474,7 +474,7 @@ void DeleteMessagesBox::prepare() { canDeleteAllForEveryone = false; } } - auto count = qMax(1, _ids.size()); + auto count = std::max(1, _ids.size()); if (canDeleteAllForEveryone) { _forEveryone.create(this, forEveryoneText, false, st::defaultBoxCheckbox); } else if (peer && peer->isChannel()) { diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index 2d36f29d4..741515072 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -202,7 +202,7 @@ void EditColorBox::Picker::updateCurrentPoint(QPoint localPosition) { void EditColorBox::Picker::setHSV(int hue, int saturation, int brightness) { _topleft = QColor(255, 255, 255); - _topright.setHsv(qMax(0, hue), 255, 255); + _topright.setHsv(std::max(0, hue), 255, 255); _topright = _topright.toRgb(); _bottomleft = _bottomright = QColor(0, 0, 0); @@ -305,11 +305,11 @@ void EditColorBox::Slider::paintEvent(QPaintEvent *e) { } p.drawPixmap(to, _pixmap, _pixmap.rect()); 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::colorSliderArrowBottom.paint(p, x - st::colorSliderArrowBottom.width() / 2, height() - st::colorSliderArrowBottom.height(), width()); } 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::colorSliderArrowRight.paint(p, width() - st::colorSliderArrowRight.width(), y - st::colorSliderArrowRight.height() / 2, width()); } @@ -737,10 +737,10 @@ void EditColorBox::saveColor() { } void EditColorBox::updateHSVFields() { - auto hue = qRound((1. - _hueSlider->value()) * 360); - auto saturation = qRound(_picker->valueX() * 255); - auto brightness = qRound((1. - _picker->valueY()) * 255); - auto alpha = qRound(_opacitySlider->value() * 255); + auto hue = std::round((1. - _hueSlider->value()) * 360); + auto saturation = std::round(_picker->valueX() * 255); + auto brightness = std::round((1. - _picker->valueY()) * 255); + auto alpha = std::round(_opacitySlider->value() * 255); _hueField->setTextWithFocus(QString::number(hue)); _saturationField->setTextWithFocus(QString::number(percentFromByte(saturation))); _brightnessField->setTextWithFocus(QString::number(percentFromByte(brightness))); @@ -827,10 +827,10 @@ void EditColorBox::updateFromColor(QColor color) { } void EditColorBox::updateFromControls() { - auto hue = qRound((1. - _hueSlider->value()) * 360); - auto saturation = qRound(_picker->valueX() * 255); - auto brightness = qRound((1. - _picker->valueY()) * 255); - auto alpha = qRound(_opacitySlider->value() * 255); + auto hue = std::round((1. - _hueSlider->value()) * 360); + auto saturation = std::round(_picker->valueX() * 255); + auto brightness = std::round((1. - _picker->valueY()) * 255); + auto alpha = std::round(_opacitySlider->value() * 255); setHSV(hue, saturation, brightness, alpha); updateHSVFields(); updateControlsFromHSV(hue, saturation, brightness); @@ -840,7 +840,7 @@ void EditColorBox::updateFromHSVFields() { auto hue = _hueField->value(); auto saturation = percentToByte(_saturationField->value()); auto brightness = percentToByte(_brightnessField->value()); - auto alpha = qRound(_opacitySlider->value() * 255); + auto alpha = std::round(_opacitySlider->value() * 255); setHSV(hue, saturation, brightness, alpha); updateControlsFromHSV(hue, saturation, brightness); } @@ -849,7 +849,7 @@ void EditColorBox::updateFromRGBFields() { auto red = _redField->value(); auto blue = _blueField->value(); auto green = _greenField->value(); - auto alpha = qRound(_opacitySlider->value() * 255); + auto alpha = std::round(_opacitySlider->value() * 255); setRGB(red, green, blue, alpha); updateResultField(); } diff --git a/Telegram/SourceFiles/boxes/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/edit_participant_box.cpp index b4098ddd0..078ba142d 100644 --- a/Telegram/SourceFiles/boxes/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_participant_box.cpp @@ -186,7 +186,7 @@ void EditParticipantBox::removeControl(QPointer widget) { void EditParticipantBox::resizeToContent() { _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 channel, not_null user, const MTPChannelAdminRights &rights) : EditParticipantBox(nullptr, channel, user, (rights.c_channelAdminRights().vflags.v != 0)) diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 42c2f789f..10225dd56 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -133,7 +133,7 @@ void LanguageBox::refresh() { refreshLanguages(); _inner->refresh(); - setDimensions(st::langsWidth, qMin(_inner->height(), st::boxMaxListHeight)); + setDimensions(st::langsWidth, std::min(_inner->height(), st::boxMaxListHeight)); } void LanguageBox::refreshLanguages() { diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index 342746065..a21080995 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -360,7 +360,7 @@ void NotificationsBox::setOverCorner(Notify::ScreenCorner corner) { auto &samples = _cornerSamples[static_cast(_overCorner)]; auto samplesAlready = samples.size(); auto samplesNeeded = currentCount(); - auto samplesLeave = qMin(samplesAlready, samplesNeeded); + auto samplesLeave = std::min(samplesAlready, samplesNeeded); for (int i = 0; i != samplesLeave; ++i) { samples[i]->showFast(); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 23002f145..9357c3ff4 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -840,7 +840,7 @@ int PeerListBox::Inner::resizeGetHeight(int newWidth) { _aboveHeight = _aboveWidget->height(); } } - auto labelTop = rowsTop() + qMax(1, shownRowsCount()) * _rowHeight; + auto labelTop = rowsTop() + std::max(1, shownRowsCount()) * _rowHeight; if (_description) { _description->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth); _description->setVisible(!showingSearch()); @@ -953,7 +953,7 @@ void PeerListBox::Inner::paintRow(Painter &p, TimeMs ms, RowIndex index) { if (row->needsVerifiedIcon()) { auto icon = &st::dialogsVerifiedIcon; 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(); p.setPen(anim::pen(st::contactsNameFg, st::contactsNameCheckedFg, nameCheckedRatio)); diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 6d1b1764c..23a7e2a55 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -397,9 +397,9 @@ int AddParticipantsBoxController::alreadyInCount() const { return 1; // self } if (auto chat = _peer->asChat()) { - return qMax(chat->count, 1); + return std::max(chat->count, 1); } 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"); } @@ -530,7 +530,7 @@ int EditChatAdminsBoxController::LabeledCheckbox::resizeGetHeight(int newWidth) _labelWidth = newWidth - st::contactsPadding.left() - st::contactsPadding.right(); _checkbox->resizeToNaturalWidth(_labelWidth); _checkbox->moveToLeft(st::contactsPadding.left(), st::contactsAllAdminsTop); - auto labelHeight = qMax( + auto labelHeight = std::max( _labelChecked.countHeight(_labelWidth), _labelUnchecked.countHeight(_labelWidth)); return st::contactsAboutTop + labelHeight + st::contactsAboutBottom; diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index ebd03b616..747e270a9 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -65,7 +65,7 @@ void SelfDestructionBox::prepare() { auto count = int(_ttlValues.size()); _options.reserve(count); 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); y += _options.back()->heightNoMargins() + st::boxOptionListSkip; } diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index da0b358f6..79e7b2463 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -87,8 +87,8 @@ void SendFilesBox::prepareSingleFileLayout() { if (_animated) { auto limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); auto limitH = st::confirmMaxHeight; - maxW = qMax(image.width(), 1); - maxH = qMax(image.height(), 1); + maxW = std::max(image.width(), 1); + maxH = std::max(image.height(), 1); if (maxW * limitH > maxH * limitW) { if (maxW < limitW) { maxH = maxH * limitW / maxW; @@ -109,12 +109,12 @@ void SendFilesBox::prepareSingleFileLayout() { } _previewWidth = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); if (image.width() < _previewWidth) { - _previewWidth = qMax(image.width(), kMinPreviewWidth); + _previewWidth = std::max(image.width(), kMinPreviewWidth); } - auto maxthumbh = qMin(qRound(1.5 * _previewWidth), st::confirmMaxHeight); - _previewHeight = qRound(originalHeight * double(_previewWidth) / originalWidth); + auto maxthumbh = std::min(std::round(1.5 * _previewWidth), st::confirmMaxHeight); + _previewHeight = std::round(originalHeight * double(_previewWidth) / originalWidth); if (_previewHeight > maxthumbh) { - _previewWidth = qRound(_previewWidth * double(maxthumbh) / _previewHeight); + _previewWidth = std::round(_previewWidth * double(maxthumbh) / _previewHeight); accumulate_max(_previewWidth, kMinPreviewWidth); _previewHeight = maxthumbh; } @@ -182,7 +182,7 @@ void SendFilesBox::prepareDocumentLayout() { auto filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true); _nameText.setText(st::semiboldTextStyle, filename, _textNameOptions); _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; } else { auto fileinfo = QFileInfo(filepath); @@ -202,7 +202,7 @@ void SendFilesBox::prepareDocumentLayout() { auto nameString = DocumentData::composeNameString(filename, songTitle, songPerformer); _nameText.setText(st::semiboldTextStyle, nameString, _textNameOptions); _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); _nameText.setText(st::semiboldTextStyle, name, _textNameOptions); _statusText = _contactPhone; - _statusWidth = qMax(_nameText.maxWidth(), st::normalFont->width(_statusText)); + _statusWidth = std::max(_nameText.maxWidth(), st::normalFont->width(_statusText)); _contactPhotoEmpty.set(0, name); } @@ -510,7 +510,7 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) : _name.setText(st::semiboldTextStyle, doc->composeNameString(), _textNameOptions); } _status = formatSizeText(doc->size); - _statusw = qMax(_name.maxWidth(), st::normalFont->width(_status)); + _statusw = std::max(_name.maxWidth(), st::normalFont->width(_status)); _isImage = doc->isImage(); _isAudio = (doc->voice() || doc->song()); } @@ -519,8 +519,8 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) : if (_animated) { qint32 limitW = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(); qint32 limitH = st::confirmMaxHeight; - maxW = qMax(dimensions.width(), 1); - maxH = qMax(dimensions.height(), 1); + maxW = std::max(dimensions.width(), 1); + maxH = std::max(dimensions.height(), 1); if (maxW * limitH > maxH * limitW) { if (maxW < limitW) { maxH = maxH * limitW / maxW; @@ -547,10 +547,10 @@ EditCaptionBox::EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId) : if (_thumb.width() < _thumbw) { _thumbw = (_thumb.width() > 20) ? _thumb.width() : 20; } - qint32 maxthumbh = qMin(qRound(1.5 * _thumbw), int(st::confirmMaxHeight)); - _thumbh = qRound(th * double(_thumbw) / tw); + qint32 maxthumbh = std::min(std::round(1.5 * _thumbw), int(st::confirmMaxHeight)); + _thumbh = std::round(th * double(_thumbw) / tw); if (_thumbh > maxthumbh) { - _thumbw = qRound(_thumbw * double(maxthumbh) / _thumbh); + _thumbw = std::round(_thumbw * double(maxthumbh) / _thumbh); _thumbh = maxthumbh; if (_thumbw < 10) { _thumbw = 10; diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index b442242cb..0ef20b020 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -269,7 +269,7 @@ void ShareBox::onMustScrollTo(int top, int bottom) { } void ShareBox::scrollAnimationCallback() { - //auto scrollTop = qRound(_scrollAnimation.current(scrollArea()->scrollTop())); + //auto scrollTop = std::round(_scrollAnimation.current(scrollArea()->scrollTop())); //scrollArea()->scrollToY(scrollTop); } @@ -370,7 +370,7 @@ void ShareBox::Inner::repaintChatAtIndex(int index) { auto row = 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) { @@ -497,7 +497,7 @@ void ShareBox::Inner::setActive(int active) { } 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 outerWidth = width(); @@ -596,8 +596,8 @@ void ShareBox::Inner::mouseMoveEvent(QMouseEvent *e) { void ShareBox::Inner::updateUpon(const QPoint &pos) { auto x = pos.x(), y = pos.y(); auto row = (y - _rowsTop) / _rowHeight; - auto column = qFloor((x - _rowsLeft) / _rowWidthReal); - auto left = _rowsLeft + qFloor(column * _rowWidthReal) + st::shareColumnSkip / 2; + auto column = std::floor((x - _rowsLeft) / _rowWidthReal); + auto left = _rowsLeft + std::floor(column * _rowWidthReal) + st::shareColumnSkip / 2; auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop; 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); @@ -622,8 +622,8 @@ void ShareBox::Inner::onSelectActive() { void ShareBox::Inner::resizeEvent(QResizeEvent *e) { _columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / double(_columnCount + 1); _rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip; - _rowsLeft = qFloor(_columnSkip / 2); - _rowWidth = qFloor(_rowWidthReal); + _rowsLeft = std::floor(_columnSkip / 2); + _rowWidth = std::floor(_rowWidthReal); update(); } diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 7a66098a8..e74190107 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -338,8 +338,8 @@ void StickerSetBox::Inner::onPreview() { qint32 StickerSetBox::Inner::stickerFromGlobalPos(const QPoint &p) const { QPoint l(mapFromGlobal(p)); 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 col = (l.x() >= st::stickersPadding.left()) ? qFloor((l.x() - st::stickersPadding.left()) / st::stickersSize.width()) : -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()) ? std::floor((l.x() - st::stickersPadding.left()) / st::stickersSize.width()) : -1; if (row >= 0 && col >= 0 && col < kStickersPanelPerRow) { qint32 result = row * kStickersPanelPerRow + col; return (result < _pack.size()) ? result : -1; @@ -355,7 +355,7 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) { auto ms = getms(); 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 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; - 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 (h < 1) h = 1; QPoint ppos = pos + QPoint((st::stickersSize.width() - w) / 2, (st::stickersSize.height() - h) / 2); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index a1b0cb504..422656e07 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -714,7 +714,7 @@ QRect StickersBox::Inner::relativeButtonRect(bool removeButton) const { } 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 (_megagroupSet) { @@ -1041,8 +1041,8 @@ double StickersBox::Inner::aboveShadowOpacity() const { if (_above < 0) return 0; auto dx = 0; - auto dy = qAbs(_above * _rowHeight + qRound(_rows[_above]->yadd.current()) - _started * _rowHeight); - return qMin((dx + dy) * 2. / _rowHeight, 1.); + auto dy = qAbs(_above * _rowHeight + std::round(_rows[_above]->yadd.current()) - _started * _rowHeight); + return std::min((dx + dy) * 2. / _rowHeight, 1.); } void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { @@ -1324,7 +1324,7 @@ void StickersBox::Inner::setMinHeight(int newWidth, int minHeight) { void StickersBox::Inner::updateSize(int newWidth) { 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(); } diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 76cb8a422..69c8e3b83 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -463,10 +463,10 @@ void Panel::createUserpicCache(ImagePtr image) { auto width = image->width(); auto height = image->height(); if (width > height) { - width = qMax((width * size) / height, 1); + width = std::max((width * size) / height, 1); height = size; } else { - height = qMax((height * size) / width, 1); + height = std::max((height * size) / width, 1); width = size; } _userPhoto = image->pixNoCache(width, height, options, st::callWidth, st::callWidth); @@ -611,8 +611,8 @@ void Panel::paintEvent(QPaintEvent *e) { PainterHighQualityEnabler hq(p); auto marginRatio = (1. - opacity) / 5; - auto marginWidth = qRound(width() * marginRatio); - auto marginHeight = qRound(height() * marginRatio); + auto marginWidth = std::round(width() * marginRatio); + auto marginHeight = std::round(height() * marginRatio); p.drawPixmap(rect().marginsRemoved(QMargins(marginWidth, marginHeight, marginWidth, marginHeight)), _animationCache, QRect(QPoint(0, 0), _animationCache.size())); return; } diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index 416698820..af4084fe3 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -187,7 +187,7 @@ void TopBar::updateControlsGeometry() { _shortInfoLabel->setVisible(!showFull); auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) { - auto minPadding = qMax(left, right); + auto minPadding = std::max(left, right); auto infoWidth = infoLabel->naturalWidth(); auto infoLeft = (width() - infoWidth) / 2; if (infoLeft < minPadding) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 2188146b3..ee8de0b8a 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -555,7 +555,7 @@ void EmojiListWidget::onShowPicker() { auto xmax = width() - _picker->width(); auto coef = double(sel % kEmojiPanelPerRow) / double(kEmojiPanelPerRow - 1); if (rtl()) coef = 1. - coef; - _picker->move(qRound(xmax * coef), y); + _picker->move(std::round(xmax * coef), y); emit disableScroll(true); } @@ -672,7 +672,7 @@ void EmojiListWidget::updateSelected() { if (p.y() >= info.rowsTop && p.y() < info.rowsBottom) { auto sx = (rtl() ? width() - p.x() : p.x()) - st::emojiPanPadding; 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()) { newSelected = -1; } else { diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 9bdc4d29e..b7d156b2b 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -132,7 +132,7 @@ bool FieldAutocomplete::clearFilteredBotCommands() { namespace { template 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) { return (i - b); } @@ -366,7 +366,7 @@ void FieldAutocomplete::setBoundings(QRect boundings) { void FieldAutocomplete::recount(bool resetScroll) { qint32 h = 0, oldst = _scroll->scrollTop(), st = oldst, maxh = 4.5 * st::mentionHeight; 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); h = st::stickerPanPadding + rows * st::stickerPanSize.height(); } else if (!_mrows.isEmpty()) { @@ -564,9 +564,9 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) { 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; - 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 (h < 1) h = 1; QPoint ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2); @@ -578,7 +578,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) { } } } 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(); auto filter = _parent->filter(); bool hasUsername = filter.indexOf('@') > 0; @@ -684,7 +684,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *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) { diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index fb32cd5eb..c427ca821 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -182,7 +182,7 @@ int GifsListWidget::countHeight() { for (int i = 0, l = _rows.count(); i < l; ++i) { result += _rows[i].height; } - return qMax(minimalLastHeight, result) + st::stickerPanPadding; + return std::max(minimalLastHeight, result) + st::stickerPanPadding; } GifsListWidget::~GifsListWidget() { @@ -581,8 +581,8 @@ GifsListWidget::Row &GifsListWidget::layoutInlineRow(Row &row, qint32 sumWidth) for (int i = 0; i < count; ++i) { int index = indices[i]; int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth(); - int actualw = qMax(w, int(st::inlineResultsMinWidth)); - row.height = qMax(row.height, row.items[index]->resizeGetHeight(actualw)); + int actualw = std::max(w, int(st::inlineResultsMinWidth)); + row.height = std::max(row.height, row.items[index]->resizeGetHeight(actualw)); if (sumWidth) { availw -= actualw; sumWidth -= row.items.at(index)->maxWidth(); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 3729ebcc6..b728e3986 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -125,11 +125,11 @@ StickersListWidget::Footer::Footer(not_null parent) : Inner template void StickersListWidget::Footer::enumerateVisibleIcons(Callback callback) { - auto iconsX = qRound(_iconsX.current()); + int iconsX = std::round(_iconsX.current()); auto index = iconsX / st::emojiCategory.width; auto x = _iconsLeft - (iconsX % st::emojiCategory.width); - for (auto index = qMin(_icons.size(), iconsX / st::emojiCategory.width), - last = qMin(_icons.size(), index + kVisibleIconsCount); index != last; ++index) { + for (auto index = std::min(_icons.size(), iconsX / st::emojiCategory.width), + last = std::min(_icons.size(), index + kVisibleIconsCount); index != last; ++index) { callback(_icons[index], x); x += st::emojiCategory.width; } @@ -198,8 +198,8 @@ void StickersListWidget::Footer::paintEvent(QPaintEvent *e) { paintStickerSettingsIcon(p); } - auto selxrel = _iconsLeft + qRound(_iconSelX.current()); - auto selx = selxrel - qRound(_iconsX.current()); + auto selxrel = _iconsLeft + std::round(_iconSelX.current()); + auto selx = selxrel - std::round(_iconsX.current()); auto clip = QRect(_iconsLeft, _iconsTop, _iconsLeft + (kVisibleIconsCount - 1) * st::emojiCategory.width - _iconsLeft, st::emojiCategory.height); if (rtl()) clip.moveLeft(width() - _iconsLeft - clip.width()); @@ -258,7 +258,7 @@ void StickersListWidget::Footer::mousePressEvent(QMouseEvent *e) { } else { _iconDown = _iconOver; _iconsMouseDown = _iconsMousePos; - _iconsStartX = qRound(_iconsX.current()); + _iconsStartX = std::round(_iconsX.current()); } } @@ -273,7 +273,7 @@ void StickersListWidget::Footer::mouseMoveEvent(QMouseEvent *e) { } if (_iconsDragging) { 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); _iconsStartAnim = 0; _a_icons.stop(); @@ -293,7 +293,7 @@ void StickersListWidget::Footer::mouseReleaseEvent(QMouseEvent *e) { _iconsMousePos = e ? e->globalPos() : QCursor::pos(); if (_iconsDragging) { 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); _iconsStartAnim = 0; _a_icons.stop(); @@ -320,13 +320,13 @@ bool StickersListWidget::Footer::event(QEvent *e) { auto horizontal = (ev->angleDelta().x() != 0 || ev->orientation() == Qt::Horizontal); auto vertical = (ev->angleDelta().y() != 0 || ev->orientation() == Qt::Vertical); if (horizontal) _horizontal = true; - auto newX = qRound(_iconsX.current()); + int newX = std::round(_iconsX.current()); if (/*_horizontal && */horizontal) { newX = snap(newX - (rtl() ? -1 : 1) * (ev->pixelDelta().x() ? ev->pixelDelta().x() : ev->angleDelta().x()), 0, _iconsMax); } else if (/*!_horizontal && */vertical) { 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); _iconsStartAnim = 0; _a_icons.stop(); @@ -353,8 +353,8 @@ void StickersListWidget::Footer::updateSelected() { } } 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) { - x += qRound(_iconsX.current()); - newOver = qFloor(x / st::emojiCategory.width); + x += std::round(_iconsX.current()); + newOver = std::floor(x / st::emojiCategory.width); } } if (newOver != _iconOver) { @@ -377,7 +377,7 @@ void StickersListWidget::Footer::refreshIcons(ValidateIconAnimations animations) if (_icons.isEmpty()) { _iconsMax = 0; } 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) { _iconsX = anim::value(_iconsMax, _iconsMax); @@ -491,7 +491,7 @@ void StickersListWidget::readVisibleSets() { if (i * rowHeight < itemsVisibleTop || (i + 1) * rowHeight > itemsVisibleBottom) { continue; } - int count = qMin(set.pack.size(), static_cast(kStickersPanelPerRow)); + int count = std::min(set.pack.size(), static_cast(kStickersPanelPerRow)); int loaded = 0; for (int j = 0; j < count; ++j) { if (set.pack[j]->thumb->loaded() || set.pack[j]->loaded()) { @@ -568,11 +568,11 @@ int StickersListWidget::countHeight() { return st::stickerPanPadding + shownSets().size() * featuredRowHeight(); } else if (!shownSets().empty()) { 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 qMax(minimalLastHeight, countResult()) + st::stickerPanPadding; + return std::max(minimalLastHeight, countResult()) + st::stickerPanPadding; } void StickersListWidget::installedLocally(quint64 setId) { @@ -827,10 +827,10 @@ void StickersListWidget::paintSticker(Painter &p, Set &set, int y, int index, bo 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; - auto w = qMax(qRound(coef * sticker->dimensions.width()), 1); - auto h = qMax(qRound(coef * sticker->dimensions.height()), 1); + auto w = std::max(std::round(coef * sticker->dimensions.width()), 1); + auto h = std::max(std::round(coef * sticker->dimensions.height()), 1); auto ppos = pos + QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2); if (goodThumb) { 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()) { 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()) { auto overDelete = false; newSelected = OverSticker { section, index, overDelete }; @@ -1460,8 +1460,8 @@ void StickersListWidget::updateSelected() { } } else { auto special = ((set.flags & MTPDstickerSet::Flag::f_official) != 0); - auto rowIndex = qFloor(yOffset / st::stickerPanSize.height()); - auto columnIndex = qFloor(sx / st::stickerPanSize.width()); + int rowIndex = std::floor(yOffset / st::stickerPanSize.height()); + int columnIndex = std::floor(sx / st::stickerPanSize.width()); auto index = rowIndex * kStickersPanelPerRow + columnIndex; if (index >= 0 && index < set.pack.size()) { auto overDelete = false; diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index 710f96a8c..b3703991a 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -100,7 +100,7 @@ void TabbedPanel::updateContentHeight() { auto addedHeight = innerPadding().top() + innerPadding().bottom(); auto marginsHeight = _selector->marginTop() + _selector->marginBottom(); 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 resultTop = _bottom - addedHeight - contentHeight; if (contentHeight == _contentHeight) { diff --git a/Telegram/SourceFiles/codegen/lang/generator.cpp b/Telegram/SourceFiles/codegen/lang/generator.cpp index 5b272a0cd..5ae39611b 100644 --- a/Telegram/SourceFiles/codegen/lang/generator.cpp +++ b/Telegram/SourceFiles/codegen/lang/generator.cpp @@ -459,7 +459,7 @@ void Generator::writeSetSearch(const std::set> &s for (auto i = 1; i != usedIfForCheckCount; ++i) { checkTypes.push_back(UsedCheckType::UpcomingIf); chars.push_back(keyChar); - checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); + checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back())); keyChar = name[checking + i]; } } else { @@ -468,7 +468,7 @@ void Generator::writeSetSearch(const std::set> &s } ++tabsUsed; 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"; } diff --git a/Telegram/SourceFiles/codegen/style/generator.cpp b/Telegram/SourceFiles/codegen/style/generator.cpp index 9dfa0f712..faef6aeaa 100644 --- a/Telegram/SourceFiles/codegen/style/generator.cpp +++ b/Telegram/SourceFiles/codegen/style/generator.cpp @@ -931,7 +931,7 @@ int getPaletteIndex(QLatin1String name) {\n\ for (auto i = 1; i != usedIfForCheckCount; ++i) { checkTypes.push_back(UsedCheckType::UpcomingIf); chars.push_back(keyChar); - checkLengthHistory.push_back(qMax(minimalLengthCheck, checkLengthHistory.back())); + checkLengthHistory.push_back(std::max(minimalLengthCheck, checkLengthHistory.back())); keyChar = name[checking + i]; } } else { @@ -940,7 +940,7 @@ int getPaletteIndex(QLatin1String name) {\n\ } ++tabsUsed; 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"; } diff --git a/Telegram/SourceFiles/codegen/style/parsed_file.cpp b/Telegram/SourceFiles/codegen/style/parsed_file.cpp index 726fb5a80..9f129f3af 100644 --- a/Telegram/SourceFiles/codegen/style/parsed_file.cpp +++ b/Telegram/SourceFiles/codegen/style/parsed_file.cpp @@ -79,7 +79,7 @@ bool isValidColor(const QString &str) { } 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) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index be95f474d..a5f0cd287 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -374,7 +374,7 @@ void DialogsInner::paintDialog(Painter &p, Dialogs::Row *row, int fullWidth, Pee auto pos = row->pos(); auto xadd = 0, yadd = 0; if (pos < _pinnedRows.size()) { - yadd = qRound(_pinnedRows[pos].yadd.current()); + yadd = std::round(_pinnedRows[pos].yadd.current()); } if (xadd || yadd) p.translate(xadd, yadd); 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()) { auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon)); 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); @@ -784,7 +784,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) { _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()); if (!_pinnedRows[_draggingIndex].animStartTime) { _pinnedRows[_draggingIndex].yadd.finish(); @@ -835,7 +835,7 @@ void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) { if (_aboveIndex >= 0 && _aboveIndex < _pinnedRows.size()) { // Always include currently dragged chat in its current and old positions. 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); _aboveTopShift = aboveTopShift; @@ -951,7 +951,7 @@ void DialogsInner::setSearchedPressed(int pressed) { void DialogsInner::resizeEvent(QResizeEvent *e) { _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); _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) { refresh(); } 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 top = dialogsOffset(); 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); } @@ -1098,7 +1098,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect auto position = row->pos(); auto top = dialogsOffset(); if (position >= 0 && position < _pinnedRows.size()) { - top += qRound(_pinnedRows[position].yadd.current()); + top += std::round(_pinnedRows[position].yadd.current()); } updateRow(top + position * st::dialogsRowHeight); } @@ -1151,7 +1151,7 @@ void DialogsInner::updateSelectedRow(PeerData *peer) { auto position = h->posInChatList(Global::DialogsMode()); auto top = dialogsOffset(); 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); } @@ -1381,7 +1381,7 @@ void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) { auto &recent = cRecentSearchHashtags(); _hashtagResults.clear(); 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) { if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) { _hashtagResults.push_back(std::make_unique(i->first)); @@ -1663,7 +1663,7 @@ void DialogsInner::notify_historyMuteUpdated(History *history) { if (creating) { refresh(); } 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); } } } diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index f475efcf2..aaf9cc423 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -153,7 +153,7 @@ void paintRow(Painter &p, const RippleRow *row, History *history, not_nullpeer && from->isVerified()) { auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon)); 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)); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index bae6fcaee..92823d213 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -436,7 +436,7 @@ void DialogsWidget::onDraggingScrollDelta(int delta) { } 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); } @@ -943,7 +943,7 @@ void DialogsWidget::updateControlsGeometry() { auto smallLayoutRatio = (width() < st::dialogsWidthMin) ? (st::dialogsWidthMin - width()) / double(st::dialogsWidthMin - smallLayoutWidth) : 0.; 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 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 filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2; filterLeft = anim::interpolate(filterLeft, smallLayoutWidth, smallLayoutRatio); @@ -1062,7 +1062,7 @@ void DialogsWidget::paintEvent(QPaintEvent *e) { 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()) { p.drawPixmapLeft(0, _scroll->y(), width(), _widthAnimationCache); belowTop = _scroll->y() + (_widthAnimationCache.height() / cIntRetinaFactor()); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index bbcd0cbef..aa91deacb 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -428,7 +428,7 @@ bool CheckBetaVersionDir() { QByteArray k; dataStream >> v >> k; if (dataStream.status() == QDataStream::Ok) { - cSetBetaVersion(qMax(v, AppVersion * 1000ULL)); + cSetBetaVersion(std::max(v, AppVersion * 1000ULL)); cSetBetaPrivateKey(k); cSetRealBetaVersion(v); } else { diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 98480755e..507a9cd38 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1680,10 +1680,10 @@ void History::setUnreadCount(int newUnreadCount) { if (_unreadCount != newUnreadCount) { if (newUnreadCount == 1) { if (loadedAtBottom()) showFrom = lastAvailableMessage(); - inboxReadBefore = qMax(inboxReadBefore, msgIdForRead()); + inboxReadBefore = std::max(inboxReadBefore, msgIdForRead()); } else if (!newUnreadCount) { showFrom = nullptr; - inboxReadBefore = qMax(inboxReadBefore, msgIdForRead() + 1); + inboxReadBefore = std::max(inboxReadBefore, msgIdForRead() + 1); } else { if (!showFrom && !unreadBar && loadedAtBottom()) updateShowFrom(); } @@ -2069,7 +2069,7 @@ MsgId History::maxMsgId() const { MsgId History::msgIdForRead() const { MsgId result = (lastMsg && lastMsg->id > 0) ? lastMsg->id : 0; - if (loadedAtBottom()) result = qMax(result, maxMsgId()); + if (loadedAtBottom()) result = std::max(result, maxMsgId()); return result; } diff --git a/Telegram/SourceFiles/history/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/history_admin_log_filter.cpp index c27f8daec..df2b844b7 100644 --- a/Telegram/SourceFiles/history/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_filter.cpp @@ -370,7 +370,7 @@ void FilterBox::prepare() { _inner->resizeToWidth(st::boxWideWidth); refreshButtons(); - setDimensions(st::boxWideWidth, qMin(_inner->height(), st::boxMaxListHeight)); + setDimensions(st::boxWideWidth, std::min(_inner->height(), st::boxMaxListHeight)); } void FilterBox::refreshButtons() { diff --git a/Telegram/SourceFiles/history/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/history_admin_log_inner.cpp index 7c57e003a..7cbc132f1 100644 --- a/Telegram/SourceFiles/history/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_inner.cpp @@ -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. 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. - userpicBottom = qMax(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); + userpicBottom = std::max(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); // Call the template callback function that was passed // and return if it finished everything it needed. @@ -181,11 +181,11 @@ void InnerWidget::enumerateDates(Method method) { lowestInOneDayItemBottom = itembottom - item->marginBottom(); } // 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. 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 // and return if it finished everything it needed. @@ -1333,7 +1333,7 @@ void InnerWidget::updateSelected() { if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) { ++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) { selection = _mouseActionItem->adjustSelection(selection, _mouseSelectType); } diff --git a/Telegram/SourceFiles/history/history_admin_log_section.cpp b/Telegram/SourceFiles/history/history_admin_log_section.cpp index 1e1d9175f..1ca4babcb 100644 --- a/Telegram/SourceFiles/history/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_section.cpp @@ -391,10 +391,10 @@ void Widget::paintEvent(QPaintEvent *e) { auto bottom = clip.top() + clip.height(); auto w = pix.width() / cRetinaFactor(); auto h = pix.height() / cRetinaFactor(); - auto sx = qFloor(left / w); - auto sy = qFloor((top - fromy) / h); - auto cx = qCeil(right / w); - auto cy = qCeil((bottom - fromy) / h); + auto sx = std::floor(left / w); + auto sy = std::floor((top - fromy) / h); + auto cx = std::ceil(right / w); + auto cy = std::ceil((bottom - fromy) / h); for (auto i = sx; i < cx; ++i) { for (auto j = sy; j < cy; ++j) { p.drawPixmap(QPointF(i * w, fromy + j * h), pix); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 38c1f9e83..372fbb56a 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -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. 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. - userpicBottom = qMax(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); + userpicBottom = std::max(userpicBottom, lowestAttachedItemTop + st::msgPhotoSize); // Call the template callback function that was passed // and return if it finished everything it needed. @@ -328,11 +328,11 @@ void HistoryInner::enumerateDates(Method method) { lowestInOneDayItemBottom = itembottom - item->marginBottom(); } // 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. 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 // and return if it finished everything it needed. @@ -649,8 +649,8 @@ void HistoryInner::touchResetSpeed() { void HistoryInner::touchDeaccelerate(qint32 elapsed) { qint32 x = _touchSpeed.x(); qint32 y = _touchSpeed.y(); - _touchSpeed.setX((x == 0) ? x : (x > 0) ? qMax(0, x - elapsed) : qMin(0, x + elapsed)); - _touchSpeed.setY((y == 0) ? y : (y > 0) ? qMax(0, y - elapsed) : qMin(0, y + 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) ? std::max(0, y - elapsed) : std::min(0, y + elapsed)); } void HistoryInner::touchEvent(QTouchEvent *e) { @@ -1581,7 +1581,7 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) { void HistoryInner::recountHeight() { 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()) { 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(); if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; 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; _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 descMaxWidth = _scroll->width(); 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 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()); } else if (_botAbout) { @@ -1632,7 +1632,7 @@ void HistoryInner::recountHeight() { _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()) { 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(); if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; 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; _botAbout->width = tw; @@ -1674,7 +1674,7 @@ void HistoryInner::updateBotInfo(bool recount) { 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 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()); } else { @@ -1796,7 +1796,7 @@ void HistoryInner::repaintScrollDateCallback() { void HistoryInner::updateSize() { 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()) { 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 descMaxWidth = _scroll->width(); 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 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()); } @@ -2082,7 +2082,7 @@ void HistoryInner::onUpdateSelected() { auto dateLeft = st::msgServiceMargin.left(); auto maxwidth = item->history()->width; 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(); @@ -2159,7 +2159,7 @@ void HistoryInner::onUpdateSelected() { if (dragState.afterSymbol && _mouseSelectType == TextSelectType::Letters) { ++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) { selState = _mouseActionItem->adjustSelection(selState, _mouseSelectType); } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index f03a519d9..884e62116 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -146,7 +146,7 @@ void ReplyKeyboard::resize(int width, int height) { int widthOfText = 0; int maxMinButtonWidth = 0; for_const (auto &button, row) { - widthOfText += qMax(button.text.maxWidth(), 1); + widthOfText += std::max(button.text.maxWidth(), 1); int minButtonWidth = _st->minButtonWidth(button.type); widthForText -= minButtonWidth; accumulate_max(maxMinButtonWidth, minButtonWidth); @@ -156,7 +156,7 @@ void ReplyKeyboard::resize(int width, int height) { double x = 0; 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 w = textw; if (exact) { @@ -172,7 +172,7 @@ void ReplyKeyboard::resize(int width, int height) { int rectx = static_cast(std::floor(x)); int rectw = static_cast(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()); x += w + _st->buttonSkip(); @@ -187,7 +187,7 @@ bool ReplyKeyboard::isEnoughSpace(int width, const style::BotKeyboardButton &st) int s = row.size(); int widthLeft = width - ((s - 1) * st.margin + s * 2 * st.padding); for_const (auto &button, row) { - widthLeft -= qMax(button.text.maxWidth(), 1); + widthLeft -= std::max(button.text.maxWidth(), 1); if (widthLeft < 0) { if (row.size() > 3) { return false; @@ -213,7 +213,7 @@ int ReplyKeyboard::naturalWidth() const { } auto rowMaxButtonWidth = 0; 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(); @@ -525,7 +525,7 @@ void HistoryMessageUnreadBar::paint(Painter &p, int y, int w) const { int left = st::msgServiceMargin.left(); int maxwidth = w; 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; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 264e3e873..48b13bedf 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -103,22 +103,22 @@ namespace { qint32 documentMaxStatusWidth(DocumentData *document) { qint32 result = st::normalFont->width(formatDownloadText(document->size, document->size)); if (auto song = document->song()) { - result = qMax(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(formatPlayedText(song->duration, song->duration))); + result = std::max(result, st::normalFont->width(formatDurationAndSizeText(song->duration, document->size))); } else if (auto voice = document->voice()) { - result = qMax(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(formatPlayedText(voice->duration, voice->duration))); + result = std::max(result, st::normalFont->width(formatDurationAndSizeText(voice->duration, document->size))); } 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 { - result = qMax(result, st::normalFont->width(formatSizeText(document->size))); + result = std::max(result, st::normalFont->width(formatSizeText(document->size))); } return result; } qint32 gifMaxStatusWidth(DocumentData *document) { 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; } @@ -285,10 +285,10 @@ void HistoryPhoto::initDimensions() { if (_parent->toHistoryMessage()) { bool bubble = _parent->hasBubble(); - qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - qint32 maxActualWidth = qMax(tw, minWidth); - _maxw = qMax(maxActualWidth, th); - _minh = qMax(th, qint32(st::minPhotoSize)); + qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + qint32 maxActualWidth = std::max(tw, minWidth); + _maxw = std::max(maxActualWidth, th); + _minh = std::max(th, qint32(st::minPhotoSize)); if (bubble) { maxActualWidth += 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; } - _pixw = qMin(width, _maxw); + _pixw = std::min(width, _maxw); if (bubble) { _pixw -= st::mediaPadding.left() + st::mediaPadding.right(); } @@ -336,9 +336,9 @@ int HistoryPhoto::resizeGetHeight(int width) { if (_pixw < 1) _pixw = 1; if (_pixh < 1) _pixh = 1; - int minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - _width = qMax(_pixw, qint16(minWidth)); - _height = qMax(_pixh, qint16(st::minPhotoSize)); + int minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + _width = std::max(_pixw, qint16(minWidth)); + _height = std::max(_pixh, qint16(st::minPhotoSize)); if (bubble) { _width += st::mediaPadding.left() + st::mediaPadding.right(); _height += st::mediaPadding.top() + st::mediaPadding.bottom(); @@ -693,18 +693,18 @@ void HistoryVideo::initDimensions() { tw = th = 1; } 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(); } else { - tw = qRound((st::msgVideoSize.height() / double(th)) * tw); + tw = std::round((st::msgVideoSize.height() / double(th)) * tw); th = st::msgVideoSize.height(); } - _thumbw = qMax(tw, 1); - qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - minWidth = qMax(minWidth, documentMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); - _maxw = qMax(_thumbw, qint32(minWidth)); - _minh = qMax(th, qint32(st::minPhotoSize)); + _thumbw = std::max(tw, 1); + qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + minWidth = std::max(minWidth, documentMaxStatusWidth(_data) + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); + _maxw = std::max(_thumbw, qint32(minWidth)); + _minh = std::max(th, qint32(st::minPhotoSize)); if (bubble) { _maxw += st::mediaPadding.left() + st::mediaPadding.right(); _minh += st::mediaPadding.top() + st::mediaPadding.bottom(); @@ -726,10 +726,10 @@ int HistoryVideo::resizeGetHeight(int width) { tw = th = 1; } 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(); } else { - tw = qRound((st::msgVideoSize.height() / double(th)) * tw); + tw = std::round((st::msgVideoSize.height() / double(th)) * tw); th = st::msgVideoSize.height(); } @@ -737,15 +737,15 @@ int HistoryVideo::resizeGetHeight(int width) { width -= st::mediaPadding.left() + st::mediaPadding.right(); } if (width < tw) { - th = qRound((width / double(tw)) * th); + th = std::round((width / double(tw)) * th); tw = width; } - _thumbw = qMax(tw, 1); - int minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - minWidth = qMax(minWidth, documentMaxStatusWidth(_data) + 2 * int(st::msgDateImgDelta + st::msgDateImgPadding.x())); - _width = qMax(_thumbw, int(minWidth)); - _height = qMax(th, int(st::minPhotoSize)); + _thumbw = std::max(tw, 1); + int minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + minWidth = std::max(minWidth, documentMaxStatusWidth(_data) + 2 * int(st::msgDateImgDelta + st::msgDateImgPadding.x())); + _width = std::max(_thumbw, int(minWidth)); + _height = std::max(th, int(st::minPhotoSize)); if (bubble) { _width += st::mediaPadding.left() + st::mediaPadding.right(); _height += st::mediaPadding.top() + st::mediaPadding.bottom(); @@ -1142,17 +1142,17 @@ void HistoryDocument::initDimensions() { if (thumbed) { tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); tright = st::msgFileThumbPadding.left(); - _maxw = qMax(_maxw, tleft + documentMaxStatusWidth(_data) + tright); + _maxw = std::max(_maxw, tleft + documentMaxStatusWidth(_data) + tright); } else { tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); tright = st::msgFileThumbPadding.left(); 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()) { - _maxw = qMax(tleft + named->_namew + tright, _maxw); - _maxw = qMin(_maxw, int(st::msgMaxWidth)); + _maxw = std::max(tleft + named->_namew + tright, _maxw); + _maxw = std::min(_maxw, int(st::msgMaxWidth)); } if (thumbed) { @@ -1184,7 +1184,7 @@ int HistoryDocument::resizeGetHeight(int width) { return HistoryFileMedia::resizeGetHeight(width); } - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); if (Get()) { _height = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); } else { @@ -1367,7 +1367,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, return 0.; })(); 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 @@ -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 wf_size = wf ? wf->size() : Media::Player::kWaveformSamplesCount; auto availw = namewidth + st::msgWaveformSkip; - auto activew = qRound(availw * progress); + auto activew = std::round(availw * progress); if (!outbg && !voice->_playback && _parent->isMediaUnread()) { 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_delta = st::msgWaveformMax - st::msgWaveformMin; 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.finish(); } 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); } @@ -1734,7 +1734,7 @@ void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool auto state = Media::Player::mixer()->currentState(type); if (state.id == AudioMsgId(_data, _parent->fullId()) && state.length) { auto currentProgress = voice->seekingCurrent(); - auto currentPosition = qRound(currentProgress * state.length); + auto currentPosition = std::round(currentProgress * state.length); Media::Player::mixer()->seek(type, currentPosition); voice->ensurePlayback(this); @@ -1856,11 +1856,11 @@ void HistoryGif::initDimensions() { } _thumbw = tw; _thumbh = th; - _maxw = qMax(tw, qint32(st::minPhotoSize)); - _minh = qMax(th, qint32(st::minPhotoSize)); - _maxw = qMax(_maxw, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); + _maxw = std::max(tw, qint32(st::minPhotoSize)); + _minh = std::max(th, qint32(st::minPhotoSize)); + _maxw = std::max(_maxw, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); 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) { _maxw += st::mediaPadding.left() + st::mediaPadding.right(); @@ -1913,15 +1913,15 @@ int HistoryGif::resizeGetHeight(int width) { width -= st::mediaPadding.left() + st::mediaPadding.right(); } if (width < tw) { - th = qRound((width / double(tw)) * th); + th = std::round((width / double(tw)) * th); tw = width; } _thumbw = tw; _thumbh = th; - _width = qMax(tw, qint32(st::minPhotoSize)); - _height = qMax(th, qint32(st::minPhotoSize)); - _width = qMax(_width, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); + _width = std::max(tw, qint32(st::minPhotoSize)); + _height = std::max(th, qint32(st::minPhotoSize)); + _width = std::max(_width, _parent->infoWidth() + 2 * qint32(st::msgDateImgDelta + st::msgDateImgPadding.x())); if (_gif && _gif->ready()) { if (!_gif->started()) { auto isRound = _data->isRoundVideo(); @@ -1932,7 +1932,7 @@ int HistoryGif::resizeGetHeight(int width) { _gif->start(_thumbw, _thumbh, _width, _height, roundRadius, roundCorners); } } 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) { _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); auto from = QuarterArcLength; - auto len = -qRound(FullArcLength * value); + auto len = -std::round(FullArcLength * value); auto stepInside = st::radialLine / 2; { 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 recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom(); 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) { recth += forwardedHeight; } else if (via) { @@ -2290,7 +2290,7 @@ HistoryTextState HistoryGif::getState(QPoint point, HistoryStateRequest request) auto innerw = rectw - (st::msgReplyPadding.left() + st::msgReplyPadding.right()); auto recth = st::msgReplyPadding.top() + st::msgReplyPadding.bottom(); 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) { recth += forwardedHeight; } else if (via) { @@ -2660,8 +2660,8 @@ void HistorySticker::initDimensions() { } if (_pixw < 1) _pixw = 1; if (_pixh < 1) _pixh = 1; - _maxw = qMax(_pixw, qint16(st::minPhotoSize)); - _minh = qMax(_pixh, qint16(st::minPhotoSize)); + _maxw = std::max(_pixw, qint16(st::minPhotoSize)); + _minh = std::max(_pixh, qint16(st::minPhotoSize)); if (_parent->getMedia() == this) { _maxw += additionalWidth(); } @@ -2670,7 +2670,7 @@ void HistorySticker::initDimensions() { } int HistorySticker::resizeGetHeight(int width) { // return new height - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); if (_parent->getMedia() == this) { auto via = _parent->Get(); auto reply = _parent->Get(); @@ -2954,15 +2954,15 @@ void HistoryContact::initDimensions() { if (_userId) { tleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); tright = st::msgFileThumbPadding.left(); - _maxw = qMax(_maxw, tleft + _phonew + tright); + _maxw = std::max(_maxw, tleft + _phonew + tright); } else { tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); 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 = qMin(_maxw, int(st::msgMaxWidth)); + _maxw = std::max(tleft + _name.maxWidth() + tright, _maxw); + _maxw = std::min(_maxw, int(st::msgMaxWidth)); if (_userId) { _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 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) { - return qMax(thumb->medium->height() * width / thumb->medium->width(), 1); + return std::max(thumb->medium->height() * width / thumb->medium->width(), 1); } int unitedLineHeight() { - return qMax(st::webPageTitleFont->height, st::webPageDescriptionFont->height); + return std::max(st::webPageTitleFont->height, st::webPageDescriptionFont->height); } } // namespace @@ -3347,11 +3347,11 @@ void HistoryWebPage::initDimensions() { auto siteNameHeight = _data->siteName.isEmpty() ? 0 : lineHeight; auto titleMinHeight = _title.isEmpty() ? 0 : lineHeight; 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 articlePhotoMaxWidth = 0; if (_asArticle) { - articlePhotoMaxWidth = st::webPagePhotoDelta + qMax(articleThumbWidth(_data->photo, articleMinHeight), lineHeight); + articlePhotoMaxWidth = st::webPagePhotoDelta + std::max(articleThumbWidth(_data->photo, articleMinHeight), lineHeight); } if (_siteNameWidth) { @@ -3406,7 +3406,7 @@ int HistoryWebPage::resizeGetHeight(int width) { return _height; } - _width = width/* = qMin(width, _maxw)*/; + _width = width/* = std::min(width, _maxw)*/; width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); auto lineHeight = unitedLineHeight(); @@ -3417,7 +3417,7 @@ int HistoryWebPage::resizeGetHeight(int width) { _pixh = linesMax * lineHeight; do { _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; @@ -3531,13 +3531,13 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, T _data->photo->medium->load(false, false); bool full = _data->photo->medium->loaded(); 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 maxw = convertScale(_data->photo->medium->width()), maxh = convertScale(_data->photo->medium->height()); 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)); - pixh = qRound(pixh * coef); - pixw = qRound(pixw * coef); + double coef = (pixw * ph > pixh * pw) ? std::min(ph / double(pixh), maxh / double(pixh)) : std::min(pw / double(pixw), maxw / double(pixw)); + pixh = std::round(pixh * coef); + pixw = std::round(pixw * coef); } if (full) { 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 inThumb = false; 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)) { inThumb = true; } @@ -3856,7 +3856,7 @@ void HistoryGame::initDimensions() { qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight; // enable any count of lines in game description / message 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()) { accumulate_max(_maxw, _title.maxWidth()); @@ -3895,7 +3895,7 @@ void HistoryGame::updateMessageId() { } 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(); // enable any count of lines in game description / message @@ -4296,7 +4296,7 @@ void HistoryInvoice::initDimensions() { qint32 titleMinHeight = _title.isEmpty() ? 0 : lineHeight; // enable any count of lines in game description / message 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()) { accumulate_max(_maxw, _title.maxWidth()); @@ -4328,7 +4328,7 @@ void HistoryInvoice::initDimensions() { } int HistoryInvoice::resizeGetHeight(int width) { - _width = width = qMin(width, _maxw); + _width = width = std::min(width, _maxw); width -= st::msgPadding.left() + st::msgPadding.right(); auto lineHeight = unitedLineHeight(); @@ -4596,17 +4596,17 @@ void HistoryLocation::initDimensions() { th = (st::maxMediaSize * th) / tw; tw = st::maxMediaSize; } - qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - _maxw = qMax(tw, qint32(minWidth)); - _minh = qMax(th, qint32(st::minPhotoSize)); + qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + _maxw = std::max(tw, qint32(minWidth)); + _minh = std::max(th, qint32(st::minPhotoSize)); if (bubble) { _maxw += st::mediaPadding.left() + st::mediaPadding.right(); 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()) { - _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(); if (!_title.isEmpty() || !_description.isEmpty()) { @@ -4621,7 +4621,7 @@ void HistoryLocation::initDimensions() { int HistoryLocation::resizeGetHeight(int width) { bool bubble = _parent->hasBubble(); - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); if (bubble) { _width -= st::mediaPadding.left() + st::mediaPadding.right(); } @@ -4637,17 +4637,17 @@ int HistoryLocation::resizeGetHeight(int width) { } else { _width = tw; } - qint32 minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); - _width = qMax(_width, qint32(minWidth)); - _height = qMax(_height, qint32(st::minPhotoSize)); + qint32 minWidth = std::max(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x())); + _width = std::max(_width, qint32(minWidth)); + _height = std::max(_height, qint32(st::minPhotoSize)); if (bubble) { _width += st::mediaPadding.left() + st::mediaPadding.right(); _height += st::mediaPadding.top() + st::mediaPadding.bottom(); 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()) { - _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()) { _height += st::mediaInBubbleSkip; @@ -4682,12 +4682,12 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, if (!_title.isEmpty()) { 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); - skipy += qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height); + skipy += std::min(_title.countHeight(textw), 2 * st::webPageTitleFont->height); } if (!_description.isEmpty()) { 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)); - skipy += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); + skipy += std::min(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); } if (!_title.isEmpty() || !_description.isEmpty()) { skipy += st::mediaInBubbleSkip; @@ -4756,7 +4756,7 @@ HistoryTextState HistoryLocation::getState(QPoint point, HistoryStateRequest req auto textw = _width - st::msgPadding.left() - st::msgPadding.right(); 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) { result = _title.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText()); return result; @@ -4766,7 +4766,7 @@ HistoryTextState HistoryLocation::getState(QPoint point, HistoryStateRequest req skipy += titleh; } 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) { result = _description.getStateLeft(point - QPoint(skipx + st::msgPadding.left(), skipy), textw, _width, request.forText()); } else if (point.y() >= skipy + descriptionh) { diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 09b325ecc..58a1ea587 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -463,7 +463,7 @@ void HistoryMessageReply::updateName() const { 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 { _maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message)); } @@ -1142,9 +1142,9 @@ bool HistoryMessage::drawBubble() const { } QRect HistoryMessage::countGeometry() const { - auto maxwidth = qMin(st::msgMaxWidth, _maxw); + auto maxwidth = std::min(st::msgMaxWidth, _maxw); 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(); @@ -1619,7 +1619,7 @@ void HistoryMessage::draw(Painter &p, QRect clip, TextSelection selection, TimeM if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) { auto top = marginTop(); auto bottom = marginBottom(); - auto fill = qMin(top, bottom); + auto fill = std::min(top, bottom); auto skiptop = top - fill; auto fillheight = fill + g.height() + fill; @@ -1878,7 +1878,7 @@ int HistoryMessage::performResizeGetHeight() { if (emptyText()) { _height = 0; } 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) { _textWidth = textWidth; _textHeight = _text.countHeight(textWidth); diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index a29630ddb..48b71135b 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -436,7 +436,7 @@ bool HistoryService::updateDependencyItem() { QRect HistoryService::countGeometry() const { auto result = QRect(0, 0, width(), _height); 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); } @@ -513,7 +513,7 @@ int HistoryService::resizeContentGetHeight() { 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) { _textWidth = nwidth; _textHeight = _text.countHeight(nwidth); diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp index d0fdfcb89..0f5fb0cf3 100644 --- a/Telegram/SourceFiles/history/history_service_layout.cpp +++ b/Telegram/SourceFiles/history/history_service_layout.cpp @@ -169,7 +169,7 @@ void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, i int left = st::msgServiceMargin.left(); int maxwidth = w; if (Adaptive::ChatWide()) { - maxwidth = qMin(maxwidth, WideChatWidth()); + maxwidth = std::min(maxwidth, WideChatWidth()); } w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); @@ -202,7 +202,7 @@ void ServiceMessagePainter::paint( if (animms < st::activeFadeInDuration + st::activeFadeOutDuration) { auto top = st::msgServiceMargin.top(); auto bottom = st::msgServiceMargin.bottom(); - auto fill = qMin(top, bottom); + auto fill = std::min(top, bottom); auto skiptop = top - fill; auto fillheight = fill + height + fill; @@ -305,14 +305,14 @@ void ServiceMessagePainter::paintComplexBubble(Painter &p, int left, int width, } QVector 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 lineWidths; lineWidths.reserve(linesCount); text.countLineWidths(textRect.width(), &lineWidths); int minDelta = 2 * (historyServiceMsgRadius() + historyServiceMsgInvertedRadius() - historyServiceMsgInvertedShrink()); 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) { int widthBefore = lineWidths.at(i - 1); if (width < widthBefore && width + minDelta > widthBefore) { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index a09f50998..e3f127f78 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -453,7 +453,7 @@ void HistoryHider::updateControlsGeometry() { _send->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 { h += st::historyForwardChooseFont->height; _send->hide(); @@ -939,7 +939,7 @@ void HistoryWidget::scrollToAnimationCallback(FullMsgId attachToId) { if (itemTop < 0) { _scrollToAnimation.finish(); } else { - synteticScrollToY(qRound(_scrollToAnimation.current()) + itemTop); + synteticScrollToY(std::round(_scrollToAnimation.current()) + itemTop); } if (!_scrollToAnimation.animating()) { preloadHistoryByScroll(); @@ -1057,7 +1057,7 @@ int HistoryWidget::itemTopForHighlight(not_null item) const { if (heightLeft <= 0) { return itemTop; } - return qMax(itemTop - (heightLeft / 2), 0); + return std::max(itemTop - (heightLeft / 2), 0); } void HistoryWidget::start() { @@ -1551,7 +1551,7 @@ bool HistoryWidget::cmd_search() { bool HistoryWidget::cmd_next_chat() { PeerData *p = 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) { Ui::showPeerHistory(p, m); return true; @@ -1562,7 +1562,7 @@ bool HistoryWidget::cmd_next_chat() { bool HistoryWidget::cmd_previous_chat() { PeerData *p = 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) { Ui::showPeerHistory(p, m); return true; @@ -3777,7 +3777,7 @@ void HistoryWidget::onKbToggle(bool manual) { _kbScroll->show(); _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); _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(); _keyboard->resizeToWidth(_chatWidth, maxKeyboardHeight); if (_kbShown) { - keyboardHeight = qMin(_keyboard->height(), maxKeyboardHeight); + keyboardHeight = std::min(_keyboard->height(), maxKeyboardHeight); bottom -= keyboardHeight; _kbScroll->setGeometryToLeft(0, bottom, _chatWidth, keyboardHeight); } @@ -4898,7 +4898,7 @@ int HistoryWidget::countInitialScrollTop() { } else { return countAutomaticScrollTop(); } - return qMin(result, _scroll->scrollTopMax()); + return std::min(result, _scroll->scrollTopMax()); } 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) { @@ -4990,7 +4990,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S _updateHistoryGeometryRequired = false; 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) { toY += change.value; } else if (change.type == ScrollChangeNoJumpToBottom) { @@ -5117,7 +5117,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) { _botKeyboardShow->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); _kbShown = hasMarkup; _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) { editTimeLeftText = qsl("0:00"); } else if (editTimeLeft > kDisplayEditTimeWarningMs) { - updateIn = static_cast(qMin(editTimeLeft - kDisplayEditTimeWarningMs, qint64(kFullDayInMs))); + updateIn = static_cast(std::min(editTimeLeft - kDisplayEditTimeWarningMs, qint64(kFullDayInMs))); } else { updateIn = static_cast(editTimeLeft % 1000); if (!updateIn) { @@ -6528,8 +6528,8 @@ void HistoryWidget::drawRecording(Painter &p, double recordActive) { p.setPen(Qt::NoPen); p.setBrush(st::historyRecordSignalColor); - auto delta = qMin(a_recordingLevel.current() / 0x4000, 1.); - auto d = 2 * qRound(st::historyRecordSignalMin + (delta * (st::historyRecordSignalMax - st::historyRecordSignalMin))); + auto delta = std::min(a_recordingLevel.current() / 0x4000, 1.); + auto d = 2 * std::round(st::historyRecordSignalMin + (delta * (st::historyRecordSignalMax - st::historyRecordSignalMin))); { PainterHighQualityEnabler hq(p); 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 w = pix.width() / cRetinaFactor(); auto h = pix.height() / cRetinaFactor(); - auto sx = qFloor(left / w); - auto sy = qFloor((top - fromy) / h); - auto cx = qCeil(right / w); - auto cy = qCeil((bottom - fromy) / h); + auto sx = std::floor(left / w); + auto sy = std::floor((top - fromy) / h); + auto cx = std::ceil(right / w); + auto cy = std::ceil((bottom - fromy) / h); for (auto i = sx; i < cx; ++i) { for (auto j = sy; j < cy; ++j) { p.drawPixmap(QPointF(i * w, fromy + j * h), pix); @@ -6707,7 +6707,7 @@ QPoint HistoryWidget::clampMousePosition(QPoint point) { } 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); } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index fc585f9b9..93bdeeebf 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -109,7 +109,7 @@ void Gif::initDimensions() { _maxw = 0; } else { w = w * st::inlineMediaHeight / h; - _maxw = qMax(w, qint32(st::inlineResultsMinWidth)); + _maxw = std::max(w, qint32(st::inlineResultsMinWidth)); } _minh = st::inlineMediaHeight + st::inlineResultsSkip; } @@ -423,12 +423,12 @@ void Sticker::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { } 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 coefh = (st::stickerPanSize.height() - st::buttonRadius * 2) / double(height); - double coef = qMin(qMin(coefw, coefh), 1.); - int w = qRound(coef * content_width()), h = qRound(coef * content_height()); - return QSize(qMax(w, 1), qMax(h, 1)); + double coef = std::min(std::min(coefw, coefh), 1.); + int w = std::round(coef * content_width()), h = std::round(coef * content_height()); + return QSize(std::max(w, 1), std::max(h, 1)); } void Sticker::prepareThumb() const { @@ -470,7 +470,7 @@ void Photo::initDimensions() { _maxw = 0; } else { w = w * st::inlineMediaHeight / h; - _maxw = qMax(w, qint32(st::inlineResultsMinWidth)); + _maxw = std::max(w, qint32(st::inlineResultsMinWidth)); } _minh = st::inlineMediaHeight + st::inlineResultsSkip; } @@ -577,7 +577,7 @@ void Video::initDimensions() { title = lang(lng_media_video); } _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; @@ -587,7 +587,7 @@ void Video::initDimensions() { description = _duration; } _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::inlineRowMargin * 2 + st::inlineRowBorder; @@ -620,7 +620,7 @@ void Video::paint(Painter &p, const QRect &clip, const PaintContext *context) co p.setPen(st::inlineTitleFg); _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); 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(); if (thumb->loaded()) { 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 (height < h) { w = w * height / h; @@ -893,18 +893,18 @@ void Contact::initDimensions() { qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip); TextParseOptions titleOpts = { 0, _maxw, st::semiboldFont->height, Qt::LayoutDirectionAuto }; _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 }; _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::inlineRowMargin * 2 + st::inlineRowBorder; } qint32 Contact::resizeGetHeight(qint32 width) { - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); _height = _minh; return _height; } @@ -953,7 +953,7 @@ void Contact::prepareThumb(int width, int height) const { if (thumb->loaded()) { 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 (height < h) { w = w * height / h; @@ -990,22 +990,22 @@ void Article::initDimensions() { qint32 textWidth = _maxw - (_withThumb ? (st::inlineThumbSize + st::inlineThumbSkip) : 0); TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto }; _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; QString description = _result->getLayoutDescription(); TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto }; _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; 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; } qint32 Article::resizeGetHeight(qint32 width) { - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); if (_url) { _urlText = getResultUrl(); _urlWidth = st::normalFont->width(_urlText); @@ -1051,14 +1051,14 @@ void Article::paint(Painter &p, const QRect &clip, const PaintContext *context) p.setPen(st::inlineTitleFg); _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); qint32 descriptionLines = (_withThumb || _url) ? 2 : 3; _description.drawLeftElided(p, left, st::inlineRowMargin + titleHeight, _width - left, _width, descriptionLines); 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); } @@ -1076,9 +1076,9 @@ void Article::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoint if (QRect(left, 0, _width - left, _height).contains(point)) { if (_url) { 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 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)) { link = _url; return; @@ -1100,7 +1100,7 @@ void Article::prepareThumb(int width, int height) const { if (thumb->loaded()) { 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 (height < h) { w = w * height / h; @@ -1158,13 +1158,13 @@ void Game::initDimensions() { qint32 textWidth = _maxw - (st::inlineThumbSize + st::inlineThumbSkip); TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto }; _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; QString description = _result->getLayoutDescription(); TextParseOptions descriptionOpts = { TextParseMultiline, _maxw, descriptionLines * st::normalFont->height, Qt::LayoutDirectionAuto }; _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; 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); _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); qint32 descriptionLines = 2; @@ -1278,7 +1278,7 @@ void Game::prepareThumb(int width, int height) const { if (thumb->loaded()) { 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 resizeByHeight2 = (h * width >= w * height) && (w < width); if (resizeByHeight1 || resizeByHeight2) { diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index e99c3891f..b36640565 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -392,8 +392,8 @@ Inner::Row &Inner::layoutInlineRow(Row &row, qint32 sumWidth) { for (int i = 0; i < count; ++i) { int index = indices[i]; int w = sumWidth ? (row.items.at(index)->maxWidth() * availw / sumWidth) : row.items.at(index)->maxWidth(); - int actualw = qMax(w, int(st::inlineResultsMinWidth)); - row.height = qMax(row.height, row.items.at(index)->resizeGetHeight(actualw)); + int actualw = std::max(w, int(st::inlineResultsMinWidth)); + row.height = std::max(row.height, row.items.at(index)->resizeGetHeight(actualw)); if (sumWidth) { availw -= actualw; sumWidth -= row.items.at(index)->maxWidth(); @@ -758,7 +758,7 @@ void Widget::moveBottom(int bottom) { void Widget::updateContentHeight() { 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); accumulate_min(contentHeight, _bottom - addedHeight); accumulate_min(contentHeight, _contentMaxHeight); diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index 94f11392d..e9f05c346 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -619,9 +619,9 @@ void Widget::Step::paintCover(Painter &p, int top) { } if (top < 0) { 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(); - auto rightShown = qRound(shown * (right + st::introCoverRight.width())); + auto rightShown = std::round(shown * (right + st::introCoverRight.width())); right = rightShown - st::introCoverRight.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 planeTop = top + st::introCoverIconTop; 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; planeLeft += deltaLeft; // planeTop += top; @@ -646,7 +646,7 @@ int Widget::Step::contentTop() const { auto result = height() - st::introStepHeight - st::introStepHeightAdd; if (_hasCover) { 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; } diff --git a/Telegram/SourceFiles/lang/lang_tag.cpp b/Telegram/SourceFiles/lang/lang_tag.cpp index 42466abf0..4aaea1ca7 100644 --- a/Telegram/SourceFiles/lang/lang_tag.cpp +++ b/Telegram/SourceFiles/lang/lang_tag.cpp @@ -157,8 +157,8 @@ int FindTagReplacementPosition(const QString &original, ushort tag) { PluralResult Plural(ushort keyBase, double value) { // Simplified. auto n = qAbs(value); - auto i = qFloor(n); - auto integer = (qCeil(n) == i); + auto i = std::floor(n); + auto integer = (std::ceil(n) == i); auto v = integer ? 0 : 6; auto w = v; auto f = integer ? 0 : 111111; @@ -168,8 +168,8 @@ PluralResult Plural(ushort keyBase, double value) { auto useNonDefaultPlural = (ChoosePlural != ChoosePluralEn && langpack.isNonDefaultPlural(LangKey(keyBase))); auto shift = (useNonDefaultPlural ? ChoosePlural : ChoosePluralEn)((integer ? i : -1), i, v, w, f, t); auto string = langpack.getValue(LangKey(keyBase + shift)); - if (i == qCeil(n)) { - return { string, QString::number(qRound(value)) }; + if (i == std::ceil(n)) { + return { string, QString::number(std::round(value)) }; } return { string, QString::number(value) }; } diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index e4df03910..83737483e 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -752,8 +752,8 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) { } } else { p.setOpacity(shown); -// w = qMax(qRound(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); +// w = std::max(std::round(w * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(w % 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.drawPixmap((width() - w) / 2, (height() - h) / 2, image); @@ -872,13 +872,13 @@ QSize MediaPreviewWidget::currentDimensions() const { 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()) { - 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()); } 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()); } if (_photo) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 4128a2e8e..9ef246801 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1169,7 +1169,7 @@ void MainWidget::addParticipants(PeerData *chatOrChannel, const std::vectorisChannel()) { QVector 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) { inputUsers.push_back((*i)->inputUser); if (inputUsers.size() == MaxUsersPerInvite) { @@ -1331,8 +1331,8 @@ void MainWidget::onCacheBackground() { auto h = bg.height() / cRetinaFactor(); auto sx = 0; auto sy = 0; - auto cx = qCeil(_willCacheFor.width() / w); - auto cy = qCeil(_willCacheFor.height() / h); + auto cx = std::ceil(_willCacheFor.width() / w); + auto cy = std::ceil(_willCacheFor.height() / h); for (int i = sx; i < cx; ++i) { for (int j = sy; j < cy; ++j) { p.drawPixmap(QPointF(i * w, j * h), bg); @@ -3200,7 +3200,7 @@ void MainWidget::updateControlsGeometry() { _dialogs->stopWidthAnimation(); } auto sectionTop = getSectionTop(); - auto dialogsWidth = qRound(_a_dialogsWidth.current(_dialogsWidth)); + int dialogsWidth = std::round(_a_dialogsWidth.current(_dialogsWidth)); if (Adaptive::OneColumn()) { if (_callTopBar) { _callTopBar->resizeToWidth(dialogsWidth); @@ -3384,8 +3384,8 @@ void MainWidget::updateWindowAdaptiveLayout() { if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) { auto thirdColumnWidth = _history->tabbedSelectorSectionWidth(); auto twoColumnsWidth = (layout.bodyWidth - thirdColumnWidth); - auto sameRatioChatWidth = twoColumnsWidth - qRound(dialogsWidthRatio * twoColumnsWidth); - auto desiredChatWidth = qMax(sameRatioChatWidth, HistoryLayout::WideChatWidth()); + int sameRatioChatWidth = twoColumnsWidth - std::round(dialogsWidthRatio * twoColumnsWidth); + auto desiredChatWidth = std::max(sameRatioChatWidth, HistoryLayout::WideChatWidth()); chatWidth -= thirdColumnWidth; auto extendChatBy = desiredChatWidth - chatWidth; accumulate_min(extendChatBy, layout.dialogsWidth - st::dialogsWidthMin); @@ -3824,7 +3824,7 @@ void MainWidget::onGetDifferenceTimeByPts() { } for (ChannelGetDifferenceTime::iterator i = _channelGetDifferenceTimeByPts.begin(); i != _channelGetDifferenceTimeByPts.cend();) { 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; } else { getChannelDifference(i.key(), ChannelDifferenceRequest::PtsGapOrShortPoll); @@ -3851,7 +3851,7 @@ void MainWidget::onGetDifferenceTimeAfterFail() { } for (auto i = _channelGetDifferenceTimeAfterFail.begin(); i != _channelGetDifferenceTimeAfterFail.cend();) { 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; } else { getChannelDifference(i.key(), ChannelDifferenceRequest::AfterFail); @@ -4415,7 +4415,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) { _idleFinishTimer.start(900); } } else { - updateIn = qMin(updateIn, int(Global::OfflineIdleTimeout() - idle)); + updateIn = std::min(updateIn, int(Global::OfflineIdleTimeout() - idle)); } } auto ms = getms(true); @@ -4441,7 +4441,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) { updateOnlineDisplay(); } else if (isOnline) { - updateIn = qMin(updateIn, int(_lastSetOnline + Global::OnlineUpdatePeriod() - ms)); + updateIn = std::min(updateIn, int(_lastSetOnline + Global::OnlineUpdatePeriod() - ms)); } _onlineTimer.start(updateIn); } diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp index a3eba9794..59797df7a 100644 --- a/Telegram/SourceFiles/media/media_audio.cpp +++ b/Telegram/SourceFiles/media/media_audio.cpp @@ -317,7 +317,7 @@ void Mixer::Track::reattach(AudioMsgId::Type type) { 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) { alSourcef(stream.source, AL_GAIN, ComputeVolume(type)); alSourcePlay(stream.source); @@ -830,7 +830,7 @@ void Mixer::resume(const AudioMsgId &audio, bool fast) { Audio::AttachToDevice(); if (track->state.state == State::PausedAtEnd) { 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; } } @@ -1067,7 +1067,7 @@ void Mixer::reattachTracks() { } void Mixer::setSongVolume(double volume) { - _volumeSong.storeRelease(qRound(volume * kVolumeRound)); + _volumeSong.storeRelease(std::round(volume * kVolumeRound)); } double Mixer::getSongVolume() const { @@ -1075,7 +1075,7 @@ double Mixer::getSongVolume() const { } void Mixer::setVideoVolume(double volume) { - _volumeVideo.storeRelease(qRound(volume * kVolumeRound)); + _volumeVideo.storeRelease(std::round(volume * kVolumeRound)); } double Mixer::getVideoVolume() const { @@ -1555,11 +1555,11 @@ public: } 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()); 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; diff --git a/Telegram/SourceFiles/media/media_audio_capture.cpp b/Telegram/SourceFiles/media/media_audio_capture.cpp index 8de184061..f0bcc0254 100644 --- a/Telegram/SourceFiles/media/media_audio_capture.cpp +++ b/Telegram/SourceFiles/media/media_audio_capture.cpp @@ -126,7 +126,7 @@ struct Instance::Inner::Private { static int _read_data(void *opaque, uint8_t *buf, int buf_size) { auto l = reinterpret_cast(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) { return 0; } @@ -360,7 +360,7 @@ void Instance::Inner::onStop(bool needResult) { double coef = 1. / fadeSamples, fadedFrom = 0; for (short *ptr = ((short*)_captured.data()) + capturedSamples, *end = ptr - fadeSamples; ptr != end; ++fadedFrom) { --ptr; - *ptr = qRound(fadedFrom * coef * *ptr); + *ptr = std::round(fadedFrom * coef * *ptr); } if (capturedSamples % d->srcSamples) { qint32 s = _captured.size(); @@ -416,11 +416,11 @@ void Instance::Inner::onStop(bool needResult) { } 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()); 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) { quint16 value = qAbs(*ptr); if (levelindex < skipSamples + fadeSamples) { - value = qRound(value * double(levelindex - skipSamples) / fadeSamples); + value = std::round(value * double(levelindex - skipSamples) / fadeSamples); } if (d->levelMax < value) { d->levelMax = value; @@ -569,14 +569,14 @@ void Instance::Inner::processFrame(qint32 offset, qint32 framesize) { auto skipSamples = static_cast(kCaptureSkipDuration * kCaptureFrequency / 1000); auto fadeSamples = static_cast(kCaptureFadeInDuration * kCaptureFrequency / 1000); 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; - 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) { *ptr = 0; } for (; ptr != end; ++ptr, ++fadedFrom) { - *ptr = qRound(fadedFrom * coef * *ptr); + *ptr = std::round(fadedFrom * coef * *ptr); } } diff --git a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp index c366e0106..c149f126a 100644 --- a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp +++ b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp @@ -92,7 +92,7 @@ AbstractFFMpegLoader::~AbstractFFMpegLoader() { int AbstractFFMpegLoader::_read_data(void *opaque, uint8_t *buf, int buf_size) { auto l = reinterpret_cast(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) { 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) { auto l = reinterpret_cast(opaque); - auto nbytes = qMin(static_cast(l->_bytes.size()) - l->_dataPos, buf_size); + auto nbytes = std::min(static_cast(l->_bytes.size()) - l->_dataPos, buf_size); if (nbytes <= 0) { return 0; } diff --git a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp index 9ee203e38..d018b3678 100644 --- a/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/media_clip_ffmpeg.cpp @@ -211,7 +211,7 @@ TimeMs FFMpegReaderImplementation::frameRealTime() 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 { @@ -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)); 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(); for (qint32 i = 0, l = _frame->height; i < l; ++i) { memcpy(d + i * dbpl, s + i * sbpl, bpl); diff --git a/Telegram/SourceFiles/media/media_clip_qtgif.cpp b/Telegram/SourceFiles/media/media_clip_qtgif.cpp index 8b2296fff..850bf364c 100644 --- a/Telegram/SourceFiles/media/media_clip_qtgif.cpp +++ b/Telegram/SourceFiles/media/media_clip_qtgif.cpp @@ -47,7 +47,7 @@ TimeMs QtGifReaderImplementation::frameRealTime() const { } TimeMs QtGifReaderImplementation::framePresentationTime() const { - return qMax(_frameTime, Q_INT64_C(0)); + return std::max(_frameTime, Q_INT64_C(0)); } ReaderImplementation::ReadResult QtGifReaderImplementation::readNextFrame() { @@ -76,7 +76,7 @@ bool QtGifReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const QS qint32 w = _frame.width(), h = _frame.height(); if (to.width() == w && to.height() == h && to.format() == _frame.format()) { 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) { memcpy(to.scanLine(i), _frame.constScanLine(i), bpl); } diff --git a/Telegram/SourceFiles/media/media_clip_reader.cpp b/Telegram/SourceFiles/media/media_clip_reader.cpp index e7831f515..410fa80e8 100644 --- a/Telegram/SourceFiles/media/media_clip_reader.cpp +++ b/Telegram/SourceFiles/media/media_clip_reader.cpp @@ -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); } 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(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)), 0, std::min(cache.width(), request.framew) / factor, (request.outerh - request.frameh) / (2 * 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) { - 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)); if (needResize) { diff --git a/Telegram/SourceFiles/media/player/media_player_cover.cpp b/Telegram/SourceFiles/media/player/media_player_cover.cpp index c22a35c38..f2b53ca58 100644 --- a/Telegram/SourceFiles/media/player/media_player_cover.cpp +++ b/Telegram/SourceFiles/media/player/media_player_cover.cpp @@ -171,7 +171,7 @@ void CoverWidget::handleSeekFinished(double progress) { auto type = AudioMsgId::Type::Song; auto state = Media::Player::mixer()->currentState(type); 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); @@ -286,7 +286,7 @@ void CoverWidget::updateTimeText(const TrackState &state) { _lastDurationMs = (state.length * 1000LL) / frequency; 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); } else { display = display / frequency; diff --git a/Telegram/SourceFiles/media/player/media_player_float.cpp b/Telegram/SourceFiles/media/player/media_player_float.cpp index f34bc383f..29e07e283 100644 --- a/Telegram/SourceFiles/media/player/media_player_float.cpp +++ b/Telegram/SourceFiles/media/player/media_player_float.cpp @@ -172,7 +172,7 @@ void Float::paintEvent(QPaintEvent *e) { p.setOpacity(_opacity * st::historyVideoMessageProgressOpacity); auto from = QuarterArcLength; - auto len = -qRound(FullArcLength * progress); + auto len = -std::round(FullArcLength * progress); auto stepInside = st::radialLine / 2; { PainterHighQualityEnabler hq(p); diff --git a/Telegram/SourceFiles/media/player/media_player_panel.cpp b/Telegram/SourceFiles/media/player/media_player_panel.cpp index 179ed04d7..e1ae56037 100644 --- a/Telegram/SourceFiles/media/player/media_player_panel.cpp +++ b/Telegram/SourceFiles/media/player/media_player_panel.cpp @@ -86,7 +86,7 @@ void Panel::updateControlsGeometry() { _scrollShadow->moveToRight(contentRight(), scrollTop); } } - auto scrollHeight = qMax(height() - scrollTop - contentBottom() - scrollMarginBottom(), 0); + auto scrollHeight = std::max(height() - scrollTop - contentBottom() - scrollMarginBottom(), 0); if (scrollHeight > 0) { _scroll->setGeometryToRight(contentRight(), scrollTop, width, scrollHeight); } @@ -136,7 +136,7 @@ void Panel::updateSize() { listHeight = widget->height(); } 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(); resize(width, height); _scroll->setVisible(scrollVisible); diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 9933be875..f5472dc8f 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -253,7 +253,7 @@ void Widget::handleSeekFinished(double progress) { auto state = mixer()->currentState(_type); if (state.id && state.length) { - mixer()->seek(_type, qRound(progress * state.length)); + mixer()->seek(_type, std::round(progress * state.length)); } instance()->stopSeeking(_type); @@ -443,7 +443,7 @@ void Widget::updateTimeText(const TrackState &state) { _lastDurationMs = (state.length * 1000LL) / frequency; 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); } else { display = display / frequency; diff --git a/Telegram/SourceFiles/media/view/media_clip_playback.cpp b/Telegram/SourceFiles/media/view/media_clip_playback.cpp index 615c723cc..286c896dd 100644 --- a/Telegram/SourceFiles/media/view/media_clip_playback.cpp +++ b/Telegram/SourceFiles/media/view/media_clip_playback.cpp @@ -61,7 +61,7 @@ void Playback::updateState(const Player::TrackState &state) { progress = snap(double(position) / length, 0., 1.); } 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 (auto animated = (length && _length && animatedProgress > value())) { setValue(animatedProgress, animated); @@ -85,7 +85,7 @@ void Playback::updateLoadingState(double progress) { } double Playback::value() const { - return qMin(a_value.current(), 1.); + return std::min(a_value.current(), 1.); } double Playback::value(TimeMs ms) { diff --git a/Telegram/SourceFiles/media/view/media_clip_volume_controller.cpp b/Telegram/SourceFiles/media/view/media_clip_volume_controller.cpp index af8599fbb..97ed57223 100644 --- a/Telegram/SourceFiles/media/view/media_clip_volume_controller.cpp +++ b/Telegram/SourceFiles/media/view/media_clip_volume_controller.cpp @@ -41,7 +41,7 @@ void VolumeController::paintEvent(QPaintEvent *e) { qint32 top = st::mediaviewVolumeIconTop; 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(); if (mid > left) { diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 813dde101..16bc9e2f4 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -386,7 +386,7 @@ void MediaView::updateControls() { } if (_from) { _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); } else { _nameNav = QRect(); @@ -417,9 +417,9 @@ void MediaView::updateControls() { } if (!_caption.isEmpty()) { - qint32 skipw = qMax(_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 maxh = qMin(_caption.countHeight(maxw), int(height() / 4 - st::mediaviewCaptionPadding.top() - st::mediaviewCaptionPadding.bottom() - 2 * st::mediaviewCaptionMargin.height())); + qint32 skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); + 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 = 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); } else { _captionRect = QRect(); @@ -576,8 +576,8 @@ void MediaView::step_radial(TimeMs ms, bool timer) { void MediaView::zoomIn() { qint32 newZoom = _zoom; if (newZoom == ZoomToScreenLevel) { - if (qCeil(_zoomToScreen) <= MaxZoomLevel) { - newZoom = qCeil(_zoomToScreen); + if (std::ceil(_zoomToScreen) <= MaxZoomLevel) { + newZoom = std::ceil(_zoomToScreen); } } else { if (newZoom < _zoomToScreen && (newZoom + 1 > _zoomToScreen || (_zoomToScreen > MaxZoomLevel && newZoom == MaxZoomLevel))) { @@ -592,8 +592,8 @@ void MediaView::zoomIn() { void MediaView::zoomOut() { qint32 newZoom = _zoom; if (newZoom == ZoomToScreenLevel) { - if (qFloor(_zoomToScreen) >= -MaxZoomLevel) { - newZoom = qFloor(_zoomToScreen); + if (std::floor(_zoomToScreen) >= -MaxZoomLevel) { + newZoom = std::floor(_zoomToScreen); } } else { if (newZoom > _zoomToScreen && (newZoom - 1 < _zoomToScreen || (_zoomToScreen < -MaxZoomLevel && newZoom == -MaxZoomLevel))) { @@ -608,8 +608,8 @@ void MediaView::zoomOut() { void MediaView::zoomReset() { qint32 newZoom = _zoom; if (_zoom == 0) { - if (qFloor(_zoomToScreen) == qCeil(_zoomToScreen) && qRound(_zoomToScreen) >= -MaxZoomLevel && qRound(_zoomToScreen) <= MaxZoomLevel) { - newZoom = qRound(_zoomToScreen); + if (std::floor(_zoomToScreen) == std::ceil(_zoomToScreen) && std::round(_zoomToScreen) >= -MaxZoomLevel && std::round(_zoomToScreen) <= MaxZoomLevel) { + newZoom = std::round(_zoomToScreen); } else { newZoom = ZoomToScreenLevel; } @@ -620,11 +620,11 @@ void MediaView::zoomReset() { _y = -((gifShown() ? _gif->height() : (_current.height() / cIntRetinaFactor())) / 2); double z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; if (z >= 0) { - _x = qRound(_x * (z + 1)); - _y = qRound(_y * (z + 1)); + _x = std::round(_x * (z + 1)); + _y = std::round(_y * (z + 1)); } else { - _x = qRound(_x / (-z + 1)); - _y = qRound(_y / (-z + 1)); + _x = std::round(_x / (-z + 1)); + _y = std::round(_y / (-z + 1)); } _x += width() / 2; _y += height() / 2; @@ -1204,8 +1204,8 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) { if (auto photoMsg = dynamic_cast(itemMsg->getMedia())) { auto asBot = (item->author()->isUser() && item->author()->asUser()->botInfo); - auto skipw = qMax(_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 skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); + 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.setMarkedText( st::mediaviewCaptionStyle, @@ -1225,11 +1225,11 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) { moveToScreen(); } if (_w > width()) { - _h = qRound(_h * width() / double(_w)); + _h = std::round(_h * width() / double(_w)); _w = width(); } if (_h > height()) { - _w = qRound(_w * height() / double(_h)); + _w = std::round(_w * height() / double(_h)); _h = height(); } _x = (width() - _w) / 2; @@ -1377,11 +1377,11 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty if ((_w > width()) || (_h > height()) || _fullScreenVideo) { _zoom = ZoomToScreenLevel; if (_zoomToScreen >= 0) { - _w = qRound(_w * (_zoomToScreen + 1)); - _h = qRound(_h * (_zoomToScreen + 1)); + _w = std::round(_w * (_zoomToScreen + 1)); + _h = std::round(_h * (_zoomToScreen + 1)); } else { - _w = qRound(_w / (-_zoomToScreen + 1)); - _h = qRound(_h / (-_zoomToScreen + 1)); + _w = std::round(_w / (-_zoomToScreen + 1)); + _h = std::round(_h / (-_zoomToScreen + 1)); } snapXY(); } 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()); _themePreviewRect = previewRect.marginsAdded(st::themePreviewMargin); if (_themeApply) { - auto right = qMax(width() - _themePreviewRect.x() - _themePreviewRect.width(), 0) + st::themePreviewMargin.right(); - auto bottom = qMin(height(), _themePreviewRect.y() + _themePreviewRect.height()); + auto right = std::max(width() - _themePreviewRect.x() - _themePreviewRect.width(), 0) + st::themePreviewMargin.right(); + auto bottom = std::min(height(), _themePreviewRect.y() + _themePreviewRect.height()); _themeApply->moveToRight(right, bottom - st::themePreviewMargin.bottom() + (st::themePreviewMargin.bottom() - _themeApply->height()) / 2); right += _themeApply->width() + st::themePreviewButtonsSkip; _themeCancel->moveToRight(right, _themeApply->y()); @@ -1782,7 +1782,7 @@ void MediaView::paintEvent(QPaintEvent *e) { _saveMsgOpacity.start(0); } 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) { p.setOpacity(_saveMsgOpacity.current()); App::roundRect(p, _saveMsg, st::mediaviewSaveMsgBg, MediaviewSaveCorners); @@ -2145,15 +2145,15 @@ void MediaView::setZoomLevel(int newZoom) { _zoom = newZoom; z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; if (z > 0) { - _w = qRound(_w * (z + 1)); - _h = qRound(_h * (z + 1)); - _x = qRound(nx * (z + 1) + width() / 2.); - _y = qRound(ny * (z + 1) + height() / 2.); + _w = std::round(_w * (z + 1)); + _h = std::round(_h * (z + 1)); + _x = std::round(nx * (z + 1) + width() / 2.); + _y = std::round(ny * (z + 1) + height() / 2.); } else { - _w = qRound(_w / (-z + 1)); - _h = qRound(_h / (-z + 1)); - _x = qRound(nx / (-z + 1) + width() / 2.); - _y = qRound(ny / (-z + 1) + height() / 2.); + _w = std::round(_w / (-z + 1)); + _h = std::round(_h / (-z + 1)); + _x = std::round(nx / (-z + 1) + width() / 2.); + _y = std::round(ny / (-z + 1) + height() / 2.); } snapXY(); update(); diff --git a/Telegram/SourceFiles/mtproto/connection.cpp b/Telegram/SourceFiles/mtproto/connection.cpp index b34e2f463..93ecadab7 100644 --- a/Telegram/SourceFiles/mtproto/connection.cpp +++ b/Telegram/SourceFiles/mtproto/connection.cpp @@ -1139,7 +1139,7 @@ void ConnectionPrivate::onReceivedSome() { qint32 ms = getms(true) - firstSentAt; 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; } } diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index fb774b6bc..15e90d5c3 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -221,9 +221,9 @@ void Photo::initDimensions() { } qint32 Photo::resizeGetHeight(qint32 width) { - width = qMin(width, _maxw); + width = std::min(width, _maxw); if (width != _width || width != _height) { - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); _height = _width; } return _height; @@ -321,7 +321,7 @@ void Video::initDimensions() { } qint32 Video::resizeGetHeight(qint32 width) { - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); _height = _width; return _height; } @@ -866,7 +866,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con } 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))) { p.setPen(st::historyFileNameInFg); _name.drawLeftElided(p, nameleft, nametop, namewidth, _width); @@ -929,7 +929,7 @@ void Document::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, QPoin link = _namel; 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; return; } @@ -1064,8 +1064,8 @@ Link::Link(HistoryMedia *media, HistoryItem *parent) : ItemBase(parent) { th = st::linksPhotoSize; } } - _pixw = qMax(tw, 1); - _pixh = qMax(th, 1); + _pixw = std::max(tw, 1); + _pixh = std::max(th, 1); if (_page) { _title = _page->title; @@ -1101,14 +1101,14 @@ void Link::initDimensions() { _minh += st::semiboldFont->height; } 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 = 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) { - _width = qMin(width, _maxw); + _width = std::min(width, _maxw); qint32 w = _width - st::linksPhotoSize - st::linksPhotoPadding; for (qint32 i = 0, l = _links.size(); i < l; ++i) { _links.at(i).lnk->setFullDisplayed(w >= _links.at(i).width); @@ -1119,10 +1119,10 @@ qint32 Link::resizeGetHeight(qint32 width) { _height += st::semiboldFont->height; } 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 = 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; } @@ -1175,14 +1175,14 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P p.setPen(st::linksTextFg); p.setFont(st::semiboldFont); 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); } top += st::semiboldFont->height; } p.setFont(st::msgFont); 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))) { _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); 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.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; } 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; return; } top += st::webPageTitleFont->height; } 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) { - 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; return; } diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index b47679b65..8dd82c480 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -348,7 +348,7 @@ void OverviewInner::repaintItem(MsgId itemId, qint32 itemIndex) { double w = (double(_width - st::overviewPhotoSkip) / _photosInRow); qint32 vsize = (_rowWidth + st::overviewPhotoSkip); 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 { qint32 top = _items.at(itemIndex)->Get()->top; if (_reversed) top = _height - top; @@ -365,8 +365,8 @@ void OverviewInner::touchResetSpeed() { void OverviewInner::touchDeaccelerate(qint32 elapsed) { qint32 x = _touchSpeed.x(); qint32 y = _touchSpeed.y(); - _touchSpeed.setX((x == 0) ? x : (x > 0) ? qMax(0, x - elapsed) : qMin(0, x + elapsed)); - _touchSpeed.setY((y == 0) ? y : (y > 0) ? qMax(0, y - elapsed) : qMin(0, y + 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) ? std::max(0, y - elapsed) : std::min(0, y + elapsed)); } void OverviewInner::touchEvent(QTouchEvent *e) { @@ -1316,8 +1316,8 @@ qint32 OverviewInner::resizeToWidth(qint32 nwidth, qint32 scrollTop, qint32 minH } auto widthWithMin = st::windowMinWidth; auto widthWithMax = st::overviewFileLayout.maxWidth + 2 * contentLeftMax; - _rowsLeft = anim::interpolate(contentLeftMax, contentLeftMin, qMax(widthWithMax - _width, 0) / double(widthWithMax - widthWithMin)); - _rowWidth = qMin(_width - 2 * _rowsLeft, st::overviewFileLayout.maxWidth); + _rowsLeft = anim::interpolate(contentLeftMax, contentLeftMin, std::max(widthWithMax - _width, 0) / double(widthWithMax - widthWithMin)); + _rowWidth = std::min(_width - 2 * _rowsLeft, st::overviewFileLayout.maxWidth); } _search->setGeometry(_rowsLeft, st::linksSearchTop, _rowWidth, _search->height()); @@ -1630,7 +1630,7 @@ void OverviewInner::mediaOverviewUpdated() { auto migrateCount = migratedIndexSkip(); auto wasCount = _items.size(); auto fullCount = (migrateCount + o.size()); - auto tocheck = qMin(fullCount, _itemsToBeLoaded); + auto tocheck = std::min(fullCount, _itemsToBeLoaded); _items.reserve(tocheck); auto index = 0; @@ -1672,7 +1672,7 @@ void OverviewInner::mediaOverviewUpdated() { auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migrateCount = migratedIndexSkip(); 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 auto migrateIt = migratedOverview ? migratedOverview->end() : o.end(); @@ -1835,7 +1835,7 @@ void OverviewInner::repaintItem(const HistoryItem *msg) { double w = (double(width() - st::overviewPhotoSkip) / _photosInRow); qint32 vsize = (_rowWidth + st::overviewPhotoSkip); 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; } } @@ -1866,17 +1866,17 @@ int OverviewInner::countHeight() { void OverviewInner::recountMargins() { if (_type == OverviewPhotos || _type == OverviewVideos) { - _marginBottom = qMax(_minHeight - _height - _marginTop, 0); + _marginBottom = std::max(_minHeight - _height - _marginTop, 0); _marginTop = 0; } else if (_type == OverviewMusicFiles) { _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) { _marginTop = st::linksSearchTop + _search->height(); - _marginBottom = qMax(_minHeight - _height - _marginTop, qint32(st::playlistPadding)); + _marginBottom = std::max(_minHeight - _height - _marginTop, qint32(st::playlistPadding)); } else { _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() { - 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); } diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 574790894..8d3b9ec29 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -166,7 +166,7 @@ void MainWindow::Private::initCustomTitle(NSWindow *window, NSView *view) { [window setTitlebarAppearsTransparent:YES]; auto inner = [window contentLayoutRect]; auto full = [view frame]; - _public->_customTitleHeight = qMax(qRound(full.size.height - inner.size.height), 0); + _public->_customTitleHeight = std::max(std::round(full.size.height - inner.size.height), 0); #ifndef OS_MAC_OLD [[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window]; diff --git a/Telegram/SourceFiles/profile/profile_block_channel_members.cpp b/Telegram/SourceFiles/profile/profile_block_channel_members.cpp index 28d0914c3..a855f3cd7 100644 --- a/Telegram/SourceFiles/profile/profile_block_channel_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_channel_members.cpp @@ -82,7 +82,7 @@ void ChannelMembersWidget::refreshAdmins() { auto getAdminsText = [this] { if (auto channel = peer()->asChannel()) { 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); } } @@ -105,7 +105,7 @@ void ChannelMembersWidget::refreshMembers() { auto getMembersText = [this]() -> QString { if (auto channel = peer()->asChannel()) { 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); } } diff --git a/Telegram/SourceFiles/profile/profile_block_info.cpp b/Telegram/SourceFiles/profile/profile_block_info.cpp index d638790b4..596e89f62 100644 --- a/Telegram/SourceFiles/profile/profile_block_info.cpp +++ b/Telegram/SourceFiles/profile/profile_block_info.cpp @@ -111,7 +111,7 @@ int InfoWidget::resizeGetHeight(int newWidth) { 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(_mobileNumberLabel, _mobileNumber, nullptr); diff --git a/Telegram/SourceFiles/profile/profile_block_peer_list.cpp b/Telegram/SourceFiles/profile/profile_block_peer_list.cpp index d4a0cd5b7..19b808b48 100644 --- a/Telegram/SourceFiles/profile/profile_block_peer_list.cpp +++ b/Telegram/SourceFiles/profile/profile_block_peer_list.cpp @@ -113,7 +113,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select } if (item->adminState != Item::AdminState::None) { 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) ? (selected ? st::profileMemberCreatorIconOver : st::profileMemberCreatorIcon) : (selected ? st::profileMemberAdminIconOver : st::profileMemberAdminIcon); @@ -303,7 +303,7 @@ int PeerListWidget::getListLeft() const { } int PeerListWidget::rowWidth() const { - return qMin(width() - getListLeft(), st::profileBlockWideWidthMax); + return std::min(width() - getListLeft(), st::profileBlockWideWidthMax); } void PeerListWidget::preloadPhotos() { diff --git a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp index 928d2618c..dbc9c4cf8 100644 --- a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp +++ b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp @@ -196,13 +196,13 @@ int InnerWidget::resizeGetHeight(int newWidth) { auto contentLeftMax = st::profileCommonGroupsLeftMax; auto widthWithMin = st::windowMinWidth; auto widthWithMax = st::profileCommonGroupsWidthMax + 2 * contentLeftMax; - _contentLeft = anim::interpolate(contentLeftMax, contentLeftMin, qMax(widthWithMax - newWidth, 0) / double(widthWithMax - widthWithMin)); - _contentWidth = qMin(newWidth - 2 * _contentLeft, st::profileCommonGroupsWidthMax); + _contentLeft = anim::interpolate(contentLeftMax, contentLeftMin, std::max(widthWithMax - newWidth, 0) / double(widthWithMax - widthWithMin)); + _contentWidth = std::min(newWidth - 2 * _contentLeft, st::profileCommonGroupsWidthMax); auto newHeight = _contentTop; newHeight += _items.size() * _rowHeight; newHeight += st::profileCommonGroupsSkip; - return qMax(newHeight, _minHeight); + return std::max(newHeight, _minHeight); } void InnerWidget::paintEvent(QPaintEvent *e) { diff --git a/Telegram/SourceFiles/profile/profile_cover.cpp b/Telegram/SourceFiles/profile/profile_cover.cpp index 00ca529fe..204975fd0 100644 --- a/Telegram/SourceFiles/profile/profile_cover.cpp +++ b/Telegram/SourceFiles/profile/profile_cover.cpp @@ -118,7 +118,7 @@ void CoverWidget::onCancelPhotoUpload() { int CoverWidget::countPhotoLeft(int newWidth) const { int result = st::profilePhotoLeftMin; result += (newWidth - st::windowMinWidth) / 2; - return qMin(result, st::profilePhotoLeftMax); + return std::min(result, st::profilePhotoLeftMax); } int CoverWidget::resizeGetHeight(int newWidth) { @@ -160,7 +160,7 @@ void CoverWidget::refreshNameGeometry(int newWidth) { nameWidth -= st::profileVerifiedCheckShift + st::profileVerifiedCheck.width(); } 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); } @@ -380,7 +380,7 @@ void CoverWidget::refreshStatusText() { _statusText = App::onlineText(_peerUser, currentTime, true); _statusTextIsOnline = App::onlineColorUse(_peerUser, currentTime); } 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) { auto membersCount = lng_chat_status_members(lt_count, fullCount); auto onlineCount = lng_chat_status_online(lt_count, _onlineCount); diff --git a/Telegram/SourceFiles/profile/profile_inner_widget.cpp b/Telegram/SourceFiles/profile/profile_inner_widget.cpp index 07abb9565..8e0aecd4c 100644 --- a/Telegram/SourceFiles/profile/profile_inner_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_inner_widget.cpp @@ -120,7 +120,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { if (_mode == Mode::TwoColumn) { int leftHeight = countBlocksHeight(RectPart::Left); int rightHeight = countBlocksHeight(RectPart::Right); - int shadowHeight = rightHeight;// qMin(leftHeight, rightHeight); + int shadowHeight = rightHeight;// std::min(leftHeight, rightHeight); int shadowLeft = _blocksLeft + _leftColumnWidth + _columnDivider; int shadowTop = _blocksTop + st::profileBlockMarginTop; @@ -149,7 +149,7 @@ int InnerWidget::countBlocksHeight(RectPart countSide) const { int InnerWidget::countBlocksLeft(int newWidth) const { int result = st::profileBlockLeftMin; result += (newWidth - st::windowMinWidth) / 2; - return qMin(result, st::profileBlockLeftMax); + return std::min(result, st::profileBlockLeftMax); } InnerWidget::Mode InnerWidget::countBlocksMode(int newWidth) const { @@ -239,7 +239,7 @@ int InnerWidget::resizeGetHeight(int newWidth) { update(); auto naturalHeight = countHeight(); - _addedHeight = qMax(_minHeight - naturalHeight, 0); + _addedHeight = std::max(_minHeight - naturalHeight, 0); return naturalHeight + _addedHeight; } @@ -248,7 +248,7 @@ int InnerWidget::countHeight() const { auto leftHeight = countBlocksHeight(RectPart::Left); 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; return newHeight; diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index 27d321981..fbb051fd6 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -109,11 +109,11 @@ int BackgroundRow::resizeGetHeight(int newWidth) { auto linkTop = 0; auto linkLeft = st::settingsBackgroundSize + st::settingsSmallSkip; auto linkWidth = newWidth - linkLeft; - _chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth())); - _chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth())); - _editTheme->resizeToWidth(qMin(linkWidth, _editTheme->naturalWidth())); + _chooseFromGallery->resizeToWidth(std::min(linkWidth, _chooseFromGallery->naturalWidth())); + _chooseFromFile->resizeToWidth(std::min(linkWidth, _chooseFromFile->naturalWidth())); + _editTheme->resizeToWidth(std::min(linkWidth, _editTheme->naturalWidth())); if (_useDefaultTheme) { - _useDefaultTheme->resizeToWidth(qMin(linkWidth, _useDefaultTheme->naturalWidth())); + _useDefaultTheme->resizeToWidth(std::min(linkWidth, _useDefaultTheme->naturalWidth())); _useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth); linkTop += _useDefaultTheme->height() + st::settingsSmallSkip; } diff --git a/Telegram/SourceFiles/settings/settings_block_widget.cpp b/Telegram/SourceFiles/settings/settings_block_widget.cpp index 36da0365f..e608bf362 100644 --- a/Telegram/SourceFiles/settings/settings_block_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_block_widget.cpp @@ -47,7 +47,7 @@ int BlockWidget::resizeGetHeight(int newWidth) { row.child->moveToLeft(x + row.margin.left(), result + row.margin.top(), newWidth); auto availRowWidth = availw - row.margin.left() - row.margin.right() - x; 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) { row.child->resizeToWidth(rowWidth); } diff --git a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp index f69e4d2b2..ce0979b46 100644 --- a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp @@ -77,7 +77,7 @@ DownloadPathState::DownloadPathState(QWidget *parent) : TWidget(parent) } int DownloadPathState::resizeGetHeight(int newWidth) { - _path->resizeToWidth(qMin(newWidth, _path->naturalWidth())); + _path->resizeToWidth(std::min(newWidth, _path->naturalWidth())); _path->moveToLeft(0, 0, newWidth); _clear->moveToRight(0, 0, newWidth); return _path->height(); diff --git a/Telegram/SourceFiles/settings/settings_cover.cpp b/Telegram/SourceFiles/settings/settings_cover.cpp index e6f7c855d..c843b25dc 100644 --- a/Telegram/SourceFiles/settings/settings_cover.cpp +++ b/Telegram/SourceFiles/settings/settings_cover.cpp @@ -145,7 +145,7 @@ void CoverWidget::refreshNameGeometry(int newWidth) { } 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); _editNameInline->moveToLeft(nameLeft + _name->width(), nameTop, newWidth); diff --git a/Telegram/SourceFiles/settings/settings_info_widget.cpp b/Telegram/SourceFiles/settings/settings_info_widget.cpp index 086ceabde..e22400e61 100644 --- a/Telegram/SourceFiles/settings/settings_info_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_info_widget.cpp @@ -191,7 +191,7 @@ int InfoWidget::LabeledWidget::resizeGetHeight(int newWidth) { auto labelNatural = _label->naturalWidth(); 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 textWidth = _text->naturalWidth(); @@ -215,7 +215,7 @@ int InfoWidget::LabeledWidget::resizeGetHeight(int newWidth) { _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 diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index 7e4e4977b..075b42f12 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -1026,7 +1026,7 @@ public: } void setProgress(qint64 already, qint64 size) { _already = already; - _size = qMax(size, 0LL); + _size = std::max(size, 0LL); } qint64 size() const { @@ -1236,7 +1236,7 @@ void WebLoadManager::onMeta() { if (QString::fromUtf8(i->first).toLower() == "content-range") { QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second)); 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)) { _replies.erase(j); _loaders.remove(loader); diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index 8f210ee81..22f7303c3 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -410,7 +410,7 @@ void FileLoadTask::process() { 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) { return; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 505ebfe3d..8c02848c2 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -1811,13 +1811,13 @@ void _writeUserSettings() { data.stream << quint32(dbiDownloadPath) << (Global::AskDownloadPath() ? QString() : Global::DownloadPath()) << (Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark()); data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage()); data.stream << quint32(dbiDialogLastPath) << cDialogLastPath(); - data.stream << quint32(dbiSongVolume) << qint32(qRound(Global::SongVolume() * 1e6)); - data.stream << quint32(dbiVideoVolume) << qint32(qRound(Global::VideoVolume() * 1e6)); + data.stream << quint32(dbiSongVolume) << qint32(std::round(Global::SongVolume() * 1e6)); + data.stream << quint32(dbiVideoVolume) << qint32(std::round(Global::VideoVolume() * 1e6)); data.stream << quint32(dbiAutoDownload) << qint32(cAutoDownloadPhoto()) << qint32(cAutoDownloadAudio()) << qint32(cAutoDownloadGif()); data.stream << quint32(dbiDialogsMode) << qint32(Global::DialogsModeEnabled() ? 1 : 0) << static_cast(Global::DialogsMode()); data.stream << quint32(dbiModerateMode) << qint32(Global::ModerateModeEnabled() ? 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(std::round(dialogsWidthRatio() * 1000000), 0, 1000000)); data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer()); if (!userData.isEmpty()) { data.stream << quint32(dbiAuthSessionData) << userData; diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index b8f7b8448..04078c089 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -138,7 +138,7 @@ void EmptyUserpic::Impl::paintSquare(Painter &p, int x, int y, int size) { StorageKey EmptyUserpic::Impl::uniqueKey() const { auto first = 0xFFFFFFFF00000000ULL | anim::getPremultiplied(_color->c); 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); } @@ -1122,7 +1122,7 @@ bool PtsWaiter::check(ChannelData *channel, qint32 pts, qint32 count) { // retur return true; } - _last = qMax(_last, pts); + _last = std::max(_last, pts); _count += count; if (_last == _count) { _good = _last; diff --git a/Telegram/SourceFiles/ui/effects/cross_animation.cpp b/Telegram/SourceFiles/ui/effects/cross_animation.cpp index 34284ed03..039aeda4f 100644 --- a/Telegram/SourceFiles/ui/effects/cross_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/cross_animation.cpp @@ -135,7 +135,7 @@ void CrossAnimation::paint(Painter &p, const style::CrossAnimation &st, style::c transformLoadingCross(loading, pathDelete, pathDeleteSize); auto loadingArc = (loading >= 0.5) ? (loading - 1.) : loading; - loadingArcLength = qRound(-loadingArc * 2 * FullArcLength); + loadingArcLength = std::round(-loadingArc * 2 * FullArcLength); } 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 roundPart = QRectF(x + roundSkip, y + roundSkip, st.size - 2 * roundSkip, st.size - 2 * roundSkip); if (shown < 1.) { - loadingArcStart -= qRound(-(shown - 1.) * FullArcLength / 4.); + loadingArcStart -= std::round(-(shown - 1.) * FullArcLength / 4.); } p.setBrush(Qt::NoBrush); auto pen = color->p; diff --git a/Telegram/SourceFiles/ui/effects/panel_animation.cpp b/Telegram/SourceFiles/ui/effects/panel_animation.cpp index e31a127a9..902e804ec 100644 --- a/Telegram/SourceFiles/ui/effects/panel_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/panel_animation.cpp @@ -159,7 +159,7 @@ void RoundShadowAnimation::paintShadowCorner(int left, int top, const QImage &im for (auto y = 0; y != imageHeight; ++y) { for (auto x = 0; x != imageWidth; ++x) { 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; ++imageInts; @@ -274,30 +274,30 @@ void PanelAnimation::setFinalImage(QImage &&finalImage, QRect inner) { } void PanelAnimation::setStartWidth() { - _startWidth = qRound(_st.startWidth * _finalInnerWidth); + _startWidth = std::round(_st.startWidth * _finalInnerWidth); if (_startWidth >= 0) Assert(_startWidth <= _finalInnerWidth); } void PanelAnimation::setStartHeight() { - _startHeight = qRound(_st.startHeight * _finalInnerHeight); + _startHeight = std::round(_st.startHeight * _finalInnerHeight); if (_startHeight >= 0) Assert(_startHeight <= _finalInnerHeight); } void PanelAnimation::setStartAlpha() { - _startAlpha = qRound(_st.startOpacity * 255); + _startAlpha = std::round(_st.startOpacity * 255); Assert(_startAlpha >= 0 && _startAlpha < 256); } void PanelAnimation::setStartFadeTop() { - _startFadeTop = qRound(_st.startFadeTop * _finalInnerHeight); + _startFadeTop = std::round(_st.startFadeTop * _finalInnerHeight); } void PanelAnimation::createFadeMask() { - auto resultHeight = qRound(_finalImage.height() * _st.fadeHeight); + int resultHeight = std::round(_finalImage.height() * _st.fadeHeight); if (auto remove = (resultHeight % cIntRetinaFactor())) { resultHeight -= remove; } - auto finalAlpha = qRound(_st.fadeOpacity * 255); + int finalAlpha = std::round(_st.fadeOpacity * 255); Assert(finalAlpha >= 0 && finalAlpha < 256); auto result = QImage(cIntRetinaFactor(), resultHeight, QImage::Format_ARGB32_Premultiplied); auto ints = reinterpret_cast(result.bits()); @@ -386,7 +386,7 @@ void PanelAnimation::paintFrame(QPainter &p, int x, int y, int outerWidth, doubl if (auto decrease = (fadeTop % cIntRetinaFactor())) { fadeTop -= decrease; } - auto fadeBottom = (fadeTop < frameHeight) ? qMin(fadeTop + _fadeHeight, frameHeight) : frameHeight; + auto fadeBottom = (fadeTop < frameHeight) ? std::min(fadeTop + _fadeHeight, frameHeight) : frameHeight; auto fadeSkipLines = 0; if (_origin == Origin::BottomLeft || _origin == Origin::BottomRight) { fadeTop = frameHeight - fadeTop; diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.cpp b/Telegram/SourceFiles/ui/effects/radial_animation.cpp index af9fd645c..904d49006 100644 --- a/Telegram/SourceFiles/ui/effects/radial_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/radial_animation.cpp @@ -29,14 +29,14 @@ RadialAnimation::RadialAnimation(AnimationCallbacks &&callbacks) void RadialAnimation::start(double prg) { _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); _animation.start(); } void RadialAnimation::update(double prg, bool finished, TimeMs ms) { - auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength); - if (iprg != qRound(a_arcEnd.to())) { + auto iprg = std::round(std::max(prg, 0.0001) * AlmostFullArcLength); + if (iprg != std::round(a_arcEnd.to())) { a_arcEnd.start(iprg); _lastStart = _lastTime; } @@ -44,7 +44,7 @@ void RadialAnimation::update(double prg, bool finished, TimeMs ms) { auto dt = double(ms - _lastStart); auto fulldt = double(ms - _firstStart); - _opacity = qMin(fulldt / st::radialDuration, 1.); + _opacity = std::min(fulldt / st::radialDuration, 1.); if (!finished) { a_arcEnd.update(1. - (st::radialDuration / (st::radialDuration + dt)), anim::linear); } else if (dt >= st::radialDuration) { @@ -79,8 +79,8 @@ void RadialAnimation::draw(Painter &p, const QRect &inner, qint32 thickness, sty pen.setCapStyle(Qt::RoundCap); p.setPen(pen); - auto len = MinArcLength + qRound(a_arcEnd.current()); - auto from = QuarterArcLength - qRound(a_arcStart.current()) - len; + auto len = MinArcLength + std::round(a_arcEnd.current()); + auto from = QuarterArcLength - std::round(a_arcStart.current()) - len; if (rtl()) { from = QuarterArcLength - (from - QuarterArcLength) - len; if (from < 0) from += FullArcLength; diff --git a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp index ee68c78fd..82fba1a00 100644 --- a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp @@ -69,7 +69,7 @@ RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, QPoint origin, for (auto point : points) { 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); } diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp index ed8ec1abe..b40b669b2 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp @@ -65,7 +65,7 @@ RoundCheckbox::RoundCheckbox(const style::RoundCheckbox &st, base::lambdafadeIn.current(1.) - 0.5, 0.) * 2. * _st.size); - auto divider = qRound(realDivider); - auto cacheDivider = qRound(realDivider) * cIntRetinaFactor(); + auto realDivider = ((kWideScale - 1) * _st.size / 2 + std::max(icon->fadeIn.current(1.) - 0.5, 0.) * 2. * _st.size); + auto divider = std::round(realDivider); + 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(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.); 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 userpicLeft = x - (kWideScale - 1) * _st.imageRadius + userpicShift; auto userpicTop = y - (kWideScale - 1) * _st.imageRadius + userpicShift; diff --git a/Telegram/SourceFiles/ui/effects/widget_slide_wrap.cpp b/Telegram/SourceFiles/ui/effects/widget_slide_wrap.cpp index 239f83e6e..aec40d9b7 100644 --- a/Telegram/SourceFiles/ui/effects/widget_slide_wrap.cpp +++ b/Telegram/SourceFiles/ui/effects/widget_slide_wrap.cpp @@ -65,7 +65,7 @@ void WidgetSlideWrap::showAnimated() { if (!_hiding) return; } _hiding = false; - _forceHeight = qRound(_a_height.current(0.)); + _forceHeight = std::round(_a_height.current(0.)); _a_height.start([this] { animationCallback(); }, 0., _realSize.height(), _duration); } @@ -122,7 +122,7 @@ int WidgetSlideWrap::resizeGetHeight(int newWidth) { } void WidgetSlideWrap::animationCallback() { - _forceHeight = qRound(_a_height.current(_hiding ? 0 : -1)); + _forceHeight = std::round(_a_height.current(_hiding ? 0 : -1)); resizeToWidth(_realSize.width()); if (!_a_height.animating()) { _forceHeight = _hiding ? 0 : -1; diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 03454130c..7d9eddcd3 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -703,7 +703,7 @@ QPixmap Image::pixNoCache(int w, int h, Images::Options options, int outerw, int if (_data.isNull()) { 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); } @@ -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); } if (h < outerh) { - p.fillRect(qMax(0, (outerw - w) / 2), 0, qMin(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), 0, std::min(result.width(), w), (outerh - h) / 2, 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) { diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 387eb6c03..d714aa43c 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -112,7 +112,7 @@ void EmojiButton::paintEvent(QPaintEvent *e) { QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle); if (loading > 0) { 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); } else { p.drawEllipse(inner); diff --git a/Telegram/SourceFiles/ui/style/style_core_icon.cpp b/Telegram/SourceFiles/ui/style/style_core_icon.cpp index e07c87e94..625e2c496 100644 --- a/Telegram/SourceFiles/ui/style/style_core_icon.cpp +++ b/Telegram/SourceFiles/ui/style/style_core_icon.cpp @@ -39,7 +39,7 @@ inline int pxAdjust(int value, int scale) { if (value < 0) { 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) { @@ -51,7 +51,7 @@ QImage createIconMask(const IconMask *mask, DBIScale scale) { // 200x 100x // 150x 125x 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); if (!cRetina() && scale != dbisTwo) { if (scale == dbisOne) { diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index 14f064438..808f169be 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -898,7 +898,7 @@ public: _last_rPadding = b->f_rpadding(); _wLeft = newWidthLeft; - _lineHeight = qMax(_lineHeight, blockHeight); + _lineHeight = std::max(_lineHeight, blockHeight); longWordLine = false; continue; @@ -909,7 +909,7 @@ public: if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line _last_rPadding += b->f_rpadding(); - _lineHeight = qMax(_lineHeight, blockHeight); + _lineHeight = std::max(_lineHeight, blockHeight); longWordLine = false; continue; @@ -927,7 +927,7 @@ public: _last_rPadding = j->f_rpadding(); _wLeft = newWidthLeft; - _lineHeight = qMax(_lineHeight, blockHeight); + _lineHeight = std::max(_lineHeight, blockHeight); if (wordEndsHere) { longWordLine = false; @@ -940,7 +940,7 @@ public: continue; } - auto elidedLineHeight = qMax(_lineHeight, blockHeight); + auto elidedLineHeight = std::max(_lineHeight, blockHeight); auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide); if (elidedLine) { _lineHeight = elidedLineHeight; @@ -955,7 +955,7 @@ public: return; } _y += _lineHeight; - _lineHeight = qMax(0, blockHeight); + _lineHeight = std::max(0, blockHeight); _lineStart = j->from(); _lineStartBlock = blockIndex; @@ -974,7 +974,7 @@ public: continue; } - auto elidedLineHeight = qMax(_lineHeight, blockHeight); + auto elidedLineHeight = std::max(_lineHeight, blockHeight); auto elidedLine = _elideLast && (_y + elidedLineHeight >= _yToElide); if (elidedLine) { _lineHeight = elidedLineHeight; @@ -983,7 +983,7 @@ public: return; } _y += _lineHeight; - _lineHeight = qMax(0, blockHeight); + _lineHeight = std::max(0, blockHeight); _lineStart = b->from(); _lineStartBlock = blockIndex; @@ -1158,9 +1158,9 @@ private: auto currentBlock = _t->_blocks[blockIndex].get(); 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; - 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 lineStart = delta; @@ -1392,7 +1392,7 @@ private: unsigned short *logClusters = engine.logClusters(&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 glyphsStart = logClusters[itemStart - si.position], glyphsEnd; if (line.from + line.length < si.position + itemLength) { @@ -1611,7 +1611,7 @@ private: if (_wLeft < si.width) { lineText = lineText.mid(0, currentBlock->from() - _localFrom) + _Elide; 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()); elideSaveBlock(blockIndex - 1, _endBlock, currentBlock->from(), elideWidth); return; @@ -1621,7 +1621,7 @@ private: unsigned short *logClusters = engine.logClusters(&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 glyphsStart = logClusters[itemStart - si.position], glyphsEnd; if (line.from + line.length < si.position + itemLength) { @@ -1643,7 +1643,7 @@ private: if (lineText.size() <= pos || repeat > 3) { lineText += _Elide; 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()); _blocksSize = blockIndex; _endBlock = nextBlock; @@ -1663,7 +1663,7 @@ private: } qint32 elideStart = _localFrom + lineText.size(); - _selection.to = qMin(_selection.to, quint16(elideStart)); + _selection.to = std::min(_selection.to, quint16(elideStart)); setElideBidi(elideStart, _Elide.size()); lineText += _Elide; @@ -2515,7 +2515,7 @@ void Text::recountNaturalSize(bool initial, Qt::LayoutDirection optionsDir) { accumulate_max(_maxWidth, _width); _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_rPadding = b->f_rpadding(); @@ -2747,7 +2747,7 @@ void Text::enumerateLines(int w, Callback callback) const { last_rPadding = b->f_rpadding(); widthLeft = newWidthLeft; - lineHeight = qMax(lineHeight, blockHeight); + lineHeight = std::max(lineHeight, blockHeight); longWordLine = false; 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 last_rPadding += b->f_rpadding(); - lineHeight = qMax(lineHeight, blockHeight); + lineHeight = std::max(lineHeight, blockHeight); longWordLine = false; continue; @@ -2776,7 +2776,7 @@ void Text::enumerateLines(int w, Callback callback) const { last_rPadding = j->f_rpadding(); widthLeft = newWidthLeft; - lineHeight = qMax(lineHeight, blockHeight); + lineHeight = std::max(lineHeight, blockHeight); if (wordEndsHere) { longWordLine = false; @@ -2798,7 +2798,7 @@ void Text::enumerateLines(int w, Callback callback) const { callback(width - widthLeft, lineHeight); - lineHeight = qMax(0, blockHeight); + lineHeight = std::max(0, blockHeight); last_rBearing = j->f_rbearing(); last_rPadding = j->f_rpadding(); widthLeft = width - (j_width - last_rBearing); @@ -2813,7 +2813,7 @@ void Text::enumerateLines(int w, Callback callback) const { callback(width - widthLeft, lineHeight); - lineHeight = qMax(0, blockHeight); + lineHeight = std::max(0, blockHeight); last_rBearing = b__f_rbearing; last_rPadding = b->f_rpadding(); widthLeft = width - (b->f_width() - last_rBearing); @@ -2923,8 +2923,8 @@ void Text::enumerateText(TextSelection selection, AppendPartCallback appendPartC } if (blockLnkIndex != lnkIndex) { if (lnkIndex) { - auto rangeFrom = qMax(selection.from, lnkFrom); - auto rangeTo = qMin(blockFrom, selection.to); + auto rangeFrom = std::max(selection.from, lnkFrom); + auto rangeTo = std::min(blockFrom, selection.to); if (rangeTo > rangeFrom) { // handle click handler QStringRef r = _text.midRef(rangeFrom, rangeTo - rangeFrom); if (lnkFrom != rangeFrom || blockFrom != rangeTo) { @@ -2945,8 +2945,8 @@ void Text::enumerateText(TextSelection selection, AppendPartCallback appendPartC if ((*i)->type() == TextBlockTSkip) continue; if (!blockLnkIndex) { - auto rangeFrom = qMax(selection.from, blockFrom); - auto rangeTo = qMin(selection.to, quint16(blockFrom + countBlockLength(i, e))); + auto rangeFrom = std::max(selection.from, blockFrom); + auto rangeTo = std::min(selection.to, quint16(blockFrom + countBlockLength(i, e))); if (rangeTo > rangeFrom) { appendPartCallback(_text.midRef(rangeFrom, rangeTo - rangeFrom)); } diff --git a/Telegram/SourceFiles/ui/text/text_block.cpp b/Telegram/SourceFiles/ui/text/text_block.cpp index 9acfb7a9b..df0a62a87 100644 --- a/Telegram/SourceFiles/ui/text/text_block.cpp +++ b/Telegram/SourceFiles/ui/text/text_block.cpp @@ -86,7 +86,7 @@ struct LineBreakHelper // 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 // 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() diff --git a/Telegram/SourceFiles/ui/text/text_entity.cpp b/Telegram/SourceFiles/ui/text/text_entity.cpp index 88f06180b..c8169ca2c 100644 --- a/Telegram/SourceFiles/ui/text/text_entity.cpp +++ b/Telegram/SourceFiles/ui/text/text_entity.cpp @@ -1716,14 +1716,14 @@ void ParseMarkdown(TextWithEntities &result, bool rich) { // Check if start or end sequences intersect any existing entity. auto intersectedEntityEnd = 0; for_const (auto &entity, result.entities) { - if (qMin(part.innerStart, entity.offset() + entity.length()) > qMax(part.outerStart, entity.offset()) || - qMin(part.outerEnd, entity.offset() + entity.length()) > qMax(part.innerEnd, entity.offset())) { + if (std::min(part.innerStart, entity.offset() + entity.length()) > std::max(part.outerStart, entity.offset()) || + std::min(part.outerEnd, entity.offset() + entity.length()) > std::max(part.innerEnd, entity.offset())) { intersectedEntityEnd = entity.offset() + entity.length(); break; } } if (intersectedEntityEnd > 0) { - matchFromOffset = qMax(part.innerStart, intersectedEntityEnd); + matchFromOffset = std::max(part.innerStart, intersectedEntityEnd); continue; } @@ -1799,7 +1799,7 @@ void ParseEntities(TextWithEntities &result, qint32 flags, bool rich) { auto mDomain = RegExpDomain().match(result.text, matchOffset); auto mExplicitDomain = RegExpDomainExplicit().match(result.text, matchOffset); 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(); EntityInTextType lnkType = EntityInTextUrl; @@ -1831,7 +1831,7 @@ void ParseEntities(TextWithEntities &result, qint32 flags, bool rich) { } if (!(start + mentionStart + 1)->isLetter() || !(start + mentionEnd - 1)->isLetterOrNumber()) { mentionSkip = mentionEnd; - mMention = RegExpMention().match(result.text, qMax(mentionSkip, matchOffset)); + mMention = RegExpMention().match(result.text, std::max(mentionSkip, matchOffset)); if (mMention.hasMatch()) { mentionStart = mMention.capturedStart(); mentionEnd = mMention.capturedEnd(); @@ -2022,7 +2022,7 @@ QString ApplyEntities(const TextWithEntities &text) { already = offset; } result.append(tag); - closingTags.insert(qMin(entity->offset() + entity->length(), size), tag); + closingTags.insert(std::min(entity->offset() + entity->length(), size), tag); ++entity; tag = skipTillRelevantAndGetTag(); diff --git a/Telegram/SourceFiles/ui/toast/toast_widget.cpp b/Telegram/SourceFiles/ui/toast/toast_widget.cpp index 7bf22afe8..782e82de2 100644 --- a/Telegram/SourceFiles/ui/toast/toast_widget.cpp +++ b/Telegram/SourceFiles/ui/toast/toast_widget.cpp @@ -53,7 +53,7 @@ void Widget::onParentResized() { accumulate_min(newWidth, parentWidget()->width() - 2 * st::toastMinMargin); _textWidth = newWidth - _padding.left() - _padding.right(); 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(); setGeometry((parentWidget()->width() - newWidth) / 2, (parentWidget()->height() - newHeight) / 2, newWidth, newHeight); } diff --git a/Telegram/SourceFiles/ui/widgets/buttons.cpp b/Telegram/SourceFiles/ui/widgets/buttons.cpp index 7266a1ff7..2bd627d85 100644 --- a/Telegram/SourceFiles/ui/widgets/buttons.cpp +++ b/Telegram/SourceFiles/ui/widgets/buttons.cpp @@ -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()); } else { 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); } 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 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)) { _text = _st.font->elided(_fullText, availableWidth); _textWidth = _st.font->width(_text); diff --git a/Telegram/SourceFiles/ui/widgets/checkbox.cpp b/Telegram/SourceFiles/ui/widgets/checkbox.cpp index 81c12a5f0..31d69f330 100644 --- a/Telegram/SourceFiles/ui/widgets/checkbox.cpp +++ b/Telegram/SourceFiles/ui/widgets/checkbox.cpp @@ -268,7 +268,7 @@ void RadioView::paint(Painter &p, int left, int top, int outerWidth, TimeMs ms) pen.setWidth(_st->thickness); p.setPen(pen); 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(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; 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 (fskip != cskip) { // p.setOpacity(double(cskip) - checkSkip); @@ -376,7 +376,7 @@ void Checkbox::paintEvent(QPaintEvent *e) { } 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); _text.drawLeftElided(p, _st.margin.left() + _checkRect.width() + _st.textPosition.x(), _st.margin.top() + _st.textPosition.y(), textWidth, width()); diff --git a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp index eb584f76b..ae0c2090e 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp +++ b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp @@ -171,11 +171,11 @@ void FilledSlider::paintEvent(QPaintEvent *e) { auto disabled = isDisabled(); auto over = getCurrentOverFactor(ms); auto lineWidth = _st.lineWidth + ((_st.fullWidth - _st.lineWidth) * over); - auto lineWidthRounded = qFloor(lineWidth); + auto lineWidthRounded = std::floor(lineWidth); auto lineWidthPartial = lineWidth - lineWidthRounded; auto seekRect = getSeekRect(); 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) { p.setOpacity(masterOpacity); 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 from = _alwaysDisplayMarker ? 0 : markerFrom; 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 activeFg = disabled ? _st.activeFgDisabled : anim::brush(_st.activeFg, _st.activeFgOver, 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); 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 ? 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()); diff --git a/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp b/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp index 36c414217..c223388d5 100644 --- a/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp +++ b/Telegram/SourceFiles/ui/widgets/discrete_sliders.cpp @@ -190,9 +190,9 @@ void SettingsSlider::resizeSections(int newWidth) { auto skip = 0; auto x = 0.; enumerateSections([this, &x, &skip, sectionWidth](Section §ion) { - section.left = qFloor(x) + skip; + section.left = std::floor(x) + skip; x += sectionWidth; - section.width = qRound(x) - (section.left - skip); + section.width = std::round(x) - (section.left - skip); skip += _st.barSkip; return true; }); @@ -256,13 +256,13 @@ void SettingsSlider::paintEvent(QPaintEvent *e) { } auto from = section.left, tofill = section.width; 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); from += fill; tofill -= fill; } 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); from += fill; tofill -= fill; diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.cpp b/Telegram/SourceFiles/ui/widgets/input_fields.cpp index 40646c3eb..edf744543 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/input_fields.cpp @@ -926,7 +926,7 @@ void FlatTextarea::insertFromMimeData(const QMimeData *source) { _insertedTags.clear(); } auto cursor = textCursor(); - _realInsertPosition = qMin(cursor.position(), cursor.anchor()); + _realInsertPosition = std::min(cursor.position(), cursor.anchor()); _realCharsAdded = text.size(); QTextEdit::insertFromMimeData(source); 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) { int emojiLength = 0; if (auto emoji = Ui::Emoji::Find(ch, textEnd, &emojiLength)) { @@ -1815,7 +1815,7 @@ bool InputArea::heightAutoupdated() { 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) { newh = _st.heightMax; } else if (newh < _st.heightMin) { @@ -1904,8 +1904,8 @@ void InputArea::paintEvent(QPaintEvent *e) { auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); if (_st.borderActive && (borderOpacity > 0.)) { auto borderStart = snap(_borderAnimationStart, 0, width()); - auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); - auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); + auto borderFrom = std::round(borderStart * (1. - borderShownDegree)); + auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree); if (borderTo > borderFrom) { auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); p.setOpacity(borderOpacity); @@ -2637,8 +2637,8 @@ void InputField::paintEvent(QPaintEvent *e) { auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); if (_st.borderActive && (borderOpacity > 0.)) { auto borderStart = snap(_borderAnimationStart, 0, width()); - auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); - auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); + auto borderFrom = std::round(borderStart * (1. - borderShownDegree)); + auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree); if (borderTo > borderFrom) { auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); p.setOpacity(borderOpacity); @@ -3412,8 +3412,8 @@ void MaskedInputField::paintEvent(QPaintEvent *e) { auto borderOpacity = _a_borderOpacity.current(ms, _borderVisible ? 1. : 0.); if (_st.borderActive && (borderOpacity > 0.)) { auto borderStart = snap(_borderAnimationStart, 0, width()); - auto borderFrom = qRound(borderStart * (1. - borderShownDegree)); - auto borderTo = borderStart + qRound((width() - borderStart) * borderShownDegree); + auto borderFrom = std::round(borderStart * (1. - borderShownDegree)); + auto borderTo = borderStart + std::round((width() - borderStart) * borderShownDegree); if (borderTo > borderFrom) { auto borderFg = anim::brush(_st.borderFgActive, _st.borderFgError, errorDegree); p.setOpacity(borderOpacity); @@ -4003,7 +4003,7 @@ void PhoneInput::correctValue(const QString &was, qint32 wasCursor, QString &now } 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; int curPart = 0, leftInPart = inPart ? _pattern.at(curPart) : 0; diff --git a/Telegram/SourceFiles/ui/widgets/labels.cpp b/Telegram/SourceFiles/ui/widgets/labels.cpp index 9090eadef..ff2553a3f 100644 --- a/Telegram/SourceFiles/ui/widgets/labels.cpp +++ b/Telegram/SourceFiles/ui/widgets/labels.cpp @@ -222,7 +222,7 @@ int FlatLabel::countTextWidth() const { int FlatLabel::countTextHeight(int 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() { @@ -618,7 +618,7 @@ std::unique_ptr FlatLabel::CrossFade(FlatLabel *from, FlatLa auto was = prepareData(from); 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) { for (auto i = data.lineWidths.size(); i != maxLines; ++i) { data.lineWidths.push_back(-1); @@ -690,7 +690,7 @@ void FlatLabel::updateHover(const Text::StateResult &state) { if (state.afterSymbol && _selectionType == TextSelectType::Letters) { ++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) { _selection = selection; _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 renderElided = _breakEverywhere || heightExceeded; if (renderElided) { - auto lineHeight = qMax(_st.style.lineHeight, _st.style.font->height); - auto lines = _st.maxHeight ? qMax(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2); + auto lineHeight = std::max(_st.style.lineHeight, _st.style.font->height); + auto lines = _st.maxHeight ? std::max(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2); request.lines = lines; if (_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 renderElided = _breakEverywhere || heightExceeded; if (renderElided) { - auto lineHeight = qMax(_st.style.lineHeight, _st.style.font->height); - auto lines = _st.maxHeight ? qMax(_st.maxHeight / lineHeight, 1) : ((height() / lineHeight) + 2); + auto lineHeight = std::max(_st.style.lineHeight, _st.style.font->height); + 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); } else { _text.draw(p, _st.margin.left(), _st.margin.top(), textWidth, _st.align, e->rect().y(), e->rect().bottom(), selection); diff --git a/Telegram/SourceFiles/ui/widgets/menu.cpp b/Telegram/SourceFiles/ui/widgets/menu.cpp index bf56cfc44..d5761224c 100644 --- a/Telegram/SourceFiles/ui/widgets/menu.cpp +++ b/Telegram/SourceFiles/ui/widgets/menu.cpp @@ -78,7 +78,7 @@ QAction *Menu::addAction(QAction *action, const style::icon *icon, const style:: }; _actionsData.push_back(createData()); - auto newWidth = qMax(width(), _st.widthMin); + auto newWidth = std::max(width(), _st.widthMin); newWidth = processAction(action, _actions.size() - 1, newWidth); auto newHeight = height() + (action->isSeparator() ? _separatorHeight : _itemHeight); resize(_forceWidth ? _forceWidth : newWidth, newHeight); diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index befc3b030..f0e5f49e0 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -60,7 +60,7 @@ void MultiSelect::Item::paint(Painter &p, int outerWidth, TimeMs ms) { paintOnce(p, _x, _y, outerWidth, ms); } else { for (auto i = _copies.begin(), e = _copies.end(); i != e;) { - auto x = qRound(i->x.current(getms(), _x)); + auto x = std::round(i->x.current(getms(), _x)); auto y = i->y; auto animating = i->x.animating(); if (animating || (y == _y)) { @@ -356,7 +356,7 @@ int MultiSelect::resizeGetHeight(int newWidth) { if (newWidth != _inner->width()) { _inner->resizeToWidth(newWidth); } - auto newHeight = qMin(_inner->height(), _st.maxHeight); + auto newHeight = std::min(_inner->height(), _st.maxHeight); _scroll->setGeometryToLeft(0, 0, newWidth, newHeight); return newHeight; } @@ -537,9 +537,9 @@ void MultiSelect::Inner::paintEvent(QPaintEvent *e) { QMargins MultiSelect::Inner::itemPaintMargins() const { return { - qMax(_st.itemSkip, _st.padding.left()), + std::max(_st.itemSkip, _st.padding.left()), _st.itemSkip, - qMax(_st.itemSkip, _st.padding.right()), + std::max(_st.itemSkip, _st.padding.right()), _st.itemSkip, }; } @@ -654,7 +654,7 @@ void MultiSelect::Inner::computeItemsGeometry(int newWidth) { auto itemLeft = 0; auto itemTop = 0; auto widthLeft = newWidth; - auto maxVisiblePadding = qMax(_st.padding.left(), _st.padding.right()); + auto maxVisiblePadding = std::max(_st.padding.left(), _st.padding.right()); for_const (auto &item, _items) { auto itemWidth = item->getWidth(); Assert(itemWidth <= newWidth); @@ -689,7 +689,7 @@ void MultiSelect::Inner::updateItemsGeometry() { } void MultiSelect::Inner::updateHeightStep() { - auto newHeight = qRound(_height.current(_newHeight)); + auto newHeight = std::round(_height.current(_newHeight)); if (auto heightDelta = newHeight - height()) { resize(width(), newHeight); if (_resizedCallback) { diff --git a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp index 453d9e058..075dd436e 100644 --- a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp +++ b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp @@ -353,8 +353,8 @@ ScrollArea::ScrollArea(QWidget *parent, const style::ScrollArea &st, bool handle void ScrollArea::touchDeaccelerate(qint32 elapsed) { qint32 x = _touchSpeed.x(); qint32 y = _touchSpeed.y(); - _touchSpeed.setX((x == 0) ? x : (x > 0) ? qMax(0, x - elapsed) : qMin(0, x + elapsed)); - _touchSpeed.setY((y == 0) ? y : (y > 0) ? qMax(0, y - elapsed) : qMin(0, y + 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) ? std::max(0, y - elapsed) : std::min(0, y + elapsed)); } void ScrollArea::onScrolled() { @@ -399,12 +399,12 @@ void ScrollArea::onInnerResized() { int ScrollArea::scrollWidth() const { QWidget *w(widget()); - return w ? qMax(w->width(), width()) : width(); + return w ? std::max(w->width(), width()) : width(); } int ScrollArea::scrollHeight() const { QWidget *w(widget()); - return w ? qMax(w->height(), height()) : height(); + return w ? std::max(w->height(), height()) : height(); } int ScrollArea::scrollLeftMax() const { diff --git a/Telegram/SourceFiles/ui/widgets/tooltip.cpp b/Telegram/SourceFiles/ui/widgets/tooltip.cpp index 5f28c3929..e6b211462 100644 --- a/Telegram/SourceFiles/ui/widgets/tooltip.cpp +++ b/Telegram/SourceFiles/ui/widgets/tooltip.cpp @@ -131,16 +131,16 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip * // adjust tooltip position QRect r(QApplication::desktop()->screenGeometry(m)); if (r.x() + r.width() - _st->skip < p.x() + s.width() && p.x() + s.width() > m.x()) { - p.setX(qMax(r.x() + r.width() - qint32(_st->skip) - s.width(), m.x() - s.width())); + p.setX(std::max(r.x() + r.width() - qint32(_st->skip) - s.width(), m.x() - s.width())); } if (r.x() + _st->skip > p.x() && p.x() < m.x()) { - p.setX(qMin(m.x(), r.x() + qint32(_st->skip))); + p.setX(std::min(m.x(), r.x() + qint32(_st->skip))); } if (r.y() + r.height() - _st->skip < p.y() + s.height()) { p.setY(m.y() - s.height() - _st->skip); } if (r.y() > p.x()) { - p.setY(qMin(m.y() + _st->shift.y(), r.y() + r.height() - s.height())); + p.setY(std::min(m.y() + _st->shift.y(), r.y() + r.height() - s.height())); } setGeometry(QRect(p, s)); @@ -167,7 +167,7 @@ void Tooltip::paintEvent(QPaintEvent *e) { p.fillRect(QRect(0, st::lineWidth, st::lineWidth, height() - 2 * st::lineWidth), _st->textBorder); p.fillRect(QRect(width() - st::lineWidth, st::lineWidth, st::lineWidth, height() - 2 * st::lineWidth), _st->textBorder); } - qint32 lines = qFloor((height() - 2 * st::lineWidth - _st->textPadding.top() - _st->textPadding.bottom()) / _st->textStyle.font->height); + qint32 lines = std::floor((height() - 2 * st::lineWidth - _st->textPadding.top() - _st->textPadding.bottom()) / _st->textStyle.font->height); p.setPen(_st->textFg); _text.drawElided(p, st::lineWidth + _st->textPadding.left(), st::lineWidth + _st->textPadding.top(), width() - 2 * st::lineWidth - _st->textPadding.left() - _st->textPadding.right(), lines); diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index f7af0a799..0fb67aced 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -372,8 +372,8 @@ bool MainWindow::canExtendWidthBy(int addToWidth) { void MainWindow::tryToExtendWidthBy(int addToWidth) { auto desktop = QDesktopWidget().availableGeometry(this); - auto newWidth = qMin(width() + addToWidth, desktop.width()); - auto newLeft = qMin(x(), desktop.x() + desktop.width() - newWidth); + auto newWidth = std::min(width() + addToWidth, desktop.width()); + auto newLeft = std::min(x(), desktop.x() + desktop.width() - newWidth); if (x() != newLeft || width() != newWidth) { setGeometry(newLeft, y(), newWidth, height()); } else { diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 300814c02..8700a6fff 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -457,7 +457,7 @@ void Widget::moveByShift() { } QPoint Widget::computePosition(int height) const { - auto realShift = qRound(a_shift.current()); + auto realShift = std::round(a_shift.current()); if (_direction == Direction::Up) { realShift = -realShift - height; } diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index 809e09a44..82ae7a8a3 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -477,8 +477,8 @@ void ChatBackground::setPreparedImage(QImage &&image) { Assert(width > 0 && height > 0); auto isSmallForTiled = (width < kMinimumTiledSize || height < kMinimumTiledSize); if (isSmallForTiled) { - auto repeatTimesX = qCeil(kMinimumTiledSize / double(width)); - auto repeatTimesY = qCeil(kMinimumTiledSize / double(height)); + int repeatTimesX = std::ceil(kMinimumTiledSize / double(width)); + int repeatTimesY = std::ceil(kMinimumTiledSize / double(height)); auto imageForTiled = QImage(width * repeatTimesX, height * repeatTimesY, QImage::Format_ARGB32_Premultiplied); imageForTiled.setDevicePixelRatio(image.devicePixelRatio()); auto imageForTiledBytes = imageForTiled.bits(); @@ -787,23 +787,23 @@ bool IsPaletteTestingPath(const QString &path) { void ComputeBackgroundRects(QRect wholeFill, QSize imageSize, QRect &to, QRect &from) { if (quint64(imageSize.width()) * wholeFill.height() > quint64(imageSize.height()) * wholeFill.width()) { double pxsize = wholeFill.height() / double(imageSize.height()); - int takewidth = qCeil(wholeFill.width() / pxsize); + int takewidth = std::ceil(wholeFill.width() / pxsize); if (takewidth > imageSize.width()) { takewidth = imageSize.width(); } else if ((imageSize.width() % 2) != (takewidth % 2)) { ++takewidth; } - to = QRect(int((wholeFill.width() - takewidth * pxsize) / 2.), 0, qCeil(takewidth * pxsize), wholeFill.height()); + to = QRect(int((wholeFill.width() - takewidth * pxsize) / 2.), 0, std::ceil(takewidth * pxsize), wholeFill.height()); from = QRect((imageSize.width() - takewidth) / 2, 0, takewidth, imageSize.height()); } else { double pxsize = wholeFill.width() / double(imageSize.width()); - int takeheight = qCeil(wholeFill.height() / pxsize); + int takeheight = std::ceil(wholeFill.height() / pxsize); if (takeheight > imageSize.height()) { takeheight = imageSize.height(); } else if ((imageSize.height() % 2) != (takeheight % 2)) { ++takeheight; } - to = QRect(0, int((wholeFill.height() - takeheight * pxsize) / 2.), wholeFill.width(), qCeil(takeheight * pxsize)); + to = QRect(0, int((wholeFill.height() - takeheight * pxsize) / 2.), wholeFill.width(), std::ceil(takeheight * pxsize)); from = QRect(0, (imageSize.height() - takeheight) / 2, imageSize.width(), takeheight); } } diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index 3689f247a..950ca0729 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -273,7 +273,7 @@ void Generator::addTextBubble(QString text, QString date, Status status) { accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right()); accumulate_min(width, st::msgMaxWidth); - auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1); + auto textWidth = std::max(width - st::msgPadding.left() - st::msgPadding.right(), 1); auto textHeight = bubble.text.countHeight(textWidth); auto height = st::msgPadding.top() + textHeight + st::msgPadding.bottom(); @@ -297,7 +297,7 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta accumulate_min(width, bubble.photoWidth); accumulate_min(width, st::msgMaxWidth); - auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1); + auto textWidth = std::max(width - st::msgPadding.left() - st::msgPadding.right(), 1); auto textHeight = bubble.text.countHeight(textWidth); auto height = st::mediaCaptionSkip + textHeight + st::msgPadding.bottom(); @@ -416,8 +416,8 @@ void Generator::paintHistoryBackground() { if (tiled) { auto width = background.width(); auto height = background.height(); - auto repeatTimesX = qCeil(_history.width() * cIntRetinaFactor() / double(width)); - auto repeatTimesY = qCeil((_history.height() - fromy) * cIntRetinaFactor() / double(height)); + int repeatTimesX = std::ceil(_history.width() * cIntRetinaFactor() / double(width)); + int repeatTimesY = std::ceil((_history.height() - fromy) * cIntRetinaFactor() / double(height)); auto imageForTiled = QImage(width * repeatTimesX, height * repeatTimesY, QImage::Format_ARGB32_Premultiplied); imageForTiled.setDevicePixelRatio(background.devicePixelRatio()); auto imageForTiledBytes = imageForTiled.bits(); diff --git a/Telegram/SourceFiles/window/top_bar_widget.cpp b/Telegram/SourceFiles/window/top_bar_widget.cpp index 0254043da..11d10b9f2 100644 --- a/Telegram/SourceFiles/window/top_bar_widget.cpp +++ b/Telegram/SourceFiles/window/top_bar_widget.cpp @@ -269,7 +269,7 @@ void TopBarWidget::updateControlsGeometry() { auto buttonsWidth = _forward->contentWidth() + _delete->contentWidth() + _clearSelection->width(); buttonsWidth += buttonsLeft + st::topBarActionSkip * 3; - auto widthLeft = qMin(width() - buttonsWidth, -2 * st::defaultActiveButton.width); + auto widthLeft = std::min(width() - buttonsWidth, -2 * st::defaultActiveButton.width); _forward->setFullWidth(-(widthLeft / 2)); _delete->setFullWidth(-(widthLeft / 2)); diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 2f450ed70..e2f94d8fd 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -64,7 +64,7 @@ Controller::ColumnLayout Controller::computeColumnLayout() const { auto layout = Adaptive::WindowLayout::OneColumn; auto bodyWidth = window()->bodyWidget()->width(); - auto dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value()); + int dialogsWidth = std::round(bodyWidth * dialogsWidthRatio().value()); auto chatWidth = bodyWidth - dialogsWidth; accumulate_max(chatWidth, st::windowMinWidth); dialogsWidth = bodyWidth - chatWidth;