From b22c65a8db859c91c6859dcfd15b8f3589c57071 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 26 Jan 2021 12:15:00 +0400 Subject: [PATCH] Fix build on Windows, add report Fake-s. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/report_box.cpp | 20 +++++------- Telegram/SourceFiles/boxes/report_box.h | 2 ++ .../SourceFiles/calls/calls_group_call.cpp | 2 +- .../SourceFiles/calls/calls_group_members.cpp | 32 +++++++++++-------- .../SourceFiles/calls/calls_volume_item.cpp | 2 +- Telegram/lib_ui | 2 +- 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 773ee980ed..ab31c4d076 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -977,6 +977,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_report_bot_title" = "Report bot"; "lng_report_message_title" = "Report message"; "lng_report_reason_spam" = "Spam"; +"lng_report_reason_fake" = "Fake"; "lng_report_reason_violence" = "Violence"; "lng_report_reason_child_abuse" = "Child Abuse"; "lng_report_reason_pornography" = "Pornography"; diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 0a26a020ac..41b3d24f36 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -73,10 +73,9 @@ void ReportBox::prepare() { st::defaultBoxCheckbox); }; createButton(_reasonSpam, Reason::Spam, tr::lng_report_reason_spam(tr::now)); + createButton(_reasonFake, Reason::Fake, tr::lng_report_reason_fake(tr::now)); createButton(_reasonViolence, Reason::Violence, tr::lng_report_reason_violence(tr::now)); - if (_ids) { - createButton(_reasonChildAbuse, Reason::ChildAbuse, tr::lng_report_reason_child_abuse(tr::now)); - } + createButton(_reasonChildAbuse, Reason::ChildAbuse, tr::lng_report_reason_child_abuse(tr::now)); createButton(_reasonPornography, Reason::Pornography, tr::lng_report_reason_pornography(tr::now)); createButton(_reasonOther, Reason::Other, tr::lng_report_reason_other(tr::now)); _reasonGroup->setChangedCallback([=](Reason value) { @@ -90,14 +89,10 @@ void ReportBox::resizeEvent(QResizeEvent *e) { BoxContent::resizeEvent(e); _reasonSpam->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxOptionListPadding.top() + _reasonSpam->getMargins().top()); - _reasonViolence->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonSpam->bottomNoMargins() + st::boxOptionListSkip); - if (_ids) { - _reasonChildAbuse->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonViolence->bottomNoMargins() + st::boxOptionListSkip); - _reasonPornography->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonChildAbuse->bottomNoMargins() + st::boxOptionListSkip); - } - else{ - _reasonPornography->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonViolence->bottomNoMargins() + st::boxOptionListSkip); - } + _reasonFake->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonSpam->bottomNoMargins() + st::boxOptionListSkip); + _reasonViolence->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonFake->bottomNoMargins() + st::boxOptionListSkip); + _reasonChildAbuse->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonViolence->bottomNoMargins() + st::boxOptionListSkip); + _reasonPornography->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonChildAbuse->bottomNoMargins() + st::boxOptionListSkip); _reasonOther->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonPornography->bottomNoMargins() + st::boxOptionListSkip); if (_reasonOtherText) { @@ -156,6 +151,7 @@ void ReportBox::report() { const auto reason = [&] { switch (_reasonGroup->value()) { case Reason::Spam: return MTP_inputReportReasonSpam(); + case Reason::Fake: return MTP_inputReportReasonFake(); case Reason::Violence: return MTP_inputReportReasonViolence(); case Reason::ChildAbuse: return MTP_inputReportReasonChildAbuse(); case Reason::Pornography: return MTP_inputReportReasonPornography(); @@ -203,7 +199,7 @@ void ReportBox::reportFail(const RPCError &error) { } void ReportBox::updateMaxHeight() { - const auto buttonsCount = _ids ? 5 : 4; + const auto buttonsCount = 6; auto newHeight = st::boxOptionListPadding.top() + _reasonSpam->getMargins().top() + buttonsCount * _reasonSpam->heightNoMargins() + (buttonsCount - 1) * st::boxOptionListSkip + _reasonSpam->getMargins().bottom() + st::boxOptionListPadding.bottom(); if (_reasonOtherText) { diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index 04b5beb5de..ad637aae3c 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -37,6 +37,7 @@ protected: private: enum class Reason { Spam, + Fake, Violence, ChildAbuse, Pornography, @@ -56,6 +57,7 @@ private: std::shared_ptr> _reasonGroup; object_ptr> _reasonSpam = { nullptr }; + object_ptr> _reasonFake = { nullptr }; object_ptr> _reasonViolence = { nullptr }; object_ptr> _reasonChildAbuse = { nullptr }; object_ptr> _reasonPornography = { nullptr }; diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 2a7a4e92a3..81b7663530 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -599,8 +599,8 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) { } _otherParticipantStateValue.fire(Group::ParticipantState{ .user = user, - .mutedByMe = data.is_muted_by_you(), .volume = data.vvolume().value_or_empty(), + .mutedByMe = data.is_muted_by_you(), }); }; diff --git a/Telegram/SourceFiles/calls/calls_group_members.cpp b/Telegram/SourceFiles/calls/calls_group_members.cpp index 61a668b2e4..8bdd369216 100644 --- a/Telegram/SourceFiles/calls/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/calls_group_members.cpp @@ -902,12 +902,14 @@ void MembersController::appendInvitedUsers() { void MembersController::updateRow( const std::optional &was, const Data::GroupCall::Participant &now) { + auto reorderIfInvitedBeforeIndex = 0; auto countChange = 0; if (const auto row = findRow(now.user)) { if (now.speaking && (!was || !was->speaking)) { checkSpeakingRowPosition(row); } if (row->state() == Row::State::Invited) { + reorderIfInvitedBeforeIndex = row->absoluteIndex(); countChange = 1; } updateRow(row, &now); @@ -915,25 +917,27 @@ void MembersController::updateRow( if (row->speaking()) { delegate()->peerListPrependRow(std::move(row)); } else { - static constexpr auto kInvited = Row::State::Invited; - const auto reorder = [&] { - const auto count = delegate()->peerListFullRowsCount(); - if (!count) { - return false; - } - const auto row = delegate()->peerListRowAt(count - 1).get(); - return (static_cast(row)->state() == kInvited); - }(); + reorderIfInvitedBeforeIndex = delegate()->peerListFullRowsCount(); delegate()->peerListAppendRow(std::move(row)); - if (reorder) { - delegate()->peerListPartitionRows([](const PeerListRow &row) { - return static_cast(row).state() != kInvited; - }); - } } delegate()->peerListRefreshRows(); countChange = 1; } + static constexpr auto kInvited = Row::State::Invited; + const auto reorder = [&] { + const auto count = reorderIfInvitedBeforeIndex; + if (count <= 0) { + return false; + } + const auto row = delegate()->peerListRowAt( + reorderIfInvitedBeforeIndex - 1).get(); + return (static_cast(row)->state() == kInvited); + }(); + if (reorder) { + delegate()->peerListPartitionRows([](const PeerListRow &row) { + return static_cast(row).state() != kInvited; + }); + } if (countChange) { const auto fullCountMin = _fullCountMin.current() + countChange; if (_fullCountMax.current() < fullCountMin) { diff --git a/Telegram/SourceFiles/calls/calls_volume_item.cpp b/Telegram/SourceFiles/calls/calls_volume_item.cpp index a156537f54..f78e93e2fe 100644 --- a/Telegram/SourceFiles/calls/calls_volume_item.cpp +++ b/Telegram/SourceFiles/calls/calls_volume_item.cpp @@ -167,7 +167,7 @@ MenuVolumeItem::MenuVolumeItem( std::round(_slider->value() * _maxVolume); if ((localVolume != newVolume) && (_cloudVolume == newVolume)) { - _changeVolumeRequests.fire(localVolume); + _changeVolumeRequests.fire(int(localVolume)); } } else { setCloudVolume(newVolume); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index a5fb993721..bda12f2bec 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit a5fb99372184d5f3c00e5e851aaa16d8d28d2ce1 +Subproject commit bda12f2becd2497056d325a897b8285cc57662de