Skip to content

Commit

Permalink
Merge pull request #638 from telegramdesktop/dev
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Aug 4, 2023
2 parents d08505b + bda3bae commit c7246ae
Show file tree
Hide file tree
Showing 32 changed files with 177 additions and 137 deletions.
2 changes: 2 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filter_chats_limit_title" = "Limit Reached";
"lng_filter_chats_limit1#one" = "Sorry, you can't add more than **{count}** chat to a folder.";
"lng_filter_chats_limit1#other" = "Sorry, you can't add more than **{count}** chats to a folder.";
"lng_filter_chats_exlude_limit1#one" = "Sorry, you can't exlude more than **{count}** chat from a folder.";
"lng_filter_chats_exlude_limit1#other" = "Sorry, you can't exlude more than **{count}** chats from a folder.";
"lng_filter_chats_limit2#one" = "You can increase this limit to **{count}** by upgrading to **Telegram Premium**.";
"lng_filter_chats_limit2#other" = "You can increase this limit to **{count}** by upgrading to **Telegram Premium**.";

Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/api/api_chat_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void ShowImportError(
if (error == u"CHANNELS_TOO_MUCH"_q) {
window->show(Box(ChannelsLimitBox, session));
} else if (error == u"FILTER_INCLUDE_TOO_MUCH"_q) {
window->show(Box(FilterChatsLimitBox, session, count));
window->show(Box(FilterChatsLimitBox, session, count, true));
} else if (error == u"CHATLISTS_TOO_MUCH"_q) {
window->show(Box(ShareableFiltersLimitBox, session));
} else {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,7 @@ void ApiWrap::sendSharedContact(
void ApiWrap::sendVoiceMessage(
QByteArray result,
VoiceWaveform waveform,
int duration,
crl::time duration,
const SendAction &action) {
const auto caption = TextWithTags();
const auto to = fileLoadTaskOptions(action);
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/apiwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class ApiWrap final : public MTP::Sender {
void sendVoiceMessage(
QByteArray result,
VoiceWaveform waveform,
int duration,
crl::time duration,
const SendAction &action);
void sendFiles(
Ui::PreparedList &&list,
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/choose_filter_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void FillChooseFilterMenu(
controller->show(Box(
FilterChatsLimitBox,
&controller->session(),
r.count));
r.count,
true));
} else if (validator.canAdd()) {
validator.add(id);
}
Expand Down
8 changes: 6 additions & 2 deletions Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,18 @@ void EditExceptions(
Fn<void()> refresh) {
const auto include = (options & Flag::Contacts) != Flags(0);
const auto rules = data->current();
const auto session = &window->session();
auto controller = std::make_unique<EditFilterChatsListController>(
&window->session(),
session,
(include
? tr::lng_filters_include_title()
: tr::lng_filters_exclude_title()),
options,
rules.flags() & options,
include ? rules.always() : rules.never());
include ? rules.always() : rules.never(),
[=](int count) {
return Box(FilterChatsLimitBox, session, count, include);
});
const auto rawController = controller.get();
auto initBox = [=](not_null<PeerListBox*> box) {
box->setCloseByOutsideClick(false);
Expand Down
28 changes: 7 additions & 21 deletions Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ For license and copyright information please follow this link:
*/
#include "boxes/filters/edit_filter_chats_list.h"

#include "data/data_premium_limits.h"
#include "history/history.h"
#include "window/window_session_controller.h"
#include "boxes/premium_limits_box.h"
#include "lang/lang_keys.h"
#include "ui/widgets/labels.h"
#include "ui/wrap/vertical_layout.h"
Expand Down Expand Up @@ -99,22 +99,6 @@ class TypeController final : public PeerListController {
return PeerId(FakeChatId(static_cast<BareId>(flag))).value;
}

[[nodiscard]] int Limit(
not_null<Main::Session*> session,
const QString &key,
int fallback) {
return session->account().appConfig().get<int>(key, fallback);
}

[[nodiscard]] int Limit(not_null<Main::Session*> session) {
const auto premium = session->premium();
return Limit(session,
(premium
? "dialog_filters_chats_limit_premium"
: "dialog_filters_chats_limit_default"),
premium ? 200 : 100);
}

TypeRow::TypeRow(Flag flag) : PeerListRow(TypeId(flag)) {
}

Expand Down Expand Up @@ -338,15 +322,18 @@ EditFilterChatsListController::EditFilterChatsListController(
rpl::producer<QString> title,
Flags options,
Flags selected,
const base::flat_set<not_null<History*>> &peers)
const base::flat_set<not_null<History*>> &peers,
LimitBoxFactory limitBox)
: ChatsListBoxController(session)
, _session(session)
, _limitBox(std::move(limitBox))
, _title(std::move(title))
, _peers(peers)
, _options(options & ~Flag::Chatlist)
, _selected(selected)
, _limit(Limit(session))
, _limit(Data::PremiumLimits(session).dialogFiltersChatsCurrent())
, _chatlist(options & Flag::Chatlist) {
Expects(_limitBox != nullptr);
}

Main::Session &EditFilterChatsListController::session() const {
Expand Down Expand Up @@ -375,8 +362,7 @@ void EditFilterChatsListController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListSetRowChecked(row, !row->checked());
updateTitle();
} else {
delegate()->peerListShowBox(
Box(FilterChatsLimitBox, _session, count));
delegate()->peerListShowBox(_limitBox(count));
}
}

Expand Down
5 changes: 4 additions & 1 deletion Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ class EditFilterChatsListController final : public ChatsListBoxController {
public:
using Flag = Data::ChatFilter::Flag;
using Flags = Data::ChatFilter::Flags;
using LimitBoxFactory = Fn<object_ptr<Ui::BoxContent>(int)>;

EditFilterChatsListController(
not_null<Main::Session*> session,
rpl::producer<QString> title,
Flags options,
Flags selected,
const base::flat_set<not_null<History*>> &peers);
const base::flat_set<not_null<History*>> &peers,
LimitBoxFactory limitBox);

[[nodiscard]] Main::Session &session() const override;
[[nodiscard]] Flags chosenOptions() const {
Expand All @@ -70,6 +72,7 @@ class EditFilterChatsListController final : public ChatsListBoxController {
void updateTitle();

const not_null<Main::Session*> _session;
const LimitBoxFactory _limitBox;
rpl::producer<QString> _title;
base::flat_set<not_null<History*>> _peers;
Flags _options;
Expand Down
13 changes: 8 additions & 5 deletions Telegram/SourceFiles/boxes/premium_limits_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ void PublicLinksLimitBox(
void FilterChatsLimitBox(
not_null<Ui::GenericBox*> box,
not_null<Main::Session*> session,
int currentCount) {
int currentCount,
bool include) {
const auto premium = session->premium();
const auto premiumPossible = session->premiumPossible();

Expand All @@ -707,10 +708,12 @@ void FilterChatsLimitBox(
premiumLimit);

auto text = rpl::combine(
tr::lng_filter_chats_limit1(
lt_count,
rpl::single(premium ? premiumLimit : defaultLimit),
Ui::Text::RichLangValue),
(include
? tr::lng_filter_chats_limit1
: tr::lng_filter_chats_exlude_limit1)(
lt_count,
rpl::single(premium ? premiumLimit : defaultLimit),
Ui::Text::RichLangValue),
((premium || !premiumPossible)
? rpl::single(TextWithEntities())
: tr::lng_filter_chats_limit2(
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/premium_limits_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void PublicLinksLimitBox(
void FilterChatsLimitBox(
not_null<Ui::GenericBox*> box,
not_null<Main::Session*> session,
int currentCount);
int currentCount,
bool include);
void FilterLinksLimitBox(
not_null<Ui::GenericBox*> box,
not_null<Main::Session*> session);
Expand Down
45 changes: 25 additions & 20 deletions Telegram/SourceFiles/calls/calls_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Panel::Panel(not_null<Call*> call)
_decline->entity()->setText(tr::lng_call_decline());
_cancel->setDuration(st::callPanelDuration);
_cancel->entity()->setText(tr::lng_call_cancel());
_screencast->setDuration(st::callPanelDuration);

initWindow();
initWidget();
Expand Down Expand Up @@ -299,6 +300,7 @@ void Panel::initControls() {

_decline->finishAnimating();
_cancel->finishAnimating();
_screencast->finishAnimating();
}

void Panel::setIncomingSize(QSize size) {
Expand Down Expand Up @@ -595,6 +597,7 @@ void Panel::showControls() {
widget()->showChildren();
_decline->setVisible(_decline->toggled());
_cancel->setVisible(_cancel->toggled());
_screencast->setVisible(_screencast->toggled());

const auto shown = !_incomingFrameSize.isEmpty();
_incoming->widget()->setVisible(shown);
Expand Down Expand Up @@ -753,12 +756,6 @@ void Panel::updateControlsGeometry() {
updateOutgoingVideoBubbleGeometry();
}

auto threeWidth = _answerHangupRedial->width()
+ st::callCancel.button.width
- _screencast->width();
_decline->moveToLeft((widget()->width() - threeWidth) / 2, _buttonsTop);
_cancel->moveToLeft((widget()->width() - threeWidth) / 2, _buttonsTop);

updateHangupGeometry();
}

Expand All @@ -779,22 +776,28 @@ void Panel::updateOutgoingVideoBubbleGeometry() {
}

void Panel::updateHangupGeometry() {
auto twoWidth = _answerHangupRedial->width() + _screencast->width();
auto threeWidth = twoWidth + st::callCancel.button.width;
auto rightFrom = (widget()->width() - threeWidth) / 2;
auto rightTo = (widget()->width() - twoWidth) / 2;
auto hangupProgress = (_call
&& _call->state() == State::WaitingUserConfirmation)
const auto isWaitingUser = (_call
&& _call->state() == State::WaitingUserConfirmation);
const auto hangupProgress = isWaitingUser
? 0.
: _hangupShownProgress.value(_hangupShown ? 1. : 0.);
auto hangupRight = anim::interpolate(rightFrom, rightTo, hangupProgress);
_answerHangupRedial->moveToRight(hangupRight, _buttonsTop);
_answerHangupRedial->setProgress(hangupProgress);
_mute->moveToRight(hangupRight - _mute->width(), _buttonsTop);
_screencast->moveToLeft(hangupRight - _mute->width(), _buttonsTop);
_camera->moveToLeft(
hangupRight - _mute->width() + _screencast->width(),
_buttonsTop);

// Screencast - Camera - Cancel/Decline - Answer/Hangup/Redial - Mute.
const auto buttonWidth = st::callCancel.button.width;
const auto cancelWidth = buttonWidth * (1. - hangupProgress);
const auto cancelLeft = (isWaitingUser)
? ((widget()->width() - buttonWidth) / 2)
: (_mute->animating())
? ((widget()->width() - cancelWidth) / 2)
: ((widget()->width() / 2) - cancelWidth);

_cancel->moveToLeft(cancelLeft, _buttonsTop);
_decline->moveToLeft(cancelLeft, _buttonsTop);
_camera->moveToLeft(cancelLeft - buttonWidth, _buttonsTop);
_screencast->moveToLeft(_camera->x() - buttonWidth, _buttonsTop);
_answerHangupRedial->moveToLeft(cancelLeft + cancelWidth, _buttonsTop);
_mute->moveToLeft(_answerHangupRedial->x() + buttonWidth, _buttonsTop);
if (_startVideo) {
_startVideo->moveToLeft(_camera->x(), _camera->y());
}
Expand Down Expand Up @@ -877,7 +880,9 @@ void Panel::stateChanged(State state) {
toggleButton(_decline, incomingWaiting);
toggleButton(_cancel, (isBusy || isWaitingUser));
toggleButton(_mute, !isWaitingUser);
toggleButton(_screencast, !isWaitingUser);
toggleButton(
_screencast,
!(isBusy || isWaitingUser || incomingWaiting));
const auto hangupShown = !_decline->toggled()
&& !_cancel->toggled();
if (_hangupShown != hangupShown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct MessageToEdit {
struct VoiceToSend {
QByteArray bytes;
VoiceWaveform waveform;
int duration = 0;
crl::time duration = 0;
Api::SendOptions options;
};
struct SendActionUpdate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ enum class FilterType {
return std::clamp(float64(low) / high, 0., 1.);
}

[[nodiscard]] auto Duration(int samples) {
return samples / ::Media::Player::kDefaultFrequency;
[[nodiscard]] crl::time Duration(int samples) {
return samples * crl::time(1000) / ::Media::Player::kDefaultFrequency;
}

[[nodiscard]] auto FormatVoiceDuration(int samples) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ namespace {
result.preview = kEmpty;
result.spoilerRepaint = nullptr;
} else {
result.preview = preview->original();
result.preview = Images::Round(
preview->original(),
ImageRoundRadius::Small);
result.spoilerRepaint = spoiler ? repaint : nullptr;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ void ScheduledWidget::send(Api::SendOptions options) {
void ScheduledWidget::sendVoice(
QByteArray bytes,
VoiceWaveform waveform,
int duration) {
crl::time duration) {
const auto callback = [=](Api::SendOptions options) {
sendVoice(bytes, waveform, duration, options);
};
Expand All @@ -617,7 +617,7 @@ void ScheduledWidget::sendVoice(
void ScheduledWidget::sendVoice(
QByteArray bytes,
VoiceWaveform waveform,
int duration,
crl::time duration,
Api::SendOptions options) {
session().api().sendVoiceMessage(
bytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,14 @@ class ScheduledWidget final
Api::SendOptions options) const;
void send();
void send(Api::SendOptions options);
void sendVoice(QByteArray bytes, VoiceWaveform waveform, int duration);
void sendVoice(
QByteArray bytes,
VoiceWaveform waveform,
int duration,
crl::time duration);
void sendVoice(
QByteArray bytes,
VoiceWaveform waveform,
crl::time duration,
Api::SendOptions options);
void edit(
not_null<HistoryItem*> item,
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ For license and copyright information please follow this link:
#include "core/sandbox.h"
#include "core/application.h"
#include "export/export_manager.h"
#include "inline_bots/bot_attach_web_view.h" // AttachWebView::cancel.
#include "intro/intro_widget.h"
#include "main/main_session.h"
#include "main/main_account.h" // Account::sessionValue.
Expand Down Expand Up @@ -198,6 +199,9 @@ void MainWindow::setupPasscodeLock() {
_passcodeLock->showFinished();
setInnerFocus();
}
if (const auto sessionController = controller().sessionController()) {
sessionController->session().attachWebView().cancel();
}
}

void MainWindow::clearPasscodeLock() {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/media/audio/media_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ Ui::PreparedFileInformation PrepareForSending(
FFMpegAttributesReader reader(Core::FileLocation(fname), data);
const auto positionMs = crl::time(0);
if (reader.open(positionMs) && reader.duration() > 0) {
result.duration = reader.duration() / 1000;
result.duration = reader.duration();
result.title = reader.title();
result.performer = reader.performer();
result.cover = reader.cover();
Expand Down
6 changes: 6 additions & 0 deletions Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,12 @@ void OverlayWidget::show(OpenRequest request) {
// Count top notch on macOS before counting geometry.
_helper->beforeShow(_fullscreen);
}
if (_cachedShow) {
_cachedShow->showOrHideBoxOrLayer(
v::null,
Ui::LayerOption::CloseOther,
anim::type::instant);
}
if (photo) {
if (contextItem && contextPeer) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ QByteArray DnsUserAgent() {
static const auto kResult = QByteArray(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/114.0.5735.133 Safari/537.36");
"Chrome/115.0.5790.102 Safari/537.36");
return kResult;
}

Expand Down
Loading

0 comments on commit c7246ae

Please sign in to comment.